@webority/mobile-chat 0.146.0 → 0.147.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 (46) hide show
  1. package/LICENSE.txt +1 -1
  2. package/lib/commonjs/AgentByline.js +1 -1
  3. package/lib/commonjs/ChatComposer.js +1 -1
  4. package/lib/commonjs/ChatFooter.js +1 -1
  5. package/lib/commonjs/ChatFrame.js +1 -1
  6. package/lib/commonjs/ChatMessageActions.js +1 -1
  7. package/lib/commonjs/ChatThread.js +1 -1
  8. package/lib/commonjs/chatShared.js +1 -1
  9. package/lib/commonjs/loaders/TypingPill.js +1 -1
  10. package/lib/commonjs/renderers/ActionPart.js +1 -1
  11. package/lib/commonjs/renderers/ChartPart.js +1 -1
  12. package/lib/commonjs/renderers/FigureText.js +1 -1
  13. package/lib/commonjs/renderers/FiguresPart.js +1 -1
  14. package/lib/commonjs/renderers/HandoffPart.js +1 -1
  15. package/lib/commonjs/renderers/ImagePart.js +1 -1
  16. package/lib/commonjs/renderers/InputRequestPart.js +1 -1
  17. package/lib/commonjs/renderers/RecordCardPart.js +1 -1
  18. package/lib/commonjs/renderers/SourcesPart.js +1 -1
  19. package/lib/commonjs/renderers/TablePart.js +1 -1
  20. package/lib/commonjs/renderers/TextPart.js +1 -1
  21. package/lib/commonjs/renderers/TicketPart.js +1 -1
  22. package/lib/commonjs/renderers/VoiceClipPart.js +1 -1
  23. package/lib/module/AgentByline.js +1 -1
  24. package/lib/module/ChatComposer.js +1 -1
  25. package/lib/module/ChatFooter.js +1 -1
  26. package/lib/module/ChatFrame.js +1 -1
  27. package/lib/module/ChatMessageActions.js +1 -1
  28. package/lib/module/ChatThread.js +1 -1
  29. package/lib/module/chatShared.js +1 -1
  30. package/lib/module/loaders/TypingPill.js +1 -1
  31. package/lib/module/renderers/ActionPart.js +1 -1
  32. package/lib/module/renderers/ChartPart.js +1 -1
  33. package/lib/module/renderers/FigureText.js +1 -1
  34. package/lib/module/renderers/FiguresPart.js +1 -1
  35. package/lib/module/renderers/HandoffPart.js +1 -1
  36. package/lib/module/renderers/ImagePart.js +1 -1
  37. package/lib/module/renderers/InputRequestPart.js +1 -1
  38. package/lib/module/renderers/RecordCardPart.js +1 -1
  39. package/lib/module/renderers/SourcesPart.js +1 -1
  40. package/lib/module/renderers/TablePart.js +1 -1
  41. package/lib/module/renderers/TextPart.js +1 -1
  42. package/lib/module/renderers/TicketPart.js +1 -1
  43. package/lib/module/renderers/VoiceClipPart.js +1 -1
  44. package/lib/typescript/commonjs/chatShared.d.ts +1 -0
  45. package/lib/typescript/module/chatShared.d.ts +1 -0
  46. package/package.json +12 -12
package/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  Copyright (c) Webority Technologies. All rights reserved.
2
2
 
3
- This software and its NuGet packages are the proprietary and confidential property
3
+ This software and its Webority packages are the proprietary and confidential property
4
4
  of Webority Technologies. They are published publicly only for the convenience of
5
5
  Webority's own projects and internal consumption.
6
6
 
@@ -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,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,...void 0===n?{}:{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
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AgentByline=AgentByline;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_chatShared=require("./chatShared.js"),_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)(_reactNative.View,{...(0,_chatShared.webProps)({"aria-hidden":!0}),children:(0,_jsxRuntime.jsx)(_mobileUi.Avatar,{size:"xs",name:a,...void 0===n?{}:{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"),_iconName=require("./iconName.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,g=(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&&g.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,N=x?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{message:t.editing,accessibilityRole:"summary",actions:[{label:t.cancel,onPress:()=>e.cancelEdit()}],testID:`${o}-editing`}):null,S=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,{...null===s.progress||void 0===s.progress?{}:{progress:s.progress},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,D=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,U=p?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{message:p.message,tone:p.tone,dismissible:!0,onClose:()=>_(null),...p.openSettings?{actions:[{label:t.dictateOpenSettings,onPress:()=>{_permissions.Permissions.openSettings()}}]}:{},testID:`${o}-voice-notice`}):null,w=h.length>0,L=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=N||S||D||L||U?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[N,S,D,L,U]}):void 0,k=!j&&(!!v||void 0),O=(0,_iconName.iconNameOf)(c);return(0,_jsxRuntime.jsx)(_mobileUi.Composer,{ref:f,onSend:t=>{g.current?.(),e.submit(t)},value:h,onChangeText:t=>{g.current?.(),d(t),A&&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",...O?{sendIcon:O}:{},...e.features.Stop?{onStop:()=>e.stop()}:{},stopLabel:t.stop,disabled:0===y||e.handoffPause,maxLength:R,...void 0===k?{}:{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:g}),above:I,below:(0,_jsxRuntime.jsx)(_ChatFooter.ChatFooter,{chat:e,labels:t}),...void 0===i?{}:{keyboardAware:i},...void 0===a?{}:{keyboardOffset:a},...void 0===n?{}:{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"),_chatShared=require("./chatShared.js"),_iconName=require("./iconName.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,g=(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&&g.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,N=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,{...null===s.progress||void 0===s.progress?{}:{progress:s.progress},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,w=null!==y&&y<=ALLOWANCE_SHOWN_AT?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:0===y?"danger":"secondary",accessibilityLiveRegion:"polite",...(0,_chatShared.webProps)({role:"status"}),testID:`${o}-allowance`,children:t.allowance(y)}):null,D=p?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{message:p.message,tone:p.tone,dismissible:!0,onClose:()=>_(null),...p.openSettings?{actions:[{label:t.dictateOpenSettings,onPress:()=>{_permissions.Permissions.openSettings()}}]}:{},testID:`${o}-voice-notice`}):null,U=h.length>0,L=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||N||w||L||D?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[S,N,w,L,D]}):void 0,k=!j&&(!!v||void 0),q=(0,_iconName.iconNameOf)(c);return(0,_jsxRuntime.jsx)(_mobileUi.Composer,{ref:f,onSend:t=>{g.current?.(),e.submit(t)},value:h,onChangeText:t=>{g.current?.(),d(t),A&&t.length>0&&e.notifyTyping()},loading:e.streaming&&e.features.Stop,ring:l.input.ring&&(U||e.streaming),sendReveal:"Always"===l.input.sendReveal?"always":"onText",...q?{sendIcon:q}:{},...e.features.Stop?{onStop:()=>e.stop()}:{},stopLabel:t.stop,disabled:0===y||e.handoffPause,maxLength:R,...void 0===k?{}:{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:g}),above:I,below:(0,_jsxRuntime.jsx)(_ChatFooter.ChatFooter,{chat:e,labels:t}),...void 0===i?{}:{keyboardAware:i},...void 0===a?{}:{keyboardOffset:a},...void 0===n?{}:{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.ChatFooter=ChatFooter;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_chatShared=require("./chatShared.js"),_jsxRuntime=require("react/jsx-runtime");const GOOGLE_PRIVACY="https://policies.google.com/privacy",GOOGLE_TERMS="https://policies.google.com/terms",openLink=e=>(0,_chatShared.openExternalUrl)(e);function ChatFooter({chat:e,labels:i}){const t=(0,_mobileUi.useTheme)(),r=e.profile;if(!r)return null;const o=r.footer.disclaimer||i.disclaimer,n=r.footer.privacyUrl,a=r.footer.assuranceText,l=r.footer.privacyText,c=(0,_chatCore.showsCaptchaNote)(r);return Boolean(o)||Boolean(l)||Boolean(n)||Boolean(a)||c?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:t.space.xxs,alignItems:"center"},children:[o?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:o}):null,l?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:l}):null,n?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(n),children:i.footerPrivacy}):null,a?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:a}):null,c?(0,_jsxRuntime.jsxs)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:[i.captchaNote," ",(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(GOOGLE_PRIVACY),children:i.captchaPrivacy})," ",(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(GOOGLE_TERMS),children:i.captchaTerms})]}):null]}):null}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatFooter=ChatFooter;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_chatShared=require("./chatShared.js"),_jsxRuntime=require("react/jsx-runtime");const GOOGLE_PRIVACY="https://policies.google.com/privacy",GOOGLE_TERMS="https://policies.google.com/terms",openLink=e=>(0,_chatShared.openExternalUrl)(e);function ChatFooter({chat:e,labels:i}){const t=(0,_mobileUi.useTheme)(),r=e.profile;if(!r)return null;const a=r.footer.disclaimer||i.disclaimer,o=r.footer.privacyUrl,n=r.footer.assuranceText,c=r.footer.privacyText,l=(0,_chatCore.showsCaptchaNote)(r);if(!(Boolean(a)||Boolean(c)||Boolean(o)||Boolean(n)||l))return null;const s=[];return a&&s.push((0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:a},"disclaimer")),(c||o)&&s.push((0,_jsxRuntime.jsxs)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:[c,c&&o?" ":null,o?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(o),children:i.footerPrivacy}):null]},"privacy")),n&&s.push((0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:n},"assurance")),l&&s.push((0,_jsxRuntime.jsxs)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:[i.captchaNote," ",(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(GOOGLE_PRIVACY),children:i.captchaPrivacy})," ",(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(GOOGLE_TERMS),children:i.captchaTerms})]},"captcha")),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{gap:t.space.xxs,alignItems:"center",flexDirection:"row",flexWrap:"wrap",justifyContent:"center"},...(0,_chatShared.webProps)({role:"paragraph"}),children:s.flatMap((e,i)=>i?[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",accessibilityElementsHidden:!0,importantForAccessibility:"no",...(0,_chatShared.webProps)({"aria-hidden":!0}),children:"·"},`sep-${e.key}`),e]:[e])})}
@@ -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"),_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
+ "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}),(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)(_ChatLiveBar.ChatLiveBar,{chat:e,labels:t,testID:`${b}-live`}),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.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:n}){const r=(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,...void 0===e.profile?.assistant.name?{}:{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,p=t.stored&&RATED_AUTHORS.has(t.author.kind),x=("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||x||b||R||p&&e.features.Rating?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.space.xs},testID:n,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:`${n}-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:`${n}-share`}):null,x?(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:`${n}-regenerate`}):null,R?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:i.edit,variant:"link",size:"sm",onPress:()=>e.startEdit(t.id),testID:`${n}-edit`}):null,p&&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:r.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:`${n}-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:`${n}-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
+ "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"),_chatShared=require("./chatShared.js"),_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)(),[o,l]=(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,...void 0===e.profile?.assistant.name?{}:{assistantName:e.profile.assistant.name}}).entries.length>0,[t,i,e.profile]);if((0,_react.useEffect)(()=>()=>{null!==d.current&&clearTimeout(d.current)},[]),t.streaming)return null;const h=(0,_chatCore.messagePlainText)(t.parts),p=TEXT_AUTHORS.has(t.author.kind)&&""!==h,g=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(),x=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 p&&e.features.Copy||_&&e.features.Share&&m.canShare||b||x||R||g&&e.features.Rating?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:n.space.xs},testID:r,children:[p&&e.features.Copy?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:o?i.copied:i.copy,variant:"link",size:"sm",onPress:()=>{(async()=>{await(0,_clipboard.copyText)(h)&&(l(!0),null!==d.current&&clearTimeout(d.current),d.current=setTimeout(()=>l(!1),2e3))})()},testID:`${r}-copy`}):null,b?(0,_jsxRuntime.jsx)(_ReadAloudButton.ReadAloudButton,{chat:e,message:t,labels:i}):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,x?(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,g&&e.features.Rating?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityRole:"summary",accessibilityLabel:i.rating,...(0,_chatShared.webProps)({role:"group","aria-label":`${i.rateUp} / ${i.rateDown}`}),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 +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"),_ReplyRing=require("./loaders/ReplyRing.js"),_TypingPill=require("./loaders/TypingPill.js"),_index=require("./renderers/index.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");function isKind(e,t){return e.kind===t}const kindWrappers=new WeakMap;function forKind(e,t){const s=kindWrappers.get(t)??new Map,i=s.get(e);if(i)return i;function KindEntry(s){if(!isKind(s.part,e))throw new Error(`renderer for ${e} received a ${s.part.kind} part`);return(0,_react.createElement)(t,{part:s.part,message:s.message,turn:s.turn,pickAttachments:s.pickAttachments})}return s.set(e,KindEntry),kindWrappers.set(t,s),KindEntry}const defaults=_index.defaultRenderers;function entryFor(e,t){return forKind(e,t??defaults[e])}function resolveRenderers(e){return{Text:entryFor("Text",e?.Text),Sources:entryFor("Sources",e?.Sources),QuickReplies:entryFor("QuickReplies",e?.QuickReplies),InputRequest:entryFor("InputRequest",e?.InputRequest),Action:entryFor("Action",e?.Action),Notice:entryFor("Notice",e?.Notice),Table:entryFor("Table",e?.Table),Chart:entryFor("Chart",e?.Chart),Figures:entryFor("Figures",e?.Figures),RecordCard:entryFor("RecordCard",e?.RecordCard),Image:entryFor("Image",e?.Image),File:entryFor("File",e?.File),Ticket:entryFor("Ticket",e?.Ticket),Handoff:entryFor("Handoff",e?.Handoff),VoiceClip:entryFor("VoiceClip",e?.VoiceClip)}}const renderPart=(e,t,s,i,a,r)=>{const n=e[t.kind];return(0,_react.createElement)(n,{key:r,part:t,message:s,turn:i,pickAttachments: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:i,layoutParts:a,groupPosition:r,isLast:n,isLastVisitor:o,pickAttachments:l,onOpenAttachment:c,onOpenTarget:d,onNavigate:u,openTicket:m,handoffHosts:g,resolveLink:p,focusComposer:h,byline:y,avatar:_,replyAvatars:x,avatarStart:f,expressive:v,reduced:j,sourceRows:R,testID:T}){const b=(0,_mobileUi.useTheme)(),k=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:p,focusComposer:h,registerSourceRow:(e,t)=>{t?R.current.set(e,t):R.current.delete(e)}});let A=0;const nextSlot=()=>(A+=1,A),N=(0,_jsxRuntime.jsx)(_ChatMessageActions.ChatMessageActions,{chat:e,message:t,labels:s,isLast:n,isLastVisitor:o,testID:`${T}-actions`});if(MINE.has(t.author.kind)){const e=t.parts.filter(e=>"File"===e.kind),s=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:b.space.xs},children:[e.map(e=>renderPart(i,e,t,k,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:T})}const w="Agent"===t.author.kind,C=t.author.displayName||s.agent,M=(a?a(t):t.parts).map(e=>Array.isArray(e)?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:b.space.xs},children:e.map(e=>renderPart(i,e,t,k,l,`${t.id}-part-${nextSlot()}`))},`${t.id}-group-${nextSlot()}`):renderPart(i,e,t,k,l,`${t.id}-item-${nextSlot()}`)),S=w&&y?(0,_jsxRuntime.jsx)(_AgentByline.AgentByline,{author:t.author,labels:s,showAvatar:x},`${t.id}-byline`):null,I=S?[S,...M]:M,P=(0,_chatCore.messagePlainText)(t.parts),V=(0,_jsxRuntime.jsx)(_mobileUi.MessageBubble,{side:"theirs",...w?{}:{author:t.author.displayName||(e.profile?.assistant.name??s.assistant)},text:w?`${s.agentSays(C)} ${P}`:P,streaming:t.streaming,groupPosition:r,footer:N,testID:T,children:I});if(!x||!_||"Assistant"!==t.author.kind)return V;const F=t.author.displayName||(e.profile?.assistant.name??s.assistant);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"flex-end",gap:b.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:v&&t.streaming&&f,reduced:j,children:(0,_jsxRuntime.jsx)(_mobileUi.Avatar,{size:"xs",name:F,...f?{source:{uri:_}}:{}})})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,minWidth:0},children:V})]})}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:i,loader:a="Steps",motion:r="On",avatar:n,replyAvatars:o=!0,expressive:l=!1,pickAttachments:c,onOpenAttachment:d,onOpenTarget:u,onNavigate:m,openTicket:g,handoffHosts:p,resolveLink:h,focusComposer:y,keyboardAware:_,keyboardOffset:x,empty:f,style:v,testID:j="chat-thread"}){const R=(0,_mobileUi.useTheme)(),T=(0,_mobileUi.useReducedMotion)(),b="Reduced"===r||T,k=(0,_react.useMemo)(()=>resolveRenderers(s),[s]),A=e.messages[0],N=e.greeting??"",w=(0,_react.useMemo)(()=>""!==N&&void 0!==A&&MINE.has(A.author.kind)?{...A,id:"greeting",author:{...A.author,kind:"Assistant",displayName:null,avatarUrl:null},parts:[{kind:"Text",text:N}],stored:!1,streaming:!1,restored:!1,rating:null}:null,[N,A]),C=(0,_react.useMemo)(()=>{const t=e.messages.filter(e=>!(e.streaming&&0===e.parts.length)).reverse();return w?[...t,w]:t},[e.messages,w]),M=e.messages[e.messages.length-1]?.id,S=(0,_react.useRef)(new Map),I=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(null!==I.current)for(const s of e.messages){if(MINE.has(s.author.kind)||s.streaming||s.restored||I.current.has(s.id))continue;if("Agent"===s.author.kind&&!s.stored)continue;I.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 I.current=new Set(e.messages.map(e=>e.id))},[e.messages,t]);const P=(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]),V=(0,_react.useMemo)(()=>{const t=new Set;return e.messages.forEach((s,i)=>{if("Agent"!==s.author.kind)return;const a=e.messages[i-1];"Agent"===a?.author.kind&&(a.author.displayName||"")===(s.author.displayName||"")||t.add(s.id)}),t},[e.messages]),F=(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,i)=>{"Assistant"===e.author.kind&&"Assistant"!==s[i-1]?.author.kind&&t.add(e.id)}),t},[e.messages,w]),L=(0,_react.useMemo)(()=>(0,_chatCore.handoffSettledIds)(e.messages),[e.messages]),$=e.turnError,D="daily_limit"===$?.code,E=null!==$&&/feature_off$/.test($.code),O=D&&$?.resetsDateTimeUtc?` ${t.dailyLimitRefresh((0,_chatCore.formatChatDateTime)($.resetsDateTimeUtc))}`:"",U=e.streaming||null===$&&!e.stopped?null:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:R.space.xs},testID:`${j}-error`,children:[null!==$?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityRole:D?void 0:"alert",accessibilityLiveRegion:D?"polite":void 0,children:`${$.message}${O}`}):(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:t.stopped}),!e.features.Retry||D||E?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:`${j}-retry`})})]}),q=e.thinking&&null!==e.profile?(0,_jsxRuntime.jsx)(_ChatLoader.ChatLoader,{style:a,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:b,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"===a?TYPING_ORB_MARK:TYPING_ASSISTANT_MARK})})}):null,K=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,B=H||q||U||K?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:R.space.sm},children:[H,q,K,U]}):void 0,G=(0,_jsxRuntime.jsx)(_mobileUi.MessageList,{messages:C,keyExtractor:e=>e.id,renderMessage:({item:s,groupPosition:a})=>(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:k,layoutParts:i,groupPosition:a,isLast:s.id===M,isLastVisitor:s.id===P,handoffSettled:L.has(s.id),thinking:e.thinking,streaming:e.streaming,pickAttachments:c,onOpenAttachment:d,onOpenTarget:u,onNavigate:m,openTicket:g,handoffHosts:p,resolveLink:h,focusComposer:y,byline:V.has(s.id),avatar:n,replyAvatars:o,avatarStart:F.has(s.id),expressive:l,reduced:b,sourceRows:S,testID:`${j}-${s.id}`})})]}),getAuthorKey:e=>e.author.kind,getDate:e=>e.createdDateTimeUtc,followNew:followNew,typing:B,empty:f,ItemSeparatorComponent:TurnGap,...void 0===_?{}:{keyboardAware:_},...void 0===x?{}:{keyboardOffset:x},accessibilityLabel:t.thread,accessibilityRole:"list",style:v,testID:j});return"web"!==_reactNative.Platform.OS?G:(0,_jsxRuntime.jsx)(_reactNative.View,{role:"log","aria-live":"polite","aria-label":t.thread,style:{flex:1},children:G})}
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"),_jsxRuntime=require("react/jsx-runtime");const MINE=new Set(["Visitor","Customer"]),visuallyHidden={position:"absolute",left:-1e4,width:1,height:1,overflow:"hidden"},spokenAuthor=(e,t,s)=>MINE.has(e.author.kind)?t.you:e.author.displayName?e.author.displayName:"Agent"===e.author.kind?t.agent:s??t.assistant,joinedText=e=>e.filter(e=>"Text"===e.kind).map(e=>e.text).join("\n\n");function isKind(e,t){return e.kind===t}const kindWrappers=new WeakMap;function forKind(e,t){const s=kindWrappers.get(t)??new Map,a=s.get(e);if(a)return a;function KindEntry(s){if(!isKind(s.part,e))throw new Error(`renderer for ${e} received a ${s.part.kind} part`);return(0,_react.createElement)(t,{part:s.part,message:s.message,turn:s.turn,pickAttachments:s.pickAttachments})}return s.set(e,KindEntry),kindWrappers.set(t,s),KindEntry}const defaults=_index.defaultRenderers;function entryFor(e,t){return forKind(e,t??defaults[e])}function resolveRenderers(e){return{Text:entryFor("Text",e?.Text),Sources:entryFor("Sources",e?.Sources),QuickReplies:entryFor("QuickReplies",e?.QuickReplies),InputRequest:entryFor("InputRequest",e?.InputRequest),Action:entryFor("Action",e?.Action),Notice:entryFor("Notice",e?.Notice),Table:entryFor("Table",e?.Table),Chart:entryFor("Chart",e?.Chart),Figures:entryFor("Figures",e?.Figures),RecordCard:entryFor("RecordCard",e?.RecordCard),Image:entryFor("Image",e?.Image),File:entryFor("File",e?.File),Ticket:entryFor("Ticket",e?.Ticket),Handoff:entryFor("Handoff",e?.Handoff),VoiceClip:entryFor("VoiceClip",e?.VoiceClip)}}const renderPart=(e,t,s,a,i,r)=>{const n=e[t.kind];return(0,_react.createElement)(n,{key:r,part:t,message:s,turn:a,pickAttachments:i})},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:p,focusComposer:h,byline:y,avatar:_,replyAvatars:x,avatarStart:f,expressive:v,reduced:j,sourceRows:R,testID:T}){const k=(0,_mobileUi.useTheme)(),b=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:p,focusComposer:h,registerSourceRow:(e,t)=>{t?R.current.set(e,t):R.current.delete(e)}});let A=0;const nextSlot=()=>(A+=1,A),N=(0,_jsxRuntime.jsx)(_ChatMessageActions.ChatMessageActions,{chat:e,message:t,labels:s,isLast:n,isLastVisitor:o,testID:`${T}-actions`});if(MINE.has(t.author.kind)){const e=t.parts.filter(e=>"File"===e.kind||"VoiceClip"===e.kind),s=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:k.space.xs},children:[e.map(e=>renderPart(a,e,t,b,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:T})}const w="Agent"===t.author.kind,C=t.author.displayName||s.agent,M=(i?i(t):t.parts).map(e=>Array.isArray(e)?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:k.space.xs},children:e.map(e=>renderPart(a,e,t,b,l,`${t.id}-part-${nextSlot()}`))},`${t.id}-group-${nextSlot()}`):renderPart(a,e,t,b,l,`${t.id}-item-${nextSlot()}`)),S=w&&y?(0,_jsxRuntime.jsx)(_AgentByline.AgentByline,{author:t.author,labels:s,showAvatar:x},`${t.id}-byline`):null,I=S?[S,...M]:M,P=(0,_chatCore.messagePlainText)(t.parts),V=(0,_jsxRuntime.jsx)(_mobileUi.MessageBubble,{side:"theirs",...w?{}:{author:`${t.author.displayName||(e.profile?.assistant.name??s.assistant)}:`},text:w?`${s.agentSays(C)} ${P}`:P,streaming:t.streaming,groupPosition:r,footer:N,testID:T,children:I});if(!x||!_||"Assistant"!==t.author.kind)return V;const F=t.author.displayName||(e.profile?.assistant.name??s.assistant);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"flex-end",gap:k.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:v&&t.streaming&&f,reduced:j,children:(0,_jsxRuntime.jsx)(_mobileUi.Avatar,{size:"xs",name:F,...f?{source:{uri:_}}:{}})})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,minWidth:0},children:V})]})}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:p,resolveLink:h,focusComposer:y,keyboardAware:_,keyboardOffset:x,empty:f,style:v,testID:j="chat-thread"}){const R=(0,_mobileUi.useTheme)(),T=(0,_mobileUi.useReducedMotion)(),k="Reduced"===r||T,b=(0,_react.useMemo)(()=>resolveRenderers(s),[s]),A=e.messages[0],N=e.greeting??"",w=(0,_react.useMemo)(()=>""!==N&&void 0!==A&&MINE.has(A.author.kind)?{...A,id:"greeting",author:{...A.author,kind:"Assistant",displayName:null,avatarUrl:null},parts:[{kind:"Text",text:N}],stored:!1,streaming:!1,restored:!1,rating:null}:null,[N,A]),C=(0,_react.useMemo)(()=>{const t=e.messages.filter(e=>!(e.streaming&&0===e.parts.length)).reverse();return w?[...t,w]:t},[e.messages,w]),M=e.messages[e.messages.length-1]?.id,S=(0,_react.useRef)(new Map),I=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(null!==I.current)for(const s of e.messages){if(MINE.has(s.author.kind)||s.streaming||s.restored||I.current.has(s.id))continue;if("Agent"===s.author.kind&&!s.stored)continue;I.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 I.current=new Set(e.messages.map(e=>e.id))},[e.messages,t]);const P=(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]),V=(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]),F=(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]),L=(0,_react.useMemo)(()=>(0,_chatCore.handoffSettledIds)(e.messages),[e.messages]),$=e.turnError,O="daily_limit"===$?.code,D=null!==$&&/feature_off$/.test($.code),E=O&&$?.resetsDateTimeUtc?` ${t.dailyLimitRefresh((0,_chatCore.formatChatDateTime)($.resetsDateTimeUtc))}`:"",U=e.streaming||null===$&&!e.stopped?null:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:R.space.xs},testID:`${j}-error`,children:[null!==$?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityRole:O?void 0:"alert",accessibilityLiveRegion:O?"polite":void 0,children:`${$.message}${E}`}):(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:t.stopped}),!e.features.Retry||O||D?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:`${j}-retry`})})]}),q=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:k,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,K=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,B=H||q||U||K?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:R.space.sm},children:[H,q,K,U]}):void 0,G=(0,_jsxRuntime.jsx)(_mobileUi.MessageList,{messages:C,keyExtractor:e=>e.id,renderMessage:({item:s,groupPosition:i})=>(0,_jsxRuntime.jsxs)(_reactNative.View,{role:"listitem",children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{style:visuallyHidden,children:`${spokenAuthor(s,t,e.profile?.assistant.name)}: `}),(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:b,layoutParts:a,groupPosition:i,isLast:s.id===M,isLastVisitor:s.id===P,handoffSettled:L.has(s.id),thinking:e.thinking,streaming:e.streaming,pickAttachments:c,onOpenAttachment:d,onOpenTarget:u,onNavigate:m,openTicket:g,handoffHosts:p,resolveLink:h,focusComposer:y,byline:V.has(s.id),avatar:n,replyAvatars:o,avatarStart:F.has(s.id),expressive:l,reduced:k,sourceRows:S,testID:`${j}-${s.id}`})})]}),getAuthorKey:e=>e.author.kind,getDate:e=>e.createdDateTimeUtc,followNew:followNew,typing:B,empty:f,ItemSeparatorComponent:TurnGap,...void 0===_?{}:{keyboardAware:_},...void 0===x?{}:{keyboardOffset:x},..."web"===_reactNative.Platform.OS?{}:{accessibilityLabel:t.thread},accessibilityRole:"list",style:v,testID:j});return"web"!==_reactNative.Platform.OS?G:(0,_jsxRuntime.jsx)(_reactNative.View,{role:"log","aria-live":"polite","aria-label":t.thread,style:{flex:1},children:G})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WEB_STRONG=void 0,exports.defaultOpenTarget=defaultOpenTarget,exports.focusForAccessibility=focusForAccessibility,exports.messageSignature=messageSignature,exports.openExternalUrl=openExternalUrl;var _mobileCore=require("@webority/mobile-core"),_reactNative=require("react-native");function focusForAccessibility(e){null!=e&&("web"!==_reactNative.Platform.OS?_reactNative.AccessibilityInfo.sendAccessibilityEvent(e,"focus"):"focus"in e&&"function"==typeof e.focus&&e.focus())}function messageSignature(e){let t=0;for(const r of e.parts)"Text"===r.kind&&(t+=r.text.length);return`${e.id}|${e.parts.length}|${t}`}const ABSOLUTE_WEB_URL=/^https?:\/\//i;function openExternalUrl(e){_reactNative.Linking.openURL(e).catch(e=>{throw _mobileCore.Logger.error("[chat] link did not open",e),e})}function defaultOpenTarget(e){ABSOLUTE_WEB_URL.test(e)&&openExternalUrl(e)}const WEB_STRONG=exports.WEB_STRONG="web"===_reactNative.Platform.OS?{role:"strong"}:{};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WEB_STRONG=void 0,exports.defaultOpenTarget=defaultOpenTarget,exports.focusForAccessibility=focusForAccessibility,exports.messageSignature=messageSignature,exports.openExternalUrl=openExternalUrl,exports.webProps=void 0;var _mobileCore=require("@webority/mobile-core"),_reactNative=require("react-native");function focusForAccessibility(e){null!=e&&("web"!==_reactNative.Platform.OS?_reactNative.AccessibilityInfo.sendAccessibilityEvent(e,"focus"):"focus"in e&&"function"==typeof e.focus&&e.focus())}function messageSignature(e){let t=0;for(const r of e.parts)"Text"===r.kind&&(t+=r.text.length);return`${e.id}|${e.parts.length}|${t}`}const ABSOLUTE_WEB_URL=/^https?:\/\//i;function openExternalUrl(e){_reactNative.Linking.openURL(e).catch(e=>{throw _mobileCore.Logger.error("[chat] link did not open",e),e})}function defaultOpenTarget(e){ABSOLUTE_WEB_URL.test(e)&&openExternalUrl(e)}const WEB_STRONG=exports.WEB_STRONG="web"===_reactNative.Platform.OS?{role:"strong"}:{},webProps=e=>"web"===_reactNative.Platform.OS?e:{};exports.webProps=webProps;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TypingPill=TypingPill;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const DOT=6,LIFT_PX=4,CYCLE_MS=1200,HALF_MS=300,STEP_MS=140,STILL_OPACITY=[1,.65,.3],DOT_INDEXES=[0,1,2];function TypingPill({motion:e,mark:t}){const i=(0,_mobileUi.useTheme)(),r=(0,_react.useMemo)(()=>buildStyles(i),[i]),a=(0,_mobileUi.useReducedMotion)(),s="Reduced"===e||a;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:r.pill,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[t,(0,_jsxRuntime.jsx)(_reactNative.View,{style:r.dots,children:DOT_INDEXES.map(e=>(0,_jsxRuntime.jsx)(Dot,{index:e,reduced:s,color:i.colors["text-subtle"],size:DOT},e))})]})}const Dot=({index:e,reduced:t,color:i,size:r})=>{const a=(0,_react.useRef)(new _reactNative.Animated.Value(0)).current;(0,_react.useEffect)(()=>{if(t)return void a.setValue(0);const i=_reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.delay(140*e),_reactNative.Animated.timing(a,{toValue:1,duration:300,useNativeDriver:!0}),_reactNative.Animated.timing(a,{toValue:0,duration:300,useNativeDriver:!0}),_reactNative.Animated.delay(600-140*e)]));return i.start(),()=>i.stop()},[a,e,t]);const s={width:r,height:r,borderRadius:r/2,backgroundColor:i};if(t)return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[s,{opacity:STILL_OPACITY[e]}]});const n=a.interpolate({inputRange:[0,1],outputRange:[0,-4]});return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[s,{transform:[{translateY:n}]}]})},buildStyles=e=>_reactNative.StyleSheet.create({pill:{flexDirection:"row",alignItems:"center",alignSelf:"flex-start",gap:e.space.sm,backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.pill,paddingHorizontal:e.space.md,paddingVertical:e.space.sm},dots:{flexDirection:"row",alignItems:"center",gap:e.space.xs}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TypingPill=TypingPill;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const DOT=6,LIFT_PX=4,CYCLE_MS=1200,HALF_MS=300,STEP_MS=140,STILL_OPACITY=[1,.65,.3],DOT_INDEXES=[0,1,2];function TypingPill({motion:e,mark:t}){const i=(0,_mobileUi.useTheme)(),r=(0,_react.useMemo)(()=>buildStyles(i),[i]),a=(0,_mobileUi.useReducedMotion)(),s="Reduced"===e||a;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:r.pill,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",testID:"chat-typing-pill",children:[t,(0,_jsxRuntime.jsx)(_reactNative.View,{style:r.dots,children:DOT_INDEXES.map(e=>(0,_jsxRuntime.jsx)(Dot,{index:e,reduced:s,color:i.colors["text-subtle"],size:DOT},e))})]})}const Dot=({index:e,reduced:t,color:i,size:r})=>{const a=(0,_react.useRef)(new _reactNative.Animated.Value(0)).current;(0,_react.useEffect)(()=>{if(t)return void a.setValue(0);const i=_reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.delay(140*e),_reactNative.Animated.timing(a,{toValue:1,duration:300,useNativeDriver:!0}),_reactNative.Animated.timing(a,{toValue:0,duration:300,useNativeDriver:!0}),_reactNative.Animated.delay(600-140*e)]));return i.start(),()=>i.stop()},[a,e,t]);const s={width:r,height:r,borderRadius:r/2,backgroundColor:i};if(t)return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[s,{opacity:STILL_OPACITY[e]}]});const n=a.interpolate({inputRange:[0,1],outputRange:[0,-4]});return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[s,{transform:[{translateY:n}]}]})},buildStyles=e=>_reactNative.StyleSheet.create({pill:{flexDirection:"row",alignItems:"center",alignSelf:"flex-start",gap:e.space.sm,backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.pill,paddingHorizontal:e.space.md,paddingVertical:e.space.sm},dots:{flexDirection:"row",alignItems:"center",gap:e.space.xs}});
@@ -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"),_mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_chatShared=require("../chatShared.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:()=>(0,_chatShared.openExternalUrl)(e.href),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),[l,s]=(0,_react.useState)(""),[c,d]=(0,_react.useState)(!1),run=async(e,t)=>{o(e),s("");try{await t()}catch(t){_mobileCore.Logger.error(`[chat] action ${e} failed`,t),s(t instanceof _chatCore.ChatApiError&&""!==t.message?t.message: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,h=m&&e.rejectLabel||n.actionDismiss,j=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:[""!==l?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:l}):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:j,onPress:()=>{run("confirm",()=>t.confirmAction(e.actionId))}}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:h,variant:"ghost",disabled:j,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:j||"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({part:e,turn:t}){return(0,_jsxRuntime.jsx)(ActionBody,{part:e,turn:t},e.actionId)}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ActionPart=ActionPart;var _chatCore=require("@webority/chat-core"),_markdownCore=require("@webority/markdown-core"),_mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_chatShared=require("../chatShared.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:()=>(0,_chatShared.openExternalUrl)(e.href),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:r}=t,[a,o]=(0,_react.useState)(null),[l,s]=(0,_react.useState)(""),[c,d]=(0,_react.useState)(!1),run=async(e,t)=>{o(e),s("");try{await t()}catch(t){_mobileCore.Logger.error(`[chat] action ${e} failed`,t),s(t instanceof _chatCore.ChatApiError&&""!==t.message?t.message:n.actionFailed),o(null)}},u=(e.editFields??[]).map(e=>({label:e.label,value:e.id})),m=r.LeadRecap&&e.actionKind===LEAD_CAPTURE,x=m&&u.length>0,_=m&&e.confirmLabel||n.actionConfirm,h=m&&e.rejectLabel||n.actionDismiss,p=null!==a;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",..._chatShared.WEB_STRONG,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",...(0,_chatShared.webProps)({role:"term"}),children:t}),null!==n?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",...(0,_chatShared.webProps)({role:"definition"}),children:n}):null]},e)}),m&&e.consentText?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",...(0,_chatShared.webProps)({role:"paragraph"}),children:inlineNodes((0,_markdownCore.parseInline)(e.consentText),i)}):null,e.note?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",...(0,_chatShared.webProps)({role:"paragraph"}),children:e.note}):null,"Pending"===e.state?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[""!==l?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:l}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:i.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:"confirm"===a?n.actionWorking:_,loading:"confirm"===a,disabled:p,onPress:()=>{run("confirm",()=>t.confirmAction(e.actionId))}}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:h,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",...(0,_chatShared.webProps)({role:"paragraph"}),children:statusLine(e,n)}),x?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:n.editSomething,variant:"ghost",disabled:p||"Pending"!==e.state,onPress:()=>d(!0)}):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({part:e,turn:t}){return(0,_jsxRuntime.jsx)(ActionBody,{part:e,turn:t},e.actionId)}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChartPart=ChartPart;var _chatCore=require("@webority/chat-core"),_mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_FigureText=require("./FigureText.js"),_jsxRuntime=require("react/jsx-runtime");const TONES=["primary","info","success","warning","danger","neutral"],toneAt=e=>TONES[e%TONES.length]??"primary",MAX_SERIES=8,withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),writeValue=(e,t)=>{const i=0!==e&&Math.abs(e)<.001?(0,_FigureText.runsToText)((0,_chatCore.formatFigure)(e)):(0,_mobileCore.formatNumber)(e,{maximumFractionDigits:2});return t?`${i} ${t}`:i};function ChartPart({part:e,turn:t}){const i=(0,_mobileUi.useTheme)(),[r,a]=(0,_react.useState)(!1),l="Donut"===e.chartType?e.series.slice(0,1):e.series.slice(0,MAX_SERIES);if(l.every(e=>0===e.points.length))return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.sm},children:[e.title?(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:e.title,variant:"label",color:"primary",strong:!0}):null,(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:t.labels.chartEmpty})]});const{unit:s}=e,o=e.title?(0,_chatCore.toFigureText)(e.title):t.labels.chart,n=l.length>1;return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityLabel:o,style:{gap:i.space.sm},children:[e.title?(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:e.title,variant:"label",color:"primary",strong:!0}):null,(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:r?t.labels.chartShowChart:t.labels.chartShowTable,variant:"link",size:"sm",onPress:()=>a(e=>!e)}),withPositions(l).map(({key:a,item:l})=>{const c=toneAt(a),u=(0,_chatCore.toFigureText)(l.name)||o,m=l.points;if(0===m.length)return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.xs},children:[n?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:(0,_chatCore.toFigureText)(l.name)}):null,(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:t.labels.chartEmpty})]},a);const x=m.map(e=>e.value),h=x.reduce((e,t)=>Math.min(e,t)),_=x.reduce((e,t)=>Math.max(e,t)),b=m[0];if(void 0===b)throw new Error("A chart with points has no first point.");const j=m[m.length-1];if(void 0===j)throw new Error("A chart with points has no last point.");let p;if(r)p=(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"summary",style:{gap:i.space.xs},children:withPositions(m).map(({key:e,item:t})=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",justifyContent:"space-between",gap:i.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"primary",children:(0,_chatCore.toFigureText)(t.label)}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"primary",children:writeValue(t.value,s)})]},e))});else if("Bar"===e.chartType)p=(0,_jsxRuntime.jsx)(_mobileUi.BarChart,{data:m.map(e=>({label:(0,_chatCore.toFigureText)(e.label),value:e.value})),height:m.length>4?300:240,label:u,formatValue:e=>writeValue(e,s),formatTick:e=>s?`${(0,_mobileCore.formatCompactNumber)(e)} ${s}`:(0,_mobileCore.formatCompactNumber)(e),tone:c});else if("Line"===e.chartType)p=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Sparkline,{data:x,height:160,fill:!0,tone:c,label:u,formatLabel:e=>writeValue(e,s)}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",justifyContent:"space-between"},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",children:(0,_chatCore.toFigureText)(b.label)}),m.length>1?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",children:(0,_chatCore.toFigureText)(j.label)}):null]}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:`${t.labels.chartLow(writeValue(h,s))} ${t.labels.chartHigh(writeValue(_,s))}`})]});else{const e=x.reduce((e,t)=>e+(Number.isFinite(t)&&t>0?t:0),0);p=(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"list",style:{gap:i.space.sm},children:withPositions(m).map(({key:t,item:i})=>{const r=e>0&&Number.isFinite(i.value)&&i.value>0?i.value/e:0;return(0,_jsxRuntime.jsx)(_mobileUi.ProgressBar,{progress:r,height:8,tone:toneAt(t),label:(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:i.label,variant:"bodySmall"}),valueLabel:`${writeValue(i.value,s)} (${(0,_mobileCore.formatPercent)(r,{maximumFractionDigits:0})})`},t)})})}return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.xs},children:[n?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:(0,_chatCore.toFigureText)(l.name)}):null,p]},a)})]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChartPart=ChartPart;var _chatCore=require("@webority/chat-core"),_mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_chatShared=require("../chatShared.js"),_FigureText=require("./FigureText.js"),_jsxRuntime=require("react/jsx-runtime");const TONES=["primary","info","success","warning","danger","neutral"],toneAt=e=>TONES[e%TONES.length]??"primary",MAX_SERIES=8,withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),writeValue=(e,t)=>{const i=0!==e&&Math.abs(e)<.001?(0,_FigureText.runsToText)((0,_chatCore.formatFigure)(e)):(0,_mobileCore.formatNumber)(e,{maximumFractionDigits:2});return t?`${i} ${t}`:i};function ChartPart({part:e,turn:t}){const i=(0,_mobileUi.useTheme)(),[r,a]=(0,_react.useState)(!1),l="Donut"===e.chartType?e.series.slice(0,1):e.series.slice(0,MAX_SERIES);if(l.every(e=>0===e.points.length))return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.sm},children:[e.title?(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:e.title,variant:"label",color:"primary",strong:!0}):null,(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:t.labels.chartEmpty})]});const{unit:s}=e,o=e.title?(0,_chatCore.toFigureText)(e.title):t.labels.chart,n=l.length>1;return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityLabel:o,style:{gap:i.space.sm},...(0,_chatShared.webProps)({role:"figure"}),children:[e.title?(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:e.title,variant:"label",color:"primary",strong:!0}):null,(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:r?t.labels.chartShowChart:t.labels.chartShowTable,variant:"link",size:"sm",onPress:()=>a(e=>!e)}),withPositions(l).map(({key:a,item:l})=>{const c=toneAt(a),u=(0,_chatCore.toFigureText)(l.name)||o,m=l.points;if(0===m.length)return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.xs},children:[n?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:(0,_chatCore.toFigureText)(l.name)}):null,(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:t.labels.chartEmpty})]},a);const x=m.map(e=>e.value),h=x.reduce((e,t)=>Math.min(e,t)),_=x.reduce((e,t)=>Math.max(e,t)),b=m[0];if(void 0===b)throw new Error("A chart with points has no first point.");const j=m[m.length-1];if(void 0===j)throw new Error("A chart with points has no last point.");let p;if(r)p=(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"summary",style:{gap:i.space.xs},children:withPositions(m).map(({key:e,item:t})=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",justifyContent:"space-between",gap:i.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"primary",children:(0,_chatCore.toFigureText)(t.label)}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"primary",children:writeValue(t.value,s)})]},e))});else if("Bar"===e.chartType)p=(0,_jsxRuntime.jsx)(_mobileUi.BarChart,{data:m.map(e=>({label:(0,_chatCore.toFigureText)(e.label),value:e.value})),height:m.length>4?300:240,label:u,formatValue:e=>writeValue(e,s),formatTick:e=>s?`${(0,_mobileCore.formatCompactNumber)(e)} ${s}`:(0,_mobileCore.formatCompactNumber)(e),tone:c});else if("Line"===e.chartType)p=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Sparkline,{data:x,height:160,fill:!0,tone:c,label:u,formatLabel:e=>writeValue(e,s)}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",justifyContent:"space-between"},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",children:(0,_chatCore.toFigureText)(b.label)}),m.length>1?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",children:(0,_chatCore.toFigureText)(j.label)}):null]}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:`${t.labels.chartLow(writeValue(h,s))} ${t.labels.chartHigh(writeValue(_,s))}`})]});else{const e=x.reduce((e,t)=>e+(Number.isFinite(t)&&t>0?t:0),0);p=(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"list",style:{gap:i.space.sm},children:withPositions(m).map(({key:t,item:i})=>{const r=e>0&&Number.isFinite(i.value)&&i.value>0?i.value/e:0;return(0,_jsxRuntime.jsx)(_mobileUi.ProgressBar,{progress:r,height:8,tone:toneAt(t),label:(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:i.label,variant:"bodySmall"}),valueLabel:`${writeValue(i.value,s)} (${(0,_mobileCore.formatPercent)(r,{maximumFractionDigits:0})})`},t)})})}return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.xs},children:[n?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:(0,_chatCore.toFigureText)(l.name)}):null,p]},a)})]})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FigureRuns=FigureRuns,exports.FigureText=FigureText,exports.runsToText=runsToText;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const sizeStepOf=e=>"caption"===e?"xs":"bodySmall"===e||"label"===e?"sm":"title"===e?"lg":"base",inkFor=(e,t)=>"secondary"===t?e.colors["text-muted"]:"tertiary"===t?e.colors["text-subtle"]:"success"===t||"warning"===t||"danger"===t||"info"===t?e.colors[`${t}-text`]:e.colors["text-body"];function runsToText(e){return e.map(e=>e.text).join("")}const withOffsets=e=>e.reduce((e,t)=>{const r=e[e.length-1],i=r?r.offset+r.run.text.length:0;return e.push({offset:i,run:t}),e},[]);function runNode(e,t,r){if("text"===e.kind)return e.text;const i="sub"===e.kind?Math.round(.4*t):-Math.round(.45*t),n=Math.round(.75*t);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{transform:[{translateY:i}]},children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{fontSize:n,lineHeight:n,includeFontPadding:!1,color:r},children:e.text})})}function FigureRuns({runs:e,variant:t="bodySmall",color:r,strong:i=!1,numberOfLines:n,accessibilityLabel:s,testID:o,heading:u}){const a=(0,_mobileUi.useTheme)(),c=a.text[sizeStepOf(t)].size,l=inkFor(a,r);return(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:t,...void 0===r?{}:{color:r},...i?{weight:"semibold"}:{},...void 0===n?{}:{numberOfLines:n},...void 0===o?{}:{testID:o},...u?{accessibilityRole:"header"}:{},accessibilityLabel:s??runsToText(e),children:withOffsets(e).map(({offset:e,run:t})=>(0,_jsxRuntime.jsx)(_react.Fragment,{children:runNode(t,c,l)},e))})}function FigureText({text:e,variant:t="bodySmall",enabled:r=!0,...i}){const n=(0,_react.useMemo)(()=>r?(0,_chatCore.toFigureRuns)(e):[{kind:"text",text:e}],[e,r]);return(0,_jsxRuntime.jsx)(FigureRuns,{runs:n,variant:t,...i})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FigureRuns=FigureRuns,exports.FigureText=FigureText,exports.runsToText=runsToText;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_chatShared=require("../chatShared.js"),_jsxRuntime=require("react/jsx-runtime");const sizeStepOf=e=>"caption"===e?"xs":"bodySmall"===e||"label"===e?"sm":"title"===e?"lg":"base",inkFor=(e,t)=>"secondary"===t?e.colors["text-muted"]:"tertiary"===t?e.colors["text-subtle"]:"success"===t||"warning"===t||"danger"===t||"info"===t?e.colors[`${t}-text`]:e.colors["text-body"];function runsToText(e){return e.map(e=>e.text).join("")}const withOffsets=e=>e.reduce((e,t)=>{const r=e[e.length-1],i=r?r.offset+r.run.text.length:0;return e.push({offset:i,run:t}),e},[]);function runNode(e,t,r){if("text"===e.kind)return e.text;const i="sub"===e.kind?Math.round(.4*t):-Math.round(.45*t),n=Math.round(.75*t);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{transform:[{translateY:i}]},children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{fontSize:n,lineHeight:n,includeFontPadding:!1,color:r},children:e.text})})}function FigureRuns({runs:e,variant:t="bodySmall",color:r,strong:i=!1,numberOfLines:n,accessibilityLabel:s,testID:o,heading:u}){const a=(0,_mobileUi.useTheme)(),c=a.text[sizeStepOf(t)].size,l=inkFor(a,r);return(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:t,...void 0===r?{}:{color:r},...i?{weight:"semibold"}:{},...void 0===n?{}:{numberOfLines:n},...void 0===o?{}:{testID:o},...u?{accessibilityRole:"header",...(0,_chatShared.webProps)({"aria-level":3})}:{},accessibilityLabel:s??runsToText(e),children:withOffsets(e).map(({offset:e,run:t})=>(0,_jsxRuntime.jsx)(_react.Fragment,{children:runNode(t,c,l)},e))})}function FigureText({text:e,variant:t="bodySmall",enabled:r=!0,...i}){const n=(0,_react.useMemo)(()=>r?(0,_chatCore.toFigureRuns)(e):[{kind:"text",text:e}],[e,r]);return(0,_jsxRuntime.jsx)(FigureRuns,{runs:n,variant:t,...i})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FiguresPart=FiguresPart;var _chatCore=require("@webority/chat-core"),_mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_FigureText=require("./FigureText.js"),_jsxRuntime=require("react/jsx-runtime");const TONE={Neutral:"neutral",Positive:"success",Caution:"warning",Negative:"danger"},withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),valueRunsOf=e=>{if(0!==e.value&&Math.abs(e.value)<.001)return(0,_chatCore.formatFigure)(e.value);const t=(0,_mobileCore.formatNumber)(e.value,{maximumFractionDigits:2});return[{kind:"text",text:e.value<0?t.replace("-","−"):t}]};function FiguresPart({part:e,turn:t}){const i=(0,_mobileUi.useTheme)();return 0===e.figures.length?null:(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"summary",accessibilityLabel:t.labels.figures,style:{flexDirection:"row",flexWrap:"wrap",gap:i.space.sm},children:withPositions(e.figures).map(({key:e,item:i})=>{const r=valueRunsOf(i),u=t.labels.figureStatus(i.status),a=(0,_chatCore.toFigureText)(i.label);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexGrow:1,minWidth:110},children:(0,_jsxRuntime.jsx)(_mobileUi.StatTile,{label:a,value:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"flex-end",flexWrap:"wrap"},children:[(0,_jsxRuntime.jsx)(_FigureText.FigureRuns,{runs:r,variant:"title",color:"primary",strong:!0}),i.unit?(0,_jsxRuntime.jsx)(_FigureText.FigureRuns,{runs:[{kind:"text",text:" "},...(0,_chatCore.toFigureRuns)(i.unit)],variant:"bodySmall",color:"secondary"}):null]}),tone:TONE[i.status],caption:u||void 0,accessibilityLabel:`${a}: ${(0,_FigureText.runsToText)(r)}${i.unit?` ${i.unit}`:""}${u?`, ${u}`:""}`})},e)})})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FiguresPart=FiguresPart;var _chatCore=require("@webority/chat-core"),_mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_chatShared=require("../chatShared.js"),_FigureText=require("./FigureText.js"),_jsxRuntime=require("react/jsx-runtime");const TONE={Neutral:"neutral",Positive:"success",Caution:"warning",Negative:"danger"},withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),valueRunsOf=e=>{if(0!==e.value&&Math.abs(e.value)<.001)return(0,_chatCore.formatFigure)(e.value);const t=(0,_mobileCore.formatNumber)(e.value,{maximumFractionDigits:2});return[{kind:"text",text:e.value<0?t.replace("-","−"):t}]};function FiguresPart({part:e,turn:t}){const r=(0,_mobileUi.useTheme)();return 0===e.figures.length?null:(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"summary",accessibilityLabel:t.labels.figures,...(0,_chatShared.webProps)({role:"group"}),style:{flexDirection:"row",flexWrap:"wrap",gap:r.space.sm},children:withPositions(e.figures).map(({key:e,item:r})=>{const i=valueRunsOf(r),a=t.labels.figureStatus(r.status),u=(0,_chatCore.toFigureText)(r.label);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexGrow:1,minWidth:110},children:(0,_jsxRuntime.jsx)(_mobileUi.StatTile,{label:u,value:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"flex-end",flexWrap:"wrap"},children:[(0,_jsxRuntime.jsx)(_FigureText.FigureRuns,{runs:i,variant:"title",color:"primary",strong:!0}),r.unit?(0,_jsxRuntime.jsx)(_FigureText.FigureRuns,{runs:[{kind:"text",text:" "},...(0,_chatCore.toFigureRuns)(r.unit)],variant:"bodySmall",color:"secondary"}):null]}),tone:TONE[r.status],caption:a||void 0,accessibilityLabel:`${u}: ${(0,_FigureText.runsToText)(i)}${r.unit?` ${r.unit}`:""}${a?`, ${a}`:""}`})},e)})})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HandoffPart=HandoffPart;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");function HandoffPart({part:e,turn:i}){const t=(0,_mobileUi.useTheme)(),{labels:s}=i;if(!0===i.handoffSettled&&("Requested"===e.state||"Waiting"===e.state))return null;const a=i.isLast&&("Requested"===e.state||"Waiting"===e.state||"Joined"===e.state),n=e.agent?.displayName||s.handoffAgentFallback,r=e.agent?.avatarUrl;let o;switch(e.state){case"Requested":o=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:t.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Spinner,{size:"sm"}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:s.handoffRequested})]});break;case"Waiting":o=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:t.space.xs},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:t.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Spinner,{size:"sm"}),"number"==typeof e.queuePosition?null:(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:s.handoffWaiting})]}),"number"==typeof e.queuePosition?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.handoffQueued(e.queuePosition)}):null,(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.handoffQueuedText})]});break;case"Joined":o=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:t.space.xs},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:t.space.sm},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{position:"relative"},children:[(0,_jsxRuntime.jsx)(_mobileUi.Avatar,{size:"sm",name:n,...r?{source:{uri:r}}:{}}),(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:"absolute",right:0,bottom:0,width:8,height:8,borderRadius:t.radius.pill,backgroundColor:t.colors["success-text"]}})]}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:s.handoffJoined(n)})]}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.handoffJoinedText(n)})]});break;case"Left":o=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:t.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:s.handoffLeft(n)}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.handoffLeftText})]});break;case"Ended":o=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:t.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:s.handoffEnded}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.handoffEndedText})]})}return void 0===o?null:(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",padding:"sm",accessibilityLiveRegion:a?"polite":void 0,children:o})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HandoffPart=HandoffPart;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_chatShared=require("../chatShared.js"),_jsxRuntime=require("react/jsx-runtime");function HandoffPart({part:e,turn:i}){const t=(0,_mobileUi.useTheme)(),{labels:a}=i;if(!0===i.handoffSettled&&("Requested"===e.state||"Waiting"===e.state))return null;const s=i.isLast&&("Requested"===e.state||"Waiting"===e.state||"Joined"===e.state),n=e.agent?.displayName||a.handoffAgentFallback,r=e.agent?.avatarUrl;let o;switch(e.state){case"Requested":o=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:t.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Spinner,{size:"sm"}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:a.handoffRequested})]});break;case"Waiting":o=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:t.space.xs},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:t.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Spinner,{size:"sm"}),"number"==typeof e.queuePosition?null:(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:a.handoffWaiting})]}),"number"==typeof e.queuePosition?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:a.handoffQueued(e.queuePosition)}):null,(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:a.handoffQueuedText})]});break;case"Joined":o=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:t.space.xs},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:t.space.sm},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{position:"relative"},...(0,_chatShared.webProps)({"aria-hidden":!0}),children:[(0,_jsxRuntime.jsx)(_mobileUi.Avatar,{size:"sm",name:n,...r?{source:{uri:r}}:{}}),(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:"absolute",right:0,bottom:0,width:8,height:8,borderRadius:t.radius.pill,backgroundColor:t.colors["success-text"]}})]}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",..._chatShared.WEB_STRONG,children:a.handoffJoined(n)})]}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",...(0,_chatShared.webProps)({role:"paragraph"}),children:a.handoffJoinedText(n)})]});break;case"Left":o=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:t.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:a.handoffLeft(n)}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:a.handoffLeftText})]});break;case"Ended":o=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:t.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:a.handoffEnded}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:a.handoffEndedText})]})}return void 0===o?null:(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",padding:"sm",accessibilityLiveRegion:s?"polite":void 0,children:o})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ImagePart=ImagePart;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");function ImagePart({part:e,turn:t}){const a=(0,_mobileUi.useTheme)(),i=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[s,l]=(0,_react.useState)(!1),[r,n]=(0,_react.useState)(0),c=(0,_react.useRef)(t.readAttachment);c.current=t.readAttachment;const o=(0,_react.useMemo)(()=>({get:async()=>({data:await c.current(e.attachmentId)})}),[e.attachmentId]),m=`chat-attachment:${e.attachmentId}`,u=`${m}#${r}`,b=null!==e.width&&null!==e.height&&e.width>0&&e.height>0?e.width/e.height:null,x=(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:e.alt}),_=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:a.space.xs},children:[x,(0,_jsxRuntime.jsx)(_mobileUi.Button,{variant:"soft",size:"sm",label:t.labels.retry,onPress:()=>n(e=>e+1),testID:`image-retry-${e.attachmentId}`})]});return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"imagebutton",accessibilityLabel:t.labels.imageOpen(e.alt),onPress:()=>l(!0),children:(0,_jsxRuntime.jsx)(_mobileUi.AuthedImage,{uri:m,cacheKey:u,client:o,contentFit:"contain",accessible:!0,accessibilityLabel:e.alt,labels:{loading:t.labels.imageLoading},style:{width:"100%",...null===b?{minHeight:160}:{aspectRatio:b},maxHeight:320,borderRadius:a.radius.md},placeholder:x,fallback:_})}),(0,_jsxRuntime.jsx)(_mobileUi.Modal,{open:s,onClose:()=>l(!1),backdropPressClose:!1,presentation:"fullScreen",accessibilityLabel:e.alt,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1,backgroundColor:a.colors.bg},children:[(0,_jsxRuntime.jsx)(_mobileUi.ZoomableImage,{style:{flex:1},accessibilityLabel:e.alt,children:(0,_jsxRuntime.jsx)(_mobileUi.AuthedImage,{uri:m,cacheKey:u,client:o,contentFit:"contain",style:{flex:1},accessibilityLabel:e.alt})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:"absolute",top:i.top+a.space.sm,right:a.space.sm},children:(0,_jsxRuntime.jsx)(_mobileUi.Button,{variant:"soft",size:"sm",label:t.labels.close,onPress:()=>l(!1)})})]})})]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ImagePart=ImagePart;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_chatShared=require("../chatShared.js"),_jsxRuntime=require("react/jsx-runtime");function ImagePart({part:e,turn:t}){const a=(0,_mobileUi.useTheme)(),i=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[s,r]=(0,_react.useState)(!1),[l,n]=(0,_react.useState)(0),c=(0,_react.useRef)(t.readAttachment);c.current=t.readAttachment;const o=(0,_react.useMemo)(()=>({get:async()=>({data:await c.current(e.attachmentId)})}),[e.attachmentId]),m=`chat-attachment:${e.attachmentId}`,u=`${m}#${l}`,b=null!==e.width&&null!==e.height&&e.width>0&&e.height>0?e.width/e.height:null,h=(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:e.alt}),_=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:a.space.xs},children:[h,(0,_jsxRuntime.jsx)(_mobileUi.Button,{variant:"soft",size:"sm",label:t.labels.retry,onPress:()=>n(e=>e+1),testID:`image-retry-${e.attachmentId}`})]});return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{...(0,_chatShared.webProps)({role:"figure"}),children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"imagebutton",accessibilityLabel:t.labels.imageOpen(e.alt),onPress:()=>r(!0),children:(0,_jsxRuntime.jsx)(_mobileUi.AuthedImage,{uri:m,cacheKey:u,client:o,contentFit:"contain",accessible:!0,accessibilityLabel:e.alt,labels:{loading:t.labels.imageLoading},style:{width:"100%",...null===b?{minHeight:160}:{aspectRatio:b},maxHeight:320,borderRadius:a.radius.md},placeholder:h,fallback:_})})}),(0,_jsxRuntime.jsx)(_mobileUi.Modal,{open:s,onClose:()=>r(!1),backdropPressClose:!1,presentation:"fullScreen",accessibilityLabel:e.alt,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1,backgroundColor:a.colors.bg},children:[(0,_jsxRuntime.jsx)(_mobileUi.ZoomableImage,{style:{flex:1},accessibilityLabel:e.alt,children:(0,_jsxRuntime.jsx)(_mobileUi.AuthedImage,{uri:m,cacheKey:u,client:o,contentFit:"contain",style:{flex:1},accessibilityLabel:e.alt})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:"absolute",top:i.top+a.space.sm,right:a.space.sm},children:(0,_jsxRuntime.jsx)(_mobileUi.Button,{variant:"soft",size:"sm",label:t.labels.close,onPress:()=>r(!1)})})]})})]})}
@@ -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"),_jsxRuntime=require("react/jsx-runtime");const fileNameOf=(e,t)=>{const i="object"==typeof e&&null!==e&&"name"in e?e.name:void 0;return"string"==typeof i&&""!==i?i:t},slotFormat=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short",hour:"numeric",minute:"2-digit"}),isStringList=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e),selectedIds=e=>{if(""===e)return[];const t=JSON.parse(e);if(!isStringList(t))throw new Error("Selected ids are not a list of strings.");return t},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:n}=t,[a,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,h]=(0,_react.useState)({}),j=(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=j.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,U=Object.values(y).some(e=>"Ready"!==e.status),leave=async e=>{m(!0),d("");try{await e()}catch{d(s.errorGeneric),m(!1)}},w=n.LeadShortcuts,T=e.fields[0];if(w&&1===e.fields.length&&void 0===T)throw new Error("A one-field form has no field.");const q=w&&1===e.fields.length&&void 0!==T&&!T.required,C=w&&e.cancellable;return(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",padding:"sm",...e.title?{accessibilityLabel:e.title}:{},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(n=>{const l=a[n.key]??"",c=o[n.key];if("File"===n.type){const e=y[n.key];return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:`${n.label}${optionalSuffix(n,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=n.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,{..."number"==typeof e.progress?{progress:e.progress}:{},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 n=r[0];if(!n)return;R.current+=1;const a=R.current;commitUploads({...k.current,[e.key]:{fileName:fileNameOf(n,e.label),status:"Uploading",progress:null,token:a}});try{const i=await t.uploadInputFile(n,t=>{isLiveUpload(e.key,a)&&patchUpload(e.key,{progress:t})});isLiveUpload(e.key,a)&&(setValue(e.key,i),patchUpload(e.key,{status:"Ready",progress:null}))}catch{isLiveUpload(e.key,a)&&(setValue(e.key,""),patchUpload(e.key,{status:"Failed",progress:null}))}})(n)}})}),c?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"assertive",children:c}):null]},n.key)}if("MultiChoice"===n.type){const e=(n.options??[]).map(e=>({label:e.label,value:e.id}));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:`${n.label}${optionalSuffix(n,s)}`}),(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e=>{v.current[n.key]=e},children:(0,_jsxRuntime.jsx)(_mobileUi.ChoiceGroup,{selectionMode:"multiple",options:e,value:selectedIds(l),onChange:t=>setValue(n.key,JSON.stringify(e.filter(e=>t.includes(e.value)).map(e=>e.value))),accessibilityLabel:n.label,...void 0===c?{}:{error:c},disabled:p})})]},n.key)}if("Choice"===n.type||"TimeSlot"===n.type){const e="TimeSlot"===n.type?(n.slots??[]).map(e=>({label:slotFormat.format(new Date(e.startDateTimeUtc)),value:e.id})):(n.options??[]).map(e=>({label:e.label,value:e.id}));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:`${n.label}${optionalSuffix(n,s)}`}),(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e=>{v.current[n.key]=e},children:(0,_jsxRuntime.jsx)(_mobileUi.ChoiceGroup,{options:e,...""===l?{}:{value:l},onChange:e=>setValue(n.key,String(e)),accessibilityLabel:n.label,...void 0===c?{}:{error:c},disabled:p})})]},n.key)}if("Consent"===n.type)return(0,_jsxRuntime.jsx)(_mobileUi.Checkbox,{checked:"true"===l,onChange:e=>setValue(n.key,e?"true":"false"),label:n.consentText??n.label,...void 0===c?{}:{error:c},disabled:p},n.key);const u=(0,_jsxRuntime.jsx)(_mobileUi.Input,{ref:e=>{j.current[n.key]=e},label:n.label,..."string"==typeof n.placeholder?{placeholder:n.placeholder}:{},value:l,onChangeText:e=>setValue(n.key,e),..."number"==typeof n.maxLength?{maxLength:n.maxLength}:{},required:n.required,...void 0===c?{}:{error:c},...n.required?{}:{help:s.inputOptional},labelMode:"top",disabled:p,type:n.secret?"password":"LongText"===n.type?"textarea":"input",keyboardType:KEYBOARD_TYPES[n.type]??"default",..."Email"===n.type?{autoCapitalize:"none"}:{},...void 0===AUTO_COMPLETE[n.type]?{}:{autoComplete:AUTO_COMPLETE[n.type]}},n.key);if(!("Otp"===n.verify&&("Email"===n.type||"Phone"===n.type)))return u;const m=f[n.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:(a[i.key]??"").trim()}),h(e=>({...e,[i.key]:"sent"}))}catch{h(e=>({...e,[i.key]:"failed"}))}})(n)},testID:`otp-send-${n.key}`}),(0,_jsxRuntime.jsx)(_mobileUi.Input,{label:s.inputEnterCode,value:b[n.key]??"",onChangeText:e=>_(t=>({...t,[n.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]})]},n.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||U,onPress:()=>{(async()=>{if(U)return;const i={},r={};for(const t of e.fields){const e=a[t.key]??"";if("Consent"===t.type){const n="true"===e;t.required&&!n&&(i[t.key]=s.inputConsentRequired),r[t.key]=n?"true":"false"}else if("Choice"===t.type||"TimeSlot"===t.type)t.required&&""===e&&(i[t.key]=s.inputRequired),r[t.key]=e;else if("MultiChoice"===t.type){const n=selectedIds(e);t.required&&0===n.length&&(i[t.key]=s.inputRequired),r[t.key]=JSON.stringify(n)}else if("File"===t.type)t.required&&""===e&&(i[t.key]=s.inputRequired),r[t.key]=e;else{const n=t.secret?e:e.trim();t.required&&""===n&&(i[t.key]=s.inputRequired),r[t.key]=n}}const n={};for(const t of e.fields){if("Otp"!==t.verify)continue;const e=(b[t.key]??"").trim();""===e&&(i[t.key]=s.inputRequired),n[t.key]=e}if(c(i),Object.keys(i).length>0){const t=firstErrorKey(e.fields,i);return void(void 0!==t&&S(t))}m(!0),d("");try{const i=await t.answerInput(e.requestId,r,Object.keys(n).length>0?n:null);if(i.ok)return;c(i.errors),g.current=!0,d(i.message??"")}catch{d(s.errorGeneric)}m(!1)})()}}),U?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.attachmentUploading}):null,q?(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({part:e,turn:t,pickAttachments:i}){return"Answered"===e.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:e.answeredSummary||t.labels.inputAnswered}):"Skipped"===e.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:t.labels.inputSkipped}):"Expired"===e.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:t.labels.inputExpired}):(0,_jsxRuntime.jsx)(OpenRequest,{part:e,turn:t,pickAttachments:i},e.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"),_jsxRuntime=require("react/jsx-runtime");const fileNameOf=(e,t)=>{const i="object"==typeof e&&null!==e&&"name"in e?e.name:void 0;return"string"==typeof i&&""!==i?i:t},slotFormat=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short",hour:"numeric",minute:"2-digit"}),isStringList=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e),selectedIds=e=>{if(""===e)return[];const t=JSON.parse(e);if(!isStringList(t))throw new Error("Selected ids are not a list of strings.");return t},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:a,features:s}=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,h]=(0,_react.useState)({}),j=(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=j.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,w=Object.values(y).some(e=>"Ready"!==e.status),leave=async e=>{m(!0),d("");try{await e()}catch{d(a.errorGeneric),m(!1)}},U=s.LeadShortcuts,T=e.fields[0];if(U&&1===e.fields.length&&void 0===T)throw new Error("A one-field form has no field.");const C=U&&1===e.fields.length&&void 0!==T&&!T.required,q=U&&e.cancellable;return(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",padding:"sm",...e.title?{accessibilityLabel:e.title}:{},...(0,_chatShared.webProps)({role:"form","aria-label":e.title||e.submitLabel}),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.sm},children:[e.title?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",accessibilityRole:"header",...(0,_chatShared.webProps)({"aria-level":3}),children:e.title}):null,e.fields.map(s=>{const l=n[s.key]??"",c=o[s.key];if("File"===s.type){const e=y[s.key];return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:`${s.label}${optionalSuffix(s,a)}`}),(0,_jsxRuntime.jsx)(_reactNative.View,{...(0,_chatShared.webProps)({role:"group","aria-label":s.label}),children: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=s.key,commitUploads(Object.fromEntries(Object.entries(k.current).filter(([t])=>t!==e))),void setValue(e,"");var e},labels:{remove:a.inputRemoveFile}}),"Uploading"===e.status?(0,_jsxRuntime.jsx)(_mobileUi.ProgressBar,{..."number"==typeof e.progress?{progress:e.progress}:{},label:a.attachmentUploading,height:4}):null,"Failed"===e.status?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"assertive",children:a.attachmentFailed}):null]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row"},children:(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:a.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(a.errorGeneric)}const s=r[0];if(!s)return;R.current+=1;const n=R.current;commitUploads({...k.current,[e.key]:{fileName:fileNameOf(s,e.label),status:"Uploading",progress:null,token:n}});try{const i=await t.uploadInputFile(s,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}))}})(s)}})})}),c?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"assertive",children:c}):null]},s.key)}if("MultiChoice"===s.type){const e=(s.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:`${s.label}${optionalSuffix(s,a)}`}),(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e=>{v.current[s.key]=e},...(0,_chatShared.webProps)({role:"group","aria-label":s.label}),children:(0,_jsxRuntime.jsx)(_mobileUi.ChoiceGroup,{selectionMode:"multiple",options:e,value:selectedIds(l),onChange:t=>setValue(s.key,JSON.stringify(e.filter(e=>t.includes(e.value)).map(e=>e.value))),accessibilityLabel:s.label,...void 0===c?{}:{error:c},disabled:p})})]},s.key)}if("Choice"===s.type||"TimeSlot"===s.type){const e="TimeSlot"===s.type?(s.slots??[]).map(e=>({label:slotFormat.format(new Date(e.startDateTimeUtc)),value:e.id})):(s.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:`${s.label}${optionalSuffix(s,a)}`}),(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e=>{v.current[s.key]=e},children:(0,_jsxRuntime.jsx)(_mobileUi.ChoiceGroup,{options:e,...""===l?{}:{value:l},onChange:e=>setValue(s.key,String(e)),accessibilityLabel:s.label,...void 0===c?{}:{error:c},disabled:p})})]},s.key)}if("Consent"===s.type)return(0,_jsxRuntime.jsx)(_mobileUi.Checkbox,{checked:"true"===l,onChange:e=>setValue(s.key,e?"true":"false"),label:s.consentText??s.label,...void 0===c?{}:{error:c},disabled:p},s.key);const u=(0,_jsxRuntime.jsx)(_mobileUi.Input,{ref:e=>{j.current[s.key]=e},label:s.label,..."string"==typeof s.placeholder?{placeholder:s.placeholder}:{},value:l,onChangeText:e=>setValue(s.key,e),..."number"==typeof s.maxLength?{maxLength:s.maxLength}:{},showCounter:!1,required:s.required,...void 0===c?{}:{error:c},...s.required?{}:{help:(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:a.inputOptional})},labelMode:"top",disabled:p,type:s.secret?"password":"LongText"===s.type?"textarea":"input",keyboardType:KEYBOARD_TYPES[s.type]??"default",..."Email"===s.type?{autoCapitalize:"none"}:{},...void 0===AUTO_COMPLETE[s.type]?{}:{autoComplete:AUTO_COMPLETE[s.type]}},s.key);if(!("Otp"===s.verify&&("Email"===s.type||"Phone"===s.type)))return u;const m=f[s.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:a.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()}),h(e=>({...e,[i.key]:"sent"}))}catch{h(e=>({...e,[i.key]:"failed"}))}})(s)},testID:`otp-send-${s.key}`}),(0,_jsxRuntime.jsx)(_mobileUi.Input,{label:a.inputEnterCode,value:b[s.key]??"",onChangeText:e=>_(t=>({...t,[s.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?a.inputCodeFailed:a.inputCodeSent}):null]})]},s.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?a.inputSubmitting:e.submitLabel,loading:p,disabled:p||w,onPress:()=>{(async()=>{if(w)return;const i={},r={};for(const t of e.fields){const e=n[t.key]??"";if("Consent"===t.type){const s="true"===e;t.required&&!s&&(i[t.key]=a.inputConsentRequired),r[t.key]=s?"true":"false"}else if("Choice"===t.type||"TimeSlot"===t.type)t.required&&""===e&&(i[t.key]=a.inputRequired),r[t.key]=e;else if("MultiChoice"===t.type){const s=selectedIds(e);t.required&&0===s.length&&(i[t.key]=a.inputRequired),r[t.key]=JSON.stringify(s)}else if("File"===t.type)t.required&&""===e&&(i[t.key]=a.inputRequired),r[t.key]=e;else{const s=t.secret?e:e.trim();t.required&&""===s&&(i[t.key]=a.inputRequired),r[t.key]=s}}const s={};for(const t of e.fields){if("Otp"!==t.verify)continue;const e=(b[t.key]??"").trim();""===e&&(i[t.key]=a.inputRequired),s[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(s).length>0?s:null);if(i.ok)return;c(i.errors),g.current=!0,d(i.message??"")}catch{d(a.errorGeneric)}m(!1)})()}}),w?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:a.attachmentUploading}):null,C?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:a.skip,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.skipInput(e.requestId))}}):null,q?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:a.cancel,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.cancelLead())}}):null]}),e.allowTyped?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",...(0,_chatShared.webProps)({role:"paragraph"}),children:a.typeAnswer}):null]})})}function InputRequestPart({part:e,turn:t,pickAttachments:i}){return"Answered"===e.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:e.answeredSummary||t.labels.inputAnswered}):"Skipped"===e.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:t.labels.inputSkipped}):"Expired"===e.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:t.labels.inputExpired}):(0,_jsxRuntime.jsx)(OpenRequest,{part:e,turn:t,pickAttachments:i},e.requestId)}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RecordCardPart=RecordCardPart;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 withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),NUMERIC=new Set(["Integer","Decimal","MoneyMinor","Percent"]);function RecordCardPart({part:e,turn:t}){const r=(0,_mobileUi.useTheme)(),i=void 0!==t.openRecord&&null!==e.target;return(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",padding:"sm",accessibilityRole:"summary",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:e.title,variant:"label",color:"primary",strong:!0,numberOfLines:2,enabled:t.features.FigureText,heading:!0}),e.subtitle?(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:e.subtitle,variant:"bodySmall",color:"secondary",enabled:t.features.FigureText}):null,withPositions(e.fields).map(({key:e,item:i})=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[e>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:_reactNative.StyleSheet.hairlineWidth,backgroundColor:r.colors["border-subtle"]}}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",justifyContent:"space-between",gap:r.space.sm},children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexShrink:1},children:(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:i.label,variant:"caption",color:"secondary",enabled:t.features.FigureText})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,alignItems:NUMERIC.has(i.type)?"flex-end":"flex-start"},children:(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:(0,_chatCore.formatChatValue)(i.value,i.type,null),variant:"bodySmall",color:"primary",enabled:t.features.FigureText})})]})]},e)),i?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:t.labels.recordOpen,variant:"link",size:"sm",accessibilityLabel:t.labels.recordOpenFor((0,_chatCore.toFigureText)(e.title)),onPress:()=>t.openRecord?.(e),testID:`record-open-${e.recordId}`}):null]})})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RecordCardPart=RecordCardPart;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_chatShared=require("../chatShared.js"),_FigureText=require("./FigureText.js"),_jsxRuntime=require("react/jsx-runtime");const withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),NUMERIC=new Set(["Integer","Decimal","MoneyMinor","Percent"]);function RecordCardPart({part:e,turn:t}){const r=(0,_mobileUi.useTheme)(),i=void 0!==t.openRecord&&null!==e.target;return(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",padding:"sm",accessibilityRole:"summary",...(0,_chatShared.webProps)({role:"article","aria-label":(0,_chatCore.toFigureText)(e.title)}),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:e.title,variant:"label",color:"primary",strong:!0,numberOfLines:2,enabled:t.features.FigureText,heading:!0}),e.subtitle?(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:e.subtitle,variant:"bodySmall",color:"secondary",enabled:t.features.FigureText}):null,withPositions(e.fields).map(({key:e,item:i})=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[e>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:_reactNative.StyleSheet.hairlineWidth,backgroundColor:r.colors["border-subtle"]}}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",justifyContent:"space-between",gap:r.space.sm},children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexShrink:1},...(0,_chatShared.webProps)({role:"term"}),children:(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:i.label,variant:"caption",color:"secondary",enabled:t.features.FigureText})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,alignItems:NUMERIC.has(i.type)?"flex-end":"flex-start"},...(0,_chatShared.webProps)({role:"definition"}),children:(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:(0,_chatCore.formatChatValue)(i.value,i.type,null),variant:"bodySmall",color:"primary",enabled:t.features.FigureText})})]})]},e)),i?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:t.labels.recordOpen,variant:"link",size:"sm",accessibilityLabel:t.labels.recordOpenFor((0,_chatCore.toFigureText)(e.title)),onPress:()=>t.openRecord?.(e),testID:`record-open-${e.recordId}`}):null]})})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SourcesPart=SourcesPart;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_ChatEntrance=require("../ChatEntrance.js"),_jsxRuntime=require("react/jsx-runtime");const HTTP_LINK=/^https?:\/\//i;function SourcesPart({part:e,turn:r}){const t=(0,_mobileUi.useTheme)();if(!r.features.Sources||0===e.sources.length)return null;const i=r.openTarget;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:t.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:r.labels.sources}),(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"list",accessibilityLabel:r.labels.sources,style:{flexDirection:"row",flexWrap:"wrap",gap:t.space.xs},children:e.sources.map((e,t)=>{const s=e.url,a=null!==s&&HTTP_LINK.test(s)&&void 0!==i?()=>i(s):void 0;return(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{index:t,animate:!1,children:(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t=>r.registerSourceRow?.(String(e.marker),t),children:(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:`${e.marker} ${e.title}`,variant:"outline",size:"sm",...void 0===a?{}:{accessibilityLabel:r.labels.openSource(e.title),onPress:a}})})},e.marker)})})]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SourcesPart=SourcesPart;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_ChatEntrance=require("../ChatEntrance.js"),_chatShared=require("../chatShared.js"),_jsxRuntime=require("react/jsx-runtime");const HTTP_LINK=/^https?:\/\//i;function SourcesPart({part:e,turn:r}){const t=(0,_mobileUi.useTheme)();if(!r.features.Sources||0===e.sources.length)return null;const i=r.openTarget;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:t.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",...(0,_chatShared.webProps)({role:"paragraph"}),children:r.labels.sources}),(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"list",accessibilityLabel:r.labels.sources,style:{flexDirection:"row",flexWrap:"wrap",gap:t.space.xs},children:e.sources.map((e,t)=>{const s=e.url,a=null!==s&&HTTP_LINK.test(s)&&void 0!==i?()=>i(s):void 0;return(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{index:t,animate:!1,children:(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t=>r.registerSourceRow?.(String(e.marker),t),...(0,_chatShared.webProps)({role:"listitem"}),children:(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:`${e.marker} ${e.title}`,variant:"outline",size:"sm",...void 0===a?{}:{accessibilityLabel:r.labels.openSource(e.title),onPress:a}})})},e.marker)})})]})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TablePart=TablePart;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_FigureText=require("./FigureText.js"),_jsxRuntime=require("react/jsx-runtime");const PREVIEW_ROWS=25,COLUMN_WIDTH={Text:140,Integer:88,Decimal:96,MoneyMinor:112,Percent:80,Date:112,DateTimeUtc:152},NUMERIC=new Set(["Integer","Decimal","MoneyMinor","Percent"]),withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]);function TablePart({part:e,turn:t}){const i=(0,_mobileUi.useTheme)(),[r,n]=(0,_react.useState)(!1),[s,a]=(0,_react.useState)(0),[l,o]=(0,_react.useState)(0),[c,u]=(0,_react.useState)(0);if(0===e.columns.length||0===e.rows.length)return null;const plain=e=>t.features.FigureText?(0,_chatCore.toFigureText)(e):e,x=l>c+s+1,m=r?e.rows:e.rows.slice(0,PREVIEW_ROWS),_={height:_reactNative.StyleSheet.hairlineWidth,backgroundColor:i.colors["border-subtle"]},h={paddingVertical:i.space.xs,paddingHorizontal:i.space.sm},cellValue=(t,i,r)=>{const n=t[i];return null==n?null:(0,_chatCore.formatChatValue)(n,r.type,e.currency)};return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityLabel:e.title?plain(e.title):t.labels.table,style:{gap:i.space.xs},children:[e.title?(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:e.title,variant:"label",color:"primary",strong:!0,enabled:t.features.FigureText}):null,(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",padding:"sm",onLayout:e=>u(e.nativeEvent.layout.width),children:[(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!0,nestedScrollEnabled:!0,onScroll:e=>a(e.nativeEvent.contentOffset.x),onContentSizeChange:e=>o(e),scrollEventThrottle:16,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row"},children:e.columns.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:[h,{width:COLUMN_WIDTH[e.type],alignItems:NUMERIC.has(e.type)?"flex-end":"flex-start"}],children:(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:e.label,variant:"label",color:"secondary",strong:!0,numberOfLines:2,enabled:t.features.FigureText})},e.key))}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:_}),withPositions(m).map(({key:i,item:r})=>{const n=e.columns.map((e,t)=>`${plain(e.label)}: ${cellValue(r,t,e)??"-"}`).join(", ");return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessible:!0,accessibilityLabel:n,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:"row"},children:e.columns.map((e,i)=>{const n=cellValue(r,i,e);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[h,{width:COLUMN_WIDTH[e.type],alignItems:NUMERIC.has(e.type)?"flex-end":"flex-start"}],children:null===n?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"tertiary",children:"-"}):(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:n,variant:"bodySmall",color:"primary",numberOfLines:3,enabled:t.features.FigureText})},e.key)})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:_})]},i)})]})}),x?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:{position:"absolute",right:0,top:0,bottom:0,justifyContent:"center"},children:(0,_jsxRuntime.jsx)(_mobileUi.AppIcon,{name:"chevron-right",size:"sm",color:"tertiary"})}):null]}),!r&&e.rows.length>PREVIEW_ROWS?(0,_jsxRuntime.jsx)(_mobileUi.Button,{variant:"link",size:"sm",label:t.labels.tableShowAll(e.rows.length),onPress:()=>n(!0)}):null]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TablePart=TablePart;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_chatShared=require("../chatShared.js"),_FigureText=require("./FigureText.js"),_jsxRuntime=require("react/jsx-runtime");const PREVIEW_ROWS=25,COLUMN_WIDTH={Text:140,Integer:88,Decimal:96,MoneyMinor:112,Percent:80,Date:112,DateTimeUtc:152},NUMERIC=new Set(["Integer","Decimal","MoneyMinor","Percent"]),withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]);function TablePart({part:e,turn:t}){const r=(0,_mobileUi.useTheme)(),[i,a]=(0,_react.useState)(!1),[l,s]=(0,_react.useState)(0),[n,o]=(0,_react.useState)(0),[c,u]=(0,_react.useState)(0);if(0===e.columns.length||0===e.rows.length)return null;const plain=e=>t.features.FigureText?(0,_chatCore.toFigureText)(e):e,_=n>c+l+1,x=i?e.rows:e.rows.slice(0,PREVIEW_ROWS),h={height:_reactNative.StyleSheet.hairlineWidth,backgroundColor:r.colors["border-subtle"]},m={paddingVertical:r.space.xs,paddingHorizontal:r.space.sm},cellValue=(t,r,i)=>{const a=t[r];return null==a?null:(0,_chatCore.formatChatValue)(a,i.type,e.currency)};return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityLabel:e.title?plain(e.title):t.labels.table,style:{gap:r.space.xs},...(0,_chatShared.webProps)({role:"figure"}),children:[e.title?(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:e.title,variant:"label",color:"primary",strong:!0,enabled:t.features.FigureText}):null,(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",padding:"sm",onLayout:e=>u(e.nativeEvent.layout.width),...(0,_chatShared.webProps)({role:"region","aria-label":e.title?plain(e.title):t.labels.table}),children:[(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!0,nestedScrollEnabled:!0,onScroll:e=>s(e.nativeEvent.contentOffset.x),onContentSizeChange:e=>o(e),scrollEventThrottle:16,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{...(0,_chatShared.webProps)({role:"table"}),children:[(0,_jsxRuntime.jsx)(_reactNative.View,{...(0,_chatShared.webProps)({role:"rowgroup"}),children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row"},...(0,_chatShared.webProps)({role:"row"}),children:e.columns.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:[m,{width:COLUMN_WIDTH[e.type],alignItems:NUMERIC.has(e.type)?"flex-end":"flex-start"}],...(0,_chatShared.webProps)({role:"columnheader"}),children:(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:e.label,variant:"label",color:"secondary",strong:!0,numberOfLines:2,enabled:t.features.FigureText})},e.key))})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:h}),(0,_jsxRuntime.jsx)(_reactNative.View,{...(0,_chatShared.webProps)({role:"rowgroup"}),children:withPositions(x).map(({key:r,item:i})=>{const a=e.columns.map((e,t)=>`${plain(e.label)}: ${cellValue(i,t,e)??"-"}`).join(", ");return(0,_jsxRuntime.jsxs)(_reactNative.View,{..."web"===_reactNative.Platform.OS?{}:{accessible:!0,accessibilityLabel:a},children:[(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:"row"},...(0,_chatShared.webProps)({role:"row"}),children:e.columns.map((e,r)=>{const a=cellValue(i,r,e);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[m,{width:COLUMN_WIDTH[e.type],alignItems:NUMERIC.has(e.type)?"flex-end":"flex-start"}],...(0,_chatShared.webProps)({role:0===r&&"Text"===e.type?"rowheader":"cell"}),children:null===a?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"tertiary",children:"-"}):(0,_jsxRuntime.jsx)(_FigureText.FigureText,{text:a,variant:"bodySmall",color:"primary",numberOfLines:3,enabled:t.features.FigureText})},e.key)})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:h})]},r)})})]})}),_?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:{position:"absolute",right:0,top:0,bottom:0,justifyContent:"center"},children:(0,_jsxRuntime.jsx)(_mobileUi.AppIcon,{name:"chevron-right",size:"sm",color:"tertiary"})}):null]}),!i&&e.rows.length>PREVIEW_ROWS?(0,_jsxRuntime.jsx)(_mobileUi.Button,{variant:"link",size:"sm",label:t.labels.tableShowAll(e.rows.length),onPress:()=>a(!0)}):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"),_reactNative=require("react-native"),_FigureText=require("./FigureText.js"),_jsxRuntime=require("react/jsx-runtime");const CITATION=/^\d+$/;function TextPart({part:e,message:t,turn:r}){const i="Visitor"===t.author.kind||"Customer"===t.author.kind;return(0,_jsxRuntime.jsx)(_reactNative.View,{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),...r.features.FigureText?{figureText:_chatCore.toFigureRuns}:{},...r.openCitation?{onOpenCitation:e=>r.openCitation?.(Number(e))}:{},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"),_chatShared=require("../chatShared.js"),_FigureText=require("./FigureText.js"),_jsxRuntime=require("react/jsx-runtime");const CITATION=/^\d+$/;function TextPart({part:e,message:t,turn:r}){const i="Visitor"===t.author.kind||"Customer"===t.author.kind;return(0,_jsxRuntime.jsx)(_reactNative.View,{...(0,_chatShared.webProps)({role:"paragraph"}),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),...r.features.FigureText?{figureText:_chatCore.toFigureRuns}:{},...r.openCitation?{onOpenCitation:e=>r.openCitation?.(Number(e))}:{},children:e.text})})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TicketPart=TicketPart;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");function TicketPart({part:e,turn:t}){const i=(0,_mobileUi.useTheme)(),{labels:s,openTicket:r}=t,a=s.ticketAria(e.number),n=s.ticketStatus(e.status),l=r?()=>r({ticketId:e.ticketId,number:e.number}):void 0;return(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",padding:"sm",accessibilityLabel:n?`${a}, ${n}`:a,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.xs},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:i.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:a}),n?(0,_jsxRuntime.jsx)(_mobileUi.Chip,{size:"sm",variant:"soft",label:n}):null]}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:e.subject}),l?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.ticketView,variant:"link",size:"sm",onPress:l,testID:`ticket-view-${e.ticketId}`}):null]})})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TicketPart=TicketPart;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_chatShared=require("../chatShared.js"),_jsxRuntime=require("react/jsx-runtime");function TicketPart({part:e,turn:t}){const i=(0,_mobileUi.useTheme)(),{labels:a,openTicket:r}=t,s=a.ticketAria(e.number),n=a.ticketStatus(e.status),l=r?()=>r({ticketId:e.ticketId,number:e.number}):void 0;return(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",padding:"sm",accessibilityLabel:n?`${s}, ${n}`:s,...(0,_chatShared.webProps)({role:"article","aria-label":s}),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.xs},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:i.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:s}),n?(0,_jsxRuntime.jsx)(_mobileUi.Chip,{size:"sm",variant:"soft",label:n}):null]}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",..._chatShared.WEB_STRONG,children:e.subject}),l?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:a.ticketView,variant:"link",size:"sm",onPress:l,testID:`ticket-view-${e.ticketId}`}):null]})})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VoiceClipPart=VoiceClipPart;var _chatCore=require("@webority/chat-core"),_mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_expoModules=require("../expoModules.js"),_expoAudio=require("../speech/expoAudio.js"),_phoneSpeech=require("../speech/phoneSpeech.js"),_speechText=require("../speech/speechText.js"),_jsxRuntime=require("react/jsx-runtime");const expoFileSystem=()=>{try{return(0,_expoModules.loadExpoFileSystem)()}catch{throw new _phoneSpeech.PhoneSpeechError("Unavailable","Unavailable","Voice files are not available in this app.")}};function VoiceClipPart({part:e,turn:t}){const i=(0,_mobileUi.useTheme)(),r=(0,_react.useMemo)(()=>buildStyles(i),[i]),a=t.labels,[c,l]=(0,_react.useState)(!1),[o,s]=(0,_react.useState)(!1),[n,u]=(0,_react.useState)(!1),[p,h]=(0,_react.useState)(0),[_,m]=(0,_react.useState)(!1),x=(0,_react.useRef)(null),d=(0,_react.useRef)(null),b=(0,_react.useRef)(!0);(0,_react.useEffect)(()=>(b.current=!0,()=>{b.current=!1,x.current?.stop(),x.current=null,null!==d.current&&(0,_phoneSpeech.discardFile)(d.current)}),[]);const startPlayback=e=>{const t=(0,_expoAudio.playFile)(e,e=>{b.current&&(h(e.positionMs),u(e.playing))});x.current=t;const release=()=>!(!b.current||x.current!==t)&&(x.current=null,u(!1),!0);t.finished.then(()=>{release()&&h(0)},e=>{release()&&(s(!0),_mobileCore.Logger.error("[chat] voice clip playback failed",e))})},v=t.features.VoiceClips,y=null!==e.transcript&&""!==e.transcript?e.transcript:null,j=e.durationMs>0?Math.min(1,Math.max(0,p/e.durationMs)):0,w=(0,_react.useMemo)(()=>(0,_chatCore.voiceClipBars)(e.attachmentId,40).map((e,t)=>({id:`bar-${t}`,position:t,level:e})),[e.attachmentId]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityRole:"summary",accessibilityLabel:a.voiceClip,testID:"chat-voice-clip",style:r.root,children:[v?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:r.row,children:[(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:n?"pause":"play",accessibilityLabel:n?a.voiceClipPause:a.voiceClipPlay,variant:"ghost",tone:"neutral",size:"sm",loading:c,disabled:c,onPress:()=>{const i=x.current;null===i?null===d.current?c||(async()=>{l(!0),s(!1);try{const i=new Uint8Array(await t.readAttachment(e.attachmentId)),{File:r,Paths:a}=expoFileSystem(),c=new r(a.cache,`wchat-clip-${e.attachmentId}${(0,_speechText.audioExtension)(i)}`);if(c.create({overwrite:!0}),c.write(i),!b.current)return void(0,_phoneSpeech.discardFile)(c.uri);d.current=c.uri,startPlayback(c.uri)}catch(e){if(!b.current)return;s(!0),_mobileCore.Logger.error("[chat] voice clip failed to load",e)}finally{b.current&&l(!1)}})():startPlayback(d.current):n?i.pause():i.resume()},testID:"chat-voice-clip-play"}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:r.wave,children:w.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"chat-voice-clip-bar",style:[r.bar,{height:Math.max(4,Math.round(28*e.level)),backgroundColor:e.position<Math.floor(40*j)?i.colors.primary:i.colors["text-subtle"]}]},e.id))}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:a.voiceClipTime((0,_speechText.formatClipTime)(p),(0,_speechText.formatClipTime)(e.durationMs))})]}):null,v&&null!==y?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:_?a.voiceClipHideTranscript:a.voiceClipShowTranscript,variant:"link",size:"sm",accessibilityState:{expanded:_},onPress:()=>m(e=>!e),testID:"chat-voice-clip-transcript-toggle"}),_?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"body",children:y}):null]}):null,v||null===y?null:(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"body",children:y}),o?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:a.voiceClipFailed}):null]})}const buildStyles=e=>_reactNative.StyleSheet.create({root:{gap:e.space.xs},row:{flexDirection:"row",alignItems:"center",gap:e.space.xs},wave:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},bar:{width:3}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VoiceClipPart=VoiceClipPart;var _chatCore=require("@webority/chat-core"),_mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_chatShared=require("../chatShared.js"),_expoModules=require("../expoModules.js"),_expoAudio=require("../speech/expoAudio.js"),_phoneSpeech=require("../speech/phoneSpeech.js"),_speechText=require("../speech/speechText.js"),_jsxRuntime=require("react/jsx-runtime");const expoFileSystem=()=>{try{return(0,_expoModules.loadExpoFileSystem)()}catch{throw new _phoneSpeech.PhoneSpeechError("Unavailable","Unavailable","Voice files are not available in this app.")}};function VoiceClipPart({part:e,turn:t}){const i=(0,_mobileUi.useTheme)(),r=(0,_react.useMemo)(()=>buildStyles(i),[i]),a=t.labels,[c,o]=(0,_react.useState)(!1),[l,s]=(0,_react.useState)(!1),[n,u]=(0,_react.useState)(!1),[p,h]=(0,_react.useState)(0),[_,m]=(0,_react.useState)(!1),d=(0,_react.useRef)(null),x=(0,_react.useRef)(null),b=(0,_react.useRef)(!0);(0,_react.useEffect)(()=>(b.current=!0,()=>{b.current=!1,d.current?.stop(),d.current=null,null!==x.current&&(0,_phoneSpeech.discardFile)(x.current)}),[]);const startPlayback=e=>{const t=(0,_expoAudio.playFile)(e,e=>{b.current&&(h(e.positionMs),u(e.playing))});d.current=t;const release=()=>!(!b.current||d.current!==t)&&(d.current=null,u(!1),!0);t.finished.then(()=>{release()&&h(0)},e=>{release()&&(s(!0),_mobileCore.Logger.error("[chat] voice clip playback failed",e))})},v=t.features.VoiceClips,y=null!==e.transcript&&""!==e.transcript?e.transcript:null,j=e.durationMs>0?Math.min(1,Math.max(0,p/e.durationMs)):0,w=(0,_react.useMemo)(()=>(0,_chatCore.voiceClipBars)(e.attachmentId,40).map((e,t)=>({id:`bar-${t}`,position:t,level:e})),[e.attachmentId]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityRole:"summary",accessibilityLabel:a.voiceClip,...(0,_chatShared.webProps)({role:"group"}),testID:"chat-voice-clip",style:r.root,children:[v?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:r.row,children:[(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:n?"pause":"play",accessibilityLabel:n?a.voiceClipPause:a.voiceClipPlay,variant:"ghost",tone:"neutral",size:"sm",loading:c,disabled:c,onPress:()=>{const i=d.current;null===i?null===x.current?c||(async()=>{o(!0),s(!1);try{const i=new Uint8Array(await t.readAttachment(e.attachmentId)),{File:r,Paths:a}=expoFileSystem(),c=new r(a.cache,`wchat-clip-${e.attachmentId}${(0,_speechText.audioExtension)(i)}`);if(c.create({overwrite:!0}),c.write(i),!b.current)return void(0,_phoneSpeech.discardFile)(c.uri);x.current=c.uri,startPlayback(c.uri)}catch(e){if(!b.current)return;s(!0),_mobileCore.Logger.error("[chat] voice clip failed to load",e)}finally{b.current&&o(!1)}})():startPlayback(x.current):n?i.pause():i.resume()},testID:"chat-voice-clip-play"}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:r.wave,children:w.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"chat-voice-clip-bar",style:[r.bar,{height:Math.max(4,Math.round(28*e.level)),backgroundColor:e.position<Math.floor(40*j)?i.colors.primary:i.colors["text-subtle"]}]},e.id))}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:a.voiceClipTime((0,_speechText.formatClipTime)(p),(0,_speechText.formatClipTime)(e.durationMs))})]}):null,v&&null!==y?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:_?a.voiceClipHideTranscript:a.voiceClipShowTranscript,variant:"link",size:"sm",accessibilityState:{expanded:_},onPress:()=>m(e=>!e),testID:"chat-voice-clip-transcript-toggle"}),_?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"body",children:y}):null]}):null,v||null===y?null:(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"body",children:y}),l?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:a.voiceClipFailed}):null]})}const buildStyles=e=>_reactNative.StyleSheet.create({root:{gap:e.space.xs},row:{flexDirection:"row",alignItems:"center",gap:e.space.xs},wave:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},bar:{width:3}});
@@ -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,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,...void 0===s?{}:{source:s}}):null,_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{webProps}from"./chatShared.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function AgentByline({author:e,labels:r,showAvatar:t=!0}){const i=useTheme(),a=e.displayName||r.agent,s=e.avatarUrl?{uri:e.avatarUrl}:void 0;return _jsxs(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:"row",alignItems:"center",gap:i.space.xs},children:[t?_jsx(View,{...webProps({"aria-hidden":!0}),children:_jsx(Avatar,{size:"xs",name:a,...void 0===s?{}:{source:s}})}):null,_jsx(Text,{variant:"caption",color:"secondary",children:a}),_jsx(Text,{variant:"caption",color:"tertiary",children:r.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{iconNameOf}from"./iconName.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 m=useTheme(),u=useMemo(()=>buildStyles(m),[m]),[p,d]=useState(""),[f,h]=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:u.tray,testID:`${i}-attachments`,children:_jsx(View,{style:u.row,children:y.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,{...null===s.progress||void 0===s.progress?{}:{progress:s.progress},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,I=null!==_&&_<=10?_jsx(Text,{variant:"caption",color:0===_?"danger":"secondary",accessibilityLiveRegion:"polite",testID:`${i}-allowance`,children:t.allowance(_)}):null,L=f?_jsx(Banner,{message:f.message,tone:f.tone,dismissible:!0,onClose:()=>h(null),...f.openSettings?{actions:[{label:t.dictateOpenSettings,onPress:()=>{Permissions.openSettings()}}]}:{},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),F=iconNameOf(c);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",...F?{sendIcon:F}:{},...e.features.Stop?{onStop:()=>e.stop()}:{},stopLabel:t.stop,disabled:0===_||e.handoffPause,maxLength:S,...void 0===B?{}:{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:h,stopRef:x}),above:P,below:_jsx(ChatFooter,{chat:e,labels:t}),...void 0===a?{}:{keyboardAware:a},...void 0===o?{}:{keyboardOffset:o},...void 0===n?{}:{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{webProps}from"./chatShared.js";import{iconNameOf}from"./iconName.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:r="chat-composer",focusRef:i,look:l=defaultChatLook,sendIcon:c}){const m=useTheme(),u=useMemo(()=>buildStyles(m),[m]),[p,d]=useState(""),[h,f]=useState(null),g=e.editing,x=useRef(null),b=useRef(null);useEffect(()=>{if(i)return i.current=()=>b.current?.focus(),()=>{i.current=null}},[i]),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:`${r}-attach`}):void 0,T=g?_jsx(Banner,{message:t.editing,accessibilityRole:"summary",actions:[{label:t.cancel,onPress:()=>e.cancelEdit()}],testID:`${r}-editing`}):null,D=y.length>0?_jsx(View,{style:u.tray,testID:`${r}-attachments`,children:_jsx(View,{style:u.row,children:y.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:`${r}-remove-${s.key}`,testID:`${r}-chip-${s.key}`}),"Uploading"===s.status?_jsx(ProgressBar,{...null===s.progress||void 0===s.progress?{}:{progress:s.progress},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,I=null!==_&&_<=10?_jsx(Text,{variant:"caption",color:0===_?"danger":"secondary",accessibilityLiveRegion:"polite",...webProps({role:"status"}),testID:`${r}-allowance`,children:t.allowance(_)}):null,L=h?_jsx(Banner,{message:h.message,tone:h.tone,dismissible:!0,onClose:()=>f(null),...h.openSettings?{actions:[{label:t.dictateOpenSettings,onPress:()=>{Permissions.openSettings()}}]}:{},testID:`${r}-voice-notice`}):null,R=p.length>0,k=p.length>.9*S?_jsx(Text,{variant:"caption",color:"secondary",testID:`${r}-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),F=iconNameOf(c);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",...F?{sendIcon:F}:{},...e.features.Stop?{onStop:()=>e.stop()}:{},stopLabel:t.stop,disabled:0===_||e.handoffPause,maxLength:S,...void 0===B?{}:{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}),...void 0===a?{}:{keyboardAware:a},...void 0===o?{}:{keyboardOffset:o},...void 0===n?{}:{safeArea:n},testID:r})}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{showsCaptchaNote}from"@webority/chat-core";import{Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{openExternalUrl}from"./chatShared.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const GOOGLE_PRIVACY="https://policies.google.com/privacy",GOOGLE_TERMS="https://policies.google.com/terms",openLink=e=>openExternalUrl(e);export function ChatFooter({chat:e,labels:t}){const o=useTheme(),r=e.profile;if(!r)return null;const i=r.footer.disclaimer||t.disclaimer,n=r.footer.privacyUrl,a=r.footer.assuranceText,l=r.footer.privacyText,c=showsCaptchaNote(r);return Boolean(i)||Boolean(l)||Boolean(n)||Boolean(a)||c?_jsxs(View,{style:{gap:o.space.xxs,alignItems:"center"},children:[i?_jsx(Text,{variant:"caption",color:"tertiary",align:"center",children:i}):null,l?_jsx(Text,{variant:"caption",color:"tertiary",align:"center",children:l}):null,n?_jsx(Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(n),children:t.footerPrivacy}):null,a?_jsx(Text,{variant:"caption",color:"tertiary",align:"center",children:a}):null,c?_jsxs(Text,{variant:"caption",color:"tertiary",align:"center",children:[t.captchaNote," ",_jsx(Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(GOOGLE_PRIVACY),children:t.captchaPrivacy})," ",_jsx(Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(GOOGLE_TERMS),children:t.captchaTerms})]}):null]}):null}
1
+ "use strict";import{showsCaptchaNote}from"@webority/chat-core";import{Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{openExternalUrl,webProps}from"./chatShared.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const GOOGLE_PRIVACY="https://policies.google.com/privacy",GOOGLE_TERMS="https://policies.google.com/terms",openLink=e=>openExternalUrl(e);export function ChatFooter({chat:e,labels:r}){const t=useTheme(),i=e.profile;if(!i)return null;const o=i.footer.disclaimer||r.disclaimer,a=i.footer.privacyUrl,n=i.footer.assuranceText,c=i.footer.privacyText,s=showsCaptchaNote(i);if(!(Boolean(o)||Boolean(c)||Boolean(a)||Boolean(n)||s))return null;const l=[];return o&&l.push(_jsx(Text,{variant:"caption",color:"tertiary",align:"center",children:o},"disclaimer")),(c||a)&&l.push(_jsxs(Text,{variant:"caption",color:"tertiary",align:"center",children:[c,c&&a?" ":null,a?_jsx(Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(a),children:r.footerPrivacy}):null]},"privacy")),n&&l.push(_jsx(Text,{variant:"caption",color:"tertiary",align:"center",children:n},"assurance")),s&&l.push(_jsxs(Text,{variant:"caption",color:"tertiary",align:"center",children:[r.captchaNote," ",_jsx(Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(GOOGLE_PRIVACY),children:r.captchaPrivacy})," ",_jsx(Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(GOOGLE_TERMS),children:r.captchaTerms})]},"captcha")),_jsx(View,{style:{gap:t.space.xxs,alignItems:"center",flexDirection:"row",flexWrap:"wrap",justifyContent:"center"},...webProps({role:"paragraph"}),children:l.flatMap((e,r)=>r?[_jsx(Text,{variant:"caption",color:"tertiary",accessibilityElementsHidden:!0,importantForAccessibility:"no",...webProps({"aria-hidden":!0}),children:"·"},`sep-${e.key}`),e]:[e])})}
@@ -1 +1 @@
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
+ "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}),_jsx(ChatReveal,{plan:k.reveal.body,flex:!0,children:_jsx(View,{style:{flex:1},children:P})}),T?null:_jsx(ChatLiveBar,{chat:e,labels:t,testID:`${v}-live`}),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{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,...void 0===e.profile?.assistant.name?{}:{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}
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{webProps}from"./chatShared.js";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:a,isLastVisitor:i,testID:r}){const n=useTheme(),[o,l]=useState(!1),[c,u]=useState("idle"),m=useRef(null),p=useTranscriptActions(e,s),d=useMemo(()=>TEXT_AUTHORS.has(t.author.kind)&&buildTranscript([t],{labels:s,title:null,figureText:!1,...void 0===e.profile?.assistant.name?{}:{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=a&&"Assistant"===t.author.kind&&!e.streaming&&!e.thinking&&e.features.Regenerate&&e.messages.some(e=>e.stored&&"Visitor"===e.author.kind),b=i&&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||d&&e.features.Share&&p.canShare||x||T||b||f&&e.features.Rating?_jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:n.space.xs},testID:r,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:`${r}-copy`}):null,x?_jsx(ReadAloudButton,{chat:e,message:t,labels:s}):null,d&&e.features.Share&&p.canShare?_jsx(Button,{label:s.share,variant:"link",size:"sm",leftIcon:"share",disabled:e.streaming||e.thinking,onPress:()=>{p.shareReply(t)},testID:`${r}-share`}):null,T?_jsx(Button,{label:s.regenerate,variant:"link",size:"sm",onPress:()=>{e.regenerate()},testID:`${r}-regenerate`}):null,b?_jsx(Button,{label:s.edit,variant:"link",size:"sm",onPress:()=>e.startEdit(t.id),testID:`${r}-edit`}):null,f&&e.features.Rating?_jsxs(_Fragment,{children:[_jsxs(View,{accessibilityRole:"summary",accessibilityLabel:s.rating,...webProps({role:"group","aria-label":`${s.rateUp} / ${s.rateDown}`}),style:{flexDirection:"row",alignItems:"center",gap:n.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:`${r}-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:`${r}-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!==p.notice?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:p.notice}):null]}):null}
@@ -1 +1 @@
1
- "use strict";import{createTurnApi,formatChatDateTime,handoffSettledIds,messagePlainText}from"@webority/chat-core";import{Avatar,Button,MessageBubble,MessageList,Text,useReducedMotion,useTheme}from"@webority/mobile-ui";import{createElement,memo,useEffect,useMemo,useRef}from"react";import{AccessibilityInfo,Platform,View}from"react-native";import{AgentByline}from"./AgentByline.js";import{ChatEntrance}from"./ChatEntrance.js";import{ChatMessageActions}from"./ChatMessageActions.js";import{defaultOpenTarget,focusForAccessibility,messageSignature}from"./chatShared.js";import{ChatLoader}from"./loaders/ChatLoader.js";import{ReplyRing}from"./loaders/ReplyRing.js";import{TypingPill}from"./loaders/TypingPill.js";import{defaultRenderers}from"./renderers/index.js";import{jsx as _jsx,jsxs as _jsxs}from"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");function isKind(e,t){return e.kind===t}const kindWrappers=new WeakMap;function forKind(e,t){const s=kindWrappers.get(t)??new Map,a=s.get(e);if(a)return a;function KindEntry(s){if(!isKind(s.part,e))throw new Error(`renderer for ${e} received a ${s.part.kind} part`);return createElement(t,{part:s.part,message:s.message,turn:s.turn,pickAttachments:s.pickAttachments})}return s.set(e,KindEntry),kindWrappers.set(t,s),KindEntry}const defaults=defaultRenderers;function entryFor(e,t){return forKind(e,t??defaults[e])}function resolveRenderers(e){return{Text:entryFor("Text",e?.Text),Sources:entryFor("Sources",e?.Sources),QuickReplies:entryFor("QuickReplies",e?.QuickReplies),InputRequest:entryFor("InputRequest",e?.InputRequest),Action:entryFor("Action",e?.Action),Notice:entryFor("Notice",e?.Notice),Table:entryFor("Table",e?.Table),Chart:entryFor("Chart",e?.Chart),Figures:entryFor("Figures",e?.Figures),RecordCard:entryFor("RecordCard",e?.RecordCard),Image:entryFor("Image",e?.Image),File:entryFor("File",e?.File),Ticket:entryFor("Ticket",e?.Ticket),Handoff:entryFor("Handoff",e?.Handoff),VoiceClip:entryFor("VoiceClip",e?.VoiceClip)}}const renderPart=(e,t,s,a,r,i)=>{const n=e[t.kind];return createElement(n,{key:i,part:t,message:s,turn:a,pickAttachments:r})},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:r,groupPosition:i,isLast:n,isLastVisitor:o,pickAttachments:l,onOpenAttachment:d,onOpenTarget:c,onNavigate:u,openTicket:p,handoffHosts:g,resolveLink:m,focusComposer:h,byline:f,avatar:y,replyAvatars:x,avatarStart:T,expressive:k,reduced:v,sourceRows:A,testID:b}){const j=useTheme(),w=Object.assign(createTurnApi(e.session,{messageId:t.id,labels:s,openAttachment:d,openTarget:c??defaultOpenTarget,onNavigate:u??e.onNavigate,openTicket:p,handoffHosts:g,openCitation:e=>{return t=String(e),void focusForAccessibility(A.current.get(t));var t}}),{resolveLink:m,focusComposer:h,registerSourceRow:(e,t)=>{t?A.current.set(e,t):A.current.delete(e)}});let _=0;const nextSlot=()=>(_+=1,_),R=_jsx(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=_jsxs(View,{style:{gap:j.space.xs},children:[e.map(e=>renderPart(a,e,t,w,l,`${t.id}-file-${nextSlot()}`)),R]});return _jsx(MessageBubble,{side:"mine",text:joinedText(t.parts),labels:{you:""},groupPosition:i,footer:s,testID:b})}const M="Agent"===t.author.kind,I=t.author.displayName||s.agent,S=(r?r(t):t.parts).map(e=>Array.isArray(e)?_jsx(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:j.space.xs},children:e.map(e=>renderPart(a,e,t,w,l,`${t.id}-part-${nextSlot()}`))},`${t.id}-group-${nextSlot()}`):renderPart(a,e,t,w,l,`${t.id}-item-${nextSlot()}`)),C=M&&f?_jsx(AgentByline,{author:t.author,labels:s,showAvatar:x},`${t.id}-byline`):null,N=C?[C,...S]:S,P=messagePlainText(t.parts),V=_jsx(MessageBubble,{side:"theirs",...M?{}:{author:t.author.displayName||(e.profile?.assistant.name??s.assistant)},text:M?`${s.agentSays(I)} ${P}`:P,streaming:t.streaming,groupPosition:i,footer:R,testID:b,children:N});if(!x||!y||"Assistant"!==t.author.kind)return V;const F=t.author.displayName||(e.profile?.assistant.name??s.assistant);return _jsxs(View,{style:{flexDirection:"row",alignItems:"flex-end",gap:j.space.xs},children:[_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:T?void 0:{opacity:0},children:_jsx(ReplyRing,{active:k&&t.streaming&&T,reduced:v,children:_jsx(Avatar,{size:"xs",name:F,...T?{source:{uri:y}}:{}})})}),_jsx(View,{style:{flex:1,minWidth:0},children:V})]})}const ThreadMessage=memo(ThreadMessageView,sameMessage),TYPING_ORB_MARK=14,TYPING_ASSISTANT_MARK=8,TypingMark=({size:e})=>{const t=useTheme();return _jsx(View,{style:{width:e,height:e,borderRadius:t.radius.pill,backgroundColor:t.colors.primary}})},TYPING_DOT=6,TypingDots=()=>{const e=useTheme();return _jsx(View,{style:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},children:[0,1,2].map(t=>_jsx(View,{style:{width:6,height:6,borderRadius:3,backgroundColor:e.colors["text-muted"]}},t))})},TurnGap=()=>{const e=useTheme();return _jsx(View,{style:{height:e.space.lg}})},followNew=()=>!0;export function ChatThread({chat:e,labels:t,renderers:s,layoutParts:a,loader:r="Steps",motion:i="On",avatar:n,replyAvatars:o=!0,expressive:l=!1,pickAttachments:d,onOpenAttachment:c,onOpenTarget:u,onNavigate:p,openTicket:g,handoffHosts:m,resolveLink:h,focusComposer:f,keyboardAware:y,keyboardOffset:x,empty:T,style:k,testID:v="chat-thread"}){const A=useTheme(),b=useReducedMotion(),j="Reduced"===i||b,w=useMemo(()=>resolveRenderers(s),[s]),_=e.messages[0],R=e.greeting??"",M=useMemo(()=>""!==R&&void 0!==_&&MINE.has(_.author.kind)?{..._,id:"greeting",author:{..._.author,kind:"Assistant",displayName:null,avatarUrl:null},parts:[{kind:"Text",text:R}],stored:!1,streaming:!1,restored:!1,rating:null}:null,[R,_]),I=useMemo(()=>{const t=e.messages.filter(e=>!(e.streaming&&0===e.parts.length)).reverse();return M?[...t,M]:t},[e.messages,M]),S=e.messages[e.messages.length-1]?.id,C=useRef(new Map),N=useRef(null);useEffect(()=>{if(null!==N.current)for(const s of e.messages){if(MINE.has(s.author.kind)||s.streaming||s.restored||N.current.has(s.id))continue;if("Agent"===s.author.kind&&!s.stored)continue;N.current.add(s.id);const e=messagePlainText(s.parts);""!==e&&AccessibilityInfo.announceForAccessibility("Agent"===s.author.kind?`${t.agentSays(s.author.displayName||t.agent)} ${e}`:e)}else N.current=new Set(e.messages.map(e=>e.id))},[e.messages,t]);const P=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]),V=useMemo(()=>{const t=new Set;return e.messages.forEach((s,a)=>{if("Agent"!==s.author.kind)return;const r=e.messages[a-1];"Agent"===r?.author.kind&&(r.author.displayName||"")===(s.author.displayName||"")||t.add(s.id)}),t},[e.messages]),F=useMemo(()=>{const t=new Set,s=e.messages.filter(e=>!(e.streaming&&0===e.parts.length));return M&&t.add(M.id),s.forEach((e,a)=>{"Assistant"===e.author.kind&&"Assistant"!==s[a-1]?.author.kind&&t.add(e.id)}),t},[e.messages,M]),L=useMemo(()=>handoffSettledIds(e.messages),[e.messages]),$=e.turnError,D="daily_limit"===$?.code,E=null!==$&&/feature_off$/.test($.code),O=D&&$?.resetsDateTimeUtc?` ${t.dailyLimitRefresh(formatChatDateTime($.resetsDateTimeUtc))}`:"",H=e.streaming||null===$&&!e.stopped?null:_jsxs(View,{style:{gap:A.space.xs},testID:`${v}-error`,children:[_jsx(Text,null!==$?{variant:"bodySmall",color:"danger",accessibilityRole:D?void 0:"alert",accessibilityLiveRegion:D?"polite":void 0,children:`${$.message}${O}`}:{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:t.stopped}),!e.features.Retry||D||E?null:_jsx(View,{style:{flexDirection:"row"},children:_jsx(Button,{label:t.retry,variant:"link",size:"sm",onPress:()=>{e.retry()},testID:`${v}-retry`})})]}),K=e.thinking&&null!==e.profile?_jsx(ChatLoader,{style:r,steps:e.steps,phrases:e.profile.experience.pacing.thinkingPhrases,intervalMs:e.profile.experience.pacing.phraseIntervalMs,announce:t.preparingAnswer(e.profile.assistant.name),motion:i}):null,B=!0===e.pending?.typing?_jsx(TypingPill,{motion:i,mark:_jsx(ReplyRing,{active:l,reduced:j,children:n?_jsx(Avatar,{size:"xs",name:e.profile?.assistant.name??t.panelTitle,source:{uri:n}}):_jsx(TypingMark,{size:"Orb"===r?14:8})})}):null,W=null!==e.agentTyping&&"WithAgent"===e.conversationState?_jsxs(View,{style:{gap:A.space.xs,alignSelf:"flex-start"},children:[_jsx(TypingPill,{motion:i,mark:_jsx(TypingDots,{})}),_jsx(Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:t.agentTyping(e.agentTyping.displayName||t.agent)})]}):null,z=B||K||H||W?_jsxs(View,{style:{gap:A.space.sm},children:[B,K,W,H]}):void 0,G=_jsx(MessageList,{messages:I,keyExtractor:e=>e.id,renderMessage:({item:s,groupPosition:r})=>_jsxs(View,{role:"listitem",children:[MINE.has(s.author.kind)?_jsx(Text,{style:visuallyHidden,children:`${t.you}: `}):null,_jsx(ChatEntrance,{animate:!s.restored,children:_jsx(ThreadMessage,{chat:e,message:s,signature:messageSignature(s),labels:t,all:w,layoutParts:a,groupPosition:r,isLast:s.id===S,isLastVisitor:s.id===P,handoffSettled:L.has(s.id),thinking:e.thinking,streaming:e.streaming,pickAttachments:d,onOpenAttachment:c,onOpenTarget:u,onNavigate:p,openTicket:g,handoffHosts:m,resolveLink:h,focusComposer:f,byline:V.has(s.id),avatar:n,replyAvatars:o,avatarStart:F.has(s.id),expressive:l,reduced:j,sourceRows:C,testID:`${v}-${s.id}`})})]}),getAuthorKey:e=>e.author.kind,getDate:e=>e.createdDateTimeUtc,followNew:followNew,typing:z,empty:T,ItemSeparatorComponent:TurnGap,...void 0===y?{}:{keyboardAware:y},...void 0===x?{}:{keyboardOffset:x},accessibilityLabel:t.thread,accessibilityRole:"list",style:k,testID:v});return"web"!==Platform.OS?G:_jsx(View,{role:"log","aria-live":"polite","aria-label":t.thread,style:{flex:1},children:G})}
1
+ "use strict";import{createTurnApi,formatChatDateTime,handoffSettledIds,messagePlainText}from"@webority/chat-core";import{Avatar,Button,MessageBubble,MessageList,Text,useReducedMotion,useTheme}from"@webority/mobile-ui";import{createElement,memo,useEffect,useMemo,useRef}from"react";import{AccessibilityInfo,Platform,View}from"react-native";import{AgentByline}from"./AgentByline.js";import{ChatEntrance}from"./ChatEntrance.js";import{ChatMessageActions}from"./ChatMessageActions.js";import{defaultOpenTarget,focusForAccessibility,messageSignature}from"./chatShared.js";import{ChatLoader}from"./loaders/ChatLoader.js";import{ReplyRing}from"./loaders/ReplyRing.js";import{TypingPill}from"./loaders/TypingPill.js";import{defaultRenderers}from"./renderers/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const MINE=new Set(["Visitor","Customer"]),visuallyHidden={position:"absolute",left:-1e4,width:1,height:1,overflow:"hidden"},spokenAuthor=(e,t,s)=>MINE.has(e.author.kind)?t.you:e.author.displayName?e.author.displayName:"Agent"===e.author.kind?t.agent:s??t.assistant,joinedText=e=>e.filter(e=>"Text"===e.kind).map(e=>e.text).join("\n\n");function isKind(e,t){return e.kind===t}const kindWrappers=new WeakMap;function forKind(e,t){const s=kindWrappers.get(t)??new Map,a=s.get(e);if(a)return a;function KindEntry(s){if(!isKind(s.part,e))throw new Error(`renderer for ${e} received a ${s.part.kind} part`);return createElement(t,{part:s.part,message:s.message,turn:s.turn,pickAttachments:s.pickAttachments})}return s.set(e,KindEntry),kindWrappers.set(t,s),KindEntry}const defaults=defaultRenderers;function entryFor(e,t){return forKind(e,t??defaults[e])}function resolveRenderers(e){return{Text:entryFor("Text",e?.Text),Sources:entryFor("Sources",e?.Sources),QuickReplies:entryFor("QuickReplies",e?.QuickReplies),InputRequest:entryFor("InputRequest",e?.InputRequest),Action:entryFor("Action",e?.Action),Notice:entryFor("Notice",e?.Notice),Table:entryFor("Table",e?.Table),Chart:entryFor("Chart",e?.Chart),Figures:entryFor("Figures",e?.Figures),RecordCard:entryFor("RecordCard",e?.RecordCard),Image:entryFor("Image",e?.Image),File:entryFor("File",e?.File),Ticket:entryFor("Ticket",e?.Ticket),Handoff:entryFor("Handoff",e?.Handoff),VoiceClip:entryFor("VoiceClip",e?.VoiceClip)}}const renderPart=(e,t,s,a,r,i)=>{const n=e[t.kind];return createElement(n,{key:i,part:t,message:s,turn:a,pickAttachments:r})},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:r,groupPosition:i,isLast:n,isLastVisitor:o,pickAttachments:l,onOpenAttachment:d,onOpenTarget:c,onNavigate:u,openTicket:p,handoffHosts:g,resolveLink:m,focusComposer:h,byline:f,avatar:y,replyAvatars:x,avatarStart:k,expressive:T,reduced:v,sourceRows:A,testID:b}){const w=useTheme(),j=Object.assign(createTurnApi(e.session,{messageId:t.id,labels:s,openAttachment:d,openTarget:c??defaultOpenTarget,onNavigate:u??e.onNavigate,openTicket:p,handoffHosts:g,openCitation:e=>{return t=String(e),void focusForAccessibility(A.current.get(t));var t}}),{resolveLink:m,focusComposer:h,registerSourceRow:(e,t)=>{t?A.current.set(e,t):A.current.delete(e)}});let _=0;const nextSlot=()=>(_+=1,_),R=_jsx(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||"VoiceClip"===e.kind),s=_jsxs(View,{style:{gap:w.space.xs},children:[e.map(e=>renderPart(a,e,t,j,l,`${t.id}-file-${nextSlot()}`)),R]});return _jsx(MessageBubble,{side:"mine",text:joinedText(t.parts),labels:{you:""},groupPosition:i,footer:s,testID:b})}const M="Agent"===t.author.kind,N=t.author.displayName||s.agent,S=(r?r(t):t.parts).map(e=>Array.isArray(e)?_jsx(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:w.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()}`)),C=M&&f?_jsx(AgentByline,{author:t.author,labels:s,showAvatar:x},`${t.id}-byline`):null,I=C?[C,...S]:S,P=messagePlainText(t.parts),V=_jsx(MessageBubble,{side:"theirs",...M?{}:{author:`${t.author.displayName||(e.profile?.assistant.name??s.assistant)}:`},text:M?`${s.agentSays(N)} ${P}`:P,streaming:t.streaming,groupPosition:i,footer:R,testID:b,children:I});if(!x||!y||"Assistant"!==t.author.kind)return V;const F=t.author.displayName||(e.profile?.assistant.name??s.assistant);return _jsxs(View,{style:{flexDirection:"row",alignItems:"flex-end",gap:w.space.xs},children:[_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:k?void 0:{opacity:0},children:_jsx(ReplyRing,{active:T&&t.streaming&&k,reduced:v,children:_jsx(Avatar,{size:"xs",name:F,...k?{source:{uri:y}}:{}})})}),_jsx(View,{style:{flex:1,minWidth:0},children:V})]})}const ThreadMessage=memo(ThreadMessageView,sameMessage),TYPING_ORB_MARK=14,TYPING_ASSISTANT_MARK=8,TypingMark=({size:e})=>{const t=useTheme();return _jsx(View,{style:{width:e,height:e,borderRadius:t.radius.pill,backgroundColor:t.colors.primary}})},TYPING_DOT=6,TypingDots=()=>{const e=useTheme();return _jsx(View,{style:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},children:[0,1,2].map(t=>_jsx(View,{style:{width:6,height:6,borderRadius:3,backgroundColor:e.colors["text-muted"]}},t))})},TurnGap=()=>{const e=useTheme();return _jsx(View,{style:{height:e.space.lg}})},followNew=()=>!0;export function ChatThread({chat:e,labels:t,renderers:s,layoutParts:a,loader:r="Steps",motion:i="On",avatar:n,replyAvatars:o=!0,expressive:l=!1,pickAttachments:d,onOpenAttachment:c,onOpenTarget:u,onNavigate:p,openTicket:g,handoffHosts:m,resolveLink:h,focusComposer:f,keyboardAware:y,keyboardOffset:x,empty:k,style:T,testID:v="chat-thread"}){const A=useTheme(),b=useReducedMotion(),w="Reduced"===i||b,j=useMemo(()=>resolveRenderers(s),[s]),_=e.messages[0],R=e.greeting??"",M=useMemo(()=>""!==R&&void 0!==_&&MINE.has(_.author.kind)?{..._,id:"greeting",author:{..._.author,kind:"Assistant",displayName:null,avatarUrl:null},parts:[{kind:"Text",text:R}],stored:!1,streaming:!1,restored:!1,rating:null}:null,[R,_]),N=useMemo(()=>{const t=e.messages.filter(e=>!(e.streaming&&0===e.parts.length)).reverse();return M?[...t,M]:t},[e.messages,M]),S=e.messages[e.messages.length-1]?.id,C=useRef(new Map),I=useRef(null);useEffect(()=>{if(null!==I.current)for(const s of e.messages){if(MINE.has(s.author.kind)||s.streaming||s.restored||I.current.has(s.id))continue;if("Agent"===s.author.kind&&!s.stored)continue;I.current.add(s.id);const e=messagePlainText(s.parts);""!==e&&AccessibilityInfo.announceForAccessibility("Agent"===s.author.kind?`${t.agentSays(s.author.displayName||t.agent)} ${e}`:e)}else I.current=new Set(e.messages.map(e=>e.id))},[e.messages,t]);const P=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]),V=useMemo(()=>{const t=new Set;return e.messages.forEach((s,a)=>{if("Agent"!==s.author.kind)return;const r=e.messages[a-1];"Agent"===r?.author.kind&&(r.author.displayName||"")===(s.author.displayName||"")||t.add(s.id)}),t},[e.messages]),F=useMemo(()=>{const t=new Set,s=e.messages.filter(e=>!(e.streaming&&0===e.parts.length));return M&&t.add(M.id),s.forEach((e,a)=>{"Assistant"===e.author.kind&&"Assistant"!==s[a-1]?.author.kind&&t.add(e.id)}),t},[e.messages,M]),L=useMemo(()=>handoffSettledIds(e.messages),[e.messages]),$=e.turnError,D="daily_limit"===$?.code,E=null!==$&&/feature_off$/.test($.code),O=D&&$?.resetsDateTimeUtc?` ${t.dailyLimitRefresh(formatChatDateTime($.resetsDateTimeUtc))}`:"",H=e.streaming||null===$&&!e.stopped?null:_jsxs(View,{style:{gap:A.space.xs},testID:`${v}-error`,children:[_jsx(Text,null!==$?{variant:"bodySmall",color:"danger",accessibilityRole:D?void 0:"alert",accessibilityLiveRegion:D?"polite":void 0,children:`${$.message}${O}`}:{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:t.stopped}),!e.features.Retry||D||E?null:_jsx(View,{style:{flexDirection:"row"},children:_jsx(Button,{label:t.retry,variant:"link",size:"sm",onPress:()=>{e.retry()},testID:`${v}-retry`})})]}),K=e.thinking&&null!==e.profile?_jsx(ChatLoader,{style:r,steps:e.steps,phrases:e.profile.experience.pacing.thinkingPhrases,intervalMs:e.profile.experience.pacing.phraseIntervalMs,announce:t.preparingAnswer(e.profile.assistant.name),motion:i}):null,B=!0===e.pending?.typing?_jsx(TypingPill,{motion:i,mark:_jsx(ReplyRing,{active:l,reduced:w,children:n?_jsx(Avatar,{size:"xs",name:e.profile?.assistant.name??t.panelTitle,source:{uri:n}}):_jsx(TypingMark,{size:"Orb"===r?14:8})})}):null,W=null!==e.agentTyping&&"WithAgent"===e.conversationState?_jsxs(View,{style:{gap:A.space.xs,alignSelf:"flex-start"},children:[_jsx(TypingPill,{motion:i,mark:_jsx(TypingDots,{})}),_jsx(Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:t.agentTyping(e.agentTyping.displayName||t.agent)})]}):null,z=B||K||H||W?_jsxs(View,{style:{gap:A.space.sm},children:[B,K,W,H]}):void 0,G=_jsx(MessageList,{messages:N,keyExtractor:e=>e.id,renderMessage:({item:s,groupPosition:r})=>_jsxs(View,{role:"listitem",children:[_jsx(Text,{style:visuallyHidden,children:`${spokenAuthor(s,t,e.profile?.assistant.name)}: `}),_jsx(ChatEntrance,{animate:!s.restored,children:_jsx(ThreadMessage,{chat:e,message:s,signature:messageSignature(s),labels:t,all:j,layoutParts:a,groupPosition:r,isLast:s.id===S,isLastVisitor:s.id===P,handoffSettled:L.has(s.id),thinking:e.thinking,streaming:e.streaming,pickAttachments:d,onOpenAttachment:c,onOpenTarget:u,onNavigate:p,openTicket:g,handoffHosts:m,resolveLink:h,focusComposer:f,byline:V.has(s.id),avatar:n,replyAvatars:o,avatarStart:F.has(s.id),expressive:l,reduced:w,sourceRows:C,testID:`${v}-${s.id}`})})]}),getAuthorKey:e=>e.author.kind,getDate:e=>e.createdDateTimeUtc,followNew:followNew,typing:z,empty:k,ItemSeparatorComponent:TurnGap,...void 0===y?{}:{keyboardAware:y},...void 0===x?{}:{keyboardOffset:x},..."web"===Platform.OS?{}:{accessibilityLabel:t.thread},accessibilityRole:"list",style:T,testID:v});return"web"!==Platform.OS?G:_jsx(View,{role:"log","aria-live":"polite","aria-label":t.thread,style:{flex:1},children:G})}
@@ -1 +1 @@
1
- "use strict";import{Logger}from"@webority/mobile-core";import{AccessibilityInfo,Linking,Platform}from"react-native";export function focusForAccessibility(t){null!=t&&("web"!==Platform.OS?AccessibilityInfo.sendAccessibilityEvent(t,"focus"):"focus"in t&&"function"==typeof t.focus&&t.focus())}export function messageSignature(t){let o=0;for(const e of t.parts)"Text"===e.kind&&(o+=e.text.length);return`${t.id}|${t.parts.length}|${o}`}const ABSOLUTE_WEB_URL=/^https?:\/\//i;export function openExternalUrl(t){Linking.openURL(t).catch(t=>{throw Logger.error("[chat] link did not open",t),t})}export function defaultOpenTarget(t){ABSOLUTE_WEB_URL.test(t)&&openExternalUrl(t)}export const WEB_STRONG="web"===Platform.OS?{role:"strong"}:{};
1
+ "use strict";import{Logger}from"@webority/mobile-core";import{AccessibilityInfo,Linking,Platform}from"react-native";export function focusForAccessibility(t){null!=t&&("web"!==Platform.OS?AccessibilityInfo.sendAccessibilityEvent(t,"focus"):"focus"in t&&"function"==typeof t.focus&&t.focus())}export function messageSignature(t){let o=0;for(const e of t.parts)"Text"===e.kind&&(o+=e.text.length);return`${t.id}|${t.parts.length}|${o}`}const ABSOLUTE_WEB_URL=/^https?:\/\//i;export function openExternalUrl(t){Linking.openURL(t).catch(t=>{throw Logger.error("[chat] link did not open",t),t})}export function defaultOpenTarget(t){ABSOLUTE_WEB_URL.test(t)&&openExternalUrl(t)}export const WEB_STRONG="web"===Platform.OS?{role:"strong"}:{};export const webProps=t=>"web"===Platform.OS?t:{};
@@ -1 +1 @@
1
- "use strict";import{useReducedMotion,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef}from"react";import{Animated,StyleSheet,View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DOT=6,LIFT_PX=4,CYCLE_MS=1200,HALF_MS=300,STEP_MS=140,STILL_OPACITY=[1,.65,.3],DOT_INDEXES=[0,1,2];export function TypingPill({motion:e,mark:t}){const i=useTheme(),s=useMemo(()=>buildStyles(i),[i]),o=useReducedMotion(),r="Reduced"===e||o;return _jsxs(View,{style:s.pill,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[t,_jsx(View,{style:s.dots,children:DOT_INDEXES.map(e=>_jsx(Dot,{index:e,reduced:r,color:i.colors["text-subtle"],size:6},e))})]})}const Dot=({index:e,reduced:t,color:i,size:s})=>{const o=useRef(new Animated.Value(0)).current;useEffect(()=>{if(t)return void o.setValue(0);const i=Animated.loop(Animated.sequence([Animated.delay(140*e),Animated.timing(o,{toValue:1,duration:300,useNativeDriver:!0}),Animated.timing(o,{toValue:0,duration:300,useNativeDriver:!0}),Animated.delay(600-140*e)]));return i.start(),()=>i.stop()},[o,e,t]);const r={width:s,height:s,borderRadius:s/2,backgroundColor:i};if(t)return _jsx(View,{style:[r,{opacity:STILL_OPACITY[e]}]});const n=o.interpolate({inputRange:[0,1],outputRange:[0,-4]});return _jsx(Animated.View,{style:[r,{transform:[{translateY:n}]}]})},buildStyles=e=>StyleSheet.create({pill:{flexDirection:"row",alignItems:"center",alignSelf:"flex-start",gap:e.space.sm,backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.pill,paddingHorizontal:e.space.md,paddingVertical:e.space.sm},dots:{flexDirection:"row",alignItems:"center",gap:e.space.xs}});
1
+ "use strict";import{useReducedMotion,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef}from"react";import{Animated,StyleSheet,View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DOT=6,LIFT_PX=4,CYCLE_MS=1200,HALF_MS=300,STEP_MS=140,STILL_OPACITY=[1,.65,.3],DOT_INDEXES=[0,1,2];export function TypingPill({motion:e,mark:t}){const i=useTheme(),s=useMemo(()=>buildStyles(i),[i]),o=useReducedMotion(),r="Reduced"===e||o;return _jsxs(View,{style:s.pill,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",testID:"chat-typing-pill",children:[t,_jsx(View,{style:s.dots,children:DOT_INDEXES.map(e=>_jsx(Dot,{index:e,reduced:r,color:i.colors["text-subtle"],size:6},e))})]})}const Dot=({index:e,reduced:t,color:i,size:s})=>{const o=useRef(new Animated.Value(0)).current;useEffect(()=>{if(t)return void o.setValue(0);const i=Animated.loop(Animated.sequence([Animated.delay(140*e),Animated.timing(o,{toValue:1,duration:300,useNativeDriver:!0}),Animated.timing(o,{toValue:0,duration:300,useNativeDriver:!0}),Animated.delay(600-140*e)]));return i.start(),()=>i.stop()},[o,e,t]);const r={width:s,height:s,borderRadius:s/2,backgroundColor:i};if(t)return _jsx(View,{style:[r,{opacity:STILL_OPACITY[e]}]});const n=o.interpolate({inputRange:[0,1],outputRange:[0,-4]});return _jsx(Animated.View,{style:[r,{transform:[{translateY:n}]}]})},buildStyles=e=>StyleSheet.create({pill:{flexDirection:"row",alignItems:"center",alignSelf:"flex-start",gap:e.space.sm,backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.pill,paddingHorizontal:e.space.md,paddingVertical:e.space.sm},dots:{flexDirection:"row",alignItems:"center",gap:e.space.xs}});
@@ -1 +1 @@
1
- "use strict";import{ChatApiError,formatChatDate}from"@webority/chat-core";import{parseInline}from"@webority/markdown-core";import{Logger}from"@webority/mobile-core";import{Button,Card,OptionSheet,Text,useTheme}from"@webority/mobile-ui";import{useState}from"react";import{Text as RNText,View}from"react-native";import{openExternalUrl}from"../chatShared.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"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 n=inlineNodes(e.children,t);return SAFE_LINK.test(e.href)?_jsx(RNText,{accessibilityRole:"link",style:{color:t.colors.link,textDecorationLine:"underline"},onPress:()=>openExternalUrl(e.href),children:n},e.key):_jsx(RNText,{children:n},e.key)}if("image"===e.type)return null;const n="strong"===e.type?{fontWeight:t.weight.bold}:"em"===e.type?{fontStyle:"italic"}:{textDecorationLine:"line-through"};return _jsx(RNText,{style:n,children:inlineNodes(e.children,t)},e.key)}),splitLine=e=>{const t=e.indexOf(": ");return t<0?{term:e,detail:null}:{term:e.slice(0,t),detail:e.slice(t+2)}},statusLine=(e,t)=>{switch(e.state){case"Confirmed":return t.actionConfirmed;case"Done":return e.decidedDateTimeUtc?`${t.actionDone} ${formatChatDate(e.decidedDateTimeUtc)}`:t.actionDone;case"Rejected":return t.actionRejected;case"Expired":return t.actionExpired;case"Failed":return t.actionFailed;case"Repeat":return e.decidedDateTimeUtc?t.actionRepeat(formatChatDate(e.decidedDateTimeUtc)):t.actionDone;case"Pending":return""}};function ActionBody({part:e,turn:t}){const n=useTheme(),{labels:i,features:a}=t,[r,o]=useState(null),[l,s]=useState(""),[c,d]=useState(!1),run=async(e,t)=>{o(e),s("");try{await t()}catch(t){Logger.error(`[chat] action ${e} failed`,t),s(t instanceof ChatApiError&&""!==t.message?t.message:i.actionFailed),o(null)}},m=(e.editFields??[]).map(e=>({label:e.label,value:e.id})),u=a.LeadRecap&&e.actionKind===LEAD_CAPTURE,p=u&&m.length>0,x=u&&e.confirmLabel||i.actionConfirm,h=u&&e.rejectLabel||i.actionDismiss,f=null!==r;return _jsxs(Card,{variant:"outline",padding:"sm",children:[_jsxs(View,{style:{gap:n.space.sm},children:[_jsx(Text,{variant:"label",children:e.title}),e.lines.map(e=>{if(!u)return _jsx(Text,{variant:"bodySmall",children:e},e);const{term:t,detail:i}=splitLine(e);return _jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:n.space.xs},children:[_jsx(Text,{variant:"label",children:t}),null!==i?_jsx(Text,{variant:"bodySmall",children:i}):null]},e)}),u&&e.consentText?_jsx(Text,{variant:"caption",color:"secondary",children:inlineNodes(parseInline(e.consentText),n)}):null,"Pending"===e.state?_jsxs(_Fragment,{children:[""!==l?_jsx(Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:l}):null,_jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:n.space.sm},children:[_jsx(Button,{label:"confirm"===r?i.actionWorking:x,loading:"confirm"===r,disabled:f,onPress:()=>{run("confirm",()=>t.confirmAction(e.actionId))}}),_jsx(Button,{label:h,variant:"ghost",disabled:f,onPress:()=>{run("reject",()=>t.rejectAction(e.actionId))}})]})]}):_jsx(Text,{variant:"bodySmall",color:"Done"===e.state||"Confirmed"===e.state||"Repeat"===e.state?"success":"secondary",children:statusLine(e,i)}),p?_jsx(Button,{label:i.editSomething,variant:"ghost",disabled:f||"Pending"!==e.state,onPress:()=>d(!0)}):null,e.note?_jsx(Text,{variant:"caption",color:"secondary",children:e.note}):null]}),p?_jsx(OptionSheet,{open:c,onClose:()=>d(!1),title:i.editSomething,options:m,onChange:(e,n)=>{d(!1),t.chooseQuickReply({id:`lead.edit:${String(n.value)}`,label:n.label,action:"Send",target:null,navigateAfterMs:null,icon:null,variant:null})}}):null]})}export function ActionPart({part:e,turn:t}){return _jsx(ActionBody,{part:e,turn:t},e.actionId)}
1
+ "use strict";import{ChatApiError,formatChatDate}from"@webority/chat-core";import{parseInline}from"@webority/markdown-core";import{Logger}from"@webority/mobile-core";import{Button,Card,OptionSheet,Text,useTheme}from"@webority/mobile-ui";import{useState}from"react";import{Text as RNText,View}from"react-native";import{openExternalUrl,WEB_STRONG,webProps}from"../chatShared.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"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 n=inlineNodes(e.children,t);return SAFE_LINK.test(e.href)?_jsx(RNText,{accessibilityRole:"link",style:{color:t.colors.link,textDecorationLine:"underline"},onPress:()=>openExternalUrl(e.href),children:n},e.key):_jsx(RNText,{children:n},e.key)}if("image"===e.type)return null;const n="strong"===e.type?{fontWeight:t.weight.bold}:"em"===e.type?{fontStyle:"italic"}:{textDecorationLine:"line-through"};return _jsx(RNText,{style:n,children:inlineNodes(e.children,t)},e.key)}),splitLine=e=>{const t=e.indexOf(": ");return t<0?{term:e,detail:null}:{term:e.slice(0,t),detail:e.slice(t+2)}},statusLine=(e,t)=>{switch(e.state){case"Confirmed":return t.actionConfirmed;case"Done":return e.decidedDateTimeUtc?`${t.actionDone} ${formatChatDate(e.decidedDateTimeUtc)}`:t.actionDone;case"Rejected":return t.actionRejected;case"Expired":return t.actionExpired;case"Failed":return t.actionFailed;case"Repeat":return e.decidedDateTimeUtc?t.actionRepeat(formatChatDate(e.decidedDateTimeUtc)):t.actionDone;case"Pending":return""}};function ActionBody({part:e,turn:t}){const n=useTheme(),{labels:i,features:r}=t,[a,o]=useState(null),[l,s]=useState(""),[c,d]=useState(!1),run=async(e,t)=>{o(e),s("");try{await t()}catch(t){Logger.error(`[chat] action ${e} failed`,t),s(t instanceof ChatApiError&&""!==t.message?t.message:i.actionFailed),o(null)}},p=(e.editFields??[]).map(e=>({label:e.label,value:e.id})),m=r.LeadRecap&&e.actionKind===LEAD_CAPTURE,u=m&&p.length>0,x=m&&e.confirmLabel||i.actionConfirm,h=m&&e.rejectLabel||i.actionDismiss,f=null!==a;return _jsxs(Card,{variant:"outline",padding:"sm",children:[_jsxs(View,{style:{gap:n.space.sm},children:[_jsx(Text,{variant:"label",...WEB_STRONG,children:e.title}),e.lines.map(e=>{if(!m)return _jsx(Text,{variant:"bodySmall",children:e},e);const{term:t,detail:i}=splitLine(e);return _jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:n.space.xs},children:[_jsx(Text,{variant:"label",...webProps({role:"term"}),children:t}),null!==i?_jsx(Text,{variant:"bodySmall",...webProps({role:"definition"}),children:i}):null]},e)}),m&&e.consentText?_jsx(Text,{variant:"caption",color:"secondary",...webProps({role:"paragraph"}),children:inlineNodes(parseInline(e.consentText),n)}):null,e.note?_jsx(Text,{variant:"caption",color:"secondary",...webProps({role:"paragraph"}),children:e.note}):null,"Pending"===e.state?_jsxs(_Fragment,{children:[""!==l?_jsx(Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:l}):null,_jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:n.space.sm},children:[_jsx(Button,{label:"confirm"===a?i.actionWorking:x,loading:"confirm"===a,disabled:f,onPress:()=>{run("confirm",()=>t.confirmAction(e.actionId))}}),_jsx(Button,{label:h,variant:"ghost",disabled:f,onPress:()=>{run("reject",()=>t.rejectAction(e.actionId))}})]})]}):_jsx(Text,{variant:"bodySmall",color:"Done"===e.state||"Confirmed"===e.state||"Repeat"===e.state?"success":"secondary",...webProps({role:"paragraph"}),children:statusLine(e,i)}),u?_jsx(Button,{label:i.editSomething,variant:"ghost",disabled:f||"Pending"!==e.state,onPress:()=>d(!0)}):null]}),u?_jsx(OptionSheet,{open:c,onClose:()=>d(!1),title:i.editSomething,options:p,onChange:(e,n)=>{d(!1),t.chooseQuickReply({id:`lead.edit:${String(n.value)}`,label:n.label,action:"Send",target:null,navigateAfterMs:null,icon:null,variant:null})}}):null]})}export function ActionPart({part:e,turn:t}){return _jsx(ActionBody,{part:e,turn:t},e.actionId)}
@@ -1 +1 @@
1
- "use strict";import{formatFigure,toFigureText}from"@webority/chat-core";import{formatCompactNumber,formatNumber,formatPercent}from"@webority/mobile-core";import{BarChart,Button,ProgressBar,Sparkline,Text,useTheme}from"@webority/mobile-ui";import{useState}from"react";import{View}from"react-native";import{FigureText,runsToText}from"./FigureText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const TONES=["primary","info","success","warning","danger","neutral"],toneAt=e=>TONES[e%TONES.length]??"primary",MAX_SERIES=8,withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),writeValue=(e,t)=>{const r=0!==e&&Math.abs(e)<.001?runsToText(formatFigure(e)):formatNumber(e,{maximumFractionDigits:2});return t?`${r} ${t}`:r};export function ChartPart({part:e,turn:t}){const r=useTheme(),[a,i]=useState(!1),l="Donut"===e.chartType?e.series.slice(0,1):e.series.slice(0,8);if(l.every(e=>0===e.points.length))return _jsxs(View,{style:{gap:r.space.sm},children:[e.title?_jsx(FigureText,{text:e.title,variant:"label",color:"primary",strong:!0}):null,_jsx(Text,{variant:"bodySmall",color:"secondary",children:t.labels.chartEmpty})]});const{unit:s}=e,o=e.title?toFigureText(e.title):t.labels.chart,n=l.length>1;return _jsxs(View,{accessibilityLabel:o,style:{gap:r.space.sm},children:[e.title?_jsx(FigureText,{text:e.title,variant:"label",color:"primary",strong:!0}):null,_jsx(Button,{label:a?t.labels.chartShowChart:t.labels.chartShowTable,variant:"link",size:"sm",onPress:()=>i(e=>!e)}),withPositions(l).map(({key:i,item:l})=>{const c=toneAt(i),m=toFigureText(l.name)||o,u=l.points;if(0===u.length)return _jsxs(View,{style:{gap:r.space.xs},children:[n?_jsx(Text,{variant:"caption",color:"secondary",children:toFigureText(l.name)}):null,_jsx(Text,{variant:"bodySmall",color:"secondary",children:t.labels.chartEmpty})]},i);const x=u.map(e=>e.value),h=x.reduce((e,t)=>Math.min(e,t)),p=x.reduce((e,t)=>Math.max(e,t)),b=u[0];if(void 0===b)throw new Error("A chart with points has no first point.");const y=u[u.length-1];if(void 0===y)throw new Error("A chart with points has no last point.");let g;if(a)g=_jsx(View,{accessibilityRole:"summary",style:{gap:r.space.xs},children:withPositions(u).map(({key:e,item:t})=>_jsxs(View,{style:{flexDirection:"row",justifyContent:"space-between",gap:r.space.sm},children:[_jsx(Text,{variant:"bodySmall",color:"primary",children:toFigureText(t.label)}),_jsx(Text,{variant:"bodySmall",color:"primary",children:writeValue(t.value,s)})]},e))});else if("Bar"===e.chartType)g=_jsx(BarChart,{data:u.map(e=>({label:toFigureText(e.label),value:e.value})),height:u.length>4?300:240,label:m,formatValue:e=>writeValue(e,s),formatTick:e=>s?`${formatCompactNumber(e)} ${s}`:formatCompactNumber(e),tone:c});else if("Line"===e.chartType)g=_jsxs(View,{style:{gap:r.space.xs},children:[_jsx(Sparkline,{data:x,height:160,fill:!0,tone:c,label:m,formatLabel:e=>writeValue(e,s)}),_jsxs(View,{style:{flexDirection:"row",justifyContent:"space-between"},children:[_jsx(Text,{variant:"caption",color:"tertiary",children:toFigureText(b.label)}),u.length>1?_jsx(Text,{variant:"caption",color:"tertiary",children:toFigureText(y.label)}):null]}),_jsx(Text,{variant:"caption",color:"secondary",children:`${t.labels.chartLow(writeValue(h,s))} ${t.labels.chartHigh(writeValue(p,s))}`})]});else{const e=x.reduce((e,t)=>e+(Number.isFinite(t)&&t>0?t:0),0);g=_jsx(View,{accessibilityRole:"list",style:{gap:r.space.sm},children:withPositions(u).map(({key:t,item:r})=>{const a=e>0&&Number.isFinite(r.value)&&r.value>0?r.value/e:0;return _jsx(ProgressBar,{progress:a,height:8,tone:toneAt(t),label:_jsx(FigureText,{text:r.label,variant:"bodySmall"}),valueLabel:`${writeValue(r.value,s)} (${formatPercent(a,{maximumFractionDigits:0})})`},t)})})}return _jsxs(View,{style:{gap:r.space.xs},children:[n?_jsx(Text,{variant:"caption",color:"secondary",children:toFigureText(l.name)}):null,g]},i)})]})}
1
+ "use strict";import{formatFigure,toFigureText}from"@webority/chat-core";import{formatCompactNumber,formatNumber,formatPercent}from"@webority/mobile-core";import{BarChart,Button,ProgressBar,Sparkline,Text,useTheme}from"@webority/mobile-ui";import{useState}from"react";import{View}from"react-native";import{webProps}from"../chatShared.js";import{FigureText,runsToText}from"./FigureText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const TONES=["primary","info","success","warning","danger","neutral"],toneAt=e=>TONES[e%TONES.length]??"primary",MAX_SERIES=8,withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),writeValue=(e,t)=>{const r=0!==e&&Math.abs(e)<.001?runsToText(formatFigure(e)):formatNumber(e,{maximumFractionDigits:2});return t?`${r} ${t}`:r};export function ChartPart({part:e,turn:t}){const r=useTheme(),[a,i]=useState(!1),s="Donut"===e.chartType?e.series.slice(0,1):e.series.slice(0,8);if(s.every(e=>0===e.points.length))return _jsxs(View,{style:{gap:r.space.sm},children:[e.title?_jsx(FigureText,{text:e.title,variant:"label",color:"primary",strong:!0}):null,_jsx(Text,{variant:"bodySmall",color:"secondary",children:t.labels.chartEmpty})]});const{unit:l}=e,o=e.title?toFigureText(e.title):t.labels.chart,n=s.length>1;return _jsxs(View,{accessibilityLabel:o,style:{gap:r.space.sm},...webProps({role:"figure"}),children:[e.title?_jsx(FigureText,{text:e.title,variant:"label",color:"primary",strong:!0}):null,_jsx(Button,{label:a?t.labels.chartShowChart:t.labels.chartShowTable,variant:"link",size:"sm",onPress:()=>i(e=>!e)}),withPositions(s).map(({key:i,item:s})=>{const c=toneAt(i),m=toFigureText(s.name)||o,u=s.points;if(0===u.length)return _jsxs(View,{style:{gap:r.space.xs},children:[n?_jsx(Text,{variant:"caption",color:"secondary",children:toFigureText(s.name)}):null,_jsx(Text,{variant:"bodySmall",color:"secondary",children:t.labels.chartEmpty})]},i);const h=u.map(e=>e.value),x=h.reduce((e,t)=>Math.min(e,t)),p=h.reduce((e,t)=>Math.max(e,t)),b=u[0];if(void 0===b)throw new Error("A chart with points has no first point.");const g=u[u.length-1];if(void 0===g)throw new Error("A chart with points has no last point.");let y;if(a)y=_jsx(View,{accessibilityRole:"summary",style:{gap:r.space.xs},children:withPositions(u).map(({key:e,item:t})=>_jsxs(View,{style:{flexDirection:"row",justifyContent:"space-between",gap:r.space.sm},children:[_jsx(Text,{variant:"bodySmall",color:"primary",children:toFigureText(t.label)}),_jsx(Text,{variant:"bodySmall",color:"primary",children:writeValue(t.value,l)})]},e))});else if("Bar"===e.chartType)y=_jsx(BarChart,{data:u.map(e=>({label:toFigureText(e.label),value:e.value})),height:u.length>4?300:240,label:m,formatValue:e=>writeValue(e,l),formatTick:e=>l?`${formatCompactNumber(e)} ${l}`:formatCompactNumber(e),tone:c});else if("Line"===e.chartType)y=_jsxs(View,{style:{gap:r.space.xs},children:[_jsx(Sparkline,{data:h,height:160,fill:!0,tone:c,label:m,formatLabel:e=>writeValue(e,l)}),_jsxs(View,{style:{flexDirection:"row",justifyContent:"space-between"},children:[_jsx(Text,{variant:"caption",color:"tertiary",children:toFigureText(b.label)}),u.length>1?_jsx(Text,{variant:"caption",color:"tertiary",children:toFigureText(g.label)}):null]}),_jsx(Text,{variant:"caption",color:"secondary",children:`${t.labels.chartLow(writeValue(x,l))} ${t.labels.chartHigh(writeValue(p,l))}`})]});else{const e=h.reduce((e,t)=>e+(Number.isFinite(t)&&t>0?t:0),0);y=_jsx(View,{accessibilityRole:"list",style:{gap:r.space.sm},children:withPositions(u).map(({key:t,item:r})=>{const a=e>0&&Number.isFinite(r.value)&&r.value>0?r.value/e:0;return _jsx(ProgressBar,{progress:a,height:8,tone:toneAt(t),label:_jsx(FigureText,{text:r.label,variant:"bodySmall"}),valueLabel:`${writeValue(r.value,l)} (${formatPercent(a,{maximumFractionDigits:0})})`},t)})})}return _jsxs(View,{style:{gap:r.space.xs},children:[n?_jsx(Text,{variant:"caption",color:"secondary",children:toFigureText(s.name)}):null,y]},i)})]})}
@@ -1 +1 @@
1
- "use strict";import{toFigureRuns}from"@webority/chat-core";import{Text,useTheme}from"@webority/mobile-ui";import{Fragment,useMemo}from"react";import{Text as RNText,View}from"react-native";import{jsx as _jsx}from"react/jsx-runtime";const sizeStepOf=e=>"caption"===e?"xs":"bodySmall"===e||"label"===e?"sm":"title"===e?"lg":"base",inkFor=(e,t)=>"secondary"===t?e.colors["text-muted"]:"tertiary"===t?e.colors["text-subtle"]:"success"===t||"warning"===t||"danger"===t||"info"===t?e.colors[`${t}-text`]:e.colors["text-body"];export function runsToText(e){return e.map(e=>e.text).join("")}const withOffsets=e=>e.reduce((e,t)=>{const r=e[e.length-1],n=r?r.offset+r.run.text.length:0;return e.push({offset:n,run:t}),e},[]);function runNode(e,t,r){if("text"===e.kind)return e.text;const n="sub"===e.kind?Math.round(.4*t):-Math.round(.45*t),o=Math.round(.75*t);return _jsx(View,{style:{transform:[{translateY:n}]},children:_jsx(RNText,{style:{fontSize:o,lineHeight:o,includeFontPadding:!1,color:r},children:e.text})})}export function FigureRuns({runs:e,variant:t="bodySmall",color:r,strong:n=!1,numberOfLines:o,accessibilityLabel:i,testID:s,heading:u}){const a=useTheme(),c=a.text[sizeStepOf(t)].size,l=inkFor(a,r);return _jsx(Text,{variant:t,...void 0===r?{}:{color:r},...n?{weight:"semibold"}:{},...void 0===o?{}:{numberOfLines:o},...void 0===s?{}:{testID:s},...u?{accessibilityRole:"header"}:{},accessibilityLabel:i??runsToText(e),children:withOffsets(e).map(({offset:e,run:t})=>_jsx(Fragment,{children:runNode(t,c,l)},e))})}export function FigureText({text:e,variant:t="bodySmall",enabled:r=!0,...n}){const o=useMemo(()=>r?toFigureRuns(e):[{kind:"text",text:e}],[e,r]);return _jsx(FigureRuns,{runs:o,variant:t,...n})}
1
+ "use strict";import{toFigureRuns}from"@webority/chat-core";import{Text,useTheme}from"@webority/mobile-ui";import{Fragment,useMemo}from"react";import{Text as RNText,View}from"react-native";import{webProps}from"../chatShared.js";import{jsx as _jsx}from"react/jsx-runtime";const sizeStepOf=e=>"caption"===e?"xs":"bodySmall"===e||"label"===e?"sm":"title"===e?"lg":"base",inkFor=(e,t)=>"secondary"===t?e.colors["text-muted"]:"tertiary"===t?e.colors["text-subtle"]:"success"===t||"warning"===t||"danger"===t||"info"===t?e.colors[`${t}-text`]:e.colors["text-body"];export function runsToText(e){return e.map(e=>e.text).join("")}const withOffsets=e=>e.reduce((e,t)=>{const r=e[e.length-1],o=r?r.offset+r.run.text.length:0;return e.push({offset:o,run:t}),e},[]);function runNode(e,t,r){if("text"===e.kind)return e.text;const o="sub"===e.kind?Math.round(.4*t):-Math.round(.45*t),n=Math.round(.75*t);return _jsx(View,{style:{transform:[{translateY:o}]},children:_jsx(RNText,{style:{fontSize:n,lineHeight:n,includeFontPadding:!1,color:r},children:e.text})})}export function FigureRuns({runs:e,variant:t="bodySmall",color:r,strong:o=!1,numberOfLines:n,accessibilityLabel:s,testID:i,heading:a}){const u=useTheme(),c=u.text[sizeStepOf(t)].size,l=inkFor(u,r);return _jsx(Text,{variant:t,...void 0===r?{}:{color:r},...o?{weight:"semibold"}:{},...void 0===n?{}:{numberOfLines:n},...void 0===i?{}:{testID:i},...a?{accessibilityRole:"header",...webProps({"aria-level":3})}:{},accessibilityLabel:s??runsToText(e),children:withOffsets(e).map(({offset:e,run:t})=>_jsx(Fragment,{children:runNode(t,c,l)},e))})}export function FigureText({text:e,variant:t="bodySmall",enabled:r=!0,...o}){const n=useMemo(()=>r?toFigureRuns(e):[{kind:"text",text:e}],[e,r]);return _jsx(FigureRuns,{runs:n,variant:t,...o})}
@@ -1 +1 @@
1
- "use strict";import{formatFigure,toFigureRuns,toFigureText}from"@webority/chat-core";import{formatNumber}from"@webority/mobile-core";import{StatTile,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{FigureRuns,runsToText}from"./FigureText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const TONE={Neutral:"neutral",Positive:"success",Caution:"warning",Negative:"danger"},withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),valueRunsOf=e=>{if(0!==e.value&&Math.abs(e.value)<.001)return formatFigure(e.value);const t=formatNumber(e.value,{maximumFractionDigits:2});return[{kind:"text",text:e.value<0?t.replace("-","−"):t}]};export function FiguresPart({part:e,turn:t}){const i=useTheme();return 0===e.figures.length?null:_jsx(View,{accessibilityRole:"summary",accessibilityLabel:t.labels.figures,style:{flexDirection:"row",flexWrap:"wrap",gap:i.space.sm},children:withPositions(e.figures).map(({key:e,item:i})=>{const r=valueRunsOf(i),s=t.labels.figureStatus(i.status),u=toFigureText(i.label);return _jsx(View,{style:{flexGrow:1,minWidth:110},children:_jsx(StatTile,{label:u,value:_jsxs(View,{style:{flexDirection:"row",alignItems:"flex-end",flexWrap:"wrap"},children:[_jsx(FigureRuns,{runs:r,variant:"title",color:"primary",strong:!0}),i.unit?_jsx(FigureRuns,{runs:[{kind:"text",text:" "},...toFigureRuns(i.unit)],variant:"bodySmall",color:"secondary"}):null]}),tone:TONE[i.status],caption:s||void 0,accessibilityLabel:`${u}: ${runsToText(r)}${i.unit?` ${i.unit}`:""}${s?`, ${s}`:""}`})},e)})})}
1
+ "use strict";import{formatFigure,toFigureRuns,toFigureText}from"@webority/chat-core";import{formatNumber}from"@webority/mobile-core";import{StatTile,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{webProps}from"../chatShared.js";import{FigureRuns,runsToText}from"./FigureText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const TONE={Neutral:"neutral",Positive:"success",Caution:"warning",Negative:"danger"},withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),valueRunsOf=e=>{if(0!==e.value&&Math.abs(e.value)<.001)return formatFigure(e.value);const t=formatNumber(e.value,{maximumFractionDigits:2});return[{kind:"text",text:e.value<0?t.replace("-","−"):t}]};export function FiguresPart({part:e,turn:t}){const r=useTheme();return 0===e.figures.length?null:_jsx(View,{accessibilityRole:"summary",accessibilityLabel:t.labels.figures,...webProps({role:"group"}),style:{flexDirection:"row",flexWrap:"wrap",gap:r.space.sm},children:withPositions(e.figures).map(({key:e,item:r})=>{const i=valueRunsOf(r),s=t.labels.figureStatus(r.status),u=toFigureText(r.label);return _jsx(View,{style:{flexGrow:1,minWidth:110},children:_jsx(StatTile,{label:u,value:_jsxs(View,{style:{flexDirection:"row",alignItems:"flex-end",flexWrap:"wrap"},children:[_jsx(FigureRuns,{runs:i,variant:"title",color:"primary",strong:!0}),r.unit?_jsx(FigureRuns,{runs:[{kind:"text",text:" "},...toFigureRuns(r.unit)],variant:"bodySmall",color:"secondary"}):null]}),tone:TONE[r.status],caption:s||void 0,accessibilityLabel:`${u}: ${runsToText(i)}${r.unit?` ${r.unit}`:""}${s?`, ${s}`:""}`})},e)})})}
@@ -1 +1 @@
1
- "use strict";import{Avatar,Card,Spinner,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function HandoffPart({part:e,turn:t}){const s=useTheme(),{labels:i}=t;if(!0===t.handoffSettled&&("Requested"===e.state||"Waiting"===e.state))return null;const a=t.isLast&&("Requested"===e.state||"Waiting"===e.state||"Joined"===e.state),n=e.agent?.displayName||i.handoffAgentFallback,r=e.agent?.avatarUrl;let o;switch(e.state){case"Requested":o=_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:s.space.sm},children:[_jsx(Spinner,{size:"sm"}),_jsx(Text,{variant:"bodySmall",children:i.handoffRequested})]});break;case"Waiting":o=_jsxs(View,{style:{gap:s.space.xs},children:[_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:s.space.sm},children:[_jsx(Spinner,{size:"sm"}),"number"==typeof e.queuePosition?null:_jsx(Text,{variant:"label",children:i.handoffWaiting})]}),"number"==typeof e.queuePosition?_jsx(Text,{variant:"caption",color:"secondary",children:i.handoffQueued(e.queuePosition)}):null,_jsx(Text,{variant:"caption",color:"secondary",children:i.handoffQueuedText})]});break;case"Joined":o=_jsxs(View,{style:{gap:s.space.xs},children:[_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:s.space.sm},children:[_jsxs(View,{style:{position:"relative"},children:[_jsx(Avatar,{size:"sm",name:n,...r?{source:{uri:r}}:{}}),_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:"absolute",right:0,bottom:0,width:8,height:8,borderRadius:s.radius.pill,backgroundColor:s.colors["success-text"]}})]}),_jsx(Text,{variant:"label",children:i.handoffJoined(n)})]}),_jsx(Text,{variant:"caption",color:"secondary",children:i.handoffJoinedText(n)})]});break;case"Left":o=_jsxs(View,{style:{gap:s.space.xs},children:[_jsx(Text,{variant:"bodySmall",children:i.handoffLeft(n)}),_jsx(Text,{variant:"caption",color:"secondary",children:i.handoffLeftText})]});break;case"Ended":o=_jsxs(View,{style:{gap:s.space.xs},children:[_jsx(Text,{variant:"bodySmall",children:i.handoffEnded}),_jsx(Text,{variant:"caption",color:"secondary",children:i.handoffEndedText})]})}return void 0===o?null:_jsx(Card,{variant:"outline",padding:"sm",accessibilityLiveRegion:a?"polite":void 0,children:o})}
1
+ "use strict";import{Avatar,Card,Spinner,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{WEB_STRONG,webProps}from"../chatShared.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function HandoffPart({part:e,turn:s}){const t=useTheme(),{labels:a}=s;if(!0===s.handoffSettled&&("Requested"===e.state||"Waiting"===e.state))return null;const i=s.isLast&&("Requested"===e.state||"Waiting"===e.state||"Joined"===e.state),n=e.agent?.displayName||a.handoffAgentFallback,r=e.agent?.avatarUrl;let o;switch(e.state){case"Requested":o=_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:t.space.sm},children:[_jsx(Spinner,{size:"sm"}),_jsx(Text,{variant:"bodySmall",children:a.handoffRequested})]});break;case"Waiting":o=_jsxs(View,{style:{gap:t.space.xs},children:[_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:t.space.sm},children:[_jsx(Spinner,{size:"sm"}),"number"==typeof e.queuePosition?null:_jsx(Text,{variant:"label",children:a.handoffWaiting})]}),"number"==typeof e.queuePosition?_jsx(Text,{variant:"caption",color:"secondary",children:a.handoffQueued(e.queuePosition)}):null,_jsx(Text,{variant:"caption",color:"secondary",children:a.handoffQueuedText})]});break;case"Joined":o=_jsxs(View,{style:{gap:t.space.xs},children:[_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:t.space.sm},children:[_jsxs(View,{style:{position:"relative"},...webProps({"aria-hidden":!0}),children:[_jsx(Avatar,{size:"sm",name:n,...r?{source:{uri:r}}:{}}),_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:"absolute",right:0,bottom:0,width:8,height:8,borderRadius:t.radius.pill,backgroundColor:t.colors["success-text"]}})]}),_jsx(Text,{variant:"label",...WEB_STRONG,children:a.handoffJoined(n)})]}),_jsx(Text,{variant:"caption",color:"secondary",...webProps({role:"paragraph"}),children:a.handoffJoinedText(n)})]});break;case"Left":o=_jsxs(View,{style:{gap:t.space.xs},children:[_jsx(Text,{variant:"bodySmall",children:a.handoffLeft(n)}),_jsx(Text,{variant:"caption",color:"secondary",children:a.handoffLeftText})]});break;case"Ended":o=_jsxs(View,{style:{gap:t.space.xs},children:[_jsx(Text,{variant:"bodySmall",children:a.handoffEnded}),_jsx(Text,{variant:"caption",color:"secondary",children:a.handoffEndedText})]})}return void 0===o?null:_jsx(Card,{variant:"outline",padding:"sm",accessibilityLiveRegion:i?"polite":void 0,children:o})}
@@ -1 +1 @@
1
- "use strict";import{AuthedImage,Button,Modal,Text,useTheme,ZoomableImage}from"@webority/mobile-ui";import{useMemo,useRef,useState}from"react";import{Pressable,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export function ImagePart({part:e,turn:t}){const a=useTheme(),s=useSafeAreaInsets(),[l,i]=useState(!1),[r,n]=useState(0),c=useRef(t.readAttachment);c.current=t.readAttachment;const o=useMemo(()=>({get:async()=>({data:await c.current(e.attachmentId)})}),[e.attachmentId]),m=`chat-attachment:${e.attachmentId}`,h=`${m}#${r}`,u=null!==e.width&&null!==e.height&&e.width>0&&e.height>0?e.width/e.height:null,d=_jsx(Text,{variant:"bodySmall",color:"secondary",children:e.alt}),b=_jsxs(View,{style:{gap:a.space.xs},children:[d,_jsx(Button,{variant:"soft",size:"sm",label:t.labels.retry,onPress:()=>n(e=>e+1),testID:`image-retry-${e.attachmentId}`})]});return _jsxs(_Fragment,{children:[_jsx(Pressable,{accessibilityRole:"imagebutton",accessibilityLabel:t.labels.imageOpen(e.alt),onPress:()=>i(!0),children:_jsx(AuthedImage,{uri:m,cacheKey:h,client:o,contentFit:"contain",accessible:!0,accessibilityLabel:e.alt,labels:{loading:t.labels.imageLoading},style:{width:"100%",...null===u?{minHeight:160}:{aspectRatio:u},maxHeight:320,borderRadius:a.radius.md},placeholder:d,fallback:b})}),_jsx(Modal,{open:l,onClose:()=>i(!1),backdropPressClose:!1,presentation:"fullScreen",accessibilityLabel:e.alt,children:_jsxs(View,{style:{flex:1,backgroundColor:a.colors.bg},children:[_jsx(ZoomableImage,{style:{flex:1},accessibilityLabel:e.alt,children:_jsx(AuthedImage,{uri:m,cacheKey:h,client:o,contentFit:"contain",style:{flex:1},accessibilityLabel:e.alt})}),_jsx(View,{style:{position:"absolute",top:s.top+a.space.sm,right:a.space.sm},children:_jsx(Button,{variant:"soft",size:"sm",label:t.labels.close,onPress:()=>i(!1)})})]})})]})}
1
+ "use strict";import{AuthedImage,Button,Modal,Text,useTheme,ZoomableImage}from"@webority/mobile-ui";import{useMemo,useRef,useState}from"react";import{Pressable,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{webProps}from"../chatShared.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export function ImagePart({part:e,turn:t}){const a=useTheme(),s=useSafeAreaInsets(),[i,l]=useState(!1),[r,n]=useState(0),o=useRef(t.readAttachment);o.current=t.readAttachment;const c=useMemo(()=>({get:async()=>({data:await o.current(e.attachmentId)})}),[e.attachmentId]),m=`chat-attachment:${e.attachmentId}`,h=`${m}#${r}`,u=null!==e.width&&null!==e.height&&e.width>0&&e.height>0?e.width/e.height:null,d=_jsx(Text,{variant:"bodySmall",color:"secondary",children:e.alt}),b=_jsxs(View,{style:{gap:a.space.xs},children:[d,_jsx(Button,{variant:"soft",size:"sm",label:t.labels.retry,onPress:()=>n(e=>e+1),testID:`image-retry-${e.attachmentId}`})]});return _jsxs(_Fragment,{children:[_jsx(View,{...webProps({role:"figure"}),children:_jsx(Pressable,{accessibilityRole:"imagebutton",accessibilityLabel:t.labels.imageOpen(e.alt),onPress:()=>l(!0),children:_jsx(AuthedImage,{uri:m,cacheKey:h,client:c,contentFit:"contain",accessible:!0,accessibilityLabel:e.alt,labels:{loading:t.labels.imageLoading},style:{width:"100%",...null===u?{minHeight:160}:{aspectRatio:u},maxHeight:320,borderRadius:a.radius.md},placeholder:d,fallback:b})})}),_jsx(Modal,{open:i,onClose:()=>l(!1),backdropPressClose:!1,presentation:"fullScreen",accessibilityLabel:e.alt,children:_jsxs(View,{style:{flex:1,backgroundColor:a.colors.bg},children:[_jsx(ZoomableImage,{style:{flex:1},accessibilityLabel:e.alt,children:_jsx(AuthedImage,{uri:m,cacheKey:h,client:c,contentFit:"contain",style:{flex:1},accessibilityLabel:e.alt})}),_jsx(View,{style:{position:"absolute",top:s.top+a.space.sm,right:a.space.sm},children:_jsx(Button,{variant:"soft",size:"sm",label:t.labels.close,onPress:()=>l(!1)})})]})})]})}
@@ -1 +1 @@
1
- "use strict";import{Button,Card,Checkbox,Chip,ChoiceGroup,Input,ProgressBar,Text,useTheme}from"@webority/mobile-ui";import{useCallback,useEffect,useRef,useState}from"react";import{View}from"react-native";import{focusForAccessibility}from"../chatShared.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const fileNameOf=(e,t)=>{const r="object"==typeof e&&null!==e&&"name"in e?e.name:void 0;return"string"==typeof r&&""!==r?r:t},slotFormat=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short",hour:"numeric",minute:"2-digit"}),isStringList=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e),selectedIds=e=>{if(""===e)return[];const t=JSON.parse(e);if(!isStringList(t))throw new Error("Selected ids are not a list of strings.");return t},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:r}){const i=useTheme(),{labels:s,features:n}=t,[a,l]=useState({}),[o,c]=useState({}),[u,d]=useState(""),[p,y]=useState(!1),[f,h]=useState({}),[m,x]=useState({}),[b,k]=useState({}),v=useRef({}),g=useRef({}),j=useRef(f),_=useRef(0),S=useRef(!1),T=useCallback(e=>{const t=v.current[e];if(t)return void t.focus();const r=g.current[e];r&&focusForAccessibility(r)},[]);useEffect(()=>{if(p||!S.current)return;S.current=!1;const t=firstErrorKey(e.fields,o);void 0!==t&&T(t)},[p,o,e.fields,T]);const setValue=(e,t)=>l(r=>({...r,[e]:t})),commitUploads=e=>{j.current=e,h(e)},patchUpload=(e,t)=>{const r=j.current[e];r&&commitUploads({...j.current,[e]:{...r,...t}})},isLiveUpload=(e,t)=>j.current[e]?.token===t,w=Object.values(f).some(e=>"Ready"!==e.status),leave=async e=>{y(!0),d("");try{await e()}catch{d(s.errorGeneric),y(!1)}},C=n.LeadShortcuts,O=e.fields[0];if(C&&1===e.fields.length&&void 0===O)throw new Error("A one-field form has no field.");const R=C&&1===e.fields.length&&void 0!==O&&!O.required,E=C&&e.cancellable;return _jsx(Card,{variant:"outline",padding:"sm",...e.title?{accessibilityLabel:e.title}:{},children:_jsxs(View,{style:{gap:i.space.sm},children:[e.title?_jsx(Text,{variant:"label",accessibilityRole:"header",children:e.title}):null,e.allowTyped?_jsx(Text,{variant:"caption",color:"secondary",children:s.typeAnswer}):null,e.fields.map(n=>{const l=a[n.key]??"",c=o[n.key];if("File"===n.type){const e=f[n.key];return _jsxs(View,{style:{gap:i.space.xs},children:[_jsx(Text,{variant:"label",children:`${n.label}${optionalSuffix(n,s)}`}),e?_jsxs(View,{style:{gap:i.space.xxs},children:[_jsx(Chip,{label:e.fileName,variant:"soft",onRemove:()=>{return e=n.key,commitUploads(Object.fromEntries(Object.entries(j.current).filter(([t])=>t!==e))),void setValue(e,"");var e},labels:{remove:s.inputRemoveFile}}),"Uploading"===e.status?_jsx(ProgressBar,{..."number"==typeof e.progress?{progress:e.progress}:{},label:s.attachmentUploading,height:4}):null,"Failed"===e.status?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"assertive",children:s.attachmentFailed}):null]}):_jsx(View,{style:{flexDirection:"row"},children:_jsx(Button,{label:s.inputChooseFile,variant:"soft",size:"sm",leftIcon:"paperclip",disabled:p||void 0===r,onPress:()=>{(async e=>{if(!r)return;let i;try{i=await r(e.accept??void 0)}catch{return void d(s.errorGeneric)}const n=i[0];if(!n)return;_.current+=1;const a=_.current;commitUploads({...j.current,[e.key]:{fileName:fileNameOf(n,e.label),status:"Uploading",progress:null,token:a}});try{const r=await t.uploadInputFile(n,t=>{isLiveUpload(e.key,a)&&patchUpload(e.key,{progress:t})});isLiveUpload(e.key,a)&&(setValue(e.key,r),patchUpload(e.key,{status:"Ready",progress:null}))}catch{isLiveUpload(e.key,a)&&(setValue(e.key,""),patchUpload(e.key,{status:"Failed",progress:null}))}})(n)}})}),c?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"assertive",children:c}):null]},n.key)}if("MultiChoice"===n.type){const e=(n.options??[]).map(e=>({label:e.label,value:e.id}));return _jsxs(View,{style:{gap:i.space.xs},children:[_jsx(Text,{variant:"label",children:`${n.label}${optionalSuffix(n,s)}`}),_jsx(View,{ref:e=>{g.current[n.key]=e},children:_jsx(ChoiceGroup,{selectionMode:"multiple",options:e,value:selectedIds(l),onChange:t=>setValue(n.key,JSON.stringify(e.filter(e=>t.includes(e.value)).map(e=>e.value))),accessibilityLabel:n.label,...void 0===c?{}:{error:c},disabled:p})})]},n.key)}if("Choice"===n.type||"TimeSlot"===n.type){const e="TimeSlot"===n.type?(n.slots??[]).map(e=>({label:slotFormat.format(new Date(e.startDateTimeUtc)),value:e.id})):(n.options??[]).map(e=>({label:e.label,value:e.id}));return _jsxs(View,{style:{gap:i.space.xs},children:[_jsx(Text,{variant:"label",children:`${n.label}${optionalSuffix(n,s)}`}),_jsx(View,{ref:e=>{g.current[n.key]=e},children:_jsx(ChoiceGroup,{options:e,...""===l?{}:{value:l},onChange:e=>setValue(n.key,String(e)),accessibilityLabel:n.label,...void 0===c?{}:{error:c},disabled:p})})]},n.key)}if("Consent"===n.type)return _jsx(Checkbox,{checked:"true"===l,onChange:e=>setValue(n.key,e?"true":"false"),label:n.consentText??n.label,...void 0===c?{}:{error:c},disabled:p},n.key);const u=_jsx(Input,{ref:e=>{v.current[n.key]=e},label:n.label,..."string"==typeof n.placeholder?{placeholder:n.placeholder}:{},value:l,onChangeText:e=>setValue(n.key,e),..."number"==typeof n.maxLength?{maxLength:n.maxLength}:{},required:n.required,...void 0===c?{}:{error:c},...n.required?{}:{help:s.inputOptional},labelMode:"top",disabled:p,type:n.secret?"password":"LongText"===n.type?"textarea":"input",keyboardType:KEYBOARD_TYPES[n.type]??"default",..."Email"===n.type?{autoCapitalize:"none"}:{},...void 0===AUTO_COMPLETE[n.type]?{}:{autoComplete:AUTO_COMPLETE[n.type]}},n.key);if(!("Otp"===n.verify&&("Email"===n.type||"Phone"===n.type)))return u;const y=b[n.key];return _jsxs(View,{style:{gap:i.space.xs},children:[u,_jsxs(View,{style:{gap:i.space.xs},children:[_jsx(Button,{label:s.inputSendCode,variant:"soft",size:"sm",disabled:p,onPress:()=>{(async r=>{if("Otp"===r.verify)try{await t.sendOtp(e.requestId,{fieldKey:r.key,value:(a[r.key]??"").trim()}),k(e=>({...e,[r.key]:"sent"}))}catch{k(e=>({...e,[r.key]:"failed"}))}})(n)},testID:`otp-send-${n.key}`}),_jsx(Input,{label:s.inputEnterCode,value:m[n.key]??"",onChangeText:e=>x(t=>({...t,[n.key]:e})),keyboardType:"number-pad",autoComplete:"one-time-code",disabled:p}),y?_jsx(Text,{variant:"caption",color:"failed"===y?"danger":"secondary",accessibilityLiveRegion:"polite",children:"failed"===y?s.inputCodeFailed:s.inputCodeSent}):null]})]},n.key)}),""!==u?_jsx(Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:u}):null,_jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:i.space.sm},children:[_jsx(Button,{label:p?s.inputSubmitting:e.submitLabel,loading:p,disabled:p||w,onPress:()=>{(async()=>{if(w)return;const r={},i={};for(const t of e.fields){const e=a[t.key]??"";if("Consent"===t.type){const n="true"===e;t.required&&!n&&(r[t.key]=s.inputConsentRequired),i[t.key]=n?"true":"false"}else if("Choice"===t.type||"TimeSlot"===t.type)t.required&&""===e&&(r[t.key]=s.inputRequired),i[t.key]=e;else if("MultiChoice"===t.type){const n=selectedIds(e);t.required&&0===n.length&&(r[t.key]=s.inputRequired),i[t.key]=JSON.stringify(n)}else if("File"===t.type)t.required&&""===e&&(r[t.key]=s.inputRequired),i[t.key]=e;else{const n=t.secret?e:e.trim();t.required&&""===n&&(r[t.key]=s.inputRequired),i[t.key]=n}}const n={};for(const t of e.fields){if("Otp"!==t.verify)continue;const e=(m[t.key]??"").trim();""===e&&(r[t.key]=s.inputRequired),n[t.key]=e}if(c(r),Object.keys(r).length>0){const t=firstErrorKey(e.fields,r);return void(void 0!==t&&T(t))}y(!0),d("");try{const r=await t.answerInput(e.requestId,i,Object.keys(n).length>0?n:null);if(r.ok)return;c(r.errors),S.current=!0,d(r.message??"")}catch{d(s.errorGeneric)}y(!1)})()}}),w?_jsx(Text,{variant:"caption",color:"secondary",children:s.attachmentUploading}):null,R?_jsx(Button,{label:s.skip,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.skipInput(e.requestId))}}):null,E?_jsx(Button,{label:s.cancel,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.cancelLead())}}):null]})]})})}export function InputRequestPart({part:e,turn:t,pickAttachments:r}){return"Answered"===e.state?_jsx(Text,{variant:"bodySmall",color:"secondary",children:e.answeredSummary||t.labels.inputAnswered}):"Skipped"===e.state?_jsx(Text,{variant:"bodySmall",color:"secondary",children:t.labels.inputSkipped}):"Expired"===e.state?_jsx(Text,{variant:"bodySmall",color:"secondary",children:t.labels.inputExpired}):_jsx(OpenRequest,{part:e,turn:t,pickAttachments:r},e.requestId)}
1
+ "use strict";import{Button,Card,Checkbox,Chip,ChoiceGroup,Input,ProgressBar,Text,useTheme}from"@webority/mobile-ui";import{useCallback,useEffect,useRef,useState}from"react";import{View}from"react-native";import{focusForAccessibility,webProps}from"../chatShared.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const fileNameOf=(e,t)=>{const r="object"==typeof e&&null!==e&&"name"in e?e.name:void 0;return"string"==typeof r&&""!==r?r:t},slotFormat=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short",hour:"numeric",minute:"2-digit"}),isStringList=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e),selectedIds=e=>{if(""===e)return[];const t=JSON.parse(e);if(!isStringList(t))throw new Error("Selected ids are not a list of strings.");return t},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:r}){const i=useTheme(),{labels:s,features:a}=t,[n,l]=useState({}),[o,c]=useState({}),[u,d]=useState(""),[p,y]=useState(!1),[f,b]=useState({}),[h,m]=useState({}),[x,k]=useState({}),v=useRef({}),g=useRef({}),j=useRef(f),_=useRef(0),w=useRef(!1),T=useCallback(e=>{const t=v.current[e];if(t)return void t.focus();const r=g.current[e];r&&focusForAccessibility(r)},[]);useEffect(()=>{if(p||!w.current)return;w.current=!1;const t=firstErrorKey(e.fields,o);void 0!==t&&T(t)},[p,o,e.fields,T]);const setValue=(e,t)=>l(r=>({...r,[e]:t})),commitUploads=e=>{j.current=e,b(e)},patchUpload=(e,t)=>{const r=j.current[e];r&&commitUploads({...j.current,[e]:{...r,...t}})},isLiveUpload=(e,t)=>j.current[e]?.token===t,C=Object.values(f).some(e=>"Ready"!==e.status),leave=async e=>{y(!0),d("");try{await e()}catch{d(s.errorGeneric),y(!1)}},S=a.LeadShortcuts,O=e.fields[0];if(S&&1===e.fields.length&&void 0===O)throw new Error("A one-field form has no field.");const R=S&&1===e.fields.length&&void 0!==O&&!O.required,E=S&&e.cancellable;return _jsx(Card,{variant:"outline",padding:"sm",...e.title?{accessibilityLabel:e.title}:{},...webProps({role:"form","aria-label":e.title||e.submitLabel}),children:_jsxs(View,{style:{gap:i.space.sm},children:[e.title?_jsx(Text,{variant:"label",accessibilityRole:"header",...webProps({"aria-level":3}),children:e.title}):null,e.fields.map(a=>{const l=n[a.key]??"",c=o[a.key];if("File"===a.type){const e=f[a.key];return _jsxs(View,{style:{gap:i.space.xs},children:[_jsx(Text,{variant:"label",children:`${a.label}${optionalSuffix(a,s)}`}),_jsx(View,{...webProps({role:"group","aria-label":a.label}),children:e?_jsxs(View,{style:{gap:i.space.xxs},children:[_jsx(Chip,{label:e.fileName,variant:"soft",onRemove:()=>{return e=a.key,commitUploads(Object.fromEntries(Object.entries(j.current).filter(([t])=>t!==e))),void setValue(e,"");var e},labels:{remove:s.inputRemoveFile}}),"Uploading"===e.status?_jsx(ProgressBar,{..."number"==typeof e.progress?{progress:e.progress}:{},label:s.attachmentUploading,height:4}):null,"Failed"===e.status?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"assertive",children:s.attachmentFailed}):null]}):_jsx(View,{style:{flexDirection:"row"},children:_jsx(Button,{label:s.inputChooseFile,variant:"soft",size:"sm",leftIcon:"paperclip",disabled:p||void 0===r,onPress:()=>{(async e=>{if(!r)return;let i;try{i=await r(e.accept??void 0)}catch{return void d(s.errorGeneric)}const a=i[0];if(!a)return;_.current+=1;const n=_.current;commitUploads({...j.current,[e.key]:{fileName:fileNameOf(a,e.label),status:"Uploading",progress:null,token:n}});try{const r=await t.uploadInputFile(a,t=>{isLiveUpload(e.key,n)&&patchUpload(e.key,{progress:t})});isLiveUpload(e.key,n)&&(setValue(e.key,r),patchUpload(e.key,{status:"Ready",progress:null}))}catch{isLiveUpload(e.key,n)&&(setValue(e.key,""),patchUpload(e.key,{status:"Failed",progress:null}))}})(a)}})})}),c?_jsx(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 _jsxs(View,{style:{gap:i.space.xs},children:[_jsx(Text,{variant:"label",children:`${a.label}${optionalSuffix(a,s)}`}),_jsx(View,{ref:e=>{g.current[a.key]=e},...webProps({role:"group","aria-label":a.label}),children:_jsx(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,...void 0===c?{}:{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 _jsxs(View,{style:{gap:i.space.xs},children:[_jsx(Text,{variant:"label",children:`${a.label}${optionalSuffix(a,s)}`}),_jsx(View,{ref:e=>{g.current[a.key]=e},children:_jsx(ChoiceGroup,{options:e,...""===l?{}:{value:l},onChange:e=>setValue(a.key,String(e)),accessibilityLabel:a.label,...void 0===c?{}:{error:c},disabled:p})})]},a.key)}if("Consent"===a.type)return _jsx(Checkbox,{checked:"true"===l,onChange:e=>setValue(a.key,e?"true":"false"),label:a.consentText??a.label,...void 0===c?{}:{error:c},disabled:p},a.key);const u=_jsx(Input,{ref:e=>{v.current[a.key]=e},label:a.label,..."string"==typeof a.placeholder?{placeholder:a.placeholder}:{},value:l,onChangeText:e=>setValue(a.key,e),..."number"==typeof a.maxLength?{maxLength:a.maxLength}:{},showCounter:!1,required:a.required,...void 0===c?{}:{error:c},...a.required?{}:{help:_jsx(Text,{variant:"caption",color:"secondary",children:s.inputOptional})},labelMode:"top",disabled:p,type:a.secret?"password":"LongText"===a.type?"textarea":"input",keyboardType:KEYBOARD_TYPES[a.type]??"default",..."Email"===a.type?{autoCapitalize:"none"}:{},...void 0===AUTO_COMPLETE[a.type]?{}:{autoComplete:AUTO_COMPLETE[a.type]}},a.key);if(!("Otp"===a.verify&&("Email"===a.type||"Phone"===a.type)))return u;const y=x[a.key];return _jsxs(View,{style:{gap:i.space.xs},children:[u,_jsxs(View,{style:{gap:i.space.xs},children:[_jsx(Button,{label:s.inputSendCode,variant:"soft",size:"sm",disabled:p,onPress:()=>{(async r=>{if("Otp"===r.verify)try{await t.sendOtp(e.requestId,{fieldKey:r.key,value:(n[r.key]??"").trim()}),k(e=>({...e,[r.key]:"sent"}))}catch{k(e=>({...e,[r.key]:"failed"}))}})(a)},testID:`otp-send-${a.key}`}),_jsx(Input,{label:s.inputEnterCode,value:h[a.key]??"",onChangeText:e=>m(t=>({...t,[a.key]:e})),keyboardType:"number-pad",autoComplete:"one-time-code",disabled:p}),y?_jsx(Text,{variant:"caption",color:"failed"===y?"danger":"secondary",accessibilityLiveRegion:"polite",children:"failed"===y?s.inputCodeFailed:s.inputCodeSent}):null]})]},a.key)}),""!==u?_jsx(Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:u}):null,_jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:i.space.sm},children:[_jsx(Button,{label:p?s.inputSubmitting:e.submitLabel,loading:p,disabled:p||C,onPress:()=>{(async()=>{if(C)return;const r={},i={};for(const t of e.fields){const e=n[t.key]??"";if("Consent"===t.type){const a="true"===e;t.required&&!a&&(r[t.key]=s.inputConsentRequired),i[t.key]=a?"true":"false"}else if("Choice"===t.type||"TimeSlot"===t.type)t.required&&""===e&&(r[t.key]=s.inputRequired),i[t.key]=e;else if("MultiChoice"===t.type){const a=selectedIds(e);t.required&&0===a.length&&(r[t.key]=s.inputRequired),i[t.key]=JSON.stringify(a)}else if("File"===t.type)t.required&&""===e&&(r[t.key]=s.inputRequired),i[t.key]=e;else{const a=t.secret?e:e.trim();t.required&&""===a&&(r[t.key]=s.inputRequired),i[t.key]=a}}const a={};for(const t of e.fields){if("Otp"!==t.verify)continue;const e=(h[t.key]??"").trim();""===e&&(r[t.key]=s.inputRequired),a[t.key]=e}if(c(r),Object.keys(r).length>0){const t=firstErrorKey(e.fields,r);return void(void 0!==t&&T(t))}y(!0),d("");try{const r=await t.answerInput(e.requestId,i,Object.keys(a).length>0?a:null);if(r.ok)return;c(r.errors),w.current=!0,d(r.message??"")}catch{d(s.errorGeneric)}y(!1)})()}}),C?_jsx(Text,{variant:"caption",color:"secondary",children:s.attachmentUploading}):null,R?_jsx(Button,{label:s.skip,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.skipInput(e.requestId))}}):null,E?_jsx(Button,{label:s.cancel,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.cancelLead())}}):null]}),e.allowTyped?_jsx(Text,{variant:"caption",color:"secondary",...webProps({role:"paragraph"}),children:s.typeAnswer}):null]})})}export function InputRequestPart({part:e,turn:t,pickAttachments:r}){return"Answered"===e.state?_jsx(Text,{variant:"bodySmall",color:"secondary",children:e.answeredSummary||t.labels.inputAnswered}):"Skipped"===e.state?_jsx(Text,{variant:"bodySmall",color:"secondary",children:t.labels.inputSkipped}):"Expired"===e.state?_jsx(Text,{variant:"bodySmall",color:"secondary",children:t.labels.inputExpired}):_jsx(OpenRequest,{part:e,turn:t,pickAttachments:r},e.requestId)}
@@ -1 +1 @@
1
- "use strict";import{formatChatValue,toFigureText}from"@webority/chat-core";import{Button,Card,useTheme}from"@webority/mobile-ui";import{StyleSheet,View}from"react-native";import{FigureText}from"./FigureText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),NUMERIC=new Set(["Integer","Decimal","MoneyMinor","Percent"]);export function RecordCardPart({part:e,turn:t}){const r=useTheme(),i=void 0!==t.openRecord&&null!==e.target;return _jsx(Card,{variant:"outline",padding:"sm",accessibilityRole:"summary",children:_jsxs(View,{style:{gap:r.space.xs},children:[_jsx(FigureText,{text:e.title,variant:"label",color:"primary",strong:!0,numberOfLines:2,enabled:t.features.FigureText,heading:!0}),e.subtitle?_jsx(FigureText,{text:e.subtitle,variant:"bodySmall",color:"secondary",enabled:t.features.FigureText}):null,withPositions(e.fields).map(({key:e,item:i})=>_jsxs(View,{style:{gap:r.space.xs},children:[e>0?_jsx(View,{style:{height:StyleSheet.hairlineWidth,backgroundColor:r.colors["border-subtle"]}}):null,_jsxs(View,{style:{flexDirection:"row",justifyContent:"space-between",gap:r.space.sm},children:[_jsx(View,{style:{flexShrink:1},children:_jsx(FigureText,{text:i.label,variant:"caption",color:"secondary",enabled:t.features.FigureText})}),_jsx(View,{style:{flex:1,alignItems:NUMERIC.has(i.type)?"flex-end":"flex-start"},children:_jsx(FigureText,{text:formatChatValue(i.value,i.type,null),variant:"bodySmall",color:"primary",enabled:t.features.FigureText})})]})]},e)),i?_jsx(Button,{label:t.labels.recordOpen,variant:"link",size:"sm",accessibilityLabel:t.labels.recordOpenFor(toFigureText(e.title)),onPress:()=>t.openRecord?.(e),testID:`record-open-${e.recordId}`}):null]})})}
1
+ "use strict";import{formatChatValue,toFigureText}from"@webority/chat-core";import{Button,Card,useTheme}from"@webority/mobile-ui";import{StyleSheet,View}from"react-native";import{webProps}from"../chatShared.js";import{FigureText}from"./FigureText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),NUMERIC=new Set(["Integer","Decimal","MoneyMinor","Percent"]);export function RecordCardPart({part:e,turn:t}){const r=useTheme(),i=void 0!==t.openRecord&&null!==e.target;return _jsx(Card,{variant:"outline",padding:"sm",accessibilityRole:"summary",...webProps({role:"article","aria-label":toFigureText(e.title)}),children:_jsxs(View,{style:{gap:r.space.xs},children:[_jsx(FigureText,{text:e.title,variant:"label",color:"primary",strong:!0,numberOfLines:2,enabled:t.features.FigureText,heading:!0}),e.subtitle?_jsx(FigureText,{text:e.subtitle,variant:"bodySmall",color:"secondary",enabled:t.features.FigureText}):null,withPositions(e.fields).map(({key:e,item:i})=>_jsxs(View,{style:{gap:r.space.xs},children:[e>0?_jsx(View,{style:{height:StyleSheet.hairlineWidth,backgroundColor:r.colors["border-subtle"]}}):null,_jsxs(View,{style:{flexDirection:"row",justifyContent:"space-between",gap:r.space.sm},children:[_jsx(View,{style:{flexShrink:1},...webProps({role:"term"}),children:_jsx(FigureText,{text:i.label,variant:"caption",color:"secondary",enabled:t.features.FigureText})}),_jsx(View,{style:{flex:1,alignItems:NUMERIC.has(i.type)?"flex-end":"flex-start"},...webProps({role:"definition"}),children:_jsx(FigureText,{text:formatChatValue(i.value,i.type,null),variant:"bodySmall",color:"primary",enabled:t.features.FigureText})})]})]},e)),i?_jsx(Button,{label:t.labels.recordOpen,variant:"link",size:"sm",accessibilityLabel:t.labels.recordOpenFor(toFigureText(e.title)),onPress:()=>t.openRecord?.(e),testID:`record-open-${e.recordId}`}):null]})})}
@@ -1 +1 @@
1
- "use strict";import{Chip,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{ChatEntrance}from"../ChatEntrance.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const HTTP_LINK=/^https?:\/\//i;export function SourcesPart({part:e,turn:r}){const s=useTheme();if(!r.features.Sources||0===e.sources.length)return null;const t=r.openTarget;return _jsxs(View,{style:{gap:s.space.xs},children:[_jsx(Text,{variant:"caption",color:"secondary",children:r.labels.sources}),_jsx(View,{accessibilityRole:"list",accessibilityLabel:r.labels.sources,style:{flexDirection:"row",flexWrap:"wrap",gap:s.space.xs},children:e.sources.map((e,s)=>{const i=e.url,a=null!==i&&HTTP_LINK.test(i)&&void 0!==t?()=>t(i):void 0;return _jsx(ChatEntrance,{index:s,animate:!1,children:_jsx(View,{ref:s=>r.registerSourceRow?.(String(e.marker),s),children:_jsx(Chip,{label:`${e.marker} ${e.title}`,variant:"outline",size:"sm",...void 0===a?{}:{accessibilityLabel:r.labels.openSource(e.title),onPress:a}})})},e.marker)})})]})}
1
+ "use strict";import{Chip,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{ChatEntrance}from"../ChatEntrance.js";import{webProps}from"../chatShared.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const HTTP_LINK=/^https?:\/\//i;export function SourcesPart({part:e,turn:r}){const s=useTheme();if(!r.features.Sources||0===e.sources.length)return null;const t=r.openTarget;return _jsxs(View,{style:{gap:s.space.xs},children:[_jsx(Text,{variant:"caption",color:"secondary",...webProps({role:"paragraph"}),children:r.labels.sources}),_jsx(View,{accessibilityRole:"list",accessibilityLabel:r.labels.sources,style:{flexDirection:"row",flexWrap:"wrap",gap:s.space.xs},children:e.sources.map((e,s)=>{const i=e.url,a=null!==i&&HTTP_LINK.test(i)&&void 0!==t?()=>t(i):void 0;return _jsx(ChatEntrance,{index:s,animate:!1,children:_jsx(View,{ref:s=>r.registerSourceRow?.(String(e.marker),s),...webProps({role:"listitem"}),children:_jsx(Chip,{label:`${e.marker} ${e.title}`,variant:"outline",size:"sm",...void 0===a?{}:{accessibilityLabel:r.labels.openSource(e.title),onPress:a}})})},e.marker)})})]})}
@@ -1 +1 @@
1
- "use strict";import{formatChatValue,toFigureText}from"@webority/chat-core";import{AppIcon,Button,Card,Text,useTheme}from"@webority/mobile-ui";import{useState}from"react";import{ScrollView,StyleSheet,View}from"react-native";import{FigureText}from"./FigureText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const PREVIEW_ROWS=25,COLUMN_WIDTH={Text:140,Integer:88,Decimal:96,MoneyMinor:112,Percent:80,Date:112,DateTimeUtc:152},NUMERIC=new Set(["Integer","Decimal","MoneyMinor","Percent"]),withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]);export function TablePart({part:e,turn:t}){const r=useTheme(),[i,l]=useState(!1),[n,s]=useState(0),[o,a]=useState(0),[c,u]=useState(0);if(0===e.columns.length||0===e.rows.length)return null;const plain=e=>t.features.FigureText?toFigureText(e):e,x=o>c+n+1,m=i?e.rows:e.rows.slice(0,25),h={height:StyleSheet.hairlineWidth,backgroundColor:r.colors["border-subtle"]},d={paddingVertical:r.space.xs,paddingHorizontal:r.space.sm},cellValue=(t,r,i)=>{const l=t[r];return null==l?null:formatChatValue(l,i.type,e.currency)};return _jsxs(View,{accessibilityLabel:e.title?plain(e.title):t.labels.table,style:{gap:r.space.xs},children:[e.title?_jsx(FigureText,{text:e.title,variant:"label",color:"primary",strong:!0,enabled:t.features.FigureText}):null,_jsxs(Card,{variant:"outline",padding:"sm",onLayout:e=>u(e.nativeEvent.layout.width),children:[_jsx(ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!0,nestedScrollEnabled:!0,onScroll:e=>s(e.nativeEvent.contentOffset.x),onContentSizeChange:e=>a(e),scrollEventThrottle:16,children:_jsxs(View,{children:[_jsx(View,{style:{flexDirection:"row"},children:e.columns.map(e=>_jsx(View,{style:[d,{width:COLUMN_WIDTH[e.type],alignItems:NUMERIC.has(e.type)?"flex-end":"flex-start"}],children:_jsx(FigureText,{text:e.label,variant:"label",color:"secondary",strong:!0,numberOfLines:2,enabled:t.features.FigureText})},e.key))}),_jsx(View,{style:h}),withPositions(m).map(({key:r,item:i})=>{const l=e.columns.map((e,t)=>`${plain(e.label)}: ${cellValue(i,t,e)??"-"}`).join(", ");return _jsxs(View,{accessible:!0,accessibilityLabel:l,children:[_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:"row"},children:e.columns.map((e,r)=>{const l=cellValue(i,r,e);return _jsx(View,{style:[d,{width:COLUMN_WIDTH[e.type],alignItems:NUMERIC.has(e.type)?"flex-end":"flex-start"}],children:null===l?_jsx(Text,{variant:"bodySmall",color:"tertiary",children:"-"}):_jsx(FigureText,{text:l,variant:"bodySmall",color:"primary",numberOfLines:3,enabled:t.features.FigureText})},e.key)})}),_jsx(View,{style:h})]},r)})]})}),x?_jsx(View,{pointerEvents:"none",style:{position:"absolute",right:0,top:0,bottom:0,justifyContent:"center"},children:_jsx(AppIcon,{name:"chevron-right",size:"sm",color:"tertiary"})}):null]}),!i&&e.rows.length>25?_jsx(Button,{variant:"link",size:"sm",label:t.labels.tableShowAll(e.rows.length),onPress:()=>l(!0)}):null]})}
1
+ "use strict";import{formatChatValue,toFigureText}from"@webority/chat-core";import{AppIcon,Button,Card,Text,useTheme}from"@webority/mobile-ui";import{useState}from"react";import{Platform,ScrollView,StyleSheet,View}from"react-native";import{webProps}from"../chatShared.js";import{FigureText}from"./FigureText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const PREVIEW_ROWS=25,COLUMN_WIDTH={Text:140,Integer:88,Decimal:96,MoneyMinor:112,Percent:80,Date:112,DateTimeUtc:152},NUMERIC=new Set(["Integer","Decimal","MoneyMinor","Percent"]),withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]);export function TablePart({part:e,turn:t}){const r=useTheme(),[l,o]=useState(!1),[i,s]=useState(0),[n,a]=useState(0),[c,u]=useState(0);if(0===e.columns.length||0===e.rows.length)return null;const plain=e=>t.features.FigureText?toFigureText(e):e,x=n>c+i+1,m=l?e.rows:e.rows.slice(0,25),h={height:StyleSheet.hairlineWidth,backgroundColor:r.colors["border-subtle"]},p={paddingVertical:r.space.xs,paddingHorizontal:r.space.sm},cellValue=(t,r,l)=>{const o=t[r];return null==o?null:formatChatValue(o,l.type,e.currency)};return _jsxs(View,{accessibilityLabel:e.title?plain(e.title):t.labels.table,style:{gap:r.space.xs},...webProps({role:"figure"}),children:[e.title?_jsx(FigureText,{text:e.title,variant:"label",color:"primary",strong:!0,enabled:t.features.FigureText}):null,_jsxs(Card,{variant:"outline",padding:"sm",onLayout:e=>u(e.nativeEvent.layout.width),...webProps({role:"region","aria-label":e.title?plain(e.title):t.labels.table}),children:[_jsx(ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!0,nestedScrollEnabled:!0,onScroll:e=>s(e.nativeEvent.contentOffset.x),onContentSizeChange:e=>a(e),scrollEventThrottle:16,children:_jsxs(View,{...webProps({role:"table"}),children:[_jsx(View,{...webProps({role:"rowgroup"}),children:_jsx(View,{style:{flexDirection:"row"},...webProps({role:"row"}),children:e.columns.map(e=>_jsx(View,{style:[p,{width:COLUMN_WIDTH[e.type],alignItems:NUMERIC.has(e.type)?"flex-end":"flex-start"}],...webProps({role:"columnheader"}),children:_jsx(FigureText,{text:e.label,variant:"label",color:"secondary",strong:!0,numberOfLines:2,enabled:t.features.FigureText})},e.key))})}),_jsx(View,{style:h}),_jsx(View,{...webProps({role:"rowgroup"}),children:withPositions(m).map(({key:r,item:l})=>{const o=e.columns.map((e,t)=>`${plain(e.label)}: ${cellValue(l,t,e)??"-"}`).join(", ");return _jsxs(View,{..."web"===Platform.OS?{}:{accessible:!0,accessibilityLabel:o},children:[_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:"row"},...webProps({role:"row"}),children:e.columns.map((e,r)=>{const o=cellValue(l,r,e);return _jsx(View,{style:[p,{width:COLUMN_WIDTH[e.type],alignItems:NUMERIC.has(e.type)?"flex-end":"flex-start"}],...webProps({role:0===r&&"Text"===e.type?"rowheader":"cell"}),children:null===o?_jsx(Text,{variant:"bodySmall",color:"tertiary",children:"-"}):_jsx(FigureText,{text:o,variant:"bodySmall",color:"primary",numberOfLines:3,enabled:t.features.FigureText})},e.key)})}),_jsx(View,{style:h})]},r)})})]})}),x?_jsx(View,{pointerEvents:"none",style:{position:"absolute",right:0,top:0,bottom:0,justifyContent:"center"},children:_jsx(AppIcon,{name:"chevron-right",size:"sm",color:"tertiary"})}):null]}),!l&&e.rows.length>25?_jsx(Button,{variant:"link",size:"sm",label:t.labels.tableShowAll(e.rows.length),onPress:()=>o(!0)}):null]})}
@@ -1 +1 @@
1
- "use strict";import{isHandoffTarget,toFigureRuns}from"@webority/chat-core";import{Markdown,Text}from"@webority/mobile-ui";import{View}from"react-native";import{FigureText}from"./FigureText.js";import{jsx as _jsx}from"react/jsx-runtime";const CITATION=/^\d+$/;export function TextPart({part:t,message:e,turn:r}){const i="Visitor"===e.author.kind||"Customer"===e.author.kind;return _jsx(View,{children:i?r.features.FigureText?_jsx(FigureText,{text:t.text,variant:"body",color:"primary"}):_jsx(Text,{variant:"body",children:t.text}):_jsx(Markdown,{links:"app",headings:"text",resolveLink:t=>r.openTarget&&isHandoffTarget(t,r.handoffHosts)?t:null,onAppLinkPress:t=>r.openTarget?.(t),isCitation:t=>CITATION.test(t),...r.features.FigureText?{figureText:toFigureRuns}:{},...r.openCitation?{onOpenCitation:t=>r.openCitation?.(Number(t))}:{},children:t.text})})}
1
+ "use strict";import{isHandoffTarget,toFigureRuns}from"@webority/chat-core";import{Markdown,Text}from"@webority/mobile-ui";import{View}from"react-native";import{webProps}from"../chatShared.js";import{FigureText}from"./FigureText.js";import{jsx as _jsx}from"react/jsx-runtime";const CITATION=/^\d+$/;export function TextPart({part:t,message:e,turn:r}){const o="Visitor"===e.author.kind||"Customer"===e.author.kind;return _jsx(View,{...webProps({role:"paragraph"}),children:o?r.features.FigureText?_jsx(FigureText,{text:t.text,variant:"body",color:"primary"}):_jsx(Text,{variant:"body",children:t.text}):_jsx(Markdown,{links:"app",headings:"text",resolveLink:t=>r.openTarget&&isHandoffTarget(t,r.handoffHosts)?t:null,onAppLinkPress:t=>r.openTarget?.(t),isCitation:t=>CITATION.test(t),...r.features.FigureText?{figureText:toFigureRuns}:{},...r.openCitation?{onOpenCitation:t=>r.openCitation?.(Number(t))}:{},children:t.text})})}
@@ -1 +1 @@
1
- "use strict";import{Button,Card,Chip,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function TicketPart({part:e,turn:t}){const i=useTheme(),{labels:s,openTicket:r}=t,a=s.ticketAria(e.number),n=s.ticketStatus(e.status),l=r?()=>r({ticketId:e.ticketId,number:e.number}):void 0;return _jsx(Card,{variant:"outline",padding:"sm",accessibilityLabel:n?`${a}, ${n}`:a,children:_jsxs(View,{style:{gap:i.space.xs},children:[_jsxs(View,{style:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:i.space.sm},children:[_jsx(Text,{variant:"label",children:a}),n?_jsx(Chip,{size:"sm",variant:"soft",label:n}):null]}),_jsx(Text,{variant:"bodySmall",children:e.subject}),l?_jsx(Button,{label:s.ticketView,variant:"link",size:"sm",onPress:l,testID:`ticket-view-${e.ticketId}`}):null]})})}
1
+ "use strict";import{Button,Card,Chip,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{WEB_STRONG,webProps}from"../chatShared.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function TicketPart({part:e,turn:t}){const i=useTheme(),{labels:s,openTicket:r}=t,a=s.ticketAria(e.number),n=s.ticketStatus(e.status),l=r?()=>r({ticketId:e.ticketId,number:e.number}):void 0;return _jsx(Card,{variant:"outline",padding:"sm",accessibilityLabel:n?`${a}, ${n}`:a,...webProps({role:"article","aria-label":a}),children:_jsxs(View,{style:{gap:i.space.xs},children:[_jsxs(View,{style:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:i.space.sm},children:[_jsx(Text,{variant:"label",children:a}),n?_jsx(Chip,{size:"sm",variant:"soft",label:n}):null]}),_jsx(Text,{variant:"bodySmall",...WEB_STRONG,children:e.subject}),l?_jsx(Button,{label:s.ticketView,variant:"link",size:"sm",onPress:l,testID:`ticket-view-${e.ticketId}`}):null]})})}
@@ -1 +1 @@
1
- "use strict";import{voiceClipBars}from"@webority/chat-core";import{Logger}from"@webority/mobile-core";import{Button,IconButton,Text,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{loadExpoFileSystem}from"../expoModules.js";import{playFile}from"../speech/expoAudio.js";import{discardFile,PhoneSpeechError}from"../speech/phoneSpeech.js";import{audioExtension,formatClipTime}from"../speech/speechText.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const expoFileSystem=()=>{try{return loadExpoFileSystem()}catch{throw new PhoneSpeechError("Unavailable","Unavailable","Voice files are not available in this app.")}};export function VoiceClipPart({part:e,turn:t}){const r=useTheme(),i=useMemo(()=>buildStyles(r),[r]),a=t.labels,[o,s]=useState(!1),[l,c]=useState(!1),[n,u]=useState(!1),[p,m]=useState(0),[h,d]=useState(!1),x=useRef(null),y=useRef(null),f=useRef(!0);useEffect(()=>(f.current=!0,()=>{f.current=!1,x.current?.stop(),x.current=null,null!==y.current&&discardFile(y.current)}),[]);const startPlayback=e=>{const t=playFile(e,e=>{f.current&&(m(e.positionMs),u(e.playing))});x.current=t;const release=()=>!(!f.current||x.current!==t)&&(x.current=null,u(!1),!0);t.finished.then(()=>{release()&&m(0)},e=>{release()&&(c(!0),Logger.error("[chat] voice clip playback failed",e))})},v=t.features.VoiceClips,b=null!==e.transcript&&""!==e.transcript?e.transcript:null,w=e.durationMs>0?Math.min(1,Math.max(0,p/e.durationMs)):0,g=useMemo(()=>voiceClipBars(e.attachmentId,40).map((e,t)=>({id:`bar-${t}`,position:t,level:e})),[e.attachmentId]);return _jsxs(View,{accessibilityRole:"summary",accessibilityLabel:a.voiceClip,testID:"chat-voice-clip",style:i.root,children:[v?_jsxs(View,{style:i.row,children:[_jsx(IconButton,{icon:n?"pause":"play",accessibilityLabel:n?a.voiceClipPause:a.voiceClipPlay,variant:"ghost",tone:"neutral",size:"sm",loading:o,disabled:o,onPress:()=>{const r=x.current;null===r?null===y.current?o||(async()=>{s(!0),c(!1);try{const r=new Uint8Array(await t.readAttachment(e.attachmentId)),{File:i,Paths:a}=expoFileSystem(),o=new i(a.cache,`wchat-clip-${e.attachmentId}${audioExtension(r)}`);if(o.create({overwrite:!0}),o.write(r),!f.current)return void discardFile(o.uri);y.current=o.uri,startPlayback(o.uri)}catch(e){if(!f.current)return;c(!0),Logger.error("[chat] voice clip failed to load",e)}finally{f.current&&s(!1)}})():startPlayback(y.current):n?r.pause():r.resume()},testID:"chat-voice-clip-play"}),_jsx(View,{style:i.wave,children:g.map(e=>_jsx(View,{testID:"chat-voice-clip-bar",style:[i.bar,{height:Math.max(4,Math.round(28*e.level)),backgroundColor:e.position<Math.floor(40*w)?r.colors.primary:r.colors["text-subtle"]}]},e.id))}),_jsx(Text,{variant:"caption",color:"secondary",children:a.voiceClipTime(formatClipTime(p),formatClipTime(e.durationMs))})]}):null,v&&null!==b?_jsxs(_Fragment,{children:[_jsx(Button,{label:h?a.voiceClipHideTranscript:a.voiceClipShowTranscript,variant:"link",size:"sm",accessibilityState:{expanded:h},onPress:()=>d(e=>!e),testID:"chat-voice-clip-transcript-toggle"}),h?_jsx(Text,{variant:"body",children:b}):null]}):null,v||null===b?null:_jsx(Text,{variant:"body",children:b}),l?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:a.voiceClipFailed}):null]})}const buildStyles=e=>StyleSheet.create({root:{gap:e.space.xs},row:{flexDirection:"row",alignItems:"center",gap:e.space.xs},wave:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},bar:{width:3}});
1
+ "use strict";import{voiceClipBars}from"@webority/chat-core";import{Logger}from"@webority/mobile-core";import{Button,IconButton,Text,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{webProps}from"../chatShared.js";import{loadExpoFileSystem}from"../expoModules.js";import{playFile}from"../speech/expoAudio.js";import{discardFile,PhoneSpeechError}from"../speech/phoneSpeech.js";import{audioExtension,formatClipTime}from"../speech/speechText.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const expoFileSystem=()=>{try{return loadExpoFileSystem()}catch{throw new PhoneSpeechError("Unavailable","Unavailable","Voice files are not available in this app.")}};export function VoiceClipPart({part:e,turn:t}){const r=useTheme(),i=useMemo(()=>buildStyles(r),[r]),a=t.labels,[o,s]=useState(!1),[l,c]=useState(!1),[n,u]=useState(!1),[p,m]=useState(0),[h,d]=useState(!1),x=useRef(null),y=useRef(null),f=useRef(!0);useEffect(()=>(f.current=!0,()=>{f.current=!1,x.current?.stop(),x.current=null,null!==y.current&&discardFile(y.current)}),[]);const startPlayback=e=>{const t=playFile(e,e=>{f.current&&(m(e.positionMs),u(e.playing))});x.current=t;const release=()=>!(!f.current||x.current!==t)&&(x.current=null,u(!1),!0);t.finished.then(()=>{release()&&m(0)},e=>{release()&&(c(!0),Logger.error("[chat] voice clip playback failed",e))})},v=t.features.VoiceClips,b=null!==e.transcript&&""!==e.transcript?e.transcript:null,w=e.durationMs>0?Math.min(1,Math.max(0,p/e.durationMs)):0,g=useMemo(()=>voiceClipBars(e.attachmentId,40).map((e,t)=>({id:`bar-${t}`,position:t,level:e})),[e.attachmentId]);return _jsxs(View,{accessibilityRole:"summary",accessibilityLabel:a.voiceClip,...webProps({role:"group"}),testID:"chat-voice-clip",style:i.root,children:[v?_jsxs(View,{style:i.row,children:[_jsx(IconButton,{icon:n?"pause":"play",accessibilityLabel:n?a.voiceClipPause:a.voiceClipPlay,variant:"ghost",tone:"neutral",size:"sm",loading:o,disabled:o,onPress:()=>{const r=x.current;null===r?null===y.current?o||(async()=>{s(!0),c(!1);try{const r=new Uint8Array(await t.readAttachment(e.attachmentId)),{File:i,Paths:a}=expoFileSystem(),o=new i(a.cache,`wchat-clip-${e.attachmentId}${audioExtension(r)}`);if(o.create({overwrite:!0}),o.write(r),!f.current)return void discardFile(o.uri);y.current=o.uri,startPlayback(o.uri)}catch(e){if(!f.current)return;c(!0),Logger.error("[chat] voice clip failed to load",e)}finally{f.current&&s(!1)}})():startPlayback(y.current):n?r.pause():r.resume()},testID:"chat-voice-clip-play"}),_jsx(View,{style:i.wave,children:g.map(e=>_jsx(View,{testID:"chat-voice-clip-bar",style:[i.bar,{height:Math.max(4,Math.round(28*e.level)),backgroundColor:e.position<Math.floor(40*w)?r.colors.primary:r.colors["text-subtle"]}]},e.id))}),_jsx(Text,{variant:"caption",color:"secondary",children:a.voiceClipTime(formatClipTime(p),formatClipTime(e.durationMs))})]}):null,v&&null!==b?_jsxs(_Fragment,{children:[_jsx(Button,{label:h?a.voiceClipHideTranscript:a.voiceClipShowTranscript,variant:"link",size:"sm",accessibilityState:{expanded:h},onPress:()=>d(e=>!e),testID:"chat-voice-clip-transcript-toggle"}),h?_jsx(Text,{variant:"body",children:b}):null]}):null,v||null===b?null:_jsx(Text,{variant:"body",children:b}),l?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:a.voiceClipFailed}):null]})}const buildStyles=e=>StyleSheet.create({root:{gap:e.space.xs},row:{flexDirection:"row",alignItems:"center",gap:e.space.xs},wave:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},bar:{width:3}});
@@ -6,4 +6,5 @@ export declare function messageSignature(message: ChatLiveMessage): string;
6
6
  export declare function openExternalUrl(url: string): void;
7
7
  export declare function defaultOpenTarget(target: string): void;
8
8
  export declare const WEB_STRONG: object;
9
+ export declare const webProps: (props: Record<string, string | number | boolean>) => object;
9
10
  //# sourceMappingURL=chatShared.d.ts.map
@@ -6,4 +6,5 @@ export declare function messageSignature(message: ChatLiveMessage): string;
6
6
  export declare function openExternalUrl(url: string): void;
7
7
  export declare function defaultOpenTarget(target: string): void;
8
8
  export declare const WEB_STRONG: object;
9
+ export declare const webProps: (props: Record<string, string | number | boolean>) => object;
9
10
  //# sourceMappingURL=chatShared.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/mobile-chat",
3
- "version": "0.146.0",
3
+ "version": "0.147.0",
4
4
  "description": "Webority Chat for React Native apps: the chat screen, sheet and embedded shells, thread, composer, one renderer per message part kind and the useChat hook, built on @webority/chat-core and @webority/mobile-ui.",
5
5
  "keywords": [
6
6
  "react-native",
@@ -42,10 +42,10 @@
42
42
  "!**/*.map"
43
43
  ],
44
44
  "peerDependencies": {
45
- "@webority/chat-core": "0.146.0",
46
- "@webority/markdown-core": "^0.163.0",
47
- "@webority/mobile-core": "^0.163.0",
48
- "@webority/mobile-ui": "^0.163.0",
45
+ "@webority/chat-core": "0.147.0",
46
+ "@webority/markdown-core": "^0.165.0",
47
+ "@webority/mobile-core": "^0.165.0",
48
+ "@webority/mobile-ui": "^0.165.0",
49
49
  "expo-audio": ">=58.0.0",
50
50
  "expo-file-system": ">=58.0.0",
51
51
  "react": "^19.3.0",
@@ -95,14 +95,14 @@
95
95
  "@react-native/babel-preset": "0.88.1",
96
96
  "@react-native/jest-preset": "0.88.1",
97
97
  "@react-native/metro-config": "0.88.1",
98
- "@testing-library/react-native": "12.9.0",
98
+ "@testing-library/react-native": "14.1.0",
99
99
  "@types/jest": "29.5.14",
100
100
  "@types/react": "19.3.0",
101
- "@webority/canvas-kit": "0.163.0",
102
- "@webority/chat-core": "0.146.0",
103
- "@webority/markdown-core": "0.163.0",
104
- "@webority/mobile-core": "0.163.0",
105
- "@webority/mobile-ui": "0.163.0",
101
+ "@webority/canvas-kit": "0.165.0",
102
+ "@webority/chat-core": "0.147.0",
103
+ "@webority/markdown-core": "0.165.0",
104
+ "@webority/mobile-core": "0.165.0",
105
+ "@webority/mobile-ui": "0.165.0",
106
106
  "babel-jest": "29.7.0",
107
107
  "expo": "58.0.23",
108
108
  "expo-application": "58.1.2",
@@ -126,8 +126,8 @@
126
126
  "react-native-safe-area-context": "5.11.1",
127
127
  "react-native-svg": "15.16.0",
128
128
  "react-native-worklets": "0.13.0",
129
- "react-test-renderer": "19.3.0",
130
129
  "terser": "5.49.1",
130
+ "test-renderer": "1.3.1",
131
131
  "typescript": "7.0.2"
132
132
  },
133
133
  "scripts": {