@webority/mobile-chat 0.134.0 → 0.135.1

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 (49) hide show
  1. package/lib/commonjs/ChatAppearanceScope.js +1 -0
  2. package/lib/commonjs/ChatComposer.js +1 -1
  3. package/lib/commonjs/ChatEmbed.js +1 -1
  4. package/lib/commonjs/ChatFrame.js +1 -1
  5. package/lib/commonjs/ChatLauncher.js +1 -0
  6. package/lib/commonjs/ChatPanel.js +1 -0
  7. package/lib/commonjs/ChatScreen.js +1 -1
  8. package/lib/commonjs/ChatSheet.js +1 -1
  9. package/lib/commonjs/ChatThread.js +1 -1
  10. package/lib/commonjs/chatShared.js +1 -1
  11. package/lib/commonjs/renderers/ImagePart.js +1 -1
  12. package/lib/commonjs/renderers/InputRequestPart.js +1 -1
  13. package/lib/module/ChatAppearanceScope.js +1 -0
  14. package/lib/module/ChatComposer.js +1 -1
  15. package/lib/module/ChatEmbed.js +1 -1
  16. package/lib/module/ChatFrame.js +1 -1
  17. package/lib/module/ChatLauncher.js +1 -0
  18. package/lib/module/ChatPanel.js +1 -0
  19. package/lib/module/ChatScreen.js +1 -1
  20. package/lib/module/ChatSheet.js +1 -1
  21. package/lib/module/ChatThread.js +1 -1
  22. package/lib/module/chatShared.js +1 -1
  23. package/lib/module/renderers/ImagePart.js +1 -1
  24. package/lib/module/renderers/InputRequestPart.js +1 -1
  25. package/lib/typescript/commonjs/ChatAppearanceScope.d.ts +11 -0
  26. package/lib/typescript/commonjs/ChatComposer.d.ts +4 -2
  27. package/lib/typescript/commonjs/ChatEmbed.d.ts +1 -1
  28. package/lib/typescript/commonjs/ChatFrame.d.ts +9 -4
  29. package/lib/typescript/commonjs/ChatLauncher.d.ts +22 -0
  30. package/lib/typescript/commonjs/ChatPanel.d.ts +39 -0
  31. package/lib/typescript/commonjs/ChatScreen.d.ts +1 -1
  32. package/lib/typescript/commonjs/ChatSheet.d.ts +1 -6
  33. package/lib/typescript/commonjs/chatShared.d.ts +2 -0
  34. package/lib/typescript/commonjs/index.d.ts +1 -1
  35. package/lib/typescript/commonjs/renderers/ImagePart.d.ts +2 -1
  36. package/lib/typescript/commonjs/types.d.ts +19 -1
  37. package/lib/typescript/module/ChatAppearanceScope.d.ts +11 -0
  38. package/lib/typescript/module/ChatComposer.d.ts +4 -2
  39. package/lib/typescript/module/ChatEmbed.d.ts +1 -1
  40. package/lib/typescript/module/ChatFrame.d.ts +9 -4
  41. package/lib/typescript/module/ChatLauncher.d.ts +22 -0
  42. package/lib/typescript/module/ChatPanel.d.ts +39 -0
  43. package/lib/typescript/module/ChatScreen.d.ts +1 -1
  44. package/lib/typescript/module/ChatSheet.d.ts +1 -6
  45. package/lib/typescript/module/chatShared.d.ts +2 -0
  46. package/lib/typescript/module/index.d.ts +1 -1
  47. package/lib/typescript/module/renderers/ImagePart.d.ts +2 -1
  48. package/lib/typescript/module/types.d.ts +19 -1
  49. package/package.json +10 -10
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatAppearanceScope=ChatAppearanceScope;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_jsxRuntime=require("react/jsx-runtime");const DISPLAY_FONT="var(--wui-font-display)",radiusPx=e=>{if(null==e)return null;const r=Number.parseFloat(e);return Number.isFinite(r)?r:null},brandFor=(e,r,i)=>{if(null===e&&null===r&&null===i)return;const n={};return null!==e&&(n.colors={light:{primary:e},dark:{primary:e}}),null!==r&&(n.radius={md:r,lg:r,xl:r}),null!==i&&(n.font={ui:i}),n};function ChatAppearanceScope({appearance:e,children:r}){const i=(0,_mobileUi.useTheme)(),{preference:n}=(0,_mobileUi.useThemeMode)(),t=e?.["--wui-chat-accent"]??null,u=radiusPx(e?.["--wui-chat-radius"]),l=e?.["--wui-chat-font"]===DISPLAY_FONT?i.font.display:null,a=(0,_react.useMemo)(()=>brandFor(t,u,l),[t,u,l]);return void 0===a?(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:r}):(0,_jsxRuntime.jsx)(_mobileUi.ThemeProvider,{initialPreference:n,brand:a,settings:i.settings,children:r},n)}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatComposer=ChatComposer;var _permissions=require("@webority/mobile-core/permissions"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ChatDictationButton=require("./ChatDictationButton.js"),_ChatFooter=require("./ChatFooter.js"),_speechText=require("./speech/speechText.js"),_jsxRuntime=require("react/jsx-runtime");const ALLOWANCE_SHOWN_AT=10,COUNTER_AT=.9,DEFAULT_MAX_LENGTH=4e3,openQuestion=e=>{for(let t=e.length-1;t>=0;t-=1){const s=e[t];for(const e of[...s?.parts??[]].reverse())if("InputRequest"===e.kind&&"Open"===e.state)return e.fields[0]?.label||e.title||null}return null};function ChatComposer({chat:e,labels:t,pickAttachments:s,keyboardOffset:i,keyboardAware:a,safeArea:n,testID:o="chat-composer",focusRef:r}){const l=(0,_mobileUi.useTheme)(),c=(0,_react.useMemo)(()=>buildStyles(l),[l]),[u,m]=(0,_react.useState)(""),[h,p]=(0,_react.useState)(null),d=e.editing,_=(0,_react.useRef)(null),x=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(r)return r.current=()=>x.current?.focus(),()=>{r.current=null}},[r]),(0,_react.useEffect)(()=>{d&&_.current?.(),m(d?d.text:"")},[d]);const f=e.attachments,g=f.some(e=>"Uploading"===e.status),b=f.some(e=>"Ready"===e.status),j=e.messagesLeftToday,v=e.profile?.limits.maxMessageLength??DEFAULT_MAX_LENGTH,y=void 0!==s&&e.features.Attachments&&(e.profile?.limits.maxAttachments??0)>0,R=e.features.HumanHandoff&&("WaitingForAgent"===e.conversationState||"WithAgent"===e.conversationState),A=y&&!e.handoffPause?(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"paperclip",accessibilityLabel:t.attach,variant:"ghost",tone:"neutral",onPress:()=>{s&&s().then(t=>e.attach(t))},testID:`${o}-attach`}):void 0,T=d?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{message:t.editing,accessibilityRole:"summary",actions:[{label:t.cancel,onPress:()=>e.cancelEdit()}],testID:`${o}-editing`}):null,C=f.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:c.tray,testID:`${o}-attachments`,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:c.row,children:f.map(s=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:c.item,children:[(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:s.fileName,variant:"soft",onRemove:()=>{e.removeAttachment(s.key)},labels:{remove:t.removeAttachment},removeTestID:`${o}-remove-${s.key}`,testID:`${o}-chip-${s.key}`}),"Uploading"===s.status?(0,_jsxRuntime.jsx)(_mobileUi.ProgressBar,{progress:s.progress??void 0,label:t.attachmentUploading,height:4,containerStyle:c.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,S=null!==j&&j<=ALLOWANCE_SHOWN_AT?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:0===j?"danger":"secondary",accessibilityLiveRegion:"polite",testID:`${o}-allowance`,children:t.allowance(j)}):null,D=h?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{message:h.message,tone:h.tone,dismissible:!0,onClose:()=>p(null),actions:h.openSettings?[{label:t.dictateOpenSettings,onPress:()=>{_permissions.Permissions.openSettings()}}]:void 0,testID:`${o}-voice-notice`}):null,U=u.length>0,L=u.length>v*COUNTER_AT?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",testID:`${o}-counter`,children:t.counter(u.length,v)}):null,w=T||C||S||L||D?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[T,C,S,L,D]}):void 0,N=!g&&(!!b||void 0),I=!0===e.profile?.experience.motion;return(0,_jsxRuntime.jsx)(_mobileUi.Composer,{ref:x,onSend:t=>{_.current?.(),e.submit(t)},value:u,onChangeText:t=>{_.current?.(),m(t),R&&t.length>0&&e.notifyTyping()},loading:e.streaming&&e.features.Stop,ring:I&&(U||e.streaming),sendReveal:I?"onText":"always",onStop:e.features.Stop?()=>e.stop():void 0,stopLabel:t.stop,disabled:0===j||e.handoffPause,maxLength:v,canSend:N,placeholder:e.handoffPause?t.handoffMoment:openQuestion(e.messages)??t.placeholder,accessibilityLabel:t.composer,labels:{send:t.send},leading:A,trailing:(0,_jsxRuntime.jsx)(_ChatDictationButton.ChatDictationButton,{chat:e,labels:t,disabled:0===j||e.handoffPause,onText:e=>m(t=>(0,_speechText.joinDictation)(t,e,v)),onNotice:p,stopRef:_}),above:w,below:(0,_jsxRuntime.jsx)(_ChatFooter.ChatFooter,{chat:e,labels:t}),keyboardAware:a,keyboardOffset:i,safeArea:n,testID:o})}const buildStyles=e=>_reactNative.StyleSheet.create({tray:{gap:e.space.xs},row:{flexDirection:"row",flexWrap:"wrap",gap:e.space.xs},item:{gap:e.space.xxs,maxWidth:"100%"},progress:{minWidth:120}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatComposer=ChatComposer;var _chatCore=require("@webority/chat-core"),_permissions=require("@webority/mobile-core/permissions"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ChatDictationButton=require("./ChatDictationButton.js"),_ChatFooter=require("./ChatFooter.js"),_speechText=require("./speech/speechText.js"),_jsxRuntime=require("react/jsx-runtime");const ALLOWANCE_SHOWN_AT=10,COUNTER_AT=.9,DEFAULT_MAX_LENGTH=4e3,openQuestion=e=>{for(let t=e.length-1;t>=0;t-=1){const s=e[t];for(const e of[...s?.parts??[]].reverse())if("InputRequest"===e.kind&&"Open"===e.state)return e.fields[0]?.label||e.title||null}return null};function ChatComposer({chat:e,labels:t,pickAttachments:s,keyboardOffset:a,keyboardAware:i,safeArea:n,testID:o="chat-composer",focusRef:r,look:l=_chatCore.defaultChatLook}){const c=(0,_mobileUi.useTheme)(),u=(0,_react.useMemo)(()=>buildStyles(c),[c]),[m,h]=(0,_react.useState)(""),[p,d]=(0,_react.useState)(null),_=e.editing,x=(0,_react.useRef)(null),f=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(r)return r.current=()=>f.current?.focus(),()=>{r.current=null}},[r]),(0,_react.useEffect)(()=>{_&&x.current?.(),h(_?_.text:"")},[_]);const g=e.attachments,b=g.some(e=>"Uploading"===e.status),j=g.some(e=>"Ready"===e.status),v=e.messagesLeftToday,y=e.profile?.limits.maxMessageLength??DEFAULT_MAX_LENGTH,R=void 0!==s&&e.features.Attachments&&(e.profile?.limits.maxAttachments??0)>0,C=e.features.HumanHandoff&&("WaitingForAgent"===e.conversationState||"WithAgent"===e.conversationState),A=R&&!e.handoffPause?(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"paperclip",accessibilityLabel:t.attach,variant:"ghost",tone:"neutral",onPress:()=>{s&&s().then(t=>e.attach(t))},testID:`${o}-attach`}):void 0,T=_?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{message:t.editing,accessibilityRole:"summary",actions:[{label:t.cancel,onPress:()=>e.cancelEdit()}],testID:`${o}-editing`}):null,S=g.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:u.tray,testID:`${o}-attachments`,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:u.row,children:g.map(s=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:u.item,children:[(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:s.fileName,variant:"soft",onRemove:()=>{e.removeAttachment(s.key)},labels:{remove:t.removeAttachment},removeTestID:`${o}-remove-${s.key}`,testID:`${o}-chip-${s.key}`}),"Uploading"===s.status?(0,_jsxRuntime.jsx)(_mobileUi.ProgressBar,{progress:s.progress??void 0,label:t.attachmentUploading,height:4,containerStyle:u.progress}):null,"Failed"===s.status?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:s.error??t.attachmentFailed}):null]},s.key))})}):null,D=null!==v&&v<=ALLOWANCE_SHOWN_AT?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:0===v?"danger":"secondary",accessibilityLiveRegion:"polite",testID:`${o}-allowance`,children:t.allowance(v)}):null,U=p?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{message:p.message,tone:p.tone,dismissible:!0,onClose:()=>d(null),actions:p.openSettings?[{label:t.dictateOpenSettings,onPress:()=>{_permissions.Permissions.openSettings()}}]:void 0,testID:`${o}-voice-notice`}):null,w=m.length>0,L=m.length>y*COUNTER_AT?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",testID:`${o}-counter`,children:t.counter(m.length,y)}):null,N=T||S||D||L||U?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[T,S,D,L,U]}):void 0,k=!b&&(!!j||void 0);return(0,_jsxRuntime.jsx)(_mobileUi.Composer,{ref:f,onSend:t=>{x.current?.(),e.submit(t)},value:m,onChangeText:t=>{x.current?.(),h(t),C&&t.length>0&&e.notifyTyping()},loading:e.streaming&&e.features.Stop,ring:l.input.ring&&(w||e.streaming),sendReveal:"Always"===l.input.sendReveal?"always":"onText",onStop:e.features.Stop?()=>e.stop():void 0,stopLabel:t.stop,disabled:0===v||e.handoffPause,maxLength:y,canSend:k,placeholder:e.handoffPause?t.handoffMoment:openQuestion(e.messages)??t.placeholder,accessibilityLabel:t.composer,labels:{send:t.send},leading:A,trailing:(0,_jsxRuntime.jsx)(_ChatDictationButton.ChatDictationButton,{chat:e,labels:t,disabled:0===v||e.handoffPause,onText:e=>h(t=>(0,_speechText.joinDictation)(t,e,y)),onNotice:d,stopRef:x}),above:N,below:(0,_jsxRuntime.jsx)(_ChatFooter.ChatFooter,{chat:e,labels:t}),keyboardAware:i,keyboardOffset:a,safeArea:n,testID:o})}const buildStyles=e=>_reactNative.StyleSheet.create({tray:{gap:e.space.xs},row:{flexDirection:"row",flexWrap:"wrap",gap:e.space.xs},item:{gap:e.space.xxs,maxWidth:"100%"},progress:{minWidth:120}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatEmbed=ChatEmbed;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_ChatFrame=require("./ChatFrame.js"),_jsxRuntime=require("react/jsx-runtime");function ChatEmbed({chat:e,labels:t,renderers:r,layoutParts:o,loader:a="Steps",motion:i="On",pickAttachments:s,onOpenAttachment:n,onOpenTarget:l,onNavigate:d,openTicket:h,handoffHosts:c,resolveLink:m,keyboardOffset:u,title:b,headerActions:f,onClose:C,height:_=520,testID:p="chat-embed"}){const g=(0,_mobileUi.useTheme)();return null===e.profile||e.features.VisitorChat?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:_,overflow:"hidden",borderRadius:(0,_mobileUi.radiusOf)(g,"lg"),borderWidth:1,borderColor:g.colors["border-subtle"],backgroundColor:g.colors.bg},testID:p,children:(0,_jsxRuntime.jsx)(_ChatFrame.ChatFrame,{chat:e,labels:(0,_chatCore.mergeLabels)(t),renderers:r,layoutParts:o,loader:a,motion:i,pickAttachments:s,onOpenAttachment:n,onOpenTarget:l,onNavigate:d,openTicket:h,handoffHosts:c,resolveLink:m,keyboardOffset:u,layout:"embedded",title:b,headerActions:f,onClose:C,testID:`${p}-frame`})}):null}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatEmbed=ChatEmbed;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_ChatAppearanceScope=require("./ChatAppearanceScope.js"),_ChatFrame=require("./ChatFrame.js"),_jsxRuntime=require("react/jsx-runtime");const EmbedBox=({height:e,testID:t,children:r})=>{const a=(0,_mobileUi.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:e,overflow:"hidden",borderRadius:(0,_mobileUi.radiusOf)(a,"lg"),borderWidth:1,borderColor:a.colors["border-subtle"],backgroundColor:a.colors.bg},testID:t,children:r})};function ChatEmbed({chat:e,labels:t,renderers:r,layoutParts:a,loader:o="Steps",look:i,appearance:s,pickAttachments:n,onOpenAttachment:c,onOpenTarget:h,onNavigate:l,openTicket:d,handoffHosts:u,resolveLink:p,keyboardOffset:m,title:b,headerActions:C,onClose:_,height:f=520,testID:x="chat-embed"}){return null===e.profile||e.features.VisitorChat?(0,_jsxRuntime.jsx)(_ChatAppearanceScope.ChatAppearanceScope,{appearance:s,children:(0,_jsxRuntime.jsx)(EmbedBox,{height:f,testID:x,children:(0,_jsxRuntime.jsx)(_ChatFrame.ChatFrame,{chat:e,labels:(0,_chatCore.mergeLabels)(t),renderers:r,layoutParts:a,loader:o,look:i,pickAttachments:n,onOpenAttachment:c,onOpenTarget:h,onNavigate:l,openTicket:d,handoffHosts:u,resolveLink:p,keyboardOffset:m,layout:"embedded",title:b,headerActions:C,onClose:_,testID:`${x}-frame`})})}):null}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatFrame=ChatFrame;var _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"),_ChatStarters=require("./ChatStarters.js"),_ChatThread=require("./ChatThread.js"),_useChatHaptics=require("./useChatHaptics.js"),_useChatSound=require("./useChatSound.js"),_jsxRuntime=require("react/jsx-runtime");function ChatFrame({chat:e,labels:t,renderers:s,layoutParts:a,loader:r="Steps",motion:i="On",pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:u,openTicket:c,handoffHosts:m,resolveLink:h,keyboardOffset:d,layout:_,title:x,headerActions:C,onClose:j,testID:b="chat-frame"}){const p=(0,_mobileUi.useTheme)(),[f,v]=(0,_react.useState)(!1),y=f&&!0===e.features.History;(0,_useChatHaptics.useChatHaptics)(e),(0,_useChatSound.useChatSound)(e);const R="sheet"!==_,g=null!==e.profile,k=(0,_react.useRef)(null);if(g&&!e.features.VisitorChat)return null;const I=e.messages.length>0,D=e.messages.some(e=>"Visitor"===e.author.kind||"Customer"===e.author.kind),S="screen"===_||D,T=!0===e.profile?.experience.sound.muteControl&&e.features.Sounds,H=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:p.space.sm,paddingHorizontal:p.space.md,paddingVertical:p.space.sm,borderBottomWidth:1,borderBottomColor:p.colors["border-subtle"]},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1,minWidth:0},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"title",accessibilityRole:"header",numberOfLines:1,children:x??e.profile?.assistant.name??t.panelTitle}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:t.headerStatus})]}),C,y?null:(0,_jsxRuntime.jsx)(_ChatConversationActions.ChatConversationActions,{chat:e,labels:t,testID:`${b}-conversation-actions`}),T?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:e.muted?t.unmuteSounds:t.muteSounds,variant:"link",size:"sm",onPress:()=>e.session.setMuted(!e.muted),testID:`${b}-mute`}):null,e.features.History?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:y?t.backToChat:t.history,variant:"link",size:"sm",onPress:()=>v(e=>!e),testID:`${b}-history`}):null,y||!S?null:(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:t.newChat,size:"sm",variant:"soft",leftIcon:"add",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 $=y?(0,_jsxRuntime.jsx)(_ChatHistory.ChatHistory,{chat:e,labels:t,onOpen:()=>v(!1),testID:`${b}-history-list`}):e.profileError?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"danger",message:e.profileError.message,accessibilityRole:"alert",testID:`${b}-profile-error`}):!g||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`}):I?(0,_jsxRuntime.jsx)(_ChatThread.ChatThread,{chat:e,labels:t,renderers:s,layoutParts:a,loader:r,motion:i,pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:u,openTicket:c,handoffHosts:m,resolveLink:h,focusComposer:()=>k.current?.(),keyboardAware:R,keyboardOffset:d,style:{flex:1},testID:`${b}-thread`}):(0,_jsxRuntime.jsx)(_ChatStarters.ChatStarters,{chat:e,labels:t,openTicket:c,testID:`${b}-starters`}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1},testID:b,children:[H,y?null:(0,_jsxRuntime.jsx)(_ChatLiveBar.ChatLiveBar,{chat:e,labels:t,testID:`${b}-live`}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1},children:$}),y?null:(0,_jsxRuntime.jsx)(_ChatComposer.ChatComposer,{chat:e,labels:t,pickAttachments:n,keyboardOffset:d,keyboardAware:R,focusRef:k,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"),_useChatHaptics=require("./useChatHaptics.js"),_useChatSound=require("./useChatSound.js"),_jsxRuntime=require("react/jsx-runtime");function ChatFrame({chat:e,labels:t,renderers:s,layoutParts:a,loader:r="Steps",look:i,pickAttachments:o,onOpenAttachment:n,onOpenTarget:l,onNavigate:u,openTicket:c,handoffHosts:h,resolveLink:m,keyboardOffset:d,layout:_,title:C,headerActions:x,onClose:j,enterKey:b=0,testID:p="chat-frame"}){const v=(0,_mobileUi.useTheme)(),f=(0,_react.useMemo)(()=>(0,_chatCore.mergeLook)(i),[i]),y=(0,_mobileUi.useReducedMotion)(),R="Reduced"===f.motion||y,g="embedded"===_?"None":f.panel.motion,I="sheet"===_?"sheet":"screen",k=(0,_react.useMemo)(()=>(0,_ChatPanel.panelRun)({motion:g,reduced:R,mode:I,run:b}),[g,R,I,b]),[w,D]=(0,_react.useState)(!1),P=w&&!0===e.features.History;(0,_useChatHaptics.useChatHaptics)(e),(0,_useChatSound.useChatSound)(e);const S="sheet"!==_,q=null!==e.profile,T=(0,_react.useRef)(null);if(q&&!e.features.VisitorChat)return null;const H=e.messages.length>0,$=e.messages.some(e=>"Visitor"===e.author.kind||"Customer"===e.author.kind),A="screen"===_||$,B=!0===e.profile?.experience.sound.muteControl&&e.features.Sounds,L=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:v.space.sm,paddingHorizontal:v.space.md,paddingVertical:v.space.sm,borderBottomWidth:1,borderBottomColor:v.colors["border-subtle"]},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1,minWidth:0},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"title",accessibilityRole:"header",numberOfLines:1,children:C??e.profile?.assistant.name??t.panelTitle}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:t.headerStatus})]}),x,P?null:(0,_jsxRuntime.jsx)(_ChatConversationActions.ChatConversationActions,{chat:e,labels:t,testID:`${p}-conversation-actions`}),e.features.History?(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:P?"arrow-left":"history",variant:"ghost",tone:"neutral",accessibilityLabel:P?t.backToChat:t.history,onPress:()=>D(e=>!e),testID:`${p}-history`}):null,B?(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:e.muted?"volume-mute":"volume-high",variant:"ghost",tone:"neutral",accessibilityLabel:e.muted?t.unmuteSounds:t.muteSounds,onPress:()=>e.session.setMuted(!e.muted),testID:`${p}-mute`}):null,P||!A?null:(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"plus",variant:"ghost",tone:"neutral",accessibilityLabel:t.newChat,disabled:e.streaming||e.thinking,onPress:()=>e.newConversation(),testID:`${p}-new`}),j?(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"x",variant:"ghost",tone:"neutral",accessibilityLabel:t.close,onPress:j,testID:`${p}-close`}):null]});let U;return U=P?(0,_jsxRuntime.jsx)(_ChatHistory.ChatHistory,{chat:e,labels:t,onOpen:()=>D(!1),testID:`${p}-history-list`}):e.profileError?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"danger",message:e.profileError.message,accessibilityRole:"alert",testID:`${p}-profile-error`}):!q||e.loading?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,alignItems:"center",justifyContent:"center"},children:(0,_jsxRuntime.jsx)(_mobileUi.Spinner,{message:t.loadingConversation,testID:`${p}-loading`})}):e.loadError?(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"danger",message:e.loadError.message,accessibilityRole:"alert",testID:`${p}-load-error`}):H?(0,_jsxRuntime.jsx)(_ChatThread.ChatThread,{chat:e,labels:t,renderers:s,layoutParts:a,loader:r,motion:f.motion,pickAttachments:o,onOpenAttachment:n,onOpenTarget:l,onNavigate:u,openTicket:c,handoffHosts:h,resolveLink:m,focusComposer:()=>T.current?.(),keyboardAware:S,keyboardOffset:d,style:{flex:1},testID:`${p}-thread`}):(0,_jsxRuntime.jsx)(_ChatStarters.ChatStarters,{chat:e,labels:t,openTicket:c,testID:`${p}-starters`}),(0,_jsxRuntime.jsx)(_ChatPanel.ChatPanelGrow,{grow:k.grow,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1},testID:p,children:[(0,_jsxRuntime.jsx)(_ChatPanel.ChatReveal,{plan:k.reveal.header,children:L}),P?null:(0,_jsxRuntime.jsx)(_ChatLiveBar.ChatLiveBar,{chat:e,labels:t,testID:`${p}-live`}),(0,_jsxRuntime.jsx)(_ChatPanel.ChatReveal,{plan:k.reveal.body,flex:!0,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1},children:U})}),P?null:(0,_jsxRuntime.jsx)(_ChatPanel.ChatReveal,{plan:k.reveal.composer,children:(0,_jsxRuntime.jsx)(_ChatComposer.ChatComposer,{chat:e,labels:t,look:f,pickAttachments:o,keyboardOffset:d,keyboardAware:S,focusRef:T,testID:`${p}-composer`})})]})})}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatLauncher=ChatLauncher;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_jsxRuntime=require("react/jsx-runtime");const RISE_MS=900,RISE_DELAY_MS=400,ENTRANCE_MS=800,ENTRANCE_DELAY_MS=1e3,FLOAT_HALF_MS=1600,FLOAT_PX=4,RISE_FROM_PX=116;function entranceStyle(e,t){const range=(e,a)=>t.interpolate({inputRange:e,outputRange:a,extrapolate:"clamp"});switch(e){case"Rise":return{opacity:range([0,.4,1],[0,1,1]),transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[116,0]})}]};case"SlideUp":return{opacity:range([0,1],[0,1]),transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[100,0]})},{scale:t.interpolate({inputRange:[0,1],outputRange:[.8,1]})}]};case"BounceIn":return{transform:[{scale:range([0,.5,.7,1],[.3,1.05,.9,1])}]};case"FadeInPulse":return{opacity:range([0,.5,1],[0,1,1]),transform:[{scale:range([0,.5,1],[1,1.1,1])}]};case"SpinScale":return{transform:[{rotate:t.interpolate({inputRange:[0,1],outputRange:["-180deg","0deg"]})},{scale:t.interpolate({inputRange:[0,1],outputRange:[0,1]})}]};case"WiggleIn":return{transform:[{translateY:range([0,.4,1],[100,0,0])},{rotate:range([0,.4,.6,.8,1],["-10deg","5deg","-3deg","1deg","0deg"])}]};case"ElasticIn":return{transform:[{scale:range([0,.55,.75,1],[0,1.1,.95,1])}]};default:return{transform:[]}}}const OVERSHOOT=new Set(["Rise","SlideUp","SpinScale"]);function ChatLauncher({look:e,label:t,side:a,offsetX:n,offsetY:r,enter:i,reduced:s,buttonRef:o,onPress:c,testID:u}){const l=(0,_mobileUi.useTheme)(),_=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),p=e.launcher.entrance,[g]=(0,_react.useState)(()=>i&&!s&&"None"!==p),d=!s&&"FloatAndPulse"===e.launcher.idle,[m]=(0,_react.useState)(()=>new _reactNative.Animated.Value(g?0:1)),[S]=(0,_react.useState)(()=>new _reactNative.Animated.Value(0));(0,_react.useEffect)(()=>{if(!g)return void m.setValue(1);const e="Rise"===p,t=_reactNative.Animated.timing(m,{toValue:1,duration:e?RISE_MS:ENTRANCE_MS,delay:e?RISE_DELAY_MS:ENTRANCE_DELAY_MS,easing:OVERSHOOT.has(p)?_reactNative.Easing.bezier(.34,e?1.4:1.56,.64,1):_reactNative.Easing.linear,useNativeDriver:!0});return t.start(),()=>t.stop()},[g,p,m]),(0,_react.useEffect)(()=>{if(!d)return void S.setValue(0);const e=_reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(S,{toValue:1,duration:FLOAT_HALF_MS,easing:_reactNative.Easing.inOut(_reactNative.Easing.ease),useNativeDriver:!0}),_reactNative.Animated.timing(S,{toValue:0,duration:FLOAT_HALF_MS,easing:_reactNative.Easing.inOut(_reactNative.Easing.ease),useNativeDriver:!0})]));return e.start(),()=>e.stop()},[d,S]);const f="Pill"===e.launcher.style&&!e.launcher.compact,R=l.space[l.components["floating-action-button"]["edge-offset"]]+n,v={position:"absolute",bottom:r+_.bottom,..."start"===a?{left:R}:{right:R}},N=entranceStyle(p,m);return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"box-none",style:_reactNative.StyleSheet.absoluteFill,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[v,{opacity:N.opacity??1,transform:[...N.transform,{translateY:S.interpolate({inputRange:[0,1],outputRange:[0,-FLOAT_PX]})}]}],children:(0,_jsxRuntime.jsx)(_mobileUi.FloatingActionButton,{ref:o,icon:"messages",label:f?t:void 0,collapsed:!f,accessibilityLabel:t,onPress:c,testID:u})})})}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatPanelGrow=ChatPanelGrow,exports.ChatReveal=ChatReveal,exports.panelRun=void 0;var _react=require("react"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const SPRING_DELAY={header:110,body:160,composer:240},revealFor=(e,t,a,r)=>a?null:"Spring"===e?{run:r,delay:SPRING_DELAY[t],duration:260,distance:10}:"Gentle"===e?{run:r,delay:0,duration:250,distance:12}:null,panelRun=e=>{const{motion:t,reduced:a,mode:r,run:n}=e;return{grow:"Spring"!==t||a||"screen"!==r?null:{run:n},reveal:{header:revealFor(t,"header",a,n),body:revealFor(t,"body",a,n),composer:revealFor(t,"composer",a,n)}}};exports.panelRun=panelRun;const SPRING={stiffness:200,damping:22.4,mass:1,useNativeDriver:!0};function ChatReveal({plan:e,flex:t=!1,children:a}){const[r]=(0,_react.useState)(()=>new _reactNative.Animated.Value(null===e?1:0));(0,_react.useEffect)(()=>{if(null===e)return void r.setValue(1);r.setValue(0);const t=_reactNative.Animated.timing(r,{toValue:1,duration:e.duration,delay:e.delay,useNativeDriver:!0});return t.start(),()=>t.stop()},[e,r]);const n=e?.distance??0;return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{flex:t?1:void 0,opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[n,0]})}]},children:a})}function ChatPanelGrow({grow:e,children:t}){const[a]=(0,_react.useState)(()=>new _reactNative.Animated.Value(null===e?1:0)),[r,n]=(0,_react.useState)({width:0,height:0});(0,_react.useEffect)(()=>{if(null===e)return void a.setValue(1);a.setValue(0);const t=_reactNative.Animated.spring(a,{toValue:1,...SPRING});return t.start(),()=>t.stop()},[e,a]);const i=[{translateY:a.interpolate({inputRange:[0,1],outputRange:[r.height,0]})}];return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{onLayout:e=>{const{width:t,height:a}=e.nativeEvent.layout;n(e=>e.width===t&&e.height===a?e:{width:t,height:a})},style:{flex:1,transform:i},children:t})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatScreen=ChatScreen;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_ChatFrame=require("./ChatFrame.js"),_jsxRuntime=require("react/jsx-runtime");function ChatScreen({chat:e,labels:t,renderers:r,layoutParts:a,loader:o="Steps",motion:n="On",pickAttachments:s,onOpenAttachment:i,onOpenTarget:c,onNavigate:l,openTicket:h,handoffHosts:u,resolveLink:m,keyboardOffset:d,title:f,headerActions:b,onClose:p,testID:C="chat-screen"}){const _=(0,_mobileUi.useTheme)();return null===e.profile||e.features.VisitorChat?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,backgroundColor:_.colors.bg},testID:C,children:(0,_jsxRuntime.jsx)(_ChatFrame.ChatFrame,{chat:e,labels:(0,_chatCore.mergeLabels)(t),renderers:r,layoutParts:a,loader:o,motion:n,pickAttachments:s,onOpenAttachment:i,onOpenTarget:c,onNavigate:l,openTicket:h,handoffHosts:u,resolveLink:m,keyboardOffset:d,layout:"screen",title:f,headerActions:b,onClose:p,testID:`${C}-frame`})}):null}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatScreen=ChatScreen;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_ChatAppearanceScope=require("./ChatAppearanceScope.js"),_ChatFrame=require("./ChatFrame.js"),_jsxRuntime=require("react/jsx-runtime");function ChatScreen({chat:e,labels:t,renderers:a,layoutParts:r,loader:o="Steps",look:n,appearance:s,pickAttachments:c,onOpenAttachment:i,onOpenTarget:l,onNavigate:h,openTicket:p,handoffHosts:u,resolveLink:m,keyboardOffset:C,title:_,headerActions:d,onClose:f,testID:b="chat-screen"}){const j=(0,_mobileUi.useTheme)();return null===e.profile||e.features.VisitorChat?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,backgroundColor:j.colors.bg},testID:b,children:(0,_jsxRuntime.jsx)(_ChatAppearanceScope.ChatAppearanceScope,{appearance:s,children:(0,_jsxRuntime.jsx)(_ChatFrame.ChatFrame,{chat:e,labels:(0,_chatCore.mergeLabels)(t),renderers:a,layoutParts:r,loader:o,look:n,pickAttachments:c,onOpenAttachment:i,onOpenTarget:l,onNavigate:h,openTicket:p,handoffHosts:u,resolveLink:m,keyboardOffset:C,layout:"screen",title:_,headerActions:d,onClose:f,testID:`${b}-frame`})})}):null}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatSheet=ChatSheet;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ChatFrame=require("./ChatFrame.js"),_ChatNudge=require("./ChatNudge.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_SNAP_POINTS=["92%"];function ChatSheet({chat:e,labels:t,renderers:s,layoutParts:o,loader:n="Steps",motion:r="On",pickAttachments:a,onOpenAttachment:i,onOpenTarget:l,onNavigate:c,keyboardOffset:u,open:f,defaultOpen:h=!1,onOpenChange:p,position:m="end",bottomOffset:_=16,snapPoints:b=DEFAULT_SNAP_POINTS,compact:d=!1,openTicket:g,handoffHosts:C,resolveLink:j,conversationId:v,onClose:x,testID:N="chat-sheet"}){const y=(0,_mobileUi.useTheme)(),O=(0,_chatCore.mergeLabels)(t),A=void 0!==f,P=A?f:e.open,R=(0,_react.useRef)(null),k=(0,_react.useRef)(!1),T=(0,_react.useRef)(v??null),I=e.setChatVisible;(0,_react.useEffect)(()=>{k.current||(k.current=!0,A||!h||null===e.profile||e.open||e.session.open({trigger:"manual"}))},[A,h,e.profile,e.open,e.session]),(0,_react.useEffect)(()=>{A&&(f&&!e.open&&e.session.open({trigger:"manual"}),!f&&e.open&&e.session.close("button"))},[A,f,e.open,e.session]);const S=(0,_react.useRef)(P);if((0,_react.useEffect)(()=>{if(S.current&&!P){const e=(0,_reactNative.findNodeHandle)(R.current);null!==e&&_reactNative.AccessibilityInfo.setAccessibilityFocus(e)}S.current=P},[P]),(0,_react.useEffect)(()=>{I(P)},[I,P]),(0,_react.useEffect)(()=>{!A&&v&&v!==T.current&&null!==e.profile&&(T.current=v,e.open||(e.session.open({trigger:"manual"}),p?.(!0)))},[A,v,e.profile,e.open,e.session,p]),null===e.profile||!e.features.VisitorChat)return null;const setOpen=t=>{t?e.session.open({trigger:"manual"}):e.session.close("button"),p?.(t)},closeSheet=()=>{setOpen(!1),x?.()},D="start"===m?"bottomLeft":"bottomRight";return(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:N,children:[P?null:(0,_jsxRuntime.jsx)(_mobileUi.FloatingActionButton,{ref:R,icon:"messages",label:d?void 0:O.launcher,position:D,bottomOffset:_,accessibilityLabel:O.launcher,onPress:()=>setOpen(!0),testID:`${N}-launcher`}),(0,_jsxRuntime.jsx)(_ChatNudge.ChatNudge,{chat:e,labels:O,enabled:!P&&e.features.Nudges,onActivate:()=>setOpen(!0),bottomOffset:_,position:m,testID:`${N}-nudge`}),(0,_jsxRuntime.jsx)(_mobileUi.BottomSheet,{open:P,onClose:closeSheet,snapPoints:b,keyboardBehavior:"shift",scrollable:!1,enablePanDownToClose:!0,enableBackdropPress:!0,accessibilityViewIsModal:!0,accessibilityLabel:O.panelTitle,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,backgroundColor:y.colors.bg},children:(0,_jsxRuntime.jsx)(_ChatFrame.ChatFrame,{chat:e,labels:O,renderers:s,layoutParts:o,loader:n,motion:r,pickAttachments:a,onOpenAttachment:i,onOpenTarget:l,onNavigate:c,openTicket:g,handoffHosts:C,resolveLink:j,keyboardOffset:u,onClose:closeSheet,layout:"sheet",testID:`${N}-frame`})})})]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatSheet=ChatSheet;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_ChatAppearanceScope=require("./ChatAppearanceScope.js"),_ChatFrame=require("./ChatFrame.js"),_ChatLauncher=require("./ChatLauncher.js"),_ChatNudge=require("./ChatNudge.js"),_chatShared=require("./chatShared.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_SNAP_POINTS=["92%"],DEFAULT_BOTTOM_OFFSET=16;function ChatSheet({chat:e,labels:t,renderers:r,layoutParts:a,loader:s="Steps",look:n,appearance:o,pickAttachments:c,onOpenAttachment:i,onOpenTarget:u,onNavigate:l,keyboardOffset:h,open:p,defaultOpen:_=!1,onOpenChange:f,snapPoints:d=DEFAULT_SNAP_POINTS,openTicket:m,handoffHosts:b,resolveLink:C,conversationId:g,onClose:j,testID:S="chat-sheet"}){const x=(0,_mobileUi.useTheme)(),T=(0,_chatCore.mergeLabels)(t),O=(0,_react.useMemo)(()=>(0,_chatCore.mergeLook)(n),[n]),R=(0,_mobileUi.useReducedMotion)(),v="Reduced"===O.motion||R,y=o?.position??"end",A=void 0!==p,k=A?p:e.open,N=(0,_react.useRef)(null),E=(0,_react.useRef)(!1),F=(0,_react.useRef)(g??null),L=e.setChatVisible,P=(0,_react.useRef)(!1),q=!P.current,[D,I]=(0,_react.useState)(0),U=(0,_react.useRef)(k);(0,_react.useEffect)(()=>{k&&(P.current=!0)},[k]),(0,_react.useEffect)(()=>{k&&!U.current&&I(e=>e+1),U.current=k},[k]),(0,_react.useEffect)(()=>{E.current||(E.current=!0,A||!_||null===e.profile||e.open||e.session.open({trigger:"manual"}))},[A,_,e.profile,e.open,e.session]),(0,_react.useEffect)(()=>{A&&(p&&!e.open&&e.session.open({trigger:"manual"}),!p&&e.open&&e.session.close("button"))},[A,p,e.open,e.session]);const w=(0,_react.useRef)(k);if((0,_react.useEffect)(()=>{w.current&&!k&&(0,_chatShared.focusForAccessibility)(N.current),w.current=k},[k]),(0,_react.useEffect)(()=>{L(k)},[L,k]),(0,_react.useEffect)(()=>{!A&&g&&g!==F.current&&null!==e.profile&&(F.current=g,e.open||(e.session.open({trigger:"manual"}),f?.(!0)))},[A,g,e.profile,e.open,e.session,f]),null===e.profile||!e.features.VisitorChat)return null;const setOpen=t=>{t?e.session.open({trigger:"manual"}):e.session.close("button"),f?.(t)},closeSheet=()=>{setOpen(!1),j?.()},M=o?.offsetY??DEFAULT_BOTTOM_OFFSET;return(0,_jsxRuntime.jsx)(_reactNative.View,{testID:S,style:_reactNative.StyleSheet.absoluteFill,pointerEvents:"box-none",children:(0,_jsxRuntime.jsxs)(_ChatAppearanceScope.ChatAppearanceScope,{appearance:o,children:[k?null:(0,_jsxRuntime.jsx)(_ChatLauncher.ChatLauncher,{look:O,label:T.launcher,side:y,offsetX:o?.offsetX??0,offsetY:M,enter:q,reduced:v,buttonRef:N,onPress:()=>setOpen(!0),testID:`${S}-launcher`}),(0,_jsxRuntime.jsx)(_ChatNudge.ChatNudge,{chat:e,labels:T,enabled:!k&&e.features.Nudges,onActivate:()=>setOpen(!0),bottomOffset:M,position:y,testID:`${S}-nudge`}),(0,_jsxRuntime.jsx)(_mobileUi.BottomSheet,{open:k,onClose:closeSheet,snapPoints:d,keyboardBehavior:"shift",scrollable:!1,enablePanDownToClose:!0,enableBackdropPress:!0,accessibilityViewIsModal:!0,accessibilityLabel:T.panelTitle,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,backgroundColor:x.colors.bg},children:(0,_jsxRuntime.jsx)(_ChatFrame.ChatFrame,{chat:e,labels:T,renderers:r,layoutParts:a,loader:s,look:n,pickAttachments:c,onOpenAttachment:i,onOpenTarget:u,onNavigate:l,openTicket:m,handoffHosts:b,resolveLink:C,keyboardOffset:h,onClose:closeSheet,layout:"sheet",enterKey:D,testID:`${S}-frame`})})})]})})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatThread=ChatThread;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_AgentByline=require("./AgentByline.js"),_ChatEntrance=require("./ChatEntrance.js"),_ChatMessageActions=require("./ChatMessageActions.js"),_chatShared=require("./chatShared.js"),_ChatLoader=require("./loaders/ChatLoader.js"),_TypingPill=require("./loaders/TypingPill.js"),_index=require("./renderers/index.js"),_NoticePart=require("./renderers/NoticePart.js"),_jsxRuntime=require("react/jsx-runtime");const MINE=new Set(["Visitor","Customer"]),joinedText=e=>e.filter(e=>"Text"===e.kind).map(e=>e.text).join("\n\n"),renderPart=(e,t,s,a,i,r)=>{const n=e[t.kind];if(n)return(0,_react.createElement)(n,{key:r,part:t,message:s,turn:a,pickAttachments:i});const o={kind:"Notice",code:"NeedsNewerApp",text:a.labels.needsNewerApp};return(0,_react.createElement)(_NoticePart.NoticePart,{key:r,part:o,message:s,turn:a})},sameMessage=(e,t)=>e.signature===t.signature&&e.message.id===t.message.id&&e.message.rating===t.message.rating&&e.message.stored===t.message.stored&&e.groupPosition===t.groupPosition&&e.isLast===t.isLast&&e.handoffSettled===t.handoffSettled&&e.isLastVisitor===t.isLastVisitor&&e.thinking===t.thinking&&e.streaming===t.streaming&&e.pickAttachments===t.pickAttachments&&e.labels===t.labels&&e.all===t.all&&e.layoutParts===t.layoutParts&&e.chat.session===t.chat.session&&e.chat.features===t.chat.features&&e.chat.onNavigate===t.chat.onNavigate&&e.onNavigate===t.onNavigate&&e.onOpenAttachment===t.onOpenAttachment&&e.onOpenTarget===t.onOpenTarget&&e.openTicket===t.openTicket&&e.resolveLink===t.resolveLink&&e.focusComposer===t.focusComposer&&e.byline===t.byline&&e.handoffHosts===t.handoffHosts;function ThreadMessageView({chat:e,message:t,labels:s,all:a,layoutParts:i,groupPosition:r,isLast:n,isLastVisitor:o,pickAttachments:l,onOpenAttachment:c,onOpenTarget:u,onNavigate:d,openTicket:g,handoffHosts:m,resolveLink:h,focusComposer:p,byline:_,sourceRows:x,testID:y}){const f=(0,_mobileUi.useTheme)(),j=Object.assign((0,_chatCore.createTurnApi)(e.session,{messageId:t.id,labels:s,openAttachment:c,openTarget:u??_chatShared.defaultOpenTarget,onNavigate:d??e.onNavigate,openTicket:g,handoffHosts:m,openCitation:e=>(e=>{const t=x.current.get(e),s=t?(0,_reactNative.findNodeHandle)(t):null;null!==s&&_reactNative.AccessibilityInfo.setAccessibilityFocus(s)})(String(e))}),{resolveLink:h,focusComposer:p,registerSourceRow:(e,t)=>{t?x.current.set(e,t):x.current.delete(e)}});let T=0;const nextSlot=()=>(T+=1,T),b=(0,_jsxRuntime.jsx)(_ChatMessageActions.ChatMessageActions,{chat:e,message:t,labels:s,isLast:n,isLastVisitor:o,testID:`${y}-actions`});if(MINE.has(t.author.kind)){const e=t.parts.filter(e=>"File"===e.kind),i=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:f.space.xs},children:[e.map(e=>renderPart(a,e,t,j,l,`${t.id}-file-${nextSlot()}`)),b]});return(0,_jsxRuntime.jsx)(_mobileUi.MessageBubble,{side:"mine",text:joinedText(t.parts),labels:{you:s.you},groupPosition:r,footer:i,testID:y})}const k="Agent"===t.author.kind,N=t.author.displayName||s.agent,v=(i?i(t):t.parts).map(e=>Array.isArray(e)?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:f.space.xs},children:e.map(e=>renderPart(a,e,t,j,l,`${t.id}-part-${nextSlot()}`))},`${t.id}-group-${nextSlot()}`):renderPart(a,e,t,j,l,`${t.id}-item-${nextSlot()}`)),A=k&&_?[(0,_jsxRuntime.jsx)(_AgentByline.AgentByline,{author:t.author,labels:s},`${t.id}-byline`),...v]:v,R=(0,_chatCore.messagePlainText)(t.parts);return(0,_jsxRuntime.jsx)(_mobileUi.MessageBubble,{side:"theirs",author:k?void 0:t.author.displayName||s.assistant,text:k?`${s.agentSays(N)} ${R}`:R,streaming:t.streaming,groupPosition:r,footer:b,testID:y,children:A})}const ThreadMessage=(0,_react.memo)(ThreadMessageView,sameMessage),TYPING_ORB_MARK=14,TYPING_ASSISTANT_MARK=8,TypingMark=({size:e})=>{const t=(0,_mobileUi.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:e,height:e,borderRadius:t.radius.pill,backgroundColor:t.colors.primary}})},TYPING_DOT=6,TypingDots=()=>{const e=(0,_mobileUi.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},children:[0,1,2].map(t=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:6,height:6,borderRadius:3,backgroundColor:e.colors["text-muted"]}},t))})},TurnGap=()=>{const e=(0,_mobileUi.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:e.space.lg}})},followNew=()=>!0;function ChatThread({chat:e,labels:t,renderers:s,layoutParts:a,loader:i="Steps",motion:r="On",pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:c,openTicket:u,handoffHosts:d,resolveLink:g,focusComposer:m,keyboardAware:h,keyboardOffset:p,empty:_,style:x,testID:y="chat-thread"}){const f=(0,_mobileUi.useTheme)(),j=(0,_react.useMemo)(()=>({..._index.defaultRenderers,...s}),[s]),T=e.messages[0],b=e.greeting??"",k=(0,_react.useMemo)(()=>""!==b&&void 0!==T&&MINE.has(T.author.kind)?{...T,id:"greeting",author:{...T.author,kind:"Assistant",displayName:null,avatarUrl:null},parts:[{kind:"Text",text:b}],stored:!1,streaming:!1,restored:!1,rating:null}:null,[b,T]),N=(0,_react.useMemo)(()=>{const t=e.messages.filter(e=>!(e.streaming&&0===e.parts.length)).reverse();return k?[...t,k]:t},[e.messages,k]),v=e.messages[e.messages.length-1]?.id,A=(0,_react.useRef)(new Map),R=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(null!==R.current)for(const s of e.messages){if(MINE.has(s.author.kind)||s.streaming||s.restored||R.current.has(s.id))continue;if("Agent"===s.author.kind&&!s.stored)continue;R.current.add(s.id);const e=(0,_chatCore.messagePlainText)(s.parts);""!==e&&_reactNative.AccessibilityInfo.announceForAccessibility("Agent"===s.author.kind?`${t.agentSays(s.author.displayName||t.agent)} ${e}`:e)}else R.current=new Set(e.messages.map(e=>e.id))},[e.messages,t]);const w=(0,_react.useMemo)(()=>{for(let t=e.messages.length-1;t>=0;t-=1){const s=e.messages[t];if(s?.stored&&"Visitor"===s.author.kind)return s.id}},[e.messages]),P=(0,_react.useMemo)(()=>{const t=new Set;return e.messages.forEach((s,a)=>{if("Agent"!==s.author.kind)return;const i=e.messages[a-1];"Agent"===i?.author.kind&&(i.author.displayName||"")===(s.author.displayName||"")||t.add(s.id)}),t},[e.messages]),M=(0,_react.useMemo)(()=>(0,_chatCore.handoffSettledIds)(e.messages),[e.messages]),C=e.turnError,S="daily_limit"===C?.code,I=null!==C&&/feature_off$/.test(C.code),L=S&&C?.resetsDateTimeUtc?` ${t.dailyLimitRefresh((0,_chatCore.formatChatDateTime)(C.resetsDateTimeUtc))}`:"",$=e.streaming||null===C&&!e.stopped?null:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:f.space.xs},testID:`${y}-error`,children:[null!==C?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityRole:S?void 0:"alert",accessibilityLiveRegion:S?"polite":void 0,children:`${C.message}${L}`}):(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:t.stopped}),!e.features.Retry||S||I?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row"},children:(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:t.retry,variant:"link",size:"sm",onPress:()=>{e.retry()},testID:`${y}-retry`})})]}),D=e.thinking&&null!==e.profile?(0,_jsxRuntime.jsx)(_ChatLoader.ChatLoader,{style:i,steps:e.steps,phrases:e.profile.experience.pacing.thinkingPhrases,intervalMs:e.profile.experience.pacing.phraseIntervalMs,announce:t.preparingAnswer(e.profile.assistant.name),motion:r}):null,O=!0===e.pending?.typing?(0,_jsxRuntime.jsx)(_TypingPill.TypingPill,{motion:r,mark:(0,_jsxRuntime.jsx)(TypingMark,{size:"Orb"===i?TYPING_ORB_MARK:TYPING_ASSISTANT_MARK})}):null,V=null!==e.agentTyping&&"WithAgent"===e.conversationState?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:f.space.xs,alignSelf:"flex-start"},children:[(0,_jsxRuntime.jsx)(_TypingPill.TypingPill,{motion:r,mark:(0,_jsxRuntime.jsx)(TypingDots,{})}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:t.agentTyping(e.agentTyping.displayName||t.agent)})]}):null,U=O||D||$||V?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:f.space.sm},children:[O,D,V,$]}):void 0;return(0,_jsxRuntime.jsx)(_mobileUi.MessageList,{messages:N,keyExtractor:e=>e.id,renderMessage:({item:s,groupPosition:i})=>(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{animate:!s.restored,children:(0,_jsxRuntime.jsx)(ThreadMessage,{chat:e,message:s,signature:(0,_chatShared.messageSignature)(s),labels:t,all:j,layoutParts:a,groupPosition:i,isLast:s.id===v,isLastVisitor:s.id===w,handoffSettled:M.has(s.id),thinking:e.thinking,streaming:e.streaming,pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:c,openTicket:u,handoffHosts:d,resolveLink:g,focusComposer:m,byline:P.has(s.id),sourceRows:A,testID:`${y}-${s.id}`})}),getAuthorKey:e=>e.author.kind,getDate:e=>e.createdDateTimeUtc,followNew:followNew,typing:U,empty:_,ItemSeparatorComponent:TurnGap,keyboardAware:h,keyboardOffset:p,accessibilityLabel:t.thread,style:x,testID:y})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatThread=ChatThread;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_AgentByline=require("./AgentByline.js"),_ChatEntrance=require("./ChatEntrance.js"),_ChatMessageActions=require("./ChatMessageActions.js"),_chatShared=require("./chatShared.js"),_ChatLoader=require("./loaders/ChatLoader.js"),_TypingPill=require("./loaders/TypingPill.js"),_index=require("./renderers/index.js"),_NoticePart=require("./renderers/NoticePart.js"),_jsxRuntime=require("react/jsx-runtime");const MINE=new Set(["Visitor","Customer"]),joinedText=e=>e.filter(e=>"Text"===e.kind).map(e=>e.text).join("\n\n"),renderPart=(e,t,s,a,i,r)=>{const n=e[t.kind];if(n)return(0,_react.createElement)(n,{key:r,part:t,message:s,turn:a,pickAttachments:i});const o={kind:"Notice",code:"NeedsNewerApp",text:a.labels.needsNewerApp};return(0,_react.createElement)(_NoticePart.NoticePart,{key:r,part:o,message:s,turn:a})},sameMessage=(e,t)=>e.signature===t.signature&&e.message.id===t.message.id&&e.message.rating===t.message.rating&&e.message.stored===t.message.stored&&e.groupPosition===t.groupPosition&&e.isLast===t.isLast&&e.handoffSettled===t.handoffSettled&&e.isLastVisitor===t.isLastVisitor&&e.thinking===t.thinking&&e.streaming===t.streaming&&e.pickAttachments===t.pickAttachments&&e.labels===t.labels&&e.all===t.all&&e.layoutParts===t.layoutParts&&e.chat.session===t.chat.session&&e.chat.features===t.chat.features&&e.chat.onNavigate===t.chat.onNavigate&&e.onNavigate===t.onNavigate&&e.onOpenAttachment===t.onOpenAttachment&&e.onOpenTarget===t.onOpenTarget&&e.openTicket===t.openTicket&&e.resolveLink===t.resolveLink&&e.focusComposer===t.focusComposer&&e.byline===t.byline&&e.handoffHosts===t.handoffHosts;function ThreadMessageView({chat:e,message:t,labels:s,all:a,layoutParts:i,groupPosition:r,isLast:n,isLastVisitor:o,pickAttachments:l,onOpenAttachment:c,onOpenTarget:u,onNavigate:g,openTicket:m,handoffHosts:d,resolveLink:h,focusComposer:p,byline:_,sourceRows:x,testID:y}){const f=(0,_mobileUi.useTheme)(),j=Object.assign((0,_chatCore.createTurnApi)(e.session,{messageId:t.id,labels:s,openAttachment:c,openTarget:u??_chatShared.defaultOpenTarget,onNavigate:g??e.onNavigate,openTicket:m,handoffHosts:d,openCitation:e=>{return t=String(e),void(0,_chatShared.focusForAccessibility)(x.current.get(t));var t}}),{resolveLink:h,focusComposer:p,registerSourceRow:(e,t)=>{t?x.current.set(e,t):x.current.delete(e)}});let T=0;const nextSlot=()=>(T+=1,T),b=(0,_jsxRuntime.jsx)(_ChatMessageActions.ChatMessageActions,{chat:e,message:t,labels:s,isLast:n,isLastVisitor:o,testID:`${y}-actions`});if(MINE.has(t.author.kind)){const e=t.parts.filter(e=>"File"===e.kind),i=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:f.space.xs},children:[e.map(e=>renderPart(a,e,t,j,l,`${t.id}-file-${nextSlot()}`)),b]});return(0,_jsxRuntime.jsx)(_mobileUi.MessageBubble,{side:"mine",text:joinedText(t.parts),labels:{you:s.you},groupPosition:r,footer:i,testID:y})}const k="Agent"===t.author.kind,N=t.author.displayName||s.agent,v=(i?i(t):t.parts).map(e=>Array.isArray(e)?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:f.space.xs},children:e.map(e=>renderPart(a,e,t,j,l,`${t.id}-part-${nextSlot()}`))},`${t.id}-group-${nextSlot()}`):renderPart(a,e,t,j,l,`${t.id}-item-${nextSlot()}`)),A=k&&_?[(0,_jsxRuntime.jsx)(_AgentByline.AgentByline,{author:t.author,labels:s},`${t.id}-byline`),...v]:v,R=(0,_chatCore.messagePlainText)(t.parts);return(0,_jsxRuntime.jsx)(_mobileUi.MessageBubble,{side:"theirs",author:k?void 0:t.author.displayName||s.assistant,text:k?`${s.agentSays(N)} ${R}`:R,streaming:t.streaming,groupPosition:r,footer:b,testID:y,children:A})}const ThreadMessage=(0,_react.memo)(ThreadMessageView,sameMessage),TYPING_ORB_MARK=14,TYPING_ASSISTANT_MARK=8,TypingMark=({size:e})=>{const t=(0,_mobileUi.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:e,height:e,borderRadius:t.radius.pill,backgroundColor:t.colors.primary}})},TYPING_DOT=6,TypingDots=()=>{const e=(0,_mobileUi.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},children:[0,1,2].map(t=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:6,height:6,borderRadius:3,backgroundColor:e.colors["text-muted"]}},t))})},TurnGap=()=>{const e=(0,_mobileUi.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:e.space.lg}})},followNew=()=>!0;function ChatThread({chat:e,labels:t,renderers:s,layoutParts:a,loader:i="Steps",motion:r="On",pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:c,openTicket:u,handoffHosts:g,resolveLink:m,focusComposer:d,keyboardAware:h,keyboardOffset:p,empty:_,style:x,testID:y="chat-thread"}){const f=(0,_mobileUi.useTheme)(),j=(0,_react.useMemo)(()=>({..._index.defaultRenderers,...s}),[s]),T=e.messages[0],b=e.greeting??"",k=(0,_react.useMemo)(()=>""!==b&&void 0!==T&&MINE.has(T.author.kind)?{...T,id:"greeting",author:{...T.author,kind:"Assistant",displayName:null,avatarUrl:null},parts:[{kind:"Text",text:b}],stored:!1,streaming:!1,restored:!1,rating:null}:null,[b,T]),N=(0,_react.useMemo)(()=>{const t=e.messages.filter(e=>!(e.streaming&&0===e.parts.length)).reverse();return k?[...t,k]:t},[e.messages,k]),v=e.messages[e.messages.length-1]?.id,A=(0,_react.useRef)(new Map),R=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(null!==R.current)for(const s of e.messages){if(MINE.has(s.author.kind)||s.streaming||s.restored||R.current.has(s.id))continue;if("Agent"===s.author.kind&&!s.stored)continue;R.current.add(s.id);const e=(0,_chatCore.messagePlainText)(s.parts);""!==e&&_reactNative.AccessibilityInfo.announceForAccessibility("Agent"===s.author.kind?`${t.agentSays(s.author.displayName||t.agent)} ${e}`:e)}else R.current=new Set(e.messages.map(e=>e.id))},[e.messages,t]);const w=(0,_react.useMemo)(()=>{for(let t=e.messages.length-1;t>=0;t-=1){const s=e.messages[t];if(s?.stored&&"Visitor"===s.author.kind)return s.id}},[e.messages]),P=(0,_react.useMemo)(()=>{const t=new Set;return e.messages.forEach((s,a)=>{if("Agent"!==s.author.kind)return;const i=e.messages[a-1];"Agent"===i?.author.kind&&(i.author.displayName||"")===(s.author.displayName||"")||t.add(s.id)}),t},[e.messages]),M=(0,_react.useMemo)(()=>(0,_chatCore.handoffSettledIds)(e.messages),[e.messages]),C=e.turnError,S="daily_limit"===C?.code,I=null!==C&&/feature_off$/.test(C.code),L=S&&C?.resetsDateTimeUtc?` ${t.dailyLimitRefresh((0,_chatCore.formatChatDateTime)(C.resetsDateTimeUtc))}`:"",$=e.streaming||null===C&&!e.stopped?null:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:f.space.xs},testID:`${y}-error`,children:[null!==C?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityRole:S?void 0:"alert",accessibilityLiveRegion:S?"polite":void 0,children:`${C.message}${L}`}):(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:t.stopped}),!e.features.Retry||S||I?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row"},children:(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:t.retry,variant:"link",size:"sm",onPress:()=>{e.retry()},testID:`${y}-retry`})})]}),D=e.thinking&&null!==e.profile?(0,_jsxRuntime.jsx)(_ChatLoader.ChatLoader,{style:i,steps:e.steps,phrases:e.profile.experience.pacing.thinkingPhrases,intervalMs:e.profile.experience.pacing.phraseIntervalMs,announce:t.preparingAnswer(e.profile.assistant.name),motion:r}):null,O=!0===e.pending?.typing?(0,_jsxRuntime.jsx)(_TypingPill.TypingPill,{motion:r,mark:(0,_jsxRuntime.jsx)(TypingMark,{size:"Orb"===i?TYPING_ORB_MARK:TYPING_ASSISTANT_MARK})}):null,V=null!==e.agentTyping&&"WithAgent"===e.conversationState?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:f.space.xs,alignSelf:"flex-start"},children:[(0,_jsxRuntime.jsx)(_TypingPill.TypingPill,{motion:r,mark:(0,_jsxRuntime.jsx)(TypingDots,{})}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:t.agentTyping(e.agentTyping.displayName||t.agent)})]}):null,U=O||D||$||V?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:f.space.sm},children:[O,D,V,$]}):void 0;return(0,_jsxRuntime.jsx)(_mobileUi.MessageList,{messages:N,keyExtractor:e=>e.id,renderMessage:({item:s,groupPosition:i})=>(0,_jsxRuntime.jsx)(_ChatEntrance.ChatEntrance,{animate:!s.restored,children:(0,_jsxRuntime.jsx)(ThreadMessage,{chat:e,message:s,signature:(0,_chatShared.messageSignature)(s),labels:t,all:j,layoutParts:a,groupPosition:i,isLast:s.id===v,isLastVisitor:s.id===w,handoffSettled:M.has(s.id),thinking:e.thinking,streaming:e.streaming,pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:c,openTicket:u,handoffHosts:g,resolveLink:m,focusComposer:d,byline:P.has(s.id),sourceRows:A,testID:`${y}-${s.id}`})}),getAuthorKey:e=>e.author.kind,getDate:e=>e.createdDateTimeUtc,followNew:followNew,typing:U,empty:_,ItemSeparatorComponent:TurnGap,keyboardAware:h,keyboardOffset:p,accessibilityLabel:t.thread,style:x,testID:y})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.defaultOpenTarget=defaultOpenTarget,exports.messageSignature=messageSignature;var _reactNative=require("react-native");function messageSignature(e){let t=0;for(const a of e.parts)"Text"===a.kind&&(t+=a.text.length);return`${e.id}|${e.parts.length}|${t}`}const ABSOLUTE_WEB_URL=/^https?:\/\//i;function defaultOpenTarget(e){ABSOLUTE_WEB_URL.test(e)&&_reactNative.Linking.openURL(e).catch(()=>{})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.defaultOpenTarget=defaultOpenTarget,exports.focusForAccessibility=focusForAccessibility,exports.messageSignature=messageSignature;var _reactNative=require("react-native");function focusForAccessibility(e){if(null==e)return;if("web"===_reactNative.Platform.OS)return void e.focus?.();const t=(0,_reactNative.findNodeHandle)(e);null!==t&&_reactNative.AccessibilityInfo.setAccessibilityFocus(t)}function messageSignature(e){let t=0;for(const i of e.parts)"Text"===i.kind&&(t+=i.text.length);return`${e.id}|${e.parts.length}|${t}`}const ABSOLUTE_WEB_URL=/^https?:\/\//i;function defaultOpenTarget(e){ABSOLUTE_WEB_URL.test(e)&&_reactNative.Linking.openURL(e).catch(()=>{})}
@@ -1 +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)(null),[c,o]=(0,_react.useState)(!1),u=(0,_react.useRef)(t.loadAttachmentUrl);u.current=t.loadAttachmentUrl;const m=(0,_react.useRef)(0),b=(0,_react.useCallback)(e=>{const t=++m.current;n(null),o(!1),u.current(e).then(e=>{m.current===t&&n(e)},()=>{m.current===t&&o(!0)})},[]);if((0,_react.useEffect)(()=>(b(e.attachmentId),()=>{m.current++}),[e.attachmentId,b]),c)return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:a.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:e.alt}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{variant:"soft",size:"sm",label:t.labels.retry,onPress:()=>b(e.attachmentId),testID:`image-retry-${e.attachmentId}`})]});if(null===r)return(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:e.alt});const x=null!==e.width&&null!==e.height&&e.width>0&&e.height>0?e.width/e.height:null,_=(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:e.alt});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:r,contentFit:"contain",accessible:!0,accessibilityLabel:e.alt,labels:{loading:t.labels.imageLoading},style:{width:"100%",...null===x?{minHeight:160}:{aspectRatio:x},maxHeight:320,borderRadius:a.radius.md},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:r,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"),_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 +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"),_NoticePart=require("./NoticePart.js"),_jsxRuntime=require("react/jsx-runtime");const FIELD_TYPES=new Set(["Email","Phone","Name","Company","Text","LongText","Choice","MultiChoice","TimeSlot","File","Consent"]),isUndrawnField=e=>!FIELD_TYPES.has(e.type),fileNameOf=(e,t)=>{const i=e.name;return"string"==typeof i&&""!==i?i:t},slotFormat=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short",hour:"numeric",minute:"2-digit"}),selectedIds=e=>""===e?[]:JSON.parse(e),KEYBOARD_TYPES={Email:"email-address",Phone:"phone-pad"},AUTO_COMPLETE={Email:"email",Phone:"tel",Name:"name",Company:"organization"},optionalSuffix=(e,t)=>e.required?"":` (${t.inputOptional})`,firstErrorKey=(e,t)=>e.find(e=>void 0!==t[e.key])?.key;function OpenRequest({part:e,turn:t,pickAttachments:i}){const r=(0,_mobileUi.useTheme)(),{labels:s,features: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,j]=(0,_react.useState)({}),h=(0,_react.useRef)({}),v=(0,_react.useRef)({}),k=(0,_react.useRef)(y),R=(0,_react.useRef)(0),g=(0,_react.useRef)(!1),T=(0,_react.useCallback)(e=>{const t=h.current[e];if(t)return void t.focus();const i=v.current[e];if(!i)return;const r=(0,_reactNative.findNodeHandle)(i);null!==r&&_reactNative.AccessibilityInfo.setAccessibilityFocus(r)},[]);(0,_react.useEffect)(()=>{if(p||!g.current)return;g.current=!1;const t=firstErrorKey(e.fields,o);void 0!==t&&T(t)},[p,o,e.fields,T]);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,S=w&&1===e.fields.length&&!e.fields[0].required,C=w&&e.cancellable;return(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",padding:"sm",accessibilityLabel:e.title||void 0,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.sm},children:[e.title?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",accessibilityRole:"header",children:e.title}):null,e.allowTyped?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.typeAnswer}):null,e.fields.map(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,{progress:e.progress??void 0,label:s.attachmentUploading,height:4}):null,"Failed"===e.status?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"assertive",children:s.attachmentFailed}):null]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row"},children:(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.inputChooseFile,variant:"soft",size:"sm",leftIcon:"paperclip",disabled:p||void 0===i,onPress:()=>{(async e=>{if(!i)return;let r;try{r=await i()}catch{return void d(s.errorGeneric)}const 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,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,value:""===l?void 0:l,onChange:e=>setValue(n.key,String(e)),accessibilityLabel:n.label,error:c,disabled:p})})]},n.key)}if("Consent"===n.type)return(0,_jsxRuntime.jsx)(_mobileUi.Checkbox,{checked:"true"===l,onChange:e=>setValue(n.key,e?"true":"false"),label:n.consentText??n.label,error:c,disabled:p},n.key);const u=(0,_jsxRuntime.jsx)(_mobileUi.Input,{ref:e=>{h.current[n.key]=e},label:n.label,placeholder:n.placeholder??void 0,value:l,onChangeText:e=>setValue(n.key,e),maxLength:n.maxLength??void 0,required:n.required,error:c,help:n.required?void 0:s.inputOptional,labelMode:"top",disabled:p,type:n.secret?"password":"LongText"===n.type?"textarea":"input",keyboardType:KEYBOARD_TYPES[n.type]??"default",autoCapitalize:"Email"===n.type?"none":void 0,autoComplete:AUTO_COMPLETE[n.type]},n.key);if(!("Otp"===n.verify&&("Email"===n.type||"Phone"===n.type)))return u;const 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()}),j(e=>({...e,[i.key]:"sent"}))}catch{j(e=>({...e,[i.key]:"failed"}))}})(n)},testID:`otp-send-${n.key}`}),(0,_jsxRuntime.jsx)(_mobileUi.Input,{label:s.inputEnterCode,value:_[n.key]??"",onChangeText:e=>b(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=(_[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&&T(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,S?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.skip,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.skipInput(e.requestId))}}):null,C?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.cancel,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.cancelLead())}}):null]})]})})}function InputRequestPart(e){const{part:t,message:i,turn:r,pickAttachments:s}=e;if("InputRequest"!==t.kind||t.fields.some(isUndrawnField)){const e={kind:"Notice",code:"NeedsNewerApp",text:r.labels.needsNewerApp};return(0,_jsxRuntime.jsx)(_NoticePart.NoticePart,{part:e,message:i,turn:r})}return"Answered"===t.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:t.answeredSummary||r.labels.inputAnswered}):"Skipped"===t.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:r.labels.inputSkipped}):"Expired"===t.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:r.labels.inputExpired}):(0,_jsxRuntime.jsx)(OpenRequest,{part:t,turn:r,pickAttachments:s},t.requestId)}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.InputRequestPart=InputRequestPart;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_chatShared=require("../chatShared.js"),_NoticePart=require("./NoticePart.js"),_jsxRuntime=require("react/jsx-runtime");const FIELD_TYPES=new Set(["Email","Phone","Name","Company","Text","LongText","Choice","MultiChoice","TimeSlot","File","Consent"]),isUndrawnField=e=>!FIELD_TYPES.has(e.type),fileNameOf=(e,t)=>{const i=e.name;return"string"==typeof i&&""!==i?i:t},slotFormat=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short",hour:"numeric",minute:"2-digit"}),selectedIds=e=>""===e?[]:JSON.parse(e),KEYBOARD_TYPES={Email:"email-address",Phone:"phone-pad"},AUTO_COMPLETE={Email:"email",Phone:"tel",Name:"name",Company:"organization"},optionalSuffix=(e,t)=>e.required?"":` (${t.inputOptional})`,firstErrorKey=(e,t)=>e.find(e=>void 0!==t[e.key])?.key;function OpenRequest({part:e,turn:t,pickAttachments:i}){const r=(0,_mobileUi.useTheme)(),{labels:s,features:a}=t,[n,l]=(0,_react.useState)({}),[o,c]=(0,_react.useState)({}),[u,d]=(0,_react.useState)(""),[p,m]=(0,_react.useState)(!1),[y,x]=(0,_react.useState)({}),[_,b]=(0,_react.useState)({}),[f,j]=(0,_react.useState)({}),h=(0,_react.useRef)({}),v=(0,_react.useRef)({}),k=(0,_react.useRef)(y),R=(0,_react.useRef)(0),g=(0,_react.useRef)(!1),S=(0,_react.useCallback)(e=>{const t=h.current[e];if(t)return void t.focus();const i=v.current[e];i&&(0,_chatShared.focusForAccessibility)(i)},[]);(0,_react.useEffect)(()=>{if(p||!g.current)return;g.current=!1;const t=firstErrorKey(e.fields,o);void 0!==t&&S(t)},[p,o,e.fields,S]);const setValue=(e,t)=>l(i=>({...i,[e]:t})),commitUploads=e=>{k.current=e,x(e)},patchUpload=(e,t)=>{const i=k.current[e];i&&commitUploads({...k.current,[e]:{...i,...t}})},isLiveUpload=(e,t)=>k.current[e]?.token===t,T=Object.values(y).some(e=>"Ready"!==e.status),leave=async e=>{m(!0),d("");try{await e()}catch{d(s.errorGeneric),m(!1)}},U=a.LeadShortcuts,w=U&&1===e.fields.length&&!e.fields[0].required,C=U&&e.cancellable;return(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",padding:"sm",accessibilityLabel:e.title||void 0,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.sm},children:[e.title?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",accessibilityRole:"header",children:e.title}):null,e.allowTyped?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.typeAnswer}):null,e.fields.map(a=>{const l=n[a.key]??"",c=o[a.key];if("File"===a.type){const e=y[a.key];return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:`${a.label}${optionalSuffix(a,s)}`}),e?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xxs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Chip,{label:e.fileName,variant:"soft",onRemove:()=>{return e=a.key,commitUploads(Object.fromEntries(Object.entries(k.current).filter(([t])=>t!==e))),void setValue(e,"");var e},labels:{remove:s.inputRemoveFile}}),"Uploading"===e.status?(0,_jsxRuntime.jsx)(_mobileUi.ProgressBar,{progress:e.progress??void 0,label:s.attachmentUploading,height:4}):null,"Failed"===e.status?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"assertive",children:s.attachmentFailed}):null]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row"},children:(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.inputChooseFile,variant:"soft",size:"sm",leftIcon:"paperclip",disabled:p||void 0===i,onPress:()=>{(async e=>{if(!i)return;let r;try{r=await i()}catch{return void d(s.errorGeneric)}const a=r[0];if(!a)return;R.current+=1;const n=R.current;commitUploads({...k.current,[e.key]:{fileName:fileNameOf(a,e.label),status:"Uploading",progress:null,token:n}});try{const i=await t.uploadInputFile(a,t=>{isLiveUpload(e.key,n)&&patchUpload(e.key,{progress:t})});isLiveUpload(e.key,n)&&(setValue(e.key,i),patchUpload(e.key,{status:"Ready",progress:null}))}catch{isLiveUpload(e.key,n)&&(setValue(e.key,""),patchUpload(e.key,{status:"Failed",progress:null}))}})(a)}})}),c?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"assertive",children:c}):null]},a.key)}if("MultiChoice"===a.type){const e=(a.options??[]).map(e=>({label:e.label,value:e.id}));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:`${a.label}${optionalSuffix(a,s)}`}),(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e=>{v.current[a.key]=e},children:(0,_jsxRuntime.jsx)(_mobileUi.ChoiceGroup,{selectionMode:"multiple",options:e,value:selectedIds(l),onChange:t=>setValue(a.key,JSON.stringify(e.filter(e=>t.includes(e.value)).map(e=>e.value))),accessibilityLabel:a.label,error:c,disabled:p})})]},a.key)}if("Choice"===a.type||"TimeSlot"===a.type){const e="TimeSlot"===a.type?(a.slots??[]).map(e=>({label:slotFormat.format(new Date(e.startDateTimeUtc)),value:e.id})):(a.options??[]).map(e=>({label:e.label,value:e.id}));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:`${a.label}${optionalSuffix(a,s)}`}),(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e=>{v.current[a.key]=e},children:(0,_jsxRuntime.jsx)(_mobileUi.ChoiceGroup,{options:e,value:""===l?void 0:l,onChange:e=>setValue(a.key,String(e)),accessibilityLabel:a.label,error:c,disabled:p})})]},a.key)}if("Consent"===a.type)return(0,_jsxRuntime.jsx)(_mobileUi.Checkbox,{checked:"true"===l,onChange:e=>setValue(a.key,e?"true":"false"),label:a.consentText??a.label,error:c,disabled:p},a.key);const u=(0,_jsxRuntime.jsx)(_mobileUi.Input,{ref:e=>{h.current[a.key]=e},label:a.label,placeholder:a.placeholder??void 0,value:l,onChangeText:e=>setValue(a.key,e),maxLength:a.maxLength??void 0,required:a.required,error:c,help:a.required?void 0:s.inputOptional,labelMode:"top",disabled:p,type:a.secret?"password":"LongText"===a.type?"textarea":"input",keyboardType:KEYBOARD_TYPES[a.type]??"default",autoCapitalize:"Email"===a.type?"none":void 0,autoComplete:AUTO_COMPLETE[a.type]},a.key);if(!("Otp"===a.verify&&("Email"===a.type||"Phone"===a.type)))return u;const m=f[a.key];return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[u,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:r.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.inputSendCode,variant:"soft",size:"sm",disabled:p,onPress:()=>{(async i=>{if("Otp"===i.verify)try{await t.sendOtp(e.requestId,{fieldKey:i.key,value:(n[i.key]??"").trim()}),j(e=>({...e,[i.key]:"sent"}))}catch{j(e=>({...e,[i.key]:"failed"}))}})(a)},testID:`otp-send-${a.key}`}),(0,_jsxRuntime.jsx)(_mobileUi.Input,{label:s.inputEnterCode,value:_[a.key]??"",onChangeText:e=>b(t=>({...t,[a.key]:e})),keyboardType:"number-pad",autoComplete:"one-time-code",disabled:p}),m?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"failed"===m?"danger":"secondary",accessibilityLiveRegion:"polite",children:"failed"===m?s.inputCodeFailed:s.inputCodeSent}):null]})]},a.key)}),""!==u?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:u}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:r.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:p?s.inputSubmitting:e.submitLabel,loading:p,disabled:p||T,onPress:()=>{(async()=>{if(T)return;const i={},r={};for(const t of e.fields){const e=n[t.key]??"";if("Consent"===t.type){const a="true"===e;t.required&&!a&&(i[t.key]=s.inputConsentRequired),r[t.key]=a?"true":"false"}else if("Choice"===t.type||"TimeSlot"===t.type)t.required&&""===e&&(i[t.key]=s.inputRequired),r[t.key]=e;else if("MultiChoice"===t.type){const a=selectedIds(e);t.required&&0===a.length&&(i[t.key]=s.inputRequired),r[t.key]=JSON.stringify(a)}else if("File"===t.type)t.required&&""===e&&(i[t.key]=s.inputRequired),r[t.key]=e;else{const a=t.secret?e:e.trim();t.required&&""===a&&(i[t.key]=s.inputRequired),r[t.key]=a}}const a={};for(const t of e.fields){if("Otp"!==t.verify)continue;const e=(_[t.key]??"").trim();""===e&&(i[t.key]=s.inputRequired),a[t.key]=e}if(c(i),Object.keys(i).length>0){const t=firstErrorKey(e.fields,i);return void(void 0!==t&&S(t))}m(!0),d("");try{const i=await t.answerInput(e.requestId,r,Object.keys(a).length>0?a:null);if(i.ok)return;c(i.errors),g.current=!0,d(i.message??"")}catch{d(s.errorGeneric)}m(!1)})()}}),T?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:s.attachmentUploading}):null,w?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.skip,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.skipInput(e.requestId))}}):null,C?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:s.cancel,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.cancelLead())}}):null]})]})})}function InputRequestPart(e){const{part:t,message:i,turn:r,pickAttachments:s}=e;if("InputRequest"!==t.kind||t.fields.some(isUndrawnField)){const e={kind:"Notice",code:"NeedsNewerApp",text:r.labels.needsNewerApp};return(0,_jsxRuntime.jsx)(_NoticePart.NoticePart,{part:e,message:i,turn:r})}return"Answered"===t.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:t.answeredSummary||r.labels.inputAnswered}):"Skipped"===t.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:r.labels.inputSkipped}):"Expired"===t.state?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:r.labels.inputExpired}):(0,_jsxRuntime.jsx)(OpenRequest,{part:t,turn:r,pickAttachments:s},t.requestId)}
@@ -0,0 +1 @@
1
+ "use strict";import{ThemeProvider,useTheme,useThemeMode}from"@webority/mobile-ui";import{useMemo}from"react";import{Fragment as _Fragment,jsx as _jsx}from"react/jsx-runtime";const DISPLAY_FONT="var(--wui-font-display)",radiusPx=e=>{if(null==e)return null;const r=Number.parseFloat(e);return Number.isFinite(r)?r:null},brandFor=(e,r,n)=>{if(null===e&&null===r&&null===n)return;const t={};return null!==e&&(t.colors={light:{primary:e},dark:{primary:e}}),null!==r&&(t.radius={md:r,lg:r,xl:r}),null!==n&&(t.font={ui:n}),t};export function ChatAppearanceScope({appearance:e,children:r}){const n=useTheme(),{preference:t}=useThemeMode(),i=e?.["--wui-chat-accent"]??null,u=radiusPx(e?.["--wui-chat-radius"]),l=e?.["--wui-chat-font"]===DISPLAY_FONT?n.font.display:null,a=useMemo(()=>brandFor(i,u,l),[i,u,l]);return void 0===a?_jsx(_Fragment,{children:r}):_jsx(ThemeProvider,{initialPreference:t,brand:a,settings:n.settings,children:r},t)}
@@ -1 +1 @@
1
- "use strict";import{Permissions}from"@webority/mobile-core/permissions";import{Banner,Chip,Composer,IconButton,ProgressBar,Text,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{ChatDictationButton}from"./ChatDictationButton.js";import{ChatFooter}from"./ChatFooter.js";import{joinDictation}from"./speech/speechText.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const ALLOWANCE_SHOWN_AT=10,COUNTER_AT=.9,DEFAULT_MAX_LENGTH=4e3,openQuestion=e=>{for(let t=e.length-1;t>=0;t-=1){const s=e[t];for(const e of[...s?.parts??[]].reverse())if("InputRequest"===e.kind&&"Open"===e.state)return e.fields[0]?.label||e.title||null}return null};export function ChatComposer({chat:e,labels:t,pickAttachments:s,keyboardOffset:a,keyboardAware:o,safeArea:n,testID:i="chat-composer",focusRef:r}){const l=useTheme(),c=useMemo(()=>buildStyles(l),[l]),[m,u]=useState(""),[p,h]=useState(null),d=e.editing,f=useRef(null),g=useRef(null);useEffect(()=>{if(r)return r.current=()=>g.current?.focus(),()=>{r.current=null}},[r]),useEffect(()=>{d&&f.current?.(),u(d?d.text:"")},[d]);const x=e.attachments,b=x.some(e=>"Uploading"===e.status),y=x.some(e=>"Ready"===e.status),v=e.messagesLeftToday,j=e.profile?.limits.maxMessageLength??4e3,_=void 0!==s&&e.features.Attachments&&(e.profile?.limits.maxAttachments??0)>0,S=e.features.HumanHandoff&&("WaitingForAgent"===e.conversationState||"WithAgent"===e.conversationState),T=_&&!e.handoffPause?_jsx(IconButton,{icon:"paperclip",accessibilityLabel:t.attach,variant:"ghost",tone:"neutral",onPress:()=>{s&&s().then(t=>e.attach(t))},testID:`${i}-attach`}):void 0,A=d?_jsx(Banner,{message:t.editing,accessibilityRole:"summary",actions:[{label:t.cancel,onPress:()=>e.cancelEdit()}],testID:`${i}-editing`}):null,D=x.length>0?_jsx(View,{style:c.tray,testID:`${i}-attachments`,children:_jsx(View,{style:c.row,children:x.map(s=>_jsxs(View,{style:c.item,children:[_jsx(Chip,{label:s.fileName,variant:"soft",onRemove:()=>{e.removeAttachment(s.key)},labels:{remove:t.removeAttachment},removeTestID:`${i}-remove-${s.key}`,testID:`${i}-chip-${s.key}`}),"Uploading"===s.status?_jsx(ProgressBar,{progress:s.progress??void 0,label:t.attachmentUploading,height:4,containerStyle:c.progress}):null,"Failed"===s.status?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:s.error??t.attachmentFailed}):null]},s.key))})}):null,w=null!==v&&v<=10?_jsx(Text,{variant:"caption",color:0===v?"danger":"secondary",accessibilityLiveRegion:"polite",testID:`${i}-allowance`,children:t.allowance(v)}):null,C=p?_jsx(Banner,{message:p.message,tone:p.tone,dismissible:!0,onClose:()=>h(null),actions:p.openSettings?[{label:t.dictateOpenSettings,onPress:()=>{Permissions.openSettings()}}]:void 0,testID:`${i}-voice-notice`}):null,I=m.length>0,R=m.length>.9*j?_jsx(Text,{variant:"caption",color:"secondary",testID:`${i}-counter`,children:t.counter(m.length,j)}):null,L=A||D||w||R||C?_jsxs(_Fragment,{children:[A,D,w,R,C]}):void 0,P=!b&&(!!y||void 0),k=!0===e.profile?.experience.motion;return _jsx(Composer,{ref:g,onSend:t=>{f.current?.(),e.submit(t)},value:m,onChangeText:t=>{f.current?.(),u(t),S&&t.length>0&&e.notifyTyping()},loading:e.streaming&&e.features.Stop,ring:k&&(I||e.streaming),sendReveal:k?"onText":"always",onStop:e.features.Stop?()=>e.stop():void 0,stopLabel:t.stop,disabled:0===v||e.handoffPause,maxLength:j,canSend:P,placeholder:e.handoffPause?t.handoffMoment:openQuestion(e.messages)??t.placeholder,accessibilityLabel:t.composer,labels:{send:t.send},leading:T,trailing:_jsx(ChatDictationButton,{chat:e,labels:t,disabled:0===v||e.handoffPause,onText:e=>u(t=>joinDictation(t,e,j)),onNotice:h,stopRef:f}),above:L,below:_jsx(ChatFooter,{chat:e,labels:t}),keyboardAware:o,keyboardOffset:a,safeArea:n,testID:i})}const buildStyles=e=>StyleSheet.create({tray:{gap:e.space.xs},row:{flexDirection:"row",flexWrap:"wrap",gap:e.space.xs},item:{gap:e.space.xxs,maxWidth:"100%"},progress:{minWidth:120}});
1
+ "use strict";import{defaultChatLook}from"@webority/chat-core";import{Permissions}from"@webority/mobile-core/permissions";import{Banner,Chip,Composer,IconButton,ProgressBar,Text,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{ChatDictationButton}from"./ChatDictationButton.js";import{ChatFooter}from"./ChatFooter.js";import{joinDictation}from"./speech/speechText.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const ALLOWANCE_SHOWN_AT=10,COUNTER_AT=.9,DEFAULT_MAX_LENGTH=4e3,openQuestion=e=>{for(let t=e.length-1;t>=0;t-=1){const s=e[t];for(const e of[...s?.parts??[]].reverse())if("InputRequest"===e.kind&&"Open"===e.state)return e.fields[0]?.label||e.title||null}return null};export function ChatComposer({chat:e,labels:t,pickAttachments:s,keyboardOffset:a,keyboardAware:o,safeArea:n,testID:i="chat-composer",focusRef:r,look:l=defaultChatLook}){const c=useTheme(),u=useMemo(()=>buildStyles(c),[c]),[m,p]=useState(""),[h,d]=useState(null),f=e.editing,g=useRef(null),x=useRef(null);useEffect(()=>{if(r)return r.current=()=>x.current?.focus(),()=>{r.current=null}},[r]),useEffect(()=>{f&&g.current?.(),p(f?f.text:"")},[f]);const b=e.attachments,y=b.some(e=>"Uploading"===e.status),v=b.some(e=>"Ready"===e.status),j=e.messagesLeftToday,_=e.profile?.limits.maxMessageLength??4e3,S=void 0!==s&&e.features.Attachments&&(e.profile?.limits.maxAttachments??0)>0,w=e.features.HumanHandoff&&("WaitingForAgent"===e.conversationState||"WithAgent"===e.conversationState),A=S&&!e.handoffPause?_jsx(IconButton,{icon:"paperclip",accessibilityLabel:t.attach,variant:"ghost",tone:"neutral",onPress:()=>{s&&s().then(t=>e.attach(t))},testID:`${i}-attach`}):void 0,C=f?_jsx(Banner,{message:t.editing,accessibilityRole:"summary",actions:[{label:t.cancel,onPress:()=>e.cancelEdit()}],testID:`${i}-editing`}):null,T=b.length>0?_jsx(View,{style:u.tray,testID:`${i}-attachments`,children:_jsx(View,{style:u.row,children:b.map(s=>_jsxs(View,{style:u.item,children:[_jsx(Chip,{label:s.fileName,variant:"soft",onRemove:()=>{e.removeAttachment(s.key)},labels:{remove:t.removeAttachment},removeTestID:`${i}-remove-${s.key}`,testID:`${i}-chip-${s.key}`}),"Uploading"===s.status?_jsx(ProgressBar,{progress:s.progress??void 0,label:t.attachmentUploading,height:4,containerStyle:u.progress}):null,"Failed"===s.status?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:s.error??t.attachmentFailed}):null]},s.key))})}):null,D=null!==j&&j<=10?_jsx(Text,{variant:"caption",color:0===j?"danger":"secondary",accessibilityLiveRegion:"polite",testID:`${i}-allowance`,children:t.allowance(j)}):null,L=h?_jsx(Banner,{message:h.message,tone:h.tone,dismissible:!0,onClose:()=>d(null),actions:h.openSettings?[{label:t.dictateOpenSettings,onPress:()=>{Permissions.openSettings()}}]:void 0,testID:`${i}-voice-notice`}):null,R=m.length>0,k=m.length>.9*_?_jsx(Text,{variant:"caption",color:"secondary",testID:`${i}-counter`,children:t.counter(m.length,_)}):null,I=C||T||D||k||L?_jsxs(_Fragment,{children:[C,T,D,k,L]}):void 0,P=!y&&(!!v||void 0);return _jsx(Composer,{ref:x,onSend:t=>{g.current?.(),e.submit(t)},value:m,onChangeText:t=>{g.current?.(),p(t),w&&t.length>0&&e.notifyTyping()},loading:e.streaming&&e.features.Stop,ring:l.input.ring&&(R||e.streaming),sendReveal:"Always"===l.input.sendReveal?"always":"onText",onStop:e.features.Stop?()=>e.stop():void 0,stopLabel:t.stop,disabled:0===j||e.handoffPause,maxLength:_,canSend:P,placeholder:e.handoffPause?t.handoffMoment:openQuestion(e.messages)??t.placeholder,accessibilityLabel:t.composer,labels:{send:t.send},leading:A,trailing:_jsx(ChatDictationButton,{chat:e,labels:t,disabled:0===j||e.handoffPause,onText:e=>p(t=>joinDictation(t,e,_)),onNotice:d,stopRef:g}),above:I,below:_jsx(ChatFooter,{chat:e,labels:t}),keyboardAware:o,keyboardOffset:a,safeArea:n,testID:i})}const buildStyles=e=>StyleSheet.create({tray:{gap:e.space.xs},row:{flexDirection:"row",flexWrap:"wrap",gap:e.space.xs},item:{gap:e.space.xxs,maxWidth:"100%"},progress:{minWidth:120}});
@@ -1 +1 @@
1
- "use strict";import{mergeLabels}from"@webority/chat-core";import{radiusOf,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{ChatFrame}from"./ChatFrame.js";import{jsx as _jsx}from"react/jsx-runtime";export function ChatEmbed({chat:e,labels:t,renderers:o,layoutParts:r,loader:a="Steps",motion:s="On",pickAttachments:i,onOpenAttachment:n,onOpenTarget:l,onNavigate:m,openTicket:d,handoffHosts:h,resolveLink:c,keyboardOffset:f,title:b,headerActions:u,onClose:p,height:g=520,testID:k="chat-embed"}){const C=useTheme();return null===e.profile||e.features.VisitorChat?_jsx(View,{style:{height:g,overflow:"hidden",borderRadius:radiusOf(C,"lg"),borderWidth:1,borderColor:C.colors["border-subtle"],backgroundColor:C.colors.bg},testID:k,children:_jsx(ChatFrame,{chat:e,labels:mergeLabels(t),renderers:o,layoutParts:r,loader:a,motion:s,pickAttachments:i,onOpenAttachment:n,onOpenTarget:l,onNavigate:m,openTicket:d,handoffHosts:h,resolveLink:c,keyboardOffset:f,layout:"embedded",title:b,headerActions:u,onClose:p,testID:`${k}-frame`})}):null}
1
+ "use strict";import{mergeLabels}from"@webority/chat-core";import{radiusOf,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{ChatAppearanceScope}from"./ChatAppearanceScope.js";import{ChatFrame}from"./ChatFrame.js";import{jsx as _jsx}from"react/jsx-runtime";const EmbedBox=({height:e,testID:t,children:r})=>{const o=useTheme();return _jsx(View,{style:{height:e,overflow:"hidden",borderRadius:radiusOf(o,"lg"),borderWidth:1,borderColor:o.colors["border-subtle"],backgroundColor:o.colors.bg},testID:t,children:r})};export function ChatEmbed({chat:e,labels:t,renderers:r,layoutParts:o,loader:a="Steps",look:s,appearance:n,pickAttachments:i,onOpenAttachment:l,onOpenTarget:c,onNavigate:h,openTicket:d,handoffHosts:m,resolveLink:p,keyboardOffset:b,title:f,headerActions:u,onClose:g,height:C=520,testID:k="chat-embed"}){return null===e.profile||e.features.VisitorChat?_jsx(ChatAppearanceScope,{appearance:n,children:_jsx(EmbedBox,{height:C,testID:k,children:_jsx(ChatFrame,{chat:e,labels:mergeLabels(t),renderers:r,layoutParts:o,loader:a,look:s,pickAttachments:i,onOpenAttachment:l,onOpenTarget:c,onNavigate:h,openTicket:d,handoffHosts:m,resolveLink:p,keyboardOffset:b,layout:"embedded",title:f,headerActions:u,onClose:g,testID:`${k}-frame`})})}):null}
@@ -1 +1 @@
1
- "use strict";import{Banner,Button,IconButton,Spinner,Text,useTheme}from"@webority/mobile-ui";import{useRef,useState}from"react";import{View}from"react-native";import{ChatComposer}from"./ChatComposer.js";import{ChatConversationActions}from"./ChatConversationActions.js";import{ChatHistory}from"./ChatHistory.js";import{ChatLiveBar}from"./ChatLiveBar.js";import{ChatStarters}from"./ChatStarters.js";import{ChatThread}from"./ChatThread.js";import{useChatHaptics}from"./useChatHaptics.js";import{useChatSound}from"./useChatSound.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function ChatFrame({chat:e,labels:t,renderers:s,layoutParts:o,loader:r="Steps",motion:a="On",pickAttachments:n,onOpenAttachment:i,onOpenTarget:l,onNavigate:c,openTicket:m,handoffHosts:h,resolveLink:u,keyboardOffset:d,layout:f,title:p,headerActions:C,onClose:x,testID:j="chat-frame"}){const b=useTheme(),[y,g]=useState(!1),_=y&&!0===e.features.History;useChatHaptics(e),useChatSound(e);const v="sheet"!==f,I=null!==e.profile,k=useRef(null);if(I&&!e.features.VisitorChat)return null;const D=e.messages.length>0,S=e.messages.some(e=>"Visitor"===e.author.kind||"Customer"===e.author.kind),T="screen"===f||S,B=!0===e.profile?.experience.sound.muteControl&&e.features.Sounds,w=_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:b.space.sm,paddingHorizontal:b.space.md,paddingVertical:b.space.sm,borderBottomWidth:1,borderBottomColor:b.colors["border-subtle"]},children:[_jsxs(View,{style:{flex:1,minWidth:0},children:[_jsx(Text,{variant:"title",accessibilityRole:"header",numberOfLines:1,children:p??e.profile?.assistant.name??t.panelTitle}),_jsx(Text,{variant:"caption",color:"secondary",children:t.headerStatus})]}),C,_?null:_jsx(ChatConversationActions,{chat:e,labels:t,testID:`${j}-conversation-actions`}),B?_jsx(Button,{label:e.muted?t.unmuteSounds:t.muteSounds,variant:"link",size:"sm",onPress:()=>e.session.setMuted(!e.muted),testID:`${j}-mute`}):null,e.features.History?_jsx(Button,{label:_?t.backToChat:t.history,variant:"link",size:"sm",onPress:()=>g(e=>!e),testID:`${j}-history`}):null,_||!T?null:_jsx(Button,{label:t.newChat,size:"sm",variant:"soft",leftIcon:"add",disabled:e.streaming||e.thinking,onPress:()=>e.newConversation(),testID:`${j}-new`}),x?_jsx(IconButton,{icon:"x",variant:"ghost",tone:"neutral",accessibilityLabel:t.close,onPress:x,testID:`${j}-close`}):null]});let $;return $=_?_jsx(ChatHistory,{chat:e,labels:t,onOpen:()=>g(!1),testID:`${j}-history-list`}):e.profileError?_jsx(Banner,{tone:"danger",message:e.profileError.message,accessibilityRole:"alert",testID:`${j}-profile-error`}):!I||e.loading?_jsx(View,{style:{flex:1,alignItems:"center",justifyContent:"center"},children:_jsx(Spinner,{message:t.loadingConversation,testID:`${j}-loading`})}):e.loadError?_jsx(Banner,{tone:"danger",message:e.loadError.message,accessibilityRole:"alert",testID:`${j}-load-error`}):D?_jsx(ChatThread,{chat:e,labels:t,renderers:s,layoutParts:o,loader:r,motion:a,pickAttachments:n,onOpenAttachment:i,onOpenTarget:l,onNavigate:c,openTicket:m,handoffHosts:h,resolveLink:u,focusComposer:()=>k.current?.(),keyboardAware:v,keyboardOffset:d,style:{flex:1},testID:`${j}-thread`}):_jsx(ChatStarters,{chat:e,labels:t,openTicket:m,testID:`${j}-starters`}),_jsxs(View,{style:{flex:1},testID:j,children:[w,_?null:_jsx(ChatLiveBar,{chat:e,labels:t,testID:`${j}-live`}),_jsx(View,{style:{flex:1},children:$}),_?null:_jsx(ChatComposer,{chat:e,labels:t,pickAttachments:n,keyboardOffset:d,keyboardAware:v,focusRef:k,testID:`${j}-composer`})]})}
1
+ "use strict";import{mergeLook}from"@webority/chat-core";import{Banner,IconButton,Spinner,Text,useReducedMotion,useTheme}from"@webority/mobile-ui";import{useMemo,useRef,useState}from"react";import{View}from"react-native";import{ChatComposer}from"./ChatComposer.js";import{ChatConversationActions}from"./ChatConversationActions.js";import{ChatHistory}from"./ChatHistory.js";import{ChatLiveBar}from"./ChatLiveBar.js";import{ChatPanelGrow,ChatReveal,panelRun}from"./ChatPanel.js";import{ChatStarters}from"./ChatStarters.js";import{ChatThread}from"./ChatThread.js";import{useChatHaptics}from"./useChatHaptics.js";import{useChatSound}from"./useChatSound.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function ChatFrame({chat:e,labels:t,renderers:s,layoutParts:o,loader:r="Steps",look:a,pickAttachments:n,onOpenAttachment:i,onOpenTarget:l,onNavigate:c,openTicket:h,handoffHosts:m,resolveLink:u,keyboardOffset:d,layout:p,title:f,headerActions:C,onClose:x,enterKey:j=0,testID:y="chat-frame"}){const b=useTheme(),g=useMemo(()=>mergeLook(a),[a]),v=useReducedMotion(),_="Reduced"===g.motion||v,I="embedded"===p?"None":g.panel.motion,k="sheet"===p?"sheet":"screen",w=useMemo(()=>panelRun({motion:I,reduced:_,mode:k,run:j}),[I,_,k,j]),[D,R]=useState(!1),S=D&&!0===e.features.History;useChatHaptics(e),useChatSound(e);const T="sheet"!==p,B=null!==e.profile,$=useRef(null);if(B&&!e.features.VisitorChat)return null;const L=e.messages.length>0,A=e.messages.some(e=>"Visitor"===e.author.kind||"Customer"===e.author.kind),H="screen"===p||A,O=!0===e.profile?.experience.sound.muteControl&&e.features.Sounds,P=_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:b.space.sm,paddingHorizontal:b.space.md,paddingVertical:b.space.sm,borderBottomWidth:1,borderBottomColor:b.colors["border-subtle"]},children:[_jsxs(View,{style:{flex:1,minWidth:0},children:[_jsx(Text,{variant:"title",accessibilityRole:"header",numberOfLines:1,children:f??e.profile?.assistant.name??t.panelTitle}),_jsx(Text,{variant:"caption",color:"secondary",children:t.headerStatus})]}),C,S?null:_jsx(ChatConversationActions,{chat:e,labels:t,testID:`${y}-conversation-actions`}),e.features.History?_jsx(IconButton,{icon:S?"arrow-left":"history",variant:"ghost",tone:"neutral",accessibilityLabel:S?t.backToChat:t.history,onPress:()=>R(e=>!e),testID:`${y}-history`}):null,O?_jsx(IconButton,{icon:e.muted?"volume-mute":"volume-high",variant:"ghost",tone:"neutral",accessibilityLabel:e.muted?t.unmuteSounds:t.muteSounds,onPress:()=>e.session.setMuted(!e.muted),testID:`${y}-mute`}):null,S||!H?null:_jsx(IconButton,{icon:"plus",variant:"ghost",tone:"neutral",accessibilityLabel:t.newChat,disabled:e.streaming||e.thinking,onPress:()=>e.newConversation(),testID:`${y}-new`}),x?_jsx(IconButton,{icon:"x",variant:"ghost",tone:"neutral",accessibilityLabel:t.close,onPress:x,testID:`${y}-close`}):null]});let V;return V=S?_jsx(ChatHistory,{chat:e,labels:t,onOpen:()=>R(!1),testID:`${y}-history-list`}):e.profileError?_jsx(Banner,{tone:"danger",message:e.profileError.message,accessibilityRole:"alert",testID:`${y}-profile-error`}):!B||e.loading?_jsx(View,{style:{flex:1,alignItems:"center",justifyContent:"center"},children:_jsx(Spinner,{message:t.loadingConversation,testID:`${y}-loading`})}):e.loadError?_jsx(Banner,{tone:"danger",message:e.loadError.message,accessibilityRole:"alert",testID:`${y}-load-error`}):L?_jsx(ChatThread,{chat:e,labels:t,renderers:s,layoutParts:o,loader:r,motion:g.motion,pickAttachments:n,onOpenAttachment:i,onOpenTarget:l,onNavigate:c,openTicket:h,handoffHosts:m,resolveLink:u,focusComposer:()=>$.current?.(),keyboardAware:T,keyboardOffset:d,style:{flex:1},testID:`${y}-thread`}):_jsx(ChatStarters,{chat:e,labels:t,openTicket:h,testID:`${y}-starters`}),_jsx(ChatPanelGrow,{grow:w.grow,children:_jsxs(View,{style:{flex:1},testID:y,children:[_jsx(ChatReveal,{plan:w.reveal.header,children:P}),S?null:_jsx(ChatLiveBar,{chat:e,labels:t,testID:`${y}-live`}),_jsx(ChatReveal,{plan:w.reveal.body,flex:!0,children:_jsx(View,{style:{flex:1},children:V})}),S?null:_jsx(ChatReveal,{plan:w.reveal.composer,children:_jsx(ChatComposer,{chat:e,labels:t,look:g,pickAttachments:n,keyboardOffset:d,keyboardAware:T,focusRef:$,testID:`${y}-composer`})})]})})}
@@ -0,0 +1 @@
1
+ "use strict";import{FloatingActionButton,useTheme}from"@webority/mobile-ui";import{useEffect,useState}from"react";import{Animated,Easing,StyleSheet}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{jsx as _jsx}from"react/jsx-runtime";const RISE_MS=900,RISE_DELAY_MS=400,ENTRANCE_MS=800,ENTRANCE_DELAY_MS=1e3,FLOAT_HALF_MS=1600,FLOAT_PX=4,RISE_FROM_PX=116;function entranceStyle(e,t){const range=(e,a)=>t.interpolate({inputRange:e,outputRange:a,extrapolate:"clamp"});switch(e){case"Rise":return{opacity:range([0,.4,1],[0,1,1]),transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[116,0]})}]};case"SlideUp":return{opacity:range([0,1],[0,1]),transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[100,0]})},{scale:t.interpolate({inputRange:[0,1],outputRange:[.8,1]})}]};case"BounceIn":return{transform:[{scale:range([0,.5,.7,1],[.3,1.05,.9,1])}]};case"FadeInPulse":return{opacity:range([0,.5,1],[0,1,1]),transform:[{scale:range([0,.5,1],[1,1.1,1])}]};case"SpinScale":return{transform:[{rotate:t.interpolate({inputRange:[0,1],outputRange:["-180deg","0deg"]})},{scale:t.interpolate({inputRange:[0,1],outputRange:[0,1]})}]};case"WiggleIn":return{transform:[{translateY:range([0,.4,1],[100,0,0])},{rotate:range([0,.4,.6,.8,1],["-10deg","5deg","-3deg","1deg","0deg"])}]};case"ElasticIn":return{transform:[{scale:range([0,.55,.75,1],[0,1.1,.95,1])}]};default:return{transform:[]}}}const OVERSHOOT=new Set(["Rise","SlideUp","SpinScale"]);export function ChatLauncher({look:e,label:t,side:a,offsetX:n,offsetY:s,enter:r,reduced:i,buttonRef:o,onPress:u,testID:l}){const c=useTheme(),p=useSafeAreaInsets(),m=e.launcher.entrance,[g]=useState(()=>r&&!i&&"None"!==m),f=!i&&"FloatAndPulse"===e.launcher.idle,[d]=useState(()=>new Animated.Value(g?0:1)),[S]=useState(()=>new Animated.Value(0));useEffect(()=>{if(!g)return void d.setValue(1);const e="Rise"===m,t=Animated.timing(d,{toValue:1,duration:e?900:800,delay:e?400:1e3,easing:OVERSHOOT.has(m)?Easing.bezier(.34,e?1.4:1.56,.64,1):Easing.linear,useNativeDriver:!0});return t.start(),()=>t.stop()},[g,m,d]),useEffect(()=>{if(!f)return void S.setValue(0);const e=Animated.loop(Animated.sequence([Animated.timing(S,{toValue:1,duration:1600,easing:Easing.inOut(Easing.ease),useNativeDriver:!0}),Animated.timing(S,{toValue:0,duration:1600,easing:Easing.inOut(Easing.ease),useNativeDriver:!0})]));return e.start(),()=>e.stop()},[f,S]);const R="Pill"===e.launcher.style&&!e.launcher.compact,E=c.space[c.components["floating-action-button"]["edge-offset"]]+n,A={position:"absolute",bottom:s+p.bottom,..."start"===a?{left:E}:{right:E}},h=entranceStyle(m,d);return _jsx(Animated.View,{pointerEvents:"box-none",style:StyleSheet.absoluteFill,children:_jsx(Animated.View,{style:[A,{opacity:h.opacity??1,transform:[...h.transform,{translateY:S.interpolate({inputRange:[0,1],outputRange:[0,-4]})}]}],children:_jsx(FloatingActionButton,{ref:o,icon:"messages",label:R?t:void 0,collapsed:!R,accessibilityLabel:t,onPress:u,testID:l})})})}
@@ -0,0 +1 @@
1
+ "use strict";import{useEffect,useState}from"react";import{Animated}from"react-native";import{jsx as _jsx}from"react/jsx-runtime";const SPRING_DELAY={header:110,body:160,composer:240},revealFor=(e,t,n,r)=>n?null:"Spring"===e?{run:r,delay:SPRING_DELAY[t],duration:260,distance:10}:"Gentle"===e?{run:r,delay:0,duration:250,distance:12}:null;export const panelRun=e=>{const{motion:t,reduced:n,mode:r,run:a}=e;return{grow:"Spring"!==t||n||"screen"!==r?null:{run:a},reveal:{header:revealFor(t,"header",n,a),body:revealFor(t,"body",n,a),composer:revealFor(t,"composer",n,a)}}};const SPRING={stiffness:200,damping:22.4,mass:1,useNativeDriver:!0};export function ChatReveal({plan:e,flex:t=!1,children:n}){const[r]=useState(()=>new Animated.Value(null===e?1:0));useEffect(()=>{if(null===e)return void r.setValue(1);r.setValue(0);const t=Animated.timing(r,{toValue:1,duration:e.duration,delay:e.delay,useNativeDriver:!0});return t.start(),()=>t.stop()},[e,r]);const a=e?.distance??0;return _jsx(Animated.View,{style:{flex:t?1:void 0,opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[a,0]})}]},children:n})}export function ChatPanelGrow({grow:e,children:t}){const[n]=useState(()=>new Animated.Value(null===e?1:0)),[r,a]=useState({width:0,height:0});useEffect(()=>{if(null===e)return void n.setValue(1);n.setValue(0);const t=Animated.spring(n,{toValue:1,...SPRING});return t.start(),()=>t.stop()},[e,n]);const o=[{translateY:n.interpolate({inputRange:[0,1],outputRange:[r.height,0]})}];return _jsx(Animated.View,{onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;a(e=>e.width===t&&e.height===n?e:{width:t,height:n})},style:{flex:1,transform:o},children:t})}
@@ -1 +1 @@
1
- "use strict";import{mergeLabels}from"@webority/chat-core";import{useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{ChatFrame}from"./ChatFrame.js";import{jsx as _jsx}from"react/jsx-runtime";export function ChatScreen({chat:e,labels:t,renderers:o,layoutParts:r,loader:a="Steps",motion:s="On",pickAttachments:n,onOpenAttachment:i,onOpenTarget:l,onNavigate:c,openTicket:m,handoffHosts:h,resolveLink:f,keyboardOffset:p,title:u,headerActions:d,onClose:b,testID:k="chat-screen"}){const g=useTheme();return null===e.profile||e.features.VisitorChat?_jsx(View,{style:{flex:1,backgroundColor:g.colors.bg},testID:k,children:_jsx(ChatFrame,{chat:e,labels:mergeLabels(t),renderers:o,layoutParts:r,loader:a,motion:s,pickAttachments:n,onOpenAttachment:i,onOpenTarget:l,onNavigate:c,openTicket:m,handoffHosts:h,resolveLink:f,keyboardOffset:p,layout:"screen",title:u,headerActions:d,onClose:b,testID:`${k}-frame`})}):null}
1
+ "use strict";import{mergeLabels}from"@webority/chat-core";import{useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{ChatAppearanceScope}from"./ChatAppearanceScope.js";import{ChatFrame}from"./ChatFrame.js";import{jsx as _jsx}from"react/jsx-runtime";export function ChatScreen({chat:e,labels:t,renderers:r,layoutParts:a,loader:o="Steps",look:s,appearance:n,pickAttachments:c,onOpenAttachment:i,onOpenTarget:l,onNavigate:p,openTicket:m,handoffHosts:h,resolveLink:f,keyboardOffset:u,title:d,headerActions:b,onClose:k,testID:C="chat-screen"}){const A=useTheme();return null===e.profile||e.features.VisitorChat?_jsx(View,{style:{flex:1,backgroundColor:A.colors.bg},testID:C,children:_jsx(ChatAppearanceScope,{appearance:n,children:_jsx(ChatFrame,{chat:e,labels:mergeLabels(t),renderers:r,layoutParts:a,loader:o,look:s,pickAttachments:c,onOpenAttachment:i,onOpenTarget:l,onNavigate:p,openTicket:m,handoffHosts:h,resolveLink:f,keyboardOffset:u,layout:"screen",title:d,headerActions:b,onClose:k,testID:`${C}-frame`})})}):null}
@@ -1 +1 @@
1
- "use strict";import{mergeLabels}from"@webority/chat-core";import{BottomSheet,FloatingActionButton,useTheme}from"@webority/mobile-ui";import{useEffect,useRef}from"react";import{AccessibilityInfo,findNodeHandle,View}from"react-native";import{ChatFrame}from"./ChatFrame.js";import{ChatNudge}from"./ChatNudge.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_SNAP_POINTS=["92%"];export function ChatSheet({chat:e,labels:t,renderers:o,layoutParts:s,loader:n="Steps",motion:i="On",pickAttachments:r,onOpenAttachment:a,onOpenTarget:l,onNavigate:c,keyboardOffset:f,open:u,defaultOpen:p=!1,onOpenChange:m,position:h="end",bottomOffset:b=16,snapPoints:d=DEFAULT_SNAP_POINTS,compact:g=!1,openTicket:y,handoffHosts:C,resolveLink:A,conversationId:O,onClose:j,testID:x="chat-sheet"}){const N=useTheme(),T=mergeLabels(t),_=void 0!==u,k=_?u:e.open,I=useRef(null),P=useRef(!1),v=useRef(O??null),L=e.setChatVisible;useEffect(()=>{P.current||(P.current=!0,_||!p||null===e.profile||e.open||e.session.open({trigger:"manual"}))},[_,p,e.profile,e.open,e.session]),useEffect(()=>{_&&(u&&!e.open&&e.session.open({trigger:"manual"}),!u&&e.open&&e.session.close("button"))},[_,u,e.open,e.session]);const D=useRef(k);if(useEffect(()=>{if(D.current&&!k){const e=findNodeHandle(I.current);null!==e&&AccessibilityInfo.setAccessibilityFocus(e)}D.current=k},[k]),useEffect(()=>{L(k)},[L,k]),useEffect(()=>{!_&&O&&O!==v.current&&null!==e.profile&&(v.current=O,e.open||(e.session.open({trigger:"manual"}),m?.(!0)))},[_,O,e.profile,e.open,e.session,m]),null===e.profile||!e.features.VisitorChat)return null;const setOpen=t=>{t?e.session.open({trigger:"manual"}):e.session.close("button"),m?.(t)},closeSheet=()=>{setOpen(!1),j?.()},E="start"===h?"bottomLeft":"bottomRight";return _jsxs(View,{testID:x,children:[k?null:_jsx(FloatingActionButton,{ref:I,icon:"messages",label:g?void 0:T.launcher,position:E,bottomOffset:b,accessibilityLabel:T.launcher,onPress:()=>setOpen(!0),testID:`${x}-launcher`}),_jsx(ChatNudge,{chat:e,labels:T,enabled:!k&&e.features.Nudges,onActivate:()=>setOpen(!0),bottomOffset:b,position:h,testID:`${x}-nudge`}),_jsx(BottomSheet,{open:k,onClose:closeSheet,snapPoints:d,keyboardBehavior:"shift",scrollable:!1,enablePanDownToClose:!0,enableBackdropPress:!0,accessibilityViewIsModal:!0,accessibilityLabel:T.panelTitle,children:_jsx(View,{style:{flex:1,backgroundColor:N.colors.bg},children:_jsx(ChatFrame,{chat:e,labels:T,renderers:o,layoutParts:s,loader:n,motion:i,pickAttachments:r,onOpenAttachment:a,onOpenTarget:l,onNavigate:c,openTicket:y,handoffHosts:C,resolveLink:A,keyboardOffset:f,onClose:closeSheet,layout:"sheet",testID:`${x}-frame`})})})]})}
1
+ "use strict";import{mergeLabels,mergeLook}from"@webority/chat-core";import{BottomSheet,useReducedMotion,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{ChatAppearanceScope}from"./ChatAppearanceScope.js";import{ChatFrame}from"./ChatFrame.js";import{ChatLauncher}from"./ChatLauncher.js";import{ChatNudge}from"./ChatNudge.js";import{focusForAccessibility}from"./chatShared.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_SNAP_POINTS=["92%"],DEFAULT_BOTTOM_OFFSET=16;export function ChatSheet({chat:e,labels:t,renderers:o,layoutParts:s,loader:n="Steps",look:r,appearance:a,pickAttachments:i,onOpenAttachment:c,onOpenTarget:l,onNavigate:u,keyboardOffset:f,open:p,defaultOpen:h=!1,onOpenChange:m,snapPoints:d=DEFAULT_SNAP_POINTS,openTicket:b,handoffHosts:g,resolveLink:C,conversationId:S,onClose:j,testID:y="chat-sheet"}){const k=useTheme(),T=mergeLabels(t),x=useMemo(()=>mergeLook(r),[r]),A=useReducedMotion(),_="Reduced"===x.motion||A,O=a?.position??"end",E=void 0!==p,L=E?p:e.open,F=useRef(null),P=useRef(!1),R=useRef(S??null),v=e.setChatVisible,N=useRef(!1),D=!N.current,[I,w]=useState(0),M=useRef(L);useEffect(()=>{L&&(N.current=!0)},[L]),useEffect(()=>{L&&!M.current&&w(e=>e+1),M.current=L},[L]),useEffect(()=>{P.current||(P.current=!0,E||!h||null===e.profile||e.open||e.session.open({trigger:"manual"}))},[E,h,e.profile,e.open,e.session]),useEffect(()=>{E&&(p&&!e.open&&e.session.open({trigger:"manual"}),!p&&e.open&&e.session.close("button"))},[E,p,e.open,e.session]);const V=useRef(L);if(useEffect(()=>{V.current&&!L&&focusForAccessibility(F.current),V.current=L},[L]),useEffect(()=>{v(L)},[v,L]),useEffect(()=>{!E&&S&&S!==R.current&&null!==e.profile&&(R.current=S,e.open||(e.session.open({trigger:"manual"}),m?.(!0)))},[E,S,e.profile,e.open,e.session,m]),null===e.profile||!e.features.VisitorChat)return null;const setOpen=t=>{t?e.session.open({trigger:"manual"}):e.session.close("button"),m?.(t)},closeSheet=()=>{setOpen(!1),j?.()},B=a?.offsetY??16;return _jsx(View,{testID:y,style:StyleSheet.absoluteFill,pointerEvents:"box-none",children:_jsxs(ChatAppearanceScope,{appearance:a,children:[L?null:_jsx(ChatLauncher,{look:x,label:T.launcher,side:O,offsetX:a?.offsetX??0,offsetY:B,enter:D,reduced:_,buttonRef:F,onPress:()=>setOpen(!0),testID:`${y}-launcher`}),_jsx(ChatNudge,{chat:e,labels:T,enabled:!L&&e.features.Nudges,onActivate:()=>setOpen(!0),bottomOffset:B,position:O,testID:`${y}-nudge`}),_jsx(BottomSheet,{open:L,onClose:closeSheet,snapPoints:d,keyboardBehavior:"shift",scrollable:!1,enablePanDownToClose:!0,enableBackdropPress:!0,accessibilityViewIsModal:!0,accessibilityLabel:T.panelTitle,children:_jsx(View,{style:{flex:1,backgroundColor:k.colors.bg},children:_jsx(ChatFrame,{chat:e,labels:T,renderers:o,layoutParts:s,loader:n,look:r,pickAttachments:i,onOpenAttachment:c,onOpenTarget:l,onNavigate:u,openTicket:b,handoffHosts:g,resolveLink:C,keyboardOffset:f,onClose:closeSheet,layout:"sheet",enterKey:I,testID:`${y}-frame`})})})]})})}
@@ -1 +1 @@
1
- "use strict";import{createTurnApi,formatChatDateTime,handoffSettledIds,messagePlainText}from"@webority/chat-core";import{Button,MessageBubble,MessageList,Text,useTheme}from"@webority/mobile-ui";import{createElement,memo,useEffect,useMemo,useRef}from"react";import{AccessibilityInfo,findNodeHandle,View}from"react-native";import{AgentByline}from"./AgentByline.js";import{ChatEntrance}from"./ChatEntrance.js";import{ChatMessageActions}from"./ChatMessageActions.js";import{defaultOpenTarget,messageSignature}from"./chatShared.js";import{ChatLoader}from"./loaders/ChatLoader.js";import{TypingPill}from"./loaders/TypingPill.js";import{defaultRenderers}from"./renderers/index.js";import{NoticePart}from"./renderers/NoticePart.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const MINE=new Set(["Visitor","Customer"]),joinedText=e=>e.filter(e=>"Text"===e.kind).map(e=>e.text).join("\n\n"),renderPart=(e,t,s,a,i,r)=>{const n=e[t.kind];if(n)return createElement(n,{key:r,part:t,message:s,turn:a,pickAttachments:i});const o={kind:"Notice",code:"NeedsNewerApp",text:a.labels.needsNewerApp};return createElement(NoticePart,{key:r,part:o,message:s,turn:a})},sameMessage=(e,t)=>e.signature===t.signature&&e.message.id===t.message.id&&e.message.rating===t.message.rating&&e.message.stored===t.message.stored&&e.groupPosition===t.groupPosition&&e.isLast===t.isLast&&e.handoffSettled===t.handoffSettled&&e.isLastVisitor===t.isLastVisitor&&e.thinking===t.thinking&&e.streaming===t.streaming&&e.pickAttachments===t.pickAttachments&&e.labels===t.labels&&e.all===t.all&&e.layoutParts===t.layoutParts&&e.chat.session===t.chat.session&&e.chat.features===t.chat.features&&e.chat.onNavigate===t.chat.onNavigate&&e.onNavigate===t.onNavigate&&e.onOpenAttachment===t.onOpenAttachment&&e.onOpenTarget===t.onOpenTarget&&e.openTicket===t.openTicket&&e.resolveLink===t.resolveLink&&e.focusComposer===t.focusComposer&&e.byline===t.byline&&e.handoffHosts===t.handoffHosts;function ThreadMessageView({chat:e,message:t,labels:s,all:a,layoutParts:i,groupPosition:r,isLast:n,isLastVisitor:o,pickAttachments:l,onOpenAttachment:c,onOpenTarget:g,onNavigate:d,openTicket:m,handoffHosts:p,resolveLink:u,focusComposer:h,byline:f,sourceRows:y,testID:x}){const T=useTheme(),k=Object.assign(createTurnApi(e.session,{messageId:t.id,labels:s,openAttachment:c,openTarget:g??defaultOpenTarget,onNavigate:d??e.onNavigate,openTicket:m,handoffHosts:p,openCitation:e=>(e=>{const t=y.current.get(e),s=t?findNodeHandle(t):null;null!==s&&AccessibilityInfo.setAccessibilityFocus(s)})(String(e))}),{resolveLink:u,focusComposer:h,registerSourceRow:(e,t)=>{t?y.current.set(e,t):y.current.delete(e)}});let b=0;const nextSlot=()=>(b+=1,b),A=_jsx(ChatMessageActions,{chat:e,message:t,labels:s,isLast:n,isLastVisitor:o,testID:`${x}-actions`});if(MINE.has(t.author.kind)){const e=t.parts.filter(e=>"File"===e.kind),i=_jsxs(View,{style:{gap:T.space.xs},children:[e.map(e=>renderPart(a,e,t,k,l,`${t.id}-file-${nextSlot()}`)),A]});return _jsx(MessageBubble,{side:"mine",text:joinedText(t.parts),labels:{you:s.you},groupPosition:r,footer:i,testID:x})}const j="Agent"===t.author.kind,w=t.author.displayName||s.agent,N=(i?i(t):t.parts).map(e=>Array.isArray(e)?_jsx(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:T.space.xs},children:e.map(e=>renderPart(a,e,t,k,l,`${t.id}-part-${nextSlot()}`))},`${t.id}-group-${nextSlot()}`):renderPart(a,e,t,k,l,`${t.id}-item-${nextSlot()}`)),_=j&&f?[_jsx(AgentByline,{author:t.author,labels:s},`${t.id}-byline`),...N]:N,v=messagePlainText(t.parts);return _jsx(MessageBubble,{side:"theirs",author:j?void 0:t.author.displayName||s.assistant,text:j?`${s.agentSays(w)} ${v}`:v,streaming:t.streaming,groupPosition:r,footer:A,testID:x,children:_})}const ThreadMessage=memo(ThreadMessageView,sameMessage),TYPING_ORB_MARK=14,TYPING_ASSISTANT_MARK=8,TypingMark=({size:e})=>{const t=useTheme();return _jsx(View,{style:{width:e,height:e,borderRadius:t.radius.pill,backgroundColor:t.colors.primary}})},TYPING_DOT=6,TypingDots=()=>{const e=useTheme();return _jsx(View,{style:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},children:[0,1,2].map(t=>_jsx(View,{style:{width:6,height:6,borderRadius:3,backgroundColor:e.colors["text-muted"]}},t))})},TurnGap=()=>{const e=useTheme();return _jsx(View,{style:{height:e.space.lg}})},followNew=()=>!0;export function ChatThread({chat:e,labels:t,renderers:s,layoutParts:a,loader:i="Steps",motion:r="On",pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:c,openTicket:g,handoffHosts:d,resolveLink:m,focusComposer:p,keyboardAware:u,keyboardOffset:h,empty:f,style:y,testID:x="chat-thread"}){const T=useTheme(),k=useMemo(()=>({...defaultRenderers,...s}),[s]),b=e.messages[0],A=e.greeting??"",j=useMemo(()=>""!==A&&void 0!==b&&MINE.has(b.author.kind)?{...b,id:"greeting",author:{...b.author,kind:"Assistant",displayName:null,avatarUrl:null},parts:[{kind:"Text",text:A}],stored:!1,streaming:!1,restored:!1,rating:null}:null,[A,b]),w=useMemo(()=>{const t=e.messages.filter(e=>!(e.streaming&&0===e.parts.length)).reverse();return j?[...t,j]:t},[e.messages,j]),N=e.messages[e.messages.length-1]?.id,_=useRef(new Map),v=useRef(null);useEffect(()=>{if(null!==v.current)for(const s of e.messages){if(MINE.has(s.author.kind)||s.streaming||s.restored||v.current.has(s.id))continue;if("Agent"===s.author.kind&&!s.stored)continue;v.current.add(s.id);const e=messagePlainText(s.parts);""!==e&&AccessibilityInfo.announceForAccessibility("Agent"===s.author.kind?`${t.agentSays(s.author.displayName||t.agent)} ${e}`:e)}else v.current=new Set(e.messages.map(e=>e.id))},[e.messages,t]);const M=useMemo(()=>{for(let t=e.messages.length-1;t>=0;t-=1){const s=e.messages[t];if(s?.stored&&"Visitor"===s.author.kind)return s.id}},[e.messages]),P=useMemo(()=>{const t=new Set;return e.messages.forEach((s,a)=>{if("Agent"!==s.author.kind)return;const i=e.messages[a-1];"Agent"===i?.author.kind&&(i.author.displayName||"")===(s.author.displayName||"")||t.add(s.id)}),t},[e.messages]),I=useMemo(()=>handoffSettledIds(e.messages),[e.messages]),L=e.turnError,S="daily_limit"===L?.code,C=null!==L&&/feature_off$/.test(L.code),$=S&&L?.resetsDateTimeUtc?` ${t.dailyLimitRefresh(formatChatDateTime(L.resetsDateTimeUtc))}`:"",D=e.streaming||null===L&&!e.stopped?null:_jsxs(View,{style:{gap:T.space.xs},testID:`${x}-error`,children:[_jsx(Text,null!==L?{variant:"bodySmall",color:"danger",accessibilityRole:S?void 0:"alert",accessibilityLiveRegion:S?"polite":void 0,children:`${L.message}${$}`}:{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:t.stopped}),!e.features.Retry||S||C?null:_jsx(View,{style:{flexDirection:"row"},children:_jsx(Button,{label:t.retry,variant:"link",size:"sm",onPress:()=>{e.retry()},testID:`${x}-retry`})})]}),V=e.thinking&&null!==e.profile?_jsx(ChatLoader,{style:i,steps:e.steps,phrases:e.profile.experience.pacing.thinkingPhrases,intervalMs:e.profile.experience.pacing.phraseIntervalMs,announce:t.preparingAnswer(e.profile.assistant.name),motion:r}):null,O=!0===e.pending?.typing?_jsx(TypingPill,{motion:r,mark:_jsx(TypingMark,{size:"Orb"===i?14:8})}):null,R=null!==e.agentTyping&&"WithAgent"===e.conversationState?_jsxs(View,{style:{gap:T.space.xs,alignSelf:"flex-start"},children:[_jsx(TypingPill,{motion:r,mark:_jsx(TypingDots,{})}),_jsx(Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:t.agentTyping(e.agentTyping.displayName||t.agent)})]}):null,E=O||V||D||R?_jsxs(View,{style:{gap:T.space.sm},children:[O,V,R,D]}):void 0;return _jsx(MessageList,{messages:w,keyExtractor:e=>e.id,renderMessage:({item:s,groupPosition:i})=>_jsx(ChatEntrance,{animate:!s.restored,children:_jsx(ThreadMessage,{chat:e,message:s,signature:messageSignature(s),labels:t,all:k,layoutParts:a,groupPosition:i,isLast:s.id===N,isLastVisitor:s.id===M,handoffSettled:I.has(s.id),thinking:e.thinking,streaming:e.streaming,pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:c,openTicket:g,handoffHosts:d,resolveLink:m,focusComposer:p,byline:P.has(s.id),sourceRows:_,testID:`${x}-${s.id}`})}),getAuthorKey:e=>e.author.kind,getDate:e=>e.createdDateTimeUtc,followNew:followNew,typing:E,empty:f,ItemSeparatorComponent:TurnGap,keyboardAware:u,keyboardOffset:h,accessibilityLabel:t.thread,style:y,testID:x})}
1
+ "use strict";import{createTurnApi,formatChatDateTime,handoffSettledIds,messagePlainText}from"@webority/chat-core";import{Button,MessageBubble,MessageList,Text,useTheme}from"@webority/mobile-ui";import{createElement,memo,useEffect,useMemo,useRef}from"react";import{AccessibilityInfo,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{TypingPill}from"./loaders/TypingPill.js";import{defaultRenderers}from"./renderers/index.js";import{NoticePart}from"./renderers/NoticePart.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const MINE=new Set(["Visitor","Customer"]),joinedText=e=>e.filter(e=>"Text"===e.kind).map(e=>e.text).join("\n\n"),renderPart=(e,t,s,a,r,i)=>{const n=e[t.kind];if(n)return createElement(n,{key:i,part:t,message:s,turn:a,pickAttachments:r});const o={kind:"Notice",code:"NeedsNewerApp",text:a.labels.needsNewerApp};return createElement(NoticePart,{key:i,part:o,message:s,turn:a})},sameMessage=(e,t)=>e.signature===t.signature&&e.message.id===t.message.id&&e.message.rating===t.message.rating&&e.message.stored===t.message.stored&&e.groupPosition===t.groupPosition&&e.isLast===t.isLast&&e.handoffSettled===t.handoffSettled&&e.isLastVisitor===t.isLastVisitor&&e.thinking===t.thinking&&e.streaming===t.streaming&&e.pickAttachments===t.pickAttachments&&e.labels===t.labels&&e.all===t.all&&e.layoutParts===t.layoutParts&&e.chat.session===t.chat.session&&e.chat.features===t.chat.features&&e.chat.onNavigate===t.chat.onNavigate&&e.onNavigate===t.onNavigate&&e.onOpenAttachment===t.onOpenAttachment&&e.onOpenTarget===t.onOpenTarget&&e.openTicket===t.openTicket&&e.resolveLink===t.resolveLink&&e.focusComposer===t.focusComposer&&e.byline===t.byline&&e.handoffHosts===t.handoffHosts;function ThreadMessageView({chat:e,message:t,labels:s,all:a,layoutParts:r,groupPosition:i,isLast:n,isLastVisitor:o,pickAttachments:l,onOpenAttachment:c,onOpenTarget:g,onNavigate:m,openTicket:d,handoffHosts:p,resolveLink:u,focusComposer:h,byline:f,sourceRows:y,testID:x}){const T=useTheme(),k=Object.assign(createTurnApi(e.session,{messageId:t.id,labels:s,openAttachment:c,openTarget:g??defaultOpenTarget,onNavigate:m??e.onNavigate,openTicket:d,handoffHosts:p,openCitation:e=>{return t=String(e),void focusForAccessibility(y.current.get(t));var t}}),{resolveLink:u,focusComposer:h,registerSourceRow:(e,t)=>{t?y.current.set(e,t):y.current.delete(e)}});let b=0;const nextSlot=()=>(b+=1,b),A=_jsx(ChatMessageActions,{chat:e,message:t,labels:s,isLast:n,isLastVisitor:o,testID:`${x}-actions`});if(MINE.has(t.author.kind)){const e=t.parts.filter(e=>"File"===e.kind),r=_jsxs(View,{style:{gap:T.space.xs},children:[e.map(e=>renderPart(a,e,t,k,l,`${t.id}-file-${nextSlot()}`)),A]});return _jsx(MessageBubble,{side:"mine",text:joinedText(t.parts),labels:{you:s.you},groupPosition:i,footer:r,testID:x})}const j="Agent"===t.author.kind,w=t.author.displayName||s.agent,v=(r?r(t):t.parts).map(e=>Array.isArray(e)?_jsx(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:T.space.xs},children:e.map(e=>renderPart(a,e,t,k,l,`${t.id}-part-${nextSlot()}`))},`${t.id}-group-${nextSlot()}`):renderPart(a,e,t,k,l,`${t.id}-item-${nextSlot()}`)),N=j&&f?[_jsx(AgentByline,{author:t.author,labels:s},`${t.id}-byline`),...v]:v,_=messagePlainText(t.parts);return _jsx(MessageBubble,{side:"theirs",author:j?void 0:t.author.displayName||s.assistant,text:j?`${s.agentSays(w)} ${_}`:_,streaming:t.streaming,groupPosition:i,footer:A,testID:x,children:N})}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",pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:c,openTicket:g,handoffHosts:m,resolveLink:d,focusComposer:p,keyboardAware:u,keyboardOffset:h,empty:f,style:y,testID:x="chat-thread"}){const T=useTheme(),k=useMemo(()=>({...defaultRenderers,...s}),[s]),b=e.messages[0],A=e.greeting??"",j=useMemo(()=>""!==A&&void 0!==b&&MINE.has(b.author.kind)?{...b,id:"greeting",author:{...b.author,kind:"Assistant",displayName:null,avatarUrl:null},parts:[{kind:"Text",text:A}],stored:!1,streaming:!1,restored:!1,rating:null}:null,[A,b]),w=useMemo(()=>{const t=e.messages.filter(e=>!(e.streaming&&0===e.parts.length)).reverse();return j?[...t,j]:t},[e.messages,j]),v=e.messages[e.messages.length-1]?.id,N=useRef(new Map),_=useRef(null);useEffect(()=>{if(null!==_.current)for(const s of e.messages){if(MINE.has(s.author.kind)||s.streaming||s.restored||_.current.has(s.id))continue;if("Agent"===s.author.kind&&!s.stored)continue;_.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 _.current=new Set(e.messages.map(e=>e.id))},[e.messages,t]);const M=useMemo(()=>{for(let t=e.messages.length-1;t>=0;t-=1){const s=e.messages[t];if(s?.stored&&"Visitor"===s.author.kind)return s.id}},[e.messages]),P=useMemo(()=>{const t=new Set;return e.messages.forEach((s,a)=>{if("Agent"!==s.author.kind)return;const r=e.messages[a-1];"Agent"===r?.author.kind&&(r.author.displayName||"")===(s.author.displayName||"")||t.add(s.id)}),t},[e.messages]),L=useMemo(()=>handoffSettledIds(e.messages),[e.messages]),I=e.turnError,S="daily_limit"===I?.code,C=null!==I&&/feature_off$/.test(I.code),$=S&&I?.resetsDateTimeUtc?` ${t.dailyLimitRefresh(formatChatDateTime(I.resetsDateTimeUtc))}`:"",D=e.streaming||null===I&&!e.stopped?null:_jsxs(View,{style:{gap:T.space.xs},testID:`${x}-error`,children:[_jsx(Text,null!==I?{variant:"bodySmall",color:"danger",accessibilityRole:S?void 0:"alert",accessibilityLiveRegion:S?"polite":void 0,children:`${I.message}${$}`}:{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:t.stopped}),!e.features.Retry||S||C?null:_jsx(View,{style:{flexDirection:"row"},children:_jsx(Button,{label:t.retry,variant:"link",size:"sm",onPress:()=>{e.retry()},testID:`${x}-retry`})})]}),V=e.thinking&&null!==e.profile?_jsx(ChatLoader,{style: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,O=!0===e.pending?.typing?_jsx(TypingPill,{motion:i,mark:_jsx(TypingMark,{size:"Orb"===r?14:8})}):null,R=null!==e.agentTyping&&"WithAgent"===e.conversationState?_jsxs(View,{style:{gap:T.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,E=O||V||D||R?_jsxs(View,{style:{gap:T.space.sm},children:[O,V,R,D]}):void 0;return _jsx(MessageList,{messages:w,keyExtractor:e=>e.id,renderMessage:({item:s,groupPosition:r})=>_jsx(ChatEntrance,{animate:!s.restored,children:_jsx(ThreadMessage,{chat:e,message:s,signature:messageSignature(s),labels:t,all:k,layoutParts:a,groupPosition:r,isLast:s.id===v,isLastVisitor:s.id===M,handoffSettled:L.has(s.id),thinking:e.thinking,streaming:e.streaming,pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:c,openTicket:g,handoffHosts:m,resolveLink:d,focusComposer:p,byline:P.has(s.id),sourceRows:N,testID:`${x}-${s.id}`})}),getAuthorKey:e=>e.author.kind,getDate:e=>e.createdDateTimeUtc,followNew:followNew,typing:E,empty:f,ItemSeparatorComponent:TurnGap,keyboardAware:u,keyboardOffset:h,accessibilityLabel:t.thread,style:y,testID:x})}
@@ -1 +1 @@
1
- "use strict";import{Linking}from"react-native";export function messageSignature(t){let e=0;for(const n of t.parts)"Text"===n.kind&&(e+=n.text.length);return`${t.id}|${t.parts.length}|${e}`}const ABSOLUTE_WEB_URL=/^https?:\/\//i;export function defaultOpenTarget(t){ABSOLUTE_WEB_URL.test(t)&&Linking.openURL(t).catch(()=>{})}
1
+ "use strict";import{AccessibilityInfo,findNodeHandle,Linking,Platform}from"react-native";export function focusForAccessibility(t){if(null==t)return;if("web"===Platform.OS)return void t.focus?.();const e=findNodeHandle(t);null!==e&&AccessibilityInfo.setAccessibilityFocus(e)}export function messageSignature(t){let e=0;for(const i of t.parts)"Text"===i.kind&&(e+=i.text.length);return`${t.id}|${t.parts.length}|${e}`}const ABSOLUTE_WEB_URL=/^https?:\/\//i;export function defaultOpenTarget(t){ABSOLUTE_WEB_URL.test(t)&&Linking.openURL(t).catch(()=>{})}
@@ -1 +1 @@
1
- "use strict";import{AuthedImage,Button,Modal,Text,useTheme,ZoomableImage}from"@webority/mobile-ui";import{useCallback,useEffect,useRef,useState}from"react";import{Pressable,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export function ImagePart({part:e,turn:t}){const a=useTheme(),s=useSafeAreaInsets(),[l,r]=useState(!1),[i,n]=useState(null),[o,c]=useState(!1),u=useRef(t.loadAttachmentUrl);u.current=t.loadAttachmentUrl;const m=useRef(0),d=useCallback(e=>{const t=++m.current;n(null),c(!1),u.current(e).then(e=>{m.current===t&&n(e)},()=>{m.current===t&&c(!0)})},[]);if(useEffect(()=>(d(e.attachmentId),()=>{m.current++}),[e.attachmentId,d]),o)return _jsxs(View,{style:{gap:a.space.xs},children:[_jsx(Text,{variant:"bodySmall",color:"secondary",children:e.alt}),_jsx(Button,{variant:"soft",size:"sm",label:t.labels.retry,onPress:()=>d(e.attachmentId),testID:`image-retry-${e.attachmentId}`})]});if(null===i)return _jsx(Text,{variant:"bodySmall",color:"secondary",children:e.alt});const b=null!==e.width&&null!==e.height&&e.width>0&&e.height>0?e.width/e.height:null,h=_jsx(Text,{variant:"bodySmall",color:"secondary",children:e.alt});return _jsxs(_Fragment,{children:[_jsx(Pressable,{accessibilityRole:"imagebutton",accessibilityLabel:t.labels.imageOpen(e.alt),onPress:()=>r(!0),children:_jsx(AuthedImage,{uri:i,contentFit:"contain",accessible:!0,accessibilityLabel:e.alt,labels:{loading:t.labels.imageLoading},style:{width:"100%",...null===b?{minHeight:160}:{aspectRatio:b},maxHeight:320,borderRadius:a.radius.md},fallback:h})}),_jsx(Modal,{open:l,onClose:()=>r(!1),backdropPressClose:!1,presentation:"fullScreen",accessibilityLabel:e.alt,children:_jsxs(View,{style:{flex:1,backgroundColor:a.colors.bg},children:[_jsx(ZoomableImage,{style:{flex:1},accessibilityLabel:e.alt,children:_jsx(AuthedImage,{uri:i,contentFit:"contain",style:{flex:1},accessibilityLabel:e.alt})}),_jsx(View,{style:{position:"absolute",top:s.top+a.space.sm,right:a.space.sm},children:_jsx(Button,{variant:"soft",size:"sm",label:t.labels.close,onPress:()=>r(!1)})})]})})]})}
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 +1 @@
1
- "use strict";import{Button,Card,Checkbox,Chip,ChoiceGroup,Input,ProgressBar,Text,useTheme}from"@webority/mobile-ui";import{useCallback,useEffect,useRef,useState}from"react";import{AccessibilityInfo,findNodeHandle,View}from"react-native";import{NoticePart}from"./NoticePart.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const FIELD_TYPES=new Set(["Email","Phone","Name","Company","Text","LongText","Choice","MultiChoice","TimeSlot","File","Consent"]),isUndrawnField=e=>!FIELD_TYPES.has(e.type),fileNameOf=(e,t)=>{const i=e.name;return"string"==typeof i&&""!==i?i:t},slotFormat=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short",hour:"numeric",minute:"2-digit"}),selectedIds=e=>""===e?[]:JSON.parse(e),KEYBOARD_TYPES={Email:"email-address",Phone:"phone-pad"},AUTO_COMPLETE={Email:"email",Phone:"tel",Name:"name",Company:"organization"},optionalSuffix=(e,t)=>e.required?"":` (${t.inputOptional})`,firstErrorKey=(e,t)=>e.find(e=>void 0!==t[e.key])?.key;function OpenRequest({part:e,turn:t,pickAttachments:i}){const r=useTheme(),{labels:s,features:n}=t,[a,l]=useState({}),[o,c]=useState({}),[u,d]=useState(""),[p,y]=useState(!1),[f,m]=useState({}),[x,h]=useState({}),[b,k]=useState({}),v=useRef({}),g=useRef({}),j=useRef(f),_=useRef(0),T=useRef(!1),C=useCallback(e=>{const t=v.current[e];if(t)return void t.focus();const i=g.current[e];if(!i)return;const r=findNodeHandle(i);null!==r&&AccessibilityInfo.setAccessibilityFocus(r)},[]);useEffect(()=>{if(p||!T.current)return;T.current=!1;const t=firstErrorKey(e.fields,o);void 0!==t&&C(t)},[p,o,e.fields,C]);const setValue=(e,t)=>l(i=>({...i,[e]:t})),commitUploads=e=>{j.current=e,m(e)},patchUpload=(e,t)=>{const i=j.current[e];i&&commitUploads({...j.current,[e]:{...i,...t}})},isLiveUpload=(e,t)=>j.current[e]?.token===t,w=Object.values(f).some(e=>"Ready"!==e.status),leave=async e=>{y(!0),d("");try{await e()}catch{d(s.errorGeneric),y(!1)}},S=n.LeadShortcuts,R=S&&1===e.fields.length&&!e.fields[0].required,E=S&&e.cancellable;return _jsx(Card,{variant:"outline",padding:"sm",accessibilityLabel:e.title||void 0,children:_jsxs(View,{style:{gap:r.space.sm},children:[e.title?_jsx(Text,{variant:"label",accessibilityRole:"header",children:e.title}):null,e.allowTyped?_jsx(Text,{variant:"caption",color:"secondary",children:s.typeAnswer}):null,e.fields.map(n=>{const l=a[n.key]??"",c=o[n.key];if("File"===n.type){const e=f[n.key];return _jsxs(View,{style:{gap:r.space.xs},children:[_jsx(Text,{variant:"label",children:`${n.label}${optionalSuffix(n,s)}`}),e?_jsxs(View,{style:{gap:r.space.xxs},children:[_jsx(Chip,{label:e.fileName,variant:"soft",onRemove:()=>{return e=n.key,commitUploads(Object.fromEntries(Object.entries(j.current).filter(([t])=>t!==e))),void setValue(e,"");var e},labels:{remove:s.inputRemoveFile}}),"Uploading"===e.status?_jsx(ProgressBar,{progress:e.progress??void 0,label:s.attachmentUploading,height:4}):null,"Failed"===e.status?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"assertive",children:s.attachmentFailed}):null]}):_jsx(View,{style:{flexDirection:"row"},children:_jsx(Button,{label:s.inputChooseFile,variant:"soft",size:"sm",leftIcon:"paperclip",disabled:p||void 0===i,onPress:()=>{(async e=>{if(!i)return;let r;try{r=await i()}catch{return void d(s.errorGeneric)}const n=r[0];if(!n)return;_.current+=1;const a=_.current;commitUploads({...j.current,[e.key]:{fileName:fileNameOf(n,e.label),status:"Uploading",progress:null,token:a}});try{const i=await t.uploadInputFile(n,t=>{isLiveUpload(e.key,a)&&patchUpload(e.key,{progress:t})});isLiveUpload(e.key,a)&&(setValue(e.key,i),patchUpload(e.key,{status:"Ready",progress:null}))}catch{isLiveUpload(e.key,a)&&(setValue(e.key,""),patchUpload(e.key,{status:"Failed",progress:null}))}})(n)}})}),c?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"assertive",children:c}):null]},n.key)}if("MultiChoice"===n.type){const e=(n.options??[]).map(e=>({label:e.label,value:e.id}));return _jsxs(View,{style:{gap:r.space.xs},children:[_jsx(Text,{variant:"label",children:`${n.label}${optionalSuffix(n,s)}`}),_jsx(View,{ref:e=>{g.current[n.key]=e},children:_jsx(ChoiceGroup,{selectionMode:"multiple",options:e,value:selectedIds(l),onChange:t=>setValue(n.key,JSON.stringify(e.filter(e=>t.includes(e.value)).map(e=>e.value))),accessibilityLabel:n.label,error:c,disabled:p})})]},n.key)}if("Choice"===n.type||"TimeSlot"===n.type){const e="TimeSlot"===n.type?(n.slots??[]).map(e=>({label:slotFormat.format(new Date(e.startDateTimeUtc)),value:e.id})):(n.options??[]).map(e=>({label:e.label,value:e.id}));return _jsxs(View,{style:{gap:r.space.xs},children:[_jsx(Text,{variant:"label",children:`${n.label}${optionalSuffix(n,s)}`}),_jsx(View,{ref:e=>{g.current[n.key]=e},children:_jsx(ChoiceGroup,{options:e,value:""===l?void 0:l,onChange:e=>setValue(n.key,String(e)),accessibilityLabel:n.label,error:c,disabled:p})})]},n.key)}if("Consent"===n.type)return _jsx(Checkbox,{checked:"true"===l,onChange:e=>setValue(n.key,e?"true":"false"),label:n.consentText??n.label,error:c,disabled:p},n.key);const u=_jsx(Input,{ref:e=>{v.current[n.key]=e},label:n.label,placeholder:n.placeholder??void 0,value:l,onChangeText:e=>setValue(n.key,e),maxLength:n.maxLength??void 0,required:n.required,error:c,help:n.required?void 0:s.inputOptional,labelMode:"top",disabled:p,type:n.secret?"password":"LongText"===n.type?"textarea":"input",keyboardType:KEYBOARD_TYPES[n.type]??"default",autoCapitalize:"Email"===n.type?"none":void 0,autoComplete:AUTO_COMPLETE[n.type]},n.key);if(!("Otp"===n.verify&&("Email"===n.type||"Phone"===n.type)))return u;const y=b[n.key];return _jsxs(View,{style:{gap:r.space.xs},children:[u,_jsxs(View,{style:{gap:r.space.xs},children:[_jsx(Button,{label:s.inputSendCode,variant:"soft",size:"sm",disabled:p,onPress:()=>{(async i=>{if("Otp"===i.verify)try{await t.sendOtp(e.requestId,{fieldKey:i.key,value:(a[i.key]??"").trim()}),k(e=>({...e,[i.key]:"sent"}))}catch{k(e=>({...e,[i.key]:"failed"}))}})(n)},testID:`otp-send-${n.key}`}),_jsx(Input,{label:s.inputEnterCode,value:x[n.key]??"",onChangeText:e=>h(t=>({...t,[n.key]:e})),keyboardType:"number-pad",autoComplete:"one-time-code",disabled:p}),y?_jsx(Text,{variant:"caption",color:"failed"===y?"danger":"secondary",accessibilityLiveRegion:"polite",children:"failed"===y?s.inputCodeFailed:s.inputCodeSent}):null]})]},n.key)}),""!==u?_jsx(Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:u}):null,_jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:r.space.sm},children:[_jsx(Button,{label:p?s.inputSubmitting:e.submitLabel,loading:p,disabled:p||w,onPress:()=>{(async()=>{if(w)return;const i={},r={};for(const t of e.fields){const e=a[t.key]??"";if("Consent"===t.type){const n="true"===e;t.required&&!n&&(i[t.key]=s.inputConsentRequired),r[t.key]=n?"true":"false"}else if("Choice"===t.type||"TimeSlot"===t.type)t.required&&""===e&&(i[t.key]=s.inputRequired),r[t.key]=e;else if("MultiChoice"===t.type){const n=selectedIds(e);t.required&&0===n.length&&(i[t.key]=s.inputRequired),r[t.key]=JSON.stringify(n)}else if("File"===t.type)t.required&&""===e&&(i[t.key]=s.inputRequired),r[t.key]=e;else{const n=t.secret?e:e.trim();t.required&&""===n&&(i[t.key]=s.inputRequired),r[t.key]=n}}const n={};for(const t of e.fields){if("Otp"!==t.verify)continue;const e=(x[t.key]??"").trim();""===e&&(i[t.key]=s.inputRequired),n[t.key]=e}if(c(i),Object.keys(i).length>0){const t=firstErrorKey(e.fields,i);return void(void 0!==t&&C(t))}y(!0),d("");try{const i=await t.answerInput(e.requestId,r,Object.keys(n).length>0?n:null);if(i.ok)return;c(i.errors),T.current=!0,d(i.message??"")}catch{d(s.errorGeneric)}y(!1)})()}}),w?_jsx(Text,{variant:"caption",color:"secondary",children:s.attachmentUploading}):null,R?_jsx(Button,{label:s.skip,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.skipInput(e.requestId))}}):null,E?_jsx(Button,{label:s.cancel,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.cancelLead())}}):null]})]})})}export function InputRequestPart(e){const{part:t,message:i,turn:r,pickAttachments:s}=e;if("InputRequest"!==t.kind||t.fields.some(isUndrawnField)){const e={kind:"Notice",code:"NeedsNewerApp",text:r.labels.needsNewerApp};return _jsx(NoticePart,{part:e,message:i,turn:r})}return"Answered"===t.state?_jsx(Text,{variant:"bodySmall",color:"secondary",children:t.answeredSummary||r.labels.inputAnswered}):"Skipped"===t.state?_jsx(Text,{variant:"bodySmall",color:"secondary",children:r.labels.inputSkipped}):"Expired"===t.state?_jsx(Text,{variant:"bodySmall",color:"secondary",children:r.labels.inputExpired}):_jsx(OpenRequest,{part:t,turn:r,pickAttachments:s},t.requestId)}
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{NoticePart}from"./NoticePart.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const FIELD_TYPES=new Set(["Email","Phone","Name","Company","Text","LongText","Choice","MultiChoice","TimeSlot","File","Consent"]),isUndrawnField=e=>!FIELD_TYPES.has(e.type),fileNameOf=(e,t)=>{const i=e.name;return"string"==typeof i&&""!==i?i:t},slotFormat=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short",hour:"numeric",minute:"2-digit"}),selectedIds=e=>""===e?[]:JSON.parse(e),KEYBOARD_TYPES={Email:"email-address",Phone:"phone-pad"},AUTO_COMPLETE={Email:"email",Phone:"tel",Name:"name",Company:"organization"},optionalSuffix=(e,t)=>e.required?"":` (${t.inputOptional})`,firstErrorKey=(e,t)=>e.find(e=>void 0!==t[e.key])?.key;function OpenRequest({part:e,turn:t,pickAttachments:i}){const r=useTheme(),{labels:s,features:a}=t,[n,l]=useState({}),[o,c]=useState({}),[u,d]=useState(""),[p,y]=useState(!1),[f,m]=useState({}),[x,h]=useState({}),[b,k]=useState({}),v=useRef({}),g=useRef({}),j=useRef(f),_=useRef(0),T=useRef(!1),C=useCallback(e=>{const t=v.current[e];if(t)return void t.focus();const i=g.current[e];i&&focusForAccessibility(i)},[]);useEffect(()=>{if(p||!T.current)return;T.current=!1;const t=firstErrorKey(e.fields,o);void 0!==t&&C(t)},[p,o,e.fields,C]);const setValue=(e,t)=>l(i=>({...i,[e]:t})),commitUploads=e=>{j.current=e,m(e)},patchUpload=(e,t)=>{const i=j.current[e];i&&commitUploads({...j.current,[e]:{...i,...t}})},isLiveUpload=(e,t)=>j.current[e]?.token===t,S=Object.values(f).some(e=>"Ready"!==e.status),leave=async e=>{y(!0),d("");try{await e()}catch{d(s.errorGeneric),y(!1)}},w=a.LeadShortcuts,R=w&&1===e.fields.length&&!e.fields[0].required,E=w&&e.cancellable;return _jsx(Card,{variant:"outline",padding:"sm",accessibilityLabel:e.title||void 0,children:_jsxs(View,{style:{gap:r.space.sm},children:[e.title?_jsx(Text,{variant:"label",accessibilityRole:"header",children:e.title}):null,e.allowTyped?_jsx(Text,{variant:"caption",color:"secondary",children:s.typeAnswer}):null,e.fields.map(a=>{const l=n[a.key]??"",c=o[a.key];if("File"===a.type){const e=f[a.key];return _jsxs(View,{style:{gap:r.space.xs},children:[_jsx(Text,{variant:"label",children:`${a.label}${optionalSuffix(a,s)}`}),e?_jsxs(View,{style:{gap:r.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,{progress:e.progress??void 0,label:s.attachmentUploading,height:4}):null,"Failed"===e.status?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"assertive",children:s.attachmentFailed}):null]}):_jsx(View,{style:{flexDirection:"row"},children:_jsx(Button,{label:s.inputChooseFile,variant:"soft",size:"sm",leftIcon:"paperclip",disabled:p||void 0===i,onPress:()=>{(async e=>{if(!i)return;let r;try{r=await i()}catch{return void d(s.errorGeneric)}const a=r[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 i=await t.uploadInputFile(a,t=>{isLiveUpload(e.key,n)&&patchUpload(e.key,{progress:t})});isLiveUpload(e.key,n)&&(setValue(e.key,i),patchUpload(e.key,{status:"Ready",progress:null}))}catch{isLiveUpload(e.key,n)&&(setValue(e.key,""),patchUpload(e.key,{status:"Failed",progress:null}))}})(a)}})}),c?_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:r.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,{selectionMode:"multiple",options:e,value:selectedIds(l),onChange:t=>setValue(a.key,JSON.stringify(e.filter(e=>t.includes(e.value)).map(e=>e.value))),accessibilityLabel:a.label,error:c,disabled:p})})]},a.key)}if("Choice"===a.type||"TimeSlot"===a.type){const e="TimeSlot"===a.type?(a.slots??[]).map(e=>({label:slotFormat.format(new Date(e.startDateTimeUtc)),value:e.id})):(a.options??[]).map(e=>({label:e.label,value:e.id}));return _jsxs(View,{style:{gap:r.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,value:""===l?void 0:l,onChange:e=>setValue(a.key,String(e)),accessibilityLabel:a.label,error:c,disabled:p})})]},a.key)}if("Consent"===a.type)return _jsx(Checkbox,{checked:"true"===l,onChange:e=>setValue(a.key,e?"true":"false"),label:a.consentText??a.label,error:c,disabled:p},a.key);const u=_jsx(Input,{ref:e=>{v.current[a.key]=e},label:a.label,placeholder:a.placeholder??void 0,value:l,onChangeText:e=>setValue(a.key,e),maxLength:a.maxLength??void 0,required:a.required,error:c,help:a.required?void 0:s.inputOptional,labelMode:"top",disabled:p,type:a.secret?"password":"LongText"===a.type?"textarea":"input",keyboardType:KEYBOARD_TYPES[a.type]??"default",autoCapitalize:"Email"===a.type?"none":void 0,autoComplete:AUTO_COMPLETE[a.type]},a.key);if(!("Otp"===a.verify&&("Email"===a.type||"Phone"===a.type)))return u;const y=b[a.key];return _jsxs(View,{style:{gap:r.space.xs},children:[u,_jsxs(View,{style:{gap:r.space.xs},children:[_jsx(Button,{label:s.inputSendCode,variant:"soft",size:"sm",disabled:p,onPress:()=>{(async i=>{if("Otp"===i.verify)try{await t.sendOtp(e.requestId,{fieldKey:i.key,value:(n[i.key]??"").trim()}),k(e=>({...e,[i.key]:"sent"}))}catch{k(e=>({...e,[i.key]:"failed"}))}})(a)},testID:`otp-send-${a.key}`}),_jsx(Input,{label:s.inputEnterCode,value:x[a.key]??"",onChangeText:e=>h(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:r.space.sm},children:[_jsx(Button,{label:p?s.inputSubmitting:e.submitLabel,loading:p,disabled:p||S,onPress:()=>{(async()=>{if(S)return;const i={},r={};for(const t of e.fields){const e=n[t.key]??"";if("Consent"===t.type){const a="true"===e;t.required&&!a&&(i[t.key]=s.inputConsentRequired),r[t.key]=a?"true":"false"}else if("Choice"===t.type||"TimeSlot"===t.type)t.required&&""===e&&(i[t.key]=s.inputRequired),r[t.key]=e;else if("MultiChoice"===t.type){const a=selectedIds(e);t.required&&0===a.length&&(i[t.key]=s.inputRequired),r[t.key]=JSON.stringify(a)}else if("File"===t.type)t.required&&""===e&&(i[t.key]=s.inputRequired),r[t.key]=e;else{const a=t.secret?e:e.trim();t.required&&""===a&&(i[t.key]=s.inputRequired),r[t.key]=a}}const a={};for(const t of e.fields){if("Otp"!==t.verify)continue;const e=(x[t.key]??"").trim();""===e&&(i[t.key]=s.inputRequired),a[t.key]=e}if(c(i),Object.keys(i).length>0){const t=firstErrorKey(e.fields,i);return void(void 0!==t&&C(t))}y(!0),d("");try{const i=await t.answerInput(e.requestId,r,Object.keys(a).length>0?a:null);if(i.ok)return;c(i.errors),T.current=!0,d(i.message??"")}catch{d(s.errorGeneric)}y(!1)})()}}),S?_jsx(Text,{variant:"caption",color:"secondary",children:s.attachmentUploading}):null,R?_jsx(Button,{label:s.skip,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.skipInput(e.requestId))}}):null,E?_jsx(Button,{label:s.cancel,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.cancelLead())}}):null]})]})})}export function InputRequestPart(e){const{part:t,message:i,turn:r,pickAttachments:s}=e;if("InputRequest"!==t.kind||t.fields.some(isUndrawnField)){const e={kind:"Notice",code:"NeedsNewerApp",text:r.labels.needsNewerApp};return _jsx(NoticePart,{part:e,message:i,turn:r})}return"Answered"===t.state?_jsx(Text,{variant:"bodySmall",color:"secondary",children:t.answeredSummary||r.labels.inputAnswered}):"Skipped"===t.state?_jsx(Text,{variant:"bodySmall",color:"secondary",children:r.labels.inputSkipped}):"Expired"===t.state?_jsx(Text,{variant:"bodySmall",color:"secondary",children:r.labels.inputExpired}):_jsx(OpenRequest,{part:t,turn:r,pickAttachments:s},t.requestId)}
@@ -0,0 +1,11 @@
1
+ import type React from "react";
2
+ import type { ChatAppearance } from "./types";
3
+ /**
4
+ * Draws the accent colour, corner radius and font of the chat's appearance over its subtree, through a
5
+ * nested theme. With no appearance key set it draws its children as they are.
6
+ */
7
+ export declare function ChatAppearanceScope({ appearance, children, }: {
8
+ appearance?: ChatAppearance;
9
+ children: React.ReactNode;
10
+ }): React.ReactElement;
11
+ //# sourceMappingURL=ChatAppearanceScope.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { ChatLabels, ChatUploadFile } from "@webority/chat-core";
1
+ import { type ChatLabels, type ChatLook, type ChatUploadFile } from "@webority/chat-core";
2
2
  import type React from "react";
3
3
  import type { UseChatResult } from "./useChat";
4
4
  export interface ChatComposerProps {
@@ -10,6 +10,8 @@ export interface ChatComposerProps {
10
10
  safeArea?: boolean;
11
11
  testID?: string;
12
12
  focusRef?: React.MutableRefObject<(() => void) | null>;
13
+ /** The resolved look: its input ring and send reveal draw the box and the send button. */
14
+ look?: ChatLook;
13
15
  }
14
- export declare function ChatComposer({ chat, labels, pickAttachments, keyboardOffset, keyboardAware, safeArea, testID, focusRef, }: ChatComposerProps): React.ReactElement;
16
+ export declare function ChatComposer({ chat, labels, pickAttachments, keyboardOffset, keyboardAware, safeArea, testID, focusRef, look, }: ChatComposerProps): React.ReactElement;
15
17
  //# sourceMappingURL=ChatComposer.d.ts.map
@@ -7,5 +7,5 @@ export interface ChatEmbedProps extends ChatShellProps {
7
7
  height?: number;
8
8
  }
9
9
  /** The chat drawn inside a bounded area of a screen, with a border and rounded corners. */
10
- export declare function ChatEmbed({ chat, labels, renderers, layoutParts, loader, motion, pickAttachments, onOpenAttachment, onOpenTarget, onNavigate, openTicket, handoffHosts, resolveLink, keyboardOffset, title, headerActions, onClose, height, testID, }: ChatEmbedProps): React.ReactElement | null;
10
+ export declare function ChatEmbed({ chat, labels, renderers, layoutParts, loader, look, appearance, pickAttachments, onOpenAttachment, onOpenTarget, onNavigate, openTicket, handoffHosts, resolveLink, keyboardOffset, title, headerActions, onClose, height, testID, }: ChatEmbedProps): React.ReactElement | null;
11
11
  //# sourceMappingURL=ChatEmbed.d.ts.map
@@ -1,6 +1,6 @@
1
- import type { ChatLabels, ChatLoaderStyle, ChatMotion, ChatPart, ChatUploadFile } from "@webority/chat-core";
1
+ import { type ChatLabels, type ChatLoaderStyle, type ChatLookInput, type ChatPart, type ChatUploadFile } from "@webority/chat-core";
2
2
  import type React from "react";
3
- import type { ChatLayoutParts, ChatOpenTicketHandler, ChatRenderers } from "./types";
3
+ import type { ChatAppearance, ChatLayoutParts, ChatOpenTicketHandler, ChatRenderers } from "./types";
4
4
  import type { UseChatResult } from "./useChat";
5
5
  export type ChatLayout = "screen" | "sheet" | "embedded";
6
6
  /** The props every shell passes down to its frame. */
@@ -10,7 +10,8 @@ export interface ChatCommonProps {
10
10
  renderers?: ChatRenderers;
11
11
  layoutParts?: ChatLayoutParts;
12
12
  loader?: ChatLoaderStyle;
13
- motion?: ChatMotion;
13
+ /** The look: its input ring and send reveal, its panel motion and its motion switch. Unset values take the defaults. */
14
+ look?: ChatLookInput;
14
15
  pickAttachments?: () => Promise<ChatUploadFile[]>;
15
16
  onOpenAttachment?: (part: Extract<ChatPart, {
16
17
  kind: "File";
@@ -32,6 +33,8 @@ export interface ChatFrameProps extends ChatCommonProps {
32
33
  headerActions?: React.ReactNode;
33
34
  /** The host sheet closes through this callback. */
34
35
  onClose?: () => void;
36
+ /** Changes each time the panel opens, so the panel motion plays again. Default 0. */
37
+ enterKey?: number;
35
38
  }
36
39
  /** The props of the three shells: the frame's, with labels as a partial merged over the defaults. */
37
40
  export interface ChatShellProps extends Omit<ChatCommonProps, "labels"> {
@@ -40,6 +43,8 @@ export interface ChatShellProps extends Omit<ChatCommonProps, "labels"> {
40
43
  headerActions?: React.ReactNode;
41
44
  /** The host sheet closes through this callback. */
42
45
  onClose?: () => void;
46
+ /** The web's appearance keys the phone reads: accent, corner radius and font, and the launcher side and offsets for a sheet. */
47
+ appearance?: ChatAppearance;
43
48
  }
44
- export declare function ChatFrame({ chat, labels, renderers, layoutParts, loader, motion, pickAttachments, onOpenAttachment, onOpenTarget, onNavigate, openTicket, handoffHosts, resolveLink, keyboardOffset, layout, title, headerActions, onClose, testID, }: ChatFrameProps): React.ReactElement | null;
49
+ export declare function ChatFrame({ chat, labels, renderers, layoutParts, loader, look, pickAttachments, onOpenAttachment, onOpenTarget, onNavigate, openTicket, handoffHosts, resolveLink, keyboardOffset, layout, title, headerActions, onClose, enterKey, testID, }: ChatFrameProps): React.ReactElement | null;
45
50
  //# sourceMappingURL=ChatFrame.d.ts.map
@@ -0,0 +1,22 @@
1
+ import type { ChatLook } from "@webority/chat-core";
2
+ import type React from "react";
3
+ import { type View } from "react-native";
4
+ export interface ChatLauncherProps {
5
+ look: ChatLook;
6
+ label: string;
7
+ side: "start" | "end";
8
+ offsetX: number;
9
+ offsetY: number;
10
+ /** Plays the entrance once, on the first show of the launcher. */
11
+ enter: boolean;
12
+ reduced: boolean;
13
+ buttonRef: React.RefObject<View | null>;
14
+ onPress: () => void;
15
+ testID: string;
16
+ }
17
+ /**
18
+ * The floating launcher as the look draws it: round or pill, with its label, the chosen entrance and the
19
+ * float idle. The entrance moves the button's own wrapper, so a scale or a turn happens around the button.
20
+ */
21
+ export declare function ChatLauncher({ look, label, side, offsetX, offsetY, enter, reduced, buttonRef, onPress, testID, }: ChatLauncherProps): React.ReactElement;
22
+ //# sourceMappingURL=ChatLauncher.d.ts.map
@@ -0,0 +1,39 @@
1
+ import type { ChatPanelMotion } from "@webority/chat-core";
2
+ import type React from "react";
3
+ export type RevealSlot = "header" | "body" | "composer";
4
+ /** One open of the panel: the run number changes each open, so a new plan object replays the animation. */
5
+ export interface RevealPlan {
6
+ run: number;
7
+ delay: number;
8
+ duration: number;
9
+ distance: number;
10
+ }
11
+ export interface GrowPlan {
12
+ run: number;
13
+ }
14
+ export interface PanelRun {
15
+ grow: GrowPlan | null;
16
+ reveal: Record<RevealSlot, RevealPlan | null>;
17
+ }
18
+ /** The plans for one open of the panel. Each call builds new objects, so a changed run restarts the motion. */
19
+ export declare const panelRun: (options: {
20
+ motion: ChatPanelMotion;
21
+ reduced: boolean;
22
+ mode: "sheet" | "screen";
23
+ run: number;
24
+ }) => PanelRun;
25
+ interface ChatRevealProps {
26
+ plan: RevealPlan | null;
27
+ flex?: boolean;
28
+ children: React.ReactNode;
29
+ }
30
+ /** Fades and rises its child by the plan's distance, and plays again for each new plan. */
31
+ export declare function ChatReveal({ plan, flex, children }: ChatRevealProps): React.ReactElement;
32
+ interface ChatPanelGrowProps {
33
+ grow: GrowPlan | null;
34
+ children: React.ReactNode;
35
+ }
36
+ /** The spring panel: a full screen slides up from below. With no plan it draws its child as is. */
37
+ export declare function ChatPanelGrow({ grow, children }: ChatPanelGrowProps): React.ReactElement;
38
+ export {};
39
+ //# sourceMappingURL=ChatPanel.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import type React from "react";
2
2
  import { type ChatShellProps } from "./ChatFrame";
3
3
  /** The whole chat for one screen of the app's navigator. Keep `useChat` above the navigator so the conversation survives leaving the screen. */
4
- export declare function ChatScreen({ chat, labels, renderers, layoutParts, loader, motion, pickAttachments, onOpenAttachment, onOpenTarget, onNavigate, openTicket, handoffHosts, resolveLink, keyboardOffset, title, headerActions, onClose, testID, }: ChatShellProps): React.ReactElement | null;
4
+ export declare function ChatScreen({ chat, labels, renderers, layoutParts, loader, look, appearance, pickAttachments, onOpenAttachment, onOpenTarget, onNavigate, openTicket, handoffHosts, resolveLink, keyboardOffset, title, headerActions, onClose, testID, }: ChatShellProps): React.ReactElement | null;
5
5
  //# sourceMappingURL=ChatScreen.d.ts.map
@@ -7,15 +7,10 @@ export interface ChatSheetProps extends ChatShellProps {
7
7
  /** The starting state when `open` is not given. Default false. */
8
8
  defaultOpen?: boolean;
9
9
  onOpenChange?: (open: boolean) => void;
10
- position?: "end" | "start";
11
- /** Space between the launcher and the bottom edge. Default 16. */
12
- bottomOffset?: number;
13
10
  snapPoints?: BottomSheetProps["snapPoints"];
14
- /** The launcher shows only its icon. */
15
- compact?: boolean;
16
11
  /** Opens the sheet on this conversation when it changes to a new id (a push tap); uncontrolled sheets only. */
17
12
  conversationId?: string | null;
18
13
  }
19
14
  /** The chat in a bottom sheet over the screen, opened from a floating launcher. */
20
- export declare function ChatSheet({ chat, labels, renderers, layoutParts, loader, motion, pickAttachments, onOpenAttachment, onOpenTarget, onNavigate, keyboardOffset, open, defaultOpen, onOpenChange, position, bottomOffset, snapPoints, compact, openTicket, handoffHosts, resolveLink, conversationId, onClose, testID, }: ChatSheetProps): React.ReactElement | null;
15
+ export declare function ChatSheet({ chat, labels, renderers, layoutParts, loader, look, appearance, pickAttachments, onOpenAttachment, onOpenTarget, onNavigate, keyboardOffset, open, defaultOpen, onOpenChange, snapPoints, openTicket, handoffHosts, resolveLink, conversationId, onClose, testID, }: ChatSheetProps): React.ReactElement | null;
21
16
  //# sourceMappingURL=ChatSheet.d.ts.map
@@ -1,4 +1,6 @@
1
1
  import type { ChatLiveMessage } from "@webority/chat-core";
2
+ /** Moves screen-reader focus to a view. findNodeHandle throws on react-native-web, so the browser focuses the element itself. */
3
+ export declare function focusForAccessibility(node: unknown): void;
2
4
  export declare function messageSignature(message: ChatLiveMessage): string;
3
5
  export declare function defaultOpenTarget(target: string): void;
4
6
  //# sourceMappingURL=chatShared.d.ts.map
@@ -22,7 +22,7 @@ export { TypingPill } from "./loaders/TypingPill";
22
22
  export { CHAT_PUSH_TYPE, chatConversationIdFromPush } from "./pushOpen";
23
23
  export { ReadAloudButton } from "./ReadAloudButton";
24
24
  export { defaultRenderers } from "./renderers";
25
- export type { ChatLayoutParts, ChatPartRendererProps, ChatRenderers } from "./types";
25
+ export type { ChatAppearance, ChatLayoutParts, ChatLookInput, ChatPartRendererProps, ChatRenderers } from "./types";
26
26
  export type { UseChatOptions, UseChatResult } from "./useChat";
27
27
  export { useChat } from "./useChat";
28
28
  export { useChatSpeech } from "./useChatSpeech";
@@ -1,8 +1,9 @@
1
1
  import type { ChatPart } from "@webority/chat-core";
2
+ import type React from "react";
2
3
  import type { ChatPartRendererProps } from "../types";
3
4
  type ImagePartProps = ChatPartRendererProps<Extract<ChatPart, {
4
5
  kind: "Image";
5
6
  }>>;
6
- export declare function ImagePart({ part, turn }: Pick<ImagePartProps, "part" | "turn">): import("react").JSX.Element;
7
+ export declare function ImagePart({ part, turn }: Pick<ImagePartProps, "part" | "turn">): React.JSX.Element;
7
8
  export {};
8
9
  //# sourceMappingURL=ImagePart.d.ts.map
@@ -1,7 +1,25 @@
1
1
  import type { ChatLiveMessage, ChatPart, ChatPartKind, ChatTurnApi, ChatUploadFile } from "@webority/chat-core";
2
2
  import type React from "react";
3
3
  import type { View } from "react-native";
4
- export type { ChatMotion } from "@webority/chat-core";
4
+ export type { ChatLookInput, ChatMotion } from "@webority/chat-core";
5
+ /**
6
+ * The web chat's appearance keys that the phone reads, under the names applyAppearance and the
7
+ * CSS variables use on the web. Each key the phone has no part for is left out, never accepted and ignored.
8
+ */
9
+ export interface ChatAppearance {
10
+ /** Which side the launcher sits on. Default "end". */
11
+ position?: "end" | "start";
12
+ /** Launcher offset from the side edge, in px. */
13
+ offsetX?: number;
14
+ /** Launcher offset from the bottom edge, in px. */
15
+ offsetY?: number;
16
+ /** Accent colour as a hex string, or null for the theme's primary. */
17
+ "--wui-chat-accent"?: string | null;
18
+ /** Corner radius as a px length such as "14px", or null for the theme's radius. */
19
+ "--wui-chat-radius"?: string | null;
20
+ /** A font as the web names it: "var(--wui-font-display)" draws the display face, anything else the theme's UI face. */
21
+ "--wui-chat-font"?: string | null;
22
+ }
5
23
  /** Host values the thread adds to each part's turn: the host's link resolver and the source rows a citation focuses. */
6
24
  export interface ChatTurnHostApi {
7
25
  resolveLink?: (href: string) => string | null;
@@ -0,0 +1,11 @@
1
+ import type React from "react";
2
+ import type { ChatAppearance } from "./types.js";
3
+ /**
4
+ * Draws the accent colour, corner radius and font of the chat's appearance over its subtree, through a
5
+ * nested theme. With no appearance key set it draws its children as they are.
6
+ */
7
+ export declare function ChatAppearanceScope({ appearance, children, }: {
8
+ appearance?: ChatAppearance;
9
+ children: React.ReactNode;
10
+ }): React.ReactElement;
11
+ //# sourceMappingURL=ChatAppearanceScope.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { ChatLabels, ChatUploadFile } from "@webority/chat-core";
1
+ import { type ChatLabels, type ChatLook, type ChatUploadFile } from "@webority/chat-core";
2
2
  import type React from "react";
3
3
  import type { UseChatResult } from "./useChat.js";
4
4
  export interface ChatComposerProps {
@@ -10,6 +10,8 @@ export interface ChatComposerProps {
10
10
  safeArea?: boolean;
11
11
  testID?: string;
12
12
  focusRef?: React.MutableRefObject<(() => void) | null>;
13
+ /** The resolved look: its input ring and send reveal draw the box and the send button. */
14
+ look?: ChatLook;
13
15
  }
14
- export declare function ChatComposer({ chat, labels, pickAttachments, keyboardOffset, keyboardAware, safeArea, testID, focusRef, }: ChatComposerProps): React.ReactElement;
16
+ export declare function ChatComposer({ chat, labels, pickAttachments, keyboardOffset, keyboardAware, safeArea, testID, focusRef, look, }: ChatComposerProps): React.ReactElement;
15
17
  //# sourceMappingURL=ChatComposer.d.ts.map
@@ -7,5 +7,5 @@ export interface ChatEmbedProps extends ChatShellProps {
7
7
  height?: number;
8
8
  }
9
9
  /** The chat drawn inside a bounded area of a screen, with a border and rounded corners. */
10
- export declare function ChatEmbed({ chat, labels, renderers, layoutParts, loader, motion, pickAttachments, onOpenAttachment, onOpenTarget, onNavigate, openTicket, handoffHosts, resolveLink, keyboardOffset, title, headerActions, onClose, height, testID, }: ChatEmbedProps): React.ReactElement | null;
10
+ export declare function ChatEmbed({ chat, labels, renderers, layoutParts, loader, look, appearance, pickAttachments, onOpenAttachment, onOpenTarget, onNavigate, openTicket, handoffHosts, resolveLink, keyboardOffset, title, headerActions, onClose, height, testID, }: ChatEmbedProps): React.ReactElement | null;
11
11
  //# sourceMappingURL=ChatEmbed.d.ts.map
@@ -1,6 +1,6 @@
1
- import type { ChatLabels, ChatLoaderStyle, ChatMotion, ChatPart, ChatUploadFile } from "@webority/chat-core";
1
+ import { type ChatLabels, type ChatLoaderStyle, type ChatLookInput, type ChatPart, type ChatUploadFile } from "@webority/chat-core";
2
2
  import type React from "react";
3
- import type { ChatLayoutParts, ChatOpenTicketHandler, ChatRenderers } from "./types.js";
3
+ import type { ChatAppearance, ChatLayoutParts, ChatOpenTicketHandler, ChatRenderers } from "./types.js";
4
4
  import type { UseChatResult } from "./useChat.js";
5
5
  export type ChatLayout = "screen" | "sheet" | "embedded";
6
6
  /** The props every shell passes down to its frame. */
@@ -10,7 +10,8 @@ export interface ChatCommonProps {
10
10
  renderers?: ChatRenderers;
11
11
  layoutParts?: ChatLayoutParts;
12
12
  loader?: ChatLoaderStyle;
13
- motion?: ChatMotion;
13
+ /** The look: its input ring and send reveal, its panel motion and its motion switch. Unset values take the defaults. */
14
+ look?: ChatLookInput;
14
15
  pickAttachments?: () => Promise<ChatUploadFile[]>;
15
16
  onOpenAttachment?: (part: Extract<ChatPart, {
16
17
  kind: "File";
@@ -32,6 +33,8 @@ export interface ChatFrameProps extends ChatCommonProps {
32
33
  headerActions?: React.ReactNode;
33
34
  /** The host sheet closes through this callback. */
34
35
  onClose?: () => void;
36
+ /** Changes each time the panel opens, so the panel motion plays again. Default 0. */
37
+ enterKey?: number;
35
38
  }
36
39
  /** The props of the three shells: the frame's, with labels as a partial merged over the defaults. */
37
40
  export interface ChatShellProps extends Omit<ChatCommonProps, "labels"> {
@@ -40,6 +43,8 @@ export interface ChatShellProps extends Omit<ChatCommonProps, "labels"> {
40
43
  headerActions?: React.ReactNode;
41
44
  /** The host sheet closes through this callback. */
42
45
  onClose?: () => void;
46
+ /** The web's appearance keys the phone reads: accent, corner radius and font, and the launcher side and offsets for a sheet. */
47
+ appearance?: ChatAppearance;
43
48
  }
44
- export declare function ChatFrame({ chat, labels, renderers, layoutParts, loader, motion, pickAttachments, onOpenAttachment, onOpenTarget, onNavigate, openTicket, handoffHosts, resolveLink, keyboardOffset, layout, title, headerActions, onClose, testID, }: ChatFrameProps): React.ReactElement | null;
49
+ export declare function ChatFrame({ chat, labels, renderers, layoutParts, loader, look, pickAttachments, onOpenAttachment, onOpenTarget, onNavigate, openTicket, handoffHosts, resolveLink, keyboardOffset, layout, title, headerActions, onClose, enterKey, testID, }: ChatFrameProps): React.ReactElement | null;
45
50
  //# sourceMappingURL=ChatFrame.d.ts.map
@@ -0,0 +1,22 @@
1
+ import type { ChatLook } from "@webority/chat-core";
2
+ import type React from "react";
3
+ import { type View } from "react-native";
4
+ export interface ChatLauncherProps {
5
+ look: ChatLook;
6
+ label: string;
7
+ side: "start" | "end";
8
+ offsetX: number;
9
+ offsetY: number;
10
+ /** Plays the entrance once, on the first show of the launcher. */
11
+ enter: boolean;
12
+ reduced: boolean;
13
+ buttonRef: React.RefObject<View | null>;
14
+ onPress: () => void;
15
+ testID: string;
16
+ }
17
+ /**
18
+ * The floating launcher as the look draws it: round or pill, with its label, the chosen entrance and the
19
+ * float idle. The entrance moves the button's own wrapper, so a scale or a turn happens around the button.
20
+ */
21
+ export declare function ChatLauncher({ look, label, side, offsetX, offsetY, enter, reduced, buttonRef, onPress, testID, }: ChatLauncherProps): React.ReactElement;
22
+ //# sourceMappingURL=ChatLauncher.d.ts.map
@@ -0,0 +1,39 @@
1
+ import type { ChatPanelMotion } from "@webority/chat-core";
2
+ import type React from "react";
3
+ export type RevealSlot = "header" | "body" | "composer";
4
+ /** One open of the panel: the run number changes each open, so a new plan object replays the animation. */
5
+ export interface RevealPlan {
6
+ run: number;
7
+ delay: number;
8
+ duration: number;
9
+ distance: number;
10
+ }
11
+ export interface GrowPlan {
12
+ run: number;
13
+ }
14
+ export interface PanelRun {
15
+ grow: GrowPlan | null;
16
+ reveal: Record<RevealSlot, RevealPlan | null>;
17
+ }
18
+ /** The plans for one open of the panel. Each call builds new objects, so a changed run restarts the motion. */
19
+ export declare const panelRun: (options: {
20
+ motion: ChatPanelMotion;
21
+ reduced: boolean;
22
+ mode: "sheet" | "screen";
23
+ run: number;
24
+ }) => PanelRun;
25
+ interface ChatRevealProps {
26
+ plan: RevealPlan | null;
27
+ flex?: boolean;
28
+ children: React.ReactNode;
29
+ }
30
+ /** Fades and rises its child by the plan's distance, and plays again for each new plan. */
31
+ export declare function ChatReveal({ plan, flex, children }: ChatRevealProps): React.ReactElement;
32
+ interface ChatPanelGrowProps {
33
+ grow: GrowPlan | null;
34
+ children: React.ReactNode;
35
+ }
36
+ /** The spring panel: a full screen slides up from below. With no plan it draws its child as is. */
37
+ export declare function ChatPanelGrow({ grow, children }: ChatPanelGrowProps): React.ReactElement;
38
+ export {};
39
+ //# sourceMappingURL=ChatPanel.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import type React from "react";
2
2
  import { type ChatShellProps } from "./ChatFrame.js";
3
3
  /** The whole chat for one screen of the app's navigator. Keep `useChat` above the navigator so the conversation survives leaving the screen. */
4
- export declare function ChatScreen({ chat, labels, renderers, layoutParts, loader, motion, pickAttachments, onOpenAttachment, onOpenTarget, onNavigate, openTicket, handoffHosts, resolveLink, keyboardOffset, title, headerActions, onClose, testID, }: ChatShellProps): React.ReactElement | null;
4
+ export declare function ChatScreen({ chat, labels, renderers, layoutParts, loader, look, appearance, pickAttachments, onOpenAttachment, onOpenTarget, onNavigate, openTicket, handoffHosts, resolveLink, keyboardOffset, title, headerActions, onClose, testID, }: ChatShellProps): React.ReactElement | null;
5
5
  //# sourceMappingURL=ChatScreen.d.ts.map
@@ -7,15 +7,10 @@ export interface ChatSheetProps extends ChatShellProps {
7
7
  /** The starting state when `open` is not given. Default false. */
8
8
  defaultOpen?: boolean;
9
9
  onOpenChange?: (open: boolean) => void;
10
- position?: "end" | "start";
11
- /** Space between the launcher and the bottom edge. Default 16. */
12
- bottomOffset?: number;
13
10
  snapPoints?: BottomSheetProps["snapPoints"];
14
- /** The launcher shows only its icon. */
15
- compact?: boolean;
16
11
  /** Opens the sheet on this conversation when it changes to a new id (a push tap); uncontrolled sheets only. */
17
12
  conversationId?: string | null;
18
13
  }
19
14
  /** The chat in a bottom sheet over the screen, opened from a floating launcher. */
20
- export declare function ChatSheet({ chat, labels, renderers, layoutParts, loader, motion, pickAttachments, onOpenAttachment, onOpenTarget, onNavigate, keyboardOffset, open, defaultOpen, onOpenChange, position, bottomOffset, snapPoints, compact, openTicket, handoffHosts, resolveLink, conversationId, onClose, testID, }: ChatSheetProps): React.ReactElement | null;
15
+ export declare function ChatSheet({ chat, labels, renderers, layoutParts, loader, look, appearance, pickAttachments, onOpenAttachment, onOpenTarget, onNavigate, keyboardOffset, open, defaultOpen, onOpenChange, snapPoints, openTicket, handoffHosts, resolveLink, conversationId, onClose, testID, }: ChatSheetProps): React.ReactElement | null;
21
16
  //# sourceMappingURL=ChatSheet.d.ts.map
@@ -1,4 +1,6 @@
1
1
  import type { ChatLiveMessage } from "@webority/chat-core";
2
+ /** Moves screen-reader focus to a view. findNodeHandle throws on react-native-web, so the browser focuses the element itself. */
3
+ export declare function focusForAccessibility(node: unknown): void;
2
4
  export declare function messageSignature(message: ChatLiveMessage): string;
3
5
  export declare function defaultOpenTarget(target: string): void;
4
6
  //# sourceMappingURL=chatShared.d.ts.map
@@ -22,7 +22,7 @@ export { TypingPill } from "./loaders/TypingPill.js";
22
22
  export { CHAT_PUSH_TYPE, chatConversationIdFromPush } from "./pushOpen.js";
23
23
  export { ReadAloudButton } from "./ReadAloudButton.js";
24
24
  export { defaultRenderers } from "./renderers/index.js";
25
- export type { ChatLayoutParts, ChatPartRendererProps, ChatRenderers } from "./types.js";
25
+ export type { ChatAppearance, ChatLayoutParts, ChatLookInput, ChatPartRendererProps, ChatRenderers } from "./types.js";
26
26
  export type { UseChatOptions, UseChatResult } from "./useChat.js";
27
27
  export { useChat } from "./useChat.js";
28
28
  export { useChatSpeech } from "./useChatSpeech.js";
@@ -1,8 +1,9 @@
1
1
  import type { ChatPart } from "@webority/chat-core";
2
+ import type React from "react";
2
3
  import type { ChatPartRendererProps } from "../types.js";
3
4
  type ImagePartProps = ChatPartRendererProps<Extract<ChatPart, {
4
5
  kind: "Image";
5
6
  }>>;
6
- export declare function ImagePart({ part, turn }: Pick<ImagePartProps, "part" | "turn">): import("react").JSX.Element;
7
+ export declare function ImagePart({ part, turn }: Pick<ImagePartProps, "part" | "turn">): React.JSX.Element;
7
8
  export {};
8
9
  //# sourceMappingURL=ImagePart.d.ts.map
@@ -1,7 +1,25 @@
1
1
  import type { ChatLiveMessage, ChatPart, ChatPartKind, ChatTurnApi, ChatUploadFile } from "@webority/chat-core";
2
2
  import type React from "react";
3
3
  import type { View } from "react-native";
4
- export type { ChatMotion } from "@webority/chat-core";
4
+ export type { ChatLookInput, ChatMotion } from "@webority/chat-core";
5
+ /**
6
+ * The web chat's appearance keys that the phone reads, under the names applyAppearance and the
7
+ * CSS variables use on the web. Each key the phone has no part for is left out, never accepted and ignored.
8
+ */
9
+ export interface ChatAppearance {
10
+ /** Which side the launcher sits on. Default "end". */
11
+ position?: "end" | "start";
12
+ /** Launcher offset from the side edge, in px. */
13
+ offsetX?: number;
14
+ /** Launcher offset from the bottom edge, in px. */
15
+ offsetY?: number;
16
+ /** Accent colour as a hex string, or null for the theme's primary. */
17
+ "--wui-chat-accent"?: string | null;
18
+ /** Corner radius as a px length such as "14px", or null for the theme's radius. */
19
+ "--wui-chat-radius"?: string | null;
20
+ /** A font as the web names it: "var(--wui-font-display)" draws the display face, anything else the theme's UI face. */
21
+ "--wui-chat-font"?: string | null;
22
+ }
5
23
  /** Host values the thread adds to each part's turn: the host's link resolver and the source rows a citation focuses. */
6
24
  export interface ChatTurnHostApi {
7
25
  resolveLink?: (href: string) => string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/mobile-chat",
3
- "version": "0.134.0",
3
+ "version": "0.135.1",
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.134.0",
46
- "@webority/markdown-core": "^0.130.3",
47
- "@webority/mobile-core": "^0.130.3",
48
- "@webority/mobile-ui": "^0.130.3",
45
+ "@webority/chat-core": "0.135.1",
46
+ "@webority/markdown-core": "^0.131.0",
47
+ "@webority/mobile-core": "^0.131.0",
48
+ "@webority/mobile-ui": "^0.131.0",
49
49
  "expo-audio": ">=57.0.0",
50
50
  "expo-file-system": ">=57.0.0",
51
51
  "react": "^19.1.0",
@@ -97,11 +97,11 @@
97
97
  "@react-native/metro-config": "0.86.3",
98
98
  "@testing-library/react-native": "12.9.0",
99
99
  "@types/react": "19.2.18",
100
- "@webority/canvas-kit": "0.130.3",
101
- "@webority/chat-core": "0.134.0",
102
- "@webority/markdown-core": "0.130.3",
103
- "@webority/mobile-core": "0.130.3",
104
- "@webority/mobile-ui": "0.130.3",
100
+ "@webority/canvas-kit": "0.131.0",
101
+ "@webority/chat-core": "0.135.1",
102
+ "@webority/markdown-core": "0.131.0",
103
+ "@webority/mobile-core": "0.131.0",
104
+ "@webority/mobile-ui": "0.131.0",
105
105
  "babel-jest": "29.7.0",
106
106
  "expo": "57.0.31",
107
107
  "expo-application": "57.0.3",