@linktr.ee/messaging-react 3.10.0-rc-1783660962 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Card-B-L2MST4.js +107 -0
- package/dist/Card-B-L2MST4.js.map +1 -0
- package/dist/Card-B56QxJW3.cjs +2 -0
- package/dist/Card-B56QxJW3.cjs.map +1 -0
- package/dist/Card-Bqh-BQaX.js +132 -0
- package/dist/Card-Bqh-BQaX.js.map +1 -0
- package/dist/Card-ZCE6Lhfc.cjs +2 -0
- package/dist/Card-ZCE6Lhfc.cjs.map +1 -0
- package/dist/Card-g4JD-2ES.js +163 -0
- package/dist/Card-g4JD-2ES.js.map +1 -0
- package/dist/Card-wac6AMNc.cjs +2 -0
- package/dist/Card-wac6AMNc.cjs.map +1 -0
- package/dist/LockedThumbnail-BAQmoIff.js +220 -0
- package/dist/LockedThumbnail-BAQmoIff.js.map +1 -0
- package/dist/LockedThumbnail-Cr0Gqs3Y.cjs +2 -0
- package/dist/LockedThumbnail-Cr0Gqs3Y.cjs.map +1 -0
- package/dist/assets/index.css +1 -1
- package/dist/index-BPhZyaxT.cjs +2 -0
- package/dist/index-BPhZyaxT.cjs.map +1 -0
- package/dist/{index-DFZrAiLB.js → index-BxzzWK4K.js} +1249 -1276
- package/dist/index-BxzzWK4K.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +101 -164
- package/dist/index.js +1 -1
- package/dist/testing.d.ts +0 -1
- package/package.json +2 -2
- package/src/components/ChannelList/CustomChannelPreview.test.tsx +0 -95
- package/src/components/ChannelList/CustomChannelPreview.tsx +9 -21
- package/src/components/CustomMessage/CustomMessage.stories.tsx +1 -54
- package/src/components/CustomMessage/MessageTag.tsx +0 -8
- package/src/components/CustomMessage/context.tsx +1 -1
- package/src/components/CustomMessage/index.tsx +42 -76
- package/src/components/CustomMessageInput/CustomMessageInput.stories.tsx +3 -5
- package/src/components/LockedAttachment/LockedAttachment.stories.tsx +450 -0
- package/src/components/LockedAttachment/components/Composer/Card.tsx +221 -0
- package/src/components/LockedAttachment/components/Composer/index.ts +2 -0
- package/src/components/LockedAttachment/components/Received/Card.tsx +191 -0
- package/src/components/{CustomMessage/LockedAttachment/components/Media → LockedAttachment/components/Received}/CardActions.tsx +2 -9
- package/src/components/LockedAttachment/components/Received/index.ts +2 -0
- package/src/components/LockedAttachment/components/Sent/Card.tsx +177 -0
- package/src/components/LockedAttachment/components/Sent/index.ts +2 -0
- package/src/components/{CustomMessage/LockedAttachment → LockedAttachment}/components/_shared/CardBody.tsx +7 -8
- package/src/components/{CustomMessage/LockedAttachment → LockedAttachment}/components/_shared/GalleryThumbnail.tsx +39 -31
- package/src/components/LockedAttachment/components/_shared/LockBadge.tsx +39 -0
- package/src/components/{CustomMessage/LockedAttachment/components/_shared/MediaShell.tsx → LockedAttachment/components/_shared/LockedCardShell.tsx} +8 -8
- package/src/components/{CustomMessage/LockedAttachment/components/_shared/SingleThumbnail.tsx → LockedAttachment/components/_shared/LockedThumbnail.tsx} +7 -11
- package/src/components/LockedAttachment/index.tsx +63 -0
- package/src/components/LockedAttachment/types.ts +51 -0
- package/src/index.ts +8 -3
- package/src/stream-custom-data.ts +0 -1
- package/src/styles.css +0 -12
- package/src/types.ts +1 -1
- package/dist/Card-415OfRhw.cjs +0 -2
- package/dist/Card-415OfRhw.cjs.map +0 -1
- package/dist/Card-CyWdUMCB.cjs +0 -2
- package/dist/Card-CyWdUMCB.cjs.map +0 -1
- package/dist/Card-V5d6qhDT.js +0 -694
- package/dist/Card-V5d6qhDT.js.map +0 -1
- package/dist/Card-qS17qnN0.js +0 -103
- package/dist/Card-qS17qnN0.js.map +0 -1
- package/dist/LoadingDots-Ct3WmVlT.js +0 -59
- package/dist/LoadingDots-Ct3WmVlT.js.map +0 -1
- package/dist/LoadingDots-D9GGphgM.cjs +0 -2
- package/dist/LoadingDots-D9GGphgM.cjs.map +0 -1
- package/dist/index-Bx_zjNMR.cjs +0 -2
- package/dist/index-Bx_zjNMR.cjs.map +0 -1
- package/dist/index-DFZrAiLB.js.map +0 -1
- package/src/components/CustomMessage/LockedAttachment/LockedAttachment.stories.tsx +0 -541
- package/src/components/CustomMessage/LockedAttachment/LockedAttachment.test.tsx +0 -117
- package/src/components/CustomMessage/LockedAttachment/components/Media/Card.tsx +0 -358
- package/src/components/CustomMessage/LockedAttachment/components/Media/types.ts +0 -79
- package/src/components/CustomMessage/LockedAttachment/components/Text/Card.tsx +0 -153
- package/src/components/CustomMessage/LockedAttachment/components/Text/types.ts +0 -58
- package/src/components/CustomMessage/LockedAttachment/components/_shared/CardThumbnail.tsx +0 -92
- package/src/components/CustomMessage/LockedAttachment/components/_shared/LoadingDots.tsx +0 -36
- package/src/components/CustomMessage/LockedAttachment/components/_shared/LockBadge.tsx +0 -63
- package/src/components/CustomMessage/LockedAttachment/components/_shared/PreviewToggle.tsx +0 -58
- package/src/components/CustomMessage/LockedAttachment/components/_shared/PriceLockRow.tsx +0 -21
- package/src/components/CustomMessage/LockedAttachment/components/_shared/PurchaseStatusBadge.tsx +0 -74
- package/src/components/CustomMessage/LockedAttachment/components/_shared/SkeletonTextLines.tsx +0 -29
- package/src/components/CustomMessage/LockedAttachment/components/_shared/TextShell.tsx +0 -28
- package/src/components/CustomMessage/LockedAttachment/components/_shared/usePreviewToggle.test.ts +0 -67
- package/src/components/CustomMessage/LockedAttachment/components/_shared/usePreviewToggle.ts +0 -89
- package/src/components/CustomMessage/LockedAttachment/components/_shared/useReceivedSource.ts +0 -83
- package/src/components/CustomMessage/LockedAttachment/index.tsx +0 -105
- package/src/components/CustomMessage/LockedAttachment/types.ts +0 -44
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),m=require("react"),Ms=require("@linktr.ee/messaging-core"),Oe=require("stream-chat"),w=require("stream-chat-react"),j=require("@phosphor-icons/react"),k=require("classnames"),He=require("stream-chat-react/experimental"),Bt=m.createContext({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),Ye=()=>m.useContext(Bt),As=({children:e,user:s,serviceConfig:n,apiKey:a,capabilities:r={},debug:i=!1,client:l})=>{var T,R;const o=m.useCallback((M,...z)=>{i&&console.log(`🔥 [MessagingProvider] ${M}`,...z)},[i]);o("🔄 RENDER START",{userId:s==null?void 0:s.id,apiKey:(a==null?void 0:a.substring(0,8))+"...",serviceConfig:!!n,capabilities:Object.keys(r)});const[d,u]=m.useState(null),[g,h]=m.useState(null),[f,c]=m.useState(!1),[p,v]=m.useState(!1),[b,x]=m.useState(null),_=m.useRef(!1),N=m.useRef(null),S=m.useRef(n);S.current=n;const L=m.useRef(i);L.current=i;const I=m.useRef({userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r}),D=m.useRef(0);D.current++,o("📊 RENDER INFO",{renderCount:D.current,currentProps:{userId:s==null?void 0:s.id,apiKey:(a==null?void 0:a.substring(0,8))+"..."},propChanges:{userChanged:I.current.userId!==(s==null?void 0:s.id),apiKeyChanged:I.current.apiKey!==a,serviceConfigChanged:I.current.serviceConfig!==n,capabilitiesChanged:I.current.capabilities!==r}}),I.current={userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r};const B=m.useRef(null);!l&&a&&((T=B.current)==null?void 0:T.apiKey)!==a&&(B.current={apiKey:a,client:new Oe.StreamChat(a)});const O=l||(a?((R=B.current)==null?void 0:R.client)??null:null);m.useEffect(()=>{const M=D.current,z=S.current;if(l){N.current=null,u(null),h(null),c(!1),x(null),v(!1);return}if(!a||!O||!z){o("⚠️ SERVICE INIT SKIPPED",{renderCount:M,reason:"Missing apiKey, client, or serviceConfig"});return}o("🚀 CREATING SERVICE",{renderCount:M,apiKey:(a==null?void 0:a.substring(0,8))+"..."});const $=new Ms.StreamChatService({...z,apiKey:a,debug:L.current,client:O});N.current=$,u($),o("✅ SERVICE SET",{renderCount:M,serviceInstance:!!$})},[a,O,l]);const F=m.useRef(null);m.useEffect(()=>{var z,$;if(o("🔗 USER CONNECTION EFFECT TRIGGERED",{hasService:!!d,hasUser:!!s,userId:s==null?void 0:s.id,isConnecting:_.current,isConnected:f,dependencies:{service:!!d,userId:s==null?void 0:s.id}}),l)return;if(!d||!s){o("⚠️ USER CONNECTION SKIPPED","Missing service or user");return}if(_.current){o("⚠️ USER CONNECTION SKIPPED","Already connecting");return}if(((z=F.current)==null?void 0:z.serviceId)===d&&(($=F.current)==null?void 0:$.userId)===s.id){o("⚠️ USER CONNECTION SKIPPED","Already connected this user with this service");return}(async()=>{o("🚀 STARTING USER CONNECTION",{userId:s.id}),_.current=!0,v(!0),x(null);try{o("📞 CALLING SERVICE.CONNECTUSER",{userId:s.id});const V=await d.connectUser(s);h(V),c(!0),F.current={serviceId:d,userId:s.id},o("✅ USER CONNECTION SUCCESS",{userId:s.id,clientId:V.userID})}catch(V){const X=V instanceof Error?V.message:"Connection failed";x(X),o("❌ USER CONNECTION ERROR",{userId:s.id,error:X})}finally{v(!1),_.current=!1,o("🔄 USER CONNECTION FINISHED",{userId:s.id,isConnected:f})}})()},[d,s,o,f,l]),m.useEffect(()=>{const M=O;return()=>{var z;M&&(F.current=null,(z=N.current)==null||z.disconnectUser().catch(console.error))}},[O]);const C=m.useCallback(async()=>{if(o("🔄 REFRESH CONNECTION CALLED",{hasService:!!d,hasUser:!!s}),!l){if(!d||!s){o("⚠️ REFRESH CONNECTION SKIPPED","Missing service or user");return}o("🚀 STARTING CONNECTION REFRESH",{userId:s.id}),v(!0);try{o("🔌 DISCONNECTING FOR REFRESH"),await d.disconnectUser(),o("📞 RECONNECTING FOR REFRESH");const M=await d.connectUser(s);h(M),c(!0),x(null),o("✅ CONNECTION REFRESH SUCCESS",{userId:s.id})}catch(M){const z=M instanceof Error?M.message:"Refresh failed";x(z),o("❌ CONNECTION REFRESH ERROR",{userId:s.id,error:z})}finally{v(!1),o("🔄 CONNECTION REFRESH FINISHED",{userId:s.id})}}},[d,s,o,l]),E=m.useMemo(()=>(o("💫 CONTEXT VALUE MEMOIZATION",{hasService:!!d,hasClient:!!g,isConnected:f,isLoading:p,hasError:!!b,capabilitiesKeys:Object.keys(r)}),{service:l?null:d,client:l??g,isConnected:l?!0:f,isLoading:l?!1:p,error:l?null:b,capabilities:r,refreshConnection:C,debug:i}),[d,g,l,f,p,b,r,C,i,o]);return o("🔄 RENDER END",{renderCount:D.current,willRenderChat:!!O,contextValueReady:!!E}),t.jsx(Bt.Provider,{value:E,children:O?t.jsx(w.Chat,{client:O,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})},Ut=()=>Ye(),qe=e=>{var a,r;const[s,n]=m.useState(!!((r=(a=e==null?void 0:e.state)==null?void 0:a.membership)!=null&&r.pinned_at));return m.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},Rs="linktree-official",Ls="linktree-official-sender";function fe(e,s,n){const a=Object.values(e||{});if(n===Rs){const r=a.find(i=>{var l;return((l=i.user)==null?void 0:l.id)===Ls});if(r)return r}return a.find(r=>{var i;return((i=r.user)==null?void 0:i.id)&&r.user.id!==s})}const Ds=/^[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 Vt(e){return Ds.test(e.trim())}function At(e,s){const n=e==null?void 0:e.trim();return!n||s&&n===s?!1:!Vt(n)}function Se(e){return At(e==null?void 0:e.name,e==null?void 0:e.id)?e.name.trim():At(e==null?void 0:e.username,e==null?void 0:e.id)?e.username.trim():"Unknown member"}const Rt=[{emoji:"🍎",bgColor:"#FFD1DD"},{emoji:"🍌",bgColor:"#FFF1C9"},{emoji:"🍇",bgColor:"#E6D9FF"},{emoji:"🍊",bgColor:"#D6F4FF"},{emoji:"🍓",bgColor:"#FFE0AE"},{emoji:"🥥",bgColor:"#F7E7D8"},{emoji:"🍒",bgColor:"#DFF4D8"},{emoji:"🥭",bgColor:"#FFD8C2"},{emoji:"🍉",bgColor:"#D6EBFF"},{emoji:"🍋",bgColor:"#CAEEB5"},{emoji:"🥝",bgColor:"#FFE7C7"},{emoji:"🫒",bgColor:"#F6E3B4"},{emoji:"🍈",bgColor:"#D9F7E1"}];function Fs(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 Gt(e){return Rt[Fs(e)%Rt.length]}function zs(e){return Gt(e).emoji}function Ps(e){return Gt(e).bgColor}const J=({id:e,image:s,size:n=40,className:a,starred:r=!1,shape:i="squircle",dmAgentEnabled:l=!1})=>{const o=zs(e),d=Ps(e),u=.45,h=n<32?Math.round(n*u):n<56?14:n<120?18:36,f=n>=40?2:1,c=i==="circle"?{borderRadius:"50%"}:{borderRadius:"1rem"},p=t.jsx("div",{className:"h-full w-full overflow-hidden",style:c,children:s?t.jsx("img",{src:s,alt:"",className:"h-full w-full object-cover"}):t.jsx("div",{"aria-hidden":"true",className:k("avatar-fallback flex h-full w-full items-center justify-center font-semibold select-none transition-colors"),style:{fontSize:h,lineHeight:1},children:o})});return t.jsxs("div",{className:k("relative flex-shrink-0",a),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`,backgroundColor:s?void 0:d,...c},children:[r&&t.jsx("div",{"aria-hidden":"true",className:"absolute -left-1.5 -top-1.5 z-10 flex size-5 items-center justify-center rounded-full bg-white shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",children:t.jsx(j.StarIcon,{className:"size-3 text-yellow-600",weight:"duotone"})}),t.jsx("div",{"data-testid":"avatar-ring",className:k("h-full w-full","bg-transparent"),style:{...c,...l&&{borderWidth:`${f}px`,borderStyle:"solid",borderColor:"var(--AI-Gradient, #7F22FE)",boxShadow:"inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"}},children:p})]})},Os="https://linktr.ee/s/about/trust-center/report",$s=({channel:e,participant:s,showBlockParticipant:n=!0,enabled:a=!0,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:l,onBlockParticipantClick:o,onReportParticipantClick:d,onActionComplete:u,logLabel:g="useChannelModerationActions"})=>{var E;const{service:h,debug:f}=Ye(),c=(E=s==null?void 0:s.user)==null?void 0:E.id,p=!!(a&&n&&h&&c),[v,b]=m.useState(!1),[x,_]=m.useState(null),[N,S]=m.useState(!1),[L,I]=m.useState(!1),D=p&&((x==null?void 0:x.participantId)!==c||(x==null?void 0:x.service)!==h);return m.useEffect(()=>{if(!p||!h||!c){b(!1),_(null);return}let T=!1;return(async()=>{try{const R=await h.getBlockedUsers();if(T)return;b(R.some(M=>M.blocked_user_id===c))}catch(R){T||console.error(`[${g}] Failed to check blocked status:`,R)}finally{T||_({participantId:c,service:h})}})(),()=>{T=!0}},[p,h,c,g]),{isParticipantBlocked:v,isCheckingBlockedStatus:D,isLeaving:N,isUpdatingBlockStatus:L,handleLeaveConversation:async()=>{var T;if(!N){l==null||l(),f&&console.log(`[${g}] Leave conversation`,e.cid),S(!0);try{const R=((T=e._client)==null?void 0:T.userID)??null;await e.hide(R,!1),r&&await r(e),u==null||u()}catch(R){console.error(`[${g}] Failed to leave conversation`,R)}finally{S(!1)}}},handleBlockUser:async()=>{var T,R,M;if(!(L||!h)){o==null||o(),f&&console.log(`[${g}] Block member`,(T=s==null?void 0:s.user)==null?void 0:T.id),I(!0);try{await h.blockUser((R=s==null?void 0:s.user)==null?void 0:R.id),i&&await i((M=s==null?void 0:s.user)==null?void 0:M.id),u==null||u()}catch(z){console.error(`[${g}] Failed to block member`,z)}finally{I(!1)}}},handleUnblockUser:async()=>{var T,R,M;if(!(L||!h)){o==null||o(),f&&console.log(`[${g}] Unblock member`,(T=s==null?void 0:s.user)==null?void 0:T.id),I(!0);try{await h.unBlockUser((R=s==null?void 0:s.user)==null?void 0:R.id),i&&await i((M=s==null?void 0:s.user)==null?void 0:M.id),u==null||u()}catch(z){console.error(`[${g}] Failed to unblock member`,z)}finally{I(!1)}}},handleReportUser:()=>{d==null||d(),u==null||u(),window.open(Os,"_blank","noopener,noreferrer")}}},me=({variant:e="default",className:s,children:n,...a})=>{const r=e==="danger";return t.jsx("button",{type:"button",className:k("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})},$e=({channel:e,participant:s,showDeleteConversation:n=!0,showBlockParticipant:a=!0,showReportParticipant:r=!0,onLeaveConversation:i,onBlockParticipant:l,onDeleteConversationClick:o,onBlockParticipantClick:d,onReportParticipantClick:u,customChannelActions:g,triggerClassName:h})=>{const[f,c]=m.useState(!1),p=m.useRef(null),v=m.useId(),b=m.useCallback(()=>c(!1),[]),{isParticipantBlocked:x,isCheckingBlockedStatus:_,isLeaving:N,isUpdatingBlockStatus:S,handleLeaveConversation:L,handleBlockUser:I,handleUnblockUser:D,handleReportUser:B}=$s({channel:e,participant:s,showBlockParticipant:a,enabled:f,onLeaveConversation:i,onBlockParticipant:l,onDeleteConversationClick:o,onBlockParticipantClick:d,onReportParticipantClick:u,onActionComplete:b,logLabel:"ChannelActionsMenu"});return m.useEffect(()=>{if(!f)return;const F=E=>{p.current&&!p.current.contains(E.target)&&c(!1)},C=E=>{E.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",F),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",F),document.removeEventListener("keydown",C)}},[f]),!s||!(n||a||r||!!g)?null:t.jsxs("div",{ref:p,className:"relative",children:[t.jsxs("button",{className:h,type:"button","aria-haspopup":"true","aria-expanded":f,"aria-controls":f?v:void 0,onClick:()=>c(F=>!F),children:[t.jsx(j.DotsThreeIcon,{className:"size-5 text-black/90"}),t.jsx("span",{className:"sr-only",children:"More options"})]}),f&&t.jsx("div",{id:v,"aria-label":"Conversation options",className:k("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(me,{onClick:L,disabled:N,"aria-busy":N,children:[N?t.jsx(j.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):t.jsx(j.SignOutIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Delete Conversation"})]})}),a&&t.jsx("li",{children:_?t.jsxs(me,{disabled:!0,"aria-busy":!0,children:[t.jsx(j.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}),t.jsx("span",{children:"Block"})]}):x?t.jsxs(me,{onClick:D,disabled:S,"aria-busy":S,children:[S?t.jsx(j.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):t.jsx(j.ProhibitInsetIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Unblock"})]}):t.jsxs(me,{onClick:I,disabled:S,"aria-busy":S,children:[S?t.jsx(j.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):t.jsx(j.ProhibitInsetIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Block"})]})}),r&&t.jsx("li",{children:t.jsxs(me,{variant:"danger",onClick:B,children:[t.jsx(j.FlagIcon,{className:"h-5 w-5"}),t.jsx("span",{children:"Report"})]})}),g]})})]})},Re="flex size-10 flex-shrink-0 items-center justify-center rounded-full bg-white/65 shadow-[0px_4px_8px_0px_rgba(0,0,0,0.06),0px_0px_0px_1px_rgba(0,0,0,0.04)] backdrop-blur-[40px] transition-filter duration-150 hover:brightness-95 aria-expanded:brightness-95 focus-ring",Bs="CUSTOMER_PAID",Us="Replies instantly with AI assistant",Vs=e=>typeof e=="string"&&e.trim().replace(/[\s-]+/g,"_").toUpperCase()===Bs,Gs=e=>{const s=e;return[s==null?void 0:s.customerTag,s==null?void 0:s.customer_tag].some(Vs)},Hs=({className:e,onBack:s,showBackButton:n,showStarButton:a=!1,dmAgentEnabled:r=!1,onLeaveConversation:i,onBlockParticipant:l,showDeleteConversation:o=!0,showBlockParticipant:d=!0,showReportParticipant:u=!0,onDeleteConversationClick:g,onBlockParticipantClick:h,onReportParticipantClick:f,customChannelActions:c,renderChannelActions:p,showChannelInfo:v=!0,onParticipantNameClick:b})=>{var O,F,C;const{channel:x}=w.useChannelStateContext(),{client:_}=w.useChatContext(),N=m.useMemo(()=>{var E;return fe((E=x.state)==null?void 0:E.members,_==null?void 0:_.userID,x.type)},[(O=x.state)==null?void 0:O.members,_==null?void 0:_.userID,x.type]),S=Se(N==null?void 0:N.user),L=(F=N==null?void 0:N.user)==null?void 0:F.image,I=qe(x),D=Gs(N),B=async()=>{try{I?await x.unpin():await x.pin()}catch(E){console.error("[ChannelHeaderRedesign] Failed to update pinned status:",E)}};return t.jsx("div",{className:k("@container bg-[linear-gradient(180deg,#FBFAF9_0%,rgba(251,250,249,0.92)_58%,rgba(251,250,249,0)_100%)]",e),children:t.jsxs("div",{className:"grid min-h-[100px] grid-cols-[minmax(40px,1fr)_auto_minmax(40px,1fr)] items-start pb-2 pt-5 @lg:min-h-[104px] @lg:pt-6",children:[t.jsx("div",{className:"flex items-start",children:n&&t.jsx("button",{className:k(Re,"messaging-channel-view-back-button-mobile messaging-channel-view-back-button-desktop"),onClick:s||(()=>{}),type:"button","aria-label":"Back to conversations",children:t.jsx(j.ArrowLeftIcon,{className:"size-5 text-black/90"})})}),t.jsx("div",{className:"flex min-w-0 justify-center","data-dd-privacy":"mask",children:t.jsxs("button",{type:"button",onClick:b,"aria-label":`View details for ${S}`,className:"group flex min-w-0 max-w-full appearance-none flex-col items-center border-0 bg-transparent px-2 focus-ring focus-visible:outline-none",children:[t.jsx(J,{id:((C=N==null?void 0:N.user)==null?void 0:C.id)||x.id||"unknown",name:S,image:L,dmAgentEnabled:r,shape:"circle",size:48,className:"-mb-2"}),t.jsxs("span",{className:"relative z-10 flex max-w-full flex-col items-center justify-center rounded-full border border-white/10 bg-white/65 py-1.5 pl-3 pr-2 shadow-[0px_0px_0px_0px_rgba(0,0,0,0.04),0px_1px_2px_0px_rgba(0,0,0,0.04),0px_8px_32px_0px_rgba(0,0,0,0.1)] backdrop-blur-[2px] transition-filter duration-150 group-hover:brightness-95",children:[t.jsxs("span",{className:"flex max-w-full items-center justify-center",children:[t.jsx("span",{className:"min-w-0 truncate text-sm font-bold leading-[1.43] tracking-[0.28px] text-black/90",children:S}),t.jsxs("span",{className:"ml-2 flex gap-1",children:[D&&t.jsx("span",{"aria-label":"Paid customer",className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-[#34C759] text-white",children:t.jsx(j.CurrencyDollarIcon,{className:"size-2.5",weight:"bold"})}),a&&I&&t.jsx("span",{"aria-label":"Starred conversation",className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-[#FFD60A] text-white",children:t.jsx(j.StarIcon,{className:"size-2.5",weight:"fill"})}),t.jsx(j.CaretRightIcon,{"aria-hidden":"true",className:"size-4 shrink-0 text-black/65",weight:"bold"})]})]}),r&&t.jsxs("span",{className:"mt-1 flex items-center gap-1 px-1 pb-0.5 text-[10px] leading-3 text-black/55",children:[t.jsx(j.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),t.jsx("span",{children:Us})]})]})]})}),t.jsxs("div",{className:"flex items-start justify-end gap-2",children:[a&&t.jsx("button",{className:Re,onClick:B,type:"button","aria-pressed":I,"aria-label":I?"Unstar conversation":"Star conversation",children:t.jsx(j.StarIcon,{className:k("size-5",{"text-[#FFD60A]":I,"text-black/90":!I}),weight:I?"fill":"regular"})}),v&&(p!==void 0?p:t.jsx($e,{channel:x,participant:N,showDeleteConversation:o,showBlockParticipant:d,showReportParticipant:u,onLeaveConversation:i,onBlockParticipant:l,onDeleteConversationClick:g,onBlockParticipantClick:h,onReportParticipantClick:f,customChannelActions:c,triggerClassName:Re}))]})]})})},Ys=e=>t.jsx(w.DateSeparator,{...e,position:"center"}),Be="vote_up",Ue="vote_down";function qs(e){return e!=null&&e.length?e.some(s=>s.type===Ue)?"down":e.some(s=>s.type===Be)?"up":null:null}function Ht(e){const{channel:s}=w.useChannelStateContext(),{client:n}=w.useChatContext("useMessageVote"),a=m.useMemo(()=>qs(e.own_reactions),[e.own_reactions]),r=m.useCallback(async()=>{if(n!=null&&n.userID)try{a==="up"?await s.deleteReaction(e.id,Be):await s.sendReaction(e.id,{type:Be},{enforce_unique:!0,skip_push:!0})}catch{}},[s,n==null?void 0:n.userID,e.id,a]),i=m.useCallback(async()=>{if(n!=null&&n.userID)try{a==="down"?await s.deleteReaction(e.id,Ue):await s.sendReaction(e.id,{type:Ue},{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 Yt(e){return(e==null?void 0:e.trim().toLowerCase().split(/[-_]/)[0])||void 0}function Xe({message:e,viewerLanguage:s}){var r;const n=e==null?void 0:e.text,a=Yt(s);return a?((r=e==null?void 0:e.i18n)==null?void 0:r[`${a}_text`])??n:n}const Xs=m.lazy(()=>Promise.resolve().then(()=>require("./Card-ZCE6Lhfc.cjs"))),Ws=m.lazy(()=>Promise.resolve().then(()=>require("./Card-wac6AMNc.cjs"))),Ks=m.lazy(()=>Promise.resolve().then(()=>require("./Card-B56QxJW3.cjs"))),We=()=>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}),Zs=e=>t.jsx(m.Suspense,{fallback:t.jsx(We,{}),children:t.jsx(Xs,{...e})}),qt=e=>t.jsx(m.Suspense,{fallback:t.jsx(We,{}),children:t.jsx(Ws,{...e})}),Xt=e=>t.jsx(m.Suspense,{fallback:t.jsx(We,{}),children:t.jsx(Ks,{...e})}),Js=qt,Qs=Xt,Ve={Composer:Zs,Sent:qt,Received:Xt,Creator:Js,Visitor:Qs},en=[[/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 Wt(e){const s=en.find(([n])=>n.test(e));return s?s[1]:"generic"}const tn={video:j.VideoCameraIcon,audio:j.SpeakerHighIcon,image:j.ImageIcon,document:j.FileIcon},sn={pdf:j.FilePdfIcon,doc:j.FileDocIcon,xls:j.FileXlsIcon,csv:j.FileCsvIcon,ppt:j.FilePptIcon,zip:j.FileZipIcon,text:j.FileTextIcon,markdown:j.FileMdIcon,generic:j.FileIcon};function nn(e){const s=te(e);return s!=="document"?tn[s]:sn[Wt(e)]}function ie(e,s){return m.createElement(nn(e),s)}const an=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},rn=({source:e,mimeType:s,poster:n,autoPlay:a=!1,playing:r,loop:i=!1,controls:l=!0,showProgress:o=!1,muted:d=!1,onContainerClick:u})=>{const g=te(s),h=m.useRef(null),f=m.useRef(null),c=m.useRef(null),p=m.useRef(r),[v,b]=m.useState(a),[x,_]=m.useState(0),[N,S]=m.useState(!1),[L,I]=m.useState(!1),[D,B]=m.useState(!1),[O,F]=m.useState(!1),[C,E]=m.useState(!0),[T,R]=m.useState(null),M=m.useCallback(()=>{B(!1),b(!0)},[]),z=m.useCallback(y=>{const A=f.current;if(!A)return 0;const G=A.getBoundingClientRect();return Math.max(0,Math.min(1,(an(y)-G.left)/G.width))},[]),$=m.useCallback(y=>{const A=h.current;A&&A.duration&&(A.currentTime=y*A.duration)},[]),V=y=>{y.stopPropagation(),S(!0);const A=z(y);_(A),$(A)};m.useEffect(()=>{r!==void 0&&r!==p.current&&(p.current=r,b(r))},[r]),m.useEffect(()=>{if(!v){c.current!==null&&(cancelAnimationFrame(c.current),c.current=null);return}const y=()=>{const A=h.current;A&&A.duration&&!N&&_(A.currentTime/A.duration),c.current=requestAnimationFrame(y)};return c.current=requestAnimationFrame(y),()=>{c.current!==null&&cancelAnimationFrame(c.current)}},[v,N]),m.useEffect(()=>{const y=h.current;y&&(v?y.play().catch(A=>{b(!1),B(!0)}):y.pause())},[v]),m.useEffect(()=>{if(!N)return;const y=G=>_(z(G)),A=G=>{S(!1),$(z(G))};return window.addEventListener("mousemove",y),window.addEventListener("mouseup",A),window.addEventListener("touchmove",y,{passive:!0}),window.addEventListener("touchend",A),()=>{window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",A),window.removeEventListener("touchmove",y),window.removeEventListener("touchend",A)}},[N,z,$]);const X=T?{aspectRatio:String(T)}:void 0,Z=T?"":" aspect-video",W=Math.round(x*100);return t.jsxs("div",{role:"button",tabIndex:0,className:`relative cursor-pointer overflow-hidden bg-black ${Z}`,style:X,onClick:y=>{if(u){u(y);return}D||l&&b(A=>!A)},onKeyDown:y=>{if(!(y.key!=="Enter"&&y.key!==" ")){if(y.preventDefault(),u){u(y);return}D||l&&b(A=>!A)}},children:[n&&(g==="audio"||C)&&t.jsx("img",{src:n,alt:"",className:"absolute inset-0 h-full w-full object-cover"}),!n&&(g==="audio"||C)&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:ie(s,{className:"size-12 text-black/20",weight:"regular"})}),t.jsx("div",{className:"absolute inset-0",children:g==="audio"?t.jsx("audio",{ref:h,src:e,loop:i,muted:d,style:{width:"100%",height:"100%"},onLoadStart:()=>F(!0),onCanPlay:()=>{F(!1),E(!1)},onWaiting:()=>F(!0),onPlay:()=>B(!1),onEnded:()=>{i||(b(!1),_(0))},children:t.jsx("track",{kind:"captions"})}):t.jsx("video",{ref:h,src:e,loop:i,muted:d,playsInline:!0,style:{width:"100%",height:"100%"},onLoadStart:()=>F(!0),onCanPlay:()=>{F(!1),E(!1)},onWaiting:()=>F(!0),onPlay:()=>B(!1),onLoadedMetadata:()=>{const y=h.current;y instanceof HTMLVideoElement&&y.videoWidth&&y.videoHeight&&R(y.videoWidth/y.videoHeight)},onEnded:()=>{i||(b(!1),_(0))},children:t.jsx("track",{kind:"captions"})})}),O&&!D&&t.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:t.jsx(j.CircleNotchIcon,{className:"size-8 animate-spin text-white/80",weight:"bold"})}),D&&!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:y=>{y.stopPropagation(),M()},onKeyDown:y=>{y.key!=="Enter"&&y.key!==" "||(y.preventDefault(),y.stopPropagation(),M())},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(j.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":W,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:f,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:V,onTouchStart:V,onClick:y=>y.stopPropagation(),onKeyDown:y=>{y.key==="ArrowRight"&&$(Math.min(1,x+.05)),y.key==="ArrowLeft"&&$(Math.max(0,x-.05))},children:t.jsx("div",{className:"w-full overflow-hidden rounded-full bg-white/30 h-1",children:t.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${W}%`}})})})}),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:y=>{y.stopPropagation(),b(A=>!A)},className:"shrink-0 text-white","aria-label":v?"Pause":"Play",children:v?t.jsx(j.PauseIcon,{className:"size-5",weight:"fill"}):t.jsx(j.PlayIcon,{className:"size-5 translate-x-px",weight:"fill"})}),t.jsxs("div",{role:"slider","aria-label":"Playback position","aria-valuenow":W,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:f,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:V,onTouchStart:V,onClick:y=>y.stopPropagation(),onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),onKeyDown:y=>{y.key==="ArrowRight"&&$(Math.min(1,x+.05)),y.key==="ArrowLeft"&&$(Math.max(0,x-.05))},children:[t.jsx("div",{className:`w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${L||N?"h-1.5":"h-1"}`,children:t.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${W}%`}})}),t.jsx("div",{className:`absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${L||N?"scale-100 opacity-100":"scale-0 opacity-0"}`,style:{left:`${W}%`}})]})]})]})},Lt=e=>e==="dark"?"size-12 text-white/20":"size-12 text-black/20",on=e=>e==="dark"?"aspect-video overflow-hidden bg-white/10":"aspect-video overflow-hidden bg-black/5",Ke=({mimeType:e,sourceUrl:s,thumbnailUrl:n,title:a,variant:r,mediaPlayerProps:i,containedImage:l=!1})=>{const o=te(e),[d,u]=m.useState(!1);return s&&(o==="video"||o==="audio")?t.jsx(rn,{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:()=>u(!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:()=>u(!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:ie(e,{className:Lt(r),weight:"regular"})}):n?t.jsx("div",{className:`relative ${on(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:ie(e,{className:Lt(r),weight:"regular"})})},Kt=({variant:e,thumbnail:s,title:n,placeholderTitle:a="Attachment title",mimeType:r,detail:i,statusBadge:l,action:o,topLeft:d,topRight:u,rootRef:g,"data-testid":h})=>{const f=e==="dark",c=f?n??a:n??"",p=f&&!n;return t.jsxs("div",{ref:g,"data-testid":h,className:k("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)]",f?"bg-[#1e2330]":"bg-white"),children:[d?t.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-50",children:d}):null,u?t.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-50",children:u}):null,s,t.jsxs("div",{className:"px-4 pb-3 pt-3",children:[c.trim()!==""&&t.jsx("p",{className:k("mb-0.5 truncate text-base font-medium",{"text-black":!f,"text-white/30":f&&p,"text-white":f&&!p}),children:c}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[ie(r,{className:k("size-5 shrink-0",f?"text-white/55":"text-black/55"),weight:"regular"}),i!=null&&i!==""&&t.jsx("span",{className:k("text-xs font-medium",f?"text-white/55":"text-black/55"),children:i}),l]}),o]})]})};function Zt(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ze(e){return`w-[280px] select-none overflow-hidden rounded-[24px] ${e?"bg-[#1e2330]":"bg-[#F3F3F1]"} shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]`}function ln(e){return e?"bg-white/10":"bg-black/5"}function cn(e){return e?"text-white":"text-black"}function dn(e){return e?"text-white/55":"text-black/55"}function un(e){return e?"text-white/40":"text-black/40"}function mn(e){return e?"text-white/20":"text-black/20"}const Je=({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,u=t.jsxs(m.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] ${ln(s)} flex items-center justify-center`,children:t.jsx(j.LinkIcon,{className:`size-12 ${mn(s)}`})})}),t.jsxs("div",{className:"px-3 pb-3",children:[n&&t.jsx("p",{className:`truncate text-[14px] font-medium leading-5 ${cn(s)}`,children:n}),a&&t.jsx("p",{className:`truncate text-[12px] leading-4 ${dn(s)}`,children:a}),d&&t.jsx("p",{className:`mt-1 truncate text-[12px] leading-4 ${un(s)}`,children:d})]})]});return d?t.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"block no-underline",children:u}):t.jsx("div",{className:"block",children:u})};function Qe(e){return e.type==="link"||!!e.og_scrape_url&&!e.asset_url}function Ie(e){var s;return(s=e.attachments)==null?void 0:s.find(Qe)}async function hn(e,s){let n;try{n=s??new URL(e).pathname.split("/").pop()??"download"}catch{n=s??"download"}const a=await fetch(e,{mode:"cors"});if(!a.ok)throw new Error(`HTTP ${a.status}`);const r=await a.blob(),i=URL.createObjectURL(r),l=document.createElement("a");l.href=i,l.download=n,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)}const xn=({url:e,filename:s})=>{const[n,a]=m.useState(!1),r=i=>{i.stopPropagation();const l=window.open("","_blank","noopener,noreferrer");a(!0),hn(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(j.CircleNotchIcon,{className:"size-4 animate-spin text-white",weight:"bold"}):t.jsxs(m.Fragment,{children:[t.jsx(j.DownloadSimpleIcon,{className:"size-4 text-white",weight:"bold"}),"Download"]})})};function Ee(e){var h,f,c,p;const s=(h=e.attachments)==null?void 0:h.find(v=>v.type==="video"&&v.asset_url),n=(f=e.attachments)==null?void 0:f.find(v=>v.type==="image"&&v.image_url),a=(c=e.attachments)==null?void 0:c.find(v=>v.type==="audio"&&v.asset_url),r=(p=e.attachments)==null?void 0:p.find(v=>v.type==="file"&&v.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,u=i==null?void 0:i.file_size,g=s==null?void 0:s.thumb_url;return{resolvedUrl:l,resolvedType:o,title:d,fileSize:u,thumbnailUrl:g}}const Jt=({resolvedUrl:e,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=a!==void 0?Zt(a):void 0;return t.jsx(Kt,{variant:"dark",title:n,placeholderTitle:"",mimeType:s,detail:i,thumbnail:t.jsx(Ke,{mimeType:s,sourceUrl:e,thumbnailUrl:r,title:n,variant:"dark"})})},Qt=({resolvedUrl:e,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=te(s),l=a!==void 0?Zt(a):void 0;return t.jsx(Kt,{variant:"light",title:n,mimeType:s,detail:l,thumbnail:t.jsx(Ke,{mimeType:s,sourceUrl:e,thumbnailUrl:r,title:n,variant:"light",containedImage:i==="image"||i==="document"}),action:t.jsx(xn,{url:e,filename:n})})},fn=({message:e,isMyMessage:s=!1})=>{const n=Ie(e),a=Ee(e);if(!n&&!a)return null;const r=s?"str-chat__message str-chat__message-simple str-chat__message--me str-chat__message-simple--me":"str-chat__message str-chat__message-simple str-chat__message--other";return t.jsxs("div",{className:r,"data-dd-privacy":"mask",children:[!s&&e.user&&t.jsx(J,{className:"str-chat__avatar str-chat__message-sender-avatar",id:e.user.id,image:e.user.image,name:e.user.name??e.user.id}),t.jsx("div",{className:"str-chat__message-inner",style:{marginInlineEnd:0,marginInlineStart:0},children:t.jsx("div",{className:"str-chat__message-bubble-wrapper",children:t.jsx("div",{className:"str-chat__message-bubble","data-attachment-bubble":"true",style:{padding:0,borderRadius:0,overflow:"visible",background:"transparent"},children:n?t.jsx("div",{className:Ze(s),children:t.jsx(Je,{attachment:n,isMyMessage:s})}):s?t.jsx(Jt,{...a}):t.jsx(Qt,{...a})})})})]})},gn=({message:e})=>{const s=Ie(e);if(s)return t.jsx("div",{className:Ze(!0),"data-dd-privacy":"mask",children:t.jsx(Je,{attachment:s,isMyMessage:!0})});const n=Ee(e);return n?t.jsx("div",{style:{display:"contents"},"data-dd-privacy":"mask",children:t.jsx(Jt,{...n})}):null},pn=({message:e})=>{const s=Ie(e);if(s)return t.jsx("div",{className:Ze(!1),"data-dd-privacy":"mask",children:t.jsx(Je,{attachment:s,isMyMessage:!1})});const n=Ee(e);return n?t.jsx("div",{style:{display:"contents"},"data-dd-privacy":"mask",children:t.jsx(Qt,{...n})}):null},bn=Object.assign(fn,{Creator:gn,Visitor:pn}),vn={dark:"bg-[#1e2330]",light:"bg-[#f2f1ef]"},jn={dark:"text-white",light:"text-[#000000]"},wn={dark:"border-white/[0.08]",light:"border-black/[0.08]"},_n=e=>e==="dark"?"sender":"receiver",Nn={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]"}},ge=({variant:e,text:s,bordered:n=!0,groupPosition:a="single",className:r,children:i,"data-testid":l})=>{const o=s!=null&&s!=="",d=Nn[_n(e)][a];return t.jsxs("div",{"data-testid":l,"data-group-position":a,className:k("relative w-[280px] overflow-hidden px-2 py-2",d,vn[e],jn[e],n&&"border",n&&wn[e],r),children:[i,o?t.jsx("p",{className:k("whitespace-pre-wrap break-words leading-snug","pt-2","px-2"),children:s}):null]})},pe=({onClick:e,variant:s="overlay",ariaLabel:n="Dismiss attachment"})=>t.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),e()},"aria-label":n,className:k("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(j.XIcon,{className:"size-3",weight:"bold"})}),be=e=>e==="received"?"light":"dark",es=({firstOfGroup:e,endOfGroup:s,groupedByUser:n})=>!n||e&&s?"single":e?"first":s?"end":"middle",yn=({src:e,mimeType:s,filename:n,items:a})=>a&&a.length>0?a:e?[{src:e,mimeType:s,filename:n}]:[],Cn=({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]}),et=({state:e,src:s,mimeType:n,filename:a,items:r,text:i,groupPosition:l,preload:o,onDismiss:d})=>{const u=be(e),g=e==="composer"&&!!d,h=yn({src:s,mimeType:n,filename:a,items:r});if(h.length===0)return null;const f=o??(h.length>1?"none":"metadata");return t.jsx(ge,{variant:u,text:i,groupPosition:l,"data-testid":"audio-attachment",children:t.jsx("div",{className:"flex flex-col gap-2",children:h.map((c,p)=>t.jsx(Cn,{item:c,preload:f,trailingAction:g&&p===0?t.jsx(pe,{onClick:d,variant:"inline"}):void 0},`${c.src}-${p}`))})})},kn=e=>t.jsx(et,{...e,state:"composer"}),Sn=e=>t.jsx(et,{...e,state:"sent"}),In=e=>t.jsx(et,{...e,state:"received"}),En={Composer:kn,Sent:Sn,Received:In};function ts(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 Tn={pdf:"PDF",doc:"DOC",xls:"XLS",csv:"CSV",ppt:"PPT",zip:"ZIP",text:"TXT",markdown:"MD"};function ss(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=Wt(e),i=Tn[r];if(i)return i;if(e==="application/octet-stream")return}const a=e.split("/")[1];if(!(!a||a==="*"))return a.toUpperCase()}function ns(e,s,n){const a=ss(e,s),r=typeof n=="number"&&n>0?ts(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 Mn={dark:"text-white/55",light:"text-black/65"},An={dark:"bg-white/10",light:"bg-black/5"},Rn={dark:"text-white/85",light:"text-black/85"},as=({variant:e,filename:s,title:n,mimeType:a="application/octet-stream",fileSize:r,onActivate:i,activateLabel:l,trailingAction:o})=>{const d=n??s??"File",u=ns(a,s,r),g=t.jsx("div",{className:k("flex size-10 shrink-0 items-center justify-center rounded-sm",An[e]),"aria-hidden":!0,children:ie(a,{className:k("size-6",Rn[e]),weight:"regular"})}),h=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}),u?t.jsx("p",{className:k("truncate text-xs leading-4",Mn[e]),children:u}):null]}),f=i?t.jsxs("button",{type:"button",onClick:i,"aria-label":l,className:k("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:[g,h]}):t.jsxs(t.Fragment,{children:[g,h]});return t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[f,o?t.jsx("div",{className:"shrink-0",children:o}):null]})};async function rs(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 Ln=({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}]:[],Dn=({variant:e,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??ee(s.src);return t.jsx(as,{variant:e,filename:i,title:s.title,mimeType:s.mimeType??"application/octet-stream",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Download ${i}`,trailingAction:r})},tt=({state:e,src:s,filename:n,fileSize:a,mimeType:r,title:i,items:l,text:o,groupPosition:d,onClick:u,onDismiss:g})=>{const h=be(e),f=e==="composer"&&!!g,c=Ln({src:s,filename:n,fileSize:a,mimeType:r,title:i,items:l}),p=b=>{if((u==null?void 0:u(b))===!1)return;const x=c[b];if(!x)return;const _=x.filename??ee(x.src);rs(x.src,_)};if(c.length===0)return null;const v=t.jsx("span",{className:k("flex size-8 items-center justify-center rounded-full",h==="dark"?"text-white/70":"text-black/70"),"aria-hidden":!0,children:t.jsx(j.DownloadSimpleIcon,{className:"size-5",weight:"bold"})});return t.jsx(ge,{variant:h,text:o,groupPosition:d,"data-testid":"file-attachment",children:t.jsx("div",{className:"flex flex-col gap-2",children:c.map((b,x)=>{const _=f&&x===0?t.jsx(pe,{onClick:g,variant:"inline"}):v;return t.jsx(Dn,{variant:h,item:b,index:x,onActivate:p,trailingAction:_},`${b.src}-${x}`)})})})},Fn=e=>t.jsx(tt,{...e,state:"composer"}),zn=e=>t.jsx(tt,{...e,state:"sent"}),Pn=e=>t.jsx(tt,{...e,state:"received"}),On={Composer:Fn,Sent:zn,Received:Pn},st=({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(j.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(j.CaretRightIcon,{size:20,weight:"bold","aria-hidden":!0})})]}),is=({url:e,filename:s,variant:n="pill",label:a="Download",iconOnly:r,tone:i="dark",onTriggered:l})=>{const[o,d]=m.useState(!1),u=m.useCallback(c=>{c.stopPropagation(),!o&&(d(!0),rs(e,s).catch(()=>{}).finally(()=>{d(!1),l==null||l()}))},[o,e,s,l]),g=r??n!=="pill",f={className:k(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:u,disabled:o,"aria-label":a,className:k("flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70",c[i]),children:o?t.jsx(j.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):t.jsx(j.DownloadSimpleIcon,{className:"size-5 shrink-0",weight:"bold","aria-hidden":!0})})}return n==="viewer"?t.jsx("button",{type:"button",onClick:u,disabled:o,"aria-label":a,className:"mes-media-viewer__action",children:o?t.jsx(j.CircleNotchIcon,{size:20,weight:"bold","aria-hidden":!0}):t.jsx(j.DownloadSimpleIcon,{size:20,weight:"bold","aria-hidden":!0})}):t.jsxs("button",{type:"button",onClick:u,disabled:o,"aria-label":g?a:void 0,className:k("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(j.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):t.jsx(j.DownloadSimpleIcon,{...f,"aria-hidden":!0}),g?null:a]})},Le=(e,s,n)=>Math.min(Math.max(e,s),n),nt=({length:e,initialIndex:s,open:n})=>{const a=Le(s,0,Math.max(e-1,0)),[r,i]=m.useState(a);m.useEffect(()=>{n&&i(Le(s,0,Math.max(e-1,0)))},[n,s,e]),m.useEffect(()=>{i(d=>Le(d,0,Math.max(e-1,0)))},[e]);const l=m.useCallback(()=>{e<=1||i(d=>d<=0?e-1:d-1)},[e]),o=m.useCallback(()=>{e<=1||i(d=>d>=e-1?0:d+1)},[e]);return m.useEffect(()=>{if(!n||e<=1)return;const d=u=>{if(u.key!=="ArrowLeft"&&u.key!=="ArrowRight")return;const g=document.activeElement;g&&(g.tagName==="VIDEO"||g.tagName==="AUDIO")||(u.preventDefault(),u.key==="ArrowLeft"?l():o())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n,e,l,o]),{index:r,prev:l,next:o}},at=({open:e,onClose:s,ariaLabel:n,counter:a,actions:r,children:i,"data-testid":l})=>{const o=m.useRef(null),d=m.useRef(null);m.useEffect(()=>{var f;const h=o.current;if(h){if(e){if(!h.open)if(typeof h.showModal=="function")try{h.showModal()}catch{h.setAttribute("open","")}else h.setAttribute("open","");const c=typeof document<"u"?document.activeElement:null;return(f=d.current)==null||f.focus(),()=>{if(h.open)if(typeof h.close=="function")try{h.close()}catch{h.removeAttribute("open")}else h.removeAttribute("open");c&&document.body.contains(c)&&c.focus()}}if(h.open)if(typeof h.close=="function")try{h.close()}catch{h.removeAttribute("open")}else h.removeAttribute("open")}},[e]);const u=()=>{s()},g=h=>{h.target===o.current&&s()};return t.jsxs("dialog",{ref:o,className:"mes-media-viewer","aria-label":n??"Attachment viewer","data-testid":l,onClose:u,onClick:g,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(j.XIcon,{size:20,weight:"bold","aria-hidden":!0})})]})]}),t.jsx("div",{className:"mes-media-viewer__body",children:i})]})},os=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=nt({length:s.length,initialIndex:n,open:e}),o=s[r],d=m.useMemo(()=>(o==null?void 0:o.filename)??(o?ee(o.src):"image"),[o]);return o?t.jsxs(at,{open:e,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,actions:t.jsx(is,{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(st,{onPrev:i,onNext:l,prevLabel:"Previous image",nextLabel:"Next image"}):null]}):null},$n="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",ls=({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,u,g)=>{const h=k($n,"h-full w-full");return s?t.jsxs("button",{type:"button",onClick:()=>s(u),"aria-label":d.ariaLabel??`Open media ${u+1}`,className:k(h,"cursor-zoom-in"),children:[d.content,g]},u):t.jsxs("div",{className:h,children:[d.content,g]},u)};return i.length===1?t.jsx("div",{className:k("aspect-square w-full",a),children:o(i[0],0)}):i.length===2?t.jsx("div",{className:k("grid aspect-[16/9] w-full grid-cols-2 gap-0.5",a),children:i.map((d,u)=>o(d,u))}):i.length===3?t.jsxs("div",{className:k("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:k("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:i.map((d,u)=>{const g=l>0&&u===i.length-1;return o(d,u,g?t.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-black/55 text-2xl font-semibold text-white",children:["+",l]}):null)})})},ve=e=>{const[s,n]=m.useState(!1),[a,r]=m.useState(0),i=m.useCallback(o=>{(e==null?void 0:e(o))!==!1&&(r(o),n(!0))},[e]),l=m.useCallback(()=>n(!1),[]);return{viewerOpen:s,viewerIndex:a,handleActivate:i,closeViewer:l}},Bn=(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"})}),Un=({src:e,alt:s,items:n})=>n&&n.length>0?n:e?[{src:e,alt:s}]:[],cs=(e,s)=>e.map((n,a)=>({src:n.src,alt:n.alt,filename:s&&e.length===1?s:s?`${s} (${a+1})`:void 0})),Vn=({src:e,alt:s,filename:n,loading:a="lazy",onClick:r,onDismiss:i})=>{const{viewerOpen:l,viewerIndex:o,handleActivate:d,closeViewer:u}=ve(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(pe,{onClick:i})}):null,t.jsx(os,{open:l,items:cs([{src:e,alt:s}],n),initialIndex:o,onClose:u})]})},ds=({state:e,src:s,alt:n,filename:a,items:r,text:i,groupPosition:l,loading:o="lazy",onClick:d})=>{const u=Un({src:s,alt:n,items:r}),g=be(e),{viewerOpen:h,viewerIndex:f,handleActivate:c,closeViewer:p}=ve(d);if(u.length===0)return null;const v=u.map((b,x)=>Bn(b,x,u.length,o));return t.jsxs(ge,{variant:g,text:i,groupPosition:l,"data-testid":"image-attachment",children:[t.jsx("div",{className:"relative",children:t.jsx(ls,{tiles:v,onTileActivate:c})}),t.jsx(os,{open:h,items:cs(u,a),initialIndex:f,onClose:p})]})},Gn=e=>t.jsx(Vn,{...e}),Hn=e=>t.jsx(ds,{...e,state:"sent"}),Yn=e=>t.jsx(ds,{...e,state:"received"}),qn={Composer:Gn,Sent:Hn,Received:Yn},Xn=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=nt({length:s.length,initialIndex:n,open:e}),o=s[r],d=m.useMemo(()=>(o==null?void 0:o.filename)??(o?ee(o.src):"document"),[o]),u=m.useMemo(()=>o?Wn(o.src):void 0,[o]);return!o||!u?null:t.jsxs(at,{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:u,title:d,className:"mes-media-viewer__iframe",sandbox:"allow-scripts allow-forms allow-popups allow-downloads"},`${r}:${o.src}`),s.length>1?t.jsx(st,{onPrev:i,onNext:l,prevLabel:"Previous document",nextLabel:"Next document"}):null]})},Wn=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()}`},Kn=({src:e,filename:s,fileSize:n,title:a,items:r})=>r&&r.length>0?r:e?[{src:e,filename:s,fileSize:n,title:a}]:[],Zn=({variant:e,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??ee(s.src);return t.jsx(as,{variant:e,filename:i,title:s.title,mimeType:"application/pdf",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Open ${i}`,trailingAction:r})},rt=({state:e,src:s,filename:n,fileSize:a,title:r,items:i,text:l,groupPosition:o,onClick:d,onDismiss:u})=>{const g=be(e),h=Kn({src:s,filename:n,fileSize:a,title:r,items:i}),{viewerOpen:f,viewerIndex:c,handleActivate:p,closeViewer:v}=ve(d),b=e==="composer"&&!!u;if(h.length===0)return null;const x=h.map(_=>({src:_.src,filename:_.filename??ee(_.src)}));return t.jsxs(ge,{variant:g,text:l,groupPosition:o,"data-testid":"pdf-attachment",children:[t.jsx("div",{className:"flex flex-col gap-2",children:h.map((_,N)=>{const S=_.filename??ee(_.src),L=b&&N===0?t.jsx(pe,{onClick:u,variant:"inline"}):e==="composer"?void 0:t.jsx(is,{url:_.src,filename:S,variant:"inline",label:`Download ${S}`,tone:g});return t.jsx(Zn,{variant:g,item:_,index:N,onActivate:p,trailingAction:L},`${_.src}-${N}`)})}),t.jsx(Xn,{open:f,items:x,initialIndex:c,onClose:v})]})},Jn=e=>t.jsx(rt,{...e,state:"composer"}),Qn=e=>t.jsx(rt,{...e,state:"sent"}),ea=e=>t.jsx(rt,{...e,state:"received"}),ta={Composer:Jn,Sent:Qn,Received:ea},us=({open:e,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=nt({length:s.length,initialIndex:n,open:e}),o=s[r],d=m.useMemo(()=>(o==null?void 0:o.filename)??(o?ee(o.src):"video"),[o]);return o?t.jsxs(at,{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(st,{onPrev:i,onNext:l,prevLabel:"Previous video",nextLabel:"Next video"}):null]}):null},sa=()=>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(j.PlayIcon,{className:"size-6",weight:"fill","aria-hidden":!0})})}),ms=({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(j.VideoCameraIcon,{className:"size-16 rounded-md text-white/30",weight:"regular","aria-hidden":!0})}),t.jsx(sa,{})]}),na=(e,s,n)=>({ariaLabel:`Play video ${s+1} of ${n}`,content:t.jsx(ms,{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}]:[],hs=(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})),ra=({src:e,poster:s,mimeType:n,filename:a,preload:r,onClick:i,onDismiss:l})=>{const{viewerOpen:o,viewerIndex:d,handleActivate:u,closeViewer:g}=ve(i);return t.jsxs("div",{className:"relative w-fit",children:[t.jsx("button",{type:"button",onClick:()=>u(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(ms,{item:{src:e,poster:s,mimeType:n},index:0})}),l?t.jsx("div",{className:"absolute right-2 top-2 z-10",children:t.jsx(pe,{onClick:l})}):null,t.jsx(us,{open:o,items:hs([{src:e,poster:s,mimeType:n,preload:r}],a),initialIndex:d,onClose:g})]})},xs=({state:e,src:s,poster:n,mimeType:a,filename:r,items:i,text:l,groupPosition:o,preload:d,onClick:u})=>{const g=aa({src:s,poster:n,mimeType:a,preload:d,items:i}),h=be(e),{viewerOpen:f,viewerIndex:c,handleActivate:p,closeViewer:v}=ve(u);if(g.length===0)return null;const b=g.map((x,_)=>na(x,_,g.length));return t.jsxs(ge,{variant:h,text:l,groupPosition:o,"data-testid":"video-attachment",children:[t.jsx("div",{className:"relative",children:t.jsx(ls,{tiles:b,onTileActivate:p,className:"overflow-hidden rounded-md"})}),t.jsx(us,{open:f,items:hs(g,r),initialIndex:c,onClose:v})]})},ia=e=>t.jsx(ra,{...e}),oa=e=>t.jsx(xs,{...e,state:"sent"}),la=e=>t.jsx(xs,{...e,state:"received"}),ca={Composer:ia,Sent:oa,Received:la},he={Image:qn,Video:ca,Audio:En,Pdf:ta,File:On},da={isUnlocking:()=>!1},ua={LockedAttachment:da},fs=m.createContext({}),ma=fs.Provider;function gs(e){return m.useContext(fs)[e]??ua[e]}const ha=({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})}),xa=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)==="MESSAGE_TIP"},fa=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)==="MESSAGE_PAID"},Ne=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)==="MESSAGE_CHATBOT"},ga=e=>{var s;return((s=e.metadata)==null?void 0:s.custom_type)==="MESSAGE_ATTACHMENT"},ps=e=>xa(e)||fa(e),pa=e=>{var s;return ps(e)&&!((s=e.text)!=null&&s.trim())},De=({message:e,standalone:s=!1,isMyMessage:n=!1,hasAttachment:a=!1})=>{var h;const r=ps(e),i=Ne(e);if(!r&&!i)return null;if(r){const f=(h=e.metadata)==null?void 0:h.amount_text;if(!f)return null;const c=s?"message-tip-standalone":"message-tag message-tag--tip",p=s?`${f} tip`:`Delivered with ${f} tip`;return t.jsxs("div",{className:c,children:[t.jsx(j.GiftIcon,{size:s?14:12}),t.jsx("span",{children:p})]})}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(" "),u=t.jsx("span",{className:"message-chatbot-indicator__label",children:o}),g=t.jsx("span",{className:"message-chatbot-indicator__icon",children:t.jsx(ha,{size:l?12:15})});return t.jsx("div",{className:d,"data-testid":"message-chatbot-indicator",children:n&&!l?t.jsxs(t.Fragment,{children:[u,g]}):t.jsxs(t.Fragment,{children:[g,u]})})},bs=({selected:e,onVoteUp:s,onVoteDown:n})=>t.jsxs("div",{className:"message-vote-buttons",children:[t.jsx("button",{type:"button",className:k("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(j.ThumbsUpIcon,{size:16,weight:e==="up"?"fill":"regular"})}),t.jsx("button",{type:"button",className:k("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(j.ThumbsDownIcon,{size:16,weight:e==="down"?"fill":"regular"})})]}),Fe=()=>{const{message:e}=w.useMessageContext("SentMessageDeliveryStatus"),{messages:s}=w.useChannelStateContext("SentMessageDeliveryStatus"),n=(()=>{if(s)for(let a=s.length-1;a>=0;a-=1){const r=s[a];if(!(r.type==="system"||r.type==="ephemeral"||r.type==="deleted"))return r.id}})();return e.id!==n?null:t.jsxs(t.Fragment,{children:[t.jsx(j.ChecksIcon,{weight:"bold","aria-hidden":"true"}),t.jsx("span",{"data-testid":"sent-message-delivery-status",children:"Delivered"})]})},ba=()=>null,va=()=>t.jsx(w.MessageStatus,{MessageSentStatus:Fe,MessageDeliveredStatus:Fe,MessageReadStatus:Fe,MessageSendingStatus:ba}),ja=/^([a-z][a-z0-9+.-]*):/i,wa=new Set(["http","https","mailto","tel","sms"]);function it(e){if(typeof e!="string")return;const s=e.trim();if(s==="")return;const n=ja.exec(s);if(n){const a=n[1].toLowerCase();return wa.has(a)?s:void 0}return s.startsWith("//")||s.startsWith("/")?s:`https://${s}`}const _a={dark:"bg-white text-[#121110] hover:bg-white/90",light:"bg-[#121110] text-white hover:bg-[#2a2928]"},Na=({variant:e,cta:s})=>{const n=k("mt-2 inline-flex h-10 w-full items-center justify-center rounded-full px-4 text-sm font-medium leading-none transition-colors",_a[e]),a=it(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})},ya={dark:"text-white",light:"text-black/90"},Ca="text-white/30",ka={dark:"text-white/55",light:"text-black/55"},ot=({variant:e,title:s,placeholderTitle:n,description:a,url:r,appIcon:i,cta:l,trailingAction:o})=>{const d=e==="dark",u=s??(d?n:void 0)??"",g=u.trim()!=="",h=a!=null&&a.trim()!=="",f=typeof r=="string"?r.trim():"",c=f!=="",p=l!=null;if(!g&&!h&&!c&&!p)return null;const b=k("truncate text-base font-medium leading-6",d&&!s?Ca:ya[e]),x=k("truncate text-xs leading-4",ka[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:[g&&t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[i?t.jsx("span",{className:"shrink-0",children:i}):null,t.jsx("p",{className:k("min-w-0",b),children:u})]}),h&&t.jsx("p",{className:x,children:a})]}),!p&&c&&t.jsx("p",{className:x,children:f})]}),o&&t.jsx("div",{className:"shrink-0",children:o})]}),l&&t.jsx(Na,{variant:e,cta:l})]})},Sa=k("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)]"),ye=({variant:e,children:s,href:n,onClick:a,ariaLabel:r,rootRef:i,topRight:l,bgClassName:o,"data-testid":d})=>{const u=n!=null||a!=null,g=k(Sa,o??(e==="dark"?"bg-[#1e2330]":"bg-white"),u?"cursor-pointer no-underline focus-ring":null),h=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:g,children:[s,h]}):a?t.jsxs("button",{ref:i,type:"button",onClick:a,"aria-label":r,"data-testid":d,className:k(g,"text-left"),children:[s,h]}):t.jsxs("div",{ref:i,"data-testid":d,className:g,children:[s,h]})},Ia={dark:"bg-white/10",light:"bg-black/5"},Ea={dark:"size-16 text-white/25",light:"size-16 text-black/25"},Te=(e,s)=>!!s&&!!e&&te(e)==="audio",lt=(e,s)=>{if(!s||!e)return!1;const n=te(e);return n==="video"||n==="audio"},ct="bg-[#F2F3F4]",Ce=({variant:e,thumbnailUrl:s,sourceUrl:n,title:a,mimeType:r="image/*",topLeft:i,topRight:l})=>{const o=te(r),d=!!n&&o==="video";return Te(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:k("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:k("flex h-full w-full items-center justify-center",Ia[e]),children:ie(r,{className:Ea[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]})},Ta=({title:e,placeholderTitle:s,description:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:l,layout:o="featured",appIcon:d,cta:u,onDismiss:g,onEditClick:h})=>{const f=o==="classic",c=Te(r,l),p=g?t.jsx("button",{type:"button",onClick:g,"aria-label":"Dismiss attachment",className:"flex size-6 items-center justify-center rounded-full bg-[#121110] text-white",children:t.jsx(j.XIcon,{className:"size-3",weight:"bold"})}):void 0,v=h?t.jsx("button",{type:"button",onClick:h,"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(j.PencilSimpleIcon,{className:"size-5",weight:"regular"})}):void 0;return c?t.jsx(ye,{variant:"dark",bgClassName:ct,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(Ce,{variant:"dark",sourceUrl:l,title:e,mimeType:r})}),p&&t.jsx("div",{className:"shrink-0",children:p})]})}):t.jsxs(ye,{variant:"dark",topRight:f?p:void 0,children:[!f&&t.jsx(Ce,{variant:"dark",thumbnailUrl:i,sourceUrl:l,title:e,mimeType:r,topRight:p}),t.jsx(ot,{variant:"dark",title:e,placeholderTitle:s,description:n,url:a,appIcon:d,cta:u,trailingAction:v})]})},Ma=({title:e,description:s,url:n,mimeType:a,thumbnailUrl:r,sourceUrl:i,layout:l="featured",appIcon:o,cta:d,onClick:u})=>{const g=lt(a,i),h=it(n),f=d==null&&h!=null&&!g?h:void 0,c=d==null&&!g?u:void 0,p=Te(a,i)?ct:void 0,v=d&&u?{...d,onClick:()=>{var b;u(),(b=d.onClick)==null||b.call(d)}}:d;return t.jsxs(ye,{variant:"light",href:f,onClick:c,ariaLabel:e??"Open attachment preview",bgClassName:p,"data-testid":"link-attachment",children:[l==="featured"&&t.jsx(Ce,{variant:"light",thumbnailUrl:r,sourceUrl:i,title:e,mimeType:a}),t.jsx(ot,{variant:"light",title:e,description:s,url:n,appIcon:o,cta:v})]})},Aa=({title:e,placeholderTitle:s,description:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:l,layout:o="featured",appIcon:d,cta:u,onClick:g})=>{const h=lt(r,l),f=it(a),c=u==null&&f!=null&&!h?f:void 0,p=u==null&&!h&&c!=null?g:void 0;return t.jsxs(ye,{variant:"dark",href:c,onClick:p,bgClassName:Te(r,l)?ct:void 0,children:[o==="featured"&&t.jsx(Ce,{variant:"dark",thumbnailUrl:i,sourceUrl:l,title:e,mimeType:r}),t.jsx(ot,{variant:"dark",title:e,placeholderTitle:s,description:n,url:a,appIcon:d,cta:u})]})},Ge={Composer:Ta,Sent:Aa,Received:Ma};function P(e){const s=e==null?void 0:e.trim();return s||void 0}function Dt(e){return e.trim().replace(/^https?:\/\//i,"").replace(/\/+$/,"").toLowerCase()}function Ra(e,s){if(!(e!=null&&e.trim())||!(s!=null&&s.trim()))return!1;const n=Dt(e),a=Dt(s);if(n===a)return!0;if(!n.includes(a))return!1;const r=n.split(a).join("");return!/[^\p{P}\p{Z}\p{C}]/u.test(r)}function Ft(e){const s=P(e.og_scrape_url)??P(e.title_link),n=P(e.image_url)??P(e.thumb_url),a=P(e.asset_url),r=P(e.mime_type);return{title:P(e.title),description:P(e.text),url:s,thumbnailUrl:n,sourceUrl:a,layout:n||lt(r,a)?"featured":"classic",mimeType:r}}function La(e){var s;return vs(e)?null:e.type==="image"?e.image_url||e.asset_url?"image":null:e.type==="video"&&e.asset_url?"video":e.type==="audio"&&e.asset_url?"audio":e.type==="file"&&e.asset_url?e.mime_type==="application/pdf"?"pdf":(s=e.mime_type)!=null&&s.startsWith("audio/")?"audio":"file":null}function vs(e){const s=P(e.og_scrape_url);return e.type==="link"||!!s&&!e.asset_url}function js(e){if(!(e!=null&&e.length))return[];const s=[],n=(r,i)=>{const l=s[s.length-1];if((l==null?void 0:l.type)==="media"&&l.kind===r){l.attachments.push(i);return}s.push({type:"media",kind:r,attachments:[i]})},a=r=>{const i=s[s.length-1];if((i==null?void 0:i.type)==="link"){i.attachments.push(r);return}s.push({type:"link",attachments:[r]})};for(const r of e){if(vs(r)){a(r);continue}const i=La(r);i&&n(i,r)}return s}function Da(e){return e.filter(s=>s.type==="media").length}function Fa(e,s,n){return s<=1?n:e===0?"first":e===s-1?"end":"middle"}function zt(e){return P(e.image_url)??P(e.asset_url)??""}function za(e){switch(e){case"image":return he.Image;case"video":return he.Video;case"audio":return he.Audio;case"pdf":return he.Pdf;default:return he.File}}function Pa(e,s){if(s.length>1)switch(e){case"image":return{items:s.map(a=>({src:zt(a),alt:P(a.title)}))};case"video":return{items:s.map(a=>({src:P(a.asset_url)??"",poster:P(a.thumb_url),mimeType:P(a.mime_type)}))};case"audio":return{items:s.map(a=>({src:P(a.asset_url)??"",mimeType:P(a.mime_type)??"audio/mpeg",filename:P(a.title)}))};case"pdf":return{items:s.map(a=>({src:P(a.asset_url)??"",filename:P(a.title),fileSize:a.file_size}))};case"file":return{items:s.map(a=>({src:P(a.asset_url)??"",filename:P(a.title),fileSize:a.file_size,mimeType:P(a.mime_type)??"application/octet-stream"}))}}const n=s[0];if(!n)return{};switch(e){case"image":return{src:zt(n),alt:P(n.title)};case"video":return{src:P(n.asset_url)??"",poster:P(n.thumb_url),mimeType:P(n.mime_type)};case"audio":return{src:P(n.asset_url)??"",mimeType:P(n.mime_type)??"audio/mpeg",filename:P(n.title)};case"pdf":return{src:P(n.asset_url)??"",filename:P(n.title),fileSize:n.file_size};case"file":return{src:P(n.asset_url)??"",filename:P(n.title),fileSize:n.file_size,mimeType:P(n.mime_type)??"application/octet-stream"}}}function Oa({groupPosition:e,isMyMessage:s,segment:n}){const a=za(n.kind),r={...Pa(n.kind,n.attachments),groupPosition:e};return s?t.jsx(a.Sent,{...r}):t.jsx(a.Received,{...r})}const $a=({groupPosition:e,isMyMessage:s,message:n,renderText:a})=>{var p;const r=js(n.attachments);if(r.length===0)return null;const i=Da(r),l=(p=n.text)==null?void 0:p.trim(),o=r.find(v=>v.type==="link"),d=(o==null?void 0:o.type)==="link"?Ft(o.attachments[0]??{}).url:void 0,u=l&&Ra(l,d)?void 0:l;let g=0;const h=[],f=(v,b)=>{const x=s?Ge.Sent:Ge.Received;h.push(t.jsx(x,{...Ft(v)},b))},c=(v,b)=>{const x=Fa(g,i,e);g+=1,h.push(t.jsx(Oa,{groupPosition:x,isMyMessage:s,segment:v},b))};return r.forEach((v,b)=>{if(v.type==="link"){v.attachments.forEach((x,_)=>{f(x,`link-${b}-${_}`)});return}c(v,`media-${b}`)}),t.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[t.jsxs("div",{className:"str-chat__message-bubble","data-attachment-bubble":"true",style:{background:"transparent",borderRadius:0,overflow:"visible",padding:0},children:[h,!u&&t.jsx(w.MessageErrorIcon,{})]}),u?t.jsxs("div",{className:"str-chat__message-bubble",children:[t.jsx(w.MessageText,{message:n,renderText:a}),t.jsx(w.MessageErrorIcon,{})]}):null]})},Ba=e=>{var gt,pt,bt,vt,jt,wt,_t,Nt,yt,Ct,kt,St,It,Et;const{additionalMessageInputProps:s,chatbotVotingEnabled:n,editing:a,endOfGroup:r,firstOfGroup:i,groupedByUser:l,handleAction:o,handleOpenThread:d,handleRetry:u,highlighted:g,isMessageAIGenerated:h,isMyMessage:f,message:c,renderText:p,threadList:v,viewerLanguage:b}=e,{client:x}=w.useChatContext("CustomMessage"),{channel:_}=w.useChannelStateContext("CustomMessage"),{isUnlocking:N,onUnlockClick:S,onFetchSource:L,onDownloadClick:I}=gs("LockedAttachment"),[D,B]=m.useState(!1),O=w.useMessageReminder(c.id),{selected:F,voteUp:C,voteDown:E}=Ht(c),{Attachment:T=w.Attachment,EditMessageModal:R=w.EditMessageModal,MessageActions:M,MessageBlocked:z=w.MessageBlocked,MessageBouncePrompt:$=w.MessageBouncePrompt,MessageDeleted:V=w.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:X=w.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:Z=w.MessageRepliesCountButton,ReminderNotification:W=w.ReminderNotification,StreamedMessageText:y=w.StreamedMessageText,PinIndicator:A}=w.useComponentContext("CustomMessage"),G=w.messageHasAttachments(c),Y=w.messageHasReactions(c),H=m.useMemo(()=>h==null?void 0:h(c),[h,c]),U=m.useMemo(()=>{const re=c.attachments??[],de=c.shared_location?[c.shared_location,...re]:re;if(!Ne(c))return de;const Tt=de.filter(Mt=>!("type"in Mt)||!Qe(Mt));return Tt.length===de.length?de:Tt},[c]),q=m.useMemo(()=>js(U),[U]),K=m.useMemo(()=>{const re=Xe({message:c,viewerLanguage:b});return re===c.text?c:{...c,text:re}},[c,b]),ne=q.length>0,je=q.reduce((re,de)=>re+de.attachments.length,0)===((U==null?void 0:U.length)??0),we=es({endOfGroup:r,firstOfGroup:i,groupedByUser:l});if(w.isDateSeparatorMessage(c))return null;if(c.deleted_at||c.type==="deleted")return t.jsx(V,{message:c});if(w.isMessageBlocked(c))return t.jsx(z,{});const Q=!v&&!!c.reply_count,ae=!v&&c.show_in_channel&&c.parent_id,se=c.status==="failed"&&((gt=c.error)==null?void 0:gt.status)!==403,mt=w.isMessageBounced(c);let oe;se?oe=()=>u(c):mt&&(oe=()=>B(!0));const le=f(),Es=k("str-chat__message str-chat__message-simple",`str-chat__message--${c.type}`,`str-chat__message--${c.status}`,le?"str-chat__message--me str-chat__message-simple--me":"str-chat__message--other",c.text?"str-chat__message--has-text":"has-no-text",{"str-chat__message--has-attachment":G,"str-chat__message--highlighted":g,"str-chat__message--pinned pinned-message":c.pinned,"str-chat__message--with-reactions":Y,"str-chat__message-send-can-be-retried":(c==null?void 0:c.status)==="failed"&&((pt=c==null?void 0:c.error)==null?void 0:pt.status)!==403,"str-chat__message-with-thread-link":Q||ae,"str-chat__virtual-message__wrapper--end":r,"str-chat__virtual-message__wrapper--first":i,"str-chat__virtual-message__wrapper--group":l}),Me=c.poll_id&&x.polls.fromState(c.poll_id),ht=pa(c),ce=Ne(c),xt=ga(c),Ae=!!(U!=null&&U.length&&!c.quoted_message),ft=ce&&le&&Ae,Ts=ne&&je&&!c.quoted_message&&!Me&&!H&&!ce;return t.jsxs(t.Fragment,{children:[a&&t.jsx(R,{additionalMessageInputProps:s}),D&&t.jsx(w.MessageBounceModal,{MessageBouncePrompt:$,onClose:()=>B(!1),open:D}),t.jsxs("div",{className:Es,"data-message-id":c.id,"data-dd-privacy":"mask",children:[A&&t.jsx(A,{}),!!O&&t.jsx(W,{reminder:O}),c.user&&t.jsx(J,{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:k("str-chat__message-inner",{"str-chat__simple-message--error-failed":se||mt}),"data-testid":"message-inner",onClick:oe,onKeyDown:oe,role:oe?"button":void 0,tabIndex:oe?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:xt?t.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[le?t.jsxs("div",{className:"flex items-center gap-2",children:[M&&t.jsx(M,{}),t.jsx(Ve.Sent,{title:(bt=c.metadata)==null?void 0:bt.attachment_title,mimeType:(vt=c.metadata)==null?void 0:vt.attachment_mime_type,thumbnailUrl:(jt=c.metadata)==null?void 0:jt.attachment_thumbnail,amountText:(wt=c.metadata)==null?void 0:wt.amount_text,detail:(_t=c.metadata)==null?void 0:_t.attachment_detail,paymentStatus:(Nt=c.metadata)==null?void 0:Nt.payment_status,onPreviewClick:()=>S==null?void 0:S(c,_),onFetchSource:async()=>await(L==null?void 0:L(c,_))})]}):t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ve.Received,{title:(yt=c.metadata)==null?void 0:yt.attachment_title,mimeType:(Ct=c.metadata)==null?void 0:Ct.attachment_mime_type,thumbnailUrl:(kt=c.metadata)==null?void 0:kt.attachment_thumbnail,amountText:(St=c.metadata)==null?void 0:St.amount_text,detail:(It=c.metadata)==null?void 0:It.attachment_detail,paymentStatus:(Et=c.metadata)==null?void 0:Et.payment_status,isUnlocking:N(c.id),onUnlockClick:()=>S==null?void 0:S(c,_),onFetchSource:async()=>await(L==null?void 0:L(c,_)),onDownloadClick:()=>I==null?void 0:I(c,_)}),M&&t.jsx(M,{})]}),c.text&&t.jsx("div",{className:"str-chat__message-bubble",children:t.jsx(w.MessageText,{message:K,renderText:p})})]}):ht?t.jsx(De,{message:c,standalone:!0}):Ts?t.jsx($a,{groupPosition:we,isMyMessage:le,message:{...K,attachments:U,i18n:void 0},renderText:p}):t.jsx("div",{className:"str-chat__message-bubble-wrapper",children:t.jsxs("div",{className:"str-chat__message-bubble",children:[ce&&!ft&&t.jsx(De,{message:c,hasAttachment:Ae,isMyMessage:le}),Me&&t.jsx(w.Poll,{poll:Me}),U!=null&&U.length&&!c.quoted_message?t.jsx(T,{actionHandler:o,attachments:U}):null,H?t.jsx(y,{message:K,renderText:p}):t.jsx(w.MessageText,{message:K,renderText:p}),t.jsx(w.MessageErrorIcon,{})]})})}),!xt&&!ht&&t.jsxs("div",{className:"str-chat__message-footer",children:[(!ce||ft)&&t.jsx(De,{message:c,hasAttachment:Ae,isMyMessage:le}),n&&ce&&t.jsx(bs,{selected:F,onVoteUp:C,onVoteDown:E})]}),t.jsx(va,{}),Q&&t.jsx(Z,{onClick:d,reply_count:c.reply_count}),ae&&t.jsx(X,{})]},c.id)]})},Ua=m.memo(Ba,(e,s)=>e.chatbotVotingEnabled!==s.chatbotVotingEnabled||e.viewerLanguage!==s.viewerLanguage?!1:w.areMessageUIPropsEqual(e,s)),Va=e=>{const s=w.useMessageContext("CustomMessage");return t.jsx(Ua,{...s,...e})},Ga=()=>{var n;const{handleDelete:e,message:s}=w.useMessageContext("CustomMessageActions");return((n=s.metadata)==null?void 0:n.payment_status)==="paid"?null:t.jsx(He.DefaultDropdownActionButton,{onClick:e,"aria-label":"Delete",title:"Delete",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:t.jsx(j.TrashSimpleIcon,{size:16,weight:"light","aria-hidden":!0})})},Ha=()=>{const{handleFlag:e}=w.useMessageContext("CustomMessageActions");return t.jsx(He.DefaultDropdownActionButton,{onClick:e,"aria-label":"Report",title:"Report",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:t.jsx(j.FlagIcon,{size:16,weight:"light","aria-hidden":!0})})},Ya=()=>{var s;const{message:e}=w.useMessageContext("CustomMessageActions");return((s=e.metadata)==null?void 0:s.custom_type)!=="MESSAGE_ATTACHMENT"?null:t.jsx(He.MessageActions,{messageActionSet:[{Component:Ga,placement:"quick",type:"delete"},{Component:Ha,placement:"quick",type:"flag"}]})},qa=({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-[#1e2330] 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(j.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})]})]})},Xa=e=>({linkPreviews:Array.from(e.previews.values()).filter(s=>Oe.LinkPreviewsManager.previewIsLoaded(s)||Oe.LinkPreviewsManager.previewIsLoading(s))}),Wa=()=>{const{linkPreviewsManager:e}=w.useMessageComposer(),{linkPreviews:s}=w.useStateStore(e.state,Xa),n=r=>{e.dismissPreview(r)};return s.length>0?t.jsx("div",{className:"messaging-link-preview-list flex min-h-0 flex-col items-stretch w-full gap-2 mb-4 overflow-y-auto overscroll-contain",children:s.map(r=>t.jsx("div",{className:"w-full shrink-0",children:t.jsx(qa,{link:r,onDismiss:n})},r.og_scrape_url))}):null},dt=m.createContext(!1),Ka=()=>m.useContext(dt),Za=({sendMessage:e,disabled:s,...n})=>t.jsx("button",{...n,type:"button","aria-label":"Send",disabled:s,onClick:e,children:t.jsx(j.ArrowUpIcon,{weight:"bold",className:"size-4"})}),Ja=()=>{const e=m.useContext(dt),{handleSubmit:s}=w.useMessageInputContext(),n=w.useMessageComposerHasSendableData(),a=e||!n,{SendButton:r=Za,AttachmentPreviewList:i=w.AttachmentPreviewList}=w.useComponentContext("CustomMessageInput");return t.jsxs("div",{className:"central-container flex min-h-0 flex-col gap-2 min-w-0 w-full self-stretch 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)]","data-dd-privacy":"mask",children:[t.jsx(w.QuotedMessagePreview,{}),t.jsx(Wa,{}),t.jsx(i,{}),t.jsxs("div",{className:"flex shrink-0",children:[t.jsx("div",{className:"w-full ml-2 mr-4 self-center leading-[0]",children:t.jsx(w.TextareaComposer,{"aria-disabled":e||void 0,className:"w-full resize-none outline-none leading-5 placeholder:text-black/30 text-sm",autoFocus:!e,enterKeyHint:"send",maxRows:4,readOnly:e,tabIndex:e?-1:void 0})}),t.jsx(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"})]})]})},Qa=({renderActions:e,renderFooter:s,disabled:n=!1,disabledReason:a,composerInput:r})=>{var o;const{channel:i}=w.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 min-h-0 flex-col gap-4 p-4",children:[t.jsxs("div",{inert:l?"":void 0,"aria-disabled":l||void 0,className:"message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40",children:[e&&t.jsx("div",{className:"flex h-12 shrink-0 items-center justify-center",children:e()}),t.jsx(dt.Provider,{value:l,children:t.jsx(w.MessageInput,{Input:r??Ja})})]}),s==null?void 0:s()]})},er=["SYSTEM_DM_AGENT_PAUSED","SYSTEM_DM_AGENT_RESUMED"],tr={SYSTEM_DM_AGENT_PAUSED:"DM Agent has left the conversation",SYSTEM_DM_AGENT_RESUMED:"DM Agent has rejoined the conversation"},sr=["SYSTEM_AGE_SAFETY_BLOCKED"],nr={SYSTEM_AGE_SAFETY_BLOCKED:"This user isn’t able to reply because they don’t meet our age safety guidelines."},ze="age safety guidelines.",ar="https://linktr.ee/s/about/contact",Pt=e=>er.includes(e),rr=e=>sr.includes(e),ir=e=>{var a;const s=(a=e.metadata)==null?void 0:a.custom_type;if(Pt(s))return{kind:"dm-agent",type:s};if(rr(s))return{kind:"age-safety",type:s};const n=e.dm_agent_system_type;if(Pt(n))return{kind:"dm-agent",type:n}},or=e=>{const s=e.indexOf(ze);if(s===-1)return e;const n=s+ze.length;return t.jsxs(t.Fragment,{children:[e.slice(0,s),t.jsx("a",{href:ar,target:"_blank",rel:"noopener noreferrer",className:"mes-age-safety-system-message__emphasis font-medium text-inherit underline",children:ze}),e.slice(n)]})},lr=e=>{var a,r;const s=e.message.hide_date===!0,n=ir(e.message);if((n==null?void 0:n.kind)==="dm-agent"){const i=((a=e.message.text)==null?void 0:a.trim())||tr[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(j.SparkleIcon,{size:16,weight:"regular","aria-hidden":!0,className:"mes-dm-agent-system-message__sparkle shrink-0"}),t.jsx("p",{className:"mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]",children:i})]}),!s&&t.jsx(w.MessageTimestamp,{message:e.message})]})}if((n==null?void 0:n.kind)==="age-safety"){const i=((r=e.message.text)==null?void 0:r.trim())||nr[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(j.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:or(i)})})]}),!s&&t.jsx(w.MessageTimestamp,{message:e.message})]})}return t.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[t.jsxs("div",{className:"str-chat__message--system__text",children:[t.jsx("div",{className:"str-chat__message--system__line"}),t.jsx("p",{children:e.message.text}),t.jsx("div",{className:"str-chat__message--system__line"})]}),!s&&t.jsx(w.MessageTimestamp,{message:e.message})]})},ws=m.createContext(!1),Pe=({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"})}),cr=new Set([w.AIStates.Thinking,w.AIStates.Generating,w.AIStates.ExternalSources]),dr=({threadList:e})=>{var p,v;const{channel:s,channelConfig:n,thread:a}=w.useChannelStateContext(),{client:r}=w.useChatContext(),{typing:i={}}=w.useTypingContext(),{aiState:l}=w.useAIState(s),o=m.useContext(ws);if(!e&&o&&cr.has(l)){const b=ur(s,(p=r.user)==null?void 0:p.id);return t.jsx(Ot,{avatarId:(b==null?void 0:b.id)??"ai-agent",avatarName:(b==null?void 0:b.name)??(b==null?void 0:b.id)??"Agent",avatarImage:b==null?void 0:b.image,testId:"typing-indicator-ai"})}if((n==null?void 0:n.typing_events)===!1)return null;const u=e?[]:Object.values(i).filter(({parent_id:b,user:x})=>{var _;return(x==null?void 0:x.id)!==((_=r.user)==null?void 0:_.id)&&!b}),g=e?Object.values(i).filter(({parent_id:b,user:x})=>{var _;return(x==null?void 0:x.id)!==((_=r.user)==null?void 0:_.id)&&b===(a==null?void 0:a.id)}):[],h=e?g:u;if(!h.length)return null;const f=(v=h[0])==null?void 0:v.user,c=f!=null&&f.id&&s.state.members[f.id]?s.state.members[f.id].user:void 0;return t.jsx(Ot,{avatarId:(f==null?void 0:f.id)??(c==null?void 0:c.id)??"typing-user",avatarName:(f==null?void 0:f.name)??(c==null?void 0:c.name)??(f==null?void 0:f.id)??"Typing user",avatarImage:(f==null?void 0:f.image)??(c==null?void 0:c.image),testId:"typing-indicator"})},Ot=({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(J,{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(Pe,{cx:"4",index:0}),t.jsx(Pe,{cx:"16",index:1}),t.jsx(Pe,{cx:"28",index:2})]})})})})})})]})});function ur(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 _s=()=>null,mr=({className:e,message:s})=>t.jsxs("div",{className:k("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})]}),ke=m.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(mr,{className:"w-6 h-6"}),t.jsx("span",{className:"text-sm text-stone",children:"Loading messages"})]})}));ke.displayName="LoadingState";const ue="size-10 rounded-full hover:bg-[#E5E4E1] flex items-center justify-center transition-colors duration-150 focus-ring",_e="Replies instantly with AI assistant",hr=({onBack:e,showBackButton:s,showStarButton:n=!1,dmAgentEnabled:a=!1,onLeaveConversation:r,onBlockParticipant:i,showDeleteConversation:l=!0,showBlockParticipant:o=!0,showReportParticipant:d=!0,onDeleteConversationClick:u,onBlockParticipantClick:g,onReportParticipantClick:h,customChannelActions:f,renderChannelActions:c,showChannelInfo:p=!0,onParticipantNameClick:v,renderHeaderTitleBadges:b})=>{var E,T,R,M,z,$;const{channel:x}=w.useChannelStateContext(),{client:_}=w.useChatContext(),N=m.useMemo(()=>{var V;return fe((V=x.state)==null?void 0:V.members,_==null?void 0:_.userID,x.type)},[(E=x.state)==null?void 0:E.members,_==null?void 0:_.userID,x.type]),S=Se(N==null?void 0:N.user),L=(T=N==null?void 0:N.user)==null?void 0:T.image,I=qe(x),D=b==null?void 0:b({channel:x,participant:N}),B="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",O="flex min-w-0 max-w-full items-center gap-4 rounded-[12px] px-1 py-0.5 text-left text-black/90",F=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"min-w-0 truncate",children:S}),D&&t.jsx("span",{className:"shrink-0",children:D})]}),C=async()=>{try{I?await x.unpin():await x.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:k(ue,"messaging-channel-view-back-button-mobile bg-[#F1F0EE]"),onClick:e||(()=>{}),type:"button","aria-label":"Back to conversations",children:t.jsx(j.ArrowLeftIcon,{className:"size-5 text-black/90"})})}),t.jsx("div",{className:"flex flex-col gap-1 items-center","data-dd-privacy":"mask",children:v?t.jsxs("button",{type:"button",onClick:v,"aria-label":`View details for ${S}`,className:k(B,"appearance-none border-0 bg-transparent transition-opacity hover:opacity-70 focus-ring focus-visible:outline-none"),children:[t.jsx(J,{id:((R=N==null?void 0:N.user)==null?void 0:R.id)||x.id||"unknown",name:S,image:L,starred:n&&I,dmAgentEnabled:a,size:48}),t.jsxs("span",{className:"flex max-w-full items-center gap-0.5",children:[F,t.jsx(j.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(j.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),t.jsx("span",{children:_e})]})]}):t.jsxs("div",{className:B,children:[t.jsx(J,{id:((M=N==null?void 0:N.user)==null?void 0:M.id)||x.id||"unknown",name:S,image:L,starred:n&&I,dmAgentEnabled:a,size:48}),t.jsxs("p",{className:"flex max-w-full items-center justify-center gap-0.5",children:[F,t.jsx(j.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(j.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),t.jsx("span",{children:_e})]})]})}),t.jsxs("div",{className:"flex justify-end items-center gap-2",children:[n&&t.jsx("button",{className:ue,onClick:C,type:"button","aria-label":I?"Unstar conversation":"Star conversation",children:t.jsx(j.StarIcon,{className:k("size-5",{"text-yellow-600":I,"text-black/90":!I}),weight:I?"duotone":"regular"})}),p&&(c!==void 0?c:t.jsx($e,{channel:x,participant:N,showDeleteConversation:l,showBlockParticipant:o,showReportParticipant:d,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:u,onBlockParticipantClick:g,onReportParticipantClick:h,customChannelActions:f,triggerClassName:k(ue,"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","data-dd-privacy":"mask",children:[s&&e&&t.jsx("button",{className:k(ue,"messaging-channel-view-back-button-desktop"),type:"button",onClick:e,"aria-label":"Back to conversations",children:t.jsx(j.ArrowLeftIcon,{className:"size-5 text-black/90"})}),v?t.jsxs("button",{type:"button",onClick:v,"aria-label":`View details for ${S}`,className:k(O,"appearance-none border-0 bg-transparent transition-opacity hover:opacity-70 focus-ring focus-visible:outline-none"),children:[t.jsx(J,{id:((z=N==null?void 0:N.user)==null?void 0:z.id)||x.id||"unknown",name:S,image:L,starred:n&&I,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:[F,t.jsx(j.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(j.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),t.jsx("span",{className:"truncate",children:_e})]})]})]}):t.jsxs("div",{className:O,children:[t.jsx(J,{id:(($=N==null?void 0:N.user)==null?void 0:$.id)||x.id||"unknown",name:S,image:L,starred:n&&I,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:[F,t.jsx(j.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(j.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),t.jsx("span",{className:"truncate",children:_e})]})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[n&&t.jsx("button",{className:ue,onClick:C,type:"button","aria-label":I?"Unstar conversation":"Star conversation",children:t.jsx(j.StarIcon,{className:k("size-6",{"text-yellow-600":I,"text-black/90":!I}),weight:I?"duotone":"regular"})}),p&&(c!==void 0?c:t.jsx($e,{channel:x,participant:N,showDeleteConversation:l,showBlockParticipant:o,showReportParticipant:d,onLeaveConversation:r,onBlockParticipant:i,onDeleteConversationClick:u,onBlockParticipantClick:g,onReportParticipantClick:h,customChannelActions:f,triggerClassName:ue}))]})]})]})},xr=({onBack:e,showBackButton:s,renderMessageInputActions:n,renderMessageInputFooter:a,renderConversationFooter:r,onLeaveConversation:i,onBlockParticipant:l,showDeleteConversation:o=!0,onDeleteConversationClick:d,onBlockParticipantClick:u,onReportParticipantClick:g,showBlockParticipant:h=!0,showReportParticipant:f=!0,composerDisabled:c=!1,composerDisabledReason:p,showStarButton:v=!1,chatbotVotingEnabled:b=!1,renderChannelBanner:x,renderHeaderTitleBadges:_,customChannelActions:N,renderChannelActions:S,renderMessage:L,dmAgentEnabled:I=!1,viewerLanguage:D,showChannelInfo:B=!0,onParticipantNameClick:O,composerInput:F})=>{var y,A,G,Y;const{channel:C}=w.useChannelStateContext(),{client:E}=w.useChatContext(),T=m.useMemo(()=>{var H;return fe((H=C.state)==null?void 0:H.members,E==null?void 0:E.userID,C.type)},[(y=C.state)==null?void 0:y.members,E==null?void 0:E.userID,C.type]),R=m.useMemo(()=>{var q;const H=E==null?void 0:E.userID;return H?Object.values(((q=C.state)==null?void 0:q.members)||{}).find(K=>{var ne;return((ne=K.user)==null?void 0:ne.id)===H}):void 0},[E==null?void 0:E.userID,(A=C.state)==null?void 0:A.members]),M=((G=R==null?void 0:R.user)==null?void 0:G.is_account)??(R==null?void 0:R.is_account),z=((Y=T==null?void 0:T.user)==null?void 0:Y.is_account)??(T==null?void 0:T.is_account),$=I&&M===!1&&z===!0,V=C.state.messages.some(H=>H.type!=="deleted"),X=x?t.jsx(m.Fragment,{children:x()},"lt-channel-banner"):null,Z=O?t.jsx(Hs,{className:"-mx-[var(--str-chat\\_\\_spacing-2)] px-[var(--str-chat\\_\\_spacing-2)] md:-mx-[min(var(--str-chat\\_\\_spacing-10),4%)] md:px-[min(var(--str-chat\\_\\_spacing-10),4%)]",onBack:e,showBackButton:s,showChannelInfo:B,showStarButton:v,dmAgentEnabled:$,onLeaveConversation:i,onBlockParticipant:l,showDeleteConversation:o,showBlockParticipant:h,showReportParticipant:f,onDeleteConversationClick:d,onBlockParticipantClick:u,onReportParticipantClick:g,customChannelActions:N,renderChannelActions:S,onParticipantNameClick:O}):null,W=m.useCallback(H=>{const{message:U}=w.useMessageContext("ChannelView"),q=t.jsx(Va,{...H,chatbotVotingEnabled:b,viewerLanguage:D});return!L||!U?q:L(q,U)},[b,L,D]);return t.jsx(t.Fragment,{children:t.jsx(w.WithComponents,{overrides:{Message:W,MessageActions:Ya},children:t.jsxs(w.Window,{children:[!O&&t.jsxs(t.Fragment,{children:[t.jsx("div",{children:t.jsx(hr,{onBack:e,showBackButton:s,showChannelInfo:B,showStarButton:v,dmAgentEnabled:$,onLeaveConversation:i,onBlockParticipant:l,showDeleteConversation:o,showBlockParticipant:h,showReportParticipant:f,onDeleteConversationClick:d,onBlockParticipantClick:u,onReportParticipantClick:g,customChannelActions:N,renderChannelActions:S,renderHeaderTitleBadges:_})},"lt-channel-header"),X]}),t.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[O&&!V&&t.jsx("div",{className:"str-chat__list",children:t.jsxs("div",{className:"str-chat__message-list-scroll",children:[Z,X]})}),t.jsx(w.MessageList,{head:O&&V?t.jsxs("div",{className:"sticky top-0 z-10",children:[Z,X]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},"lt-channel-message-list"),r?t.jsx(m.Fragment,{children:r(C)},"lt-channel-conversation-footer"):null,t.jsx(Qa,{...n&&{renderActions:()=>n==null?void 0:n(C)},renderFooter:()=>a==null?void 0:a(C),disabled:c,disabledReason:p,composerInput:F},"lt-channel-message-input")]})})})},ut=m.memo(({channel:e,onBack:s,showBackButton:n=!1,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:l,onBlockParticipant:o,className:d,CustomChannelEmptyState:u=_s,showDeleteConversation:g=!0,onDeleteConversationClick:h,onBlockParticipantClick:f,onReportParticipantClick:c,showBlockParticipant:p=!0,showReportParticipant:v=!0,composerDisabled:b=!1,composerDisabledReason:x,dmAgentEnabled:_,messageMetadata:N,onMessageSent:S,showStarButton:L=!1,chatbotVotingEnabled:I=!1,renderChannelBanner:D,renderHeaderTitleBadges:B,customChannelActions:O,renderChannelActions:F,renderMessage:C,onMessageLinkClick:E,sendButton:T,attachmentPreviewList:R,viewerLanguage:M,showChannelInfo:z=!0,onParticipantNameClick:$,composerInput:V})=>{const X=m.useCallback(async(W,y,A)=>{var K;const G=((K=e.data)==null?void 0:K.chatbot_paused)===!0,Y=_&&!G,H={...y,...Y&&{silent:!0},...N&&{metadata:{...y.metadata??{},...N}}},U={...A,...Y&&{skip_push:!0}},q=await e.sendMessage(H,U);return S==null||S(q),q},[e,_,N,S]),Z=m.useRef(null);return m.useEffect(()=>{if(!E)return;const W=Z.current;if(!W)return;const y=A=>{const G=A.target,Y=G==null?void 0:G.closest("a[href]"),H=Y==null?void 0:Y.getAttribute("href");if(!H)return;const U=Y==null?void 0:Y.closest("[data-message-id]"),q=U==null?void 0:U.getAttribute("data-message-id"),K=q?e.state.messages.find(ne=>ne.id===q):void 0;E(H,K)};return W.addEventListener("click",y),()=>W.removeEventListener("click",y)},[E,e]),t.jsx("div",{ref:Z,className:k("messaging-channel-view h-full flex flex-col",d),children:t.jsx(ws.Provider,{value:_??!1,children:t.jsx(w.Channel,{channel:e,MessageSystem:lr,EmptyStateIndicator:u,LoadingIndicator:ke,DateSeparator:Ys,TypingIndicator:dr,doSendMessageRequest:X,...T?{SendButton:T}:{},...R?{AttachmentPreviewList:R}:{},children:t.jsx(xr,{onBack:s,showBackButton:n,renderMessageInputActions:a,renderMessageInputFooter:r,renderConversationFooter:i,onLeaveConversation:l,onBlockParticipant:o,CustomChannelEmptyState:u,showDeleteConversation:g,onDeleteConversationClick:h,onBlockParticipantClick:f,onReportParticipantClick:c,showBlockParticipant:p,showReportParticipant:v,composerDisabled:b,composerDisabledReason:x,showStarButton:L,dmAgentEnabled:_,chatbotVotingEnabled:I,renderChannelBanner:D,renderHeaderTitleBadges:B,customChannelActions:O,renderChannelActions:F,renderMessage:C,viewerLanguage:M,showChannelInfo:z,onParticipantNameClick:$,composerInput:V})})})})});ut.displayName="ChannelView";const xe=m.memo(({message:e,onBack:s})=>t.jsx("div",{className:"messaging-error-state flex items-center justify-center h-full p-8",children:t.jsxs("div",{className:"text-center max-w-sm",children:[t.jsx("div",{className:"w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6",children:t.jsx("span",{className:"text-4xl",children:"⚠️"})}),t.jsx("h2",{className:"font-semibold text-charcoal mb-2",children:"Oops!"}),t.jsx("p",{className:"text-stone text-sm mb-6",children:e}),s&&t.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-[#7f22fe] hover:bg-primary-alt rounded-lg transition-colors focus-ring",children:"Go Back"})]})}));xe.displayName="ErrorState";const fr=({capabilities:e={},renderMessageInputActions:s,renderConversationFooter:n,onChannelSelect:a,onExitConversation:r,initialParticipantFilter:i,initialParticipantData:l,CustomChannelEmptyState:o,onBlockParticipantClick:d,onReportParticipantClick:u,dmAgentEnabled:g,onMessageSent:h,chatbotVotingEnabled:f=!1,viewerLanguage:c,renderHeaderTitleBadges:p,renderChannelBanner:v,customChannelActions:b,renderChannelActions:x,onParticipantNameClick:_,renderMessage:N,onMessageLinkClick:S,showChannelInfo:L,composerInput:I})=>{const{client:D,isConnected:B,isLoading:O,error:F,refreshConnection:C,service:E,debug:T}=Ut(),[R,M]=m.useState(null),[z,$]=m.useState(null),[V,X]=m.useState(!1),{showDeleteConversation:Z=!0}=e,W=m.useRef(l);W.current=l;const y=m.useRef(a);y.current=a;const A=m.useRef(null),G=m.useRef(null);m.useEffect(()=>{G.current=R},[R]),m.useEffect(()=>{if(!D||!B)return;const U=D.userID;if(!U)return;const q=`${U}::${i}`;if(A.current===q)return;A.current=q;const K=()=>{A.current===q&&(A.current=null)};(async()=>{var je,we;try{T&&console.log("[MessagingShell] Loading initial conversation with:",i);const Q=await D.queryChannels({type:"messaging",members:{$eq:[U,i]}},{},{limit:1});if(Q.length>0){M(Q[0]),$(null),(je=y.current)==null||je.call(y,Q[0]),T&&console.log("[MessagingShell] Initial conversation loaded:",Q[0].id);return}const ae=W.current;if(!ae||!E){K(),$("No conversation found with this account"),T&&console.log("[MessagingShell] No conversation found for:",i);return}try{const se=await E.startChannelWithParticipant({id:ae.id,name:ae.name,phone:ae.phone});M(se),$(null),(we=y.current)==null||we.call(y,se),T&&console.log("[MessagingShell] Channel created and loaded:",se.id)}catch(se){console.error("[MessagingShell] Failed to create conversation:",se),K(),$("Failed to create conversation")}}catch(Q){console.error("[MessagingShell] Failed to load initial conversation:",Q),K(),G.current||$("Failed to load conversation")}})()},[i,D,B,E,T]);const Y=m.useRef(r);Y.current=r;const H=m.useCallback(()=>{var U;M(null),X(!0),(U=Y.current)==null||U.call(Y)},[]);return O?t.jsx(ke,{}):F?t.jsx(xe,{message:F,onBack:C}):!B||!D?t.jsx(xe,{message:"Not connected to messaging service",onBack:C}):z?t.jsx(xe,{message:z}):V&&!R?t.jsx(xe,{message:"Conversation ended"}):R?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(ut,{channel:R,renderMessageInputActions:s,renderConversationFooter:n,renderChannelBanner:v,onLeaveConversation:H,onBlockParticipant:H,CustomChannelEmptyState:o,showDeleteConversation:Z,onBlockParticipantClick:d,onReportParticipantClick:u,dmAgentEnabled:g,onMessageSent:h,chatbotVotingEnabled:f,viewerLanguage:c,renderHeaderTitleBadges:p,customChannelActions:b,renderChannelActions:x,onParticipantNameClick:_,renderMessage:N,onMessageLinkClick:S,showChannelInfo:L,composerInput:I},R.id)})}):t.jsx(ke,{})};function gr(e){const s=e.state.pending_messages;if(s!=null&&s.length)for(const n of s)e.state.addMessageSorted(n.message)}const Ns=m.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,channelPreview:void 0,viewerLanguage:void 0}),pr=Ns.Provider,br=()=>m.useContext(Ns),vr=(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))},ys=e=>{const s=new Date;if(Math.floor((s.getTime()-e.getTime())/1e3)<60)return"Just now";const a=vr(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"})},Cs=m.memo(e=>{var B,O,F;const{channel:s,unread:n}=e,{selectedChannel:a,onChannelSelect:r,debug:i,channelPreview:l,renderMessagePreview:o,viewerLanguage:d}=br(),{client:u}=w.useChatContext(),g=(a==null?void 0:a.id)===(s==null?void 0:s.id),h=qe(s);if(l){const C=l;return t.jsx(C,{...e,active:g,selectedChannel:a,onChannelSelect:r,viewerLanguage:d})}const f=()=>{s&&r(s)},c=C=>{const E=C.key==="Enter"||C.key===" ",T=C.repeat;!E||T||(C.preventDefault(),f())},p=fe((B=s==null?void 0:s.state)==null?void 0:B.members,u==null?void 0:u.userID,s==null?void 0:s.type),v=Se(p==null?void 0:p.user),b=(O=p==null?void 0:p.user)==null?void 0:O.image,x=(()=>{var E;const C=(E=s==null?void 0:s.state)==null?void 0:E.messages;if(C!=null&&C.length){for(let T=C.length-1;T>=0;T--)if(C[T].type!=="system")return C[T]}})(),N=(()=>{var z,$,V,X;const C=Xe({message:x,viewerLanguage:d});if(((z=x==null?void 0:x.metadata)==null?void 0:z.custom_type)==="MESSAGE_TIP")return C?`💵 ${C}`:"💵 Sent a tip";if((($=x==null?void 0:x.metadata)==null?void 0:$.custom_type)==="MESSAGE_PAID")return C?`💰 ${C}`:"💰 Sent a message";if(((V=x==null?void 0:x.metadata)==null?void 0:V.custom_type)==="MESSAGE_ATTACHMENT")return C?`📎 ${C}`:"📎 Sent an attachment";if(C)return C;const M=(X=x==null?void 0:x.attachments)==null?void 0:X[0];return M?M.og_scrape_url?M.og_scrape_url:M.type==="image"?"📷 Sent an image":M.type==="video"?"🎥 Sent a video":M.type==="audio"?"🎵 Sent audio":M.type==="file"?"📎 Sent a file":"📎 Sent an attachment":"No messages yet"})(),S=x!=null&&x.created_at?ys(new Date(x.created_at)):"",L=x?Ne(x):!1,I=o?o(x,N):`${L?"✨ ":""}${N}`,D=n??0;return i&&console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER",{channelId:s==null?void 0:s.id,isSelected:g,participantName:v,unreadCount:D,hasTimestamp:!!S}),t.jsx("div",{role:"button",tabIndex:0,onClick:f,onKeyDown:c,className:k("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]":g,"hover:bg-black/[0.02]":!g}),"data-dd-privacy":"mask",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx(J,{id:((F=p==null?void 0:p.user)==null?void 0:F.id)||s.id||"unknown",name:v,image:b,size:48,starred:h}),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:k("text-sm font-medium truncate text-[#191918]"),children:[h&&t.jsx("span",{className:"sr-only",children:"Starred conversation. "}),v]}),S&&t.jsx("span",{className:"text-xs text-[#717070] flex-shrink-0",children:S})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[t.jsx("p",{className:"text-sm text-[#717070] flex-1 line-clamp-1",children:I}),D>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:D>99?"99+":D})]})]})]})})});Cs.displayName="CustomChannelPreview";const jr={last_message_at:-1},ks=m.memo(({onChannelSelect:e,selectedChannel:s,filters:n,allowNewMessagesFromUnfilteredChannels:a=!1,channelRenderFilterFn:r,sort:i=jr,className:l,customEmptyStateIndicator:o,channelListPaginator:d=w.InfiniteScroll,channelPreview:u,renderMessagePreview:g,viewerLanguage:h})=>{const f=m.useRef(0);f.current++;const{debug:c=!1}=Ye(),p=m.useCallback(b=>{for(const x of b)gr(x);return r?r(b):b},[r]);c&&console.log("📺 [ChannelList] 🔄 RENDER START",{renderCount:f.current,selectedChannelId:s==null?void 0:s.id,filters:n});const v=m.useMemo(()=>({selectedChannel:s,onChannelSelect:e,debug:c,channelPreview:u,renderMessagePreview:g,viewerLanguage:h}),[s,e,c,u,g,h]);return t.jsx("div",{className:k("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(pr,{value:v,children:t.jsx(w.ChannelList,{filters:n,sort:i,options:{limit:30},allowNewMessagesFromUnfilteredChannels:a,channelRenderFilterFn:p,Paginator:d,Preview:Cs,EmptyStateIndicator:o},`${JSON.stringify(n)}:${JSON.stringify(i)}`)})})})});ks.displayName="ChannelList";const $t=`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='23' fill='none'%3E%3Cpath fill='black' d='M0 0H15C15 10.1934 15.859 15.2345 19.168 21.4893C19.527 22.168 19.039 22.9917 18.274 22.9178C5.176 21.6506 0.32 6.0737 0 0Z'/%3E%3C/svg%3E") no-repeat center / 100% 100%`,wr={sent:"var(--str-chat__own-message-bubble-background-color, #1e2330)",received:"var(--str-chat__message-bubble-background-color, #f1f0ee)"},_r=({variant:e})=>t.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0 z-[-1] h-[1.4375rem] w-5",style:{insetInlineEnd:e==="sent"?"calc(-1 * 0.25rem)":void 0,insetInlineStart:e==="received"?"calc(-1 * 0.25rem)":void 0,transform:e==="received"?"scaleX(-1)":void 0,transformOrigin:"center",backgroundColor:wr[e],WebkitMask:$t,mask:$t}}),Nr={sent:{backgroundColor:"var(--str-chat__own-message-bubble-background-color, #1e2330)",color:"var(--str-chat__own-message-bubble-color, #fff)"},received:{backgroundColor:"var(--str-chat__message-bubble-background-color, #f1f0ee)",color:"var(--str-chat__message-bubble-color, #000000)"}},Ss=({variant:e,text:s,tail:n=!0,header:a,className:r})=>t.jsxs("div",{"data-dd-privacy":"mask",className:k("relative px-4 py-3","text-[0.875rem] leading-[1.3125rem] tracking-[0.14px]",r),style:{...Nr[e],borderRadius:"var(--str-chat__message-bubble-border-radius, 1.5rem)",isolation:"isolate"},children:[a!=null&&t.jsx("div",{className:"mb-1 font-medium","data-testid":"message-bubble-header",children:a}),t.jsx("p",{className:"m-0 whitespace-pre-wrap break-words",children:s}),n&&t.jsx(_r,{variant:e})]}),yr=({text:e,tail:s,header:n,className:a})=>t.jsx(Ss,{variant:"received",text:e,tail:s,header:n,className:a}),Cr=({text:e,tail:s,className:n})=>t.jsx(Ss,{variant:"sent",text:e,tail:s,className:n}),kr={Sent:Cr,Received:yr},Is=({question:e,onClick:s,loading:n=!1,className:a})=>t.jsx("button",{type:"button",onClick:s,disabled:n,style:{backgroundColor:"#E6E5E3"},className:k("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}),Sr=({faqs:e,onFaqClick:s,loadingFaqId:n,headerText:a,className:r,avatarImage:i,avatarName:l})=>{const o=e.filter(d=>d.enabled).sort((d,u)=>(d.order??0)-(u.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(J,{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(Is,{question:d.question,onClick:()=>s(d.id),loading:n===d.id},d.id))]})]})})};exports.ActionButton=me;exports.AttachmentThumbnail=Ke;exports.Avatar=J;exports.ChannelEmptyState=_s;exports.ChannelList=ks;exports.ChannelView=ut;exports.CustomMessageProvider=ma;exports.FaqList=Sr;exports.FaqListItem=Is;exports.LinkAttachment=Ge;exports.LockedAttachment=Ve;exports.MediaMessage=bn;exports.MessageAttachment=he;exports.MessageBubble=kr;exports.MessageVoteButtons=bs;exports.MessagingProvider=As;exports.MessagingShell=fr;exports.bubbleGroupPositionFromStream=es;exports.buildCompactMetaLabel=ns;exports.formatFileSize=ts;exports.formatRelativeTime=ys;exports.getFileExtensionLabel=ss;exports.getMessageDisplayText=Xe;exports.getSourceType=te;exports.isLinkAttachment=Qe;exports.isUuidLike=Vt;exports.normalizeLanguageCode=Yt;exports.renderTypeIcon=ie;exports.resolveConversationParticipant=fe;exports.resolveLinkAttachment=Ie;exports.resolveMediaFromMessage=Ee;exports.resolveParticipantDisplayName=Se;exports.useComposerLocked=Ka;exports.useCustomMessage=gs;exports.useMessageVote=Ht;exports.useMessaging=Ut;
|
|
2
|
+
//# sourceMappingURL=index-BPhZyaxT.cjs.map
|