@linktr.ee/messaging-react 3.4.3-rc-1782553894 → 3.4.4-rc-1782716645

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/{Card-Cj686l88.js → Card-B3chRicI.js} +2 -2
  2. package/dist/{Card-Cj686l88.js.map → Card-B3chRicI.js.map} +1 -1
  3. package/dist/{Card-ffFBtGq1.cjs → Card-BFpVUA1p.cjs} +2 -2
  4. package/dist/{Card-ffFBtGq1.cjs.map → Card-BFpVUA1p.cjs.map} +1 -1
  5. package/dist/{Card-COb-KQ3x.js → Card-Cgh2ZQ1o.js} +2 -2
  6. package/dist/{Card-COb-KQ3x.js.map → Card-Cgh2ZQ1o.js.map} +1 -1
  7. package/dist/{Card-BVo5bHm8.cjs → Card-D9HR_DMh.cjs} +2 -2
  8. package/dist/{Card-BVo5bHm8.cjs.map → Card-D9HR_DMh.cjs.map} +1 -1
  9. package/dist/{Card-ChLOPFzW.cjs → Card-DNkyaI4C.cjs} +2 -2
  10. package/dist/{Card-ChLOPFzW.cjs.map → Card-DNkyaI4C.cjs.map} +1 -1
  11. package/dist/{Card-DAiwq638.js → Card-iPCZ4iFO.js} +3 -3
  12. package/dist/{Card-DAiwq638.js.map → Card-iPCZ4iFO.js.map} +1 -1
  13. package/dist/{LockedThumbnail-DzTY1vH1.cjs → LockedThumbnail-CFLBByiw.cjs} +2 -2
  14. package/dist/{LockedThumbnail-DzTY1vH1.cjs.map → LockedThumbnail-CFLBByiw.cjs.map} +1 -1
  15. package/dist/{LockedThumbnail-Bmw7e0iZ.js → LockedThumbnail-CtGTlb4k.js} +2 -2
  16. package/dist/{LockedThumbnail-Bmw7e0iZ.js.map → LockedThumbnail-CtGTlb4k.js.map} +1 -1
  17. package/dist/{index-D_U3aScH.js → index-BZRzouKv.js} +612 -595
  18. package/dist/index-BZRzouKv.js.map +1 -0
  19. package/dist/index-By3QMonF.cjs +2 -0
  20. package/dist/index-By3QMonF.cjs.map +1 -0
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +1 -1
  23. package/package.json +2 -2
  24. package/src/components/ChannelList/CustomChannelPreview.tsx +7 -4
  25. package/src/components/ChannelView.tsx +8 -3
  26. package/src/components/CustomMessage/index.tsx +1 -0
  27. package/src/components/CustomMessageInput/index.tsx +4 -1
  28. package/src/components/MediaMessage/index.tsx +13 -5
  29. package/dist/index-DXBga91I.cjs +0 -2
  30. package/dist/index-DXBga91I.cjs.map +0 -1
  31. package/dist/index-D_U3aScH.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DXBga91I.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.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.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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-By3QMonF.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.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.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 g, f as r, L as l, h as M, M as u, i as L, j as c, k as h, l as d, m as p, n as C, o as v, p as A, q as k, s as F, t as b, u as f, v as x, w as y, x as P, y as S, z as q, B as z, D as B, E as D } from "./index-D_U3aScH.js";
1
+ import { a as e, b as t, C as i, c as o, d as n, e as m, F as g, f as r, L as l, h as M, M as u, i as L, j as c, k as h, l as d, m as p, n as C, o as v, p as A, q as k, s as F, t as b, u as f, v as x, w as y, x as P, y as S, z as q, B as z, D as B, E as D } from "./index-BZRzouKv.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.4.3-rc-1782553894",
3
+ "version": "3.4.4-rc-1782716645",
4
4
  "description": "React messaging components built on messaging-core for web applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@linktr.ee/component-library": "11.8.6",
41
- "@linktr.ee/messaging-core": "2.3.0-rc-1782553894",
41
+ "@linktr.ee/messaging-core": "2.3.0-rc-1782716645",
42
42
  "@phosphor-icons/react": "^2.1.10"
43
43
  },
44
44
  "devDependencies": {
@@ -69,11 +69,13 @@ const CustomChannelPreview = React.memo<ChannelPreviewUIComponentProps>(
69
69
  if (isTip) return displayText ? `💵 ${displayText}` : '💵 Sent a tip'
70
70
  const isPaid = lastMessage?.metadata?.custom_type === 'MESSAGE_PAID'
71
71
  if (isPaid) return displayText ? `💰 ${displayText}` : '💰 Sent a message'
72
- const isPaidAttachment = lastMessage?.metadata?.custom_type === 'MESSAGE_ATTACHMENT'
73
- if (isPaidAttachment) return displayText ? `📎 ${displayText}` : '📎 Sent an attachment'
74
-
72
+ const isPaidAttachment =
73
+ lastMessage?.metadata?.custom_type === 'MESSAGE_ATTACHMENT'
74
+ if (isPaidAttachment)
75
+ return displayText ? `📎 ${displayText}` : '📎 Sent an attachment'
76
+
75
77
  if (displayText) return displayText
76
-
78
+
77
79
  const attachment = lastMessage?.attachments?.[0]
78
80
  if (attachment) {
79
81
  // Link previews - show the actual URL
@@ -131,6 +133,7 @@ const CustomChannelPreview = React.memo<ChannelPreviewUIComponentProps>(
131
133
  'hover:bg-black/[0.02]': !isSelected,
132
134
  }
133
135
  )}
136
+ data-dd-privacy="mask"
134
137
  >
135
138
  <div className="flex items-start gap-4">
136
139
  {/* Avatar */}
@@ -104,7 +104,9 @@ const CustomChannelHeader: React.FC<{
104
104
  const participantTitle = (
105
105
  <>
106
106
  <span className="min-w-0 truncate">{participantName}</span>
107
- {headerTitleBadges && <span className="shrink-0">{headerTitleBadges}</span>}
107
+ {headerTitleBadges && (
108
+ <span className="shrink-0">{headerTitleBadges}</span>
109
+ )}
108
110
  </>
109
111
  )
110
112
 
@@ -141,7 +143,10 @@ const CustomChannelHeader: React.FC<{
141
143
  </button>
142
144
  )}
143
145
  </div>
144
- <div className="flex flex-col gap-1 items-center">
146
+ <div
147
+ className="flex flex-col gap-1 items-center"
148
+ data-dd-privacy="mask"
149
+ >
145
150
  {onParticipantNameClick ? (
146
151
  <button
147
152
  type="button"
@@ -238,7 +243,7 @@ const CustomChannelHeader: React.FC<{
238
243
  </div>
239
244
  </div>
240
245
  <div className="px-6 py-3 hidden @lg:flex items-center justify-between gap-3 min-h-12 border-b border-b-black/[0.08]">
241
- <div className="flex items-center gap-4 min-w-0">
246
+ <div className="flex items-center gap-4 min-w-0" data-dd-privacy="mask">
242
247
  {showBackButton && onBack && (
243
248
  <button
244
249
  className={classNames(
@@ -198,6 +198,7 @@ const CustomMessageWithContext = (props: CustomMessageWithContextProps) => {
198
198
  className={rootClassName}
199
199
  key={message.id}
200
200
  data-message-id={message.id}
201
+ data-dd-privacy="mask"
201
202
  >
202
203
  {PinIndicator && <PinIndicator />}
203
204
  {!!reminder && <ReminderNotification reminder={reminder} />}
@@ -61,7 +61,10 @@ const CustomMessageInputInner: React.FC = () => {
61
61
  } = useComponentContext('CustomMessageInput')
62
62
 
63
63
  return (
64
- <div className="central-container flex flex-col gap-2 min-w-0 w-full p-2 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)]">
64
+ <div
65
+ className="central-container flex flex-col gap-2 min-w-0 w-full p-2 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)]"
66
+ data-dd-privacy="mask"
67
+ >
65
68
  <QuotedMessagePreview />
66
69
  <CustomLinkPreviewList />
67
70
  <AttachmentPreviewList />
@@ -302,7 +302,7 @@ const MediaMessageRoot: React.FC<MediaMessageProps> = ({
302
302
  : 'str-chat__message str-chat__message-simple str-chat__message--other'
303
303
 
304
304
  return (
305
- <div className={messageClass}>
305
+ <div className={messageClass} data-dd-privacy="mask">
306
306
  {!isMyMessage && message.user && (
307
307
  <Avatar
308
308
  className="str-chat__avatar str-chat__message-sender-avatar"
@@ -342,14 +342,18 @@ const MediaMessageCreatorEntry: React.FC<{ message: LocalMessage }> = ({
342
342
  const linkAttachment = resolveLinkAttachment(message)
343
343
  if (linkAttachment) {
344
344
  return (
345
- <div className={linkCardShellClass(true)}>
345
+ <div className={linkCardShellClass(true)} data-dd-privacy="mask">
346
346
  <LinkCard attachment={linkAttachment} isMyMessage={true} />
347
347
  </div>
348
348
  )
349
349
  }
350
350
  const resolved = resolveMediaFromMessage(message)
351
351
  if (!resolved) return null
352
- return <Creator {...resolved} />
352
+ return (
353
+ <div style={{ display: 'contents' }} data-dd-privacy="mask">
354
+ <Creator {...resolved} />
355
+ </div>
356
+ )
353
357
  }
354
358
 
355
359
  const MediaMessageVisitorEntry: React.FC<{ message: LocalMessage }> = ({
@@ -358,14 +362,18 @@ const MediaMessageVisitorEntry: React.FC<{ message: LocalMessage }> = ({
358
362
  const linkAttachment = resolveLinkAttachment(message)
359
363
  if (linkAttachment) {
360
364
  return (
361
- <div className={linkCardShellClass(false)}>
365
+ <div className={linkCardShellClass(false)} data-dd-privacy="mask">
362
366
  <LinkCard attachment={linkAttachment} isMyMessage={false} />
363
367
  </div>
364
368
  )
365
369
  }
366
370
  const resolved = resolveMediaFromMessage(message)
367
371
  if (!resolved) return null
368
- return <Visitor {...resolved} />
372
+ return (
373
+ <div style={{ display: 'contents' }} data-dd-privacy="mask">
374
+ <Visitor {...resolved} />
375
+ </div>
376
+ )
369
377
  }
370
378
 
371
379
  export const MediaMessage = Object.assign(MediaMessageRoot, {
@@ -1,2 +0,0 @@
1
- "use strict";const t=require("react/jsx-runtime"),u=require("react"),us=require("@linktr.ee/messaging-core"),Te=require("stream-chat"),N=require("stream-chat-react"),w=require("@phosphor-icons/react"),y=require("classnames"),Le=require("stream-chat-react/experimental"),kt=u.createContext({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),De=()=>u.useContext(kt),ms=({children:e,user:s,serviceConfig:n,apiKey:a,capabilities:r={},debug:i=!1})=>{var P,k;const l=u.useCallback((S,...T)=>{i&&console.log(`🔥 [MessagingProvider] ${S}`,...T)},[i]);l("🔄 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[o,d]=u.useState(null),[h,f]=u.useState(null),[m,x]=u.useState(!1),[c,g]=u.useState(!1),[_,j]=u.useState(null),p=u.useRef(!1),b=u.useRef(null),A=u.useRef(n);A.current=n;const M=u.useRef(i);M.current=i;const C=u.useRef({userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r}),F=u.useRef(0);F.current++,l("📊 RENDER INFO",{renderCount:F.current,currentProps:{userId:s==null?void 0:s.id,apiKey:(a==null?void 0:a.substring(0,8))+"..."},propChanges:{userChanged:C.current.userId!==(s==null?void 0:s.id),apiKeyChanged:C.current.apiKey!==a,serviceConfigChanged:C.current.serviceConfig!==n,capabilitiesChanged:C.current.capabilities!==r}}),C.current={userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r};const z=u.useRef(null);a&&((P=z.current)==null?void 0:P.apiKey)!==a&&(z.current={apiKey:a,client:new Te.StreamChat(a)});const D=a?((k=z.current)==null?void 0:k.client)??null:null;u.useEffect(()=>{const S=F.current,T=A.current;if(!a||!D||!T){l("⚠️ SERVICE INIT SKIPPED",{renderCount:S,reason:"Missing apiKey, client, or serviceConfig"});return}l("🚀 CREATING SERVICE",{renderCount:S,apiKey:(a==null?void 0:a.substring(0,8))+"..."});const $=new us.StreamChatService({...T,apiKey:a,debug:M.current,client:D});b.current=$,d($),l("✅ SERVICE SET",{renderCount:S,serviceInstance:!!$})},[a,D]);const I=u.useRef(null);u.useEffect(()=>{var T,$;if(l("🔗 USER CONNECTION EFFECT TRIGGERED",{hasService:!!o,hasUser:!!s,userId:s==null?void 0:s.id,isConnecting:p.current,isConnected:m,dependencies:{service:!!o,userId:s==null?void 0:s.id}}),!o||!s){l("⚠️ USER CONNECTION SKIPPED","Missing service or user");return}if(p.current){l("⚠️ USER CONNECTION SKIPPED","Already connecting");return}if(((T=I.current)==null?void 0:T.serviceId)===o&&(($=I.current)==null?void 0:$.userId)===s.id){l("⚠️ USER CONNECTION SKIPPED","Already connected this user with this service");return}(async()=>{l("🚀 STARTING USER CONNECTION",{userId:s.id}),p.current=!0,g(!0),j(null);try{l("📞 CALLING SERVICE.CONNECTUSER",{userId:s.id});const O=await o.connectUser(s);f(O),x(!0),I.current={serviceId:o,userId:s.id},l("✅ USER CONNECTION SUCCESS",{userId:s.id,clientId:O.userID})}catch(O){const V=O instanceof Error?O.message:"Connection failed";j(V),l("❌ USER CONNECTION ERROR",{userId:s.id,error:V})}finally{g(!1),p.current=!1,l("🔄 USER CONNECTION FINISHED",{userId:s.id,isConnected:m})}})()},[o,s,l,m]),u.useEffect(()=>{const S=D;return()=>{var T;S&&(I.current=null,(T=b.current)==null||T.disconnectUser().catch(console.error))}},[D]);const L=u.useCallback(async()=>{if(l("🔄 REFRESH CONNECTION CALLED",{hasService:!!o,hasUser:!!s}),!o||!s){l("⚠️ REFRESH CONNECTION SKIPPED","Missing service or user");return}l("🚀 STARTING CONNECTION REFRESH",{userId:s.id}),g(!0);try{l("🔌 DISCONNECTING FOR REFRESH"),await o.disconnectUser(),l("📞 RECONNECTING FOR REFRESH");const S=await o.connectUser(s);f(S),x(!0),j(null),l("✅ CONNECTION REFRESH SUCCESS",{userId:s.id})}catch(S){const T=S instanceof Error?S.message:"Refresh failed";j(T),l("❌ CONNECTION REFRESH ERROR",{userId:s.id,error:T})}finally{g(!1),l("🔄 CONNECTION REFRESH FINISHED",{userId:s.id})}},[o,s,l]),R=u.useMemo(()=>(l("💫 CONTEXT VALUE MEMOIZATION",{hasService:!!o,hasClient:!!h,isConnected:m,isLoading:c,hasError:!!_,capabilitiesKeys:Object.keys(r)}),{service:o,client:h,isConnected:m,isLoading:c,error:_,capabilities:r,refreshConnection:L,debug:i}),[o,h,m,c,_,r,L,i,l]);return l("🔄 RENDER END",{renderCount:F.current,willRenderChat:!!D,contextValueReady:!!R}),t.jsx(kt.Provider,{value:R,children:D?t.jsx(N.Chat,{client:D,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})},St=()=>De(),It=e=>{var a,r;const[s,n]=u.useState(!!((r=(a=e==null?void 0:e.state)==null?void 0:a.membership)!=null&&r.pinned_at));return u.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},hs=/^[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 Et(e){return hs.test(e.trim())}function jt(e,s){const n=e==null?void 0:e.trim();return!n||s&&n===s?!1:!Et(n)}function Pe(e){return jt(e==null?void 0:e.name,e==null?void 0:e.id)?e.name.trim():jt(e==null?void 0:e.username,e==null?void 0:e.id)?e.username.trim():"Unknown member"}const wt=["🍎","🍌","🍇","🍊","🍓","🥥","🍒","🥭","🍉","🍋","🥝","🫒","🍈"];function xs(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 fs(e){const n=xs(e)%wt.length;return wt[n]}const Q=({id:e,image:s,size:n=40,className:a,starred:r=!1,shape:i="squircle",dmAgentEnabled:l=!1})=>{const o=fs(e),h=n<32?"text-xs":n<56?"text-sm":n<120?"text-lg":"text-4xl",f=n>=40?2:1,m=i==="circle"?{borderRadius:"50%"}:{borderRadius:"1rem"},x=t.jsx("div",{className:"h-full w-full overflow-hidden",style:m,children:s?t.jsx("img",{src:s,alt:"",className:"h-full w-full object-cover"}):t.jsx("div",{"aria-hidden":"true",className:y("avatar-fallback flex h-full w-full items-center justify-center bg-[#E6E5E3] font-semibold select-none transition-colors",h),children:o})});return t.jsxs("div",{className:y("relative flex-shrink-0 !bg-transparent",a),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`},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(w.StarIcon,{className:"size-3 text-yellow-600",weight:"duotone"})}),t.jsx("div",{"data-testid":"avatar-ring",className:y("h-full w-full","bg-transparent"),style:{...m,...l&&{borderWidth:`${f}px`,borderStyle:"solid",borderColor:"var(--AI-Gradient, #7F22FE)",boxShadow:"inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"}},children:x})]})},gs="https://linktr.ee/s/about/trust-center/report",bs=({channel:e,participant:s,showBlockParticipant:n=!0,enabled:a=!0,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:l,onBlockParticipantClick:o,onReportParticipantClick:d,onActionComplete:h,logLabel:f="useChannelModerationActions"})=>{var P;const{service:m,debug:x}=De(),c=(P=s==null?void 0:s.user)==null?void 0:P.id,g=!!(a&&n&&m&&c),[_,j]=u.useState(!1),[p,b]=u.useState(null),[A,M]=u.useState(!1),[C,F]=u.useState(!1),z=g&&((p==null?void 0:p.participantId)!==c||(p==null?void 0:p.service)!==m);return u.useEffect(()=>{if(!g||!m||!c){j(!1),b(null);return}let k=!1;return(async()=>{try{const S=await m.getBlockedUsers();if(k)return;j(S.some(T=>T.blocked_user_id===c))}catch(S){k||console.error(`[${f}] Failed to check blocked status:`,S)}finally{k||b({participantId:c,service:m})}})(),()=>{k=!0}},[g,m,c,f]),{isParticipantBlocked:_,isCheckingBlockedStatus:z,isLeaving:A,isUpdatingBlockStatus:C,handleLeaveConversation:async()=>{var k;if(!A){l==null||l(),x&&console.log(`[${f}] Leave conversation`,e.cid),M(!0);try{const S=((k=e._client)==null?void 0:k.userID)??null;await e.hide(S,!1),r&&await r(e),h==null||h()}catch(S){console.error(`[${f}] Failed to leave conversation`,S)}finally{M(!1)}}},handleBlockUser:async()=>{var k,S,T;if(!(C||!m)){o==null||o(),x&&console.log(`[${f}] Block member`,(k=s==null?void 0:s.user)==null?void 0:k.id),F(!0);try{await m.blockUser((S=s==null?void 0:s.user)==null?void 0:S.id),i&&await i((T=s==null?void 0:s.user)==null?void 0:T.id),h==null||h()}catch($){console.error(`[${f}] Failed to block member`,$)}finally{F(!1)}}},handleUnblockUser:async()=>{var k,S,T;if(!(C||!m)){o==null||o(),x&&console.log(`[${f}] Unblock member`,(k=s==null?void 0:s.user)==null?void 0:k.id),F(!0);try{await m.unBlockUser((S=s==null?void 0:s.user)==null?void 0:S.id),i&&await i((T=s==null?void 0:s.user)==null?void 0:T.id),h==null||h()}catch($){console.error(`[${f}] Failed to unblock member`,$)}finally{F(!1)}}},handleReportUser:()=>{d==null||d(),h==null||h(),window.open(gs,"_blank","noopener,noreferrer")}}},re=({variant:e="default",className:s,children:n,...a})=>{const r=e==="danger";return t.jsx("button",{type:"button",className:y("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})},Nt=({channel:e,participant:s,showDeleteConversation:n=!0,showBlockParticipant:a=!0,showReportParticipant:r=!0,onLeaveConversation:i,onBlockParticipant:l,onDeleteConversationClick:o,onBlockParticipantClick:d,onReportParticipantClick:h,customChannelActions:f,triggerClassName:m})=>{const[x,c]=u.useState(!1),g=u.useRef(null),_=u.useId(),j=u.useCallback(()=>c(!1),[]),{isParticipantBlocked:p,isCheckingBlockedStatus:b,isLeaving:A,isUpdatingBlockStatus:M,handleLeaveConversation:C,handleBlockUser:F,handleUnblockUser:z,handleReportUser:D}=bs({channel:e,participant:s,showBlockParticipant:a,enabled:x,onLeaveConversation:i,onBlockParticipant:l,onDeleteConversationClick:o,onBlockParticipantClick:d,onReportParticipantClick:h,onActionComplete:j,logLabel:"ChannelActionsMenu"});return u.useEffect(()=>{if(!x)return;const L=P=>{g.current&&!g.current.contains(P.target)&&c(!1)},R=P=>{P.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",L),document.addEventListener("keydown",R),()=>{document.removeEventListener("mousedown",L),document.removeEventListener("keydown",R)}},[x]),!s||!(n||a||r||!!f)?null:t.jsxs("div",{ref:g,className:"relative",children:[t.jsxs("button",{className:m,type:"button","aria-haspopup":"true","aria-expanded":x,"aria-controls":x?_:void 0,onClick:()=>c(L=>!L),children:[t.jsx(w.DotsThreeIcon,{className:"size-5 text-black/90"}),t.jsx("span",{className:"sr-only",children:"More options"})]}),x&&t.jsx("div",{id:_,"aria-label":"Conversation options",className:y("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(re,{onClick:C,disabled:A,"aria-busy":A,children:[A?t.jsx(w.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):t.jsx(w.SignOutIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Delete Conversation"})]})}),a&&t.jsx("li",{children:b?t.jsxs(re,{disabled:!0,"aria-busy":!0,children:[t.jsx(w.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}),t.jsx("span",{children:"Block"})]}):p?t.jsxs(re,{onClick:z,disabled:M,"aria-busy":M,children:[M?t.jsx(w.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):t.jsx(w.ProhibitInsetIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Unblock"})]}):t.jsxs(re,{onClick:F,disabled:M,"aria-busy":M,children:[M?t.jsx(w.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):t.jsx(w.ProhibitInsetIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Block"})]})}),r&&t.jsx("li",{children:t.jsxs(re,{variant:"danger",onClick:D,children:[t.jsx(w.FlagIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Report"})]})}),f]})})]})},ps=e=>t.jsx(N.DateSeparator,{...e,position:"center"}),Me="vote_up",Re="vote_down";function vs(e){return e!=null&&e.length?e.some(s=>s.type===Re)?"down":e.some(s=>s.type===Me)?"up":null:null}function Tt(e){const{channel:s}=N.useChannelStateContext(),{client:n}=N.useChatContext("useMessageVote"),a=u.useMemo(()=>vs(e.own_reactions),[e.own_reactions]),r=u.useCallback(async()=>{if(n!=null&&n.userID)try{a==="up"?await s.deleteReaction(e.id,Me):await s.sendReaction(e.id,{type:Me},{enforce_unique:!0,skip_push:!0})}catch{}},[s,n==null?void 0:n.userID,e.id,a]),i=u.useCallback(async()=>{if(n!=null&&n.userID)try{a==="down"?await s.deleteReaction(e.id,Re):await s.sendReaction(e.id,{type:Re},{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 Mt(e){return(e==null?void 0:e.trim().toLowerCase().split(/[-_]/)[0])||void 0}function ze({message:e,viewerLanguage:s}){var r;const n=e==null?void 0:e.text,a=Mt(s);return a?((r=e==null?void 0:e.i18n)==null?void 0:r[`${a}_text`])??n:n}const js=u.lazy(()=>Promise.resolve().then(()=>require("./Card-ffFBtGq1.cjs"))),ws=u.lazy(()=>Promise.resolve().then(()=>require("./Card-BVo5bHm8.cjs"))),Ns=u.lazy(()=>Promise.resolve().then(()=>require("./Card-ChLOPFzW.cjs"))),Oe=()=>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}),_s=e=>t.jsx(u.Suspense,{fallback:t.jsx(Oe,{}),children:t.jsx(js,{...e})}),Rt=e=>t.jsx(u.Suspense,{fallback:t.jsx(Oe,{}),children:t.jsx(ws,{...e})}),At=e=>t.jsx(u.Suspense,{fallback:t.jsx(Oe,{}),children:t.jsx(Ns,{...e})}),ys=Rt,Cs=At,Ae={Composer:_s,Sent:Rt,Received:At,Creator:ys,Visitor:Cs},ks=[[/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 te(e){return e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.startsWith("image/")?"image":"document"}function Lt(e){const s=ks.find(([n])=>n.test(e));return s?s[1]:"generic"}const Ss={video:w.VideoCameraIcon,audio:w.SpeakerHighIcon,image:w.ImageIcon,document:w.FileIcon},Is={pdf:w.FilePdfIcon,doc:w.FileDocIcon,xls:w.FileXlsIcon,csv:w.FileCsvIcon,ppt:w.FilePptIcon,zip:w.FileZipIcon,text:w.FileTextIcon,markdown:w.FileMdIcon,generic:w.FileIcon};function Es(e){const s=te(e);return s!=="document"?Ss[s]:Is[Lt(e)]}function ne(e,s){return u.createElement(Es(e),s)}const Ts=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},Ms=({source:e,mimeType:s,poster:n,autoPlay:a=!1,playing:r,loop:i=!1,controls:l=!0,showProgress:o=!1,muted:d=!1,onContainerClick:h})=>{const f=te(s),m=u.useRef(null),x=u.useRef(null),c=u.useRef(null),g=u.useRef(r),[_,j]=u.useState(a),[p,b]=u.useState(0),[A,M]=u.useState(!1),[C,F]=u.useState(!1),[z,D]=u.useState(!1),[I,L]=u.useState(!1),[R,P]=u.useState(!0),[k,S]=u.useState(null),T=u.useCallback(()=>{D(!1),j(!0)},[]),$=u.useCallback(v=>{const E=x.current;if(!E)return 0;const U=E.getBoundingClientRect();return Math.max(0,Math.min(1,(Ts(v)-U.left)/U.width))},[]),O=u.useCallback(v=>{const E=m.current;E&&E.duration&&(E.currentTime=v*E.duration)},[]),V=v=>{v.stopPropagation(),M(!0);const E=$(v);b(E),O(E)};u.useEffect(()=>{r!==void 0&&r!==g.current&&(g.current=r,j(r))},[r]),u.useEffect(()=>{if(!_){c.current!==null&&(cancelAnimationFrame(c.current),c.current=null);return}const v=()=>{const E=m.current;E&&E.duration&&!A&&b(E.currentTime/E.duration),c.current=requestAnimationFrame(v)};return c.current=requestAnimationFrame(v),()=>{c.current!==null&&cancelAnimationFrame(c.current)}},[_,A]),u.useEffect(()=>{const v=m.current;v&&(_?v.play().catch(E=>{j(!1),D(!0)}):v.pause())},[_]),u.useEffect(()=>{if(!A)return;const v=U=>b($(U)),E=U=>{M(!1),O($(U))};return window.addEventListener("mousemove",v),window.addEventListener("mouseup",E),window.addEventListener("touchmove",v,{passive:!0}),window.addEventListener("touchend",E),()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",E),window.removeEventListener("touchmove",v),window.removeEventListener("touchend",E)}},[A,$,O]);const J=k?{aspectRatio:String(k)}:void 0,W=k?"":" aspect-video",G=Math.round(p*100);return t.jsxs("div",{role:"button",tabIndex:0,className:`relative cursor-pointer overflow-hidden bg-black ${W}`,style:J,onClick:v=>{if(h){h(v);return}z||l&&j(E=>!E)},onKeyDown:v=>{if(!(v.key!=="Enter"&&v.key!==" ")){if(v.preventDefault(),h){h(v);return}z||l&&j(E=>!E)}},children:[n&&(f==="audio"||R)&&t.jsx("img",{src:n,alt:"",className:"absolute inset-0 h-full w-full object-cover"}),!n&&(f==="audio"||R)&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:ne(s,{className:"size-12 text-black/20",weight:"regular"})}),t.jsx("div",{className:"absolute inset-0",children:f==="audio"?t.jsx("audio",{ref:m,src:e,loop:i,muted:d,style:{width:"100%",height:"100%"},onLoadStart:()=>L(!0),onCanPlay:()=>{L(!1),P(!1)},onWaiting:()=>L(!0),onPlay:()=>D(!1),onEnded:()=>{i||(j(!1),b(0))},children:t.jsx("track",{kind:"captions"})}):t.jsx("video",{ref:m,src:e,loop:i,muted:d,playsInline:!0,style:{width:"100%",height:"100%"},onLoadStart:()=>L(!0),onCanPlay:()=>{L(!1),P(!1)},onWaiting:()=>L(!0),onPlay:()=>D(!1),onLoadedMetadata:()=>{const v=m.current;v instanceof HTMLVideoElement&&v.videoWidth&&v.videoHeight&&S(v.videoWidth/v.videoHeight)},onEnded:()=>{i||(j(!1),b(0))},children:t.jsx("track",{kind:"captions"})})}),I&&!z&&t.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:t.jsx(w.CircleNotchIcon,{className:"size-8 animate-spin text-white/80",weight:"bold"})}),z&&!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:v=>{v.stopPropagation(),T()},onKeyDown:v=>{v.key!=="Enter"&&v.key!==" "||(v.preventDefault(),v.stopPropagation(),T())},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(w.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":G,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:x,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:V,onTouchStart:V,onClick:v=>v.stopPropagation(),onKeyDown:v=>{v.key==="ArrowRight"&&O(Math.min(1,p+.05)),v.key==="ArrowLeft"&&O(Math.max(0,p-.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:`${G}%`}})})})}),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:v=>{v.stopPropagation(),j(E=>!E)},className:"shrink-0 text-white","aria-label":_?"Pause":"Play",children:_?t.jsx(w.PauseIcon,{className:"size-5",weight:"fill"}):t.jsx(w.PlayIcon,{className:"size-5 translate-x-px",weight:"fill"})}),t.jsxs("div",{role:"slider","aria-label":"Playback position","aria-valuenow":G,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:x,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:V,onTouchStart:V,onClick:v=>v.stopPropagation(),onMouseEnter:()=>F(!0),onMouseLeave:()=>F(!1),onKeyDown:v=>{v.key==="ArrowRight"&&O(Math.min(1,p+.05)),v.key==="ArrowLeft"&&O(Math.max(0,p-.05))},children:[t.jsx("div",{className:`w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${C||A?"h-1.5":"h-1"}`,children:t.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${G}%`}})}),t.jsx("div",{className:`absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${C||A?"scale-100 opacity-100":"scale-0 opacity-0"}`,style:{left:`${G}%`}})]})]})]})},_t=e=>e==="dark"?"size-12 text-white/20":"size-12 text-black/20",Rs=e=>e==="dark"?"aspect-video overflow-hidden bg-white/10":"aspect-video overflow-hidden bg-black/5",Fe=({mimeType:e,sourceUrl:s,thumbnailUrl:n,title:a,variant:r,mediaPlayerProps:i,containedImage:l=!1})=>{const o=te(e),[d,h]=u.useState(!1);return s&&(o==="video"||o==="audio")?t.jsx(Ms,{source:s,mimeType:e,poster:n,controls:!0,...i}):s&&o==="image"?l?t.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:t.jsx("img",{src: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:()=>h(!0)})}):t.jsx("img",{src: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: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:()=>h(!0)})}):t.jsx("img",{src: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:ne(e,{className:_t(r),weight:"regular"})}):n?t.jsx("div",{className:`relative ${Rs(r)}`,children:t.jsx("img",{src: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:ne(e,{className:_t(r),weight:"regular"})})},Dt=({variant:e,thumbnail:s,title:n,placeholderTitle:a="Attachment title",mimeType:r,detail:i,statusBadge:l,action:o,topLeft:d,topRight:h,rootRef:f,"data-testid":m})=>{const x=e==="dark",c=x?n??a:n??"",g=x&&!n;return t.jsxs("div",{ref:f,"data-testid":m,className:y("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)]",x?"bg-[#121110]":"bg-white"),children:[d?t.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-50",children:d}):null,h?t.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-50",children:h}):null,s,t.jsxs("div",{className:"px-4 pb-3 pt-3",children:[c.trim()!==""&&t.jsx("p",{className:y("mb-0.5 truncate text-base font-medium",{"text-black":!x,"text-white/30":x&&g,"text-white":x&&!g}),children:c}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[ne(r,{className:y("size-5 shrink-0",x?"text-white/55":"text-black/55"),weight:"regular"}),i!=null&&i!==""&&t.jsx("span",{className:y("text-xs font-medium",x?"text-white/55":"text-black/55"),children:i}),l]}),o]})]})};function Pt(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function $e(e){return`w-[280px] select-none overflow-hidden rounded-[24px] ${e?"bg-[#121110]":"bg-[#F3F3F1]"} shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]`}function As(e){return e?"bg-white/10":"bg-black/5"}function Ls(e){return e?"text-white":"text-black"}function Ds(e){return e?"text-white/55":"text-black/55"}function Ps(e){return e?"text-white/40":"text-black/40"}function zs(e){return e?"text-white/20":"text-black/20"}const Be=({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,h=t.jsxs(u.Fragment,{children:[t.jsx("div",{className:"p-2",children:r?t.jsx("img",{src:r,alt:n??"",className:"aspect-video w-full rounded-[20px] object-cover"}):t.jsx("div",{className:`aspect-video w-full rounded-[20px] ${As(s)} flex items-center justify-center`,children:t.jsx(w.LinkIcon,{className:`size-12 ${zs(s)}`})})}),t.jsxs("div",{className:"px-3 pb-3",children:[n&&t.jsx("p",{className:`truncate text-[14px] font-medium leading-5 ${Ls(s)}`,children:n}),a&&t.jsx("p",{className:`truncate text-[12px] leading-4 ${Ds(s)}`,children:a}),d&&t.jsx("p",{className:`mt-1 truncate text-[12px] leading-4 ${Ps(s)}`,children:d})]})]});return d?t.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"block no-underline",children:h}):t.jsx("div",{className:"block",children:h})};function Ue(e){return e.type==="link"||!!e.og_scrape_url&&!e.asset_url}function Ne(e){var s;return(s=e.attachments)==null?void 0:s.find(Ue)}async function Os(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 Fs=({url:e,filename:s})=>{const[n,a]=u.useState(!1),r=i=>{i.stopPropagation();const l=window.open("","_blank","noopener,noreferrer");a(!0),Os(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(w.CircleNotchIcon,{className:"size-4 animate-spin text-white",weight:"bold"}):t.jsxs(u.Fragment,{children:[t.jsx(w.DownloadSimpleIcon,{className:"size-4 text-white",weight:"bold"}),"Download"]})})};function _e(e){var m,x,c,g;const s=(m=e.attachments)==null?void 0:m.find(_=>_.type==="video"&&_.asset_url),n=(x=e.attachments)==null?void 0:x.find(_=>_.type==="image"&&_.image_url),a=(c=e.attachments)==null?void 0:c.find(_=>_.type==="audio"&&_.asset_url),r=(g=e.attachments)==null?void 0:g.find(_=>_.type==="file"&&_.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,h=i==null?void 0:i.file_size,f=s==null?void 0:s.thumb_url;return{resolvedUrl:l,resolvedType:o,title:d,fileSize:h,thumbnailUrl:f}}const zt=({resolvedUrl:e,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=a!==void 0?Pt(a):void 0;return t.jsx(Dt,{variant:"dark",title:n,placeholderTitle:"",mimeType:s,detail:i,thumbnail:t.jsx(Fe,{mimeType:s,sourceUrl:e,thumbnailUrl:r,title:n,variant:"dark"})})},Ot=({resolvedUrl:e,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=te(s),l=a!==void 0?Pt(a):void 0;return t.jsx(Dt,{variant:"light",title:n,mimeType:s,detail:l,thumbnail:t.jsx(Fe,{mimeType:s,sourceUrl:e,thumbnailUrl:r,title:n,variant:"light",containedImage:i==="image"||i==="document"}),action:t.jsx(Fs,{url:e,filename:n})})},$s=({message:e,isMyMessage:s=!1})=>{const n=Ne(e),a=_e(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,children:[!s&&e.user&&t.jsx(Q,{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",style:{padding:0,borderRadius:0,overflow:"visible",background:"transparent"},children:n?t.jsx("div",{className:$e(s),children:t.jsx(Be,{attachment:n,isMyMessage:s})}):s?t.jsx(zt,{...a}):t.jsx(Ot,{...a})})})})]})},Bs=({message:e})=>{const s=Ne(e);if(s)return t.jsx("div",{className:$e(!0),children:t.jsx(Be,{attachment:s,isMyMessage:!0})});const n=_e(e);return n?t.jsx(zt,{...n}):null},Us=({message:e})=>{const s=Ne(e);if(s)return t.jsx("div",{className:$e(!1),children:t.jsx(Be,{attachment:s,isMyMessage:!1})});const n=_e(e);return n?t.jsx(Ot,{...n}):null},Vs=Object.assign($s,{Creator:Bs,Visitor:Us}),Gs={isUnlocking:()=>!1},Hs={LockedAttachment:Gs},Ft=u.createContext({}),Ys=Ft.Provider;function $t(e){return u.useContext(Ft)[e]??Hs[e]}const qs=({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})}),Xs=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)==="MESSAGE_TIP"},Ws=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)==="MESSAGE_PAID"},pe=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)==="MESSAGE_CHATBOT"},Ks=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)==="MESSAGE_ATTACHMENT"},Bt=e=>Xs(e)||Ws(e),Js=e=>{var s;return Bt(e)&&!((s=e.text)!=null&&s.trim())},ke=({message:e,standalone:s=!1,isMyMessage:n=!1,hasAttachment:a=!1})=>{var m;const r=Bt(e),i=pe(e);if(!r&&!i)return null;if(r){const x=(m=e.metadata)==null?void 0:m.amount_text;if(!x)return null;const c=s?"message-tip-standalone":"message-tag message-tag--tip",g=s?`${x} tip`:`Delivered with ${x} tip`;return t.jsxs("div",{className:c,children:[t.jsx(w.GiftIcon,{size:s?14:12}),t.jsx("span",{children:g})]})}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(" "),h=t.jsx("span",{className:"message-chatbot-indicator__label",children:o}),f=t.jsx("span",{className:"message-chatbot-indicator__icon",children:t.jsx(qs,{size:l?12:15})});return t.jsx("div",{className:d,"data-testid":"message-chatbot-indicator",children:n&&!l?t.jsxs(t.Fragment,{children:[h,f]}):t.jsxs(t.Fragment,{children:[f,h]})})},Ut=({selected:e,onVoteUp:s,onVoteDown:n})=>t.jsxs("div",{className:"message-vote-buttons",children:[t.jsx("button",{type:"button",className:y("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(w.ThumbsUpIcon,{size:16,weight:e==="up"?"fill":"regular"})}),t.jsx("button",{type:"button",className:y("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(w.ThumbsDownIcon,{size:16,weight:e==="down"?"fill":"regular"})})]}),Zs=e=>{var at,rt,it,ot,lt,ct,dt,ut,mt,ht,xt,ft,gt,bt;const{additionalMessageInputProps:s,chatbotVotingEnabled:n,editing:a,endOfGroup:r,firstOfGroup:i,groupedByUser:l,handleAction:o,handleOpenThread:d,handleRetry:h,highlighted:f,isMessageAIGenerated:m,isMyMessage:x,message:c,renderText:g,threadList:_,viewerLanguage:j}=e,{client:p}=N.useChatContext("CustomMessage"),{channel:b}=N.useChannelStateContext("CustomMessage"),{isUnlocking:A,onUnlockClick:M,onFetchSource:C,onDownloadClick:F}=$t("LockedAttachment"),[z,D]=u.useState(!1),I=N.useMessageReminder(c.id),{selected:L,voteUp:R,voteDown:P}=Tt(c),{Attachment:k=N.Attachment,EditMessageModal:S=N.EditMessageModal,MessageActions:T,MessageBlocked:$=N.MessageBlocked,MessageBouncePrompt:O=N.MessageBouncePrompt,MessageDeleted:V=N.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:J=N.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:W=N.MessageRepliesCountButton,ReminderNotification:G=N.ReminderNotification,StreamedMessageText:v=N.StreamedMessageText,PinIndicator:E}=N.useComponentContext("CustomMessage"),U=N.messageHasAttachments(c),H=N.messageHasReactions(c),Y=u.useMemo(()=>m==null?void 0:m(c),[m,c]),B=u.useMemo(()=>{const de=c.attachments??[],ge=c.shared_location?[c.shared_location,...de]:de;if(!pe(c))return ge;const pt=ge.filter(vt=>!("type"in vt)||!Ue(vt));return pt.length===ge.length?ge:pt},[c]),q=u.useMemo(()=>{const de=ze({message:c,viewerLanguage:j});return de===c.text?c:{...c,text:de}},[c,j]);if(N.isDateSeparatorMessage(c))return null;if(c.deleted_at||c.type==="deleted")return t.jsx(V,{message:c});if(N.isMessageBlocked(c))return t.jsx($,{});const X=!_&&!!c.reply_count,ie=!_&&c.show_in_channel&&c.parent_id,oe=c.status==="failed"&&((at=c.error)==null?void 0:at.status)!==403,le=N.isMessageBounced(c);let K;oe?K=()=>h(c):le&&(K=()=>D(!0));const Z=x(),se=y("str-chat__message str-chat__message-simple",`str-chat__message--${c.type}`,`str-chat__message--${c.status}`,Z?"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":U,"str-chat__message--highlighted":f,"str-chat__message--pinned pinned-message":c.pinned,"str-chat__message--with-reactions":H,"str-chat__message-send-can-be-retried":(c==null?void 0:c.status)==="failed"&&((rt=c==null?void 0:c.error)==null?void 0:rt.status)!==403,"str-chat__message-with-thread-link":X||ie,"str-chat__virtual-message__wrapper--end":r,"str-chat__virtual-message__wrapper--first":i,"str-chat__virtual-message__wrapper--group":l}),et=c.poll_id&&p.polls.fromState(c.poll_id),tt=Js(c),ce=pe(c),st=Ks(c),Ce=!!(B!=null&&B.length&&!c.quoted_message),nt=ce&&Z&&Ce;return t.jsxs(t.Fragment,{children:[a&&t.jsx(S,{additionalMessageInputProps:s}),z&&t.jsx(N.MessageBounceModal,{MessageBouncePrompt:O,onClose:()=>D(!1),open:z}),t.jsxs("div",{className:se,"data-message-id":c.id,children:[E&&t.jsx(E,{}),!!I&&t.jsx(G,{reminder:I}),c.user&&t.jsx(Q,{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:ce}),t.jsx("div",{className:y("str-chat__message-inner",{"str-chat__simple-message--error-failed":oe||le}),"data-testid":"message-inner",onClick:K,onKeyDown:K,role:K?"button":void 0,tabIndex:K?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:st?t.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[Z?t.jsxs("div",{className:"flex items-center gap-2",children:[T&&t.jsx(T,{}),t.jsx(Ae.Sent,{title:(it=c.metadata)==null?void 0:it.attachment_title,mimeType:(ot=c.metadata)==null?void 0:ot.attachment_mime_type,thumbnailUrl:(lt=c.metadata)==null?void 0:lt.attachment_thumbnail,amountText:(ct=c.metadata)==null?void 0:ct.amount_text,detail:(dt=c.metadata)==null?void 0:dt.attachment_detail,paymentStatus:(ut=c.metadata)==null?void 0:ut.payment_status,onPreviewClick:()=>M==null?void 0:M(c,b),onFetchSource:async()=>await(C==null?void 0:C(c,b))})]}):t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ae.Received,{title:(mt=c.metadata)==null?void 0:mt.attachment_title,mimeType:(ht=c.metadata)==null?void 0:ht.attachment_mime_type,thumbnailUrl:(xt=c.metadata)==null?void 0:xt.attachment_thumbnail,amountText:(ft=c.metadata)==null?void 0:ft.amount_text,detail:(gt=c.metadata)==null?void 0:gt.attachment_detail,paymentStatus:(bt=c.metadata)==null?void 0:bt.payment_status,isUnlocking:A(c.id),onUnlockClick:()=>M==null?void 0:M(c,b),onFetchSource:async()=>await(C==null?void 0:C(c,b)),onDownloadClick:()=>F==null?void 0:F(c,b)}),T&&t.jsx(T,{})]}),c.text&&t.jsx("div",{className:"str-chat__message-bubble",children:t.jsx(N.MessageText,{message:q,renderText:g})})]}):tt?t.jsx(ke,{message:c,standalone:!0}):t.jsx("div",{className:"str-chat__message-bubble-wrapper",children:t.jsxs("div",{className:"str-chat__message-bubble",children:[ce&&!nt&&t.jsx(ke,{message:c,hasAttachment:Ce,isMyMessage:Z}),et&&t.jsx(N.Poll,{poll:et}),B!=null&&B.length&&!c.quoted_message?t.jsx(k,{actionHandler:o,attachments:B}):null,Y?t.jsx(v,{message:q,renderText:g}):t.jsx(N.MessageText,{message:q,renderText:g}),t.jsx(N.MessageErrorIcon,{})]})})}),!st&&!tt&&t.jsxs("div",{className:"str-chat__message-footer",children:[(!ce||nt)&&t.jsx(ke,{message:c,hasAttachment:Ce,isMyMessage:Z}),n&&ce&&t.jsx(Ut,{selected:L,onVoteUp:R,onVoteDown:P})]}),X&&t.jsx(W,{onClick:d,reply_count:c.reply_count}),ie&&t.jsx(J,{})]},c.id)]})},Qs=u.memo(Zs,(e,s)=>e.chatbotVotingEnabled!==s.chatbotVotingEnabled||e.viewerLanguage!==s.viewerLanguage?!1:N.areMessageUIPropsEqual(e,s)),en=e=>{const s=N.useMessageContext("CustomMessage");return t.jsx(Qs,{...s,...e})},tn=()=>{var n;const{handleDelete:e,message:s}=N.useMessageContext("CustomMessageActions");return((n=s.metadata)==null?void 0:n.payment_status)==="paid"?null:t.jsx(Le.DefaultDropdownActionButton,{onClick:e,"aria-label":"Delete",title:"Delete",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:t.jsx(w.TrashSimpleIcon,{size:16,weight:"light","aria-hidden":!0})})},sn=()=>{const{handleFlag:e}=N.useMessageContext("CustomMessageActions");return t.jsx(Le.DefaultDropdownActionButton,{onClick:e,"aria-label":"Report",title:"Report",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:t.jsx(w.FlagIcon,{size:16,weight:"light","aria-hidden":!0})})},nn=()=>{var s;const{message:e}=N.useMessageContext("CustomMessageActions");return((s=e.metadata)==null?void 0:s.custom_type)!=="MESSAGE_ATTACHMENT"?null:t.jsx(Le.MessageActions,{messageActionSet:[{Component:tn,placement:"quick",type:"delete"},{Component:sn,placement:"quick",type:"flag"}]})},an=({link:e,onDismiss:s})=>{const{og_scrape_url:n,title:a,image_url:r}=e,i=l=>{l.preventDefault(),s(n)};return t.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"relative block w-full rounded-[24px] bg-[#121110] p-2 no-underline transition-opacity hover:opacity-90",children:[r&&t.jsx("img",{src:r,alt:a||"",className:"h-[180px] w-full rounded-[20px] object-cover"}),t.jsx("button",{type:"button",onClick:i,className:"absolute right-4 top-4 flex size-6 items-center justify-center rounded-full border border-white/40 bg-white/70 backdrop-blur-2xl focus-ring","aria-label":"Close link preview",children:t.jsx(w.XIcon,{className:"size-4 text-black/90"})}),t.jsxs("div",{className:"p-2",children:[a&&t.jsx("div",{className:"truncate text-[14px] font-medium leading-5 text-white",children:a}),t.jsx("div",{className:"truncate text-[12px] leading-4 text-white/55",children:n})]})]})},rn=e=>({linkPreviews:Array.from(e.previews.values()).filter(s=>Te.LinkPreviewsManager.previewIsLoaded(s)||Te.LinkPreviewsManager.previewIsLoading(s))}),on=()=>{const{linkPreviewsManager:e}=N.useMessageComposer(),{linkPreviews:s}=N.useStateStore(e.state,rn),n=r=>{e.dismissPreview(r)};return s.length>0?t.jsx("div",{className:"flex flex-col items-stretch w-full gap-2 mb-4",children:s.map(r=>t.jsx(an,{link:r,onDismiss:n},r.og_scrape_url))}):null},Ve=u.createContext(!1),ln=()=>u.useContext(Ve),cn=({sendMessage:e,disabled:s,...n})=>t.jsx("button",{...n,type:"button","aria-label":"Send",disabled:s,onClick:e,children:t.jsx(w.ArrowUpIcon,{weight:"bold",className:"size-4"})}),dn=()=>{const e=u.useContext(Ve),{handleSubmit:s}=N.useMessageInputContext(),n=N.useMessageComposerHasSendableData(),a=e||!n,{SendButton:r=cn,AttachmentPreviewList:i=N.AttachmentPreviewList}=N.useComponentContext("CustomMessageInput");return t.jsxs("div",{className:"central-container flex flex-col gap-2 min-w-0 w-full p-2 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)]",children:[t.jsx(N.QuotedMessagePreview,{}),t.jsx(on,{}),t.jsx(i,{}),t.jsxs("div",{className:"flex",children:[t.jsx("div",{className:"w-full ml-2 mr-4 self-center leading-[0]",children:t.jsx(N.TextareaComposer,{"aria-disabled":e||void 0,className:"w-full resize-none outline-none leading-5 placeholder:text-black/30 text-sm",autoFocus:!e,maxRows:4,readOnly:e,tabIndex:e?-1:void 0})}),t.jsx(r,{sendMessage:s,"aria-label":"Send",className:"str-chat__send-button mt-auto flex justify-center items-center flex-shrink-0 rounded-full size-8 bg-[#121110] disabled:bg-[#F1F0EE] disabled:text-black/20 text-white focus-ring","data-testid":"send-button",disabled:a,type:"button"})]})]})},un=({renderActions:e,renderFooter:s,disabled:n=!1,disabledReason:a,composerInput:r})=>{var o;const{channel:i}=N.useChannelStateContext(),l=((o=i==null?void 0:i.data)==null?void 0:o.frozen)===!0;return n?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:a?t.jsx("p",{className:"max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",children:a}):null}),s==null?void 0:s()]}):t.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[t.jsxs("div",{inert:l?"":void 0,"aria-disabled":l||void 0,className:"message-input flex 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(Ve.Provider,{value:l,children:t.jsx(N.MessageInput,{Input:r??dn})})]}),s==null?void 0:s()]})},mn=["SYSTEM_DM_AGENT_PAUSED","SYSTEM_DM_AGENT_RESUMED"],hn={SYSTEM_DM_AGENT_PAUSED:"DM Agent has left the conversation",SYSTEM_DM_AGENT_RESUMED:"DM Agent has rejoined the conversation"},xn=["SYSTEM_AGE_SAFETY_BLOCKED"],fn={SYSTEM_AGE_SAFETY_BLOCKED:"This user isn’t able to reply because they don’t meet our age safety guidelines."},Se="age safety guidelines.",gn="https://linktr.ee/s/about/contact",yt=e=>mn.includes(e),bn=e=>xn.includes(e),pn=e=>{var a;const s=(a=e.metadata)==null?void 0:a.custom_type;if(yt(s))return{kind:"dm-agent",type:s};if(bn(s))return{kind:"age-safety",type:s};const n=e.dm_agent_system_type;if(yt(n))return{kind:"dm-agent",type:n}},vn=e=>{const s=e.indexOf(Se);if(s===-1)return e;const n=s+Se.length;return t.jsxs(t.Fragment,{children:[e.slice(0,s),t.jsx("a",{href:gn,target:"_blank",rel:"noopener noreferrer",className:"mes-age-safety-system-message__emphasis font-medium text-inherit underline",children:Se}),e.slice(n)]})},jn=e=>{var a,r;const s=e.message.hide_date===!0,n=pn(e.message);if((n==null?void 0:n.kind)==="dm-agent"){const i=((a=e.message.text)==null?void 0:a.trim())||hn[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(w.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(N.MessageTimestamp,{message:e.message})]})}if((n==null?void 0:n.kind)==="age-safety"){const i=((r=e.message.text)==null?void 0:r.trim())||fn[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(w.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:vn(i)})})]}),!s&&t.jsx(N.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(N.MessageTimestamp,{message:e.message})]})},Vt=u.createContext(!1),Ie=({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"})}),wn=new Set([N.AIStates.Thinking,N.AIStates.Generating,N.AIStates.ExternalSources]),Nn=({threadList:e})=>{var g,_;const{channel:s,channelConfig:n,thread:a}=N.useChannelStateContext(),{client:r}=N.useChatContext(),{typing:i={}}=N.useTypingContext(),{aiState:l}=N.useAIState(s),o=u.useContext(Vt);if(!e&&o&&wn.has(l)){const j=_n(s,(g=r.user)==null?void 0:g.id);return t.jsx(Ct,{avatarId:(j==null?void 0:j.id)??"ai-agent",avatarName:(j==null?void 0:j.name)??(j==null?void 0:j.id)??"Agent",avatarImage:j==null?void 0:j.image,testId:"typing-indicator-ai"})}if((n==null?void 0:n.typing_events)===!1)return null;const h=e?[]:Object.values(i).filter(({parent_id:j,user:p})=>{var b;return(p==null?void 0:p.id)!==((b=r.user)==null?void 0:b.id)&&!j}),f=e?Object.values(i).filter(({parent_id:j,user:p})=>{var b;return(p==null?void 0:p.id)!==((b=r.user)==null?void 0:b.id)&&j===(a==null?void 0:a.id)}):[],m=e?f:h;if(!m.length)return null;const x=(_=m[0])==null?void 0:_.user,c=x!=null&&x.id&&s.state.members[x.id]?s.state.members[x.id].user:void 0;return t.jsx(Ct,{avatarId:(x==null?void 0:x.id)??(c==null?void 0:c.id)??"typing-user",avatarName:(x==null?void 0:x.name)??(c==null?void 0:c.name)??(x==null?void 0:x.id)??"Typing user",avatarImage:(x==null?void 0:x.image)??(c==null?void 0:c.image),testId:"typing-indicator"})},Ct=({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(Q,{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(Ie,{cx:"4",index:0}),t.jsx(Ie,{cx:"16",index:1}),t.jsx(Ie,{cx:"28",index:2})]})})})})})})]})});function _n(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 Gt=()=>null,yn=({className:e,message:s})=>t.jsxs("div",{className:y("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})]}),ve=u.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(yn,{className:"w-6 h-6"}),t.jsx("span",{className:"text-sm text-stone",children:"Loading messages"})]})}));ve.displayName="LoadingState";const ae="size-10 rounded-full hover:bg-[#E5E4E1] flex items-center justify-center transition-colors duration-150 focus-ring",be="Replies instantly with AI assistant",Cn=({onBack:e,showBackButton:s,showStarButton:n=!1,dmAgentEnabled:a=!1,onLeaveConversation:r,onBlockParticipant:i,showDeleteConversation:l=!0,showBlockParticipant:o=!0,showReportParticipant:d=!0,onDeleteConversationClick:h,onBlockParticipantClick:f,onReportParticipantClick:m,customChannelActions:x,renderChannelActions:c,showChannelInfo:g=!0,onParticipantNameClick:_,renderHeaderTitleBadges:j})=>{var R,P,k,S,T,$,O;const{channel:p}=N.useChannelStateContext(),b=u.useMemo(()=>{var W,G;const V=(W=p._client)==null?void 0:W.userID;return V?Object.values(((G=p.state)==null?void 0:G.members)||{}).find(v=>{var E;return((E=v.user)==null?void 0:E.id)&&v.user.id!==V}):void 0},[(R=p._client)==null?void 0:R.userID,(P=p.state)==null?void 0:P.members]),A=Pe(b==null?void 0:b.user),M=(k=b==null?void 0:b.user)==null?void 0:k.image,C=It(p),F=j==null?void 0:j({channel:p,participant:b}),z="flex max-w-full flex-col items-center gap-1 rounded-[12px] px-1 py-0.5 text-center text-xs font-medium text-black/90",D="flex min-w-0 max-w-full items-center gap-4 rounded-[12px] px-1 py-0.5 text-left text-black/90",I=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"min-w-0 truncate",children:A}),F&&t.jsx("span",{className:"shrink-0",children:F})]}),L=async()=>{try{C?await p.unpin():await p.pin()}catch(V){console.error("[CustomChannelHeader] Failed to update pinned status:",V)}};return t.jsxs("div",{className:"@container",children:[t.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] w-full items-center @lg:hidden px-6 py-3",children:[t.jsx("div",{className:"flex items-center gap-2",children:s&&t.jsx("button",{className:y(ae,"messaging-channel-view-back-button-mobile bg-[#F1F0EE]"),onClick:e||(()=>{}),type:"button","aria-label":"Back to conversations",children:t.jsx(w.ArrowLeftIcon,{className:"size-5 text-black/90"})})}),t.jsx("div",{className:"flex flex-col gap-1 items-center",children:_?t.jsxs("button",{type:"button",onClick:_,"aria-label":`View details for ${A}`,className:y(z,"appearance-none border-0 bg-transparent transition-opacity hover:opacity-70 focus-ring focus-visible:outline-none"),children:[t.jsx(Q,{id:((S=b==null?void 0:b.user)==null?void 0:S.id)||p.id||"unknown",name:A,image:M,starred:n&&C,dmAgentEnabled:a,size:48}),t.jsxs("span",{className:"flex max-w-full items-center gap-0.5",children:[I,t.jsx(w.CaretRightIcon,{className:"size-3 shrink-0",weight:"bold"})]}),a&&t.jsxs("div",{className:"flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[t.jsx(w.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),t.jsx("span",{children:be})]})]}):t.jsxs("div",{className:z,children:[t.jsx(Q,{id:((T=b==null?void 0:b.user)==null?void 0:T.id)||p.id||"unknown",name:A,image:M,starred:n&&C,dmAgentEnabled:a,size:48}),t.jsxs("p",{className:"flex max-w-full items-center justify-center gap-0.5",children:[I,t.jsx(w.CaretRightIcon,{className:"invisible size-3 shrink-0",weight:"bold"})]}),a&&t.jsxs("div",{className:"flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[t.jsx(w.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),t.jsx("span",{children:be})]})]})}),t.jsxs("div",{className:"flex justify-end items-center gap-2",children:[n&&t.jsx("button",{className:ae,onClick:L,type:"button","aria-label":C?"Unstar conversation":"Star conversation",children:t.jsx(w.StarIcon,{className:y("size-5",{"text-yellow-600":C,"text-black/90":!C}),weight:C?"duotone":"regular"})}),g&&(c!==void 0?c:t.jsx(Nt,{channel:p,participant:b,showDeleteConversation:l,showBlockParticipant:o,showReportParticipant:d,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:h,onBlockParticipantClick:f,onReportParticipantClick:m,customChannelActions:x,triggerClassName:y(ae,"bg-[#F1F0EE]")}))]})]}),t.jsxs("div",{className:"px-6 py-3 hidden @lg:flex items-center justify-between gap-3 min-h-12 border-b border-b-black/[0.08]",children:[t.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[s&&e&&t.jsx("button",{className:y(ae,"messaging-channel-view-back-button-desktop"),type:"button",onClick:e,"aria-label":"Back to conversations",children:t.jsx(w.ArrowLeftIcon,{className:"size-5 text-black/90"})}),_?t.jsxs("button",{type:"button",onClick:_,"aria-label":`View details for ${A}`,className:y(D,"appearance-none border-0 bg-transparent transition-opacity hover:opacity-70 focus-ring focus-visible:outline-none"),children:[t.jsx(Q,{id:(($=b==null?void 0:b.user)==null?void 0:$.id)||p.id||"unknown",name:A,image:M,starred:n&&C,dmAgentEnabled:a,size:48}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("h1",{className:"flex min-w-0 items-center gap-1 font-medium text-black/90",children:[I,t.jsx(w.CaretRightIcon,{className:"size-4 shrink-0",weight:"bold"})]}),a&&t.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[t.jsx(w.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),t.jsx("span",{className:"truncate",children:be})]})]})]}):t.jsxs("div",{className:D,children:[t.jsx(Q,{id:((O=b==null?void 0:b.user)==null?void 0:O.id)||p.id||"unknown",name:A,image:M,starred:n&&C,dmAgentEnabled:a,size:48}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("h1",{className:"flex min-w-0 items-center gap-1 font-medium text-black/90",children:[I,t.jsx(w.CaretRightIcon,{className:"invisible size-4 shrink-0",weight:"bold"})]}),a&&t.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[t.jsx(w.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),t.jsx("span",{className:"truncate",children:be})]})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[n&&t.jsx("button",{className:ae,onClick:L,type:"button","aria-label":C?"Unstar conversation":"Star conversation",children:t.jsx(w.StarIcon,{className:y("size-6",{"text-yellow-600":C,"text-black/90":!C}),weight:C?"duotone":"regular"})}),g&&(c!==void 0?c:t.jsx(Nt,{channel:p,participant:b,showDeleteConversation:l,showBlockParticipant:o,showReportParticipant:d,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:h,onBlockParticipantClick:f,onReportParticipantClick:m,customChannelActions:x,triggerClassName:ae}))]})]})]})},kn=({onBack:e,showBackButton:s,renderMessageInputActions:n,renderMessageInputFooter:a,renderConversationFooter:r,onLeaveConversation:i,onBlockParticipant:l,showDeleteConversation:o=!0,onDeleteConversationClick:d,onBlockParticipantClick:h,onReportParticipantClick:f,showBlockParticipant:m=!0,showReportParticipant:x=!0,composerDisabled:c=!1,composerDisabledReason:g,showStarButton:_=!1,chatbotVotingEnabled:j=!1,renderChannelBanner:p,renderHeaderTitleBadges:b,customChannelActions:A,renderChannelActions:M,renderMessage:C,dmAgentEnabled:F=!1,viewerLanguage:z,showChannelInfo:D=!0,onParticipantNameClick:I,composerInput:L})=>{var V,J,W,G,v,E;const{channel:R}=N.useChannelStateContext(),P=u.useMemo(()=>{var Y,B;const U=(Y=R._client)==null?void 0:Y.userID;return U?Object.values(((B=R.state)==null?void 0:B.members)||{}).find(q=>{var X;return((X=q.user)==null?void 0:X.id)&&q.user.id!==U}):void 0},[(V=R._client)==null?void 0:V.userID,(J=R.state)==null?void 0:J.members]),k=u.useMemo(()=>{var Y,B;const U=(Y=R._client)==null?void 0:Y.userID;return U?Object.values(((B=R.state)==null?void 0:B.members)||{}).find(q=>{var X;return((X=q.user)==null?void 0:X.id)===U}):void 0},[(W=R._client)==null?void 0:W.userID,(G=R.state)==null?void 0:G.members]),S=((v=k==null?void 0:k.user)==null?void 0:v.is_account)??(k==null?void 0:k.is_account),T=((E=P==null?void 0:P.user)==null?void 0:E.is_account)??(P==null?void 0:P.is_account),$=F&&S===!1&&T===!0,O=u.useCallback(U=>{const{message:H}=N.useMessageContext("ChannelView"),Y=t.jsx(en,{...U,chatbotVotingEnabled:j,viewerLanguage:z});return!C||!H?Y:C(Y,H)},[j,C,z]);return t.jsx(t.Fragment,{children:t.jsx(N.WithComponents,{overrides:{Message:O,MessageActions:nn},children:t.jsxs(N.Window,{children:[t.jsx("div",{children:t.jsx(Cn,{onBack:e,showBackButton:s,showChannelInfo:D,showStarButton:_,dmAgentEnabled:$,onLeaveConversation:i,onBlockParticipant:l,showDeleteConversation:o,showBlockParticipant:m,showReportParticipant:x,onDeleteConversationClick:d,onBlockParticipantClick:h,onReportParticipantClick:f,customChannelActions:A,renderChannelActions:M,onParticipantNameClick:I,renderHeaderTitleBadges:b})},"lt-channel-header"),p?t.jsx(u.Fragment,{children:p()},"lt-channel-banner"):null,t.jsx("div",{className:"flex-1 overflow-hidden relative",children:t.jsx(N.MessageList,{hideDeletedMessages:!0,hideNewMessageSeparator:!1})},"lt-channel-message-list"),r?t.jsx(u.Fragment,{children:r(R)},"lt-channel-conversation-footer"):null,t.jsx(un,{...n&&{renderActions:()=>n==null?void 0:n(R)},renderFooter:()=>a==null?void 0:a(R),disabled:c,disabledReason:g,composerInput:L},"lt-channel-message-input")]})})})},Ge=u.memo(({channel:e,onBack:s,showBackButton:n=!1,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:l,onBlockParticipant:o,className:d,CustomChannelEmptyState:h=Gt,showDeleteConversation:f=!0,onDeleteConversationClick:m,onBlockParticipantClick:x,onReportParticipantClick:c,showBlockParticipant:g=!0,showReportParticipant:_=!0,composerDisabled:j=!1,composerDisabledReason:p,dmAgentEnabled:b,messageMetadata:A,onMessageSent:M,showStarButton:C=!1,chatbotVotingEnabled:F=!1,renderChannelBanner:z,renderHeaderTitleBadges:D,customChannelActions:I,renderChannelActions:L,renderMessage:R,onMessageLinkClick:P,sendButton:k,attachmentPreviewList:S,viewerLanguage:T,showChannelInfo:$=!0,onParticipantNameClick:O,composerInput:V})=>{const J=u.useCallback(async(G,v,E)=>{var X;const U=((X=e.data)==null?void 0:X.chatbot_paused)===!0,H=b&&!U,Y={...v,...H&&{silent:!0},...A&&{metadata:{...v.metadata??{},...A}}},B={...E,...H&&{skip_push:!0}},q=await e.sendMessage(Y,B);return M==null||M(q),q},[e,b,A,M]),W=u.useRef(null);return u.useEffect(()=>{if(!P)return;const G=W.current;if(!G)return;const v=E=>{const U=E.target,H=U==null?void 0:U.closest("a[href]"),Y=H==null?void 0:H.getAttribute("href");if(!Y)return;const B=H==null?void 0:H.closest("[data-message-id]"),q=B==null?void 0:B.getAttribute("data-message-id"),X=q?e.state.messages.find(ie=>ie.id===q):void 0;P(Y,X)};return G.addEventListener("click",v),()=>G.removeEventListener("click",v)},[P,e]),t.jsx("div",{ref:W,className:y("messaging-channel-view h-full flex flex-col",d),children:t.jsx(Vt.Provider,{value:b??!1,children:t.jsx(N.Channel,{channel:e,MessageSystem:jn,EmptyStateIndicator:h,LoadingIndicator:ve,DateSeparator:ps,TypingIndicator:Nn,doSendMessageRequest:J,...k?{SendButton:k}:{},...S?{AttachmentPreviewList:S}:{},children:t.jsx(kn,{onBack:s,showBackButton:n,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:l,onBlockParticipant:o,CustomChannelEmptyState:h,showDeleteConversation:f,onDeleteConversationClick:m,onBlockParticipantClick:x,onReportParticipantClick:c,showBlockParticipant:g,showReportParticipant:_,composerDisabled:j,composerDisabledReason:p,showStarButton:C,dmAgentEnabled:b,chatbotVotingEnabled:F,renderChannelBanner:z,renderHeaderTitleBadges:D,customChannelActions:I,renderChannelActions:L,renderMessage:R,viewerLanguage:T,showChannelInfo:$,onParticipantNameClick:O,composerInput:V})})})})});Ge.displayName="ChannelView";const ue=u.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"})]})}));ue.displayName="ErrorState";const Sn=({capabilities:e={},renderMessageInputActions:s,renderConversationFooter:n,onChannelSelect:a,onExitConversation:r,initialParticipantFilter:i,initialParticipantData:l,CustomChannelEmptyState:o,onBlockParticipantClick:d,onReportParticipantClick:h,dmAgentEnabled:f,onMessageSent:m,chatbotVotingEnabled:x=!1,viewerLanguage:c,renderHeaderTitleBadges:g,renderChannelBanner:_,customChannelActions:j,renderChannelActions:p,onParticipantNameClick:b,renderMessage:A,onMessageLinkClick:M,showChannelInfo:C,composerInput:F})=>{const{client:z,isConnected:D,isLoading:I,error:L,refreshConnection:R,service:P,debug:k}=St(),[S,T]=u.useState(null),[$,O]=u.useState(null),[V,J]=u.useState(!1),{showDeleteConversation:W=!0}=e,G=u.useRef(l);G.current=l;const v=u.useRef(a);v.current=a;const E=u.useRef(null),U=u.useRef(null);u.useEffect(()=>{U.current=S},[S]),u.useEffect(()=>{if(!z||!D)return;const B=z.userID;if(!B)return;const q=`${B}::${i}`;if(E.current===q)return;E.current=q;const X=()=>{E.current===q&&(E.current=null)};(async()=>{var oe,le;try{k&&console.log("[MessagingShell] Loading initial conversation with:",i);const K=await z.queryChannels({type:"messaging",members:{$eq:[B,i]}},{},{limit:1});if(K.length>0){T(K[0]),O(null),(oe=v.current)==null||oe.call(v,K[0]),k&&console.log("[MessagingShell] Initial conversation loaded:",K[0].id);return}const Z=G.current;if(!Z||!P){X(),O("No conversation found with this account"),k&&console.log("[MessagingShell] No conversation found for:",i);return}try{const se=await P.startChannelWithParticipant({id:Z.id,name:Z.name,phone:Z.phone});T(se),O(null),(le=v.current)==null||le.call(v,se),k&&console.log("[MessagingShell] Channel created and loaded:",se.id)}catch(se){console.error("[MessagingShell] Failed to create conversation:",se),X(),O("Failed to create conversation")}}catch(K){console.error("[MessagingShell] Failed to load initial conversation:",K),X(),U.current||O("Failed to load conversation")}})()},[i,z,D,P,k]);const H=u.useRef(r);H.current=r;const Y=u.useCallback(()=>{var B;T(null),J(!0),(B=H.current)==null||B.call(H)},[]);return I?t.jsx(ve,{}):L?t.jsx(ue,{message:L,onBack:R}):!D||!z?t.jsx(ue,{message:"Not connected to messaging service",onBack:R}):$?t.jsx(ue,{message:$}):V&&!S?t.jsx(ue,{message:"Conversation ended"}):S?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(Ge,{channel:S,renderMessageInputActions:s,renderConversationFooter:n,renderChannelBanner:_,onLeaveConversation:Y,onBlockParticipant:Y,CustomChannelEmptyState:o,showDeleteConversation:W,onBlockParticipantClick:d,onReportParticipantClick:h,dmAgentEnabled:f,onMessageSent:m,chatbotVotingEnabled:x,viewerLanguage:c,renderHeaderTitleBadges:g,customChannelActions:j,renderChannelActions:p,onParticipantNameClick:b,renderMessage:A,onMessageLinkClick:M,showChannelInfo:C,composerInput:F},S.id)})}):t.jsx(ve,{})};function In(e){const s=e.state.pending_messages;if(s!=null&&s.length)for(const n of s)e.state.addMessageSorted(n.message)}const Ht=u.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,viewerLanguage:void 0}),En=Ht.Provider,Tn=()=>u.useContext(Ht),Mn=(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))},Yt=e=>{const s=new Date;if(Math.floor((s.getTime()-e.getTime())/1e3)<60)return"Just now";const a=Mn(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("en-US",{month:"numeric",day:"numeric",year:"2-digit"})},qt=u.memo(({channel:e,unread:s})=>{var F,z,D;const{selectedChannel:n,onChannelSelect:a,debug:r,renderMessagePreview:i,viewerLanguage:l}=Tn(),o=(n==null?void 0:n.id)===(e==null?void 0:e.id),d=()=>{e&&a(e)},h=I=>{const L=I.key==="Enter"||I.key===" ",R=I.repeat;!L||R||(I.preventDefault(),d())},m=Object.values(((F=e==null?void 0:e.state)==null?void 0:F.members)||{}).find(I=>{var L,R;return((L=I.user)==null?void 0:L.id)&&I.user.id!==((R=e==null?void 0:e._client)==null?void 0:R.userID)}),x=Pe(m==null?void 0:m.user),c=(z=m==null?void 0:m.user)==null?void 0:z.image,g=(()=>{var L;const I=(L=e==null?void 0:e.state)==null?void 0:L.messages;if(I!=null&&I.length){for(let R=I.length-1;R>=0;R--)if(I[R].type!=="system")return I[R]}})(),j=(()=>{var S,T,$,O;const I=ze({message:g,viewerLanguage:l});if(((S=g==null?void 0:g.metadata)==null?void 0:S.custom_type)==="MESSAGE_TIP")return I?`💵 ${I}`:"💵 Sent a tip";if(((T=g==null?void 0:g.metadata)==null?void 0:T.custom_type)==="MESSAGE_PAID")return I?`💰 ${I}`:"💰 Sent a message";if((($=g==null?void 0:g.metadata)==null?void 0:$.custom_type)==="MESSAGE_ATTACHMENT")return I?`📎 ${I}`:"📎 Sent an attachment";if(I)return I;const k=(O=g==null?void 0:g.attachments)==null?void 0:O[0];return k?k.og_scrape_url?k.og_scrape_url:k.type==="image"?"📷 Sent an image":k.type==="video"?"🎥 Sent a video":k.type==="audio"?"🎵 Sent audio":k.type==="file"?"📎 Sent a file":"📎 Sent an attachment":"No messages yet"})(),p=g!=null&&g.created_at?Yt(new Date(g.created_at)):"",b=g?pe(g):!1,A=i?i(g,j):`${b?"✨ ":""}${j}`,M=It(e),C=s??0;return r&&console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER",{channelId:e==null?void 0:e.id,isSelected:o,participantName:x,unreadCount:C,hasTimestamp:!!p}),t.jsx("div",{role:"button",tabIndex:0,onClick:d,onKeyDown:h,className:y("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]":o,"hover:bg-black/[0.02]":!o}),children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx(Q,{id:((D=m==null?void 0:m.user)==null?void 0:D.id)||e.id||"unknown",name:x,image:c,size:48,starred:M}),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:y("text-sm font-medium truncate text-[#191918]"),children:[M&&t.jsx("span",{className:"sr-only",children:"Starred conversation. "}),x]}),p&&t.jsx("span",{className:"text-xs text-[#717070] flex-shrink-0",children:p})]}),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:A}),C>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:C>99?"99+":C})]})]})]})})});qt.displayName="CustomChannelPreview";const Rn={last_message_at:-1},Xt=u.memo(({onChannelSelect:e,selectedChannel:s,filters:n,allowNewMessagesFromUnfilteredChannels:a=!1,channelRenderFilterFn:r,sort:i=Rn,className:l,customEmptyStateIndicator:o,renderMessagePreview:d,viewerLanguage:h})=>{const f=u.useRef(0);f.current++;const{debug:m=!1}=De(),x=u.useCallback(g=>{for(const _ of g)In(_);return r?r(g):g},[r]);m&&console.log("📺 [ChannelList] 🔄 RENDER START",{renderCount:f.current,selectedChannelId:s==null?void 0:s.id,filters:n});const c=u.useMemo(()=>({selectedChannel:s,onChannelSelect:e,debug:m,renderMessagePreview:d,viewerLanguage:h}),[s,e,m,d,h]);return t.jsx("div",{className:y("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(En,{value:c,children:t.jsx(N.ChannelList,{filters:n,sort:i,options:{limit:30},allowNewMessagesFromUnfilteredChannels:a,channelRenderFilterFn:x,Paginator:N.InfiniteScroll,Preview:qt,EmptyStateIndicator:o},`${JSON.stringify(n)}:${JSON.stringify(i)}`)})})})});Xt.displayName="ChannelList";const An=/^([a-z][a-z0-9+.-]*):/i,Ln=new Set(["http","https","mailto","tel","sms"]);function He(e){if(typeof e!="string")return;const s=e.trim();if(s==="")return;const n=An.exec(s);if(n){const a=n[1].toLowerCase();return Ln.has(a)?s:void 0}return s.startsWith("//")||s.startsWith("/")?s:`https://${s}`}const Dn={dark:"bg-white text-[#121110] hover:bg-white/90",light:"bg-[#121110] text-white hover:bg-[#2a2928]"},Pn=({variant:e,cta:s})=>{const n=y("mt-2 inline-flex h-10 w-full items-center justify-center rounded-full px-4 text-sm font-medium leading-none transition-colors",Dn[e]),a=He(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})},zn={dark:"text-white",light:"text-black/90"},On="text-white/30",Fn={dark:"text-white/55",light:"text-black/55"},Ye=({variant:e,title:s,placeholderTitle:n,description:a,url:r,appIcon:i,cta:l,trailingAction:o})=>{const d=e==="dark",h=s??(d?n:void 0)??"",f=h.trim()!=="",m=a!=null&&a.trim()!=="",x=typeof r=="string"?r.trim():"",c=x!=="",g=l!=null;if(!f&&!m&&!c&&!g)return null;const j=y("truncate text-base font-medium leading-6",d&&!s?On:zn[e]),p=y("truncate text-xs leading-4",Fn[e]);return t.jsxs("div",{className:"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-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[f&&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:y("min-w-0",j),children:h})]}),m&&t.jsx("p",{className:p,children:a})]}),!g&&c&&t.jsx("p",{className:p,children:x})]}),o&&t.jsx("div",{className:"shrink-0",children:o})]}),l&&t.jsx(Pn,{variant:e,cta:l})]})},$n=y("relative block w-[280px] select-none overflow-hidden rounded-md","border border-black/[0.08]","shadow-[0_1px_2px_rgba(0,0,0,0.04),0_8px_32px_rgba(0,0,0,0.1)]"),je=({variant:e,children:s,href:n,onClick:a,ariaLabel:r,rootRef:i,topRight:l,bgClassName:o,"data-testid":d})=>{const h=n!=null||a!=null,f=y($n,o??(e==="dark"?"bg-[#121110]":"bg-white"),h?"cursor-pointer no-underline focus-ring":null),m=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":d,className:f,children:[s,m]}):a?t.jsxs("button",{ref:i,type:"button",onClick:a,"aria-label":r,"data-testid":d,className:y(f,"text-left"),children:[s,m]}):t.jsxs("div",{ref:i,"data-testid":d,className:f,children:[s,m]})},Bn={dark:"bg-white/10",light:"bg-black/5"},Un={dark:"size-16 text-white/25",light:"size-16 text-black/25"},ye=(e,s)=>!!s&&!!e&&te(e)==="audio",Wt=(e,s)=>{if(!s||!e)return!1;const n=te(e);return n==="video"||n==="audio"},qe="bg-[#F2F3F4]",we=({variant:e,thumbnailUrl:s,sourceUrl:n,title:a,mimeType:r="image/*",topLeft:i,topRight:l})=>{const o=te(r),d=!!n&&o==="video";return ye(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:y("relative h-[180px] w-full overflow-hidden",d&&"bg-black"),children:[d?t.jsx("video",{src:n,poster:s,controls:!0,playsInline:!0,preload:"metadata",className:"absolute inset-0 h-full w-full object-contain",children:t.jsx("track",{kind:"captions"})}):s?t.jsx("img",{src:s,alt:a??"",draggable:!1,className:"absolute inset-0 h-full w-full object-cover"}):t.jsx("div",{className:y("flex h-full w-full items-center justify-center",Bn[e]),children:ne(r,{className:Un[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]})},Vn=({title:e,placeholderTitle:s,description:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:l,layout:o="featured",appIcon:d,cta:h,onDismiss:f,onEditClick:m})=>{const x=o==="classic",c=ye(r,l),g=f?t.jsx("button",{type:"button",onClick:f,"aria-label":"Dismiss attachment",className:"flex size-6 items-center justify-center rounded-full bg-[#121110] text-white",children:t.jsx(w.XIcon,{className:"size-3",weight:"bold"})}):void 0,_=m?t.jsx("button",{type:"button",onClick:m,"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(w.PencilSimpleIcon,{className:"size-5",weight:"regular"})}):void 0;return c?t.jsx(je,{variant:"dark",bgClassName:qe,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(we,{variant:"dark",sourceUrl:l,title:e,mimeType:r})}),g&&t.jsx("div",{className:"shrink-0",children:g})]})}):t.jsxs(je,{variant:"dark",topRight:x?g:void 0,children:[!x&&t.jsx(we,{variant:"dark",thumbnailUrl:i,sourceUrl:l,title:e,mimeType:r,topRight:g}),t.jsx(Ye,{variant:"dark",title:e,placeholderTitle:s,description:n,url:a,appIcon:d,cta:h,trailingAction:_})]})},Gn=({title:e,description:s,url:n,mimeType:a,thumbnailUrl:r,sourceUrl:i,layout:l="featured",appIcon:o,cta:d,onClick:h})=>{const f=Wt(a,i),m=He(n),x=d==null&&m!=null&&!f?m:void 0,c=d==null&&!f?h:void 0,g=ye(a,i)?qe:void 0,_=d&&h?{...d,onClick:()=>{var j;h(),(j=d.onClick)==null||j.call(d)}}:d;return t.jsxs(je,{variant:"light",href:x,onClick:c,ariaLabel:e??"Open attachment preview",bgClassName:g,"data-testid":"link-attachment",children:[l==="featured"&&t.jsx(we,{variant:"light",thumbnailUrl:r,sourceUrl:i,title:e,mimeType:a}),t.jsx(Ye,{variant:"light",title:e,description:s,url:n,appIcon:o,cta:_})]})},Hn=({title:e,placeholderTitle:s,description:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:l,layout:o="featured",appIcon:d,cta:h,onClick:f})=>{const m=Wt(r,l),x=He(a),c=h==null&&x!=null&&!m?x:void 0,g=h==null&&!m&&c!=null?f:void 0;return t.jsxs(je,{variant:"dark",href:c,onClick:g,bgClassName:ye(r,l)?qe:void 0,children:[o==="featured"&&t.jsx(we,{variant:"dark",thumbnailUrl:i,sourceUrl:l,title:e,mimeType:r}),t.jsx(Ye,{variant:"dark",title:e,placeholderTitle:s,description:n,url:a,appIcon:d,cta:h})]})},Yn={Composer:Vn,Sent:Hn,Received:Gn},qn={dark:"bg-[#121110]",light:"bg-[#e9eaed]"},Xn={dark:"text-white",light:"text-[#080707]"},Wn={dark:"border-white/[0.08]",light:"border-black/[0.08]"},Kn=e=>e==="dark"?"sender":"receiver",Jn={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]"}},me=({variant:e,text:s,bordered:n=!0,groupPosition:a="single",className:r,children:i,"data-testid":l})=>{const o=s!=null&&s!=="",d=Jn[Kn(e)][a];return t.jsxs("div",{"data-testid":l,"data-group-position":a,className:y("relative w-[280px] overflow-hidden px-2 py-2",d,qn[e],Xn[e],n&&"border",n&&Wn[e],r),children:[i,o?t.jsx("p",{className:y("whitespace-pre-wrap break-words leading-snug","pt-2","px-2"),children:s}):null]})},he=({onClick:e,variant:s="overlay",ariaLabel:n="Dismiss attachment"})=>t.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),e()},"aria-label":n,className:y("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(w.XIcon,{className:"size-3",weight:"bold"})}),xe=e=>e==="received"?"light":"dark",Zn=({firstOfGroup:e,endOfGroup:s,groupedByUser:n})=>!n||e&&s?"single":e?"first":s?"end":"middle",Qn=({src:e,mimeType:s,filename:n,items:a})=>a&&a.length>0?a:e?[{src:e,mimeType:s,filename:n}]:[],ea=({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]}),Xe=({state:e,src:s,mimeType:n,filename:a,items:r,text:i,groupPosition:l,preload:o,onDismiss:d})=>{const h=xe(e),f=e==="composer"&&!!d,m=Qn({src:s,mimeType:n,filename:a,items:r});if(m.length===0)return null;const x=o??(m.length>1?"none":"metadata");return t.jsx(me,{variant:h,text:i,groupPosition:l,"data-testid":"audio-attachment",children:t.jsx("div",{className:"flex flex-col gap-2",children:m.map((c,g)=>t.jsx(ea,{item:c,preload:x,trailingAction:f&&g===0?t.jsx(he,{onClick:d,variant:"inline"}):void 0},`${c.src}-${g}`))})})},ta=e=>t.jsx(Xe,{...e,state:"composer"}),sa=e=>t.jsx(Xe,{...e,state:"sent"}),na=e=>t.jsx(Xe,{...e,state:"received"}),aa={Composer:ta,Sent:sa,Received:na};function Kt(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 ra={pdf:"PDF",doc:"DOC",xls:"XLS",csv:"CSV",ppt:"PPT",zip:"ZIP",text:"TXT",markdown:"MD"};function Jt(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(te(e)==="document"){const r=Lt(e),i=ra[r];if(i)return i;if(e==="application/octet-stream")return}const a=e.split("/")[1];if(!(!a||a==="*"))return a.toUpperCase()}function Zt(e,s,n){const a=Jt(e,s),r=typeof n=="number"&&n>0?Kt(n):void 0;return[a,r].filter(Boolean).join(" · ")||void 0}function ee(e){try{const n=new URL(e).pathname.split("/").pop();return n&&n.length>0?decodeURIComponent(n):"download"}catch{return"download"}}const ia={dark:"text-white/55",light:"text-black/65"},oa={dark:"bg-white/10",light:"bg-black/5"},la={dark:"text-white/85",light:"text-black/85"},Qt=({variant:e,filename:s,title:n,mimeType:a="application/octet-stream",fileSize:r,onActivate:i,activateLabel:l,trailingAction:o})=>{const d=n??s??"File",h=Zt(a,s,r),f=t.jsx("div",{className:y("flex size-10 shrink-0 items-center justify-center rounded-sm",oa[e]),"aria-hidden":!0,children:ne(a,{className:y("size-6",la[e]),weight:"regular"})}),m=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}),h?t.jsx("p",{className:y("truncate text-xs leading-4",ia[e]),children:h}):null]}),x=i?t.jsxs("button",{type:"button",onClick:i,"aria-label":l,className:y("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,m]}):t.jsxs(t.Fragment,{children:[f,m]});return t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[x,o?t.jsx("div",{className:"shrink-0",children:o}):null]})};async function es(e,s){const n=s??ee(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 ca=({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}]:[],da=({variant:e,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??ee(s.src);return t.jsx(Qt,{variant:e,filename:i,title:s.title,mimeType:s.mimeType??"application/octet-stream",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Download ${i}`,trailingAction:r})},We=({state:e,src:s,filename:n,fileSize:a,mimeType:r,title:i,items:l,text:o,groupPosition:d,onClick:h,onDismiss:f})=>{const m=xe(e),x=e==="composer"&&!!f,c=ca({src:s,filename:n,fileSize:a,mimeType:r,title:i,items:l}),g=j=>{if((h==null?void 0:h(j))===!1)return;const p=c[j];if(!p)return;const b=p.filename??ee(p.src);es(p.src,b)};if(c.length===0)return null;const _=t.jsx("span",{className:y("flex size-8 items-center justify-center rounded-full",m==="dark"?"text-white/70":"text-black/70"),"aria-hidden":!0,children:t.jsx(w.DownloadSimpleIcon,{className:"size-5",weight:"bold"})});return t.jsx(me,{variant:m,text:o,groupPosition:d,"data-testid":"file-attachment",children:t.jsx("div",{className:"flex flex-col gap-2",children:c.map((j,p)=>{const b=x&&p===0?t.jsx(he,{onClick:f,variant:"inline"}):_;return t.jsx(da,{variant:m,item:j,index:p,onActivate:g,trailingAction:b},`${j.src}-${p}`)})})})},ua=e=>t.jsx(We,{...e,state:"composer"}),ma=e=>t.jsx(We,{...e,state:"sent"}),ha=e=>t.jsx(We,{...e,state:"received"}),xa={Composer:ua,Sent:ma,Received:ha},Ke=({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(w.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(w.CaretRightIcon,{size:20,weight:"bold","aria-hidden":!0})})]}),ts=({url:e,filename:s,variant:n="pill",label:a="Download",iconOnly:r,tone:i="dark",onTriggered:l})=>{const[o,d]=u.useState(!1),h=u.useCallback(c=>{c.stopPropagation(),!o&&(d(!0),es(e,s).catch(()=>{}).finally(()=>{d(!1),l==null||l()}))},[o,e,s,l]),f=r??n!=="pill",x={className:y(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:h,disabled:o,"aria-label":a,className:y("flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70",c[i]),children:o?t.jsx(w.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):t.jsx(w.DownloadSimpleIcon,{className:"size-5 shrink-0",weight:"bold","aria-hidden":!0})})}return n==="viewer"?t.jsx("button",{type:"button",onClick:h,disabled:o,"aria-label":a,className:"mes-media-viewer__action",children:o?t.jsx(w.CircleNotchIcon,{size:20,weight:"bold","aria-hidden":!0}):t.jsx(w.DownloadSimpleIcon,{size:20,weight:"bold","aria-hidden":!0})}):t.jsxs("button",{type:"button",onClick:h,disabled:o,"aria-label":f?a:void 0,className:y("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(w.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):t.jsx(w.DownloadSimpleIcon,{...x,"aria-hidden":!0}),f?null:a]})},Ee=(e,s,n)=>Math.min(Math.max(e,s),n),Je=({length:e,initialIndex:s,open:n})=>{const a=Ee(s,0,Math.max(e-1,0)),[r,i]=u.useState(a);u.useEffect(()=>{n&&i(Ee(s,0,Math.max(e-1,0)))},[n,s,e]),u.useEffect(()=>{i(d=>Ee(d,0,Math.max(e-1,0)))},[e]);const l=u.useCallback(()=>{e<=1||i(d=>d<=0?e-1:d-1)},[e]),o=u.useCallback(()=>{e<=1||i(d=>d>=e-1?0:d+1)},[e]);return u.useEffect(()=>{if(!n||e<=1)return;const d=h=>{if(h.key!=="ArrowLeft"&&h.key!=="ArrowRight")return;const f=document.activeElement;f&&(f.tagName==="VIDEO"||f.tagName==="AUDIO")||(h.preventDefault(),h.key==="ArrowLeft"?l():o())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n,e,l,o]),{index:r,prev:l,next:o}},Ze=({open:e,onClose:s,ariaLabel:n,counter:a,actions:r,children:i,"data-testid":l})=>{const o=u.useRef(null),d=u.useRef(null);u.useEffect(()=>{var x;const m=o.current;if(m){if(e){if(!m.open)if(typeof m.showModal=="function")try{m.showModal()}catch{m.setAttribute("open","")}else m.setAttribute("open","");const c=typeof document<"u"?document.activeElement:null;return(x=d.current)==null||x.focus(),()=>{if(m.open)if(typeof m.close=="function")try{m.close()}catch{m.removeAttribute("open")}else m.removeAttribute("open");c&&document.body.contains(c)&&c.focus()}}if(m.open)if(typeof m.close=="function")try{m.close()}catch{m.removeAttribute("open")}else m.removeAttribute("open")}},[e]);const h=()=>{s()},f=m=>{m.target===o.current&&s()};return t.jsxs("dialog",{ref:o,className:"mes-media-viewer","aria-label":n??"Attachment viewer","data-testid":l,onClose:h,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(w.XIcon,{size:20,weight:"bold","aria-hidden":!0})})]})]}),t.jsx("div",{className:"mes-media-viewer__body",children:i})]})},ss=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=Je({length:s.length,initialIndex:n,open:e}),o=s[r],d=u.useMemo(()=>(o==null?void 0:o.filename)??(o?ee(o.src):"image"),[o]);return o?t.jsxs(Ze,{open:e,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,actions:t.jsx(ts,{url:o.src,filename:d,variant:"viewer",label:`Download ${d}`}),"data-testid":"image-viewer",children:[t.jsx("img",{src:o.src,alt:o.alt??d,draggable:!1,loading:"eager",decoding:"async",className:"mes-media-viewer__image"},`${r}:${o.src}`),s.length>1?t.jsx(Ke,{onPrev:i,onNext:l,prevLabel:"Previous image",nextLabel:"Next image"}):null]}):null},fa="relative block size-full overflow-hidden bg-black/5 outline-none focus-visible:ring-2 focus-visible:ring-white/80 focus-visible:ring-offset-2 focus-visible:ring-offset-black",ns=({tiles:e,onTileActivate:s,maxVisible:n=4,className:a})=>{const r=e.length;if(r===0)return null;const i=e.slice(0,Math.min(r,n)),l=r-i.length,o=(d,h,f)=>{const m=y(fa,"h-full w-full");return s?t.jsxs("button",{type:"button",onClick:()=>s(h),"aria-label":d.ariaLabel??`Open media ${h+1}`,className:y(m,"cursor-zoom-in"),children:[d.content,f]},h):t.jsxs("div",{className:m,children:[d.content,f]},h)};return i.length===1?t.jsx("div",{className:y("aspect-square w-full",a),children:o(i[0],0)}):i.length===2?t.jsx("div",{className:y("grid aspect-[16/9] w-full grid-cols-2 gap-0.5",a),children:i.map((d,h)=>o(d,h))}):i.length===3?t.jsxs("div",{className:y("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:[t.jsx("div",{className:"row-span-2",children:o(i[0],0)}),o(i[1],1),o(i[2],2)]}):t.jsx("div",{className:y("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:i.map((d,h)=>{const f=l>0&&h===i.length-1;return o(d,h,f?t.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-black/55 text-2xl font-semibold text-white",children:["+",l]}):null)})})},fe=e=>{const[s,n]=u.useState(!1),[a,r]=u.useState(0),i=u.useCallback(o=>{(e==null?void 0:e(o))!==!1&&(r(o),n(!0))},[e]),l=u.useCallback(()=>n(!1),[]);return{viewerOpen:s,viewerIndex:a,handleActivate:i,closeViewer:l}},ga=(e,s,n,a)=>({ariaLabel:`Open image ${s+1} of ${n}`,content:t.jsx("img",{src:e.src,alt:e.alt??"",width:e.width,height:e.height,draggable:!1,loading:e.loading??a,decoding:"async",className:"absolute inset-0 size-full rounded-md object-cover"})}),ba=({src:e,alt:s,items:n})=>n&&n.length>0?n:e?[{src:e,alt:s}]:[],as=(e,s)=>e.map((n,a)=>({src:n.src,alt:n.alt,filename:s&&e.length===1?s:s?`${s} (${a+1})`:void 0})),pa=({src:e,alt:s,filename:n,loading:a="lazy",onClick:r,onDismiss:i})=>{const{viewerOpen:l,viewerIndex:o,handleActivate:d,closeViewer:h}=fe(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: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(he,{onClick:i})}):null,t.jsx(ss,{open:l,items:as([{src:e,alt:s}],n),initialIndex:o,onClose:h})]})},rs=({state:e,src:s,alt:n,filename:a,items:r,text:i,groupPosition:l,loading:o="lazy",onClick:d})=>{const h=ba({src:s,alt:n,items:r}),f=xe(e),{viewerOpen:m,viewerIndex:x,handleActivate:c,closeViewer:g}=fe(d);if(h.length===0)return null;const _=h.map((j,p)=>ga(j,p,h.length,o));return t.jsxs(me,{variant:f,text:i,groupPosition:l,"data-testid":"image-attachment",children:[t.jsx("div",{className:"relative",children:t.jsx(ns,{tiles:_,onTileActivate:c})}),t.jsx(ss,{open:m,items:as(h,a),initialIndex:x,onClose:g})]})},va=e=>t.jsx(pa,{...e}),ja=e=>t.jsx(rs,{...e,state:"sent"}),wa=e=>t.jsx(rs,{...e,state:"received"}),Na={Composer:va,Sent:ja,Received:wa},_a=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=Je({length:s.length,initialIndex:n,open:e}),o=s[r],d=u.useMemo(()=>(o==null?void 0:o.filename)??(o?ee(o.src):"document"),[o]),h=u.useMemo(()=>o?ya(o.src):void 0,[o]);return!o||!h?null:t.jsxs(Ze,{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:h,title:d,className:"mes-media-viewer__iframe",sandbox:"allow-scripts allow-forms allow-popups allow-downloads"},`${r}:${o.src}`),s.length>1?t.jsx(Ke,{onPrev:i,onNext:l,prevLabel:"Previous document",nextLabel:"Next document"}):null]})},ya=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()}`},Ca=({src:e,filename:s,fileSize:n,title:a,items:r})=>r&&r.length>0?r:e?[{src:e,filename:s,fileSize:n,title:a}]:[],ka=({variant:e,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??ee(s.src);return t.jsx(Qt,{variant:e,filename:i,title:s.title,mimeType:"application/pdf",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Open ${i}`,trailingAction:r})},Qe=({state:e,src:s,filename:n,fileSize:a,title:r,items:i,text:l,groupPosition:o,onClick:d,onDismiss:h})=>{const f=xe(e),m=Ca({src:s,filename:n,fileSize:a,title:r,items:i}),{viewerOpen:x,viewerIndex:c,handleActivate:g,closeViewer:_}=fe(d),j=e==="composer"&&!!h;if(m.length===0)return null;const p=m.map(b=>({src:b.src,filename:b.filename??ee(b.src)}));return t.jsxs(me,{variant:f,text:l,groupPosition:o,"data-testid":"pdf-attachment",children:[t.jsx("div",{className:"flex flex-col gap-2",children:m.map((b,A)=>{const M=b.filename??ee(b.src),C=j&&A===0?t.jsx(he,{onClick:h,variant:"inline"}):e==="composer"?void 0:t.jsx(ts,{url:b.src,filename:M,variant:"inline",label:`Download ${M}`,tone:f});return t.jsx(ka,{variant:f,item:b,index:A,onActivate:g,trailingAction:C},`${b.src}-${A}`)})}),t.jsx(_a,{open:x,items:p,initialIndex:c,onClose:_})]})},Sa=e=>t.jsx(Qe,{...e,state:"composer"}),Ia=e=>t.jsx(Qe,{...e,state:"sent"}),Ea=e=>t.jsx(Qe,{...e,state:"received"}),Ta={Composer:Sa,Sent:Ia,Received:Ea},is=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=Je({length:s.length,initialIndex:n,open:e}),o=s[r],d=u.useMemo(()=>(o==null?void 0:o.filename)??(o?ee(o.src):"video"),[o]);return o?t.jsxs(Ze,{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(Ke,{onPrev:i,onNext:l,prevLabel:"Previous video",nextLabel:"Next video"}):null]}):null},Ma=()=>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(w.PlayIcon,{className:"size-6",weight:"fill","aria-hidden":!0})})}),os=({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 rounded-md object-cover"}):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx(w.VideoCameraIcon,{className:"size-16 rounded-md text-white/30",weight:"regular","aria-hidden":!0})}),t.jsx(Ma,{})]}),Ra=(e,s,n)=>({ariaLabel:`Play video ${s+1} of ${n}`,content:t.jsx(os,{item:e,index:s})}),Aa=({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}]:[],ls=(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})),La=({src:e,poster:s,mimeType:n,filename:a,preload:r,onClick:i,onDismiss:l})=>{const{viewerOpen:o,viewerIndex:d,handleActivate:h,closeViewer:f}=fe(i);return t.jsxs("div",{className:"relative w-fit",children:[t.jsx("button",{type:"button",onClick:()=>h(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(os,{item:{src:e,poster:s,mimeType:n},index:0})}),l?t.jsx("div",{className:"absolute right-2 top-2 z-10",children:t.jsx(he,{onClick:l})}):null,t.jsx(is,{open:o,items:ls([{src:e,poster:s,mimeType:n,preload:r}],a),initialIndex:d,onClose:f})]})},cs=({state:e,src:s,poster:n,mimeType:a,filename:r,items:i,text:l,groupPosition:o,preload:d,onClick:h})=>{const f=Aa({src:s,poster:n,mimeType:a,preload:d,items:i}),m=xe(e),{viewerOpen:x,viewerIndex:c,handleActivate:g,closeViewer:_}=fe(h);if(f.length===0)return null;const j=f.map((p,b)=>Ra(p,b,f.length));return t.jsxs(me,{variant:m,text:l,groupPosition:o,"data-testid":"video-attachment",children:[t.jsx("div",{className:"relative",children:t.jsx(ns,{tiles:j,onTileActivate:g,className:"overflow-hidden rounded-md"})}),t.jsx(is,{open:x,items:ls(f,r),initialIndex:c,onClose:_})]})},Da=e=>t.jsx(La,{...e}),Pa=e=>t.jsx(cs,{...e,state:"sent"}),za=e=>t.jsx(cs,{...e,state:"received"}),Oa={Composer:Da,Sent:Pa,Received:za},Fa={Image:Na,Video:Oa,Audio:aa,Pdf:Ta,File:xa},ds=({question:e,onClick:s,loading:n=!1,className:a})=>t.jsx("button",{type:"button",onClick:s,disabled:n,style:{backgroundColor:"#E6E5E3"},className:y("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}),$a=({faqs:e,onFaqClick:s,loadingFaqId:n,headerText:a,className:r,avatarImage:i,avatarName:l})=>{const o=e.filter(d=>d.enabled).sort((d,h)=>(d.order??0)-(h.order??0));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(Q,{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=re;exports.AttachmentThumbnail=Fe;exports.Avatar=Q;exports.ChannelEmptyState=Gt;exports.ChannelList=Xt;exports.ChannelView=Ge;exports.CustomMessageProvider=Ys;exports.FaqList=$a;exports.FaqListItem=ds;exports.LinkAttachment=Yn;exports.LockedAttachment=Ae;exports.MediaMessage=Vs;exports.MessageAttachment=Fa;exports.MessageVoteButtons=Ut;exports.MessagingProvider=ms;exports.MessagingShell=Sn;exports.bubbleGroupPositionFromStream=Zn;exports.buildCompactMetaLabel=Zt;exports.formatFileSize=Kt;exports.formatRelativeTime=Yt;exports.getFileExtensionLabel=Jt;exports.getMessageDisplayText=ze;exports.getSourceType=te;exports.isLinkAttachment=Ue;exports.isUuidLike=Et;exports.normalizeLanguageCode=Mt;exports.renderTypeIcon=ne;exports.resolveLinkAttachment=Ne;exports.resolveMediaFromMessage=_e;exports.resolveParticipantDisplayName=Pe;exports.useComposerLocked=ln;exports.useCustomMessage=$t;exports.useMessageVote=Tt;exports.useMessaging=St;
2
- //# sourceMappingURL=index-DXBga91I.cjs.map