@webority/mobile-chat 0.135.1 → 0.137.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 (61) hide show
  1. package/lib/commonjs/AgentByline.js +1 -1
  2. package/lib/commonjs/ChatComposer.js +1 -1
  3. package/lib/commonjs/ChatFrame.js +1 -1
  4. package/lib/commonjs/ChatLauncher.js +1 -1
  5. package/lib/commonjs/ChatLiveBar.js +1 -1
  6. package/lib/commonjs/ChatMessageActions.js +1 -1
  7. package/lib/commonjs/ChatSheet.js +1 -1
  8. package/lib/commonjs/ChatStarters.js +1 -1
  9. package/lib/commonjs/ChatThread.js +1 -1
  10. package/lib/commonjs/chatShared.js +1 -1
  11. package/lib/commonjs/loaders/ReplyRing.js +1 -0
  12. package/lib/commonjs/renderers/ActionPart.js +1 -1
  13. package/lib/commonjs/renderers/InputRequestPart.js +1 -1
  14. package/lib/commonjs/renderers/QuickRepliesPart.js +1 -1
  15. package/lib/commonjs/renderers/TextPart.js +1 -1
  16. package/lib/commonjs/renderers/chipLook.js +1 -0
  17. package/lib/commonjs/speech/azureSpeech.js +1 -1
  18. package/lib/commonjs/useChat.js +1 -1
  19. package/lib/commonjs/useTranscriptActions.js +1 -1
  20. package/lib/module/AgentByline.js +1 -1
  21. package/lib/module/ChatComposer.js +1 -1
  22. package/lib/module/ChatFrame.js +1 -1
  23. package/lib/module/ChatLauncher.js +1 -1
  24. package/lib/module/ChatLiveBar.js +1 -1
  25. package/lib/module/ChatMessageActions.js +1 -1
  26. package/lib/module/ChatSheet.js +1 -1
  27. package/lib/module/ChatStarters.js +1 -1
  28. package/lib/module/ChatThread.js +1 -1
  29. package/lib/module/chatShared.js +1 -1
  30. package/lib/module/loaders/ReplyRing.js +1 -0
  31. package/lib/module/renderers/ActionPart.js +1 -1
  32. package/lib/module/renderers/InputRequestPart.js +1 -1
  33. package/lib/module/renderers/QuickRepliesPart.js +1 -1
  34. package/lib/module/renderers/TextPart.js +1 -1
  35. package/lib/module/renderers/chipLook.js +1 -0
  36. package/lib/module/speech/azureSpeech.js +1 -1
  37. package/lib/module/useChat.js +1 -1
  38. package/lib/module/useTranscriptActions.js +1 -1
  39. package/lib/typescript/commonjs/AgentByline.d.ts +2 -1
  40. package/lib/typescript/commonjs/ChatComposer.d.ts +6 -3
  41. package/lib/typescript/commonjs/ChatFrame.d.ts +3 -3
  42. package/lib/typescript/commonjs/ChatLauncher.d.ts +6 -2
  43. package/lib/typescript/commonjs/ChatStarters.d.ts +4 -1
  44. package/lib/typescript/commonjs/ChatThread.d.ts +10 -4
  45. package/lib/typescript/commonjs/chatShared.d.ts +1 -0
  46. package/lib/typescript/commonjs/loaders/ReplyRing.d.ts +9 -0
  47. package/lib/typescript/commonjs/renderers/chipLook.d.ts +7 -0
  48. package/lib/typescript/commonjs/types.d.ts +6 -1
  49. package/lib/typescript/commonjs/useChat.d.ts +3 -1
  50. package/lib/typescript/module/AgentByline.d.ts +2 -1
  51. package/lib/typescript/module/ChatComposer.d.ts +6 -3
  52. package/lib/typescript/module/ChatFrame.d.ts +3 -3
  53. package/lib/typescript/module/ChatLauncher.d.ts +6 -2
  54. package/lib/typescript/module/ChatStarters.d.ts +4 -1
  55. package/lib/typescript/module/ChatThread.d.ts +10 -4
  56. package/lib/typescript/module/chatShared.d.ts +1 -0
  57. package/lib/typescript/module/loaders/ReplyRing.d.ts +9 -0
  58. package/lib/typescript/module/renderers/chipLook.d.ts +7 -0
  59. package/lib/typescript/module/types.d.ts +6 -1
  60. package/lib/typescript/module/useChat.d.ts +3 -1
  61. package/package.json +12 -11
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AgentByline=AgentByline;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");function AgentByline({author:e,labels:i}){const t=(0,_mobileUi.useTheme)(),r=e.displayName||i.agent,a=e.avatarUrl?{uri:e.avatarUrl}:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:"row",alignItems:"center",gap:t.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Avatar,{size:"xs",name:r,source:a}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:r}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",children:i.agent})]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AgentByline=AgentByline;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");function AgentByline({author:e,labels:i,showAvatar:t=!0}){const r=(0,_mobileUi.useTheme)(),a=e.displayName||i.agent,n=e.avatarUrl?{uri:e.avatarUrl}:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:"row",alignItems:"center",gap:r.space.xs},children:[t?(0,_jsxRuntime.jsx)(_mobileUi.Avatar,{size:"xs",name:a,source:n}):null,(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:a}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",children:i.agent})]})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatComposer=ChatComposer;var _chatCore=require("@webority/chat-core"),_permissions=require("@webority/mobile-core/permissions"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ChatDictationButton=require("./ChatDictationButton.js"),_ChatFooter=require("./ChatFooter.js"),_speechText=require("./speech/speechText.js"),_jsxRuntime=require("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};function ChatComposer({chat:e,labels:t,pickAttachments:s,keyboardOffset:a,keyboardAware:i,safeArea:n,testID:o="chat-composer",focusRef:r,look:l=_chatCore.defaultChatLook}){const c=(0,_mobileUi.useTheme)(),u=(0,_react.useMemo)(()=>buildStyles(c),[c]),[m,h]=(0,_react.useState)(""),[p,d]=(0,_react.useState)(null),_=e.editing,x=(0,_react.useRef)(null),f=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(r)return r.current=()=>f.current?.focus(),()=>{r.current=null}},[r]),(0,_react.useEffect)(()=>{_&&x.current?.(),h(_?_.text:"")},[_]);const g=e.attachments,b=g.some(e=>"Uploading"===e.status),j=g.some(e=>"Ready"===e.status),v=e.messagesLeftToday,y=e.profile?.limits.maxMessageLength??DEFAULT_MAX_LENGTH,R=void 0!==s&&e.features.Attachments&&(e.profile?.limits.maxAttachments??0)>0,C=e.features.HumanHandoff&&("WaitingForAgent"===e.conversationState||"WithAgent"===e.conversationState),A=R&&!e.handoffPause?(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"paperclip",accessibilityLabel:t.attach,variant:"ghost",tone:"neutral",onPress:()=>{s&&s().then(t=>e.attach(t))},testID:`${o}-attach`}):void 0,T=_?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{message:t.editing,accessibilityRole:"summary",actions:[{label:t.cancel,onPress:()=>e.cancelEdit()}],testID:`${o}-editing`}):null,S=g.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:u.tray,testID:`${o}-attachments`,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:u.row,children:g.map(s=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:u.item,children:[(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:s.fileName,variant:"soft",onRemove:()=>{e.removeAttachment(s.key)},labels:{remove:t.removeAttachment},removeTestID:`${o}-remove-${s.key}`,testID:`${o}-chip-${s.key}`}),"Uploading"===s.status?(0,_jsxRuntime.jsx)(_mobileUi.ProgressBar,{progress:s.progress??void 0,label:t.attachmentUploading,height:4,containerStyle:u.progress}):null,"Failed"===s.status?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:s.error??t.attachmentFailed}):null]},s.key))})}):null,D=null!==v&&v<=ALLOWANCE_SHOWN_AT?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:0===v?"danger":"secondary",accessibilityLiveRegion:"polite",testID:`${o}-allowance`,children:t.allowance(v)}):null,U=p?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{message:p.message,tone:p.tone,dismissible:!0,onClose:()=>d(null),actions:p.openSettings?[{label:t.dictateOpenSettings,onPress:()=>{_permissions.Permissions.openSettings()}}]:void 0,testID:`${o}-voice-notice`}):null,w=m.length>0,L=m.length>y*COUNTER_AT?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",testID:`${o}-counter`,children:t.counter(m.length,y)}):null,N=T||S||D||L||U?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[T,S,D,L,U]}):void 0,k=!b&&(!!j||void 0);return(0,_jsxRuntime.jsx)(_mobileUi.Composer,{ref:f,onSend:t=>{x.current?.(),e.submit(t)},value:m,onChangeText:t=>{x.current?.(),h(t),C&&t.length>0&&e.notifyTyping()},loading:e.streaming&&e.features.Stop,ring:l.input.ring&&(w||e.streaming),sendReveal:"Always"===l.input.sendReveal?"always":"onText",onStop:e.features.Stop?()=>e.stop():void 0,stopLabel:t.stop,disabled:0===v||e.handoffPause,maxLength:y,canSend:k,placeholder:e.handoffPause?t.handoffMoment:openQuestion(e.messages)??t.placeholder,accessibilityLabel:t.composer,labels:{send:t.send},leading:A,trailing:(0,_jsxRuntime.jsx)(_ChatDictationButton.ChatDictationButton,{chat:e,labels:t,disabled:0===v||e.handoffPause,onText:e=>h(t=>(0,_speechText.joinDictation)(t,e,y)),onNotice:d,stopRef:x}),above:N,below:(0,_jsxRuntime.jsx)(_ChatFooter.ChatFooter,{chat:e,labels:t}),keyboardAware:i,keyboardOffset:a,safeArea:n,testID:o})}const buildStyles=e=>_reactNative.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}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatComposer=ChatComposer;var _chatCore=require("@webority/chat-core"),_permissions=require("@webority/mobile-core/permissions"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ChatDictationButton=require("./ChatDictationButton.js"),_ChatFooter=require("./ChatFooter.js"),_speechText=require("./speech/speechText.js"),_jsxRuntime=require("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};function ChatComposer({chat:e,labels:t,pickAttachments:s,keyboardOffset:a,keyboardAware:i,safeArea:n,testID:o="chat-composer",focusRef:r,look:l=_chatCore.defaultChatLook,sendIcon:c}){const u=(0,_mobileUi.useTheme)(),m=(0,_react.useMemo)(()=>buildStyles(u),[u]),[h,d]=(0,_react.useState)(""),[p,_]=(0,_react.useState)(null),x=e.editing,f=(0,_react.useRef)(null),g=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(r)return r.current=()=>g.current?.focus(),()=>{r.current=null}},[r]),(0,_react.useEffect)(()=>{x&&f.current?.(),d(x?x.text:"")},[x]);const b=e.attachments,j=b.some(e=>"Uploading"===e.status),v=b.some(e=>"Ready"===e.status),y=e.messagesLeftToday,R=e.profile?.limits.maxMessageLength??DEFAULT_MAX_LENGTH,C=void 0!==s&&e.features.Attachments&&(e.profile?.limits.maxAttachments??0)>0,A=e.features.HumanHandoff&&("WaitingForAgent"===e.conversationState||"WithAgent"===e.conversationState),T=C&&!e.handoffPause?(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"paperclip",accessibilityLabel:t.attach,variant:"ghost",tone:"neutral",onPress:()=>{s&&s().then(t=>e.attach(t))},testID:`${o}-attach`}):void 0,S=x?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{message:t.editing,accessibilityRole:"summary",actions:[{label:t.cancel,onPress:()=>e.cancelEdit()}],testID:`${o}-editing`}):null,D=b.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:m.tray,testID:`${o}-attachments`,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:m.row,children:b.map(s=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:m.item,children:[(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:s.fileName,variant:"soft",onRemove:()=>{e.removeAttachment(s.key)},labels:{remove:t.removeAttachment},removeTestID:`${o}-remove-${s.key}`,testID:`${o}-chip-${s.key}`}),"Uploading"===s.status?(0,_jsxRuntime.jsx)(_mobileUi.ProgressBar,{progress:s.progress??void 0,label:t.attachmentUploading,height:4,containerStyle:m.progress}):null,"Failed"===s.status?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:s.error??t.attachmentFailed}):null]},s.key))})}):null,U=null!==y&&y<=ALLOWANCE_SHOWN_AT?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:0===y?"danger":"secondary",accessibilityLiveRegion:"polite",testID:`${o}-allowance`,children:t.allowance(y)}):null,w=p?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{message:p.message,tone:p.tone,dismissible:!0,onClose:()=>_(null),actions:p.openSettings?[{label:t.dictateOpenSettings,onPress:()=>{_permissions.Permissions.openSettings()}}]:void 0,testID:`${o}-voice-notice`}):null,L=h.length>0,N=h.length>R*COUNTER_AT?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",testID:`${o}-counter`,children:t.counter(h.length,R)}):null,I=S||D||U||N||w?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[S,D,U,N,w]}):void 0,k=!j&&(!!v||void 0);return(0,_jsxRuntime.jsx)(_mobileUi.Composer,{ref:g,onSend:t=>{f.current?.(),e.submit(t)},value:h,onChangeText:t=>{f.current?.(),d(t),A&&t.length>0&&e.notifyTyping()},loading:e.streaming&&e.features.Stop,ring:l.input.ring&&(L||e.streaming),sendReveal:"Always"===l.input.sendReveal?"always":"onText",sendIcon:c||void 0,onStop:e.features.Stop?()=>e.stop():void 0,stopLabel:t.stop,disabled:0===y||e.handoffPause,maxLength:R,canSend:k,placeholder:e.handoffPause?t.handoffMoment:openQuestion(e.messages)??t.placeholder,accessibilityLabel:t.composer,labels:{send:t.send},leading:T,trailing:(0,_jsxRuntime.jsx)(_ChatDictationButton.ChatDictationButton,{chat:e,labels:t,disabled:0===y||e.handoffPause,onText:e=>d(t=>(0,_speechText.joinDictation)(t,e,R)),onNotice:_,stopRef:f}),above:I,below:(0,_jsxRuntime.jsx)(_ChatFooter.ChatFooter,{chat:e,labels:t}),keyboardAware:i,keyboardOffset:a,safeArea:n,testID:o})}const buildStyles=e=>_reactNative.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}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatFrame=ChatFrame;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ChatComposer=require("./ChatComposer.js"),_ChatConversationActions=require("./ChatConversationActions.js"),_ChatHistory=require("./ChatHistory.js"),_ChatLiveBar=require("./ChatLiveBar.js"),_ChatPanel=require("./ChatPanel.js"),_ChatStarters=require("./ChatStarters.js"),_ChatThread=require("./ChatThread.js"),_useChatHaptics=require("./useChatHaptics.js"),_useChatSound=require("./useChatSound.js"),_jsxRuntime=require("react/jsx-runtime");function ChatFrame({chat:e,labels:t,renderers:s,layoutParts:a,loader:r="Steps",look:i,pickAttachments:o,onOpenAttachment:n,onOpenTarget:l,onNavigate:u,openTicket:c,handoffHosts:h,resolveLink:m,keyboardOffset:d,layout:_,title:C,headerActions:x,onClose:j,enterKey:b=0,testID:p="chat-frame"}){const v=(0,_mobileUi.useTheme)(),f=(0,_react.useMemo)(()=>(0,_chatCore.mergeLook)(i),[i]),y=(0,_mobileUi.useReducedMotion)(),R="Reduced"===f.motion||y,g="embedded"===_?"None":f.panel.motion,I="sheet"===_?"sheet":"screen",k=(0,_react.useMemo)(()=>(0,_ChatPanel.panelRun)({motion:g,reduced:R,mode:I,run:b}),[g,R,I,b]),[w,D]=(0,_react.useState)(!1),P=w&&!0===e.features.History;(0,_useChatHaptics.useChatHaptics)(e),(0,_useChatSound.useChatSound)(e);const S="sheet"!==_,q=null!==e.profile,T=(0,_react.useRef)(null);if(q&&!e.features.VisitorChat)return null;const H=e.messages.length>0,$=e.messages.some(e=>"Visitor"===e.author.kind||"Customer"===e.author.kind),A="screen"===_||$,B=!0===e.profile?.experience.sound.muteControl&&e.features.Sounds,L=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:v.space.sm,paddingHorizontal:v.space.md,paddingVertical:v.space.sm,borderBottomWidth:1,borderBottomColor:v.colors["border-subtle"]},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1,minWidth:0},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"title",accessibilityRole:"header",numberOfLines:1,children:C??e.profile?.assistant.name??t.panelTitle}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:t.headerStatus})]}),x,P?null:(0,_jsxRuntime.jsx)(_ChatConversationActions.ChatConversationActions,{chat:e,labels:t,testID:`${p}-conversation-actions`}),e.features.History?(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:P?"arrow-left":"history",variant:"ghost",tone:"neutral",accessibilityLabel:P?t.backToChat:t.history,onPress:()=>D(e=>!e),testID:`${p}-history`}):null,B?(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:e.muted?"volume-mute":"volume-high",variant:"ghost",tone:"neutral",accessibilityLabel:e.muted?t.unmuteSounds:t.muteSounds,onPress:()=>e.session.setMuted(!e.muted),testID:`${p}-mute`}):null,P||!A?null:(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"plus",variant:"ghost",tone:"neutral",accessibilityLabel:t.newChat,disabled:e.streaming||e.thinking,onPress:()=>e.newConversation(),testID:`${p}-new`}),j?(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"x",variant:"ghost",tone:"neutral",accessibilityLabel:t.close,onPress:j,testID:`${p}-close`}):null]});let U;return U=P?(0,_jsxRuntime.jsx)(_ChatHistory.ChatHistory,{chat:e,labels:t,onOpen:()=>D(!1),testID:`${p}-history-list`}):e.profileError?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"danger",message:e.profileError.message,accessibilityRole:"alert",testID:`${p}-profile-error`}):!q||e.loading?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,alignItems:"center",justifyContent:"center"},children:(0,_jsxRuntime.jsx)(_mobileUi.Spinner,{message:t.loadingConversation,testID:`${p}-loading`})}):e.loadError?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"danger",message:e.loadError.message,accessibilityRole:"alert",testID:`${p}-load-error`}):H?(0,_jsxRuntime.jsx)(_ChatThread.ChatThread,{chat:e,labels:t,renderers:s,layoutParts:a,loader:r,motion:f.motion,pickAttachments:o,onOpenAttachment:n,onOpenTarget:l,onNavigate:u,openTicket:c,handoffHosts:h,resolveLink:m,focusComposer:()=>T.current?.(),keyboardAware:S,keyboardOffset:d,style:{flex:1},testID:`${p}-thread`}):(0,_jsxRuntime.jsx)(_ChatStarters.ChatStarters,{chat:e,labels:t,openTicket:c,testID:`${p}-starters`}),(0,_jsxRuntime.jsx)(_ChatPanel.ChatPanelGrow,{grow:k.grow,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1},testID:p,children:[(0,_jsxRuntime.jsx)(_ChatPanel.ChatReveal,{plan:k.reveal.header,children:L}),P?null:(0,_jsxRuntime.jsx)(_ChatLiveBar.ChatLiveBar,{chat:e,labels:t,testID:`${p}-live`}),(0,_jsxRuntime.jsx)(_ChatPanel.ChatReveal,{plan:k.reveal.body,flex:!0,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1},children:U})}),P?null:(0,_jsxRuntime.jsx)(_ChatPanel.ChatReveal,{plan:k.reveal.composer,children:(0,_jsxRuntime.jsx)(_ChatComposer.ChatComposer,{chat:e,labels:t,look:f,pickAttachments:o,keyboardOffset:d,keyboardAware:S,focusRef:T,testID:`${p}-composer`})})]})})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatFrame=ChatFrame;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ChatComposer=require("./ChatComposer.js"),_ChatConversationActions=require("./ChatConversationActions.js"),_ChatHistory=require("./ChatHistory.js"),_ChatLiveBar=require("./ChatLiveBar.js"),_ChatPanel=require("./ChatPanel.js"),_ChatStarters=require("./ChatStarters.js"),_ChatThread=require("./ChatThread.js"),_chatShared=require("./chatShared.js"),_useChatHaptics=require("./useChatHaptics.js"),_useChatSound=require("./useChatSound.js"),_jsxRuntime=require("react/jsx-runtime");const lastAgentName=e=>{for(let t=e.length-1;t>=0;t-=1){const a=e[t]?.author;if("Agent"===a?.kind&&a.displayName?.trim())return a.displayName}return null},headerStatusText=(e,t)=>"WaitingForAgent"===e.conversationState?t.statusWaitingForAgent:"WithAgent"===e.conversationState?t.statusWithAgent(lastAgentName(e.messages)??t.handoffAgentFallback):t.headerStatus;function ChatFrame({chat:e,labels:t,renderers:a,layoutParts:s,loader:r="Steps",look:i,pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:u,openTicket:c,handoffHosts:h,resolveLink:m,keyboardOffset:d,layout:_,title:x,headerActions:C,onClose:j,enterKey:p=0,testID:b="chat-frame"}){const v=(0,_mobileUi.useTheme)(),g=(0,_react.useMemo)(()=>(0,_chatCore.mergeLook)(i),[i]),y=(0,_mobileUi.useReducedMotion)(),f="Reduced"===g.motion||y,R="embedded"===_?"None":g.panel.motion,A="sheet"===_?"sheet":"screen",I=(0,_react.useMemo)(()=>(0,_ChatPanel.panelRun)({motion:R,reduced:f,mode:A,run:p}),[R,f,A,p]),[S,k]=(0,_react.useState)(!1),w=S&&!0===e.features.History;(0,_useChatHaptics.useChatHaptics)(e),(0,_useChatSound.useChatSound)(e);const T="sheet"!==_,D=null!==e.profile,q=(0,_react.useRef)(null);if(D&&!e.features.VisitorChat)return null;const L=e.messages.length>0,N=e.messages.some(e=>"Visitor"===e.author.kind||"Customer"===e.author.kind),P="screen"===_||N,H=!0===e.profile?.experience.sound.muteControl&&e.features.Sounds,B=x??e.profile?.assistant.name??t.panelTitle,U=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:v.space.sm,paddingHorizontal:v.space.md,paddingVertical:v.space.sm,borderBottomWidth:1,borderBottomColor:v.colors["border-subtle"]},children:[g.avatar?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_jsxRuntime.jsx)(_mobileUi.Avatar,{size:"sm",name:e.profile?.assistant.name??t.panelTitle,source:{uri:g.avatar}})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1,minWidth:0},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"title",numberOfLines:1,..._chatShared.WEB_STRONG,children:B}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:headerStatusText(e,t)})]}),C,w?null:(0,_jsxRuntime.jsx)(_ChatConversationActions.ChatConversationActions,{chat:e,labels:t,testID:`${b}-conversation-actions`}),e.features.History?(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:w?"arrow-left":"history",variant:"ghost",tone:"neutral",accessibilityLabel:w?t.backToChat:t.history,onPress:()=>k(e=>!e),testID:`${b}-history`}):null,H?(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:e.muted?"volume-mute":"volume-high",variant:"ghost",tone:"neutral",accessibilityLabel:e.muted?t.unmuteSounds:t.muteSounds,onPress:()=>e.session.setMuted(!e.muted),testID:`${b}-mute`}):null,w||!P?null:(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"plus",variant:"ghost",tone:"neutral",accessibilityLabel:t.newChat,disabled:e.streaming||e.thinking,onPress:()=>e.newConversation(),testID:`${b}-new`}),j?(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"x",variant:"ghost",tone:"neutral",accessibilityLabel:t.close,onPress:j,testID:`${b}-close`}):null]});let $;return $=w?(0,_jsxRuntime.jsx)(_ChatHistory.ChatHistory,{chat:e,labels:t,onOpen:()=>k(!1),testID:`${b}-history-list`}):e.profileError?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"danger",message:e.profileError.message,accessibilityRole:"alert",testID:`${b}-profile-error`}):!D||e.loading?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,alignItems:"center",justifyContent:"center"},children:(0,_jsxRuntime.jsx)(_mobileUi.Spinner,{message:t.loadingConversation,testID:`${b}-loading`})}):e.loadError?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"danger",message:e.loadError.message,accessibilityRole:"alert",testID:`${b}-load-error`}):L?(0,_jsxRuntime.jsx)(_ChatThread.ChatThread,{chat:e,labels:t,renderers:a,layoutParts:s,loader:r,motion:g.motion,avatar:g.avatar,replyAvatars:g.panel.replyAvatars,expressive:g.expressive,pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:u,openTicket:c,handoffHosts:h,resolveLink:m,focusComposer:()=>q.current?.(),keyboardAware:T,keyboardOffset:d,style:{flex:1},testID:`${b}-thread`}):(0,_jsxRuntime.jsx)(_ChatStarters.ChatStarters,{chat:e,labels:t,openTicket:c,avatar:g.avatar,motion:g.motion,greetingLoaderMs:f?0:g.panel.greetingLoaderMs,testID:`${b}-starters`}),(0,_jsxRuntime.jsx)(_ChatPanel.ChatPanelGrow,{grow:I.grow,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1},role:"sheet"===_?"dialog":"region",accessibilityLabel:B,testID:b,children:[(0,_jsxRuntime.jsx)(_ChatPanel.ChatReveal,{plan:I.reveal.header,children:U}),w?null:(0,_jsxRuntime.jsx)(_ChatLiveBar.ChatLiveBar,{chat:e,labels:t,testID:`${b}-live`}),(0,_jsxRuntime.jsx)(_ChatPanel.ChatReveal,{plan:I.reveal.body,flex:!0,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1},children:$})}),w?null:(0,_jsxRuntime.jsx)(_ChatPanel.ChatReveal,{plan:I.reveal.composer,children:(0,_jsxRuntime.jsx)(_ChatComposer.ChatComposer,{chat:e,labels:t,look:g,sendIcon:i?.input?.sendIcon,pickAttachments:n,keyboardOffset:d,keyboardAware:T,focusRef:q,testID:`${b}-composer`})})]})})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatLauncher=ChatLauncher;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_jsxRuntime=require("react/jsx-runtime");const RISE_MS=900,RISE_DELAY_MS=400,ENTRANCE_MS=800,ENTRANCE_DELAY_MS=1e3,FLOAT_HALF_MS=1600,FLOAT_PX=4,RISE_FROM_PX=116;function entranceStyle(e,t){const range=(e,a)=>t.interpolate({inputRange:e,outputRange:a,extrapolate:"clamp"});switch(e){case"Rise":return{opacity:range([0,.4,1],[0,1,1]),transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[116,0]})}]};case"SlideUp":return{opacity:range([0,1],[0,1]),transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[100,0]})},{scale:t.interpolate({inputRange:[0,1],outputRange:[.8,1]})}]};case"BounceIn":return{transform:[{scale:range([0,.5,.7,1],[.3,1.05,.9,1])}]};case"FadeInPulse":return{opacity:range([0,.5,1],[0,1,1]),transform:[{scale:range([0,.5,1],[1,1.1,1])}]};case"SpinScale":return{transform:[{rotate:t.interpolate({inputRange:[0,1],outputRange:["-180deg","0deg"]})},{scale:t.interpolate({inputRange:[0,1],outputRange:[0,1]})}]};case"WiggleIn":return{transform:[{translateY:range([0,.4,1],[100,0,0])},{rotate:range([0,.4,.6,.8,1],["-10deg","5deg","-3deg","1deg","0deg"])}]};case"ElasticIn":return{transform:[{scale:range([0,.55,.75,1],[0,1.1,.95,1])}]};default:return{transform:[]}}}const OVERSHOOT=new Set(["Rise","SlideUp","SpinScale"]);function ChatLauncher({look:e,label:t,side:a,offsetX:n,offsetY:r,enter:i,reduced:s,buttonRef:o,onPress:c,testID:u}){const l=(0,_mobileUi.useTheme)(),_=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),p=e.launcher.entrance,[g]=(0,_react.useState)(()=>i&&!s&&"None"!==p),d=!s&&"FloatAndPulse"===e.launcher.idle,[m]=(0,_react.useState)(()=>new _reactNative.Animated.Value(g?0:1)),[S]=(0,_react.useState)(()=>new _reactNative.Animated.Value(0));(0,_react.useEffect)(()=>{if(!g)return void m.setValue(1);const e="Rise"===p,t=_reactNative.Animated.timing(m,{toValue:1,duration:e?RISE_MS:ENTRANCE_MS,delay:e?RISE_DELAY_MS:ENTRANCE_DELAY_MS,easing:OVERSHOOT.has(p)?_reactNative.Easing.bezier(.34,e?1.4:1.56,.64,1):_reactNative.Easing.linear,useNativeDriver:!0});return t.start(),()=>t.stop()},[g,p,m]),(0,_react.useEffect)(()=>{if(!d)return void S.setValue(0);const e=_reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(S,{toValue:1,duration:FLOAT_HALF_MS,easing:_reactNative.Easing.inOut(_reactNative.Easing.ease),useNativeDriver:!0}),_reactNative.Animated.timing(S,{toValue:0,duration:FLOAT_HALF_MS,easing:_reactNative.Easing.inOut(_reactNative.Easing.ease),useNativeDriver:!0})]));return e.start(),()=>e.stop()},[d,S]);const f="Pill"===e.launcher.style&&!e.launcher.compact,R=l.space[l.components["floating-action-button"]["edge-offset"]]+n,v={position:"absolute",bottom:r+_.bottom,..."start"===a?{left:R}:{right:R}},N=entranceStyle(p,m);return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"box-none",style:_reactNative.StyleSheet.absoluteFill,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[v,{opacity:N.opacity??1,transform:[...N.transform,{translateY:S.interpolate({inputRange:[0,1],outputRange:[0,-FLOAT_PX]})}]}],children:(0,_jsxRuntime.jsx)(_mobileUi.FloatingActionButton,{ref:o,icon:"messages",label:f?t:void 0,collapsed:!f,accessibilityLabel:t,onPress:c,testID:u})})})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatLauncher=ChatLauncher;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_jsxRuntime=require("react/jsx-runtime");const RISE_MS=900,RISE_DELAY_MS=400,ENTRANCE_MS=800,ENTRANCE_DELAY_MS=1e3,FLOAT_HALF_MS=1600,FLOAT_PX=4,RISE_FROM_PX=116,SHRINK_MS=320,SHRINK_EASING=_reactNative.Easing.bezier(.4,0,.2,1);function entranceStyle(e,t){const range=(e,a)=>t.interpolate({inputRange:e,outputRange:a,extrapolate:"clamp"});switch(e){case"Rise":return{opacity:range([0,.4,1],[0,1,1]),transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[116,0]})}]};case"SlideUp":return{opacity:range([0,1],[0,1]),transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[100,0]})},{scale:t.interpolate({inputRange:[0,1],outputRange:[.8,1]})}]};case"BounceIn":return{transform:[{scale:range([0,.5,.7,1],[.3,1.05,.9,1])}]};case"FadeInPulse":return{opacity:range([0,.5,1],[0,1,1]),transform:[{scale:range([0,.5,1],[1,1.1,1])}]};case"SpinScale":return{transform:[{rotate:t.interpolate({inputRange:[0,1],outputRange:["-180deg","0deg"]})},{scale:t.interpolate({inputRange:[0,1],outputRange:[0,1]})}]};case"WiggleIn":return{transform:[{translateY:range([0,.4,1],[100,0,0])},{rotate:range([0,.4,.6,.8,1],["-10deg","5deg","-3deg","1deg","0deg"])}]};case"ElasticIn":return{transform:[{scale:range([0,.55,.75,1],[0,1.1,.95,1])}]};default:return{transform:[]}}}const OVERSHOOT=new Set(["Rise","SlideUp","SpinScale"]);function ChatLauncher({look:e,hidden:t,label:a,side:n,offsetX:r,offsetY:i,enter:s,reduced:o,mark:u="Icon",avatar:c=null,buttonRef:l,onPress:_,testID:m}){const d=(0,_mobileUi.useTheme)(),p=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),S=e.launcher.entrance,g="Avatar"===u&&c?c:null,v=d.components["floating-action-button"].md.diameter,[N]=(0,_react.useState)(()=>s&&!o&&"None"!==S),f=t&&e.expressive&&!o,R=!o&&!t&&"FloatAndPulse"===e.launcher.idle,[A]=(0,_react.useState)(()=>new _reactNative.Animated.Value(N?0:1)),[E]=(0,_react.useState)(()=>new _reactNative.Animated.Value(0)),[b]=(0,_react.useState)(()=>new _reactNative.Animated.Value(1)),[h,I]=(0,_react.useState)(!1);if((0,_react.useEffect)(()=>{if(!t)return b.setValue(1),void I(!1);if(!f)return;const e=_reactNative.Animated.timing(b,{toValue:0,duration:SHRINK_MS,easing:SHRINK_EASING,useNativeDriver:!0});return e.start(({finished:e})=>{e&&I(!0)}),()=>e.stop()},[t,f,b]),(0,_react.useEffect)(()=>{if(!N)return void A.setValue(1);const e="Rise"===S,t=_reactNative.Animated.timing(A,{toValue:1,duration:e?RISE_MS:ENTRANCE_MS,delay:e?RISE_DELAY_MS:ENTRANCE_DELAY_MS,easing:OVERSHOOT.has(S)?_reactNative.Easing.bezier(.34,e?1.4:1.56,.64,1):_reactNative.Easing.linear,useNativeDriver:!0});return t.start(),()=>t.stop()},[N,S,A]),(0,_react.useEffect)(()=>{if(!R)return void E.setValue(0);const e=_reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(E,{toValue:1,duration:FLOAT_HALF_MS,easing:_reactNative.Easing.inOut(_reactNative.Easing.ease),useNativeDriver:!0}),_reactNative.Animated.timing(E,{toValue:0,duration:FLOAT_HALF_MS,easing:_reactNative.Easing.inOut(_reactNative.Easing.ease),useNativeDriver:!0})]));return e.start(),()=>e.stop()},[R,E]),t&&(!f||h))return null;const x="Pill"===e.launcher.style&&!e.launcher.compact,y=d.space[d.components["floating-action-button"]["edge-offset"]]+r,L={position:"absolute",bottom:i+p.bottom,..."start"===n?{left:y}:{right:y}},M=entranceStyle(S,A);return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"box-none",style:_reactNative.StyleSheet.absoluteFill,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[L,{opacity:_reactNative.Animated.multiply(M.opacity??1,b),transform:[...M.transform,{scale:b},{translateY:E.interpolate({inputRange:[0,1],outputRange:[0,-FLOAT_PX]})}]}],children:(0,_jsxRuntime.jsx)(_mobileUi.FloatingActionButton,{ref:l,icon:g?(0,_jsxRuntime.jsx)(_mobileUi.Avatar,{dimension:v,name:a,source:{uri:g}}):"messages",label:x?a:void 0,collapsed:!x,accessibilityLabel:a,onPress:_,testID:m})})})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatLiveBar=ChatLiveBar;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const newestAgentName=(e,t)=>{for(let i=e.messages.length-1;i>=0;i-=1){const n=e.messages[i];if("Agent"===n?.author.kind)return n.author.displayName||t}return t};function ChatLiveBar({chat:e,labels:t,testID:i="chat-live-bar"}){const n=(0,_mobileUi.useTheme)();if(!e.features.HumanHandoff||null===e.conversationId)return null;const s=e.conversationState;if("Closed"===s)return null;if("Open"===s){return e.features.HumanHandoff&&e.messages.some(e=>"Visitor"===e.author.kind||"Customer"===e.author.kind)&&!e.streaming&&!e.thinking?(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityLiveRegion:"polite",style:{paddingHorizontal:n.space.md,paddingVertical:n.space.xs},testID:i,children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:t.talkToPerson,variant:"soft",size:"sm",leftIcon:"user",loading:e.handoffPending,onPress:()=>{e.requestHandoff()},testID:`${i}-talk`}),null!==e.handoffError?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:t.errorGeneric}):null]}):null}const a="Lost"===e.live,r="WaitingForAgent"===s?t.statusWaitingForAgent:t.statusWithAgent(newestAgentName(e,t.agent));return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityLiveRegion:"polite",style:{gap:n.space.xs,paddingHorizontal:n.space.md,paddingVertical:n.space.xs},testID:i,children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:r}),a?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"warning",message:t.liveLost,actions:[{label:t.retry,onPress:()=>e.resumeLive()}],testID:`${i}-lost`}):null]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatLiveBar=ChatLiveBar;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");function ChatLiveBar({chat:e,labels:i,testID:t="chat-live-bar"}){const n=(0,_mobileUi.useTheme)();if(!e.features.HumanHandoff||null===e.conversationId)return null;const s=e.conversationState;if("Closed"===s)return null;if("Open"===s){return e.features.HumanHandoff&&e.messages.some(e=>"Visitor"===e.author.kind||"Customer"===e.author.kind)&&!e.streaming&&!e.thinking?(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityLiveRegion:"polite",style:{paddingHorizontal:n.space.md,paddingVertical:n.space.xs},testID:t,children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:i.talkToPerson,variant:"soft",size:"sm",leftIcon:"user",loading:e.handoffPending,onPress:()=>{e.requestHandoff()},testID:`${t}-talk`}),null!==e.handoffError?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:i.errorGeneric}):null]}):null}return"Lost"!==e.live?null:(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityLiveRegion:"polite",style:{paddingHorizontal:n.space.md,paddingVertical:n.space.xs},testID:t,children:(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"warning",message:i.liveLost,actions:[{label:i.retry,onPress:()=>e.resumeLive()}],testID:`${t}-lost`})})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatMessageActions=ChatMessageActions;var _chatCore=require("@webority/chat-core"),_clipboard=require("@webority/mobile-core/clipboard"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ReadAloudButton=require("./ReadAloudButton.js"),_useTranscriptActions=_interopRequireDefault(require("./useTranscriptActions.js")),_jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const TEXT_AUTHORS=new Set(["Assistant","Agent","Script"]),RATED_AUTHORS=new Set(["Assistant","Agent"]);function ChatMessageActions({chat:e,message:t,labels:i,isLast:s,isLastVisitor:a,testID:r}){const n=(0,_mobileUi.useTheme)(),[l,o]=(0,_react.useState)(!1),[c,u]=(0,_react.useState)("idle"),d=(0,_react.useRef)(null),m=(0,_useTranscriptActions.default)(e,i),_=(0,_react.useMemo)(()=>TEXT_AUTHORS.has(t.author.kind)&&(0,_chatCore.buildTranscript)([t],{labels:i,title:null,figureText:!1}).entries.length>0,[t,i]);if((0,_react.useEffect)(()=>()=>{null!==d.current&&clearTimeout(d.current)},[]),t.streaming)return null;const h=(0,_chatCore.messagePlainText)(t.parts),g=TEXT_AUTHORS.has(t.author.kind)&&""!==h,x=t.stored&&RATED_AUTHORS.has(t.author.kind),b=("Assistant"===t.author.kind||"Agent"===t.author.kind||"Script"===t.author.kind)&&""!==(0,_chatCore.messagePlainText)(t.parts).trim(),p=s&&"Assistant"===t.author.kind&&!e.streaming&&!e.thinking&&e.features.Regenerate&&e.messages.some(e=>e.stored&&"Visitor"===e.author.kind),R=a&&t.stored&&e.features.Edit&&!e.streaming&&!e.thinking,save=async i=>{try{await e.rate(t.id,i),u("saved")}catch{u("failed")}};return g&&e.features.Copy||_&&e.features.Share&&m.canShare||b||p||R||x&&e.features.Rating?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:n.space.xs},testID:r,children:[g&&e.features.Copy?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:l?i.copied:i.copy,variant:"link",size:"sm",onPress:()=>{(async()=>{await(0,_clipboard.copyText)(h)&&(o(!0),null!==d.current&&clearTimeout(d.current),d.current=setTimeout(()=>o(!1),2e3))})()},testID:`${r}-copy`}):null,_&&e.features.Share&&m.canShare?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:i.share,variant:"link",size:"sm",leftIcon:"share",disabled:e.streaming||e.thinking,onPress:()=>{m.shareReply(t)},testID:`${r}-share`}):null,b?(0,_jsxRuntime.jsx)(_ReadAloudButton.ReadAloudButton,{chat:e,message:t,labels:i}):null,p?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:i.regenerate,variant:"link",size:"sm",onPress:()=>{e.regenerate()},testID:`${r}-regenerate`}):null,R?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:i.edit,variant:"link",size:"sm",onPress:()=>e.startEdit(t.id),testID:`${r}-edit`}):null,x&&e.features.Rating?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityRole:"summary",accessibilityLabel:i.rating,style:{flexDirection:"row",alignItems:"center",gap:n.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"like",accessibilityLabel:i.rateUp,tone:"neutral",size:"sm",variant:"Up"===t.rating?"soft":"ghost",accessibilityState:{checked:"Up"===t.rating},onPress:()=>{save("Up")},testID:`${r}-rate-up`}),(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"dislike",accessibilityLabel:i.rateDown,tone:"neutral",size:"sm",variant:"Down"===t.rating?"soft":"ghost",accessibilityState:{checked:"Down"===t.rating},onPress:()=>{save("Down")},testID:`${r}-rate-down`})]}),"failed"===c?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:i.ratingFailed}):null,"saved"===c?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:i.rated}):null]}):null,null!==m.notice?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:m.notice}):null]}):null}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatMessageActions=ChatMessageActions;var _chatCore=require("@webority/chat-core"),_clipboard=require("@webority/mobile-core/clipboard"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ReadAloudButton=require("./ReadAloudButton.js"),_useTranscriptActions=_interopRequireDefault(require("./useTranscriptActions.js")),_jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const TEXT_AUTHORS=new Set(["Assistant","Agent","Script"]),RATED_AUTHORS=new Set(["Assistant","Agent"]);function ChatMessageActions({chat:e,message:t,labels:i,isLast:s,isLastVisitor:a,testID:r}){const n=(0,_mobileUi.useTheme)(),[l,o]=(0,_react.useState)(!1),[c,u]=(0,_react.useState)("idle"),m=(0,_react.useRef)(null),d=(0,_useTranscriptActions.default)(e,i),_=(0,_react.useMemo)(()=>TEXT_AUTHORS.has(t.author.kind)&&(0,_chatCore.buildTranscript)([t],{labels:i,title:null,figureText:!1,assistantName:e.profile?.assistant.name}).entries.length>0,[t,i,e.profile]);if((0,_react.useEffect)(()=>()=>{null!==m.current&&clearTimeout(m.current)},[]),t.streaming)return null;const h=(0,_chatCore.messagePlainText)(t.parts),g=TEXT_AUTHORS.has(t.author.kind)&&""!==h,x=t.stored&&RATED_AUTHORS.has(t.author.kind),p=("Assistant"===t.author.kind||"Agent"===t.author.kind||"Script"===t.author.kind)&&""!==(0,_chatCore.messagePlainText)(t.parts).trim(),b=s&&"Assistant"===t.author.kind&&!e.streaming&&!e.thinking&&e.features.Regenerate&&e.messages.some(e=>e.stored&&"Visitor"===e.author.kind),R=a&&t.stored&&e.features.Edit&&!e.streaming&&!e.thinking,save=async i=>{try{await e.rate(t.id,i),u("saved")}catch{u("failed")}};return g&&e.features.Copy||_&&e.features.Share&&d.canShare||p||b||R||x&&e.features.Rating?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:n.space.xs},testID:r,children:[g&&e.features.Copy?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:l?i.copied:i.copy,variant:"link",size:"sm",onPress:()=>{(async()=>{await(0,_clipboard.copyText)(h)&&(o(!0),null!==m.current&&clearTimeout(m.current),m.current=setTimeout(()=>o(!1),2e3))})()},testID:`${r}-copy`}):null,_&&e.features.Share&&d.canShare?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:i.share,variant:"link",size:"sm",leftIcon:"share",disabled:e.streaming||e.thinking,onPress:()=>{d.shareReply(t)},testID:`${r}-share`}):null,p?(0,_jsxRuntime.jsx)(_ReadAloudButton.ReadAloudButton,{chat:e,message:t,labels:i}):null,b?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:i.regenerate,variant:"link",size:"sm",onPress:()=>{e.regenerate()},testID:`${r}-regenerate`}):null,R?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:i.edit,variant:"link",size:"sm",onPress:()=>e.startEdit(t.id),testID:`${r}-edit`}):null,x&&e.features.Rating?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityRole:"summary",accessibilityLabel:i.rating,style:{flexDirection:"row",alignItems:"center",gap:n.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"like",accessibilityLabel:i.rateUp,tone:"neutral",size:"sm",variant:"Up"===t.rating?"soft":"ghost",accessibilityState:{checked:"Up"===t.rating},onPress:()=>{save("Up")},testID:`${r}-rate-up`}),(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"dislike",accessibilityLabel:i.rateDown,tone:"neutral",size:"sm",variant:"Down"===t.rating?"soft":"ghost",accessibilityState:{checked:"Down"===t.rating},onPress:()=>{save("Down")},testID:`${r}-rate-down`})]}),"failed"===c?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:i.ratingFailed}):null,"saved"===c?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:i.rated}):null]}):null,null!==d.notice?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:d.notice}):null]}):null}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatSheet=ChatSheet;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ChatAppearanceScope=require("./ChatAppearanceScope.js"),_ChatFrame=require("./ChatFrame.js"),_ChatLauncher=require("./ChatLauncher.js"),_ChatNudge=require("./ChatNudge.js"),_chatShared=require("./chatShared.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_SNAP_POINTS=["92%"],DEFAULT_BOTTOM_OFFSET=16;function ChatSheet({chat:e,labels:t,renderers:r,layoutParts:a,loader:s="Steps",look:n,appearance:o,pickAttachments:c,onOpenAttachment:i,onOpenTarget:u,onNavigate:l,keyboardOffset:h,open:p,defaultOpen:_=!1,onOpenChange:f,snapPoints:d=DEFAULT_SNAP_POINTS,openTicket:m,handoffHosts:b,resolveLink:C,conversationId:g,onClose:j,testID:S="chat-sheet"}){const x=(0,_mobileUi.useTheme)(),T=(0,_chatCore.mergeLabels)(t),O=(0,_react.useMemo)(()=>(0,_chatCore.mergeLook)(n),[n]),R=(0,_mobileUi.useReducedMotion)(),v="Reduced"===O.motion||R,y=o?.position??"end",A=void 0!==p,k=A?p:e.open,N=(0,_react.useRef)(null),E=(0,_react.useRef)(!1),F=(0,_react.useRef)(g??null),L=e.setChatVisible,P=(0,_react.useRef)(!1),q=!P.current,[D,I]=(0,_react.useState)(0),U=(0,_react.useRef)(k);(0,_react.useEffect)(()=>{k&&(P.current=!0)},[k]),(0,_react.useEffect)(()=>{k&&!U.current&&I(e=>e+1),U.current=k},[k]),(0,_react.useEffect)(()=>{E.current||(E.current=!0,A||!_||null===e.profile||e.open||e.session.open({trigger:"manual"}))},[A,_,e.profile,e.open,e.session]),(0,_react.useEffect)(()=>{A&&(p&&!e.open&&e.session.open({trigger:"manual"}),!p&&e.open&&e.session.close("button"))},[A,p,e.open,e.session]);const w=(0,_react.useRef)(k);if((0,_react.useEffect)(()=>{w.current&&!k&&(0,_chatShared.focusForAccessibility)(N.current),w.current=k},[k]),(0,_react.useEffect)(()=>{L(k)},[L,k]),(0,_react.useEffect)(()=>{!A&&g&&g!==F.current&&null!==e.profile&&(F.current=g,e.open||(e.session.open({trigger:"manual"}),f?.(!0)))},[A,g,e.profile,e.open,e.session,f]),null===e.profile||!e.features.VisitorChat)return null;const setOpen=t=>{t?e.session.open({trigger:"manual"}):e.session.close("button"),f?.(t)},closeSheet=()=>{setOpen(!1),j?.()},M=o?.offsetY??DEFAULT_BOTTOM_OFFSET;return(0,_jsxRuntime.jsx)(_reactNative.View,{testID:S,style:_reactNative.StyleSheet.absoluteFill,pointerEvents:"box-none",children:(0,_jsxRuntime.jsxs)(_ChatAppearanceScope.ChatAppearanceScope,{appearance:o,children:[k?null:(0,_jsxRuntime.jsx)(_ChatLauncher.ChatLauncher,{look:O,label:T.launcher,side:y,offsetX:o?.offsetX??0,offsetY:M,enter:q,reduced:v,buttonRef:N,onPress:()=>setOpen(!0),testID:`${S}-launcher`}),(0,_jsxRuntime.jsx)(_ChatNudge.ChatNudge,{chat:e,labels:T,enabled:!k&&e.features.Nudges,onActivate:()=>setOpen(!0),bottomOffset:M,position:y,testID:`${S}-nudge`}),(0,_jsxRuntime.jsx)(_mobileUi.BottomSheet,{open:k,onClose:closeSheet,snapPoints:d,keyboardBehavior:"shift",scrollable:!1,enablePanDownToClose:!0,enableBackdropPress:!0,accessibilityViewIsModal:!0,accessibilityLabel:T.panelTitle,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,backgroundColor:x.colors.bg},children:(0,_jsxRuntime.jsx)(_ChatFrame.ChatFrame,{chat:e,labels:T,renderers:r,layoutParts:a,loader:s,look:n,pickAttachments:c,onOpenAttachment:i,onOpenTarget:u,onNavigate:l,openTicket:m,handoffHosts:b,resolveLink:C,keyboardOffset:h,onClose:closeSheet,layout:"sheet",enterKey:D,testID:`${S}-frame`})})})]})})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatSheet=ChatSheet;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ChatAppearanceScope=require("./ChatAppearanceScope.js"),_ChatFrame=require("./ChatFrame.js"),_ChatLauncher=require("./ChatLauncher.js"),_ChatNudge=require("./ChatNudge.js"),_chatShared=require("./chatShared.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_SNAP_POINTS=["92%"],DEFAULT_BOTTOM_OFFSET=16;function ChatSheet({chat:e,labels:t,renderers:r,layoutParts:a,loader:s="Steps",look:n,appearance:o,pickAttachments:c,onOpenAttachment:i,onOpenTarget:u,onNavigate:l,keyboardOffset:h,open:p,defaultOpen:f=!1,onOpenChange:_,snapPoints:d=DEFAULT_SNAP_POINTS,openTicket:m,handoffHosts:b,resolveLink:C,conversationId:g,onClose:j,testID:x="chat-sheet"}){const S=(0,_mobileUi.useTheme)(),v=(0,_chatCore.mergeLabels)(t),T=(0,_react.useMemo)(()=>(0,_chatCore.mergeLook)(n),[n]),O=(0,_mobileUi.useReducedMotion)(),k="Reduced"===T.motion||O,R=o?.position??"end",y=void 0!==p,A=y?p:e.open,N=(0,_react.useRef)(null),E=(0,_react.useRef)(!1),F=(0,_react.useRef)(g??null),L=e.setChatVisible,P=(0,_react.useRef)(!1),q=!P.current,[D,I]=(0,_react.useState)(0),U=(0,_react.useRef)(A);(0,_react.useEffect)(()=>{A&&(P.current=!0)},[A]),(0,_react.useEffect)(()=>{A&&!U.current&&I(e=>e+1),U.current=A},[A]),(0,_react.useEffect)(()=>{E.current||(E.current=!0,y||!f||null===e.profile||e.open||e.session.open({trigger:"manual"}))},[y,f,e.profile,e.open,e.session]),(0,_react.useEffect)(()=>{y&&(p&&!e.open&&e.session.open({trigger:"manual"}),!p&&e.open&&e.session.close("button"))},[y,p,e.open,e.session]);const w=(0,_react.useRef)(A);if((0,_react.useEffect)(()=>{w.current&&!A&&(0,_chatShared.focusForAccessibility)(N.current),w.current=A},[A]),(0,_react.useEffect)(()=>{L(A)},[L,A]),(0,_react.useEffect)(()=>{!y&&g&&g!==F.current&&null!==e.profile&&(F.current=g,e.open||(e.session.open({trigger:"manual"}),_?.(!0)))},[y,g,e.profile,e.open,e.session,_]),null===e.profile||!e.features.VisitorChat)return null;const setOpen=t=>{t?e.session.open({trigger:"manual"}):e.session.close("button"),_?.(t)},closeSheet=()=>{setOpen(!1),j?.()},M=o?.offsetY??DEFAULT_BOTTOM_OFFSET;return(0,_jsxRuntime.jsx)(_reactNative.View,{testID:x,style:_reactNative.StyleSheet.absoluteFill,pointerEvents:"box-none",children:(0,_jsxRuntime.jsxs)(_ChatAppearanceScope.ChatAppearanceScope,{appearance:o,children:[(0,_jsxRuntime.jsx)(_ChatLauncher.ChatLauncher,{look:T,hidden:A,label:e.profile?.experience.launcher?.hoverLabel||v.launcher,side:R,offsetX:o?.offsetX??0,offsetY:M,enter:q,reduced:k,mark:T.launcher.mark,avatar:T.avatar,buttonRef:N,onPress:()=>setOpen(!0),testID:`${x}-launcher`}),(0,_jsxRuntime.jsx)(_ChatNudge.ChatNudge,{chat:e,labels:v,enabled:!A&&e.features.Nudges,onActivate:()=>setOpen(!0),bottomOffset:M,position:R,testID:`${x}-nudge`}),(0,_jsxRuntime.jsx)(_mobileUi.BottomSheet,{open:A,onClose:closeSheet,snapPoints:d,keyboardBehavior:"shift",scrollable:!1,enablePanDownToClose:!0,enableBackdropPress:!0,accessibilityViewIsModal:!0,accessibilityLabel:v.panelTitle,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,backgroundColor:S.colors.bg},children:(0,_jsxRuntime.jsx)(_ChatFrame.ChatFrame,{chat:e,labels:v,renderers:r,layoutParts:a,loader:s,look:n,pickAttachments:c,onOpenAttachment:i,onOpenTarget:u,onNavigate:l,openTicket:m,handoffHosts:b,resolveLink:C,keyboardOffset:h,onClose:closeSheet,layout:"sheet",enterKey:D,testID:`${x}-frame`})})})]})})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatStarters=ChatStarters;var _mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_ChatEntrance=require("./ChatEntrance.js"),_ChatOpenTickets=require("./ChatOpenTickets.js"),_ChatPastChats=require("./ChatPastChats.js"),_jsxRuntime=require("react/jsx-runtime");function ChatStarters({chat:e,labels:t,openTicket:s,testID:i="chat-starters"}){const a=(0,_mobileUi.useTheme)(),r=e.profile,n=e.greeting??"";if(!r)return null;const l=e.features.Starters&&e.starters.length>0,c=e.lastConversation,o=e.features.ResumeLast&&!e.features.History&&null!==c;return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityLabel:t.emptyTitle,style:{flex:1,justifyContent:"center",alignItems:"center",gap:a.space.md,padding:a.space.md},testID:i,children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"h2",align:"center",children:n}),l?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"none",accessibilityLabel:t.starters,style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"center",gap:a.space.xs},children:e.starters.map((t,s)=>(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{index:s,children:(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:t.label,leftIcon:t.icon?t.icon:void 0,onPress:()=>{e.submit(t.message)},testID:`${i}-${t.id}`})},t.id))}):null,o&&c?(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",padding:"sm",onPress:()=>{e.resumeLast()},testID:`${i}-resume`,children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:t.resumeLast}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",numberOfLines:1,children:c.title||t.untitled}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:(0,_mobileCore.formatDate)(c.lastActivityDateTimeUtc)})]}):null,e.features.History?(0,_jsxRuntime.jsx)(_ChatPastChats.ChatPastChats,{chat:e,labels:t,testID:`${i}-past-chats`}):null,(0,_jsxRuntime.jsx)(_ChatOpenTickets.ChatOpenTickets,{chat:e,labels:t,onOpenTicket:s})]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatStarters=ChatStarters;var _mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ChatEntrance=require("./ChatEntrance.js"),_ChatOpenTickets=require("./ChatOpenTickets.js"),_ChatPastChats=require("./ChatPastChats.js"),_TypingPill=require("./loaders/TypingPill.js"),_chipLook=require("./renderers/chipLook.js"),_jsxRuntime=require("react/jsx-runtime");function ChatStarters({chat:e,labels:t,openTicket:i,avatar:s,motion:a="On",greetingLoaderMs:r=0,testID:n="chat-starters"}){const l=(0,_mobileUi.useTheme)(),[c,o]=(0,_react.useState)(!(r>0));(0,_react.useEffect)(()=>{if(c)return;const e=setTimeout(()=>o(!0),r);return()=>clearTimeout(e)},[c,r]);const u=e.profile,m=e.greeting??"";if(!u)return null;const _=u.assistant.intro,x=e.features.Starters&&e.starters.length>0,j=e.lastConversation,h=e.features.ResumeLast&&!e.features.History&&null!==j;return(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityLabel:t.emptyTitle,style:{flex:1,justifyContent:"center",alignItems:"center",gap:l.space.md,padding:l.space.md},testID:n,children:c?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[s?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,_jsxRuntime.jsx)(_mobileUi.Avatar,{size:"lg",name:e.profile?.assistant.name??t.panelTitle,source:{uri:s}})}):null,(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"h2",align:"center",children:m}),_?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"body",color:"secondary",align:"center",children:_}):null,x?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"none",accessibilityLabel:t.starters,style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"center",gap:l.space.xs},children:e.starters.map((t,i)=>(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{index:i,children:(0,_jsxRuntime.jsx)(_mobileUi.Chip,{...t.variant?(0,_chipLook.chipLook)(t.variant):null,label:t.label,leftIcon:t.icon?t.icon:void 0,onPress:()=>{e.submit(t.message)},testID:`${n}-${t.id}`})},t.id))}):null,h&&j?(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",padding:"sm",onPress:()=>{e.resumeLast()},testID:`${n}-resume`,children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:t.resumeLast}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",numberOfLines:1,children:j.title||t.untitled}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:(0,_mobileCore.formatDate)(j.lastActivityDateTimeUtc)})]}):null,e.features.History?(0,_jsxRuntime.jsx)(_ChatPastChats.ChatPastChats,{chat:e,labels:t,testID:`${n}-past-chats`}):null,(0,_jsxRuntime.jsx)(_ChatOpenTickets.ChatOpenTickets,{chat:e,labels:t,onOpenTicket:i})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{children:(0,_jsxRuntime.jsx)(_TypingPill.TypingPill,{motion:a,mark:s?(0,_jsxRuntime.jsx)(_mobileUi.Avatar,{size:"xs",name:e.profile?.assistant.name??t.panelTitle,source:{uri:s}}):null})})})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatThread=ChatThread;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_AgentByline=require("./AgentByline.js"),_ChatEntrance=require("./ChatEntrance.js"),_ChatMessageActions=require("./ChatMessageActions.js"),_chatShared=require("./chatShared.js"),_ChatLoader=require("./loaders/ChatLoader.js"),_TypingPill=require("./loaders/TypingPill.js"),_index=require("./renderers/index.js"),_NoticePart=require("./renderers/NoticePart.js"),_jsxRuntime=require("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(0,_react.createElement)(n,{key:r,part:t,message:s,turn:a,pickAttachments:i});const o={kind:"Notice",code:"NeedsNewerApp",text:a.labels.needsNewerApp};return(0,_react.createElement)(_NoticePart.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:u,onNavigate:g,openTicket:m,handoffHosts:d,resolveLink:h,focusComposer:p,byline:_,sourceRows:x,testID:y}){const f=(0,_mobileUi.useTheme)(),j=Object.assign((0,_chatCore.createTurnApi)(e.session,{messageId:t.id,labels:s,openAttachment:c,openTarget:u??_chatShared.defaultOpenTarget,onNavigate:g??e.onNavigate,openTicket:m,handoffHosts:d,openCitation:e=>{return t=String(e),void(0,_chatShared.focusForAccessibility)(x.current.get(t));var t}}),{resolveLink:h,focusComposer:p,registerSourceRow:(e,t)=>{t?x.current.set(e,t):x.current.delete(e)}});let T=0;const nextSlot=()=>(T+=1,T),b=(0,_jsxRuntime.jsx)(_ChatMessageActions.ChatMessageActions,{chat:e,message:t,labels:s,isLast:n,isLastVisitor:o,testID:`${y}-actions`});if(MINE.has(t.author.kind)){const e=t.parts.filter(e=>"File"===e.kind),i=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:f.space.xs},children:[e.map(e=>renderPart(a,e,t,j,l,`${t.id}-file-${nextSlot()}`)),b]});return(0,_jsxRuntime.jsx)(_mobileUi.MessageBubble,{side:"mine",text:joinedText(t.parts),labels:{you:s.you},groupPosition:r,footer:i,testID:y})}const k="Agent"===t.author.kind,N=t.author.displayName||s.agent,v=(i?i(t):t.parts).map(e=>Array.isArray(e)?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:f.space.xs},children:e.map(e=>renderPart(a,e,t,j,l,`${t.id}-part-${nextSlot()}`))},`${t.id}-group-${nextSlot()}`):renderPart(a,e,t,j,l,`${t.id}-item-${nextSlot()}`)),A=k&&_?[(0,_jsxRuntime.jsx)(_AgentByline.AgentByline,{author:t.author,labels:s},`${t.id}-byline`),...v]:v,R=(0,_chatCore.messagePlainText)(t.parts);return(0,_jsxRuntime.jsx)(_mobileUi.MessageBubble,{side:"theirs",author:k?void 0:t.author.displayName||s.assistant,text:k?`${s.agentSays(N)} ${R}`:R,streaming:t.streaming,groupPosition:r,footer:b,testID:y,children:A})}const ThreadMessage=(0,_react.memo)(ThreadMessageView,sameMessage),TYPING_ORB_MARK=14,TYPING_ASSISTANT_MARK=8,TypingMark=({size:e})=>{const t=(0,_mobileUi.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:e,height:e,borderRadius:t.radius.pill,backgroundColor:t.colors.primary}})},TYPING_DOT=6,TypingDots=()=>{const e=(0,_mobileUi.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},children:[0,1,2].map(t=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:6,height:6,borderRadius:3,backgroundColor:e.colors["text-muted"]}},t))})},TurnGap=()=>{const e=(0,_mobileUi.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:e.space.lg}})},followNew=()=>!0;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:u,handoffHosts:g,resolveLink:m,focusComposer:d,keyboardAware:h,keyboardOffset:p,empty:_,style:x,testID:y="chat-thread"}){const f=(0,_mobileUi.useTheme)(),j=(0,_react.useMemo)(()=>({..._index.defaultRenderers,...s}),[s]),T=e.messages[0],b=e.greeting??"",k=(0,_react.useMemo)(()=>""!==b&&void 0!==T&&MINE.has(T.author.kind)?{...T,id:"greeting",author:{...T.author,kind:"Assistant",displayName:null,avatarUrl:null},parts:[{kind:"Text",text:b}],stored:!1,streaming:!1,restored:!1,rating:null}:null,[b,T]),N=(0,_react.useMemo)(()=>{const t=e.messages.filter(e=>!(e.streaming&&0===e.parts.length)).reverse();return k?[...t,k]:t},[e.messages,k]),v=e.messages[e.messages.length-1]?.id,A=(0,_react.useRef)(new Map),R=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(null!==R.current)for(const s of e.messages){if(MINE.has(s.author.kind)||s.streaming||s.restored||R.current.has(s.id))continue;if("Agent"===s.author.kind&&!s.stored)continue;R.current.add(s.id);const e=(0,_chatCore.messagePlainText)(s.parts);""!==e&&_reactNative.AccessibilityInfo.announceForAccessibility("Agent"===s.author.kind?`${t.agentSays(s.author.displayName||t.agent)} ${e}`:e)}else R.current=new Set(e.messages.map(e=>e.id))},[e.messages,t]);const w=(0,_react.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=(0,_react.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]),M=(0,_react.useMemo)(()=>(0,_chatCore.handoffSettledIds)(e.messages),[e.messages]),C=e.turnError,S="daily_limit"===C?.code,I=null!==C&&/feature_off$/.test(C.code),L=S&&C?.resetsDateTimeUtc?` ${t.dailyLimitRefresh((0,_chatCore.formatChatDateTime)(C.resetsDateTimeUtc))}`:"",$=e.streaming||null===C&&!e.stopped?null:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:f.space.xs},testID:`${y}-error`,children:[null!==C?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityRole:S?void 0:"alert",accessibilityLiveRegion:S?"polite":void 0,children:`${C.message}${L}`}):(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:t.stopped}),!e.features.Retry||S||I?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row"},children:(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:t.retry,variant:"link",size:"sm",onPress:()=>{e.retry()},testID:`${y}-retry`})})]}),D=e.thinking&&null!==e.profile?(0,_jsxRuntime.jsx)(_ChatLoader.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?(0,_jsxRuntime.jsx)(_TypingPill.TypingPill,{motion:r,mark:(0,_jsxRuntime.jsx)(TypingMark,{size:"Orb"===i?TYPING_ORB_MARK:TYPING_ASSISTANT_MARK})}):null,V=null!==e.agentTyping&&"WithAgent"===e.conversationState?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:f.space.xs,alignSelf:"flex-start"},children:[(0,_jsxRuntime.jsx)(_TypingPill.TypingPill,{motion:r,mark:(0,_jsxRuntime.jsx)(TypingDots,{})}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:t.agentTyping(e.agentTyping.displayName||t.agent)})]}):null,U=O||D||$||V?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:f.space.sm},children:[O,D,V,$]}):void 0;return(0,_jsxRuntime.jsx)(_mobileUi.MessageList,{messages:N,keyExtractor:e=>e.id,renderMessage:({item:s,groupPosition:i})=>(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{animate:!s.restored,children:(0,_jsxRuntime.jsx)(ThreadMessage,{chat:e,message:s,signature:(0,_chatShared.messageSignature)(s),labels:t,all:j,layoutParts:a,groupPosition:i,isLast:s.id===v,isLastVisitor:s.id===w,handoffSettled:M.has(s.id),thinking:e.thinking,streaming:e.streaming,pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:c,openTicket:u,handoffHosts:g,resolveLink:m,focusComposer:d,byline:P.has(s.id),sourceRows:A,testID:`${y}-${s.id}`})}),getAuthorKey:e=>e.author.kind,getDate:e=>e.createdDateTimeUtc,followNew:followNew,typing:U,empty:_,ItemSeparatorComponent:TurnGap,keyboardAware:h,keyboardOffset:p,accessibilityLabel:t.thread,style:x,testID:y})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatThread=ChatThread;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_AgentByline=require("./AgentByline.js"),_ChatEntrance=require("./ChatEntrance.js"),_ChatMessageActions=require("./ChatMessageActions.js"),_chatShared=require("./chatShared.js"),_ChatLoader=require("./loaders/ChatLoader.js"),_ReplyRing=require("./loaders/ReplyRing.js"),_TypingPill=require("./loaders/TypingPill.js"),_index=require("./renderers/index.js"),_NoticePart=require("./renderers/NoticePart.js"),_jsxRuntime=require("react/jsx-runtime");const MINE=new Set(["Visitor","Customer"]),visuallyHidden={position:"absolute",left:-1e4,width:1,height:1,overflow:"hidden"},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(0,_react.createElement)(n,{key:r,part:t,message:s,turn:a,pickAttachments:i});const o={kind:"Notice",code:"NeedsNewerApp",text:a.labels.needsNewerApp};return(0,_react.createElement)(_NoticePart.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.avatar===t.avatar&&e.replyAvatars===t.replyAvatars&&e.avatarStart===t.avatarStart&&e.expressive===t.expressive&&e.reduced===t.reduced&&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:d,onNavigate:u,openTicket:m,handoffHosts:g,resolveLink:h,focusComposer:p,byline:_,avatar:x,replyAvatars:y,avatarStart:f,expressive:j,reduced:v,sourceRows:R,testID:b}){const T=(0,_mobileUi.useTheme)(),A=Object.assign((0,_chatCore.createTurnApi)(e.session,{messageId:t.id,labels:s,openAttachment:c,openTarget:d??_chatShared.defaultOpenTarget,onNavigate:u??e.onNavigate,openTicket:m,handoffHosts:g,openCitation:e=>{return t=String(e),void(0,_chatShared.focusForAccessibility)(R.current.get(t));var t}}),{resolveLink:h,focusComposer:p,registerSourceRow:(e,t)=>{t?R.current.set(e,t):R.current.delete(e)}});let k=0;const nextSlot=()=>(k+=1,k),N=(0,_jsxRuntime.jsx)(_ChatMessageActions.ChatMessageActions,{chat:e,message:t,labels:s,isLast:n,isLastVisitor:o,testID:`${b}-actions`});if(MINE.has(t.author.kind)){const e=t.parts.filter(e=>"File"===e.kind),s=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:T.space.xs},children:[e.map(e=>renderPart(a,e,t,A,l,`${t.id}-file-${nextSlot()}`)),N]});return(0,_jsxRuntime.jsx)(_mobileUi.MessageBubble,{side:"mine",text:joinedText(t.parts),labels:{you:""},groupPosition:r,footer:s,testID:b})}const w="Agent"===t.author.kind,M=t.author.displayName||s.agent,P=(i?i(t):t.parts).map(e=>Array.isArray(e)?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:T.space.xs},children:e.map(e=>renderPart(a,e,t,A,l,`${t.id}-part-${nextSlot()}`))},`${t.id}-group-${nextSlot()}`):renderPart(a,e,t,A,l,`${t.id}-item-${nextSlot()}`)),S=w&&_?(0,_jsxRuntime.jsx)(_AgentByline.AgentByline,{author:t.author,labels:s,showAvatar:y},`${t.id}-byline`):null,C=S?[S,...P]:P,I=(0,_chatCore.messagePlainText)(t.parts),L=(0,_jsxRuntime.jsx)(_mobileUi.MessageBubble,{side:"theirs",author:w?void 0:t.author.displayName||(e.profile?.assistant.name??s.assistant),text:w?`${s.agentSays(M)} ${I}`:I,streaming:t.streaming,groupPosition:r,footer:N,testID:b,children:C});if(!y||!x||"Assistant"!==t.author.kind)return L;const V=t.author.displayName||(e.profile?.assistant.name??s.assistant);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"flex-end",gap:T.space.xs},children:[(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:f?void 0:{opacity:0},children:(0,_jsxRuntime.jsx)(_ReplyRing.ReplyRing,{active:j&&t.streaming&&f,reduced:v,children:(0,_jsxRuntime.jsx)(_mobileUi.Avatar,{size:"xs",name:V,source:f?{uri:x}:void 0})})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,minWidth:0},children:L})]})}const ThreadMessage=(0,_react.memo)(ThreadMessageView,sameMessage),TYPING_ORB_MARK=14,TYPING_ASSISTANT_MARK=8,TypingMark=({size:e})=>{const t=(0,_mobileUi.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:e,height:e,borderRadius:t.radius.pill,backgroundColor:t.colors.primary}})},TYPING_DOT=6,TypingDots=()=>{const e=(0,_mobileUi.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},children:[0,1,2].map(t=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:6,height:6,borderRadius:3,backgroundColor:e.colors["text-muted"]}},t))})},TurnGap=()=>{const e=(0,_mobileUi.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:e.space.lg}})},followNew=()=>!0;function ChatThread({chat:e,labels:t,renderers:s,layoutParts:a,loader:i="Steps",motion:r="On",avatar:n,replyAvatars:o=!0,expressive:l=!1,pickAttachments:c,onOpenAttachment:d,onOpenTarget:u,onNavigate:m,openTicket:g,handoffHosts:h,resolveLink:p,focusComposer:_,keyboardAware:x,keyboardOffset:y,empty:f,style:j,testID:v="chat-thread"}){const R=(0,_mobileUi.useTheme)(),b=(0,_mobileUi.useReducedMotion)(),T="Reduced"===r||b,A=(0,_react.useMemo)(()=>({..._index.defaultRenderers,...s}),[s]),k=e.messages[0],N=e.greeting??"",w=(0,_react.useMemo)(()=>""!==N&&void 0!==k&&MINE.has(k.author.kind)?{...k,id:"greeting",author:{...k.author,kind:"Assistant",displayName:null,avatarUrl:null},parts:[{kind:"Text",text:N}],stored:!1,streaming:!1,restored:!1,rating:null}:null,[N,k]),M=(0,_react.useMemo)(()=>{const t=e.messages.filter(e=>!(e.streaming&&0===e.parts.length)).reverse();return w?[...t,w]:t},[e.messages,w]),P=e.messages[e.messages.length-1]?.id,S=(0,_react.useRef)(new Map),C=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(null!==C.current)for(const s of e.messages){if(MINE.has(s.author.kind)||s.streaming||s.restored||C.current.has(s.id))continue;if("Agent"===s.author.kind&&!s.stored)continue;C.current.add(s.id);const e=(0,_chatCore.messagePlainText)(s.parts);""!==e&&_reactNative.AccessibilityInfo.announceForAccessibility("Agent"===s.author.kind?`${t.agentSays(s.author.displayName||t.agent)} ${e}`:e)}else C.current=new Set(e.messages.map(e=>e.id))},[e.messages,t]);const I=(0,_react.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]),L=(0,_react.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]),V=(0,_react.useMemo)(()=>{const t=new Set,s=e.messages.filter(e=>!(e.streaming&&0===e.parts.length));return w&&t.add(w.id),s.forEach((e,a)=>{"Assistant"===e.author.kind&&"Assistant"!==s[a-1]?.author.kind&&t.add(e.id)}),t},[e.messages,w]),$=(0,_react.useMemo)(()=>(0,_chatCore.handoffSettledIds)(e.messages),[e.messages]),D=e.turnError,O="daily_limit"===D?.code,U=null!==D&&/feature_off$/.test(D.code),E=O&&D?.resetsDateTimeUtc?` ${t.dailyLimitRefresh((0,_chatCore.formatChatDateTime)(D.resetsDateTimeUtc))}`:"",q=e.streaming||null===D&&!e.stopped?null:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:R.space.xs},testID:`${v}-error`,children:[null!==D?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityRole:O?void 0:"alert",accessibilityLiveRegion:O?"polite":void 0,children:`${D.message}${E}`}):(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:t.stopped}),!e.features.Retry||O||U?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row"},children:(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:t.retry,variant:"link",size:"sm",onPress:()=>{e.retry()},testID:`${v}-retry`})})]}),B=e.thinking&&null!==e.profile?(0,_jsxRuntime.jsx)(_ChatLoader.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,H=!0===e.pending?.typing?(0,_jsxRuntime.jsx)(_TypingPill.TypingPill,{motion:r,mark:(0,_jsxRuntime.jsx)(_ReplyRing.ReplyRing,{active:l,reduced:T,children:n?(0,_jsxRuntime.jsx)(_mobileUi.Avatar,{size:"xs",name:e.profile?.assistant.name??t.panelTitle,source:{uri:n}}):(0,_jsxRuntime.jsx)(TypingMark,{size:"Orb"===i?TYPING_ORB_MARK:TYPING_ASSISTANT_MARK})})}):null,G=null!==e.agentTyping&&"WithAgent"===e.conversationState?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:R.space.xs,alignSelf:"flex-start"},children:[(0,_jsxRuntime.jsx)(_TypingPill.TypingPill,{motion:r,mark:(0,_jsxRuntime.jsx)(TypingDots,{})}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:t.agentTyping(e.agentTyping.displayName||t.agent)})]}):null,z=H||B||q||G?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:R.space.sm},children:[H,B,G,q]}):void 0,K=(0,_jsxRuntime.jsx)(_mobileUi.MessageList,{messages:M,keyExtractor:e=>e.id,renderMessage:({item:s,groupPosition:i})=>(0,_jsxRuntime.jsxs)(_reactNative.View,{role:"listitem",children:[MINE.has(s.author.kind)?(0,_jsxRuntime.jsx)(_mobileUi.Text,{style:visuallyHidden,children:`${t.you}: `}):null,(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{animate:!s.restored,children:(0,_jsxRuntime.jsx)(ThreadMessage,{chat:e,message:s,signature:(0,_chatShared.messageSignature)(s),labels:t,all:A,layoutParts:a,groupPosition:i,isLast:s.id===P,isLastVisitor:s.id===I,handoffSettled:$.has(s.id),thinking:e.thinking,streaming:e.streaming,pickAttachments:c,onOpenAttachment:d,onOpenTarget:u,onNavigate:m,openTicket:g,handoffHosts:h,resolveLink:p,focusComposer:_,byline:L.has(s.id),avatar:n,replyAvatars:o,avatarStart:V.has(s.id),expressive:l,reduced:T,sourceRows:S,testID:`${v}-${s.id}`})})]}),getAuthorKey:e=>e.author.kind,getDate:e=>e.createdDateTimeUtc,followNew:followNew,typing:z,empty:f,ItemSeparatorComponent:TurnGap,keyboardAware:x,keyboardOffset:y,accessibilityLabel:t.thread,accessibilityRole:"list",style:j,testID:v});return"web"!==_reactNative.Platform.OS?K:(0,_jsxRuntime.jsx)(_reactNative.View,{role:"log","aria-live":"polite","aria-label":t.thread,style:{flex:1},children:K})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.defaultOpenTarget=defaultOpenTarget,exports.focusForAccessibility=focusForAccessibility,exports.messageSignature=messageSignature;var _reactNative=require("react-native");function focusForAccessibility(e){if(null==e)return;if("web"===_reactNative.Platform.OS)return void e.focus?.();const t=(0,_reactNative.findNodeHandle)(e);null!==t&&_reactNative.AccessibilityInfo.setAccessibilityFocus(t)}function messageSignature(e){let t=0;for(const i of e.parts)"Text"===i.kind&&(t+=i.text.length);return`${e.id}|${e.parts.length}|${t}`}const ABSOLUTE_WEB_URL=/^https?:\/\//i;function defaultOpenTarget(e){ABSOLUTE_WEB_URL.test(e)&&_reactNative.Linking.openURL(e).catch(()=>{})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WEB_STRONG=void 0,exports.defaultOpenTarget=defaultOpenTarget,exports.focusForAccessibility=focusForAccessibility,exports.messageSignature=messageSignature;var _reactNative=require("react-native");function focusForAccessibility(e){if(null==e)return;if("web"===_reactNative.Platform.OS)return void e.focus?.();const t=(0,_reactNative.findNodeHandle)(e);null!==t&&_reactNative.AccessibilityInfo.setAccessibilityFocus(t)}function messageSignature(e){let t=0;for(const i of e.parts)"Text"===i.kind&&(t+=i.text.length);return`${e.id}|${e.parts.length}|${t}`}const ABSOLUTE_WEB_URL=/^https?:\/\//i;function defaultOpenTarget(e){ABSOLUTE_WEB_URL.test(e)&&_reactNative.Linking.openURL(e).catch(()=>{})}const WEB_STRONG=exports.WEB_STRONG="web"===_reactNative.Platform.OS?{role:"strong"}:{};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ReplyRing=ReplyRing;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const TURN_MS=1400;function ReplyRing({active:e,reduced:t,children:i}){return!e||t?(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:i}):(0,_jsxRuntime.jsx)(TurningRing,{children:i})}const TurningRing=({children:e})=>{const t=(0,_mobileUi.useTheme)(),i=(0,_react.useRef)(new _reactNative.Animated.Value(0)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.loop(_reactNative.Animated.timing(i,{toValue:1,duration:1400,easing:_reactNative.Easing.linear,useNativeDriver:!0}));return e.start(),()=>e.stop()},[i]);const r=-t.space.xxs,n=i.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]});return(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[e,(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:"absolute",top:r,right:r,bottom:r,left:r,borderWidth:t.space.xxs,borderRadius:t.radius.pill,borderColor:t.colors.primary,borderTopColor:t.colors.info,transform:[{rotate:n}]}})]})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ActionPart=ActionPart;var _chatCore=require("@webority/chat-core"),_markdownCore=require("@webority/markdown-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_NoticePart=require("./NoticePart.js"),_jsxRuntime=require("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 i=inlineNodes(e.children,t);return SAFE_LINK.test(e.href)?(0,_jsxRuntime.jsx)(_reactNative.Text,{accessibilityRole:"link",style:{color:t.colors.link,textDecorationLine:"underline"},onPress:()=>{_reactNative.Linking.openURL(e.href).catch(()=>{})},children:i},e.key):(0,_jsxRuntime.jsx)(_reactNative.Text,{children:i},e.key)}if("image"===e.type)return null;const i="strong"===e.type?{fontWeight:t.weight.bold}:"em"===e.type?{fontStyle:"italic"}:{textDecorationLine:"line-through"};return(0,_jsxRuntime.jsx)(_reactNative.Text,{style:i,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} ${(0,_chatCore.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((0,_chatCore.formatChatDate)(e.decidedDateTimeUtc)):t.actionDone;case"Pending":return""}};function ActionBody({part:e,turn:t}){const i=(0,_mobileUi.useTheme)(),{labels:n,features:a}=t,[r,o]=(0,_react.useState)(null),[s,l]=(0,_react.useState)(""),[c,d]=(0,_react.useState)(!1),run=async(e,t)=>{o(e),l("");try{await t()}catch(e){const t=e?.message;l("string"==typeof t&&""!==t?t:n.actionFailed),o(null)}},u=(e.editFields??[]).map(e=>({label:e.label,value:e.id})),m=a.LeadRecap&&e.actionKind===LEAD_CAPTURE,x=m&&u.length>0,_=m&&e.confirmLabel||n.actionConfirm,j=m&&e.rejectLabel||n.actionDismiss,p=null!==r;return(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",padding:"sm",children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:e.title}),e.lines.map(e=>{if(!m)return(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:e},e);const{term:t,detail:n}=splitLine(e);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:i.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:t}),null!==n?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:n}):null]},e)}),m&&e.consentText?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:inlineNodes((0,_markdownCore.parseInline)(e.consentText),i)}):null,"Pending"===e.state?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[""!==s?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:s}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:i.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:"confirm"===r?n.actionWorking:_,loading:"confirm"===r,disabled:p,onPress:()=>{run("confirm",()=>t.confirmAction(e.actionId))}}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:j,variant:"ghost",disabled:p,onPress:()=>{run("reject",()=>t.rejectAction(e.actionId))}})]})]}):(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"Done"===e.state||"Confirmed"===e.state||"Repeat"===e.state?"success":"secondary",children:statusLine(e,n)}),x?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:n.editSomething,variant:"ghost",disabled:p||"Pending"!==e.state,onPress:()=>d(!0)}):null,e.note?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:e.note}):null]}),x?(0,_jsxRuntime.jsx)(_mobileUi.OptionSheet,{open:c,onClose:()=>d(!1),title:n.editSomething,options:u,onChange:(e,i)=>{d(!1),t.chooseQuickReply({id:`lead.edit:${String(i.value)}`,label:i.label,action:"Send",target:null,navigateAfterMs:null,icon:null,variant:null})}}):null]})}function ActionPart(e){const{part:t,message:i,turn:n}=e;if("Action"!==t.kind){const e={kind:"Notice",code:"NeedsNewerApp",text:n.labels.needsNewerApp};return(0,_jsxRuntime.jsx)(_NoticePart.NoticePart,{part:e,message:i,turn:n})}return(0,_jsxRuntime.jsx)(ActionBody,{part:t,turn:n},t.actionId)}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ActionPart=ActionPart;var _chatCore=require("@webority/chat-core"),_markdownCore=require("@webority/markdown-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_NoticePart=require("./NoticePart.js"),_jsxRuntime=require("react/jsx-runtime");const LEAD_CAPTURE="ChatLeadCapture",SAFE_LINK=/^https?:\/\//i,inlineNodes=(e,t)=>e.map(e=>{if("text"===e.type||"code"===e.type||"citation"===e.type)return e.text;if("link"===e.type){const i=inlineNodes(e.children,t);return SAFE_LINK.test(e.href)?(0,_jsxRuntime.jsx)(_reactNative.Text,{accessibilityRole:"link",style:{color:t.colors.link,textDecorationLine:"underline"},onPress:()=>{_reactNative.Linking.openURL(e.href).catch(()=>{})},children:i},e.key):(0,_jsxRuntime.jsx)(_reactNative.Text,{children:i},e.key)}if("image"===e.type)return null;const i="strong"===e.type?{fontWeight:t.weight.bold}:"em"===e.type?{fontStyle:"italic"}:{textDecorationLine:"line-through"};return(0,_jsxRuntime.jsx)(_reactNative.Text,{style:i,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} ${(0,_chatCore.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((0,_chatCore.formatChatDate)(e.decidedDateTimeUtc)):t.actionDone;case"Pending":return""}};function ActionBody({part:e,turn:t}){const i=(0,_mobileUi.useTheme)(),{labels:n,features:a}=t,[r,o]=(0,_react.useState)(null),[s,l]=(0,_react.useState)(""),[c,d]=(0,_react.useState)(!1),run=async(e,t)=>{o(e),l("");try{await t()}catch(e){const t=e?.message;l("string"==typeof t&&""!==t?t:n.actionFailed),o(null)}},u=(e.editFields??[]).map(e=>({label:e.label,value:e.id})),m=a.LeadRecap&&e.actionKind===LEAD_CAPTURE,x=m&&u.length>0,_=m&&e.confirmLabel||n.actionConfirm,j=m&&e.rejectLabel||n.actionDismiss,p=null!==r;return(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",padding:"sm",children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:e.title}),e.lines.map(e=>{if(!m)return(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:e},e);const{term:t,detail:n}=splitLine(e);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:i.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:t}),null!==n?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:n}):null]},e)}),m&&e.consentText?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:inlineNodes((0,_markdownCore.parseInline)(e.consentText),i)}):null,"Pending"===e.state?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[""!==s?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:s}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:i.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:"confirm"===r?n.actionWorking:_,loading:"confirm"===r,disabled:p,onPress:()=>{run("confirm",()=>t.confirmAction(e.actionId))}}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:j,variant:"ghost",disabled:p,onPress:()=>{run("reject",()=>t.rejectAction(e.actionId))}})]})]}):(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"Done"===e.state||"Confirmed"===e.state||"Repeat"===e.state?"success":"secondary",children:statusLine(e,n)}),x?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:n.editSomething,variant:"ghost",disabled:p||"Pending"!==e.state,onPress:()=>d(!0)}):null,e.note?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:e.note}):null]}),x?(0,_jsxRuntime.jsx)(_mobileUi.OptionSheet,{open:c,onClose:()=>d(!1),title:n.editSomething,options:u,onChange:(e,i)=>{d(!1),t.chooseQuickReply({id:`lead.edit:${String(i.value)}`,label:i.label,action:"Send",target:null,navigateAfterMs:null,icon:null,variant:null})}}):null]})}function ActionPart(e){const{part:t,message:i,turn:n}=e;if("Action"!==t.kind){const e={kind:"Notice",code:"NeedsNewerApp",text:n.labels.needsNewerApp};return(0,_jsxRuntime.jsx)(_NoticePart.NoticePart,{part:e,message:i,turn:n})}return(0,_jsxRuntime.jsx)(ActionBody,{part:t,turn:n},t.actionId)}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.InputRequestPart=InputRequestPart;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_chatShared=require("../chatShared.js"),_NoticePart=require("./NoticePart.js"),_jsxRuntime=require("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=(0,_mobileUi.useTheme)(),{labels:s,features:a}=t,[n,l]=(0,_react.useState)({}),[o,c]=(0,_react.useState)({}),[u,d]=(0,_react.useState)(""),[p,m]=(0,_react.useState)(!1),[y,x]=(0,_react.useState)({}),[_,b]=(0,_react.useState)({}),[f,j]=(0,_react.useState)({}),h=(0,_react.useRef)({}),v=(0,_react.useRef)({}),k=(0,_react.useRef)(y),R=(0,_react.useRef)(0),g=(0,_react.useRef)(!1),S=(0,_react.useCallback)(e=>{const t=h.current[e];if(t)return void t.focus();const i=v.current[e];i&&(0,_chatShared.focusForAccessibility)(i)},[]);(0,_react.useEffect)(()=>{if(p||!g.current)return;g.current=!1;const t=firstErrorKey(e.fields,o);void 0!==t&&S(t)},[p,o,e.fields,S]);const setValue=(e,t)=>l(i=>({...i,[e]:t})),commitUploads=e=>{k.current=e,x(e)},patchUpload=(e,t)=>{const i=k.current[e];i&&commitUploads({...k.current,[e]:{...i,...t}})},isLiveUpload=(e,t)=>k.current[e]?.token===t,T=Object.values(y).some(e=>"Ready"!==e.status),leave=async e=>{m(!0),d("");try{await e()}catch{d(s.errorGeneric),m(!1)}},U=a.LeadShortcuts,w=U&&1===e.fields.length&&!e.fields[0].required,C=U&&e.cancellable;return(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",padding:"sm",accessibilityLabel:e.title||void 0,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.sm},children:[e.title?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",accessibilityRole:"header",children:e.title}):null,e.allowTyped?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.typeAnswer}):null,e.fields.map(a=>{const l=n[a.key]??"",c=o[a.key];if("File"===a.type){const e=y[a.key];return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:`${a.label}${optionalSuffix(a,s)}`}),e?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xxs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:e.fileName,variant:"soft",onRemove:()=>{return e=a.key,commitUploads(Object.fromEntries(Object.entries(k.current).filter(([t])=>t!==e))),void setValue(e,"");var e},labels:{remove:s.inputRemoveFile}}),"Uploading"===e.status?(0,_jsxRuntime.jsx)(_mobileUi.ProgressBar,{progress:e.progress??void 0,label:s.attachmentUploading,height:4}):null,"Failed"===e.status?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"assertive",children:s.attachmentFailed}):null]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row"},children:(0,_jsxRuntime.jsx)(_mobileUi.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 a=r[0];if(!a)return;R.current+=1;const n=R.current;commitUploads({...k.current,[e.key]:{fileName:fileNameOf(a,e.label),status:"Uploading",progress:null,token:n}});try{const i=await t.uploadInputFile(a,t=>{isLiveUpload(e.key,n)&&patchUpload(e.key,{progress:t})});isLiveUpload(e.key,n)&&(setValue(e.key,i),patchUpload(e.key,{status:"Ready",progress:null}))}catch{isLiveUpload(e.key,n)&&(setValue(e.key,""),patchUpload(e.key,{status:"Failed",progress:null}))}})(a)}})}),c?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"assertive",children:c}):null]},a.key)}if("MultiChoice"===a.type){const e=(a.options??[]).map(e=>({label:e.label,value:e.id}));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:`${a.label}${optionalSuffix(a,s)}`}),(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e=>{v.current[a.key]=e},children:(0,_jsxRuntime.jsx)(_mobileUi.ChoiceGroup,{selectionMode:"multiple",options:e,value:selectedIds(l),onChange:t=>setValue(a.key,JSON.stringify(e.filter(e=>t.includes(e.value)).map(e=>e.value))),accessibilityLabel:a.label,error:c,disabled:p})})]},a.key)}if("Choice"===a.type||"TimeSlot"===a.type){const e="TimeSlot"===a.type?(a.slots??[]).map(e=>({label:slotFormat.format(new Date(e.startDateTimeUtc)),value:e.id})):(a.options??[]).map(e=>({label:e.label,value:e.id}));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:`${a.label}${optionalSuffix(a,s)}`}),(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e=>{v.current[a.key]=e},children:(0,_jsxRuntime.jsx)(_mobileUi.ChoiceGroup,{options:e,value:""===l?void 0:l,onChange:e=>setValue(a.key,String(e)),accessibilityLabel:a.label,error:c,disabled:p})})]},a.key)}if("Consent"===a.type)return(0,_jsxRuntime.jsx)(_mobileUi.Checkbox,{checked:"true"===l,onChange:e=>setValue(a.key,e?"true":"false"),label:a.consentText??a.label,error:c,disabled:p},a.key);const u=(0,_jsxRuntime.jsx)(_mobileUi.Input,{ref:e=>{h.current[a.key]=e},label:a.label,placeholder:a.placeholder??void 0,value:l,onChangeText:e=>setValue(a.key,e),maxLength:a.maxLength??void 0,required:a.required,error:c,help:a.required?void 0:s.inputOptional,labelMode:"top",disabled:p,type:a.secret?"password":"LongText"===a.type?"textarea":"input",keyboardType:KEYBOARD_TYPES[a.type]??"default",autoCapitalize:"Email"===a.type?"none":void 0,autoComplete:AUTO_COMPLETE[a.type]},a.key);if(!("Otp"===a.verify&&("Email"===a.type||"Phone"===a.type)))return u;const m=f[a.key];return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[u,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.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:(n[i.key]??"").trim()}),j(e=>({...e,[i.key]:"sent"}))}catch{j(e=>({...e,[i.key]:"failed"}))}})(a)},testID:`otp-send-${a.key}`}),(0,_jsxRuntime.jsx)(_mobileUi.Input,{label:s.inputEnterCode,value:_[a.key]??"",onChangeText:e=>b(t=>({...t,[a.key]:e})),keyboardType:"number-pad",autoComplete:"one-time-code",disabled:p}),m?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"failed"===m?"danger":"secondary",accessibilityLiveRegion:"polite",children:"failed"===m?s.inputCodeFailed:s.inputCodeSent}):null]})]},a.key)}),""!==u?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:u}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:r.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:p?s.inputSubmitting:e.submitLabel,loading:p,disabled:p||T,onPress:()=>{(async()=>{if(T)return;const i={},r={};for(const t of e.fields){const e=n[t.key]??"";if("Consent"===t.type){const a="true"===e;t.required&&!a&&(i[t.key]=s.inputConsentRequired),r[t.key]=a?"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 a=selectedIds(e);t.required&&0===a.length&&(i[t.key]=s.inputRequired),r[t.key]=JSON.stringify(a)}else if("File"===t.type)t.required&&""===e&&(i[t.key]=s.inputRequired),r[t.key]=e;else{const a=t.secret?e:e.trim();t.required&&""===a&&(i[t.key]=s.inputRequired),r[t.key]=a}}const a={};for(const t of e.fields){if("Otp"!==t.verify)continue;const e=(_[t.key]??"").trim();""===e&&(i[t.key]=s.inputRequired),a[t.key]=e}if(c(i),Object.keys(i).length>0){const t=firstErrorKey(e.fields,i);return void(void 0!==t&&S(t))}m(!0),d("");try{const i=await t.answerInput(e.requestId,r,Object.keys(a).length>0?a:null);if(i.ok)return;c(i.errors),g.current=!0,d(i.message??"")}catch{d(s.errorGeneric)}m(!1)})()}}),T?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.attachmentUploading}):null,w?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.skip,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.skipInput(e.requestId))}}):null,C?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.cancel,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.cancelLead())}}):null]})]})})}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(0,_jsxRuntime.jsx)(_NoticePart.NoticePart,{part:e,message:i,turn:r})}return"Answered"===t.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:t.answeredSummary||r.labels.inputAnswered}):"Skipped"===t.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:r.labels.inputSkipped}):"Expired"===t.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:r.labels.inputExpired}):(0,_jsxRuntime.jsx)(OpenRequest,{part:t,turn:r,pickAttachments:s},t.requestId)}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.InputRequestPart=InputRequestPart;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_chatShared=require("../chatShared.js"),_NoticePart=require("./NoticePart.js"),_jsxRuntime=require("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=(0,_mobileUi.useTheme)(),{labels:s,features:a}=t,[n,l]=(0,_react.useState)({}),[o,c]=(0,_react.useState)({}),[u,d]=(0,_react.useState)(""),[p,m]=(0,_react.useState)(!1),[y,x]=(0,_react.useState)({}),[_,b]=(0,_react.useState)({}),[f,j]=(0,_react.useState)({}),h=(0,_react.useRef)({}),v=(0,_react.useRef)({}),k=(0,_react.useRef)(y),R=(0,_react.useRef)(0),g=(0,_react.useRef)(!1),S=(0,_react.useCallback)(e=>{const t=h.current[e];if(t)return void t.focus();const i=v.current[e];i&&(0,_chatShared.focusForAccessibility)(i)},[]);(0,_react.useEffect)(()=>{if(p||!g.current)return;g.current=!1;const t=firstErrorKey(e.fields,o);void 0!==t&&S(t)},[p,o,e.fields,S]);const setValue=(e,t)=>l(i=>({...i,[e]:t})),commitUploads=e=>{k.current=e,x(e)},patchUpload=(e,t)=>{const i=k.current[e];i&&commitUploads({...k.current,[e]:{...i,...t}})},isLiveUpload=(e,t)=>k.current[e]?.token===t,T=Object.values(y).some(e=>"Ready"!==e.status),leave=async e=>{m(!0),d("");try{await e()}catch{d(s.errorGeneric),m(!1)}},U=a.LeadShortcuts,w=U&&1===e.fields.length&&!e.fields[0].required,C=U&&e.cancellable;return(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",padding:"sm",accessibilityLabel:e.title||void 0,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.sm},children:[e.title?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",accessibilityRole:"header",children:e.title}):null,e.allowTyped?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.typeAnswer}):null,e.fields.map(a=>{const l=n[a.key]??"",c=o[a.key];if("File"===a.type){const e=y[a.key];return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:`${a.label}${optionalSuffix(a,s)}`}),e?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xxs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:e.fileName,variant:"soft",onRemove:()=>{return e=a.key,commitUploads(Object.fromEntries(Object.entries(k.current).filter(([t])=>t!==e))),void setValue(e,"");var e},labels:{remove:s.inputRemoveFile}}),"Uploading"===e.status?(0,_jsxRuntime.jsx)(_mobileUi.ProgressBar,{progress:e.progress??void 0,label:s.attachmentUploading,height:4}):null,"Failed"===e.status?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"assertive",children:s.attachmentFailed}):null]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row"},children:(0,_jsxRuntime.jsx)(_mobileUi.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(e.accept??void 0)}catch{return void d(s.errorGeneric)}const a=r[0];if(!a)return;R.current+=1;const n=R.current;commitUploads({...k.current,[e.key]:{fileName:fileNameOf(a,e.label),status:"Uploading",progress:null,token:n}});try{const i=await t.uploadInputFile(a,t=>{isLiveUpload(e.key,n)&&patchUpload(e.key,{progress:t})});isLiveUpload(e.key,n)&&(setValue(e.key,i),patchUpload(e.key,{status:"Ready",progress:null}))}catch{isLiveUpload(e.key,n)&&(setValue(e.key,""),patchUpload(e.key,{status:"Failed",progress:null}))}})(a)}})}),c?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"assertive",children:c}):null]},a.key)}if("MultiChoice"===a.type){const e=(a.options??[]).map(e=>({label:e.label,value:e.id}));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:`${a.label}${optionalSuffix(a,s)}`}),(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e=>{v.current[a.key]=e},children:(0,_jsxRuntime.jsx)(_mobileUi.ChoiceGroup,{selectionMode:"multiple",options:e,value:selectedIds(l),onChange:t=>setValue(a.key,JSON.stringify(e.filter(e=>t.includes(e.value)).map(e=>e.value))),accessibilityLabel:a.label,error:c,disabled:p})})]},a.key)}if("Choice"===a.type||"TimeSlot"===a.type){const e="TimeSlot"===a.type?(a.slots??[]).map(e=>({label:slotFormat.format(new Date(e.startDateTimeUtc)),value:e.id})):(a.options??[]).map(e=>({label:e.label,value:e.id}));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:`${a.label}${optionalSuffix(a,s)}`}),(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e=>{v.current[a.key]=e},children:(0,_jsxRuntime.jsx)(_mobileUi.ChoiceGroup,{options:e,value:""===l?void 0:l,onChange:e=>setValue(a.key,String(e)),accessibilityLabel:a.label,error:c,disabled:p})})]},a.key)}if("Consent"===a.type)return(0,_jsxRuntime.jsx)(_mobileUi.Checkbox,{checked:"true"===l,onChange:e=>setValue(a.key,e?"true":"false"),label:a.consentText??a.label,error:c,disabled:p},a.key);const u=(0,_jsxRuntime.jsx)(_mobileUi.Input,{ref:e=>{h.current[a.key]=e},label:a.label,placeholder:a.placeholder??void 0,value:l,onChangeText:e=>setValue(a.key,e),maxLength:a.maxLength??void 0,required:a.required,error:c,help:a.required?void 0:s.inputOptional,labelMode:"top",disabled:p,type:a.secret?"password":"LongText"===a.type?"textarea":"input",keyboardType:KEYBOARD_TYPES[a.type]??"default",autoCapitalize:"Email"===a.type?"none":void 0,autoComplete:AUTO_COMPLETE[a.type]},a.key);if(!("Otp"===a.verify&&("Email"===a.type||"Phone"===a.type)))return u;const m=f[a.key];return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[u,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.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:(n[i.key]??"").trim()}),j(e=>({...e,[i.key]:"sent"}))}catch{j(e=>({...e,[i.key]:"failed"}))}})(a)},testID:`otp-send-${a.key}`}),(0,_jsxRuntime.jsx)(_mobileUi.Input,{label:s.inputEnterCode,value:_[a.key]??"",onChangeText:e=>b(t=>({...t,[a.key]:e})),keyboardType:"number-pad",autoComplete:"one-time-code",disabled:p}),m?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"failed"===m?"danger":"secondary",accessibilityLiveRegion:"polite",children:"failed"===m?s.inputCodeFailed:s.inputCodeSent}):null]})]},a.key)}),""!==u?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:u}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:r.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:p?s.inputSubmitting:e.submitLabel,loading:p,disabled:p||T,onPress:()=>{(async()=>{if(T)return;const i={},r={};for(const t of e.fields){const e=n[t.key]??"";if("Consent"===t.type){const a="true"===e;t.required&&!a&&(i[t.key]=s.inputConsentRequired),r[t.key]=a?"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 a=selectedIds(e);t.required&&0===a.length&&(i[t.key]=s.inputRequired),r[t.key]=JSON.stringify(a)}else if("File"===t.type)t.required&&""===e&&(i[t.key]=s.inputRequired),r[t.key]=e;else{const a=t.secret?e:e.trim();t.required&&""===a&&(i[t.key]=s.inputRequired),r[t.key]=a}}const a={};for(const t of e.fields){if("Otp"!==t.verify)continue;const e=(_[t.key]??"").trim();""===e&&(i[t.key]=s.inputRequired),a[t.key]=e}if(c(i),Object.keys(i).length>0){const t=firstErrorKey(e.fields,i);return void(void 0!==t&&S(t))}m(!0),d("");try{const i=await t.answerInput(e.requestId,r,Object.keys(a).length>0?a:null);if(i.ok)return;c(i.errors),g.current=!0,d(i.message??"")}catch{d(s.errorGeneric)}m(!1)})()}}),T?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.attachmentUploading}):null,w?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.skip,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.skipInput(e.requestId))}}):null,C?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.cancel,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.cancelLead())}}):null]})]})})}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(0,_jsxRuntime.jsx)(_NoticePart.NoticePart,{part:e,message:i,turn:r})}return"Answered"===t.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:t.answeredSummary||r.labels.inputAnswered}):"Skipped"===t.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:r.labels.inputSkipped}):"Expired"===t.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:r.labels.inputExpired}):(0,_jsxRuntime.jsx)(OpenRequest,{part:t,turn:r,pickAttachments:s},t.requestId)}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.QuickRepliesPart=QuickRepliesPart;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_ChatEntrance=require("../ChatEntrance.js"),_chatShared=require("../chatShared.js"),_jsxRuntime=require("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}}function QuickRepliesPart({part:e,turn:i}){const t=(0,_mobileUi.useTheme)();if(!i.features.SuggestedReplies||!i.isLast||i.busy||0===e.replies.length)return null;const n=i.openTarget,a=i.onNavigate,r=void 0!==n&&n!==_chatShared.defaultOpenTarget,s="Composer"===e.placement,o=e.replies.filter(e=>"Send"===e.action||"Open"===e.action&&e.target&&n||"Navigate"===e.action&&i.features.LinkHandoff);if(0===o.length)return null;const l=s?void 0:o.find(e=>e.id===_chatCore.CHAT_HANDOFF_REQUEST_ID&&"Send"===e.action),c=l?o.filter(e=>e!==l):o,u=l?1:0,sendChip=(e,t)=>(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:e.label,variant:t.variant,tone:t.tone,leftIcon:e.icon?e.icon:void 0,onPress:()=>{i.chooseQuickReply(e),i.focusComposer?.()}});return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityRole:"summary",accessibilityLabel:i.labels.quickReplies,accessibilityLiveRegion:i.handoffPause?"polite":void 0,style:{flexDirection:"row",flexWrap:"wrap",gap:t.space.xs,...s?{paddingHorizontal:t.space.md}:null},children:[l?(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{index:0,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexBasis:"100%",alignItems:"flex-start",gap:t.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:l.label}),sendChip(l,lookOf("Primary"))]})},l.id):null,c.map((e,t)=>{const s=t+u,o=l?QUIET_LOOK:lookOf(e.variant),c=e.icon?e.icon:void 0;if("Send"===e.action)return(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{index:s,children:sendChip(e,o)},e.id);const d=e.target;if("Open"===e.action&&d&&n)return(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{index:s,children:(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:e.label,variant:o.variant,tone:o.tone,leftIcon:c,onPress:()=>n(d)})},e.id);if("Navigate"===e.action){const t=(e=>{if(!e)return null;if((0,_chatCore.isHandoffTarget)(e,i.handoffHosts))return e;const t=i.resolveLink?.(e);return"string"==typeof t&&""!==t?t:null})(d),l=null===t?void 0:(e=>e.startsWith("/")?n&&r?()=>n(e):a?()=>a(e):void 0:n?()=>n(e):void 0)(t);return null===t||void 0===l?(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{index:s,children:(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"primary",children:e.label})},e.id):(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{index:s,children:(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:i.handoffPause?i.labels.handoffMoment:e.label,variant:i.handoffPause?QUIET_LOOK.variant:o.variant,tone:i.handoffPause?void 0:o.tone,leftIcon:c,disabled:i.handoffPause,onPress:()=>i.beginHandoff(e,l)})},e.id)}return null})]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.QuickRepliesPart=QuickRepliesPart;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_ChatEntrance=require("../ChatEntrance.js"),_chatShared=require("../chatShared.js"),_chipLook=require("./chipLook.js"),_jsxRuntime=require("react/jsx-runtime");const QUIET_LOOK={variant:"outline"};function QuickRepliesPart({part:e,turn:i}){const t=(0,_mobileUi.useTheme)();if(!i.features.SuggestedReplies||!i.isLast||i.busy||0===e.replies.length)return null;const n=i.openTarget,a=i.onNavigate,r=void 0!==n&&n!==_chatShared.defaultOpenTarget,o="Composer"===e.placement,s=e.replies.filter(e=>"Send"===e.action||"Open"===e.action&&e.target&&n||"Navigate"===e.action&&i.features.LinkHandoff);if(0===s.length)return null;const l=o?void 0:s.find(e=>e.id===_chatCore.CHAT_HANDOFF_REQUEST_ID&&"Send"===e.action),c=l?s.filter(e=>e!==l):s,u=l?1:0,sendChip=(e,t)=>(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:e.label,variant:t.variant,tone:t.tone,leftIcon:e.icon?e.icon:void 0,onPress:()=>{i.chooseQuickReply(e),i.focusComposer?.()}});return(0,_jsxRuntime.jsxs)(_reactNative.View,{role:"group",accessibilityLabel:i.labels.quickReplies,accessibilityLiveRegion:i.handoffPause?"polite":void 0,style:{flexDirection:"row",flexWrap:"wrap",gap:t.space.xs,...o?{paddingHorizontal:t.space.md}:null},children:[l?(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{index:0,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexBasis:"100%",alignItems:"flex-start",gap:t.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:l.label}),sendChip(l,(0,_chipLook.chipLook)("Primary"))]})},l.id):null,c.map((e,t)=>{const o=t+u,s=l?QUIET_LOOK:(0,_chipLook.chipLook)(e.variant),c=e.icon?e.icon:void 0;if("Send"===e.action)return(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{index:o,children:sendChip(e,s)},e.id);const d=e.target;if("Open"===e.action&&d&&n)return(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{index:o,children:(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:e.label,variant:s.variant,tone:s.tone,leftIcon:c,onPress:()=>n(d)})},e.id);if("Navigate"===e.action){const t=(e=>{if(!e)return null;if((0,_chatCore.isHandoffTarget)(e,i.handoffHosts))return e;const t=i.resolveLink?.(e);return"string"==typeof t&&""!==t?t:null})(d),l=null===t?void 0:(e=>e.startsWith("/")?n&&r?()=>n(e):a?()=>a(e):void 0:n?()=>n(e):void 0)(t);return null===t||void 0===l?(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{index:o,children:(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"primary",children:e.label})},e.id):(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{index:o,children:(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:i.handoffPause?i.labels.handoffMoment:e.label,variant:i.handoffPause?QUIET_LOOK.variant:s.variant,tone:i.handoffPause?void 0:s.tone,leftIcon:c,disabled:i.handoffPause,onPress:()=>i.beginHandoff(e,l)})},e.id)}return null})]})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TextPart=TextPart;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_FigureText=require("./FigureText.js"),_jsxRuntime=require("react/jsx-runtime");const CITATION=/^\d+$/;function TextPart({part:e,message:t,turn:r}){return"Visitor"===t.author.kind||"Customer"===t.author.kind?r.features.FigureText?(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:e.text,variant:"body",color:"primary"}):(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"body",children:e.text}):(0,_jsxRuntime.jsx)(_mobileUi.Markdown,{links:"app",headings:"text",resolveLink:e=>r.openTarget&&(0,_chatCore.isHandoffTarget)(e,r.handoffHosts)?e:null,onAppLinkPress:e=>r.openTarget?.(e),isCitation:e=>CITATION.test(e),onOpenCitation:r.openCitation?e=>r.openCitation?.(Number(e)):void 0,children:e.text})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TextPart=TextPart;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_FigureText=require("./FigureText.js"),_jsxRuntime=require("react/jsx-runtime");const CITATION=/^\d+$/,PARAGRAPH_ROLE="paragraph";function TextPart({part:e,message:t,turn:r}){const i="Visitor"===t.author.kind||"Customer"===t.author.kind;return(0,_jsxRuntime.jsx)(_reactNative.View,{role:PARAGRAPH_ROLE,children:i?r.features.FigureText?(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:e.text,variant:"body",color:"primary"}):(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"body",children:e.text}):(0,_jsxRuntime.jsx)(_mobileUi.Markdown,{links:"app",headings:"text",resolveLink:e=>r.openTarget&&(0,_chatCore.isHandoffTarget)(e,r.handoffHosts)?e:null,onAppLinkPress:e=>r.openTarget?.(e),isCitation:e=>CITATION.test(e),figureText:r.features.FigureText?_chatCore.toFigureRuns:void 0,onOpenCitation:r.openCitation?e=>r.openCitation?.(Number(e)):void 0,children:e.text})})}
@@ -0,0 +1 @@
1
+ "use strict";function chipLook(e){switch(e){case"Primary":case"Cta":return{variant:"solid",tone:"primary"};default:return{variant:"outline"}}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.chipLook=chipLook;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SpeechRequestError=void 0,exports.synthesizeSpeech=synthesizeSpeech,exports.transcribeClip=transcribeClip;var _chatCore=require("@webority/chat-core"),_speechText=require("./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]+$/;class SpeechRequestError extends Error{constructor(e){super(`Speech request failed with status ${e}`),this.name="SpeechRequestError",this.status=e}}exports.SpeechRequestError=SpeechRequestError;const assertRegion=e=>{if(!REGION_PATTERN.test(e))throw new _chatCore.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)}};async function transcribeClip(e){const{token:t,uri:r,language:o,signal:s,fetchImpl:i=fetch}=e;assertRegion(t.region);const a=new FormData;return a.append("audio",{uri:r,name:"dictation.m4a",type:"audio/mp4"}),a.append("definition",JSON.stringify({locales:[o]})),withTimeout(s,async e=>{const r=await i(`https://${t.region}.api.cognitive.microsoft.com/speechtotext/transcriptions:transcribe?api-version=${TRANSCRIBE_API_VERSION}`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`},body:a,signal:e});if(!r.ok)throw new SpeechRequestError(r.status);return((await r.json()).combinedPhrases??[]).map(e=>e.text??"").join(" ").trim()})}async function synthesizeSpeech(e){const{token:t,text:r,language:o,voice:s,signal:i,fetchImpl:a=fetch}=e;return assertRegion(t.region),withTimeout(i,async e=>{const i=await a(`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:(0,_speechText.buildSsml)((0,_speechText.clampSpeakText)(r),o,s),signal:e});if(!i.ok)throw new SpeechRequestError(i.status);return new Uint8Array(await i.arrayBuffer())})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SpeechRequestError=void 0,exports.synthesizeSpeech=synthesizeSpeech,exports.transcribeClip=transcribeClip;var _chatCore=require("@webority/chat-core"),_mobileCore=require("@webority/mobile-core"),_speechText=require("./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]+$/;class SpeechRequestError extends Error{constructor(e){super(`Speech request failed with status ${e}`),this.name="SpeechRequestError",this.status=e}}exports.SpeechRequestError=SpeechRequestError;const assertRegion=e=>{if(!REGION_PATTERN.test(e))throw new _chatCore.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)}};async function transcribeClip(e){const{token:t,uri:r,language:o,signal:i,fetchImpl:s=fetch}=e;assertRegion(t.region);const a=new FormData;return a.append("audio",{uri:r,name:"dictation.m4a",type:"audio/mp4"}),a.append("definition",JSON.stringify({locales:[o]})),withTimeout(i,async e=>{const r=await(0,_mobileCore.fetchWithRetry)(s,`https://${t.region}.api.cognitive.microsoft.com/speechtotext/transcriptions:transcribe?api-version=${TRANSCRIBE_API_VERSION}`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`},body:a,signal:e});if(!r.ok)throw new SpeechRequestError(r.status);return((await r.json()).combinedPhrases??[]).map(e=>e.text??"").join(" ").trim()})}async function synthesizeSpeech(e){const{token:t,text:r,language:o,voice:i,signal:s,fetchImpl:a=fetch}=e;return assertRegion(t.region),withTimeout(s,async e=>{const s=await(0,_mobileCore.fetchWithRetry)(a,`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:(0,_speechText.buildSsml)((0,_speechText.clampSpeakText)(r),o,i),signal:e});if(!s.ok)throw new SpeechRequestError(s.status);return new Uint8Array(await s.arrayBuffer())})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useChat=useChat;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("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((0,_chatCore.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()}}});function useChat(e){const{client:t,screen:r,layout:n,narrow:a,conversationId:c,pageContext:o,behaviour:s,prefs:u,getCaptchaToken:i,onEvent:l,onError:f,onNavigate:_}=e,p=JSON.stringify(a??{}),d=(0,_react.useRef)(_);d.current=_;const v=(0,_react.useCallback)(e=>d.current?.(e),[]),m=(0,_react.useRef)(c);m.current=c;const h=(0,_react.useRef)(o);h.current=o;const E=(0,_react.useRef)(s);E.current=s;const g=(0,_react.useRef)(i);g.current=i;const S=(0,_react.useRef)(l);S.current=l;const y=(0,_react.useRef)(f);y.current=f;const C=(0,_react.useRef)(u);C.current=u;const b=(0,_mobileUi.useReducedMotion)(),I=(0,_react.useRef)(b);I.current=b;const[R,A]=(0,_react.useState)(null),[N,L]=(0,_react.useState)(null);(0,_react.useEffect)(()=>{const e=(0,_chatCore.createChatSession)(t,{screen:r,layout:n,pathname:()=>r||"/",narrow:JSON.parse(p),conversationId:m.current??void 0,pageContext:()=>h.current,behaviour:()=>E.current?.()??null,prefs:C.current,getCaptchaToken:e=>g.current?.(e)??Promise.reject(new Error("No captcha handler.")),onEvent:(e,t)=>S.current?.(e,t),onError:e=>y.current?.(e),schedule:requestFrame,reducedMotion:()=>I.current});return A({client:t,screen:r,layout:n,narrowKey:p,session:e}),()=>e.dispose()},[t,r,n,p]);const O=null!==R&&R.client===t&&R.screen===r&&R.layout===n&&R.narrowKey===p?R.session:IDLE_SESSION,T=(0,_react.useSyncExternalStore)(O.subscribe,O.getState),w=(0,_react.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=>{L(null);try{await O.requestHandoff(e)}catch(e){const t=e instanceof Error&&""!==e.message?e.message:_chatCore.DEFAULT_CHAT_LABELS.errorGeneric;throw L(t),e}},notifyTyping:()=>O.notifyTyping(),resumeLive:()=>O.resumeLive()}),[O]),k=(0,_react.useRef)(c);(0,_react.useEffect)(()=>{O!==IDLE_SESSION&&c&&c!==k.current&&(k.current=c,O.openConversation(c))},[c,O]);const q=(0,_react.useRef)("active"===_reactNative.AppState.currentState),P=(0,_react.useRef)(!0),j=(0,_react.useCallback)(()=>O.setLiveActive(q.current&&P.current),[O]),x=(0,_react.useCallback)(e=>{P.current=e,j()},[j]);(0,_react.useEffect)(()=>{j();const e=_reactNative.AppState.addEventListener("change",e=>{"active"===e?(q.current=!0,O.endHandoffPause()):q.current=!1,j()});return()=>e.remove()},[j,O]);const D=(0,_react.useCallback)((e,t)=>{S.current?.(e,t)},[]);return{...T,...w,session:O,client:t,emit:D,setChatVisible:x,handoffError:N,onNavigate:_?v:void 0}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useChat=useChat;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("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((0,_chatCore.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,handoffContactRequestId:null,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()}}});function useChat(e){const{client:t,screen:r,layout:n,narrow:a,conversationId:c,pageContext:o,behaviour:s,attribution:u,prefs:i,getCaptchaToken:l,onEvent:f,onError:_,onNavigate:d}=e,p=JSON.stringify(a??{}),v=(0,_react.useRef)(d);v.current=d;const m=(0,_react.useCallback)(e=>v.current?.(e),[]),h=(0,_react.useRef)(c);h.current=c;const E=(0,_react.useRef)(o);E.current=o;const g=(0,_react.useRef)(s);g.current=s;const S=(0,_react.useRef)(u);S.current=u;const C=(0,_react.useRef)(l);C.current=l;const y=(0,_react.useRef)(f);y.current=f;const b=(0,_react.useRef)(_);b.current=_;const I=(0,_react.useRef)(i);I.current=i;const R=(0,_mobileUi.useReducedMotion)(),A=(0,_react.useRef)(R);A.current=R;const[N,L]=(0,_react.useState)(null),[O,T]=(0,_react.useState)(null);(0,_react.useEffect)(()=>{const e=(0,_chatCore.createChatSession)(t,{screen:r,layout:n,pathname:()=>r||"/",narrow:JSON.parse(p),conversationId:h.current??void 0,pageContext:()=>E.current,behaviour:()=>g.current?.()??null,attribution:()=>S.current?.()??null,prefs:I.current,getCaptchaToken:e=>C.current?.(e)??Promise.reject(new Error("No captcha handler.")),onEvent:(e,t)=>y.current?.(e,t),onError:e=>b.current?.(e),schedule:requestFrame,reducedMotion:()=>A.current});return L({client:t,screen:r,layout:n,narrowKey:p,session:e}),()=>e.dispose()},[t,r,n,p]);const w=null!==N&&N.client===t&&N.screen===r&&N.layout===n&&N.narrowKey===p?N.session:IDLE_SESSION,k=(0,_react.useSyncExternalStore)(w.subscribe,w.getState),q=(0,_react.useMemo)(()=>({load:()=>w.load(),submit:e=>w.submit(e),chooseQuickReply:e=>w.chooseQuickReply(e),answerInput:(e,t)=>w.answerInput(e,t),confirmAction:e=>w.confirmAction(e),rejectAction:(e,t)=>w.rejectAction(e,t),stop:()=>w.stop(),retry:()=>w.retry(),regenerate:()=>w.regenerate(),startEdit:e=>w.startEdit(e),cancelEdit:()=>w.cancelEdit(),attach:e=>w.attach(e),removeAttachment:e=>w.removeAttachment(e),openConversation:e=>w.openConversation(e),resumeLast:()=>w.resumeLast(),newConversation:()=>w.newConversation(),rate:(e,t,r)=>w.rate(e,t,r),reset:()=>w.reset(),requestHandoff:async e=>{T(null);try{await w.requestHandoff(e)}catch(e){const t=e instanceof Error&&""!==e.message?e.message:_chatCore.DEFAULT_CHAT_LABELS.errorGeneric;throw T(t),e}},notifyTyping:()=>w.notifyTyping(),resumeLive:()=>w.resumeLive()}),[w]),P=(0,_react.useRef)(c);(0,_react.useEffect)(()=>{w!==IDLE_SESSION&&c&&c!==P.current&&(P.current=c,w.openConversation(c))},[c,w]);const j=(0,_react.useRef)("active"===_reactNative.AppState.currentState),x=(0,_react.useRef)(!0),D=(0,_react.useCallback)(()=>w.setLiveActive(j.current&&x.current),[w]),F=(0,_react.useCallback)(e=>{x.current=e,D()},[D]);(0,_react.useEffect)(()=>{D();const e=_reactNative.AppState.addEventListener("change",e=>{"active"===e?(j.current=!0,w.endHandoffPause()):j.current=!1,D()});return()=>e.remove()},[D,w]);const U=(0,_react.useCallback)((e,t)=>{y.current?.(e,t)},[]);return{...k,...q,session:w,client:t,emit:U,setChatVisible:F,handoffError:O,onNavigate:d?m:void 0}}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=useTranscriptActions;var _chatCore=require("@webority/chat-core"),_mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native");const NOTICE_MS=3e3;async function shareMessages(e,r,t,a){const s=(0,_chatCore.buildTranscript)(e,r);if(0===s.entries.length)return;const c=(0,_chatCore.transcriptToText)(s,{heading:t,speakers:t});try{await _reactNative.Share.share({message:c,title:s.title})}catch(e){_mobileCore.Logger.error("[chat] share failed",e),a()}}function useTranscriptActions(e,r){const[t,a]=(0,_react.useState)(null),s=(0,_react.useRef)(null),c=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>(c.current=!0,()=>{c.current=!1,null!==s.current&&clearTimeout(s.current)}),[]);const i=(0,_react.useCallback)(e=>{c.current&&(null!==s.current&&clearTimeout(s.current),a(e),s.current=setTimeout(()=>a(null),NOTICE_MS))},[]),{messages:u,title:n}=e,l=e.features.FigureText,o=(0,_react.useCallback)(e=>shareMessages([e],{labels:r,title:n,figureText:l},!1,()=>i(r.shareFailed)),[r,n,l,i]),h=(0,_react.useCallback)(()=>shareMessages(u,{labels:r,title:n,figureText:l},!0,()=>i(r.shareFailed)),[u,r,n,l,i]);return{canShare:e.features.Share,notice:t,shareReply:o,shareConversation:h}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=useTranscriptActions;var _chatCore=require("@webority/chat-core"),_mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native");const NOTICE_MS=3e3;async function shareMessages(e,r,t,a){const s=(0,_chatCore.buildTranscript)(e,r);if(0===s.entries.length)return;const c=(0,_chatCore.transcriptToText)(s,{heading:t,speakers:t});try{await _reactNative.Share.share({message:c,title:s.title})}catch(e){_mobileCore.Logger.error("[chat] share failed",e),a()}}function useTranscriptActions(e,r){const[t,a]=(0,_react.useState)(null),s=(0,_react.useRef)(null),c=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>(c.current=!0,()=>{c.current=!1,null!==s.current&&clearTimeout(s.current)}),[]);const i=(0,_react.useCallback)(e=>{c.current&&(null!==s.current&&clearTimeout(s.current),a(e),s.current=setTimeout(()=>a(null),NOTICE_MS))},[]),{messages:n,title:u}=e,l=e.features.FigureText,o=e.profile?.assistant.name,h=(0,_react.useCallback)(e=>shareMessages([e],{labels:r,title:u,figureText:l,assistantName:o},!1,()=>i(r.shareFailed)),[r,u,l,o,i]),_=(0,_react.useCallback)(()=>shareMessages(n,{labels:r,title:u,figureText:l,assistantName:o},!0,()=>i(r.shareFailed)),[n,r,u,l,o,i]);return{canShare:e.features.Share,notice:t,shareReply:h,shareConversation:_}}
@@ -1 +1 @@
1
- "use strict";import{Avatar,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function AgentByline({author:e,labels:t}){const r=useTheme(),i=e.displayName||t.agent,a=e.avatarUrl?{uri:e.avatarUrl}:void 0;return _jsxs(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:"row",alignItems:"center",gap:r.space.xs},children:[_jsx(Avatar,{size:"xs",name:i,source:a}),_jsx(Text,{variant:"caption",color:"secondary",children:i}),_jsx(Text,{variant:"caption",color:"tertiary",children:t.agent})]})}
1
+ "use strict";import{Avatar,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function AgentByline({author:e,labels:t,showAvatar:r=!0}){const a=useTheme(),i=e.displayName||t.agent,s=e.avatarUrl?{uri:e.avatarUrl}:void 0;return _jsxs(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:"row",alignItems:"center",gap:a.space.xs},children:[r?_jsx(Avatar,{size:"xs",name:i,source:s}):null,_jsx(Text,{variant:"caption",color:"secondary",children:i}),_jsx(Text,{variant:"caption",color:"tertiary",children:t.agent})]})}
@@ -1 +1 @@
1
- "use strict";import{defaultChatLook}from"@webority/chat-core";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,look:l=defaultChatLook}){const c=useTheme(),u=useMemo(()=>buildStyles(c),[c]),[m,p]=useState(""),[h,d]=useState(null),f=e.editing,g=useRef(null),x=useRef(null);useEffect(()=>{if(r)return r.current=()=>x.current?.focus(),()=>{r.current=null}},[r]),useEffect(()=>{f&&g.current?.(),p(f?f.text:"")},[f]);const b=e.attachments,y=b.some(e=>"Uploading"===e.status),v=b.some(e=>"Ready"===e.status),j=e.messagesLeftToday,_=e.profile?.limits.maxMessageLength??4e3,S=void 0!==s&&e.features.Attachments&&(e.profile?.limits.maxAttachments??0)>0,w=e.features.HumanHandoff&&("WaitingForAgent"===e.conversationState||"WithAgent"===e.conversationState),A=S&&!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,C=f?_jsx(Banner,{message:t.editing,accessibilityRole:"summary",actions:[{label:t.cancel,onPress:()=>e.cancelEdit()}],testID:`${i}-editing`}):null,T=b.length>0?_jsx(View,{style:u.tray,testID:`${i}-attachments`,children:_jsx(View,{style:u.row,children:b.map(s=>_jsxs(View,{style:u.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:u.progress}):null,"Failed"===s.status?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:s.error??t.attachmentFailed}):null]},s.key))})}):null,D=null!==j&&j<=10?_jsx(Text,{variant:"caption",color:0===j?"danger":"secondary",accessibilityLiveRegion:"polite",testID:`${i}-allowance`,children:t.allowance(j)}):null,L=h?_jsx(Banner,{message:h.message,tone:h.tone,dismissible:!0,onClose:()=>d(null),actions:h.openSettings?[{label:t.dictateOpenSettings,onPress:()=>{Permissions.openSettings()}}]:void 0,testID:`${i}-voice-notice`}):null,R=m.length>0,k=m.length>.9*_?_jsx(Text,{variant:"caption",color:"secondary",testID:`${i}-counter`,children:t.counter(m.length,_)}):null,I=C||T||D||k||L?_jsxs(_Fragment,{children:[C,T,D,k,L]}):void 0,P=!y&&(!!v||void 0);return _jsx(Composer,{ref:x,onSend:t=>{g.current?.(),e.submit(t)},value:m,onChangeText:t=>{g.current?.(),p(t),w&&t.length>0&&e.notifyTyping()},loading:e.streaming&&e.features.Stop,ring:l.input.ring&&(R||e.streaming),sendReveal:"Always"===l.input.sendReveal?"always":"onText",onStop:e.features.Stop?()=>e.stop():void 0,stopLabel:t.stop,disabled:0===j||e.handoffPause,maxLength:_,canSend:P,placeholder:e.handoffPause?t.handoffMoment:openQuestion(e.messages)??t.placeholder,accessibilityLabel:t.composer,labels:{send:t.send},leading:A,trailing:_jsx(ChatDictationButton,{chat:e,labels:t,disabled:0===j||e.handoffPause,onText:e=>p(t=>joinDictation(t,e,_)),onNotice:d,stopRef:g}),above:I,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}});
1
+ "use strict";import{defaultChatLook}from"@webority/chat-core";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:o,keyboardAware:a,safeArea:n,testID:i="chat-composer",focusRef:r,look:l=defaultChatLook,sendIcon:c}){const u=useTheme(),m=useMemo(()=>buildStyles(u),[u]),[p,d]=useState(""),[h,f]=useState(null),g=e.editing,x=useRef(null),b=useRef(null);useEffect(()=>{if(r)return r.current=()=>b.current?.focus(),()=>{r.current=null}},[r]),useEffect(()=>{g&&x.current?.(),d(g?g.text:"")},[g]);const y=e.attachments,v=y.some(e=>"Uploading"===e.status),j=y.some(e=>"Ready"===e.status),_=e.messagesLeftToday,S=e.profile?.limits.maxMessageLength??4e3,w=void 0!==s&&e.features.Attachments&&(e.profile?.limits.maxAttachments??0)>0,A=e.features.HumanHandoff&&("WaitingForAgent"===e.conversationState||"WithAgent"===e.conversationState),C=w&&!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,T=g?_jsx(Banner,{message:t.editing,accessibilityRole:"summary",actions:[{label:t.cancel,onPress:()=>e.cancelEdit()}],testID:`${i}-editing`}):null,D=y.length>0?_jsx(View,{style:m.tray,testID:`${i}-attachments`,children:_jsx(View,{style:m.row,children:y.map(s=>_jsxs(View,{style:m.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:m.progress}):null,"Failed"===s.status?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:s.error??t.attachmentFailed}):null]},s.key))})}):null,I=null!==_&&_<=10?_jsx(Text,{variant:"caption",color:0===_?"danger":"secondary",accessibilityLiveRegion:"polite",testID:`${i}-allowance`,children:t.allowance(_)}):null,L=h?_jsx(Banner,{message:h.message,tone:h.tone,dismissible:!0,onClose:()=>f(null),actions:h.openSettings?[{label:t.dictateOpenSettings,onPress:()=>{Permissions.openSettings()}}]:void 0,testID:`${i}-voice-notice`}):null,R=p.length>0,k=p.length>.9*S?_jsx(Text,{variant:"caption",color:"secondary",testID:`${i}-counter`,children:t.counter(p.length,S)}):null,P=T||D||I||k||L?_jsxs(_Fragment,{children:[T,D,I,k,L]}):void 0,B=!v&&(!!j||void 0);return _jsx(Composer,{ref:b,onSend:t=>{x.current?.(),e.submit(t)},value:p,onChangeText:t=>{x.current?.(),d(t),A&&t.length>0&&e.notifyTyping()},loading:e.streaming&&e.features.Stop,ring:l.input.ring&&(R||e.streaming),sendReveal:"Always"===l.input.sendReveal?"always":"onText",sendIcon:c||void 0,onStop:e.features.Stop?()=>e.stop():void 0,stopLabel:t.stop,disabled:0===_||e.handoffPause,maxLength:S,canSend:B,placeholder:e.handoffPause?t.handoffMoment:openQuestion(e.messages)??t.placeholder,accessibilityLabel:t.composer,labels:{send:t.send},leading:C,trailing:_jsx(ChatDictationButton,{chat:e,labels:t,disabled:0===_||e.handoffPause,onText:e=>d(t=>joinDictation(t,e,S)),onNotice:f,stopRef:x}),above:P,below:_jsx(ChatFooter,{chat:e,labels:t}),keyboardAware:a,keyboardOffset:o,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}});
@@ -1 +1 @@
1
- "use strict";import{mergeLook}from"@webority/chat-core";import{Banner,IconButton,Spinner,Text,useReducedMotion,useTheme}from"@webority/mobile-ui";import{useMemo,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{ChatPanelGrow,ChatReveal,panelRun}from"./ChatPanel.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",look:a,pickAttachments:n,onOpenAttachment:i,onOpenTarget:l,onNavigate:c,openTicket:h,handoffHosts:m,resolveLink:u,keyboardOffset:d,layout:p,title:f,headerActions:C,onClose:x,enterKey:j=0,testID:y="chat-frame"}){const b=useTheme(),g=useMemo(()=>mergeLook(a),[a]),v=useReducedMotion(),_="Reduced"===g.motion||v,I="embedded"===p?"None":g.panel.motion,k="sheet"===p?"sheet":"screen",w=useMemo(()=>panelRun({motion:I,reduced:_,mode:k,run:j}),[I,_,k,j]),[D,R]=useState(!1),S=D&&!0===e.features.History;useChatHaptics(e),useChatSound(e);const T="sheet"!==p,B=null!==e.profile,$=useRef(null);if(B&&!e.features.VisitorChat)return null;const L=e.messages.length>0,A=e.messages.some(e=>"Visitor"===e.author.kind||"Customer"===e.author.kind),H="screen"===p||A,O=!0===e.profile?.experience.sound.muteControl&&e.features.Sounds,P=_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:f??e.profile?.assistant.name??t.panelTitle}),_jsx(Text,{variant:"caption",color:"secondary",children:t.headerStatus})]}),C,S?null:_jsx(ChatConversationActions,{chat:e,labels:t,testID:`${y}-conversation-actions`}),e.features.History?_jsx(IconButton,{icon:S?"arrow-left":"history",variant:"ghost",tone:"neutral",accessibilityLabel:S?t.backToChat:t.history,onPress:()=>R(e=>!e),testID:`${y}-history`}):null,O?_jsx(IconButton,{icon:e.muted?"volume-mute":"volume-high",variant:"ghost",tone:"neutral",accessibilityLabel:e.muted?t.unmuteSounds:t.muteSounds,onPress:()=>e.session.setMuted(!e.muted),testID:`${y}-mute`}):null,S||!H?null:_jsx(IconButton,{icon:"plus",variant:"ghost",tone:"neutral",accessibilityLabel:t.newChat,disabled:e.streaming||e.thinking,onPress:()=>e.newConversation(),testID:`${y}-new`}),x?_jsx(IconButton,{icon:"x",variant:"ghost",tone:"neutral",accessibilityLabel:t.close,onPress:x,testID:`${y}-close`}):null]});let V;return V=S?_jsx(ChatHistory,{chat:e,labels:t,onOpen:()=>R(!1),testID:`${y}-history-list`}):e.profileError?_jsx(Banner,{tone:"danger",message:e.profileError.message,accessibilityRole:"alert",testID:`${y}-profile-error`}):!B||e.loading?_jsx(View,{style:{flex:1,alignItems:"center",justifyContent:"center"},children:_jsx(Spinner,{message:t.loadingConversation,testID:`${y}-loading`})}):e.loadError?_jsx(Banner,{tone:"danger",message:e.loadError.message,accessibilityRole:"alert",testID:`${y}-load-error`}):L?_jsx(ChatThread,{chat:e,labels:t,renderers:s,layoutParts:o,loader:r,motion:g.motion,pickAttachments:n,onOpenAttachment:i,onOpenTarget:l,onNavigate:c,openTicket:h,handoffHosts:m,resolveLink:u,focusComposer:()=>$.current?.(),keyboardAware:T,keyboardOffset:d,style:{flex:1},testID:`${y}-thread`}):_jsx(ChatStarters,{chat:e,labels:t,openTicket:h,testID:`${y}-starters`}),_jsx(ChatPanelGrow,{grow:w.grow,children:_jsxs(View,{style:{flex:1},testID:y,children:[_jsx(ChatReveal,{plan:w.reveal.header,children:P}),S?null:_jsx(ChatLiveBar,{chat:e,labels:t,testID:`${y}-live`}),_jsx(ChatReveal,{plan:w.reveal.body,flex:!0,children:_jsx(View,{style:{flex:1},children:V})}),S?null:_jsx(ChatReveal,{plan:w.reveal.composer,children:_jsx(ChatComposer,{chat:e,labels:t,look:g,pickAttachments:n,keyboardOffset:d,keyboardAware:T,focusRef:$,testID:`${y}-composer`})})]})})}
1
+ "use strict";import{mergeLook}from"@webority/chat-core";import{Avatar,Banner,IconButton,Spinner,Text,useReducedMotion,useTheme}from"@webority/mobile-ui";import{useMemo,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{ChatPanelGrow,ChatReveal,panelRun}from"./ChatPanel.js";import{ChatStarters}from"./ChatStarters.js";import{ChatThread}from"./ChatThread.js";import{WEB_STRONG}from"./chatShared.js";import{useChatHaptics}from"./useChatHaptics.js";import{useChatSound}from"./useChatSound.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const lastAgentName=e=>{for(let t=e.length-1;t>=0;t-=1){const s=e[t]?.author;if("Agent"===s?.kind&&s.displayName?.trim())return s.displayName}return null},headerStatusText=(e,t)=>"WaitingForAgent"===e.conversationState?t.statusWaitingForAgent:"WithAgent"===e.conversationState?t.statusWithAgent(lastAgentName(e.messages)??t.handoffAgentFallback):t.headerStatus;export function ChatFrame({chat:e,labels:t,renderers:s,layoutParts:a,loader:o="Steps",look:r,pickAttachments:n,onOpenAttachment:i,onOpenTarget:l,onNavigate:c,openTicket:h,handoffHosts:m,resolveLink:u,keyboardOffset:d,layout:p,title:f,headerActions:g,onClose:C,enterKey:x=0,testID:v="chat-frame"}){const j=useTheme(),y=useMemo(()=>mergeLook(r),[r]),b=useReducedMotion(),_="Reduced"===y.motion||b,A="embedded"===p?"None":y.panel.motion,I="sheet"===p?"sheet":"screen",k=useMemo(()=>panelRun({motion:A,reduced:_,mode:I,run:x}),[A,_,I,x]),[S,w]=useState(!1),T=S&&!0===e.features.History;useChatHaptics(e),useChatSound(e);const D="sheet"!==p,R=null!==e.profile,B=useRef(null);if(R&&!e.features.VisitorChat)return null;const L=e.messages.length>0,$=e.messages.some(e=>"Visitor"===e.author.kind||"Customer"===e.author.kind),H="screen"===p||$,O=!0===e.profile?.experience.sound.muteControl&&e.features.Sounds,V=f??e.profile?.assistant.name??t.panelTitle,N=_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:j.space.sm,paddingHorizontal:j.space.md,paddingVertical:j.space.sm,borderBottomWidth:1,borderBottomColor:j.colors["border-subtle"]},children:[y.avatar?_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:_jsx(Avatar,{size:"sm",name:e.profile?.assistant.name??t.panelTitle,source:{uri:y.avatar}})}):null,_jsxs(View,{style:{flex:1,minWidth:0},children:[_jsx(Text,{variant:"title",numberOfLines:1,...WEB_STRONG,children:V}),_jsx(Text,{variant:"caption",color:"secondary",children:headerStatusText(e,t)})]}),g,T?null:_jsx(ChatConversationActions,{chat:e,labels:t,testID:`${v}-conversation-actions`}),e.features.History?_jsx(IconButton,{icon:T?"arrow-left":"history",variant:"ghost",tone:"neutral",accessibilityLabel:T?t.backToChat:t.history,onPress:()=>w(e=>!e),testID:`${v}-history`}):null,O?_jsx(IconButton,{icon:e.muted?"volume-mute":"volume-high",variant:"ghost",tone:"neutral",accessibilityLabel:e.muted?t.unmuteSounds:t.muteSounds,onPress:()=>e.session.setMuted(!e.muted),testID:`${v}-mute`}):null,T||!H?null:_jsx(IconButton,{icon:"plus",variant:"ghost",tone:"neutral",accessibilityLabel:t.newChat,disabled:e.streaming||e.thinking,onPress:()=>e.newConversation(),testID:`${v}-new`}),C?_jsx(IconButton,{icon:"x",variant:"ghost",tone:"neutral",accessibilityLabel:t.close,onPress:C,testID:`${v}-close`}):null]});let P;return P=T?_jsx(ChatHistory,{chat:e,labels:t,onOpen:()=>w(!1),testID:`${v}-history-list`}):e.profileError?_jsx(Banner,{tone:"danger",message:e.profileError.message,accessibilityRole:"alert",testID:`${v}-profile-error`}):!R||e.loading?_jsx(View,{style:{flex:1,alignItems:"center",justifyContent:"center"},children:_jsx(Spinner,{message:t.loadingConversation,testID:`${v}-loading`})}):e.loadError?_jsx(Banner,{tone:"danger",message:e.loadError.message,accessibilityRole:"alert",testID:`${v}-load-error`}):L?_jsx(ChatThread,{chat:e,labels:t,renderers:s,layoutParts:a,loader:o,motion:y.motion,avatar:y.avatar,replyAvatars:y.panel.replyAvatars,expressive:y.expressive,pickAttachments:n,onOpenAttachment:i,onOpenTarget:l,onNavigate:c,openTicket:h,handoffHosts:m,resolveLink:u,focusComposer:()=>B.current?.(),keyboardAware:D,keyboardOffset:d,style:{flex:1},testID:`${v}-thread`}):_jsx(ChatStarters,{chat:e,labels:t,openTicket:h,avatar:y.avatar,motion:y.motion,greetingLoaderMs:_?0:y.panel.greetingLoaderMs,testID:`${v}-starters`}),_jsx(ChatPanelGrow,{grow:k.grow,children:_jsxs(View,{style:{flex:1},role:"sheet"===p?"dialog":"region",accessibilityLabel:V,testID:v,children:[_jsx(ChatReveal,{plan:k.reveal.header,children:N}),T?null:_jsx(ChatLiveBar,{chat:e,labels:t,testID:`${v}-live`}),_jsx(ChatReveal,{plan:k.reveal.body,flex:!0,children:_jsx(View,{style:{flex:1},children:P})}),T?null:_jsx(ChatReveal,{plan:k.reveal.composer,children:_jsx(ChatComposer,{chat:e,labels:t,look:y,sendIcon:r?.input?.sendIcon,pickAttachments:n,keyboardOffset:d,keyboardAware:D,focusRef:B,testID:`${v}-composer`})})]})})}
@@ -1 +1 @@
1
- "use strict";import{FloatingActionButton,useTheme}from"@webority/mobile-ui";import{useEffect,useState}from"react";import{Animated,Easing,StyleSheet}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{jsx as _jsx}from"react/jsx-runtime";const RISE_MS=900,RISE_DELAY_MS=400,ENTRANCE_MS=800,ENTRANCE_DELAY_MS=1e3,FLOAT_HALF_MS=1600,FLOAT_PX=4,RISE_FROM_PX=116;function entranceStyle(e,t){const range=(e,a)=>t.interpolate({inputRange:e,outputRange:a,extrapolate:"clamp"});switch(e){case"Rise":return{opacity:range([0,.4,1],[0,1,1]),transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[116,0]})}]};case"SlideUp":return{opacity:range([0,1],[0,1]),transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[100,0]})},{scale:t.interpolate({inputRange:[0,1],outputRange:[.8,1]})}]};case"BounceIn":return{transform:[{scale:range([0,.5,.7,1],[.3,1.05,.9,1])}]};case"FadeInPulse":return{opacity:range([0,.5,1],[0,1,1]),transform:[{scale:range([0,.5,1],[1,1.1,1])}]};case"SpinScale":return{transform:[{rotate:t.interpolate({inputRange:[0,1],outputRange:["-180deg","0deg"]})},{scale:t.interpolate({inputRange:[0,1],outputRange:[0,1]})}]};case"WiggleIn":return{transform:[{translateY:range([0,.4,1],[100,0,0])},{rotate:range([0,.4,.6,.8,1],["-10deg","5deg","-3deg","1deg","0deg"])}]};case"ElasticIn":return{transform:[{scale:range([0,.55,.75,1],[0,1.1,.95,1])}]};default:return{transform:[]}}}const OVERSHOOT=new Set(["Rise","SlideUp","SpinScale"]);export function ChatLauncher({look:e,label:t,side:a,offsetX:n,offsetY:s,enter:r,reduced:i,buttonRef:o,onPress:u,testID:l}){const c=useTheme(),p=useSafeAreaInsets(),m=e.launcher.entrance,[g]=useState(()=>r&&!i&&"None"!==m),f=!i&&"FloatAndPulse"===e.launcher.idle,[d]=useState(()=>new Animated.Value(g?0:1)),[S]=useState(()=>new Animated.Value(0));useEffect(()=>{if(!g)return void d.setValue(1);const e="Rise"===m,t=Animated.timing(d,{toValue:1,duration:e?900:800,delay:e?400:1e3,easing:OVERSHOOT.has(m)?Easing.bezier(.34,e?1.4:1.56,.64,1):Easing.linear,useNativeDriver:!0});return t.start(),()=>t.stop()},[g,m,d]),useEffect(()=>{if(!f)return void S.setValue(0);const e=Animated.loop(Animated.sequence([Animated.timing(S,{toValue:1,duration:1600,easing:Easing.inOut(Easing.ease),useNativeDriver:!0}),Animated.timing(S,{toValue:0,duration:1600,easing:Easing.inOut(Easing.ease),useNativeDriver:!0})]));return e.start(),()=>e.stop()},[f,S]);const R="Pill"===e.launcher.style&&!e.launcher.compact,E=c.space[c.components["floating-action-button"]["edge-offset"]]+n,A={position:"absolute",bottom:s+p.bottom,..."start"===a?{left:E}:{right:E}},h=entranceStyle(m,d);return _jsx(Animated.View,{pointerEvents:"box-none",style:StyleSheet.absoluteFill,children:_jsx(Animated.View,{style:[A,{opacity:h.opacity??1,transform:[...h.transform,{translateY:S.interpolate({inputRange:[0,1],outputRange:[0,-4]})}]}],children:_jsx(FloatingActionButton,{ref:o,icon:"messages",label:R?t:void 0,collapsed:!R,accessibilityLabel:t,onPress:u,testID:l})})})}
1
+ "use strict";import{Avatar,FloatingActionButton,useTheme}from"@webority/mobile-ui";import{useEffect,useState}from"react";import{Animated,Easing,StyleSheet}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{jsx as _jsx}from"react/jsx-runtime";const RISE_MS=900,RISE_DELAY_MS=400,ENTRANCE_MS=800,ENTRANCE_DELAY_MS=1e3,FLOAT_HALF_MS=1600,FLOAT_PX=4,RISE_FROM_PX=116,SHRINK_MS=320,SHRINK_EASING=Easing.bezier(.4,0,.2,1);function entranceStyle(e,t){const range=(e,a)=>t.interpolate({inputRange:e,outputRange:a,extrapolate:"clamp"});switch(e){case"Rise":return{opacity:range([0,.4,1],[0,1,1]),transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[116,0]})}]};case"SlideUp":return{opacity:range([0,1],[0,1]),transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[100,0]})},{scale:t.interpolate({inputRange:[0,1],outputRange:[.8,1]})}]};case"BounceIn":return{transform:[{scale:range([0,.5,.7,1],[.3,1.05,.9,1])}]};case"FadeInPulse":return{opacity:range([0,.5,1],[0,1,1]),transform:[{scale:range([0,.5,1],[1,1.1,1])}]};case"SpinScale":return{transform:[{rotate:t.interpolate({inputRange:[0,1],outputRange:["-180deg","0deg"]})},{scale:t.interpolate({inputRange:[0,1],outputRange:[0,1]})}]};case"WiggleIn":return{transform:[{translateY:range([0,.4,1],[100,0,0])},{rotate:range([0,.4,.6,.8,1],["-10deg","5deg","-3deg","1deg","0deg"])}]};case"ElasticIn":return{transform:[{scale:range([0,.55,.75,1],[0,1.1,.95,1])}]};default:return{transform:[]}}}const OVERSHOOT=new Set(["Rise","SlideUp","SpinScale"]);export function ChatLauncher({look:e,hidden:t,label:a,side:n,offsetX:i,offsetY:r,enter:s,reduced:o,mark:u="Icon",avatar:l=null,buttonRef:c,onPress:m,testID:p}){const d=useTheme(),f=useSafeAreaInsets(),g=e.launcher.entrance,S="Avatar"===u&&l?l:null,A=d.components["floating-action-button"].md.diameter,[R]=useState(()=>s&&!o&&"None"!==g),E=t&&e.expressive&&!o,v=!o&&!t&&"FloatAndPulse"===e.launcher.idle,[_]=useState(()=>new Animated.Value(R?0:1)),[h]=useState(()=>new Animated.Value(0)),[I]=useState(()=>new Animated.Value(1)),[b,y]=useState(!1);if(useEffect(()=>{if(!t)return I.setValue(1),void y(!1);if(!E)return;const e=Animated.timing(I,{toValue:0,duration:320,easing:SHRINK_EASING,useNativeDriver:!0});return e.start(({finished:e})=>{e&&y(!0)}),()=>e.stop()},[t,E,I]),useEffect(()=>{if(!R)return void _.setValue(1);const e="Rise"===g,t=Animated.timing(_,{toValue:1,duration:e?900:800,delay:e?400:1e3,easing:OVERSHOOT.has(g)?Easing.bezier(.34,e?1.4:1.56,.64,1):Easing.linear,useNativeDriver:!0});return t.start(),()=>t.stop()},[R,g,_]),useEffect(()=>{if(!v)return void h.setValue(0);const e=Animated.loop(Animated.sequence([Animated.timing(h,{toValue:1,duration:1600,easing:Easing.inOut(Easing.ease),useNativeDriver:!0}),Animated.timing(h,{toValue:0,duration:1600,easing:Easing.inOut(Easing.ease),useNativeDriver:!0})]));return e.start(),()=>e.stop()},[v,h]),t&&(!E||b))return null;const N="Pill"===e.launcher.style&&!e.launcher.compact,V=d.space[d.components["floating-action-button"]["edge-offset"]]+i,x={position:"absolute",bottom:r+f.bottom,..."start"===n?{left:V}:{right:V}},O=entranceStyle(g,_);return _jsx(Animated.View,{pointerEvents:"box-none",style:StyleSheet.absoluteFill,children:_jsx(Animated.View,{style:[x,{opacity:Animated.multiply(O.opacity??1,I),transform:[...O.transform,{scale:I},{translateY:h.interpolate({inputRange:[0,1],outputRange:[0,-4]})}]}],children:_jsx(FloatingActionButton,{ref:c,icon:S?_jsx(Avatar,{dimension:A,name:a,source:{uri:S}}):"messages",label:N?a:void 0,collapsed:!N,accessibilityLabel:a,onPress:m,testID:p})})})}
@@ -1 +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]})}
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";export function ChatLiveBar({chat:e,labels:t,testID:s="chat-live-bar"}){const i=useTheme();if(!e.features.HumanHandoff||null===e.conversationId)return null;const n=e.conversationState;if("Closed"===n)return null;if("Open"===n){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:i.space.md,paddingVertical:i.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}return"Lost"!==e.live?null:_jsx(View,{accessibilityLiveRegion:"polite",style:{paddingHorizontal:i.space.md,paddingVertical:i.space.xs},testID:s,children:_jsx(Banner,{tone:"warning",message:t.liveLost,actions:[{label:t.retry,onPress:()=>e.resumeLive()}],testID:`${s}-lost`})})}
@@ -1 +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}
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),p=useMemo(()=>TEXT_AUTHORS.has(t.author.kind)&&buildTranscript([t],{labels:s,title:null,figureText:!1,assistantName:e.profile?.assistant.name}).entries.length>0,[t,s,e.profile]);if(useEffect(()=>()=>{null!==m.current&&clearTimeout(m.current)},[]),t.streaming)return null;const g=messagePlainText(t.parts),h=TEXT_AUTHORS.has(t.author.kind)&&""!==g,f=t.stored&&RATED_AUTHORS.has(t.author.kind),x=("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||p&&e.features.Share&&d.canShare||x||T||b||f&&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(g)&&(l(!0),null!==m.current&&clearTimeout(m.current),m.current=setTimeout(()=>l(!1),2e3))})()},testID:`${n}-copy`}):null,p&&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,x?_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,f&&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}