@linktr.ee/messaging-react 3.23.0-rc-1785426600 → 3.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Card-BiZLzRIQ.cjs → Card-CRhkz5Jp.cjs} +2 -2
- package/dist/{Card-BiZLzRIQ.cjs.map → Card-CRhkz5Jp.cjs.map} +1 -1
- package/dist/{Card-G28kYBkV.js → Card-Cgn2G-VJ.js} +2 -2
- package/dist/{Card-G28kYBkV.js.map → Card-Cgn2G-VJ.js.map} +1 -1
- package/dist/index-BwfUbPpY.cjs +2 -0
- package/dist/{index-BnBvT5FW.cjs.map → index-BwfUbPpY.cjs.map} +1 -1
- package/dist/{index-DIKyFjPC.js → index-Daw6ObfN.js} +418 -411
- package/dist/{index-DIKyFjPC.js.map → index-Daw6ObfN.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/components/ChannelView.test.tsx +66 -1
- package/src/components/ChannelView.tsx +14 -2
- package/dist/index-BnBvT5FW.cjs +0 -2
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BwfUbPpY.cjs");exports.ActionButton=e.ActionButton;exports.Avatar=e.Avatar;exports.ChannelEmptyState=e.ChannelEmptyState;exports.ChannelList=e.ChannelList;exports.ChannelView=e.ChannelView;exports.CustomMessageProvider=e.CustomMessageProvider;exports.FaqList=e.FaqList;exports.FaqListItem=e.FaqListItem;exports.LinkAttachment=e.LinkAttachment;exports.LockedAttachment=e.LockedAttachment;exports.MediaMessage=e.MediaMessage;exports.MessageAttachment=e.MessageAttachment;exports.MessageBubble=e.MessageBubble;exports.MessageVoteButtons=e.MessageVoteButtons;exports.MessagingProvider=e.MessagingProvider;exports.MessagingShell=e.MessagingShell;exports.buildCompactMetaLabel=e.buildCompactMetaLabel;exports.formatFileSize=e.formatFileSize;exports.formatRelativeTime=e.formatRelativeTime;exports.getFileExtensionLabel=e.getFileExtensionLabel;exports.getMessageDisplayText=e.getMessageDisplayText;exports.isLinkAttachment=e.isLinkAttachment;exports.isUuidLike=e.isUuidLike;exports.messageAttachmentGroupPositionFromStream=e.bubbleGroupPositionFromStream;exports.normalizeLanguageCode=e.normalizeLanguageCode;exports.optimizeMessagingAttachmentUrl=e.optimizeMessagingAttachmentUrl;exports.resolveConversationParticipant=e.resolveConversationParticipant;exports.resolveLinkAttachment=e.resolveLinkAttachment;exports.resolveMediaFromMessage=e.resolveMediaFromMessage;exports.resolveParticipantDisplayName=e.resolveParticipantDisplayName;exports.useComposerLocked=e.useComposerLocked;exports.useCustomMessage=e.useCustomMessage;exports.useMessageVote=e.useMessageVote;exports.useMessaging=e.useMessaging;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, b as t, C as i, c as o, d as n, e as m, F as r, f as g, L as l, h as M, M as c, i as u, j as L, k as h, l as p, m as d, n as v, p as C, q as A, s as k, t as F, u as b, v as P, w as f, x, o as y, y as z, z as B, B as S, D as q, E as D, G as E, H as V, I as w } from "./index-
|
|
1
|
+
import { a as e, b as t, C as i, c as o, d as n, e as m, F as r, f as g, L as l, h as M, M as c, i as u, j as L, k as h, l as p, m as d, n as v, p as C, q as A, s as k, t as F, u as b, v as P, w as f, x, o as y, y as z, z as B, B as S, D as q, E as D, G as E, H as V, I as w } from "./index-Daw6ObfN.js";
|
|
2
2
|
export {
|
|
3
3
|
e as ActionButton,
|
|
4
4
|
t as Avatar,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linktr.ee/messaging-react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.24.0",
|
|
4
4
|
"description": "React messaging components built on messaging-core for web applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@linktr.ee/component-library": "11.8.6",
|
|
53
|
-
"@linktr.ee/messaging-core": "2.
|
|
53
|
+
"@linktr.ee/messaging-core": "^2.2.0",
|
|
54
54
|
"@linktr.ee/messaging-taxonomy": "^0.3.0",
|
|
55
55
|
"@phosphor-icons/react": "^2.1.10"
|
|
56
56
|
},
|
|
@@ -74,8 +74,29 @@ vi.mock('./CustomMessageInput', () => ({
|
|
|
74
74
|
},
|
|
75
75
|
}))
|
|
76
76
|
|
|
77
|
+
const customMessageMounts = vi.fn()
|
|
78
|
+
const customMessageUnmounts = vi.fn()
|
|
77
79
|
vi.mock('./CustomMessage', () => ({
|
|
78
|
-
CustomMessage: (
|
|
80
|
+
CustomMessage: (props: {
|
|
81
|
+
onBroadcastClick?: (broadcast: { id: string; name?: string }) => void
|
|
82
|
+
}) => {
|
|
83
|
+
React.useEffect(() => {
|
|
84
|
+
customMessageMounts()
|
|
85
|
+
return customMessageUnmounts
|
|
86
|
+
}, [])
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<button
|
|
90
|
+
data-testid="custom-message"
|
|
91
|
+
onClick={() =>
|
|
92
|
+
props.onBroadcastClick?.({
|
|
93
|
+
id: 'broadcast-1',
|
|
94
|
+
name: 'Campaign',
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
/>
|
|
98
|
+
)
|
|
99
|
+
},
|
|
79
100
|
}))
|
|
80
101
|
|
|
81
102
|
vi.mock('./CustomSystemMessage', () => ({
|
|
@@ -180,6 +201,8 @@ describe('ChannelView', () => {
|
|
|
180
201
|
avatarRenderCalls.length = 0
|
|
181
202
|
channelActionsMenuProps.length = 0
|
|
182
203
|
messageInputProps.length = 0
|
|
204
|
+
customMessageMounts.mockClear()
|
|
205
|
+
customMessageUnmounts.mockClear()
|
|
183
206
|
mockIsStarred = false
|
|
184
207
|
})
|
|
185
208
|
|
|
@@ -318,6 +341,48 @@ describe('ChannelView', () => {
|
|
|
318
341
|
)
|
|
319
342
|
})
|
|
320
343
|
|
|
344
|
+
it('keeps message rows mounted while updating the broadcast click handler', () => {
|
|
345
|
+
const firstHandler = vi.fn()
|
|
346
|
+
const secondHandler = vi.fn()
|
|
347
|
+
const { rerender: rerenderChannel } = renderWithProviders(
|
|
348
|
+
<ChannelView
|
|
349
|
+
channel={createChannel()}
|
|
350
|
+
onBroadcastClick={firstHandler}
|
|
351
|
+
/>
|
|
352
|
+
)
|
|
353
|
+
const firstMessageOverride = activeComponentOverrides.Message as React.ComponentType
|
|
354
|
+
const MessageRowHarness = ({
|
|
355
|
+
Message,
|
|
356
|
+
}: {
|
|
357
|
+
Message: React.ComponentType
|
|
358
|
+
}) => <Message />
|
|
359
|
+
const { rerender: rerenderMessageRow } = renderWithProviders(
|
|
360
|
+
<MessageRowHarness Message={firstMessageOverride} />
|
|
361
|
+
)
|
|
362
|
+
|
|
363
|
+
expect(customMessageMounts).toHaveBeenCalledOnce()
|
|
364
|
+
|
|
365
|
+
rerenderChannel(
|
|
366
|
+
<ChannelView
|
|
367
|
+
channel={createChannel()}
|
|
368
|
+
onBroadcastClick={secondHandler}
|
|
369
|
+
/>
|
|
370
|
+
)
|
|
371
|
+
const secondMessageOverride = activeComponentOverrides.Message as React.ComponentType
|
|
372
|
+
|
|
373
|
+
expect(secondMessageOverride).toBe(firstMessageOverride)
|
|
374
|
+
rerenderMessageRow(<MessageRowHarness Message={secondMessageOverride} />)
|
|
375
|
+
expect(customMessageMounts).toHaveBeenCalledOnce()
|
|
376
|
+
expect(customMessageUnmounts).not.toHaveBeenCalled()
|
|
377
|
+
|
|
378
|
+
screen.getByTestId('custom-message').click()
|
|
379
|
+
expect(firstHandler).not.toHaveBeenCalled()
|
|
380
|
+
expect(secondHandler).toHaveBeenCalledWith({
|
|
381
|
+
id: 'broadcast-1',
|
|
382
|
+
name: 'Campaign',
|
|
383
|
+
})
|
|
384
|
+
})
|
|
385
|
+
|
|
321
386
|
it('hides the actions menu (both desktop and mobile) when showChannelInfo is false', () => {
|
|
322
387
|
renderWithProviders(
|
|
323
388
|
<ChannelView channel={createChannel()} showChannelInfo={false} />
|
|
@@ -87,6 +87,18 @@ const ChannelViewInner: React.FC<{
|
|
|
87
87
|
composerInput,
|
|
88
88
|
}) => {
|
|
89
89
|
const { channel } = useChannelStateContext()
|
|
90
|
+
const onBroadcastClickRef = useRef(onBroadcastClick)
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
onBroadcastClickRef.current = onBroadcastClick
|
|
93
|
+
}, [onBroadcastClick])
|
|
94
|
+
const stableOnBroadcastClick = useCallback<
|
|
95
|
+
NonNullable<ChannelViewProps['onBroadcastClick']>
|
|
96
|
+
>((broadcast) => {
|
|
97
|
+
onBroadcastClickRef.current?.(broadcast)
|
|
98
|
+
}, [])
|
|
99
|
+
const messageBroadcastClick = onBroadcastClick
|
|
100
|
+
? stableOnBroadcastClick
|
|
101
|
+
: undefined
|
|
90
102
|
|
|
91
103
|
const hasVisibleMessages = channel.state.messages.some(
|
|
92
104
|
(message) => message.type !== 'deleted'
|
|
@@ -127,7 +139,7 @@ const ChannelViewInner: React.FC<{
|
|
|
127
139
|
{...props}
|
|
128
140
|
chatbotVotingEnabled={chatbotVotingEnabled}
|
|
129
141
|
viewerLanguage={viewerLanguage}
|
|
130
|
-
onBroadcastClick={
|
|
142
|
+
onBroadcastClick={messageBroadcastClick}
|
|
131
143
|
/>
|
|
132
144
|
)
|
|
133
145
|
|
|
@@ -137,7 +149,7 @@ const ChannelViewInner: React.FC<{
|
|
|
137
149
|
|
|
138
150
|
return renderMessage(messageNode, message)
|
|
139
151
|
},
|
|
140
|
-
[chatbotVotingEnabled,
|
|
152
|
+
[chatbotVotingEnabled, messageBroadcastClick, renderMessage, viewerLanguage]
|
|
141
153
|
)
|
|
142
154
|
|
|
143
155
|
return (
|
package/dist/index-BnBvT5FW.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const t=require("react/jsx-runtime"),h=require("react"),zs=require("@linktr.ee/messaging-core"),Ce=require("stream-chat"),w=require("stream-chat-react"),C=require("classnames"),y=require("@phosphor-icons/react"),W=require("@linktr.ee/messaging-taxonomy"),Ye=require("stream-chat-react/experimental"),qt=h.createContext({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),qe=()=>h.useContext(qt),Bs=({children:e,user:s,serviceConfig:n,apiKey:a,capabilities:r={},debug:i=!1,client:l})=>{var k,M;const o=h.useCallback((I,...L)=>{i&&console.log(`🔥 [MessagingProvider] ${I}`,...L)},[i]);o("🔄 RENDER START",{userId:s==null?void 0:s.id,apiKey:(a==null?void 0:a.substring(0,8))+"...",serviceConfig:!!n,capabilities:Object.keys(r)});const[d,m]=h.useState(null),[f,u]=h.useState(null),[g,c]=h.useState(!1),[v,j]=h.useState(!1),[p,x]=h.useState(null),b=h.useRef(!1),_=h.useRef(null),S=h.useRef(n);S.current=n;const T=h.useRef(i);T.current=i;const F=h.useRef({userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r}),P=h.useRef(0);P.current++,o("📊 RENDER INFO",{renderCount:P.current,currentProps:{userId:s==null?void 0:s.id,apiKey:(a==null?void 0:a.substring(0,8))+"..."},propChanges:{userChanged:F.current.userId!==(s==null?void 0:s.id),apiKeyChanged:F.current.apiKey!==a,serviceConfigChanged:F.current.serviceConfig!==n,capabilitiesChanged:F.current.capabilities!==r}}),F.current={userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r};const z=h.useRef(null);!l&&a&&((k=z.current)==null?void 0:k.apiKey)!==a&&(z.current={apiKey:a,client:new Ce.StreamChat(a)});const B=l||(a?((M=z.current)==null?void 0:M.client)??null:null);h.useEffect(()=>{const I=P.current,L=S.current;if(l){_.current=null,m(null),u(null),c(!1),x(null),j(!1);return}if(!a||!B||!L){o("⚠️ SERVICE INIT SKIPPED",{renderCount:I,reason:"Missing apiKey, client, or serviceConfig"});return}o("🚀 CREATING SERVICE",{renderCount:I,apiKey:(a==null?void 0:a.substring(0,8))+"..."});const $=new zs.StreamChatService({...L,apiKey:a,debug:T.current,client:B});_.current=$,m($),o("✅ SERVICE SET",{renderCount:I,serviceInstance:!!$})},[a,B,l]);const A=h.useRef(null);h.useEffect(()=>{var L,$;if(o("🔗 USER CONNECTION EFFECT TRIGGERED",{hasService:!!d,hasUser:!!s,userId:s==null?void 0:s.id,isConnecting:b.current,isConnected:g,dependencies:{service:!!d,userId:s==null?void 0:s.id}}),l)return;if(!d||!s){o("⚠️ USER CONNECTION SKIPPED","Missing service or user");return}if(b.current){o("⚠️ USER CONNECTION SKIPPED","Already connecting");return}if(((L=A.current)==null?void 0:L.serviceId)===d&&(($=A.current)==null?void 0:$.userId)===s.id){o("⚠️ USER CONNECTION SKIPPED","Already connected this user with this service");return}(async()=>{o("🚀 STARTING USER CONNECTION",{userId:s.id}),b.current=!0,j(!0),x(null);try{o("📞 CALLING SERVICE.CONNECTUSER",{userId:s.id});const H=await d.connectUser(s);u(H),c(!0),A.current={serviceId:d,userId:s.id},o("✅ USER CONNECTION SUCCESS",{userId:s.id,clientId:H.userID})}catch(H){const Z=H instanceof Error?H.message:"Connection failed";x(Z),o("❌ USER CONNECTION ERROR",{userId:s.id,error:Z})}finally{j(!1),b.current=!1,o("🔄 USER CONNECTION FINISHED",{userId:s.id,isConnected:g})}})()},[d,s,o,g,l]),h.useEffect(()=>{const I=B;return()=>{var L;I&&(A.current=null,(L=_.current)==null||L.disconnectUser().catch(console.error))}},[B]);const E=h.useCallback(async()=>{if(o("🔄 REFRESH CONNECTION CALLED",{hasService:!!d,hasUser:!!s}),!l){if(!d||!s){o("⚠️ REFRESH CONNECTION SKIPPED","Missing service or user");return}o("🚀 STARTING CONNECTION REFRESH",{userId:s.id}),j(!0);try{o("🔌 DISCONNECTING FOR REFRESH"),await d.disconnectUser(),o("📞 RECONNECTING FOR REFRESH");const I=await d.connectUser(s);u(I),c(!0),x(null),o("✅ CONNECTION REFRESH SUCCESS",{userId:s.id})}catch(I){const L=I instanceof Error?I.message:"Refresh failed";x(L),o("❌ CONNECTION REFRESH ERROR",{userId:s.id,error:L})}finally{j(!1),o("🔄 CONNECTION REFRESH FINISHED",{userId:s.id})}}},[d,s,o,l]),R=h.useMemo(()=>(o("💫 CONTEXT VALUE MEMOIZATION",{hasService:!!d,hasClient:!!f,isConnected:g,isLoading:v,hasError:!!p,capabilitiesKeys:Object.keys(r)}),{service:l?null:d,client:l??f,isConnected:l?!0:g,isLoading:l?!1:v,error:l?null:p,capabilities:r,refreshConnection:E,debug:i}),[d,f,l,g,v,p,r,E,i,o]);return o("🔄 RENDER END",{renderCount:P.current,willRenderChat:!!B,contextValueReady:!!R}),t.jsx(qt.Provider,{value:R,children:B?t.jsx(w.Chat,{client:B,customClasses:{channelList:"str-chat__channel-list str-chat__channel-list-react bg-transparent lg:border-r-2 border-r-0 border-[#0000000A]"},children:e}):e})},Wt=()=>qe(),Xt=e=>{var a,r;const[s,n]=h.useState(!!((r=(a=e==null?void 0:e.state)==null?void 0:a.membership)!=null&&r.pinned_at));return h.useEffect(()=>{var l;if(!e){n(!1);return}n(!!((l=e.state.membership)!=null&&l.pinned_at));const i=o=>{var d;n(o!=null&&o.member?!!o.member.pinned_at:!!((d=e.state.membership)!=null&&d.pinned_at))};return e.on("member.updated",i),()=>{e.off("member.updated",i)}},[e]),s};function We(e,s,n){const a=Object.values(e||{});if(W.isOfficialChannel(n)){const r=a.find(i=>{var l;return((l=i.user)==null?void 0:l.id)===W.OFFICIAL_SENDER_USER_ID});if(r)return r}return a.find(r=>{var i;return((i=r.user)==null?void 0:i.id)&&r.user.id!==s})}const $s=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function Kt(e){return $s.test(e.trim())}function Lt(e,s){const n=e==null?void 0:e.trim();return!n||s&&n===s||s&&n===`Follower ${s}`?!1:!Kt(n)}function Xe(e){return Lt(e==null?void 0:e.name,e==null?void 0:e.id)?e.name.trim():Lt(e==null?void 0:e.username,e==null?void 0:e.id)?e.username.trim():"Unknown member"}const Rt=[{emoji:"🍎",bgColor:"#FFD1DD"},{emoji:"🍌",bgColor:"#FFF1C9"},{emoji:"🍇",bgColor:"#E6D9FF"},{emoji:"🍊",bgColor:"#D6F4FF"},{emoji:"🍓",bgColor:"#FFE0AE"},{emoji:"🥥",bgColor:"#F7E7D8"},{emoji:"🍒",bgColor:"#DFF4D8"},{emoji:"🥭",bgColor:"#FFD8C2"},{emoji:"🍉",bgColor:"#D6EBFF"},{emoji:"🍋",bgColor:"#CAEEB5"},{emoji:"🥝",bgColor:"#FFE7C7"},{emoji:"🫒",bgColor:"#F6E3B4"},{emoji:"🍈",bgColor:"#D9F7E1"}];function Us(e){let s=0;for(let n=0;n<e.length;n++){const a=e.charCodeAt(n);s=(s<<5)-s+a,s=s&s}return Math.abs(s)}function Zt(e){return Rt[Us(e)%Rt.length]}function Vs(e){return Zt(e).emoji}function Hs(e){return Zt(e).bgColor}const ce=({id:e,image:s,size:n=40,className:a,starred:r=!1,shape:i="squircle",dmAgentEnabled:l=!1})=>{const o=Vs(e),d=Hs(e),m=.45,u=n<32?Math.round(n*m):n<56?14:n<120?18:36,g=n>=40?2:1,c=i==="circle"?{borderRadius:"50%"}:{borderRadius:"1rem"},v=t.jsx("div",{className:"h-full w-full overflow-hidden",style:c,children:s?t.jsx("img",{src:s,alt:"",className:"h-full w-full object-cover"}):t.jsx("div",{"aria-hidden":"true",className:C("avatar-fallback flex h-full w-full items-center justify-center font-semibold select-none transition-colors"),style:{fontSize:u,lineHeight:1},children:o})});return t.jsxs("div",{className:C("relative flex-shrink-0",a),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`,backgroundColor:s?void 0:d,...c},children:[r&&t.jsx("div",{"aria-hidden":"true",className:"absolute -left-1.5 -top-1.5 z-10 flex size-5 items-center justify-center rounded-full bg-white shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",children:t.jsx(y.StarIcon,{className:"size-3 text-yellow-600",weight:"duotone"})}),t.jsx("div",{"data-testid":"avatar-ring",className:C("h-full w-full","bg-transparent"),style:{...c,...l&&{borderWidth:`${g}px`,borderStyle:"solid",borderColor:"var(--AI-Gradient, #7F22FE)",boxShadow:"inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"}},children:v})]})},Gs="https://linktr.ee/s/about/trust-center/report",Ys=({channel:e,participant:s,showBlockParticipant:n=!0,enabled:a=!0,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:l,onBlockParticipantClick:o,onReportParticipantClick:d,onActionComplete:m,logLabel:f="useChannelModerationActions"})=>{var R;const{service:u,debug:g}=qe(),c=(R=s==null?void 0:s.user)==null?void 0:R.id,v=!!(a&&n&&u&&c),[j,p]=h.useState(!1),[x,b]=h.useState(null),[_,S]=h.useState(!1),[T,F]=h.useState(!1),P=v&&((x==null?void 0:x.participantId)!==c||(x==null?void 0:x.service)!==u);return h.useEffect(()=>{if(!v||!u||!c){p(!1),b(null);return}let k=!1;return(async()=>{try{const M=await u.getBlockedUsers();if(k)return;p(M.some(I=>I.blocked_user_id===c))}catch(M){k||console.error(`[${f}] Failed to check blocked status:`,M)}finally{k||b({participantId:c,service:u})}})(),()=>{k=!0}},[v,u,c,f]),{isParticipantBlocked:j,isCheckingBlockedStatus:P,isLeaving:_,isUpdatingBlockStatus:T,handleLeaveConversation:async()=>{var k;if(!_){l==null||l(),g&&console.log(`[${f}] Leave conversation`,e.cid),S(!0);try{const M=((k=e._client)==null?void 0:k.userID)??null;await e.hide(M,!1),r&&await r(e),m==null||m()}catch(M){console.error(`[${f}] Failed to leave conversation`,M)}finally{S(!1)}}},handleBlockUser:async()=>{var k,M,I;if(!(T||!u)){o==null||o(),g&&console.log(`[${f}] Block member`,(k=s==null?void 0:s.user)==null?void 0:k.id),F(!0);try{await u.blockUser((M=s==null?void 0:s.user)==null?void 0:M.id),i&&await i((I=s==null?void 0:s.user)==null?void 0:I.id),m==null||m()}catch(L){console.error(`[${f}] Failed to block member`,L)}finally{F(!1)}}},handleUnblockUser:async()=>{var k,M,I;if(!(T||!u)){o==null||o(),g&&console.log(`[${f}] Unblock member`,(k=s==null?void 0:s.user)==null?void 0:k.id),F(!0);try{await u.unBlockUser((M=s==null?void 0:s.user)==null?void 0:M.id),i&&await i((I=s==null?void 0:s.user)==null?void 0:I.id),m==null||m()}catch(L){console.error(`[${f}] Failed to unblock member`,L)}finally{F(!1)}}},handleReportUser:()=>{d==null||d(),m==null||m(),window.open(Gs,"_blank","noopener,noreferrer")}}},he=({variant:e="default",className:s,children:n,...a})=>{const r=e==="danger";return t.jsx("button",{type:"button",className:C("flex w-full items-center gap-3 rounded-lg px-4 py-3 text-left text-sm transition-colors focus-ring disabled:cursor-not-allowed disabled:opacity-60",r?"text-danger hover:bg-danger/50":"text-charcoal hover:bg-sand",s),...a,children:n})},qs=({channel:e,participant:s,showDeleteConversation:n=!0,showBlockParticipant:a=!0,showReportParticipant:r=!0,onLeaveConversation:i,onBlockParticipant:l,onDeleteConversationClick:o,onBlockParticipantClick:d,onReportParticipantClick:m,customChannelActions:f,triggerClassName:u})=>{const[g,c]=h.useState(!1),v=h.useRef(null),j=h.useId(),p=h.useCallback(()=>c(!1),[]),{isParticipantBlocked:x,isCheckingBlockedStatus:b,isLeaving:_,isUpdatingBlockStatus:S,handleLeaveConversation:T,handleBlockUser:F,handleUnblockUser:P,handleReportUser:z}=Ys({channel:e,participant:s,showBlockParticipant:a,enabled:g,onLeaveConversation:i,onBlockParticipant:l,onDeleteConversationClick:o,onBlockParticipantClick:d,onReportParticipantClick:m,onActionComplete:p,logLabel:"ChannelActionsMenu"});return h.useEffect(()=>{if(!g)return;const A=R=>{v.current&&!v.current.contains(R.target)&&c(!1)},E=R=>{R.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",A),document.addEventListener("keydown",E),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("keydown",E)}},[g]),!s||!(n||a||r||!!f)?null:t.jsxs("div",{ref:v,className:"relative",children:[t.jsxs("button",{className:u,type:"button","aria-haspopup":"true","aria-expanded":g,"aria-controls":g?j:void 0,onClick:()=>c(A=>!A),children:[t.jsx(y.DotsThreeIcon,{className:"size-5 text-black/90"}),t.jsx("span",{className:"sr-only",children:"More options"})]}),g&&t.jsx("div",{id:j,"aria-label":"Conversation options",className:C("absolute right-0 top-full z-50 mt-2 w-56 overflow-hidden","rounded-lg border border-sand bg-white p-1 shadow-max-elevation-light"),children:t.jsxs("ul",{className:"flex flex-col gap-1",children:[n&&t.jsx("li",{children:t.jsxs(he,{onClick:T,disabled:_,"aria-busy":_,children:[_?t.jsx(y.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):t.jsx(y.SignOutIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Delete Conversation"})]})}),a&&t.jsx("li",{children:b?t.jsxs(he,{disabled:!0,"aria-busy":!0,children:[t.jsx(y.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}),t.jsx("span",{children:"Block"})]}):x?t.jsxs(he,{onClick:P,disabled:S,"aria-busy":S,children:[S?t.jsx(y.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):t.jsx(y.ProhibitInsetIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Unblock"})]}):t.jsxs(he,{onClick:F,disabled:S,"aria-busy":S,children:[S?t.jsx(y.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):t.jsx(y.ProhibitInsetIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Block"})]})}),r&&t.jsx("li",{children:t.jsxs(he,{variant:"danger",onClick:z,children:[t.jsx(y.FlagIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Report"})]})}),f]})})]})},Pe="flex size-10 flex-shrink-0 items-center justify-center rounded-full bg-white/65 shadow-[0px_4px_8px_0px_rgba(0,0,0,0.06),0px_0px_0px_1px_rgba(0,0,0,0.04)] backdrop-blur-[40px] transition-filter duration-150 hover:brightness-95 aria-expanded:brightness-95 focus-ring",Ws="CUSTOMER_PAID",Xs=e=>typeof e=="string"&&e.trim().replace(/[\s-]+/g,"_").toUpperCase()===Ws,Ks=({className:e,onBack:s,showBackButton:n,showStarButton:a=!1,onLeaveConversation:r,onBlockParticipant:i,showDeleteConversation:l=!0,showBlockParticipant:o=!0,showReportParticipant:d=!0,onDeleteConversationClick:m,onBlockParticipantClick:f,onReportParticipantClick:u,customChannelActions:g,renderChannelActions:c,showChannelInfo:v=!0,onParticipantNameClick:j})=>{var E,R,k,M;const{channel:p}=w.useChannelStateContext(),{client:x}=w.useChatContext(),b=h.useMemo(()=>{var I;return We((I=p.state)==null?void 0:I.members,x==null?void 0:x.userID,p.type)},[(E=p.state)==null?void 0:E.members,x==null?void 0:x.userID,p.type]),_=Xe(b==null?void 0:b.user),S=(R=b==null?void 0:b.user)==null?void 0:R.image,T=Xt(p),F=Xs((k=p.data)==null?void 0:k.customer_tag)&&(b==null?void 0:b.is_follower)===!0,P=a&&T,z=F||P||!!j,B=async()=>{try{T?await p.unpin():await p.pin()}catch(I){console.error("[ChannelHeaderRedesign] Failed to update pinned status:",I)}},A=t.jsxs(t.Fragment,{children:[t.jsx(ce,{id:((M=b==null?void 0:b.user)==null?void 0:M.id)||p.id||"unknown",name:_,image:S,shape:"circle",size:48,className:"-mb-2"}),t.jsx("span",{className:C("relative z-10 flex max-w-full flex-col items-center justify-center rounded-full border border-white/10 bg-white/65 py-1.5 shadow-[0px_0px_0px_0px_rgba(0,0,0,0.04),0px_1px_2px_0px_rgba(0,0,0,0.04),0px_8px_32px_0px_rgba(0,0,0,0.1)] backdrop-blur-[2px] transition-filter duration-150 group-hover:brightness-95",z?"pl-3 pr-2":"px-3"),children:t.jsxs("span",{className:"flex max-w-full items-center justify-center",children:[t.jsx("span",{className:"min-w-0 truncate text-sm font-bold leading-[1.43] tracking-[0.28px] text-black/90",children:_}),z&&t.jsxs("span",{className:"ml-2 flex gap-1",children:[F&&t.jsx("span",{"aria-label":"Paid customer",className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-[#34C759] text-white",children:t.jsx(y.CurrencyDollarIcon,{className:"size-2.5",weight:"bold"})}),P&&t.jsx("span",{"aria-label":"Starred conversation",className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-[#FFD60A] text-white",children:t.jsx(y.StarIcon,{className:"size-2.5",weight:"fill"})}),j&&t.jsx(y.CaretRightIcon,{"aria-hidden":"true",className:"size-4 shrink-0 text-black/65",weight:"bold"})]})]})})]});return t.jsx("div",{className:C("@container bg-[linear-gradient(180deg,#FBFAF9_0%,rgba(251,250,249,0.92)_58%,rgba(251,250,249,0)_100%)]",e),children:t.jsxs("div",{className:"grid min-h-[100px] grid-cols-[minmax(40px,1fr)_auto_minmax(40px,1fr)] items-start pb-2 pt-5 @lg:min-h-[104px] @lg:pt-6",children:[t.jsx("div",{className:"flex items-start",children:n&&t.jsx("button",{className:C(Pe,"messaging-channel-view-back-button-mobile messaging-channel-view-back-button-desktop"),onClick:s||(()=>{}),type:"button","aria-label":"Back to conversations",children:t.jsx(y.ArrowLeftIcon,{className:"size-5 text-black/90"})})}),t.jsx("div",{className:"flex min-w-0 justify-center","data-dd-privacy":"mask",children:j?t.jsx("button",{type:"button",onClick:j,"aria-label":`View details for ${_}`,className:"group flex min-w-0 max-w-full appearance-none flex-col items-center border-0 bg-transparent px-2 focus-ring focus-visible:outline-none",children:A}):t.jsx("div",{className:"flex min-w-0 max-w-full flex-col items-center px-2",children:A})}),t.jsxs("div",{className:"flex items-start justify-end gap-2",children:[a&&t.jsx("button",{className:Pe,onClick:B,type:"button","aria-pressed":T,"aria-label":T?"Unstar conversation":"Star conversation",children:t.jsx(y.StarIcon,{className:C("size-5",{"text-[#FFD60A]":T,"text-black/90":!T}),weight:T?"fill":"regular"})}),v&&(c!==void 0?c:t.jsx(qs,{channel:p,participant:b,showDeleteConversation:l,showBlockParticipant:o,showReportParticipant:d,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:m,onBlockParticipantClick:f,onReportParticipantClick:u,customChannelActions:g,triggerClassName:Pe}))]})]})})},Zs=e=>t.jsx(w.DateSeparator,{...e,position:"center"}),Ve="vote_up",He="vote_down";function Js(e){return e!=null&&e.length?e.some(s=>s.type===He)?"down":e.some(s=>s.type===Ve)?"up":null:null}function Jt(e){const{channel:s}=w.useChannelStateContext(),{client:n}=w.useChatContext("useMessageVote"),a=h.useMemo(()=>Js(e.own_reactions),[e.own_reactions]),r=h.useCallback(async()=>{if(n!=null&&n.userID)try{a==="up"?await s.deleteReaction(e.id,Ve):await s.sendReaction(e.id,{type:Ve},{enforce_unique:!0,skip_push:!0})}catch{}},[s,n==null?void 0:n.userID,e.id,a]),i=h.useCallback(async()=>{if(n!=null&&n.userID)try{a==="down"?await s.deleteReaction(e.id,He):await s.sendReaction(e.id,{type:He},{enforce_unique:!0,skip_push:!0})}catch{}},[s,n==null?void 0:n.userID,e.id,a]);return{selected:a,voteUp:r,voteDown:i}}function Qt(e){return(e==null?void 0:e.trim().toLowerCase().split(/[-_]/)[0])||void 0}function Ke({message:e,viewerLanguage:s}){var r;const n=e==null?void 0:e.text,a=Qt(s);return a?((r=e==null?void 0:e.i18n)==null?void 0:r[`${a}_text`])??n:n}const Qs=["linktr.ee"],Dt="messaging-attachment-v1_0";function en(e){try{return new URL(e).hostname.toLowerCase()}catch{return null}}function tn(e){return Qs.some(s=>e===s||e.endsWith(`.${s}`))}function re(e){const s=e==null?void 0:e.trim();if(!s)return;const n=en(s);if(!n||!tn(n))return s;const a=new URL(s);return a.searchParams.get("io")==="true"&&a.searchParams.get("size")===Dt?s:(a.searchParams.set("io","true"),a.searchParams.set("size",Dt),a.toString())}const sn=[[/pdf/,"pdf"],[/wordprocessingml|msword|\.doc/,"doc"],[/spreadsheetml|ms-excel|\.xls/,"xls"],[/csv/,"csv"],[/presentationml|ms-powerpoint|\.ppt/,"ppt"],[/zip|x-rar|x-7z|x-tar|x-gzip/,"zip"],[/plain|rtf/,"text"],[/markdown/,"markdown"]];function ee(e){return e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.startsWith("image/")?"image":"document"}function es(e){const s=sn.find(([n])=>n.test(e));return s?s[1]:"generic"}const nn={video:y.VideoCameraIcon,audio:y.SpeakerHighIcon,image:y.ImageIcon,document:y.FileIcon},an={pdf:y.FilePdfIcon,doc:y.FileDocIcon,xls:y.FileXlsIcon,csv:y.FileCsvIcon,ppt:y.FilePptIcon,zip:y.FileZipIcon,text:y.FileTextIcon,markdown:y.FileMdIcon,generic:y.FileIcon};function rn(e){const s=ee(e);return s!=="document"?nn[s]:an[es(e)]}function le(e,s){return h.createElement(rn(e),s)}const on=e=>{var s,n;return"touches"in e?((s=e.touches[0])==null?void 0:s.clientX)??((n=e.changedTouches[0])==null?void 0:n.clientX)??0:e.clientX},ln=({source:e,mimeType:s,poster:n,autoPlay:a=!1,playing:r,loop:i=!1,controls:l=!0,showProgress:o=!1,muted:d=!1,onContainerClick:m})=>{const f=ee(s),u=h.useRef(null),g=h.useRef(null),c=h.useRef(null),v=h.useRef(r),[j,p]=h.useState(a),[x,b]=h.useState(0),[_,S]=h.useState(!1),[T,F]=h.useState(!1),[P,z]=h.useState(!1),[B,A]=h.useState(!1),[E,R]=h.useState(!0),[k,M]=h.useState(null),I=h.useCallback(()=>{z(!1),p(!0)},[]),L=h.useCallback(N=>{const D=g.current;if(!D)return 0;const V=D.getBoundingClientRect();return Math.max(0,Math.min(1,(on(N)-V.left)/V.width))},[]),$=h.useCallback(N=>{const D=u.current;D&&D.duration&&(D.currentTime=N*D.duration)},[]),H=N=>{N.stopPropagation(),S(!0);const D=L(N);b(D),$(D)};h.useEffect(()=>{r!==void 0&&r!==v.current&&(v.current=r,p(r))},[r]),h.useEffect(()=>{if(!j){c.current!==null&&(cancelAnimationFrame(c.current),c.current=null);return}const N=()=>{const D=u.current;D&&D.duration&&!_&&b(D.currentTime/D.duration),c.current=requestAnimationFrame(N)};return c.current=requestAnimationFrame(N),()=>{c.current!==null&&cancelAnimationFrame(c.current)}},[j,_]),h.useEffect(()=>{const N=u.current;N&&(j?N.play().catch(D=>{p(!1),z(!0)}):N.pause())},[j]),h.useEffect(()=>{if(!_)return;const N=V=>b(L(V)),D=V=>{S(!1),$(L(V))};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",D),window.addEventListener("touchmove",N,{passive:!0}),window.addEventListener("touchend",D),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",D),window.removeEventListener("touchmove",N),window.removeEventListener("touchend",D)}},[_,L,$]);const Z=k?{aspectRatio:String(k)}:void 0,te=k?"":" aspect-video",Y=Math.round(x*100);return t.jsxs("div",{role:"button",tabIndex:0,className:`relative cursor-pointer overflow-hidden bg-black ${te}`,style:Z,onClick:N=>{if(m){m(N);return}P||l&&p(D=>!D)},onKeyDown:N=>{if(!(N.key!=="Enter"&&N.key!==" ")){if(N.preventDefault(),m){m(N);return}P||l&&p(D=>!D)}},children:[n&&(f==="audio"||E)&&t.jsx("img",{src:n,alt:"",className:"absolute inset-0 h-full w-full object-cover"}),!n&&(f==="audio"||E)&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:le(s,{className:"size-12 text-black/20",weight:"regular"})}),t.jsx("div",{className:"absolute inset-0",children:f==="audio"?t.jsx("audio",{ref:u,src:e,loop:i,muted:d,style:{width:"100%",height:"100%"},onLoadStart:()=>A(!0),onCanPlay:()=>{A(!1),R(!1)},onWaiting:()=>A(!0),onPlay:()=>z(!1),onEnded:()=>{i||(p(!1),b(0))},children:t.jsx("track",{kind:"captions"})}):t.jsx("video",{ref:u,src:e,loop:i,muted:d,playsInline:!0,style:{width:"100%",height:"100%"},onLoadStart:()=>A(!0),onCanPlay:()=>{A(!1),R(!1)},onWaiting:()=>A(!0),onPlay:()=>z(!1),onLoadedMetadata:()=>{const N=u.current;N instanceof HTMLVideoElement&&N.videoWidth&&N.videoHeight&&M(N.videoWidth/N.videoHeight)},onEnded:()=>{i||(p(!1),b(0))},children:t.jsx("track",{kind:"captions"})})}),B&&!P&&t.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:t.jsx(y.CircleNotchIcon,{className:"size-8 animate-spin text-white/80",weight:"bold"})}),P&&!l&&t.jsx("div",{className:"absolute inset-0 z-30 flex cursor-pointer items-center justify-center bg-black/35",role:"button",tabIndex:0,"aria-label":"Play preview",onClick:N=>{N.stopPropagation(),I()},onKeyDown:N=>{N.key!=="Enter"&&N.key!==" "||(N.preventDefault(),N.stopPropagation(),I())},children:t.jsx("span",{className:"flex size-16 items-center justify-center rounded-full bg-white/20 text-white backdrop-blur-sm",children:t.jsx(y.PlayIcon,{className:"size-9 translate-x-0.5",weight:"fill"})})}),o&&!l&&t.jsx("div",{className:"absolute inset-x-0 bottom-0 px-3 pb-2.5 pt-6 bg-gradient-to-t from-black/40 to-transparent",children:t.jsx("div",{role:"slider","aria-label":"Playback position","aria-valuenow":Y,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:g,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:H,onTouchStart:H,onClick:N=>N.stopPropagation(),onKeyDown:N=>{N.key==="ArrowRight"&&$(Math.min(1,x+.05)),N.key==="ArrowLeft"&&$(Math.max(0,x-.05))},children:t.jsx("div",{className:"w-full overflow-hidden rounded-full bg-white/30 h-1",children:t.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${Y}%`}})})})}),l&&t.jsxs("div",{className:"absolute inset-x-0 bottom-0 flex items-center gap-2 bg-gradient-to-t from-black/60 to-transparent px-3 pb-2.5 pt-6 transition-all duration-200",children:[t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),p(D=>!D)},className:"shrink-0 text-white","aria-label":j?"Pause":"Play",children:j?t.jsx(y.PauseIcon,{className:"size-5",weight:"fill"}):t.jsx(y.PlayIcon,{className:"size-5 translate-x-px",weight:"fill"})}),t.jsxs("div",{role:"slider","aria-label":"Playback position","aria-valuenow":Y,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:g,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:H,onTouchStart:H,onClick:N=>N.stopPropagation(),onMouseEnter:()=>F(!0),onMouseLeave:()=>F(!1),onKeyDown:N=>{N.key==="ArrowRight"&&$(Math.min(1,x+.05)),N.key==="ArrowLeft"&&$(Math.max(0,x-.05))},children:[t.jsx("div",{className:`w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${T||_?"h-1.5":"h-1"}`,children:t.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${Y}%`}})}),t.jsx("div",{className:`absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${T||_?"scale-100 opacity-100":"scale-0 opacity-0"}`,style:{left:`${Y}%`}})]})]})]})},Pt=e=>e==="dark"?"size-12 text-white/20":"size-12 text-black/20",cn=e=>e==="dark"?"aspect-video overflow-hidden bg-white/10":"aspect-video overflow-hidden bg-black/5",Ze=({mimeType:e,sourceUrl:s,thumbnailUrl:n,title:a,variant:r,mediaPlayerProps:i,containedImage:l=!1})=>{const o=ee(e),[d,m]=h.useState(!1),f=re(s),u=re(n);return s&&(o==="video"||o==="audio")?t.jsx(ln,{source:s,mimeType:e,poster:u,controls:!0,...i}):s&&o==="image"?l?t.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:t.jsx("img",{src:f??s,alt:a??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${d?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>m(!0)})}):t.jsx("img",{src:f??s,alt:a??"",className:"block w-full",draggable:!1}):s&&o==="document"?n?l?t.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:t.jsx("img",{src:u??n,alt:a??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${d?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>m(!0)})}):t.jsx("img",{src:u??n,alt:"",className:"block w-full",draggable:!1}):t.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${r==="dark"?"bg-white/10":"bg-black/5"}`,children:le(e,{className:Pt(r),weight:"regular"})}):n?t.jsx("div",{className:`relative ${cn(r)}`,children:t.jsx("img",{src:u??n,alt:a??"",draggable:!1,className:"absolute inset-0 h-full w-full object-cover"})}):t.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${r==="dark"?"bg-white/10":"bg-black/5"}`,children:le(e,{className:Pt(r),weight:"regular"})})},ts=({variant:e,thumbnail:s,title:n,placeholderTitle:a="Attachment title",mimeType:r,detail:i,statusBadge:l,action:o,topLeft:d,topRight:m,rootRef:f,"data-testid":u})=>{const g=e==="dark",c=g?n??a:n??"",v=g&&!n;return t.jsxs("div",{ref:f,"data-testid":u,className:C("relative w-[280px] select-none overflow-hidden rounded-[24px] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",g?"bg-[#1e2330]":"bg-white"),children:[d?t.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-50",children:d}):null,m?t.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-50",children:m}):null,s,t.jsxs("div",{className:"px-4 pb-3 pt-3",children:[c.trim()!==""&&t.jsx("p",{className:C("mb-0.5 truncate text-base font-medium",{"text-black":!g,"text-white/30":g&&v,"text-white":g&&!v}),children:c}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[le(r,{className:C("size-5 shrink-0",g?"text-white/55":"text-black/55"),weight:"regular"}),i!=null&&i!==""&&t.jsx("span",{className:C("text-xs font-medium",g?"text-white/55":"text-black/55"),children:i}),l]}),o]})]})};function ss(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Je(e){return`w-[280px] select-none overflow-hidden rounded-[24px] ${e?"bg-[#1e2330]":"bg-[#F3F3F1]"} shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]`}function dn(e){return e?"bg-white/10":"bg-black/5"}function un(e){return e?"text-white":"text-black"}function mn(e){return e?"text-white/55":"text-black/55"}function hn(e){return e?"text-white/40":"text-black/40"}function fn(e){return e?"text-white/20":"text-black/20"}const Qe=({attachment:e,isMyMessage:s})=>{const{title:n,text:a,image_url:r,og_scrape_url:i,title_link:l}=e,o=i??l,d=typeof o=="string"&&o.trim()!==""?o:void 0,m=t.jsxs(h.Fragment,{children:[t.jsx("div",{className:"p-2",children:r?t.jsx("img",{src:re(r)??r,alt:n??"",className:"aspect-video w-full rounded-[20px] object-cover"}):t.jsx("div",{className:`aspect-video w-full rounded-[20px] ${dn(s)} flex items-center justify-center`,children:t.jsx(y.LinkIcon,{className:`size-12 ${fn(s)}`})})}),t.jsxs("div",{className:"px-3 pb-3",children:[n&&t.jsx("p",{className:`truncate text-[14px] font-medium leading-5 ${un(s)}`,children:n}),a&&t.jsx("p",{className:`truncate text-[12px] leading-4 ${mn(s)}`,children:a}),d&&t.jsx("p",{className:`mt-1 truncate text-[12px] leading-4 ${hn(s)}`,children:d})]})]});return d?t.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"block no-underline",children:m}):t.jsx("div",{className:"block",children:m})};function et(e){return e.type==="link"||!!e.og_scrape_url&&!e.asset_url}function Ae(e){var s;return(s=e.attachments)==null?void 0:s.find(et)}async function gn(e,s){let n;try{n=s??new URL(e).pathname.split("/").pop()??"download"}catch{n=s??"download"}const a=await fetch(e,{mode:"cors"});if(!a.ok)throw new Error(`HTTP ${a.status}`);const r=await a.blob(),i=URL.createObjectURL(r),l=document.createElement("a");l.href=i,l.download=n,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)}const xn=({url:e,filename:s})=>{const[n,a]=h.useState(!1),r=i=>{i.stopPropagation();const l=window.open("","_blank","noopener,noreferrer");a(!0),gn(e,s).then(()=>{l==null||l.close()}).catch(()=>{l&&(l.location.href=e)}).finally(()=>a(!1))};return t.jsx("button",{type:"button",onClick:r,disabled:n,className:"mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounded-full bg-[#121110] px-4 text-sm font-medium leading-none text-white hover:bg-[#2a2928] disabled:opacity-70",children:n?t.jsx(y.CircleNotchIcon,{className:"size-4 animate-spin text-white",weight:"bold"}):t.jsxs(h.Fragment,{children:[t.jsx(y.DownloadSimpleIcon,{className:"size-4 text-white",weight:"bold"}),"Download"]})})};function Le(e){var u,g,c,v;const s=(u=e.attachments)==null?void 0:u.find(j=>j.type==="video"&&j.asset_url),n=(g=e.attachments)==null?void 0:g.find(j=>j.type==="image"&&j.image_url),a=(c=e.attachments)==null?void 0:c.find(j=>j.type==="audio"&&j.asset_url),r=(v=e.attachments)==null?void 0:v.find(j=>j.type==="file"&&j.asset_url),i=s??n??a??r,l=(s==null?void 0:s.asset_url)??(n==null?void 0:n.image_url)??(a==null?void 0:a.asset_url)??(r==null?void 0:r.asset_url);if(!l)return null;const o=(i==null?void 0:i.mime_type)??((i==null?void 0:i.type)==="image"?"image/jpeg":(i==null?void 0:i.type)==="video"?"video/mp4":(i==null?void 0:i.type)==="audio"?"audio/mpeg":"application/octet-stream"),d=i==null?void 0:i.title,m=i==null?void 0:i.file_size,f=s==null?void 0:s.thumb_url;return{resolvedUrl:l,resolvedType:o,title:d,fileSize:m,thumbnailUrl:f}}const ns=({resolvedUrl:e,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=a!==void 0?ss(a):void 0;return t.jsx(ts,{variant:"dark",title:n,placeholderTitle:"",mimeType:s,detail:i,thumbnail:t.jsx(Ze,{mimeType:s,sourceUrl:e,thumbnailUrl:r,title:n,variant:"dark"})})},as=({resolvedUrl:e,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=ee(s),l=a!==void 0?ss(a):void 0;return t.jsx(ts,{variant:"light",title:n,mimeType:s,detail:l,thumbnail:t.jsx(Ze,{mimeType:s,sourceUrl:e,thumbnailUrl:r,title:n,variant:"light",containedImage:i==="image"||i==="document"}),action:t.jsx(xn,{url:e,filename:n})})},pn=({message:e,isMyMessage:s=!1})=>{const n=Ae(e),a=Le(e);if(!n&&!a)return null;const r=s?"str-chat__message str-chat__message-simple str-chat__message--me str-chat__message-simple--me":"str-chat__message str-chat__message-simple str-chat__message--other";return t.jsxs("div",{className:r,"data-dd-privacy":"mask",children:[!s&&e.user&&t.jsx(ce,{className:"str-chat__avatar str-chat__message-sender-avatar",id:e.user.id,image:e.user.image,name:e.user.name??e.user.id}),t.jsx("div",{className:"str-chat__message-inner",style:{marginInlineEnd:0,marginInlineStart:0},children:t.jsx("div",{className:"str-chat__message-bubble-wrapper",children:t.jsx("div",{className:"str-chat__message-bubble","data-attachment-bubble":"true",style:{padding:0,borderRadius:0,overflow:"visible",background:"transparent"},children:n?t.jsx("div",{className:Je(s),children:t.jsx(Qe,{attachment:n,isMyMessage:s})}):s?t.jsx(ns,{...a}):t.jsx(as,{...a})})})})]})},bn=({message:e})=>{const s=Ae(e);if(s)return t.jsx("div",{className:Je(!0),"data-dd-privacy":"mask",children:t.jsx(Qe,{attachment:s,isMyMessage:!0})});const n=Le(e);return n?t.jsx("div",{style:{display:"contents"},"data-dd-privacy":"mask",children:t.jsx(ns,{...n})}):null},vn=({message:e})=>{const s=Ae(e);if(s)return t.jsx("div",{className:Je(!1),"data-dd-privacy":"mask",children:t.jsx(Qe,{attachment:s,isMyMessage:!1})});const n=Le(e);return n?t.jsx("div",{style:{display:"contents"},"data-dd-privacy":"mask",children:t.jsx(as,{...n})}):null},jn=Object.assign(pn,{Creator:bn,Visitor:vn}),_n={dark:"bg-[#1e2330]",light:"bg-[#f2f1ef]"},wn={dark:"text-white",light:"text-[#000000]"},Nn={dark:"border-white/[0.08]",light:"border-black/[0.08]"},yn=e=>e==="dark"?"sender":"receiver",Cn={sender:{single:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]",first:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[4px]",middle:"rounded-tl-[18px] rounded-tr-[4px] rounded-bl-[18px] rounded-br-[4px]",end:"rounded-tl-[18px] rounded-tr-[4px] rounded-bl-[18px] rounded-br-[18px]"},receiver:{single:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]",first:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[4px] rounded-br-[18px]",middle:"rounded-tl-[4px] rounded-tr-[18px] rounded-bl-[4px] rounded-br-[18px]",end:"rounded-tl-[4px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]"}},pe=({variant:e,text:s,bordered:n=!0,groupPosition:a="single",widthClassName:r="w-[280px]",paddingClassName:i="px-2 py-2",radiusClassName:l,className:o,children:d,"data-testid":m})=>{const f=s!=null&&s!=="",u=l??Cn[yn(e)][a];return t.jsxs("div",{"data-testid":m,"data-group-position":a,className:C("relative",r,"overflow-hidden",i,f&&"pb-0",u,_n[e],wn[e],n&&"border",n&&Nn[e],o),children:[d,f?t.jsx("p",{className:C("whitespace-pre-wrap break-words leading-snug","pb-2 pt-2","px-2"),children:s}):null]})},be=({onClick:e,variant:s="overlay",ariaLabel:n="Dismiss attachment"})=>t.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),e()},"aria-label":n,className:C("flex size-6 items-center justify-center rounded-full text-white",s==="overlay"?"bg-[#121110]/85 backdrop-blur":"bg-white/15 hover:bg-white/25"),children:t.jsx(y.XIcon,{className:"size-3",weight:"bold"})}),ve=e=>e==="received"?"light":"dark",rs=({firstOfGroup:e,endOfGroup:s,groupedByUser:n})=>!n||e&&s?"single":e?"first":s?"end":"middle",Sn=({src:e,mimeType:s,filename:n,items:a})=>a&&a.length>0?a:e?[{src:e,mimeType:s,filename:n}]:[],kn=({item:e,preload:s,trailingAction:n})=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("audio",{src:e.src,controls:!0,preload:e.preload??s,className:"block min-w-0 flex-1",children:e.mimeType?t.jsx("source",{src:e.src,type:e.mimeType}):null}),n??null]}),tt=({state:e,src:s,mimeType:n,filename:a,items:r,text:i,groupPosition:l,preload:o,onDismiss:d})=>{const m=ve(e),f=e==="composer"&&!!d,u=Sn({src:s,mimeType:n,filename:a,items:r});if(u.length===0)return null;const g=o??(u.length>1?"none":"metadata");return t.jsx(pe,{variant:m,text:i,groupPosition:l,"data-testid":"audio-attachment",children:t.jsx("div",{className:"flex flex-col gap-2",children:u.map((c,v)=>t.jsx(kn,{item:c,preload:g,trailingAction:f&&v===0?t.jsx(be,{onClick:d,variant:"inline"}):void 0},`${c.src}-${v}`))})})},En=e=>t.jsx(tt,{...e,state:"composer"}),In=e=>t.jsx(tt,{...e,state:"sent"}),Tn=e=>t.jsx(tt,{...e,state:"received"}),Mn={Composer:En,Sent:In,Received:Tn};function is(e){return!Number.isFinite(e)||e<0?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(2)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}const An={pdf:"PDF",doc:"DOC",xls:"XLS",csv:"CSV",ppt:"PPT",zip:"ZIP",text:"TXT",markdown:"MD"};function os(e,s){if(s){const r=s.lastIndexOf(".");if(r>0&&r<s.length-1){const i=s.slice(r+1);if(i&&i.length<=5)return i.toUpperCase()}}if(!e)return;if(ee(e)==="document"){const r=es(e),i=An[r];if(i)return i;if(e==="application/octet-stream")return}const a=e.split("/")[1];if(!(!a||a==="*"))return a.toUpperCase()}function ls(e,s,n){const a=os(e,s),r=typeof n=="number"&&n>0?is(n):void 0;return[a,r].filter(Boolean).join(" · ")||void 0}function Q(e){try{const n=new URL(e).pathname.split("/").pop();return n&&n.length>0?decodeURIComponent(n):"download"}catch{return"download"}}const Ln={dark:"text-white/55",light:"text-black/65"},Rn={dark:"bg-white/10",light:"bg-black/5"},Dn={dark:"text-white/85",light:"text-black/85"},cs=({variant:e,filename:s,title:n,mimeType:a="application/octet-stream",fileSize:r,onActivate:i,activateLabel:l,trailingAction:o})=>{const d=n??s??"File",m=ls(a,s,r),f=t.jsx("div",{className:C("flex size-10 shrink-0 items-center justify-center rounded-sm",Rn[e]),"aria-hidden":!0,children:le(a,{className:C("size-6",Dn[e]),weight:"regular"})}),u=t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col text-left",children:[t.jsx("p",{className:"truncate font-medium leading-snug",children:d}),m?t.jsx("p",{className:C("truncate text-xs leading-4",Ln[e]),children:m}):null]}),g=i?t.jsxs("button",{type:"button",onClick:i,"aria-label":l,className:C("flex min-w-0 flex-1 items-center gap-3 rounded-sm text-left transition-colors",e==="dark"?"hover:bg-white/[0.04]":"hover:bg-black/[0.04]"),children:[f,u]}):t.jsxs(t.Fragment,{children:[f,u]});return t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[g,o?t.jsx("div",{className:"shrink-0",children:o}):null]})};async function ds(e,s){const n=s??Q(e);try{const a=await fetch(e,{mode:"cors"});if(!a.ok)throw new Error(`HTTP ${a.status}`);const r=await a.blob(),i=URL.createObjectURL(r),l=document.createElement("a");l.href=i,l.download=n,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)}catch{if(!window.open(e,"_blank","noopener,noreferrer")){const r=document.createElement("a");r.href=e,r.download=n,r.target="_blank",r.rel="noopener noreferrer",r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r)}}}const Pn=({src:e,filename:s,fileSize:n,mimeType:a,title:r,items:i})=>i&&i.length>0?i:e?[{src:e,filename:s,fileSize:n,mimeType:a,title:r}]:[],On=({variant:e,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??Q(s.src);return t.jsx(cs,{variant:e,filename:i,title:s.title,mimeType:s.mimeType??"application/octet-stream",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Download ${i}`,trailingAction:r})},st=({state:e,src:s,filename:n,fileSize:a,mimeType:r,title:i,items:l,text:o,groupPosition:d,onClick:m,onDismiss:f})=>{const u=ve(e),g=e==="composer"&&!!f,c=Pn({src:s,filename:n,fileSize:a,mimeType:r,title:i,items:l}),v=p=>{if((m==null?void 0:m(p))===!1)return;const x=c[p];if(!x)return;const b=x.filename??Q(x.src);ds(x.src,b)};if(c.length===0)return null;const j=t.jsx("span",{className:C("flex size-8 items-center justify-center rounded-full",u==="dark"?"text-white/70":"text-black/70"),"aria-hidden":!0,children:t.jsx(y.DownloadSimpleIcon,{className:"size-5",weight:"bold"})});return t.jsx(pe,{variant:u,text:o,groupPosition:d,"data-testid":"file-attachment",children:t.jsx("div",{className:"flex flex-col gap-2",children:c.map((p,x)=>{const b=g&&x===0?t.jsx(be,{onClick:f,variant:"inline"}):j;return t.jsx(On,{variant:u,item:p,index:x,onActivate:v,trailingAction:b},`${p.src}-${x}`)})})})},Fn=e=>t.jsx(st,{...e,state:"composer"}),zn=e=>t.jsx(st,{...e,state:"sent"}),Bn=e=>t.jsx(st,{...e,state:"received"}),$n={Composer:Fn,Sent:zn,Received:Bn},nt=({onPrev:e,onNext:s,prevLabel:n="Previous",nextLabel:a="Next"})=>t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:e,"aria-label":n,className:"mes-media-viewer__nav mes-media-viewer__nav--prev",children:t.jsx(y.CaretLeftIcon,{size:20,weight:"bold","aria-hidden":!0})}),t.jsx("button",{type:"button",onClick:s,"aria-label":a,className:"mes-media-viewer__nav mes-media-viewer__nav--next",children:t.jsx(y.CaretRightIcon,{size:20,weight:"bold","aria-hidden":!0})})]}),us=({url:e,filename:s,variant:n="pill",label:a="Download",iconOnly:r,tone:i="dark",onTriggered:l})=>{const[o,d]=h.useState(!1),m=h.useCallback(c=>{c.stopPropagation(),!o&&(d(!0),ds(e,s).catch(()=>{}).finally(()=>{d(!1),l==null||l()}))},[o,e,s,l]),f=r??n!=="pill",g={className:C(n==="pill"?"size-4":"size-5","shrink-0"),weight:"bold"};if(n==="inline"){const c={dark:"text-white/70 hover:bg-white/[0.08] hover:text-white",light:"text-black/70 hover:bg-black/[0.08] hover:text-black"};return t.jsx("button",{type:"button",onClick:m,disabled:o,"aria-label":a,className:C("flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70",c[i]),children:o?t.jsx(y.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):t.jsx(y.DownloadSimpleIcon,{className:"size-5 shrink-0",weight:"bold","aria-hidden":!0})})}return n==="viewer"?t.jsx("button",{type:"button",onClick:m,disabled:o,"aria-label":a,className:"mes-media-viewer__action",children:o?t.jsx(y.CircleNotchIcon,{size:20,weight:"bold","aria-hidden":!0}):t.jsx(y.DownloadSimpleIcon,{size:20,weight:"bold","aria-hidden":!0})}):t.jsxs("button",{type:"button",onClick:m,disabled:o,"aria-label":f?a:void 0,className:C("mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounded-full px-4 text-sm font-medium leading-none transition-colors disabled:opacity-70",i==="dark"?"bg-[#121110] text-white hover:bg-[#2a2928]":"bg-white text-[#121110] hover:bg-white/90"),children:[o?t.jsx(y.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):t.jsx(y.DownloadSimpleIcon,{...g,"aria-hidden":!0}),f?null:a]})},Oe=(e,s,n)=>Math.min(Math.max(e,s),n),at=({length:e,initialIndex:s,open:n})=>{const a=Oe(s,0,Math.max(e-1,0)),[r,i]=h.useState(a);h.useEffect(()=>{n&&i(Oe(s,0,Math.max(e-1,0)))},[n,s,e]),h.useEffect(()=>{i(d=>Oe(d,0,Math.max(e-1,0)))},[e]);const l=h.useCallback(()=>{e<=1||i(d=>d<=0?e-1:d-1)},[e]),o=h.useCallback(()=>{e<=1||i(d=>d>=e-1?0:d+1)},[e]);return h.useEffect(()=>{if(!n||e<=1)return;const d=m=>{if(m.key!=="ArrowLeft"&&m.key!=="ArrowRight")return;const f=document.activeElement;f&&(f.tagName==="VIDEO"||f.tagName==="AUDIO")||(m.preventDefault(),m.key==="ArrowLeft"?l():o())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n,e,l,o]),{index:r,prev:l,next:o}},rt=({open:e,onClose:s,ariaLabel:n,counter:a,actions:r,children:i,"data-testid":l})=>{const o=h.useRef(null),d=h.useRef(null);h.useEffect(()=>{var g;const u=o.current;if(u){if(e){if(!u.open)if(typeof u.showModal=="function")try{u.showModal()}catch{u.setAttribute("open","")}else u.setAttribute("open","");const c=typeof document<"u"?document.activeElement:null;return(g=d.current)==null||g.focus(),()=>{if(u.open)if(typeof u.close=="function")try{u.close()}catch{u.removeAttribute("open")}else u.removeAttribute("open");c&&document.body.contains(c)&&c.focus()}}if(u.open)if(typeof u.close=="function")try{u.close()}catch{u.removeAttribute("open")}else u.removeAttribute("open")}},[e]);const m=()=>{s()},f=u=>{u.target===o.current&&s()};return t.jsxs("dialog",{ref:o,className:"mes-media-viewer","aria-label":n??"Attachment viewer","data-testid":l,onClose:m,onClick:f,children:[t.jsxs("div",{className:"mes-media-viewer__chrome",children:[a?t.jsx("span",{className:"mes-media-viewer__counter",children:a}):null,t.jsxs("div",{className:"mes-media-viewer__actions",children:[r,t.jsx("button",{ref:d,type:"button",onClick:s,"aria-label":"Close viewer",className:"mes-media-viewer__action",children:t.jsx(y.XIcon,{size:20,weight:"bold","aria-hidden":!0})})]})]}),t.jsx("div",{className:"mes-media-viewer__body",children:i})]})},ms=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=at({length:s.length,initialIndex:n,open:e}),o=s[r],d=h.useMemo(()=>(o==null?void 0:o.filename)??(o?Q(o.src):"image"),[o]);return o?t.jsxs(rt,{open:e,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,actions:t.jsx(us,{url:o.src,filename:d,variant:"viewer",label:`Download ${d}`}),"data-testid":"image-viewer",children:[e?t.jsx("img",{src:o.src,alt:o.alt??d,draggable:!1,loading:"eager",decoding:"async",className:"mes-media-viewer__image"},`${r}:${o.src}`):null,s.length>1?t.jsx(nt,{onPrev:i,onNext:l,prevLabel:"Previous image",nextLabel:"Next image"}):null]}):null},Un="relative block size-full overflow-hidden bg-black/5 outline-none after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-white/80 focus-visible:after:ring-offset-2 focus-visible:after:ring-offset-black",Vn={1:["rounded-[18px]"],2:["rounded-l-[18px]","rounded-r-[18px]"],3:["rounded-l-[18px]","rounded-tr-[18px]","rounded-br-[18px]"],4:["rounded-tl-[18px]","rounded-tr-[18px]","rounded-bl-[18px]","rounded-br-[18px]"]},Hn="--mes-single-width-cap",Gn="[--mes-single-width-cap:309px] sm:[--mes-single-width-cap:326px]",Yn=436,hs=({tiles:e,onTileActivate:s,maxVisible:n=4,singleAspectRatio:a,className:r})=>{const i=e.length;if(i===0)return null;const l=e.slice(0,Math.min(i,n)),o=i-l.length,d=(f,u,g)=>{var v;const c=C(Un,"h-full w-full",(v=Vn[l.length])==null?void 0:v[u]);return s?t.jsxs("button",{type:"button",onClick:()=>s(u),"aria-label":f.ariaLabel??`Open media ${u+1}`,className:C(c,"cursor-zoom-in"),children:[f.content,g]},u):t.jsxs("div",{className:c,children:[f.content,g]},u)};let m;return a&&(m={aspectRatio:a,width:`min(var(${Hn}), ${Math.round(Yn*a*100)/100}px)`,maxWidth:"100%"}),l.length===1?t.jsx("div",{className:C(a?Gn:"aspect-square w-full",r),style:m,children:d(l[0],0)}):l.length===2?t.jsx("div",{className:C("grid aspect-[16/9] w-full grid-cols-2 gap-0.5",r),children:l.map((f,u)=>d(f,u))}):l.length===3?t.jsxs("div",{className:C("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",r),children:[t.jsx("div",{className:"row-span-2",children:d(l[0],0)}),d(l[1],1),d(l[2],2)]}):t.jsx("div",{className:C("grid aspect-[379/286] w-full grid-cols-2 grid-rows-2 gap-0.5",r),children:l.map((f,u)=>{const g=o>0&&u===l.length-1;return d(f,u,g?t.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-black/55 text-2xl font-semibold text-white",children:["+",o]}):null)})})},je=e=>{const[s,n]=h.useState(!1),[a,r]=h.useState(0),i=h.useCallback(o=>{(e==null?void 0:e(o))!==!1&&(r(o),n(!0))},[e]),l=h.useCallback(()=>n(!1),[]);return{viewerOpen:s,viewerIndex:a,handleActivate:i,closeViewer:l}},qn=({item:e,index:s,totalCount:n,fallbackLoading:a,imgRef:r,onLoad:i})=>({ariaLabel:`Open image ${s+1} of ${n}`,content:t.jsx("img",{ref:r,src:re(e.src)??e.src,alt:e.alt??"",width:e.width,height:e.height,draggable:!1,loading:e.loading??a,decoding:"async",onLoad:i,className:"absolute inset-0 size-full object-cover"})}),Wn=({src:e,alt:s,items:n})=>n&&n.length>0?n:e?[{src:e,alt:s}]:[],fs=(e,s)=>e.map((n,a)=>({src:n.src,alt:n.alt,filename:s&&e.length===1?s:s?`${s} (${a+1})`:void 0})),Xn=({src:e,alt:s,filename:n,loading:a="lazy",onClick:r,onDismiss:i})=>{const{viewerOpen:l,viewerIndex:o,handleActivate:d,closeViewer:m}=je(r);return t.jsxs("div",{className:"relative w-fit",children:[t.jsx("button",{type:"button",onClick:()=>d(0),"aria-label":"Open image",className:"block size-[280px] cursor-zoom-in overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",children:t.jsx("img",{src:re(e)??e,alt:s??"",draggable:!1,loading:a,decoding:"async",className:"size-full object-cover"})}),i?t.jsx("div",{className:"absolute right-2 top-2 z-10",children:t.jsx(be,{onClick:i})}):null,t.jsx(ms,{open:l,items:fs([{src:e,alt:s}],n),initialIndex:o,onClose:m})]})},Kn=326/246,Zn=e=>{const s=e==null?void 0:e.src,[n,a]=h.useState(),r=h.useCallback(d=>{if(!d||d.naturalWidth<=0||d.naturalHeight<=0||s===void 0)return;const m=d.naturalWidth/d.naturalHeight;a(f=>f&&f.src===s&&f.ratio===m?f:{src:s,ratio:m})},[s]),i=h.useCallback(d=>r(d.currentTarget),[r]),l=e!=null&&e.width&&(e!=null&&e.height)?e.width/e.height:void 0,o=n&&n.src===s?n.ratio:void 0;return{ratio:l??o??Kn,imgRef:r,onLoad:i}},gs=({state:e,src:s,alt:n,filename:a,items:r,text:i,groupPosition:l,loading:o="lazy",onClick:d})=>{const m=Wn({src:s,alt:n,items:r}),f=ve(e),{viewerOpen:u,viewerIndex:g,handleActivate:c,closeViewer:v}=je(d),j=m.length===1,p=Zn(j?m[0]:void 0);if(m.length===0)return null;const x=m.map((b,_)=>qn({item:b,index:_,totalCount:m.length,fallbackLoading:o,imgRef:j?p.imgRef:void 0,onLoad:j?p.onLoad:void 0}));return t.jsxs(pe,{variant:f,text:i,groupPosition:l,bordered:!1,widthClassName:j?"w-fit max-w-[313px] sm:max-w-[330px]":"w-[383px] max-w-full",paddingClassName:"p-0.5",radiusClassName:"rounded-[20px]","data-testid":"image-attachment",children:[t.jsx("div",{className:"relative",children:t.jsx(hs,{tiles:x,onTileActivate:c,singleAspectRatio:j?p.ratio:void 0})}),t.jsx(ms,{open:u,items:fs(m,a),initialIndex:g,onClose:v})]})},Jn=e=>t.jsx(Xn,{...e}),Qn=e=>t.jsx(gs,{...e,state:"sent"}),ea=e=>t.jsx(gs,{...e,state:"received"}),ta={Composer:Jn,Sent:Qn,Received:ea},sa=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=at({length:s.length,initialIndex:n,open:e}),o=s[r],d=h.useMemo(()=>(o==null?void 0:o.filename)??(o?Q(o.src):"document"),[o]),m=h.useMemo(()=>o?na(o.src):void 0,[o]);return!o||!m?null:t.jsxs(rt,{open:e,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,"data-testid":"pdf-viewer",children:[t.jsx("iframe",{src:m,title:d,className:"mes-media-viewer__iframe",sandbox:"allow-scripts allow-forms allow-popups allow-downloads"},`${r}:${o.src}`),s.length>1?t.jsx(nt,{onPrev:i,onNext:l,prevLabel:"Previous document",nextLabel:"Next document"}):null]})},na=e=>{const s=e.indexOf("#"),n=s===-1?e:e.slice(0,s),a=s===-1?"":e.slice(s+1),r=new URLSearchParams(a);return r.has("toolbar")||r.set("toolbar","0"),r.has("navpanes")||r.set("navpanes","0"),`${n}#${r.toString()}`},aa=({src:e,filename:s,fileSize:n,title:a,items:r})=>r&&r.length>0?r:e?[{src:e,filename:s,fileSize:n,title:a}]:[],ra=({variant:e,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??Q(s.src);return t.jsx(cs,{variant:e,filename:i,title:s.title,mimeType:"application/pdf",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Open ${i}`,trailingAction:r})},it=({state:e,src:s,filename:n,fileSize:a,title:r,items:i,text:l,groupPosition:o,onClick:d,onDismiss:m})=>{const f=ve(e),u=aa({src:s,filename:n,fileSize:a,title:r,items:i}),{viewerOpen:g,viewerIndex:c,handleActivate:v,closeViewer:j}=je(d),p=e==="composer"&&!!m;if(u.length===0)return null;const x=u.map(b=>({src:b.src,filename:b.filename??Q(b.src)}));return t.jsxs(pe,{variant:f,text:l,groupPosition:o,"data-testid":"pdf-attachment",children:[t.jsx("div",{className:"flex flex-col gap-2",children:u.map((b,_)=>{const S=b.filename??Q(b.src),T=p&&_===0?t.jsx(be,{onClick:m,variant:"inline"}):e==="composer"?void 0:t.jsx(us,{url:b.src,filename:S,variant:"inline",label:`Download ${S}`,tone:f});return t.jsx(ra,{variant:f,item:b,index:_,onActivate:v,trailingAction:T},`${b.src}-${_}`)})}),t.jsx(sa,{open:g,items:x,initialIndex:c,onClose:j})]})},ia=e=>t.jsx(it,{...e,state:"composer"}),oa=e=>t.jsx(it,{...e,state:"sent"}),la=e=>t.jsx(it,{...e,state:"received"}),ca={Composer:ia,Sent:oa,Received:la},xs=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=at({length:s.length,initialIndex:n,open:e}),o=s[r],d=h.useMemo(()=>(o==null?void 0:o.filename)??(o?Q(o.src):"video"),[o]);return o?t.jsxs(rt,{open:e,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,"data-testid":"video-viewer",children:[t.jsx("video",{src:o.src,poster:o.poster,controls:!0,autoPlay:!0,muted:!0,playsInline:!0,preload:o.preload??"metadata",className:"mes-media-viewer__video",children:o.mimeType?t.jsx("source",{src:o.src,type:o.mimeType}):null},`${r}:${o.src}`),s.length>1?t.jsx(nt,{onPrev:i,onNext:l,prevLabel:"Previous video",nextLabel:"Next video"}):null]}):null},da=()=>t.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:t.jsx("span",{className:"flex size-12 items-center justify-center rounded-full bg-black/55 text-white backdrop-blur",children:t.jsx(y.PlayIcon,{className:"size-6",weight:"fill","aria-hidden":!0})})}),ps=({item:e,index:s})=>t.jsxs("div",{className:"absolute inset-0 size-full bg-[#0d0d0d]",children:[e.poster?t.jsx("img",{src:e.poster,alt:`Video ${s+1} thumbnail`,draggable:!1,loading:"lazy",decoding:"async",className:"absolute inset-0 size-full object-cover"}):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx(y.VideoCameraIcon,{className:"size-16 text-white/30",weight:"regular","aria-hidden":!0})}),t.jsx(da,{})]}),ua=(e,s,n)=>({ariaLabel:`Play video ${s+1} of ${n}`,content:t.jsx(ps,{item:e,index:s})}),ma=({src:e,poster:s,mimeType:n,preload:a,items:r})=>r&&r.length>0?a?r.map(i=>({...i,preload:i.preload??a})):r:e?[{src:e,poster:s,mimeType:n,preload:a}]:[],bs=(e,s)=>e.map((n,a)=>({src:n.src,poster:n.poster,mimeType:n.mimeType,preload:n.preload,filename:s&&e.length===1?s:s?`${s} (${a+1})`:void 0})),ha=({src:e,poster:s,mimeType:n,filename:a,preload:r,onClick:i,onDismiss:l})=>{const{viewerOpen:o,viewerIndex:d,handleActivate:m,closeViewer:f}=je(i);return t.jsxs("div",{className:"relative w-fit",children:[t.jsx("button",{type:"button",onClick:()=>m(0),"aria-label":"Play video",className:"relative block size-[280px] cursor-pointer overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",children:t.jsx(ps,{item:{src:e,poster:s,mimeType:n},index:0})}),l?t.jsx("div",{className:"absolute right-2 top-2 z-10",children:t.jsx(be,{onClick:l})}):null,t.jsx(xs,{open:o,items:bs([{src:e,poster:s,mimeType:n,preload:r}],a),initialIndex:d,onClose:f})]})},vs=({state:e,src:s,poster:n,mimeType:a,filename:r,items:i,text:l,groupPosition:o,preload:d,onClick:m})=>{const f=ma({src:s,poster:n,mimeType:a,preload:d,items:i}),u=ve(e),{viewerOpen:g,viewerIndex:c,handleActivate:v,closeViewer:j}=je(m);if(f.length===0)return null;const p=f.map((x,b)=>ua(x,b,f.length));return t.jsxs(pe,{variant:u,text:l,groupPosition:o,"data-testid":"video-attachment",children:[t.jsx("div",{className:"relative",children:t.jsx(hs,{tiles:p,onTileActivate:v})}),t.jsx(xs,{open:g,items:bs(f,r),initialIndex:c,onClose:j})]})},fa=e=>t.jsx(ha,{...e}),ga=e=>t.jsx(vs,{...e,state:"sent"}),xa=e=>t.jsx(vs,{...e,state:"received"}),pa={Composer:fa,Sent:ga,Received:xa},fe={Image:ta,Video:pa,Audio:Mn,Pdf:ca,File:$n},ba={isUnlocking:()=>!1},va={LockedAttachment:ba},js=h.createContext({}),ja=js.Provider;function _s(e){return h.useContext(js)[e]??va[e]}const _a=h.lazy(()=>Promise.resolve().then(()=>require("./Card-415OfRhw.cjs"))),wa=h.lazy(()=>Promise.resolve().then(()=>require("./Card-BiZLzRIQ.cjs"))),Na=()=>t.jsx("div",{className:"w-[280px] min-h-[200px] animate-pulse rounded-md bg-black/[0.06] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_1px_2px_rgba(0,0,0,0.04),0_8px_32px_rgba(0,0,0,0.1)]","aria-hidden":!0}),ge=e=>t.jsx(h.Suspense,{fallback:t.jsx(Na,{}),children:e.contentType==="text"?t.jsx(_a,{...e}):t.jsx(wa,{...e})}),ya=({size:e=15})=>t.jsx("svg",{width:e,height:e,viewBox:"0 0 15 15",fill:"none","aria-hidden":"true",children:t.jsx("path",{d:"M12.003 9a.985.985 0 0 1-.652.934l-3.223 1.191-1.188 3.226a.995.995 0 0 1-1.867 0l-1.195-3.226L.65 9.937a.995.995 0 0 1 0-1.867l3.227-1.195 1.187-3.226a.995.995 0 0 1 1.868 0l1.195 3.226 3.226 1.187a.99.99 0 0 1 .649.938m3-5.83a.52.52 0 0 1-.344.492l-1.702.63-.627 1.703a.525.525 0 0 1-.986 0l-.63-1.704-1.704-.627a.525.525 0 0 1 0-.986l1.703-.63.627-1.704a.526.526 0 0 1 .986 0l.631 1.703 1.704.627a.52.52 0 0 1 .342.495",fill:"currentColor",fillOpacity:.55})}),Ca=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)===W.MESSAGE_CUSTOM_TYPE.TIP},ws=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)===W.MESSAGE_CUSTOM_TYPE.PAID},Se=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)===W.MESSAGE_CUSTOM_TYPE.CHATBOT},ot=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)===W.MESSAGE_CUSTOM_TYPE.ATTACHMENT},Sa=e=>{var s;return ot(e)&&((s=e.metadata)==null?void 0:s.attachment_content_type)==="text"},ka=e=>{var s;return ot(e)&&((s=e.metadata)==null?void 0:s.attachment_content_type)!=="text"},Ns=e=>Ca(e)||ws(e),Ea=e=>{var s;return Ns(e)&&!((s=e.text)!=null&&s.trim())},Fe=({message:e,standalone:s=!1,isMyMessage:n=!1,hasAttachment:a=!1})=>{var u;const r=Ns(e),i=Se(e);if(!r&&!i)return null;if(r){const g=(u=e.metadata)==null?void 0:u.amount_text;if(!g)return null;const c=s?"message-tip-standalone":"message-tag message-tag--tip",v=ws(e)?"message":"tip",j=s?`${g} ${v}`:`Delivered with ${g} ${v}`;return t.jsxs("div",{className:c,children:[t.jsx(y.GiftIcon,{size:s?14:12}),t.jsx("span",{children:j})]})}const l=n&&a,o=l?"Sent with AI":"Sent by AI Assistant",d=["message-chatbot-indicator",n?"message-chatbot-indicator--sender":"message-chatbot-indicator--receiver",l?"message-chatbot-indicator--attachment":"message-chatbot-indicator--text"].join(" "),m=t.jsx("span",{className:"message-chatbot-indicator__label",children:o}),f=t.jsx("span",{className:"message-chatbot-indicator__icon",children:t.jsx(ya,{size:l?12:15})});return t.jsx("div",{className:d,"data-testid":"message-chatbot-indicator",children:n&&!l?t.jsxs(t.Fragment,{children:[m,f]}):t.jsxs(t.Fragment,{children:[f,m]})})},ys=({selected:e,onVoteUp:s,onVoteDown:n})=>t.jsxs("div",{className:"message-vote-buttons",children:[t.jsx("button",{type:"button",className:C("message-vote-button focus-ring",{"message-vote-button--selected":e==="up"}),onClick:s,"aria-label":"Good response","aria-pressed":e==="up","data-tooltip":"Good response",children:t.jsx(y.ThumbsUpIcon,{size:16,weight:e==="up"?"fill":"regular"})}),t.jsx("button",{type:"button",className:C("message-vote-button focus-ring",{"message-vote-button--selected":e==="down"}),onClick:n,"aria-label":"Bad response","aria-pressed":e==="down","data-tooltip":"Bad response",children:t.jsx(y.ThumbsDownIcon,{size:16,weight:e==="down"?"fill":"regular"})})]}),lt=()=>{const{message:e}=w.useMessageContext("SentMessageDeliveryStatus"),{messages:s}=w.useChannelStateContext("SentMessageDeliveryStatus"),n=(()=>{if(s)for(let a=s.length-1;a>=0;a-=1){const r=s[a];if(!(r.type==="system"||r.type==="ephemeral"||r.type==="deleted"))return r.id}})();return e.id===n},ze=()=>lt()?t.jsxs(t.Fragment,{children:[t.jsx(y.ChecksIcon,{weight:"bold","aria-hidden":"true"}),t.jsx("span",{"data-testid":"sent-message-delivery-status",children:"Delivered"})]}):null,Ia=()=>lt()?t.jsxs(t.Fragment,{children:[t.jsx(y.CircleNotchIcon,{className:"sent-message-status__spinner animate-spin",weight:"bold","aria-hidden":"true"}),t.jsx("span",{"data-testid":"sent-message-sending-status",children:"Sending"})]}):null,Ta=({broadcastId:e,broadcastName:s,onBroadcastClick:n})=>{const a=s||"Broadcast",r=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"sent-message-broadcast-badge","aria-hidden":"true",children:t.jsx(y.MegaphoneIcon,{weight:"fill"})}),t.jsx("span",{className:"sent-message-broadcast-name","data-testid":"sent-message-broadcast-status",children:a})]});return n?t.jsx("button",{type:"button",className:"sent-message-broadcast-link","aria-label":`View broadcast ${a}`,onClick:()=>n({id:e,...s?{name:s}:{}}),children:r}):r},Ma=()=>t.jsxs("span",{className:"str-chat__message-status sent-message-status--failed",children:[t.jsx(y.WarningCircleIcon,{weight:"bold","aria-hidden":"true"}),t.jsx("span",{"data-testid":"sent-message-failed-status",children:"Failed to send"})]}),Aa=({onBroadcastClick:e})=>{var f,u;const{isMyMessage:s,message:n,threadList:a}=w.useMessageContext("SentMessageDeliveryStatus"),r=s(),i=lt();if(a)return null;if(n.status==="failed"&&r&&n.type!=="error")return t.jsx(Ma,{});if(!r)return null;const l=(f=n.metadata)==null?void 0:f.broadcast_id,o=(u=n.metadata)==null?void 0:u.broadcast_name,d=n.status!=="sending"&&n.status!=="failed"&&l?t.jsx(Ta,{broadcastId:l,broadcastName:o,onBroadcastClick:e}):null,m=t.jsx(w.MessageStatus,{MessageSentStatus:ze,MessageDeliveredStatus:ze,MessageReadStatus:ze,MessageSendingStatus:Ia});return d?t.jsxs("span",{className:"sent-message-status-row",children:[m,i&&t.jsx("span",{className:"sent-message-broadcast-separator","aria-hidden":"true",children:"•"}),d]}):m},La=/^([a-z][a-z0-9+.-]*):/i,Ra=new Set(["http","https","mailto","tel","sms"]);function ct(e){if(typeof e!="string")return;const s=e.trim();if(s==="")return;const n=La.exec(s);if(n){const a=n[1].toLowerCase();return Ra.has(a)?s:void 0}return s.startsWith("//")||s.startsWith("/")?s:`https://${s}`}const Da={dark:"bg-white text-[#121110] hover:bg-white/90",light:"bg-[#121110] text-white hover:bg-[#2a2928]"},Pa=({variant:e,cta:s})=>{const n=C("mt-2 inline-flex h-10 w-full items-center justify-center rounded-full px-4 text-sm font-medium leading-none transition-colors",Da[e]),a=ct(s.href);return a?t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:r=>{var i;r.stopPropagation(),(i=s.onClick)==null||i.call(s)},className:`${n} no-underline`,children:s.label}):t.jsx("button",{type:"button",onClick:r=>{var i;r.stopPropagation(),(i=s.onClick)==null||i.call(s)},className:n,children:s.label})},Oa={dark:"text-white",light:"text-black/90"},Fa="text-white/30",za={dark:"text-white/55",light:"text-black/55"},Ba={dark:"bg-white/25",light:"bg-black/15"},dt=({variant:e,title:s,placeholderTitle:n,description:a,url:r,appIcon:i,cta:l,trailingAction:o,chinTextColor:d,isLoading:m=!1})=>{const f=e==="dark",u=s??(f?n:void 0)??"",g=u.trim()!=="",c=a!=null&&a.trim()!=="",v=typeof r=="string"?r.trim():"",j=v!=="",p=l!=null;if(!m&&!g&&!c&&!j&&!p)return null;const x=f&&!s,b=C("line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.28px]",d==null&&(x?Fa:Oa[e])),_=C("truncate text-[12px] leading-4 tracking-[0.24px]",d==null&&za[e]),S=d?{color:d}:void 0;if(m){const T=C("animate-pulse rounded",Ba[e]);return t.jsx("div",{className:"shrink-0 px-4 py-3",children:t.jsxs("div",{className:"flex min-w-0 flex-col gap-[2px]",children:[t.jsx("div",{className:C("h-5 w-3/4",T),"aria-hidden":!0}),t.jsx("div",{className:C("h-4 w-1/2",T),"aria-hidden":!0})]})})}return t.jsxs("div",{className:"shrink-0 px-4 py-3",children:[t.jsxs("div",{className:"flex items-end gap-3",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-[2px]",children:[g&&t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[i?t.jsx("span",{className:"shrink-0",children:i}):null,t.jsx("p",{className:C("min-w-0",b),style:S,children:u})]}),c&&t.jsx("p",{className:_,style:S,children:a}),!p&&j&&t.jsx("p",{className:_,style:S,children:v})]}),o&&t.jsx("div",{className:"shrink-0",children:o})]}),l&&t.jsx(Pa,{variant:e,cta:l})]})},$a="Loading link preview",Ua=C("relative w-[290px] select-none overflow-hidden","rounded-[20px]"),Va="flex h-[250px] flex-col",ke=({variant:e,children:s,href:n,onClick:a,ariaLabel:r,rootRef:i,topRight:l,bgClassName:o,accentStyle:d,fixedHeight:m=!1,busy:f=!1,"data-testid":u})=>{const g=n!=null||a!=null,c=C(Ua,m?Va:"block",o??(e==="dark"?"bg-shade":"bg-white"),g?"cursor-pointer no-underline focus-ring":null),v=f?{role:"status","aria-busy":!0,"aria-label":$a}:void 0,j=l?t.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:l}):null;return n?t.jsxs("a",{ref:i,href:n,target:"_blank",rel:"noopener noreferrer",onClick:a,"data-testid":u,className:c,style:d,...v,children:[s,j]}):a?t.jsxs("button",{ref:i,type:"button",onClick:a,"aria-label":r,"data-testid":u,className:C(c,"text-left"),style:d,...v,children:[s,j]}):t.jsxs("div",{ref:i,"data-testid":u,className:c,style:d,...v,children:[s,j]})},Ot={dark:"bg-white/10",light:"bg-black/5"},Ha={dark:"size-16 text-white/25",light:"size-16 text-black/25"},_e=(e,s)=>!!s&&!!e&&ee(e)==="audio",ut=(e,s)=>{if(!s||!e)return!1;const n=ee(e);return n==="video"||n==="audio"},mt="bg-[#F2F3F4]",Ee=({variant:e,thumbnailUrl:s,sourceUrl:n,title:a,mimeType:r="image/*",topLeft:i,topRight:l,isLoading:o=!1,onImageError:d})=>{const m=ee(r),f=!!n&&m==="video",u=re(s);return!o&&_e(r,n)?t.jsx("div",{className:"p-3",children:t.jsx("audio",{src:n,controls:!0,preload:"metadata",className:"block w-full",children:t.jsx("track",{kind:"captions"})})}):t.jsxs("div",{className:C("relative min-h-0 w-full flex-1 overflow-hidden",f&&"bg-black"),children:[o?t.jsx("div",{className:C("h-full w-full animate-pulse",Ot[e]),"aria-hidden":!0}):f?t.jsxs(t.Fragment,{children:[t.jsx("video",{src:n,poster:u,controls:!0,playsInline:!0,preload:"metadata",className:"absolute inset-0 h-full w-full object-contain",children:t.jsx("track",{kind:"captions"})}),u&&d?t.jsx("img",{src:u,alt:"","aria-hidden":!0,onError:d,className:"hidden"}):null]}):s?t.jsx("img",{src:u??s,alt:a??"",draggable:!1,loading:"lazy",decoding:"async",onError:d,className:"absolute inset-0 h-full w-full object-cover"}):t.jsx("div",{className:C("flex h-full w-full items-center justify-center",Ot[e]),children:le(r,{className:Ha[e],weight:"regular"})}),i?t.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-10",children:i}):null,l?t.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:l}):null]})},ye="#FFFFFF",Ft="#040403",Ga="#1e2330",Ya=3,qa=/^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;function Wa(e){if(typeof e!="string"||!qa.test(e.trim()))return;const s=e.trim().replace(/^#/,""),n=s.length===Ya?s.replace(/./g,a=>a+a):s;return[Number.parseInt(n.slice(0,2),16),Number.parseInt(n.slice(2,4),16),Number.parseInt(n.slice(4,6),16)]}function Be(e){const s=e/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4}function Ge(e){const s=Wa(e);return s?.2126*Be(s[0])+.7152*Be(s[1])+.0722*Be(s[2]):Number.NaN}function zt(e,s){const n=Ge(e),a=Ge(s);if(Number.isNaN(n)||Number.isNaN(a))return Number.NaN;const r=Math.max(n,a),i=Math.min(n,a);return(r+.05)/(i+.05)}function Xa(e){if(e==null)return ye;const s=zt(e,ye);return Number.isNaN(s)||s>=zt(e,Ft)?ye:Ft}function Ka(e){if(e==null||Number.isNaN(Ge(e)))return;const s=e.trim();return s.startsWith("#")?s:`#${s}`}const Za={dark:Ga,light:"#ffffff"};function ht({variant:e,accentColor:s,status:n="ready",layout:a="featured",thumbnailUrl:r,mimeType:i,sourceUrl:l}){const[o,d]=h.useState(!1);h.useEffect(()=>{d(!1)},[r]);const m=h.useCallback(()=>{d(!0)},[]),u=a==="featured"&&!!r&&!_e(i,l)&&!o&&n==="ready"?Ka(s):void 0;return{thumbnailUrl:o?void 0:r,accentStyle:u?{backgroundColor:u}:void 0,chinTextColor:u?Xa(u):void 0,tailColor:u??Za[e],isLoading:n==="loading",onImageError:m}}const Ja="flex size-6 items-center justify-center rounded-full bg-[#121110] text-white focus-ring",Qa="relative before:absolute before:-inset-[10px] before:content-['']",er=({title:e,placeholderTitle:s,description:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:l,layout:o="featured",appIcon:d,cta:m,accentColor:f,status:u="ready",onDismiss:g,onEditClick:c,dismissLabel:v="Dismiss attachment"})=>{const j=o==="classic",p=_e(r,l),x=ht({variant:"dark",accentColor:f,status:u,layout:o,thumbnailUrl:i,mimeType:r,sourceUrl:l}),b=g?t.jsx("button",{type:"button",onClick:g,"aria-label":v,className:C(Ja,!p&&Qa),children:t.jsx(y.XIcon,{className:"size-3",weight:"bold"})}):void 0,_=c?t.jsx("button",{type:"button",onClick:c,"aria-label":"Edit attachment",className:"flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",children:t.jsx(y.PencilSimpleIcon,{className:"size-5",weight:"regular"})}):void 0;return p&&!x.isLoading?t.jsx(ke,{variant:"dark",bgClassName:mt,children:t.jsxs("div",{className:"flex items-center gap-2 pr-3",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(Ee,{variant:"dark",sourceUrl:l,title:e,mimeType:r})}),b&&t.jsx("div",{className:"shrink-0",children:b})]})}):t.jsxs(ke,{variant:"dark",fixedHeight:!j,accentStyle:x.accentStyle,busy:x.isLoading,topRight:j?b:void 0,children:[!j&&t.jsx(Ee,{variant:"dark",thumbnailUrl:x.thumbnailUrl,sourceUrl:l,title:e,mimeType:r,topRight:b,isLoading:x.isLoading,onImageError:x.onImageError}),t.jsx(dt,{variant:"dark",title:e,placeholderTitle:s,description:n,url:a,appIcon:d,cta:m,trailingAction:_,chinTextColor:x.chinTextColor,isLoading:x.isLoading})]})},Cs=({color:e,side:s,visible:n,children:a})=>n?t.jsxs("div",{className:"relative isolate w-fit",children:[a,t.jsx("span",{"aria-hidden":!0,"data-testid":"link-card-tail",style:{backgroundColor:e},className:C("messaging-link-card-tail",s==="receiver"&&"messaging-link-card-tail--received")})]}):t.jsx(t.Fragment,{children:a}),tr=({title:e,description:s,url:n,mimeType:a,thumbnailUrl:r,sourceUrl:i,layout:l="featured",appIcon:o,cta:d,accentColor:m,status:f="ready",onClick:u,groupPosition:g="single"})=>{const c=ut(a,i),v=ct(n),j=d==null&&v!=null&&!c?v:void 0,p=d==null&&!c?u:void 0,x=f!=="loading"&&_e(a,i)?mt:void 0,b=d&&u?{...d,onClick:()=>{var S;u(),(S=d.onClick)==null||S.call(d)}}:d,_=ht({variant:"light",accentColor:m,status:f,layout:l,thumbnailUrl:r,mimeType:a,sourceUrl:i});return t.jsx(Cs,{color:_.tailColor,side:"receiver",visible:x==null&&(g==="single"||g==="end"),children:t.jsxs(ke,{variant:"light",href:j,onClick:p,ariaLabel:e??"Open attachment preview",fixedHeight:l==="featured"&&x==null,accentStyle:_.accentStyle,busy:_.isLoading,bgClassName:x,"data-testid":"link-attachment",children:[l==="featured"&&t.jsx(Ee,{variant:"light",thumbnailUrl:_.thumbnailUrl,sourceUrl:i,title:e,mimeType:a,isLoading:_.isLoading,onImageError:_.onImageError}),t.jsx(dt,{variant:"light",title:e,description:s,url:n,appIcon:o,cta:b,chinTextColor:_.chinTextColor,isLoading:_.isLoading})]})})},sr=({title:e,placeholderTitle:s,description:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:l,layout:o="featured",appIcon:d,cta:m,accentColor:f,status:u="ready",onClick:g,groupPosition:c="single"})=>{const v=ut(r,l),j=ct(a),p=m==null&&j!=null&&!v?j:void 0,x=m==null&&!v&&p!=null?g:void 0,b=u!=="loading"&&_e(r,l),_=ht({variant:"dark",accentColor:f,status:u,layout:o,thumbnailUrl:i,mimeType:r,sourceUrl:l});return t.jsx(Cs,{color:_.tailColor,side:"sender",visible:!b&&(c==="single"||c==="end"),children:t.jsxs(ke,{variant:"dark",href:p,onClick:x,fixedHeight:o==="featured"&&!b,accentStyle:_.accentStyle,busy:_.isLoading,bgClassName:b?mt:void 0,children:[o==="featured"&&t.jsx(Ee,{variant:"dark",thumbnailUrl:_.thumbnailUrl,sourceUrl:l,title:e,mimeType:r,isLoading:_.isLoading,onImageError:_.onImageError}),t.jsx(dt,{variant:"dark",title:e,placeholderTitle:s,description:n,url:a,appIcon:d,cta:m,chinTextColor:_.chinTextColor,isLoading:_.isLoading})]})})},Ie={Composer:er,Sent:sr,Received:tr};function O(e){const s=e==null?void 0:e.trim();return s||void 0}function Bt(e){return e.trim().replace(/^https?:\/\//i,"").replace(/\/+$/,"").toLowerCase()}function nr(e,s){if(!(e!=null&&e.trim())||!(s!=null&&s.trim()))return!1;const n=Bt(e),a=Bt(s);if(n===a)return!0;if(!n.includes(a))return!1;const r=n.split(a).join("");return!/[^\p{P}\p{Z}\p{C}]/u.test(r)}function $t(e){const s=O(e.og_scrape_url)??O(e.title_link),n=O(e.image_url)??O(e.thumb_url),a=O(e.asset_url),r=O(e.mime_type);return{title:O(e.title),description:O(e.text),url:s,thumbnailUrl:re(n),sourceUrl:a,layout:n||ut(r,a)?"featured":"classic",mimeType:r,accentColor:O(e.accent_color),status:"ready"}}function ar(e){var s;return Ss(e)?null:e.type==="image"?e.image_url||e.asset_url?"image":null:e.type==="video"&&e.asset_url?"video":e.type==="audio"&&e.asset_url?"audio":e.type==="file"&&e.asset_url?e.mime_type==="application/pdf"?"pdf":(s=e.mime_type)!=null&&s.startsWith("audio/")?"audio":"file":null}function Ss(e){const s=O(e.og_scrape_url);return e.type==="link"||!!s&&!e.asset_url}function ks(e){if(!(e!=null&&e.length))return[];const s=[],n=(r,i)=>{const l=s[s.length-1];if((l==null?void 0:l.type)==="media"&&l.kind===r){l.attachments.push(i);return}s.push({type:"media",kind:r,attachments:[i]})},a=r=>{const i=s[s.length-1];if((i==null?void 0:i.type)==="link"){i.attachments.push(r);return}s.push({type:"link",attachments:[r]})};for(const r of e){if(Ss(r)){a(r);continue}const i=ar(r);i&&n(i,r)}return s}function rr(e){return e.filter(s=>s.type==="media").length}function ir(e,s,n){return s<=1?n:e===0?"first":e===s-1?"end":"middle"}function Ut(e){return O(e.image_url)??O(e.asset_url)??""}function or(e){switch(e){case"image":return fe.Image;case"video":return fe.Video;case"audio":return fe.Audio;case"pdf":return fe.Pdf;default:return fe.File}}function lr(e,s){if(s.length>1)switch(e){case"image":return{items:s.map(a=>({src:Ut(a),alt:O(a.title)}))};case"video":return{items:s.map(a=>({src:O(a.asset_url)??"",poster:O(a.thumb_url),mimeType:O(a.mime_type)}))};case"audio":return{items:s.map(a=>({src:O(a.asset_url)??"",mimeType:O(a.mime_type)??"audio/mpeg",filename:O(a.title)}))};case"pdf":return{items:s.map(a=>({src:O(a.asset_url)??"",filename:O(a.title),fileSize:a.file_size}))};case"file":return{items:s.map(a=>({src:O(a.asset_url)??"",filename:O(a.title),fileSize:a.file_size,mimeType:O(a.mime_type)??"application/octet-stream"}))}}const n=s[0];if(!n)return{};switch(e){case"image":return{src:Ut(n),alt:O(n.title)};case"video":return{src:O(n.asset_url)??"",poster:O(n.thumb_url),mimeType:O(n.mime_type)};case"audio":return{src:O(n.asset_url)??"",mimeType:O(n.mime_type)??"audio/mpeg",filename:O(n.title)};case"pdf":return{src:O(n.asset_url)??"",filename:O(n.title),fileSize:n.file_size};case"file":return{src:O(n.asset_url)??"",filename:O(n.title),fileSize:n.file_size,mimeType:O(n.mime_type)??"application/octet-stream"}}}function cr({groupPosition:e,isMyMessage:s,segment:n}){const a=or(n.kind),r={...lr(n.kind,n.attachments),groupPosition:e};return s?t.jsx(a.Sent,{...r}):t.jsx(a.Received,{...r})}const dr=({groupPosition:e,isMyMessage:s,message:n,renderText:a})=>{var j;const r=ks(n.attachments);if(r.length===0)return null;const i=rr(r),l=(j=n.text)==null?void 0:j.trim(),o=r.find(p=>p.type==="link"),d=(o==null?void 0:o.type)==="link"?$t(o.attachments[0]??{}).url:void 0,m=l&&nr(l,d)?void 0:l;let f=0;const u=[],g=m?"middle":e,c=(p,x,b)=>{const _=s?Ie.Sent:Ie.Received;u.push(t.jsx(_,{...$t(p),groupPosition:b?g:"middle"},x))},v=(p,x)=>{const b=ir(f,i,e);f+=1,u.push(t.jsx(cr,{groupPosition:b,isMyMessage:s,segment:p},x))};return r.forEach((p,x)=>{const b=x===r.length-1;if(p.type==="link"){p.attachments.forEach((_,S)=>{c(_,`link-${x}-${S}`,b&&S===p.attachments.length-1)});return}v(p,`media-${x}`)}),t.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[t.jsxs("div",{className:"str-chat__message-bubble","data-attachment-bubble":"true",style:{background:"transparent",borderRadius:0,overflow:"visible",padding:0},children:[u,!m&&t.jsx(w.MessageErrorIcon,{})]}),m?t.jsxs("div",{className:"str-chat__message-bubble",children:[t.jsx(w.MessageText,{message:n,renderText:a}),t.jsx(w.MessageErrorIcon,{})]}):null]})},ur=e=>{var _t,wt,Nt,yt,Ct,St,kt,Et,It,Tt;const{additionalMessageInputProps:s,chatbotVotingEnabled:n,editing:a,endOfGroup:r,firstOfGroup:i,groupedByUser:l,handleAction:o,handleOpenThread:d,handleRetry:m,highlighted:f,isMessageAIGenerated:u,isMyMessage:g,message:c,renderText:v,threadList:j,viewerLanguage:p,onBroadcastClick:x}=e,{client:b}=w.useChatContext("CustomMessage"),{channel:_}=w.useChannelStateContext("CustomMessage"),{isUnlocking:S,onUnlockClick:T,onFetchSource:F,onDownloadClick:P}=_s("LockedAttachment"),[z,B]=h.useState(!1),A=w.useMessageReminder(c.id),{selected:E,voteUp:R,voteDown:k}=Jt(c),{Attachment:M=w.Attachment,EditMessageModal:I=w.EditMessageModal,MessageActions:L,MessageBlocked:$=w.MessageBlocked,MessageBouncePrompt:H=w.MessageBouncePrompt,MessageDeleted:Z=w.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:te=w.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:Y=w.MessageRepliesCountButton,ReminderNotification:N=w.ReminderNotification,StreamedMessageText:D=w.StreamedMessageText,PinIndicator:V}=w.useComponentContext("CustomMessage"),G=w.messageHasAttachments(c),J=w.messageHasReactions(c),q=h.useMemo(()=>u==null?void 0:u(c),[u,c]),U=h.useMemo(()=>{const oe=c.attachments??[],me=c.shared_location?[c.shared_location,...oe]:oe;if(!Se(c))return me;const Mt=me.filter(At=>!("type"in At)||!et(At));return Mt.length===me.length?me:Mt},[c]),X=h.useMemo(()=>ks(U),[U]),se=h.useMemo(()=>{const oe=Ke({message:c,viewerLanguage:p});return oe===c.text?c:{...c,text:oe}},[c,p]),we=X.length>0,Ne=X.reduce((oe,me)=>oe+me.attachments.length,0)===((U==null?void 0:U.length)??0),ne=rs({endOfGroup:r,firstOfGroup:i,groupedByUser:l});if(w.isDateSeparatorMessage(c))return null;if(c.deleted_at||c.type==="deleted")return t.jsx(Z,{message:c});if(w.isMessageBlocked(c))return t.jsx($,{});const ie=!j&&!!c.reply_count,ae=!j&&c.show_in_channel&&c.parent_id,gt=c.status==="failed"&&((_t=c.error)==null?void 0:_t.status)!==403,xt=w.isMessageBounced(c);let de;gt?de=()=>m(c):xt&&(de=()=>B(!0));const K=g(),Ps=C("str-chat__message str-chat__message-simple",`str-chat__message--${c.type}`,`str-chat__message--${c.status}`,K?"str-chat__message--me str-chat__message-simple--me":"str-chat__message--other",c.text?"str-chat__message--has-text":"has-no-text",{"str-chat__message--has-attachment":G,"str-chat__message--highlighted":f,"str-chat__message--pinned pinned-message":c.pinned,"str-chat__message--with-reactions":J,"str-chat__message-send-can-be-retried":(c==null?void 0:c.status)==="failed"&&((wt=c==null?void 0:c.error)==null?void 0:wt.status)!==403,"str-chat__message-with-thread-link":ie||ae,"str-chat__virtual-message__wrapper--end":r,"str-chat__virtual-message__wrapper--first":i,"str-chat__virtual-message__wrapper--group":l}),Re=c.poll_id&&b.polls.fromState(c.poll_id),pt=Ea(c),ue=Se(c),Os=ot(c),De=!!(U!=null&&U.length&&!c.quoted_message),bt=ue&&K&&De,Fs=we&&Ne&&!c.quoted_message&&!Re&&!q&&!ue,vt={contentType:"text",amountText:(Nt=c.metadata)==null?void 0:Nt.amount_text,paymentStatus:(yt=c.metadata)==null?void 0:yt.payment_status,renderedText:c.text&&t.jsx(w.MessageText,{message:se,renderText:v})},jt={contentType:"media",title:(Ct=c.metadata)==null?void 0:Ct.attachment_title,mimeType:(St=c.metadata)==null?void 0:St.attachment_mime_type,thumbnailUrl:(kt=c.metadata)==null?void 0:kt.attachment_thumbnail,amountText:(Et=c.metadata)==null?void 0:Et.amount_text,detail:(It=c.metadata)==null?void 0:It.attachment_detail,paymentStatus:(Tt=c.metadata)==null?void 0:Tt.payment_status,onFetchSource:F?()=>F(c,_):void 0};return t.jsxs(t.Fragment,{children:[a&&t.jsx(I,{additionalMessageInputProps:s}),z&&t.jsx(w.MessageBounceModal,{MessageBouncePrompt:H,onClose:()=>B(!1),open:z}),t.jsxs("div",{className:Ps,"data-message-id":c.id,"data-dd-privacy":"mask",children:[V&&t.jsx(V,{}),!!A&&t.jsx(N,{reminder:A}),c.user&&t.jsx(ce,{className:"str-chat__avatar str-chat__message-sender-avatar",id:c.user.id,image:c.user.image,name:c.user.name||c.user.id,size:24,shape:"circle",dmAgentEnabled:ue}),t.jsx("div",{className:C("str-chat__message-inner",{"str-chat__simple-message--error-failed":gt||xt}),"data-testid":"message-inner",onClick:de,onKeyDown:de,role:de?"button":void 0,tabIndex:de?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:pt?t.jsx(Fe,{message:c,standalone:!0}):Sa(c)?t.jsx("div",{className:"str-chat__message-bubble-wrapper",children:t.jsxs("div",{className:"flex items-center gap-2",children:[K&&L&&t.jsx(L,{}),K?t.jsx(ge,{...vt,isMine:!0}):t.jsx(ge,{...vt,isMine:!1,isUnlocking:S(c.id),onUnlockClick:()=>T==null?void 0:T(c,_)}),!K&&L&&t.jsx(L,{})]})}):ka(c)?t.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[K&&L&&t.jsx(L,{}),K?t.jsx(ge,{...jt,isMine:!0,onPreviewClick:()=>T?T(c,_):void 0}):t.jsx(ge,{...jt,isMine:!1,isUnlocking:S(c.id),onUnlockClick:()=>T?T(c,_):void 0,onDownloadClick:()=>P?P(c,_):void 0}),!K&&L&&t.jsx(L,{})]}),c.text&&t.jsx("div",{className:"str-chat__message-bubble",children:t.jsx(w.MessageText,{message:se,renderText:v})})]}):Fs?t.jsx(dr,{groupPosition:ne,isMyMessage:K,message:{...se,attachments:U,i18n:void 0},renderText:v}):t.jsx("div",{className:"str-chat__message-bubble-wrapper",children:t.jsxs("div",{className:"str-chat__message-bubble",children:[ue&&!bt&&t.jsx(Fe,{message:c,hasAttachment:De,isMyMessage:K}),Re&&t.jsx(w.Poll,{poll:Re}),U!=null&&U.length&&!c.quoted_message?t.jsx(M,{actionHandler:o,attachments:U}):null,q?t.jsx(D,{message:se,renderText:v}):t.jsx(w.MessageText,{message:se,renderText:v}),t.jsx(w.MessageErrorIcon,{})]})})}),!Os&&!pt&&t.jsxs("div",{className:"str-chat__message-footer",children:[(!ue||bt)&&t.jsx(Fe,{message:c,hasAttachment:De,isMyMessage:K}),n&&ue&&t.jsx(ys,{selected:E,onVoteUp:R,onVoteDown:k})]}),t.jsx(Aa,{onBroadcastClick:x}),ie&&t.jsx(Y,{onClick:d,reply_count:c.reply_count}),ae&&t.jsx(te,{})]},c.id)]})},mr=h.memo(ur,(e,s)=>e.chatbotVotingEnabled!==s.chatbotVotingEnabled||e.viewerLanguage!==s.viewerLanguage||e.onBroadcastClick!==s.onBroadcastClick?!1:w.areMessageUIPropsEqual(e,s)),hr=e=>{const s=w.useMessageContext("CustomMessage");return t.jsx(mr,{...s,...e})},fr=()=>{var n;const{handleDelete:e,message:s}=w.useMessageContext("CustomMessageActions");return((n=s.metadata)==null?void 0:n.payment_status)==="paid"?null:t.jsx(Ye.DefaultDropdownActionButton,{onClick:e,"aria-label":"Delete",title:"Delete",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:t.jsx(y.TrashSimpleIcon,{size:16,weight:"light","aria-hidden":!0})})},gr=()=>{const{handleFlag:e}=w.useMessageContext("CustomMessageActions");return t.jsx(Ye.DefaultDropdownActionButton,{onClick:e,"aria-label":"Report",title:"Report",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:t.jsx(y.FlagIcon,{size:16,weight:"light","aria-hidden":!0})})},xr=()=>{var s;const{message:e}=w.useMessageContext("CustomMessageActions");return((s=e.metadata)==null?void 0:s.custom_type)!==W.MESSAGE_CUSTOM_TYPE.ATTACHMENT?null:t.jsx(Ye.MessageActions,{messageActionSet:[{Component:fr,placement:"quick",type:"delete"},{Component:gr,placement:"quick",type:"flag"}]})},pr=e=>({linkPreviews:Array.from(e.previews.values()).filter(s=>Ce.LinkPreviewsManager.previewIsLoaded(s)||Ce.LinkPreviewsManager.previewIsLoading(s))}),br=()=>{const{linkPreviewsManager:e}=w.useMessageComposer(),{linkPreviews:s}=w.useStateStore(e.state,pr),n=r=>{e.dismissPreview(r)};return s.length>0?t.jsx("div",{className:"messaging-link-preview-list flex min-h-0 flex-col items-stretch w-full gap-2 overflow-y-auto overscroll-contain",children:s.map(r=>{const i=Ce.LinkPreviewsManager.previewIsLoading(r);return t.jsx("div",{className:"w-full shrink-0",children:t.jsx(Ie.Composer,{title:r.title,url:r.og_scrape_url,thumbnailUrl:r.image_url,layout:i||r.image_url?"featured":"classic",status:i?"loading":"ready",onDismiss:()=>n(r.og_scrape_url)})},r.og_scrape_url)})}):null},Te=h.createContext(!1),vr=200,jr=()=>h.useContext(Te),_r=({sendMessage:e,disabled:s,...n})=>t.jsx("button",{...n,type:"button","aria-label":"Send",disabled:s,onPointerDown:a=>a.preventDefault(),onClick:e,children:t.jsx(y.ArrowUpIcon,{weight:"bold",className:"size-4"})}),Vt=()=>{const e=h.useContext(Te),{handleSubmit:s}=w.useMessageInputContext(),n=w.useMessageComposerHasSendableData(),a=e||!n,{SendButton:r=_r,AttachmentPreviewList:i=w.AttachmentPreviewList}=w.useComponentContext("CustomMessageInput");return t.jsxs("div",{className:"central-container flex min-h-0 flex-col min-w-0 w-full self-stretch bg-white rounded-[1.5rem] shadow-[0_4px_16px_0_rgba(0,0,0,0.08),0_1px_2px_0_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.04)] [&>:not(.messaging-composer-previews):not(.messaging-composer-row)]:p-2","data-dd-privacy":"mask",children:[t.jsxs("div",{className:"messaging-composer-previews empty:hidden flex min-h-0 flex-col gap-2 px-2 pt-2",children:[t.jsx(w.QuotedMessagePreview,{}),t.jsx(br,{}),t.jsx(i,{})]}),t.jsxs("div",{className:"messaging-composer-row flex shrink-0 items-start",children:[t.jsx(w.TextareaComposer,{"aria-disabled":e||void 0,containerClassName:"min-w-0 flex-1 leading-[0]",className:"w-full resize-none bg-transparent py-3.5 pl-4 pr-4 outline-none leading-5 placeholder:text-black/30 text-sm",autoFocus:!e,enterKeyHint:"send",maxRows:4,readOnly:e,tabIndex:e?-1:void 0}),t.jsx("div",{className:"mt-auto mb-2 mr-2 shrink-0",children:t.jsx(r,{sendMessage:s,"aria-label":"Send",className:"str-chat__send-button relative flex justify-center items-center rounded-full size-8 bg-[#121110] disabled:bg-[#F1F0EE] disabled:text-black/20 text-white focus-ring before:absolute before:-inset-2 before:content-['']","data-testid":"send-button",disabled:a,type:"button"})})]})]})},Ht=({renderActions:e,renderHeader:s,renderFooter:n,disabled:a=!1,disabledReason:r,composerInput:i})=>{var f;const{channel:l}=w.useChannelStateContext(),o=((f=l==null?void 0:l.data)==null?void 0:f.frozen)===!0,d=!!i,m=h.useRef(null);return h.useEffect(()=>{if(!d)return;const u=m.current,g=u==null?void 0:u.parentElement;if(!u||!g)return;let c=u.offsetHeight;const v=()=>{const p=u.offsetHeight,x=p>c;c=p;const b=Array.from(g.querySelectorAll(".str-chat__list")).find(S=>S.scrollHeight>S.clientHeight)??null,_=b?b.scrollHeight-b.scrollTop-b.clientHeight<vr:!1;g.style.setProperty("--messaging-composer-height",`${p}px`),x&&_&&b&&(b.scrollTop=b.scrollHeight)};if(v(),typeof ResizeObserver>"u")return;const j=new ResizeObserver(v);return j.observe(u),()=>{j.disconnect(),g.style.removeProperty("--messaging-composer-height")}},[d]),a?d?t.jsxs("div",{ref:m,className:"messaging-composer-chrome messaging-composer-chrome--floating",children:[t.jsxs("div",{className:"messaging-composer-backdrop","aria-hidden":"true",children:[t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-gradient"})]}),t.jsxs("div",{className:"relative z-10 flex flex-col",children:[s==null?void 0:s(),t.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:r?t.jsx("p",{className:"max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",children:r}):null}),n==null?void 0:n()]})]}):t.jsxs(t.Fragment,{children:[s==null?void 0:s(),t.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:r?t.jsx("p",{className:"max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",children:r}):null}),n==null?void 0:n()]}):d?t.jsxs("div",{ref:m,className:"messaging-composer-chrome messaging-composer-chrome--floating",children:[t.jsxs("div",{className:"messaging-composer-backdrop","aria-hidden":"true",children:[t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-blur"}),t.jsx("div",{className:"messaging-composer-backdrop-gradient"})]}),t.jsxs("div",{className:"relative z-10 flex min-h-0 flex-col",children:[s==null?void 0:s(),t.jsxs("div",{className:"flex min-h-0 flex-col gap-4 p-4",children:[t.jsxs("div",{inert:o?"":void 0,"aria-disabled":o||void 0,className:"message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40",children:[e&&t.jsx("div",{className:"flex h-12 shrink-0 items-center justify-center",children:e()}),t.jsx(Te.Provider,{value:o,children:t.jsx(w.MessageInput,{Input:i??Vt})})]}),n==null?void 0:n()]})]})]}):t.jsxs("div",{className:"flex min-h-0 flex-col gap-4 p-4",children:[s==null?void 0:s(),t.jsxs("div",{inert:o?"":void 0,"aria-disabled":o||void 0,className:"message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40",children:[e&&t.jsx("div",{className:"flex h-12 shrink-0 items-center justify-center",children:e()}),t.jsx(Te.Provider,{value:o,children:t.jsx(w.MessageInput,{Input:Vt})})]}),n==null?void 0:n()]})},wr={SYSTEM_DM_AGENT_PAUSED:"DM Agent has left the conversation",SYSTEM_DM_AGENT_RESUMED:"DM Agent has rejoined the conversation"},Nr=["SYSTEM_AGE_SAFETY_BLOCKED"],yr={SYSTEM_AGE_SAFETY_BLOCKED:"This user isn’t able to reply because they don’t meet our age safety guidelines."},$e="age safety guidelines.",Cr="https://linktr.ee/s/about/contact",Sr=e=>Nr.includes(e),kr=e=>{var s;return Sr((s=e.metadata)==null?void 0:s.custom_type)},Er=e=>{var a;const s=(a=e.metadata)==null?void 0:a.custom_type;if(W.isDmAgentSystemType(s))return{kind:"dm-agent",type:s};if(W.isAgeSafetySystemType(s))return{kind:"age-safety",type:s};const n=e.dm_agent_system_type;if(W.isDmAgentSystemType(n))return{kind:"dm-agent",type:n}},Ir=e=>{const s=e.indexOf($e);if(s===-1)return e;const n=s+$e.length;return t.jsxs(t.Fragment,{children:[e.slice(0,s),t.jsx("a",{href:Cr,target:"_blank",rel:"noopener noreferrer",className:"mes-age-safety-system-message__emphasis font-medium text-inherit underline",children:$e}),e.slice(n)]})},Tr=e=>{var a,r;const s=!kr(e.message),n=Er(e.message);if((n==null?void 0:n.kind)==="dm-agent"){const i=((a=e.message.text)==null?void 0:a.trim())||wr[n.type];return t.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[t.jsxs("div",{className:"mes-dm-agent-system-message mx-auto mb-2 inline-flex w-fit max-w-[min(100%,480px)] items-center justify-center gap-[10px] rounded-[12px] border border-[rgba(0,0,0,0.08)] p-3 text-[rgba(0,0,0,0.55)]","data-testid":"dm-agent-system-message","data-dm-agent-system-type":n.type,children:[t.jsx(y.SparkleIcon,{size:16,weight:"regular","aria-hidden":!0,className:"mes-dm-agent-system-message__sparkle shrink-0"}),t.jsx("p",{className:"mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]",children:i})]}),!s&&t.jsx(w.MessageTimestamp,{message:e.message})]})}if((n==null?void 0:n.kind)==="age-safety"){const i=((r=e.message.text)==null?void 0:r.trim())||yr[n.type];return t.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[t.jsxs("div",{className:"mes-age-safety-system-message box-border mx-auto mb-2 flex w-full max-w-[329px] items-start justify-center gap-3 rounded-[12px] border border-[var(--border-secondary,rgba(0,0,0,0.08))] bg-[var(--bg-warning-subtle,#fef3c6)] px-2 py-4 pl-5 text-[color:var(--text-warning-on-warning,#894b00)]","data-testid":"age-safety-system-message","data-age-safety-system-type":n.type,children:[t.jsx(y.ProhibitIcon,{size:24,weight:"duotone","aria-hidden":!0,className:"mes-age-safety-system-message__icon shrink-0 text-[color:var(--text-warning-on-warning,#894b00)]","data-testid":"age-safety-system-message-icon"}),t.jsx("div",{className:"mes-age-safety-system-message__content min-w-0 flex-[1_0_0]",children:t.jsx("p",{className:"m-0 text-balance text-left text-[12px] font-normal leading-4 tracking-[0.21px] text-[color:var(--text-warning-on-warning,#894b00)]",children:Ir(i)})})]}),!s&&t.jsx(w.MessageTimestamp,{message:e.message})]})}return t.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[t.jsxs("div",{className:"str-chat__message--system__text",children:[t.jsx("div",{className:"str-chat__message--system__line"}),t.jsx("p",{children:e.message.text}),t.jsx("div",{className:"str-chat__message--system__line"})]}),!s&&t.jsx(w.MessageTimestamp,{message:e.message})]})},Es=h.createContext(!1),Ue=({cx:e,index:s})=>t.jsx("circle",{cx:e,cy:"6.15",r:"3.9",fill:"#A0A0A0",children:t.jsx("animateTransform",{attributeName:"transform",type:"translate",values:"0 0; 0 -2.25; 0 0;",dur:"900ms",begin:`${120*s}ms`,repeatCount:"indefinite"})}),Mr=new Set([w.AIStates.Thinking,w.AIStates.Generating,w.AIStates.ExternalSources]),Ar=({threadList:e})=>{var v,j;const{channel:s,channelConfig:n,thread:a}=w.useChannelStateContext(),{client:r}=w.useChatContext(),{typing:i={}}=w.useTypingContext(),{aiState:l}=w.useAIState(s),o=h.useContext(Es);if(!e&&o&&Mr.has(l)){const p=Lr(s,(v=r.user)==null?void 0:v.id);return t.jsx(Gt,{avatarId:(p==null?void 0:p.id)??"ai-agent",avatarName:(p==null?void 0:p.name)??(p==null?void 0:p.id)??"Agent",avatarImage:p==null?void 0:p.image,testId:"typing-indicator-ai"})}if((n==null?void 0:n.typing_events)===!1)return null;const m=e?[]:Object.values(i).filter(({parent_id:p,user:x})=>{var b;return(x==null?void 0:x.id)!==((b=r.user)==null?void 0:b.id)&&!p}),f=e?Object.values(i).filter(({parent_id:p,user:x})=>{var b;return(x==null?void 0:x.id)!==((b=r.user)==null?void 0:b.id)&&p===(a==null?void 0:a.id)}):[],u=e?f:m;if(!u.length)return null;const g=(j=u[0])==null?void 0:j.user,c=g!=null&&g.id&&s.state.members[g.id]?s.state.members[g.id].user:void 0;return t.jsx(Gt,{avatarId:(g==null?void 0:g.id)??(c==null?void 0:c.id)??"typing-user",avatarName:(g==null?void 0:g.name)??(c==null?void 0:c.name)??(g==null?void 0:g.id)??"Typing user",avatarImage:(g==null?void 0:g.image)??(c==null?void 0:c.image),testId:"typing-indicator"})},Gt=({avatarId:e,avatarName:s,avatarImage:n,testId:a})=>t.jsx("div",{className:"str-chat__li str-chat__li--single str-chat__typing-indicator !static","data-testid":a,style:{marginBottom:"var(--messaging-channel-input-spacer-height, 80px)"},children:t.jsxs("div",{className:"str-chat__message str-chat__message-simple str-chat__message--regular str-chat__message--received str-chat__message--other str-chat__message--has-text",children:[t.jsx(ce,{className:"str-chat__avatar str-chat__message-sender-avatar",id:e,name:s,image:n??void 0,size:24,shape:"circle"}),t.jsx("div",{className:"str-chat__message-inner mx-0",children:t.jsx("div",{className:"str-chat__message-bubble-wrapper",children:t.jsx("div",{className:"str-chat__message-bubble",children:t.jsx("div",{className:"str-chat__message-text min-h-11 flex items-center",children:t.jsx("div",{className:"str-chat__message-text-inner str-chat__message-simple-text-inner",children:t.jsxs("svg",{"aria-hidden":"true",className:"block overflow-visible",viewBox:"0 0 32 12.3",width:"32",height:"13",overflow:"visible",children:[t.jsx(Ue,{cx:"4",index:0}),t.jsx(Ue,{cx:"16",index:1}),t.jsx(Ue,{cx:"28",index:2})]})})})})})})]})});function Lr(e,s){var a;const n=((a=e==null?void 0:e.state)==null?void 0:a.members)??{};for(const r of Object.values(n)){const i=r==null?void 0:r.user;if(i&&i.id!==s)return i}}const Is=()=>null,Rr=({className:e,message:s})=>t.jsxs("div",{className:C("flex items-center justify-center h-full",e),children:[t.jsxs("svg",{viewBox:"0 0 100 100",className:"size-8 fill-pebble",stroke:"none",children:[t.jsx("circle",{cx:"6",cy:"50",r:"6",children:t.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 15 ; 0 -15; 0 15",repeatCount:"indefinite",begin:"0.1"})}),t.jsx("circle",{cx:"30",cy:"50",r:"6",children:t.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 10 ; 0 -10; 0 10",repeatCount:"indefinite",begin:"0.2"})}),t.jsx("circle",{cx:"54",cy:"50",r:"6",children:t.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 5 ; 0 -5; 0 5",repeatCount:"indefinite",begin:"0.3"})})]}),s&&t.jsx("span",{className:"text-stone",children:s})]}),Me=h.memo(()=>t.jsx("div",{className:"messaging-loading-state flex items-center justify-center h-full",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx(Rr,{className:"w-6 h-6"}),t.jsx("span",{className:"text-sm text-stone",children:"Loading messages"})]})}));Me.displayName="LoadingState";const Dr=({onBack:e,showBackButton:s,renderMessageInputActions:n,renderMessageInputFooter:a,renderConversationFooter:r,onLeaveConversation:i,onBlockParticipant:l,showDeleteConversation:o=!0,onDeleteConversationClick:d,onBlockParticipantClick:m,onReportParticipantClick:f,showBlockParticipant:u=!0,showReportParticipant:g=!0,composerDisabled:c=!1,composerDisabledReason:v,showStarButton:j=!1,chatbotVotingEnabled:p=!1,renderChannelBanner:x,customChannelActions:b,renderChannelActions:_,renderMessage:S,viewerLanguage:T,showChannelInfo:F=!0,onParticipantNameClick:P,onBroadcastClick:z,composerInput:B})=>{const{channel:A}=w.useChannelStateContext(),E=A.state.messages.some(I=>I.type!=="deleted"),R=x?t.jsx(h.Fragment,{children:x()},"lt-channel-banner"):null,k=t.jsx(Ks,{className:"-mx-[var(--str-chat\\_\\_spacing-2)] px-[var(--str-chat\\_\\_spacing-2)] md:-mx-[min(var(--str-chat\\_\\_spacing-10),4%)] md:px-[min(var(--str-chat\\_\\_spacing-10),4%)]",onBack:e,showBackButton:s,showChannelInfo:F,showStarButton:j,onLeaveConversation:i,onBlockParticipant:l,showDeleteConversation:o,showBlockParticipant:u,showReportParticipant:g,onDeleteConversationClick:d,onBlockParticipantClick:m,onReportParticipantClick:f,customChannelActions:b,renderChannelActions:_,onParticipantNameClick:P}),M=h.useCallback(I=>{const{message:L}=w.useMessageContext("ChannelView"),$=t.jsx(hr,{...I,chatbotVotingEnabled:p,viewerLanguage:T,onBroadcastClick:z});return!S||!L?$:S($,L)},[p,z,S,T]);return t.jsx(t.Fragment,{children:t.jsx(w.WithComponents,{overrides:{Message:M,MessageActions:xr,UnreadMessagesNotification:()=>null,UnreadMessagesSeparator:()=>null},children:t.jsx(w.Window,{children:B?t.jsxs("div",{className:"messaging-channel-layout relative flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:"messaging-channel-message-list messaging-channel-message-list--floating relative min-h-0 flex-1 overflow-hidden",children:[!E&&t.jsx("div",{className:"str-chat__list",children:t.jsxs("div",{className:"str-chat__message-list-scroll",children:[k,R]})}),t.jsx(w.MessageList,{head:E?t.jsxs("div",{className:"sticky top-0 z-10",children:[k,R]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},"lt-channel-message-list"),t.jsx(Ht,{...n&&{renderActions:()=>n==null?void 0:n(A)},...r&&{renderHeader:()=>r(A)},renderFooter:()=>a==null?void 0:a(A),disabled:c,disabledReason:v,composerInput:B},"lt-channel-message-input")]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[!E&&t.jsx("div",{className:"str-chat__list",children:t.jsxs("div",{className:"str-chat__message-list-scroll",children:[k,R]})}),t.jsx(w.MessageList,{head:E?t.jsxs("div",{className:"sticky top-0 z-10",children:[k,R]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},"lt-channel-message-list"),r?t.jsx(h.Fragment,{children:r(A)},"lt-channel-conversation-footer"):null,t.jsx(Ht,{...n&&{renderActions:()=>n==null?void 0:n(A)},renderFooter:()=>a==null?void 0:a(A),disabled:c,disabledReason:v,composerInput:B},"lt-channel-message-input")]})})})})},ft=h.memo(({channel:e,onBack:s,showBackButton:n=!1,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:l,onBlockParticipant:o,className:d,CustomChannelEmptyState:m=Is,showDeleteConversation:f=!0,onDeleteConversationClick:u,onBlockParticipantClick:g,onReportParticipantClick:c,showBlockParticipant:v=!0,showReportParticipant:j=!0,composerDisabled:p=!1,composerDisabledReason:x,dmAgentEnabled:b,messageMetadata:_,onMessageSent:S,showStarButton:T=!1,chatbotVotingEnabled:F=!1,renderChannelBanner:P,customChannelActions:z,renderChannelActions:B,renderMessage:A,onMessageLinkClick:E,sendButton:R,attachmentPreviewList:k,viewerLanguage:M,showChannelInfo:I=!0,onParticipantNameClick:L,onBroadcastClick:$,composerInput:H})=>{const Z=h.useCallback(async(Y,N,D)=>{var X;const V=((X=e.data)==null?void 0:X.chatbot_paused)===!0,G=b&&!V,J={...N,...G&&{silent:!0},..._&&{metadata:{...N.metadata??{},..._}}},q={...D,...G&&{skip_push:!0}},U=await e.sendMessage(J,q);return S==null||S(U),U},[e,b,_,S]),te=h.useRef(null);return h.useEffect(()=>{if(!E)return;const Y=te.current;if(!Y)return;const N=D=>{const V=D.target,G=V==null?void 0:V.closest("a[href]"),J=G==null?void 0:G.getAttribute("href");if(!J)return;const q=G==null?void 0:G.closest("[data-message-id]"),U=q==null?void 0:q.getAttribute("data-message-id"),X=U?e.state.messages.find(se=>se.id===U):void 0;E(J,X)};return Y.addEventListener("click",N),()=>Y.removeEventListener("click",N)},[E,e]),t.jsx("div",{ref:te,className:C("messaging-channel-view h-full flex flex-col",d),children:t.jsx(Es.Provider,{value:b??!1,children:t.jsx(w.Channel,{channel:e,MessageSystem:Tr,EmptyStateIndicator:m,LoadingIndicator:Me,DateSeparator:Zs,TypingIndicator:Ar,doSendMessageRequest:Z,...R?{SendButton:R}:{},...k?{AttachmentPreviewList:k}:{},children:t.jsx(Dr,{onBack:s,showBackButton:n,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:l,onBlockParticipant:o,CustomChannelEmptyState:m,showDeleteConversation:f,onDeleteConversationClick:u,onBlockParticipantClick:g,onReportParticipantClick:c,showBlockParticipant:v,showReportParticipant:j,composerDisabled:p,composerDisabledReason:x,showStarButton:T,chatbotVotingEnabled:F,renderChannelBanner:P,customChannelActions:z,renderChannelActions:B,renderMessage:A,viewerLanguage:M,showChannelInfo:I,onParticipantNameClick:L,onBroadcastClick:$,composerInput:H})})})})});ft.displayName="ChannelView";const xe=h.memo(({message:e,onBack:s})=>t.jsx("div",{className:"messaging-error-state flex items-center justify-center h-full p-8",children:t.jsxs("div",{className:"text-center max-w-sm",children:[t.jsx("div",{className:"w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6",children:t.jsx("span",{className:"text-4xl",children:"⚠️"})}),t.jsx("h2",{className:"font-semibold text-charcoal mb-2",children:"Oops!"}),t.jsx("p",{className:"text-stone text-sm mb-6",children:e}),s&&t.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-[#7f22fe] hover:bg-primary-alt rounded-lg transition-colors focus-ring",children:"Go Back"})]})}));xe.displayName="ErrorState";const Pr=({capabilities:e={},renderMessageInputActions:s,renderConversationFooter:n,onChannelSelect:a,onExitConversation:r,initialParticipantFilter:i,initialParticipantData:l,CustomChannelEmptyState:o,onBlockParticipantClick:d,onReportParticipantClick:m,dmAgentEnabled:f,onMessageSent:u,chatbotVotingEnabled:g=!1,viewerLanguage:c,renderChannelBanner:v,customChannelActions:j,renderChannelActions:p,onParticipantNameClick:x,onBroadcastClick:b,renderMessage:_,onMessageLinkClick:S,showChannelInfo:T,composerInput:F})=>{const{client:P,isConnected:z,isLoading:B,error:A,refreshConnection:E,service:R,debug:k}=Wt(),[M,I]=h.useState(null),[L,$]=h.useState(null),[H,Z]=h.useState(!1),{showDeleteConversation:te=!0}=e,Y=h.useRef(l);Y.current=l;const N=h.useRef(a);N.current=a;const D=h.useRef(null),V=h.useRef(null);h.useEffect(()=>{V.current=M},[M]),h.useEffect(()=>{if(!P||!z)return;const q=P.userID;if(!q)return;const U=`${q}::${i}`;if(D.current===U)return;D.current=U;const X=()=>{D.current===U&&(D.current=null)};(async()=>{var we,Ne;try{k&&console.log("[MessagingShell] Loading initial conversation with:",i);const ne=await P.queryChannels({type:"messaging",members:{$eq:[q,i]}},{},{limit:1});if(ne.length>0){I(ne[0]),$(null),(we=N.current)==null||we.call(N,ne[0]),k&&console.log("[MessagingShell] Initial conversation loaded:",ne[0].id);return}const ie=Y.current;if(!ie||!R){X(),$("No conversation found with this account"),k&&console.log("[MessagingShell] No conversation found for:",i);return}try{const ae=await R.startChannelWithParticipant({id:ie.id,name:ie.name,phone:ie.phone});I(ae),$(null),(Ne=N.current)==null||Ne.call(N,ae),k&&console.log("[MessagingShell] Channel created and loaded:",ae.id)}catch(ae){console.error("[MessagingShell] Failed to create conversation:",ae),X(),$("Failed to create conversation")}}catch(ne){console.error("[MessagingShell] Failed to load initial conversation:",ne),X(),V.current||$("Failed to load conversation")}})()},[i,P,z,R,k]);const G=h.useRef(r);G.current=r;const J=h.useCallback(()=>{var q;I(null),Z(!0),(q=G.current)==null||q.call(G)},[]);return B?t.jsx(Me,{}):A?t.jsx(xe,{message:A,onBack:E}):!z||!P?t.jsx(xe,{message:"Not connected to messaging service",onBack:E}):L?t.jsx(xe,{message:L}):H&&!M?t.jsx(xe,{message:"Conversation ended"}):M?t.jsx("div",{className:"messaging-shell h-full bg-background-primary overflow-hidden",children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:t.jsx(ft,{channel:M,renderMessageInputActions:s,renderConversationFooter:n,renderChannelBanner:v,onLeaveConversation:J,onBlockParticipant:J,CustomChannelEmptyState:o,showDeleteConversation:te,onBlockParticipantClick:d,onReportParticipantClick:m,dmAgentEnabled:f,onMessageSent:u,chatbotVotingEnabled:g,viewerLanguage:c,customChannelActions:j,renderChannelActions:p,onParticipantNameClick:x,onBroadcastClick:b,renderMessage:_,onMessageLinkClick:S,showChannelInfo:T,composerInput:F},M.id)})}):t.jsx(Me,{})};function Or(e){const s=e.state.pending_messages;if(s!=null&&s.length)for(const n of s)e.state.addMessageSorted(n.message)}const Ts=h.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,channelPreview:void 0,viewerLanguage:void 0}),Fr=Ts.Provider,zr=()=>h.useContext(Ts),Br=(e,s)=>{const n=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())),r=new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())).getTime()-n.getTime();return Math.floor(r/(1e3*60*60*24))},Ms=e=>{const s=new Date;if(Math.floor((s.getTime()-e.getTime())/1e3)<60)return"Just now";const a=Br(e,s);return a===0?e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):a===1?"Yesterday":a<7?`${a}d`:a<28?`${Math.floor(a/7)}w`:e.toLocaleDateString(void 0,{day:"numeric",month:"short",year:"2-digit"})},As=h.memo(e=>{var z,B,A;const{channel:s,unread:n}=e,{selectedChannel:a,onChannelSelect:r,debug:i,channelPreview:l,renderMessagePreview:o,viewerLanguage:d}=zr(),{client:m}=w.useChatContext(),f=(a==null?void 0:a.id)===(s==null?void 0:s.id),u=Xt(s);if(l){const E=l;return t.jsx(E,{...e,active:f,selectedChannel:a,onChannelSelect:r,viewerLanguage:d})}const g=()=>{s&&r(s)},c=E=>{const R=E.key==="Enter"||E.key===" ",k=E.repeat;!R||k||(E.preventDefault(),g())},v=We((z=s==null?void 0:s.state)==null?void 0:z.members,m==null?void 0:m.userID,s==null?void 0:s.type),j=Xe(v==null?void 0:v.user),p=(B=v==null?void 0:v.user)==null?void 0:B.image,x=(()=>{var R;const E=(R=s==null?void 0:s.state)==null?void 0:R.messages;if(E!=null&&E.length){for(let k=E.length-1;k>=0;k--)if(E[k].type!=="system")return E[k]}})(),_=(()=>{var I;const E=Ke({message:x,viewerLanguage:d}),{custom_type:R,attachment_content_type:k}=(x==null?void 0:x.metadata)||{};if(R===W.MESSAGE_CUSTOM_TYPE.TIP)return E||"Sent a tip";if(R===W.MESSAGE_CUSTOM_TYPE.PAID)return E||"Sent a message";if(R===W.MESSAGE_CUSTOM_TYPE.ATTACHMENT){if(k==="text")return"🔒 Sent a locked message";if(k==="media")return"🔒 Sent a locked attachment"}if(E)return E;const M=(I=x==null?void 0:x.attachments)==null?void 0:I[0];return M?M.og_scrape_url?M.og_scrape_url:M.type==="image"?"📷 Sent an image":M.type==="video"?"🎥 Sent a video":M.type==="audio"?"🎵 Sent audio":M.type==="file"?"📎 Sent a file":"📎 Sent an attachment":"No messages yet"})(),S=x!=null&&x.created_at?Ms(new Date(x.created_at)):"",T=x?Se(x):!1,F=o?o(x,_):`${T?"✨ ":""}${_}`,P=n??0;return i&&console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER",{channelId:s==null?void 0:s.id,isSelected:f,participantName:j,unreadCount:P,hasTimestamp:!!S}),t.jsx("div",{role:"button",tabIndex:0,onClick:g,onKeyDown:c,className:C("group w-full px-4 py-3 transition-colors text-left max-w-full overflow-hidden focus-ring rounded-[12px] [&+&]:mt-2",{"bg-black/[0.04]":f,"hover:bg-black/[0.02]":!f}),"data-dd-privacy":"mask",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx(ce,{id:((A=v==null?void 0:v.user)==null?void 0:A.id)||s.id||"unknown",name:j,image:p,size:48,starred:u}),t.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("h3",{className:C("text-sm font-medium truncate text-[#191918]"),children:[u&&t.jsx("span",{className:"sr-only",children:"Starred conversation. "}),j]}),S&&t.jsx("span",{className:"text-xs text-[#717070] flex-shrink-0",children:S})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[t.jsx("p",{className:"text-sm text-[#717070] flex-1 line-clamp-1",children:F}),P>0&&t.jsx("span",{className:"bg-[#7f22fe] text-white text-[10px] rounded-full h-4 flex items-center justify-center p-1 min-w-4 text-center flex-shrink-0",children:P>99?"99+":P})]})]})]})})});As.displayName="CustomChannelPreview";const $r={last_message_at:-1},Ls=h.memo(({onChannelSelect:e,selectedChannel:s,filters:n,allowNewMessagesFromUnfilteredChannels:a=!1,channelRenderFilterFn:r,sort:i=$r,className:l,customEmptyStateIndicator:o,channelListPaginator:d=w.InfiniteScroll,channelPreview:m,renderMessagePreview:f,viewerLanguage:u,lockChannelOrder:g,onMessageNewHandler:c,onMessageNew:v,onChannelVisible:j,onAddedToChannel:p,onChannelUpdated:x})=>{const b=h.useRef(0);b.current++;const{debug:_=!1}=qe(),S=h.useCallback(F=>{for(const P of F)Or(P);return r?r(F):F},[r]);_&&console.log("📺 [ChannelList] 🔄 RENDER START",{renderCount:b.current,selectedChannelId:s==null?void 0:s.id,filters:n});const T=h.useMemo(()=>({selectedChannel:s,onChannelSelect:e,debug:_,channelPreview:m,renderMessagePreview:f,viewerLanguage:u}),[s,e,_,m,f,u]);return t.jsx("div",{className:C("messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",l),children:t.jsx("div",{className:"flex-1 overflow-hidden min-w-0",children:t.jsx(Fr,{value:T,children:t.jsx(w.ChannelList,{filters:n,sort:i,options:{limit:30},allowNewMessagesFromUnfilteredChannels:a,channelRenderFilterFn:S,lockChannelOrder:g,onMessageNewHandler:c,onMessageNew:v,onChannelVisible:j,onAddedToChannel:p,onChannelUpdated:x,Paginator:d,Preview:As,EmptyStateIndicator:o},`${JSON.stringify(n)}:${JSON.stringify(i)}`)})})})});Ls.displayName="ChannelList";const Yt=`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='23' fill='none'%3E%3Cpath fill='black' d='M0 0H15C15 10.1934 15.859 15.2345 19.168 21.4893C19.527 22.168 19.039 22.9917 18.274 22.9178C5.176 21.6506 0.32 6.0737 0 0Z'/%3E%3C/svg%3E") no-repeat center / 100% 100%`,Ur={sent:"var(--str-chat__own-message-bubble-background-color, #1e2330)",received:"var(--str-chat__message-bubble-background-color, #f1f0ee)"},Vr=({variant:e})=>t.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0 z-[-1] h-[1.4375rem] w-5",style:{insetInlineEnd:e==="sent"?"calc(-1 * 0.25rem)":void 0,insetInlineStart:e==="received"?"calc(-1 * 0.25rem)":void 0,transform:e==="received"?"scaleX(-1)":void 0,transformOrigin:"center",backgroundColor:Ur[e],WebkitMask:Yt,mask:Yt}}),Hr={sent:{backgroundColor:"var(--str-chat__own-message-bubble-background-color, #1e2330)",color:"var(--str-chat__own-message-bubble-color, #fff)"},received:{backgroundColor:"var(--str-chat__message-bubble-background-color, #f1f0ee)",color:"var(--str-chat__message-bubble-color, #000000)"}},Rs=({variant:e,text:s,tail:n=!0,header:a,className:r})=>t.jsxs("div",{"data-dd-privacy":"mask",className:C("relative px-4 py-3","text-[0.875rem] leading-[1.3125rem] tracking-[0.14px]",r),style:{...Hr[e],borderRadius:"var(--str-chat__message-bubble-border-radius, 1.5rem)",isolation:"isolate"},children:[a!=null&&t.jsx("div",{className:"mb-1 font-medium","data-testid":"message-bubble-header",children:a}),t.jsx("p",{className:"m-0 whitespace-pre-wrap break-words",children:s}),n&&t.jsx(Vr,{variant:e})]}),Gr=({text:e,tail:s,header:n,className:a})=>t.jsx(Rs,{variant:"received",text:e,tail:s,header:n,className:a}),Yr=({text:e,tail:s,className:n})=>t.jsx(Rs,{variant:"sent",text:e,tail:s,className:n}),qr={Sent:Yr,Received:Gr},Ds=({question:e,onClick:s,loading:n=!1,className:a})=>t.jsx("button",{type:"button",onClick:s,disabled:n,style:{backgroundColor:"#E6E5E3"},className:C("w-full text-center p-4 rounded-xl text-charcoal font-medium transition-colors focus-ring",{"hover:brightness-95 active:brightness-90":!n,"opacity-50 cursor-not-allowed":n},a),children:e}),Wr=({faqs:e,onFaqClick:s,loadingFaqId:n,headerText:a,className:r,avatarImage:i,avatarName:l})=>{const o=W.selectEnabledFaqs(e);return o.length===0?null:t.jsx("div",{className:r,children:t.jsxs("div",{className:"flex gap-3 items-end",children:[(i||l)&&t.jsx("div",{className:"flex-none",children:t.jsx(ce,{id:l||"account",name:l||"Account",image:i,size:24,shape:"circle"})}),t.jsxs("div",{className:"flex-1 flex flex-col gap-3 rounded-lg p-4",style:{backgroundColor:"#F1F0EE"},children:[a&&t.jsx("p",{className:"text-md text-charcoal mb-4",children:a}),o.map(d=>t.jsx(Ds,{question:d.question,onClick:()=>s(d.id),loading:n===d.id},d.id))]})]})})};exports.ActionButton=he;exports.AttachmentThumbnail=Ze;exports.Avatar=ce;exports.ChannelEmptyState=Is;exports.ChannelList=Ls;exports.ChannelView=ft;exports.CustomMessageProvider=ja;exports.FaqList=Wr;exports.FaqListItem=Ds;exports.LinkAttachment=Ie;exports.LockedAttachment=ge;exports.MediaMessage=jn;exports.MessageAttachment=fe;exports.MessageBubble=qr;exports.MessageVoteButtons=ys;exports.MessagingProvider=Bs;exports.MessagingShell=Pr;exports.bubbleGroupPositionFromStream=rs;exports.buildCompactMetaLabel=ls;exports.formatFileSize=is;exports.formatRelativeTime=Ms;exports.getFileExtensionLabel=os;exports.getMessageDisplayText=Ke;exports.getSourceType=ee;exports.isLinkAttachment=et;exports.isUuidLike=Kt;exports.normalizeLanguageCode=Qt;exports.optimizeMessagingAttachmentUrl=re;exports.renderTypeIcon=le;exports.resolveConversationParticipant=We;exports.resolveLinkAttachment=Ae;exports.resolveMediaFromMessage=Le;exports.resolveParticipantDisplayName=Xe;exports.useComposerLocked=jr;exports.useCustomMessage=_s;exports.useMessageVote=Jt;exports.useMessaging=Wt;
|
|
2
|
-
//# sourceMappingURL=index-BnBvT5FW.cjs.map
|