@linktr.ee/messaging-react 4.4.6 β 4.4.7-rc-1788242278
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/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +739 -710
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/CustomMessage/CustomMessage.test.tsx +149 -4
- package/src/components/CustomMessage/index.tsx +29 -0
- package/src/components/MessageAttachment/MessageAttachment.behavior.test.tsx +45 -2
- package/src/components/MessageAttachment/Video/index.tsx +24 -8
- package/src/logging/index.test.tsx +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./AttachmentCard-BbsjzdLJ.cjs");let n=require("react");n=e.t(n,1);let r=require("@linktr.ee/messaging-core"),i=require("stream-chat"),a=require("stream-chat-react"),o=require("react/jsx-runtime"),s=require("@linktr.ee/messaging-taxonomy"),c=require("classnames");c=e.t(c,1);let l=require("@phosphor-icons/react"),u=require("stream-chat-react/experimental");var d={debug:(e,...t)=>console.log(e,...t),info:(e,...t)=>console.log(e,...t),warn:(e,...t)=>console.warn(e,...t),error:(e,...t)=>console.error(e,...t)},f=e=>({debug:e?.debug??d.debug,info:e?.info??d.info,warn:e?.warn??d.warn,error:e?.error??d.error}),p=(0,n.createContext)(d),m=({logger:e,children:t})=>{let r=(0,n.useMemo)(()=>f(e),[e]);return(0,o.jsx)(p.Provider,{value:r,children:t})},h=()=>(0,n.useContext)(p),g=(0,n.createContext)({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),_=()=>(0,n.useContext)(g),v=({children:e,user:t,serviceConfig:s,apiKey:c,capabilities:l={},debug:u=!1,client:d,logger:p})=>{let h=(0,n.useCallback)((e,...t)=>{u&&console.log(`π₯ [MessagingProvider] ${e}`,...t)},[u]);h(`π RENDER START`,{userId:t?.id,apiKey:c?.substring(0,8)+`...`,serviceConfig:!!s,capabilities:Object.keys(l)});let[_,v]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),[x,S]=(0,n.useState)(!1),[C,w]=(0,n.useState)(!1),[T,E]=(0,n.useState)(null),D=(0,n.useRef)(!1),O=(0,n.useRef)(null),k=(0,n.useRef)(s);k.current=s;let A=(0,n.useRef)(u);A.current=u;let j=(0,n.useRef)(p);j.current=p;let M=(0,n.useRef)({userId:t?.id,apiKey:c,serviceConfig:s,capabilities:l}),N=(0,n.useRef)(0);N.current++,h(`π RENDER INFO`,{renderCount:N.current,currentProps:{userId:t?.id,apiKey:c?.substring(0,8)+`...`},propChanges:{userChanged:M.current.userId!==t?.id,apiKeyChanged:M.current.apiKey!==c,serviceConfigChanged:M.current.serviceConfig!==s,capabilitiesChanged:M.current.capabilities!==l}}),M.current={userId:t?.id,apiKey:c,serviceConfig:s,capabilities:l};let P=(0,n.useRef)(null);!d&&c&&P.current?.apiKey!==c&&(P.current={apiKey:c,client:new i.StreamChat(c)});let F=d||(c?P.current?.client??null:null);(0,n.useEffect)(()=>{let e=N.current,t=k.current;if(d){O.current=null,v(null),b(null),S(!1),E(null),w(!1);return}if(!c||!F||!t){h(`β οΈ SERVICE INIT SKIPPED`,{renderCount:e,reason:`Missing apiKey, client, or serviceConfig`});return}h(`π CREATING SERVICE`,{renderCount:e,apiKey:c?.substring(0,8)+`...`});let n=new r.StreamChatService({...t,apiKey:c,debug:A.current,client:F,...t.logger||!j.current?{}:{logger:f(j.current)}});O.current=n,v(n),h(`β
SERVICE SET`,{renderCount:e,serviceInstance:!!n})},[c,F,d]);let I=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(h(`π USER CONNECTION EFFECT TRIGGERED`,{hasService:!!_,hasUser:!!t,userId:t?.id,isConnecting:D.current,isConnected:x,dependencies:{service:!!_,userId:t?.id}}),!d){if(!_||!t){h(`β οΈ USER CONNECTION SKIPPED`,`Missing service or user`);return}if(D.current){h(`β οΈ USER CONNECTION SKIPPED`,`Already connecting`);return}if(I.current?.serviceId===_&&I.current?.userId===t.id){h(`β οΈ USER CONNECTION SKIPPED`,`Already connected this user with this service`);return}(async()=>{h(`π STARTING USER CONNECTION`,{userId:t.id}),D.current=!0,w(!0),E(null);try{h(`π CALLING SERVICE.CONNECTUSER`,{userId:t.id});let e=await _.connectUser(t);b(e),S(!0),I.current={serviceId:_,userId:t.id},h(`β
USER CONNECTION SUCCESS`,{userId:t.id,clientId:e.userID})}catch(e){let n=e instanceof Error?e.message:`Connection failed`;E(n),h(`β USER CONNECTION ERROR`,{userId:t.id,error:n})}finally{w(!1),D.current=!1,h(`π USER CONNECTION FINISHED`,{userId:t.id,isConnected:x})}})()}},[_,t,h,x,d]),(0,n.useEffect)(()=>{let e=F;return()=>{e&&(I.current=null,O.current?.disconnectUser().catch(console.error))}},[F]);let L=(0,n.useCallback)(async()=>{if(h(`π REFRESH CONNECTION CALLED`,{hasService:!!_,hasUser:!!t}),!d){if(!_||!t){h(`β οΈ REFRESH CONNECTION SKIPPED`,`Missing service or user`);return}h(`π STARTING CONNECTION REFRESH`,{userId:t.id}),w(!0);try{h(`π DISCONNECTING FOR REFRESH`),await _.disconnectUser(),h(`π RECONNECTING FOR REFRESH`);let e=await _.connectUser(t);b(e),S(!0),E(null),h(`β
CONNECTION REFRESH SUCCESS`,{userId:t.id})}catch(e){let n=e instanceof Error?e.message:`Refresh failed`;E(n),h(`β CONNECTION REFRESH ERROR`,{userId:t.id,error:n})}finally{w(!1),h(`π CONNECTION REFRESH FINISHED`,{userId:t.id})}}},[_,t,h,d]),R=n.default.useMemo(()=>(h(`π« CONTEXT VALUE MEMOIZATION`,{hasService:!!_,hasClient:!!y,isConnected:x,isLoading:C,hasError:!!T,capabilitiesKeys:Object.keys(l)}),{service:d?null:_,client:d??y,isConnected:d?!0:x,isLoading:!d&&C,error:d?null:T,capabilities:l,refreshConnection:L,debug:u}),[_,y,d,x,C,T,l,L,u,h]);return h(`π RENDER END`,{renderCount:N.current,willRenderChat:!!F,contextValueReady:!!R}),(0,o.jsx)(m,{logger:p,children:(0,o.jsx)(g.Provider,{value:R,children:F?(0,o.jsx)(a.Chat,{client:F,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})})},y=()=>_(),b=e=>{let[t,r]=(0,n.useState)(!!e?.state?.membership?.pinned_at);return(0,n.useEffect)(()=>{if(!e){r(!1);return}r(!!e.state.membership?.pinned_at);let t=t=>{r(t?.member?!!t.member.pinned_at:!!e.state.membership?.pinned_at)};return e.on(`member.updated`,t),()=>{e.off(`member.updated`,t)}},[e]),t};function x(e,t,n){let r=Object.values(e||{});if((0,s.isOfficialChannel)(n)){let e=r.find(e=>e.user?.id===s.OFFICIAL_SENDER_USER_ID);if(e)return e}return r.find(e=>e.user?.id&&e.user.id!==t)}var S=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function C(e){return S.test(e.trim())}function w(e,t){let n=e?.trim();return!n||t&&n===t||t&&n===`Follower ${t}`?!1:!C(n)}function T(e){return w(e?.name,e?.id)?e.name.trim():w(e?.username,e?.id)?e.username.trim():`Unknown member`}var E=[{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 D(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t)}function O(e){return E[D(e)%E.length]}function k(e){return O(e).emoji}function A(e){return O(e).bgColor}var j=({id:e,image:t,size:n=40,className:r,starred:i=!1,shape:a=`squircle`,dmAgentEnabled:s=!1})=>{let u=k(e),d=A(e),f=n<32?Math.round(n*.45):n<56?14:n<120?18:36,p=n>=40?2:1,m=a===`circle`?{borderRadius:`50%`}:{borderRadius:`1rem`},h=(0,o.jsx)(`div`,{"data-testid":`avatar-inner`,className:`h-full w-full overflow-hidden`,style:m,children:t?(0,o.jsx)(`img`,{src:t,alt:``,className:`h-full w-full object-cover`}):(0,o.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`avatar-fallback`,className:(0,c.default)(`avatar-fallback flex h-full w-full items-center justify-center font-semibold select-none transition-colors`),style:{fontSize:f,lineHeight:1},children:u})});return(0,o.jsxs)(`div`,{"data-testid":`avatar`,className:(0,c.default)(`relative flex-shrink-0`,r),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`,backgroundColor:t?void 0:d,...m},children:[i&&(0,o.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`avatar-star`,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:(0,o.jsx)(l.StarIcon,{className:`size-3 text-yellow-600`,weight:`duotone`})}),(0,o.jsx)(`div`,{"data-testid":`avatar-ring`,className:(0,c.default)(`h-full w-full`,`bg-transparent`),style:{...m,...s&&{borderWidth:`${p}px`,borderStyle:`solid`,borderColor:`var(--AI-Gradient, #7F22FE)`,boxShadow:`inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)`}},children:h})]})},M=`https://linktr.ee/s/about/trust-center/report`,N=({channel:e,participant:t,showBlockParticipant:r=!0,enabled:i=!0,onLeaveConversation:a,onBlockParticipant:o,onDeleteConversationClick:s,onBlockParticipantClick:c,onReportParticipantClick:l,onActionComplete:u,logLabel:d=`useChannelModerationActions`})=>{let{service:f,debug:p}=_(),m=t?.user?.id,h=!!(i&&r&&f&&m),[g,v]=(0,n.useState)(!1),[y,b]=(0,n.useState)(null),[x,S]=(0,n.useState)(!1),[C,w]=(0,n.useState)(!1),T=h&&(y?.participantId!==m||y?.service!==f);return(0,n.useEffect)(()=>{if(!h||!f||!m){v(!1),b(null);return}let e=!1;return(async()=>{try{let t=await f.getBlockedUsers();if(e)return;v(t.some(e=>e.blocked_user_id===m))}catch(t){e||console.error(`[${d}] Failed to check blocked status:`,t)}finally{e||b({participantId:m,service:f})}})(),()=>{e=!0}},[h,f,m,d]),{isParticipantBlocked:g,isCheckingBlockedStatus:T,isLeaving:x,isUpdatingBlockStatus:C,handleLeaveConversation:async()=>{if(!x){s?.(),p&&console.log(`[${d}] Leave conversation`,e.cid),S(!0);try{let t=e._client?.userID??null;await e.hide(t,!1),a&&await a(e),u?.()}catch(e){console.error(`[${d}] Failed to leave conversation`,e)}finally{S(!1)}}},handleBlockUser:async()=>{if(!(C||!f)){c?.(),p&&console.log(`[${d}] Block member`,t?.user?.id),w(!0);try{await f.blockUser(t?.user?.id),o&&await o(t?.user?.id),u?.()}catch(e){console.error(`[${d}] Failed to block member`,e)}finally{w(!1)}}},handleUnblockUser:async()=>{if(!(C||!f)){c?.(),p&&console.log(`[${d}] Unblock member`,t?.user?.id),w(!0);try{await f.unBlockUser(t?.user?.id),o&&await o(t?.user?.id),u?.()}catch(e){console.error(`[${d}] Failed to unblock member`,e)}finally{w(!1)}}},handleReportUser:()=>{l?.(),u?.(),window.open(M,`_blank`,`noopener,noreferrer`)}}},P=({variant:e=`default`,className:t,children:n,...r})=>(0,o.jsx)(`button`,{type:`button`,className:(0,c.default)(`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`,e===`danger`?`text-danger hover:bg-danger/50`:`text-charcoal hover:bg-sand`,t),...r,children:n}),F=({channel:e,participant:t,showDeleteConversation:r=!0,showBlockParticipant:i=!0,showReportParticipant:a=!0,onLeaveConversation:s,onBlockParticipant:u,onDeleteConversationClick:d,onBlockParticipantClick:f,onReportParticipantClick:p,customChannelActions:m,triggerClassName:h})=>{let[g,_]=(0,n.useState)(!1),v=(0,n.useRef)(null),y=(0,n.useId)(),{isParticipantBlocked:b,isCheckingBlockedStatus:x,isLeaving:S,isUpdatingBlockStatus:C,handleLeaveConversation:w,handleBlockUser:T,handleUnblockUser:E,handleReportUser:D}=N({channel:e,participant:t,showBlockParticipant:i,enabled:g,onLeaveConversation:s,onBlockParticipant:u,onDeleteConversationClick:d,onBlockParticipantClick:f,onReportParticipantClick:p,onActionComplete:(0,n.useCallback)(()=>_(!1),[]),logLabel:`ChannelActionsMenu`});return(0,n.useEffect)(()=>{if(!g)return;let e=e=>{v.current&&!v.current.contains(e.target)&&_(!1)},t=e=>{e.key===`Escape`&&_(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[g]),!t||!(r||i||a||m)?null:(0,o.jsxs)(`div`,{ref:v,className:`relative`,children:[(0,o.jsxs)(`button`,{className:h,type:`button`,"aria-haspopup":`true`,"aria-expanded":g,"aria-controls":g?y:void 0,onClick:()=>_(e=>!e),children:[(0,o.jsx)(l.DotsThreeIcon,{className:`size-5 text-black/90`}),(0,o.jsx)(`span`,{className:`sr-only`,children:`More options`})]}),g&&(0,o.jsx)(`div`,{id:y,"aria-label":`Conversation options`,className:(0,c.default)(`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:(0,o.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[r&&(0,o.jsx)(`li`,{children:(0,o.jsxs)(P,{onClick:w,disabled:S,"aria-busy":S,children:[S?(0,o.jsx)(l.SpinnerGapIcon,{className:`h-5 w-5 animate-spin`}):(0,o.jsx)(l.SignOutIcon,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{children:`Delete Conversation`})]})}),i&&(0,o.jsx)(`li`,{children:x?(0,o.jsxs)(P,{disabled:!0,"aria-busy":!0,children:[(0,o.jsx)(l.SpinnerGapIcon,{className:`h-5 w-5 animate-spin`}),(0,o.jsx)(`span`,{children:`Block`})]}):b?(0,o.jsxs)(P,{onClick:E,disabled:C,"aria-busy":C,children:[C?(0,o.jsx)(l.SpinnerGapIcon,{className:`h-5 w-5 animate-spin`}):(0,o.jsx)(l.ProhibitInsetIcon,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{children:`Unblock`})]}):(0,o.jsxs)(P,{onClick:T,disabled:C,"aria-busy":C,children:[C?(0,o.jsx)(l.SpinnerGapIcon,{className:`h-5 w-5 animate-spin`}):(0,o.jsx)(l.ProhibitInsetIcon,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{children:`Block`})]})}),a&&(0,o.jsx)(`li`,{children:(0,o.jsxs)(P,{variant:`danger`,onClick:D,children:[(0,o.jsx)(l.FlagIcon,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{children:`Report`})]})}),m]})})]})},I=`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`,L=`CUSTOMER_PAID`,R=e=>typeof e==`string`&&e.trim().replace(/[\s-]+/g,`_`).toUpperCase()===L,ee=({className:e,onBack:t,showBackButton:r,showStarButton:i=!1,onLeaveConversation:s,onBlockParticipant:u,showDeleteConversation:d=!0,showBlockParticipant:f=!0,showReportParticipant:p=!0,onDeleteConversationClick:m,onBlockParticipantClick:h,onReportParticipantClick:g,customChannelActions:_,renderChannelActions:v,showChannelInfo:y=!0,onParticipantNameClick:S})=>{let{channel:C}=(0,a.useChannelStateContext)(),{client:w}=(0,a.useChatContext)(),E=n.default.useMemo(()=>x(C.state?.members,w?.userID,C.type),[C.state?.members,w?.userID,C.type]),D=T(E?.user),O=E?.user?.image,k=b(C),A=R(C.data?.customer_tag)&&E?.is_follower===!0,M=i&&k,N=A||M||!!S,P=async()=>{try{k?await C.unpin():await C.pin()}catch(e){console.error(`[ChannelHeaderRedesign] Failed to update pinned status:`,e)}},L=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(j,{id:E?.user?.id||C.id||`unknown`,name:D,image:O,shape:`circle`,size:48,className:`-mb-2`}),(0,o.jsx)(`span`,{className:(0,c.default)(`relative z-10 flex max-w-full flex-col items-center justify-center rounded-full border border-white/10 bg-white/65 py-1.5 shadow-[0px_0px_0px_0px_rgba(0,0,0,0.04),0px_1px_2px_0px_rgba(0,0,0,0.04),0px_8px_32px_0px_rgba(0,0,0,0.1)] backdrop-blur-[2px] transition-filter duration-150 group-hover:brightness-95`,N?`pl-3 pr-2`:`px-3`),children:(0,o.jsxs)(`span`,{className:`flex max-w-full items-center justify-center`,children:[(0,o.jsx)(`span`,{className:`min-w-0 truncate text-sm font-bold leading-[1.43] tracking-[0.28px] text-black/90`,children:D}),N&&(0,o.jsxs)(`span`,{className:`ml-2 flex gap-1`,children:[A&&(0,o.jsx)(`span`,{"aria-label":`Paid customer`,className:`flex size-4 shrink-0 items-center justify-center rounded-full bg-[#34C759] text-white`,children:(0,o.jsx)(l.CurrencyDollarIcon,{className:`size-2.5`,weight:`bold`})}),M&&(0,o.jsx)(`span`,{className:`messaging-header-star-badge flex overflow-hidden`,children:(0,o.jsx)(`span`,{"aria-label":`Starred conversation`,className:`flex size-4 shrink-0 items-center justify-center rounded-full bg-[#FFD60A] text-white`,children:(0,o.jsx)(l.StarIcon,{className:`size-2.5`,weight:`fill`})})}),S&&(0,o.jsx)(l.CaretRightIcon,{"aria-hidden":`true`,className:`size-4 shrink-0 text-black/65`,weight:`bold`})]})]})})]});return(0,o.jsx)(`div`,{className:(0,c.default)(`@container bg-[linear-gradient(180deg,#FBFAF9_0%,rgba(251,250,249,0.92)_58%,rgba(251,250,249,0)_100%)]`,e),children:(0,o.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:[(0,o.jsx)(`div`,{className:`flex items-start`,children:r&&(0,o.jsx)(`button`,{className:(0,c.default)(I,`messaging-channel-view-back-button-mobile messaging-channel-view-back-button-desktop`),onClick:t||(()=>{}),type:`button`,"aria-label":`Back to conversations`,children:(0,o.jsx)(l.ArrowLeftIcon,{className:`size-5 text-black/90`})})}),(0,o.jsx)(`div`,{className:`flex min-w-0 justify-center`,"data-dd-privacy":`mask`,children:S?(0,o.jsx)(`button`,{type:`button`,onClick:S,"aria-label":`View details for ${D}`,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:L}):(0,o.jsx)(`div`,{className:`flex min-w-0 max-w-full flex-col items-center px-2`,children:L})}),(0,o.jsxs)(`div`,{className:`flex items-start justify-end gap-2`,children:[i&&(0,o.jsx)(`button`,{className:I,onClick:P,type:`button`,"aria-pressed":k,"aria-label":k?`Unstar conversation`:`Star conversation`,children:(0,o.jsx)(l.StarIcon,{className:(0,c.default)(`size-5`,{"text-[#FFD60A]":k,"text-black/90":!k}),weight:k?`fill`:`regular`})}),y&&(v===void 0?(0,o.jsx)(F,{channel:C,participant:E,showDeleteConversation:d,showBlockParticipant:f,showReportParticipant:p,onLeaveConversation:s,onBlockParticipant:u,onDeleteConversationClick:m,onBlockParticipantClick:h,onReportParticipantClick:g,customChannelActions:_,triggerClassName:I}):v)]})]})})},te=e=>(0,o.jsx)(a.DateSeparator,{...e,position:`center`});function z(e){return e?.trim().toLowerCase().split(/[-_]/)[0]||void 0}function B({message:e,viewerLanguage:t}){let n=e?.text,r=z(t);return r?e?.i18n?.[`${r}_text`]??n:n}function V(e){return e.type===`link`||!!e.og_scrape_url?.trim()}var ne={LockedAttachment:{isUnlocking:()=>!1}},H=(0,n.createContext)({}),re=H.Provider;function ie(e){return(0,n.useContext)(H)[e]??ne[e]}var ae=n.default.lazy(()=>Promise.resolve().then(()=>require("./Card-Ds1FMcUj.cjs"))),oe=n.default.lazy(()=>Promise.resolve().then(()=>require("./Card-BS6Fza2a.cjs"))),U=()=>(0,o.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}),se=e=>(0,o.jsx)(n.Suspense,{fallback:(0,o.jsx)(U,{}),children:e.contentType===`text`?(0,o.jsx)(ae,{...e}):(0,o.jsx)(oe,{...e})}),ce=({size:e=15})=>(0,o.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 15 15`,fill:`none`,"aria-hidden":`true`,children:(0,o.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})}),W=e=>e.metadata?.custom_type===s.MESSAGE_CUSTOM_TYPE.PAID,le=e=>e.metadata?.custom_type===s.MESSAGE_CUSTOM_TYPE.CHATBOT,ue=e=>e.metadata?.custom_type===s.MESSAGE_CUSTOM_TYPE.ATTACHMENT,de=e=>ue(e)&&e.metadata?.attachment_content_type===`text`,fe=e=>ue(e)&&e.metadata?.attachment_content_type!==`text`,pe=e=>W(e)&&!!e.metadata?.amount_text,me=({message:e,isMyMessage:t=!1,hasAttachment:n=!1})=>{let r=W(e),i=le(e);if(!r&&!i)return null;if(r){let t=e.metadata?.amount_text;return t?(0,o.jsxs)(`div`,{className:`message-tag--paid inline-flex items-center gap-1 text-[12px] font-medium leading-[2] text-[#016630]`,children:[(0,o.jsx)(l.GiftIcon,{size:12}),(0,o.jsxs)(`span`,{children:[`Delivered with `,t,` message`]})]}):null}let a=t&&n,s=a?`Sent with AI`:`Sent by AI Assistant`,c=a?`justify-end gap-2 text-black/30`:t?`w-full justify-start gap-1.5 mt-3 px-4 text-white/55`:`w-full justify-start gap-1.5 mt-3 px-4 text-black/30`,u=(0,o.jsx)(`span`,{className:`text-left`,children:s}),d=(0,o.jsx)(`span`,{className:`inline-flex items-center leading-none`,children:(0,o.jsx)(ce,{size:a?12:15})});return(0,o.jsx)(`div`,{className:`inline-flex items-center text-[10px] font-normal leading-4 tracking-[0.2px] ${c}`,"data-testid":`message-chatbot-indicator`,children:t&&!a?(0,o.jsxs)(o.Fragment,{children:[u,d]}):(0,o.jsxs)(o.Fragment,{children:[d,u]})})},he=`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%`,G={me:`var(--str-chat__own-message-bubble-background-color, #1e2330)`,other:`var(--str-chat__message-bubble-background-color, #f1f0ee)`},ge=({side:e})=>(0,o.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute bottom-0 z-[-1] h-[1.4375rem] w-5`,style:{insetInlineEnd:e===`me`?`calc(-1 * 0.3125rem)`:void 0,insetInlineStart:e===`other`?`calc(-1 * 0.3125rem)`:void 0,transform:e===`other`?`scaleX(-1)`:void 0,transformOrigin:`center`,backgroundColor:G[e],WebkitMask:he,mask:he}}),_e=(0,n.createContext)(void 0),K=e=>{let t=e.metadata?.outbound_id;return typeof t==`string`?t:void 0},ve=(e,t)=>{if(!t||!e?.length)return;let n=new Set,r;for(let i of e){let e=K(i);if(!e||n.has(e))continue;n.add(e);let a=t(e);a&&(r??={},r[e]={id:a.id,...a.name===void 0?{}:{name:a.name}})}return r},ye=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>e[n].id===t[n]?.id&&e[n].name===t[n]?.name)},be=(e,t)=>{let r=ve(e,t),[i,a]=(0,n.useState)(r);return ye(i,r)?i:(a(r),r)},xe=e=>e.metadata?.custom_type===s.MESSAGE_CUSTOM_TYPE.TIP,Se=({message:e})=>{let t=e.metadata?.amount_text;return t?(0,o.jsxs)(`div`,{className:`message-tip-pill inline-flex items-end gap-0.5 max-w-[520px] rounded-[1.5rem] bg-[#43e660] px-4 py-3 text-white`,children:[(0,o.jsx)(`span`,{className:`flex h-5 items-center text-[20px] leading-none`,"aria-hidden":`true`,children:`π`}),(0,o.jsxs)(`span`,{className:`text-[14px] font-bold leading-[1.43] tracking-[0.28px] text-[rgba(4,4,3,0.9)]`,children:[t,` tip!`]})]}):null},Ce=()=>{let{message:e}=(0,a.useMessageContext)(`SentMessageDeliveryStatus`),{messages:t}=(0,a.useChannelStateContext)(`SentMessageDeliveryStatus`),n=(()=>{if(t)for(let e=t.length-1;e>=0;--e){let n=t[e];if(n.type!==`system`&&n.type!==`ephemeral`&&n.type!==`deleted`)return n.id}})();return e.id===n},q=()=>Ce()?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(l.ChecksIcon,{weight:`bold`,"aria-hidden":`true`}),(0,o.jsx)(`span`,{"data-testid":`sent-message-delivery-status`,children:`Delivered`})]}):null,J=()=>Ce()?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(l.CircleNotchIcon,{className:`sent-message-status__spinner animate-spin`,weight:`bold`,"aria-hidden":`true`}),(0,o.jsx)(`span`,{"data-testid":`sent-message-sending-status`,children:`Sending`})]}):null,we=({outbound:e,onOutboundClick:t})=>{let n=e.name||`Broadcast`,r=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{className:`sent-message-outbound-badge`,"aria-hidden":`true`,children:(0,o.jsx)(l.MegaphoneIcon,{weight:`fill`})}),(0,o.jsx)(`span`,{className:(0,c.default)(`sent-message-outbound-name`,{"underline [text-decoration-skip-ink:auto]":!!t}),"data-testid":`sent-message-outbound-status`,children:n})]});return t?(0,o.jsx)(`button`,{type:`button`,className:`inline-flex cursor-pointer items-center gap-1 border-0 bg-transparent p-0 text-inherit [font:inherit]`,"aria-label":`View broadcast ${n}`,onClick:()=>t(e),children:r}):r},Te=()=>(0,o.jsxs)(`span`,{className:`str-chat__message-status sent-message-status--failed`,children:[(0,o.jsx)(l.WarningCircleIcon,{weight:`bold`,"aria-hidden":`true`}),(0,o.jsx)(`span`,{"data-testid":`sent-message-failed-status`,children:`Failed to send`})]}),Ee=({onOutboundClick:e,resolvedOutbound:t})=>{let{isMyMessage:n,message:r,threadList:i}=(0,a.useMessageContext)(`SentMessageDeliveryStatus`),s=n(),c=Ce();if(i)return null;if(r.status===`failed`&&s&&r.type!==`error`)return(0,o.jsx)(Te,{});if(!s)return null;let l=r.metadata?.outbound_id,u=r.status!==`sending`&&r.status!==`failed`&&l&&t?(0,o.jsx)(we,{outbound:t,onOutboundClick:e}):null,d=pe(r)?null:(0,o.jsx)(a.MessageStatus,{MessageSentStatus:q,MessageDeliveredStatus:q,MessageReadStatus:q,MessageSendingStatus:xe(r)?q:J});return u?(0,o.jsxs)(`span`,{className:`sent-message-status-row`,children:[d,d&&c&&(0,o.jsx)(`span`,{className:`sent-message-outbound-separator`,"aria-hidden":`true`,children:`β’`}),u]}):d},De=/^([a-z][a-z0-9+.-]*):/i,Y=new Set([`http`,`https`,`mailto`,`tel`,`sms`]);function Oe(e){if(typeof e!=`string`)return;let t=e.trim();if(t===``)return;let n=De.exec(t);if(n){let e=n[1].toLowerCase();return Y.has(e)?t:void 0}return t.startsWith(`//`)||t.startsWith(`/`)?t:`https://${t}`}var ke={dark:{primary:`bg-white text-[#121110] hover:bg-white/90`,secondary:`bg-white/15 text-white hover:bg-white/25`},light:{primary:`bg-[#121110] text-white hover:bg-[#2a2928]`,secondary:`bg-black/[0.06] text-[#121110] hover:bg-black/10`}},Ae=({variant:e,cta:t,fullWidth:n=!0,standalone:r=!1})=>{let i=t.variant??`primary`,a=(0,c.default)(`inline-flex h-10 items-center justify-center rounded-full px-4 text-sm font-medium leading-none transition-colors`,n?`w-full`:`min-w-0`,!r&&`mt-2`,ke[e][i]),s=n?t.label:(0,o.jsx)(`span`,{className:`min-w-0 truncate`,children:t.label}),l=Oe(t.href);return l?(0,o.jsx)(`a`,{href:l,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.stopPropagation(),t.onClick?.()},className:`${a} no-underline`,children:s}):(0,o.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),t.onClick?.()},className:a,children:s})},je={dark:`text-white`,light:`text-black/90`},Me=`text-white/30`,Ne={dark:`text-white/55`,light:`text-black/55`},Pe={dark:`bg-white/25`,light:`bg-black/15`},Fe=({variant:e,ctaSurface:t,chinTextColor:n,title:r,placeholderTitle:i,description:a,descriptionLines:s=1,url:l,appIcon:u,cta:d,trailingAction:f,isLoading:p=!1})=>{let m=e===`dark`,h=r??(m?i:void 0)??``,g=h.trim()!==``,_=a!=null&&a.trim()!==``,v=typeof l==`string`?l.trim():``,y=v!==``,b=d!=null;if(!p&&!g&&!_&&!y&&!b)return null;let x=(0,c.default)(`line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.28px]`,n==null&&(m&&!r?Me:je[e])),S=(0,c.default)(`truncate text-[12px] leading-4 tracking-[0.24px]`,n==null&&Ne[e]),C=(0,c.default)(`text-[12px] leading-4 tracking-[0.24px]`,s<=1&&`truncate`,n==null&&Ne[e]);if(p){let t=(0,c.default)(`animate-pulse rounded`,Pe[e]);return(0,o.jsx)(`div`,{className:`shrink-0 px-4 py-3`,children:(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-[2px]`,children:[(0,o.jsx)(`div`,{"data-testid":`card-body-skeleton-bar`,className:(0,c.default)(`h-5 w-3/4`,t),"aria-hidden":!0}),(0,o.jsx)(`div`,{"data-testid":`card-body-skeleton-bar`,className:(0,c.default)(`h-4 w-1/2`,t),"aria-hidden":!0})]})})}let w=n?{color:n}:void 0,T=s>1?{...w,display:`-webkit-box`,WebkitBoxOrient:`vertical`,WebkitLineClamp:s,overflow:`hidden`}:w;return(0,o.jsxs)(`div`,{className:`shrink-0 px-4 py-3`,children:[(0,o.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[g&&(0,o.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[u?(0,o.jsx)(`span`,{className:`shrink-0`,children:u}):null,(0,o.jsx)(`p`,{className:(0,c.default)(`min-w-0`,x),style:w,children:h})]}),_&&(0,o.jsx)(`p`,{className:C,style:T,children:a}),!b&&y&&(0,o.jsx)(`p`,{className:S,style:w,"data-testid":`link-attachment-url`,children:v})]}),f&&(0,o.jsx)(`div`,{className:`shrink-0`,children:f})]}),d&&(0,o.jsx)(Ae,{variant:t??e,cta:d})]})},Ie=`Loading link preview`,Le=(0,c.default)(`relative w-[var(--lt-msg-card-width,290px)] max-w-full select-none overflow-hidden`,`rounded-[20px]`),Re=`flex h-[250px] flex-col`,ze=({variant:e,children:t,href:n,onClick:r,ariaLabel:i,rootRef:a,topRight:s,bgClassName:l,accentHex:u,fixedHeight:d=!1,busy:f=!1,"data-testid":p=`link-card`})=>{let m=(0,c.default)(`messaging-link-card`,Le,d?Re:`block`,l??(e===`dark`?`bg-[#1e2330]`:`bg-[#f1f0ee]`),n!=null||r!=null?`cursor-pointer no-underline focus-ring`:null),h=f?{role:`status`,"aria-busy":!0,"aria-label":Ie}:void 0,g=u?{"--accent":u}:void 0,_=s?(0,o.jsx)(`div`,{"data-testid":`card-shell-top-right`,className:`pointer-events-auto absolute right-3 top-3 z-10`,children:s}):null;return n?(0,o.jsxs)(`a`,{ref:a,href:n,target:`_blank`,rel:`noopener noreferrer`,onClick:r,"data-testid":p,"data-variant":e,className:m,style:g,...h,children:[t,_]}):r?(0,o.jsxs)(`button`,{ref:a,type:`button`,onClick:r,"aria-label":i,"data-testid":p,"data-variant":e,className:(0,c.default)(m,`text-left`),style:g,...h,children:[t,_]}):(0,o.jsxs)(`div`,{ref:a,"data-testid":p,"data-variant":e,className:m,style:g,...h,children:[t,_]})},Be={dark:`bg-white/10`,light:`bg-black/5`},Ve={dark:`size-16 text-white/25`,light:`size-16 text-black/25`},X=(e,n)=>!!n&&!!e&&t.i(e)===`audio`,He=(e,n)=>{if(!n||!e)return!1;let r=t.i(e);return r===`video`||r===`audio`},Ue=`bg-[#F2F3F4]`,We=({variant:e,thumbnailUrl:n,sourceUrl:r,title:i,mimeType:a=`image/*`,topLeft:s,topRight:l,isLoading:u=!1,onImageError:d})=>{let f=t.i(a),p=!!r&&f===`video`,m=t.s(n);return!u&&X(a,r)?(0,o.jsx)(`div`,{className:`p-3`,children:(0,o.jsx)(`audio`,{...t.a,"data-testid":`card-thumbnail-audio`,src:r,controls:!0,preload:`metadata`,className:`block w-full`,children:(0,o.jsx)(`track`,{kind:`captions`})})}):(0,o.jsxs)(`div`,{"data-testid":`card-thumbnail-hero`,className:(0,c.default)(`relative min-h-0 w-full flex-1 overflow-hidden`,p&&`bg-black`),children:[u?(0,o.jsx)(`div`,{"data-testid":`card-thumbnail-skeleton`,className:(0,c.default)(`h-full w-full animate-pulse`,Be[e]),"aria-hidden":!0}):p?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`video`,{"data-testid":`card-thumbnail-video`,src:r,poster:m,controls:!0,playsInline:!0,preload:`metadata`,className:`absolute inset-0 h-full w-full object-contain`,children:(0,o.jsx)(`track`,{kind:`captions`})}),m&&d?(0,o.jsx)(`img`,{src:m,alt:``,"aria-hidden":!0,onError:d,className:`hidden`}):null]}):n?(0,o.jsx)(`img`,{src:m??n,alt:i??``,draggable:!1,loading:`lazy`,decoding:`async`,onError:d,className:`absolute inset-0 h-full w-full object-cover`}):(0,o.jsx)(`div`,{"data-testid":`card-thumbnail-placeholder`,className:(0,c.default)(`flex h-full w-full items-center justify-center`,Be[e]),children:t.n(a,{className:Ve[e],weight:`regular`})}),s?(0,o.jsx)(`div`,{"data-testid":`card-thumbnail-top-left`,className:`pointer-events-auto absolute left-3 top-3 z-10`,children:s}):null,l?(0,o.jsx)(`div`,{"data-testid":`card-thumbnail-top-right`,className:`pointer-events-auto absolute right-3 top-3 z-10`,children:l}):null]})},Ge=/^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;function Ke(e){let t=e.trim();return t.startsWith(`#`)?t:`#${t}`}var qe=`#FFFFFF`,Je=`#040403`,Ye={dark:qe,light:Je};function Xe({variant:e,accentColor:t,status:r=`ready`,layout:i=`featured`,thumbnailUrl:a,mimeType:o,sourceUrl:s}){let[c,l]=n.default.useState(!1);n.default.useEffect(()=>{l(!1)},[a]);let u=n.default.useCallback(()=>{l(!0)},[]),d=X(o,s),f=i===`featured`&&a&&!d&&!c&&r===`ready`&&t!=null&&Ge.test(t.trim())?Ke(t):void 0,p=d?Je:Ye[e];return{thumbnailUrl:c?void 0:a,accentHex:f,chinTextColor:p,surface:d?`light`:e,isLoading:r===`loading`,onImageError:u}}var Ze=`flex size-6 items-center justify-center rounded-full bg-[#121110] text-white transition-colors duration-150 hover:bg-[#2a2928] focus-ring`,Qe=`relative before:absolute before:-inset-[10px] before:content-['']`,$e=({title:e,placeholderTitle:t,description:n,descriptionLines:r,url:i,mimeType:a,thumbnailUrl:s,sourceUrl:u,layout:d=`featured`,appIcon:f,cta:p,accentColor:m,status:h=`ready`,onDismiss:g,onEditClick:_,dismissLabel:v=`Dismiss attachment`})=>{let y=d===`classic`,b=X(a,u),x=Xe({variant:`dark`,accentColor:m,status:h,layout:d,thumbnailUrl:s,mimeType:a,sourceUrl:u}),S=g?(0,o.jsx)(`button`,{type:`button`,onClick:g,"aria-label":v,className:(0,c.default)(Ze,!b&&Qe),children:(0,o.jsx)(l.XIcon,{className:`size-3`,weight:`bold`})}):void 0,C=_?(0,o.jsx)(`button`,{type:`button`,onClick:_,"aria-label":`Edit attachment`,className:`flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15`,children:(0,o.jsx)(l.PencilSimpleIcon,{className:`size-5`,weight:`regular`})}):void 0;return b&&!x.isLoading?(0,o.jsx)(ze,{variant:`dark`,bgClassName:Ue,children:(0,o.jsxs)(`div`,{className:`flex items-center gap-2 pr-3`,children:[(0,o.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,o.jsx)(We,{variant:`dark`,sourceUrl:u,title:e,mimeType:a})}),S&&(0,o.jsx)(`div`,{className:`shrink-0`,children:S})]})}):(0,o.jsxs)(ze,{variant:`dark`,fixedHeight:!y,accentHex:x.accentHex,busy:x.isLoading,topRight:y?S:void 0,children:[!y&&(0,o.jsx)(We,{variant:`dark`,thumbnailUrl:x.thumbnailUrl,sourceUrl:u,title:e,mimeType:a,topRight:S,isLoading:x.isLoading,onImageError:x.onImageError}),(0,o.jsx)(Fe,{chinTextColor:x.chinTextColor,variant:`dark`,ctaSurface:x.surface,title:e,placeholderTitle:t,description:n,descriptionLines:r,url:i,appIcon:f,cta:p,trailingAction:C,isLoading:x.isLoading})]})},et=({accentHex:e,side:t,visible:n,children:r})=>n?(0,o.jsxs)(`div`,{className:`relative isolate w-fit`,children:[r,(0,o.jsx)(`span`,{"aria-hidden":!0,"data-testid":`link-card-tail`,"data-variant":t===`sender`?`dark`:`light`,style:e?{"--accent":e}:void 0,className:(0,c.default)(`messaging-link-card-tail`,t===`receiver`&&`messaging-link-card-tail--received`)})]}):(0,o.jsx)(o.Fragment,{children:r}),tt={Composer:$e,Sent:({title:e,placeholderTitle:t,description:n,descriptionLines:r,url:i,mimeType:a,thumbnailUrl:s,sourceUrl:c,layout:l=`featured`,appIcon:u,cta:d,accentColor:f,status:p=`ready`,onClick:m,groupPosition:h=`single`})=>{let g=He(a,c),_=Oe(i),v=d==null&&_!=null&&!g?_:void 0,y=d==null&&!g&&v!=null?m:void 0,b=p!==`loading`&&X(a,c),x=Xe({variant:`dark`,accentColor:f,status:p,layout:l,thumbnailUrl:s,mimeType:a,sourceUrl:c});return(0,o.jsx)(et,{accentHex:x.accentHex,side:`sender`,visible:!b&&(h===`single`||h===`end`),children:(0,o.jsxs)(ze,{variant:`dark`,href:v,onClick:y,fixedHeight:l===`featured`&&!b,accentHex:x.accentHex,busy:x.isLoading,bgClassName:b?Ue:void 0,children:[l===`featured`&&(0,o.jsx)(We,{variant:`dark`,thumbnailUrl:x.thumbnailUrl,sourceUrl:c,title:e,mimeType:a,isLoading:x.isLoading,onImageError:x.onImageError}),(0,o.jsx)(Fe,{chinTextColor:x.chinTextColor,variant:`dark`,ctaSurface:x.surface,title:e,placeholderTitle:t,description:n,descriptionLines:r,url:i,appIcon:u,cta:d,isLoading:x.isLoading})]})})},Received:({title:e,description:t,descriptionLines:n,url:r,mimeType:i,thumbnailUrl:a,sourceUrl:s,layout:c=`featured`,appIcon:l,cta:u,accentColor:d,status:f=`ready`,onClick:p,groupPosition:m=`single`})=>{let h=He(i,s),g=Oe(r),_=u==null&&g!=null&&!h?g:void 0,v=u==null&&!h?p:void 0,y=f!==`loading`&&X(i,s)?Ue:void 0,b=u&&p?{...u,onClick:()=>{p(),u.onClick?.()}}:u,x=Xe({variant:`light`,accentColor:d,status:f,layout:c,thumbnailUrl:a,mimeType:i,sourceUrl:s});return(0,o.jsx)(et,{accentHex:x.accentHex,side:`receiver`,visible:y==null&&(m===`single`||m===`end`),children:(0,o.jsxs)(ze,{variant:`light`,href:_,onClick:v,ariaLabel:e??`Open attachment preview`,fixedHeight:c===`featured`&&y==null,accentHex:x.accentHex,busy:x.isLoading,bgClassName:y,"data-testid":`link-attachment`,children:[c===`featured`&&(0,o.jsx)(We,{variant:`light`,thumbnailUrl:x.thumbnailUrl,sourceUrl:s,title:e,mimeType:i,isLoading:x.isLoading,onImageError:x.onImageError}),(0,o.jsx)(Fe,{chinTextColor:x.chinTextColor,variant:`light`,ctaSurface:x.surface,title:e,description:t,descriptionLines:n,url:r,appIcon:l,cta:b,isLoading:x.isLoading})]})})}},nt={dark:`bg-[#1e2330]`,light:`bg-[#f2f1ef]`},rt={dark:`text-white`,light:`text-[#000000]`},it={dark:`border-white/[0.08]`,light:`border-black/[0.08]`},at=e=>e===`dark`?`sender`:`receiver`,ot={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]`}},st=({variant:e,text:t,bordered:n=!0,groupPosition:r=`single`,widthClassName:i=`w-[280px]`,paddingClassName:a=`px-2 py-2`,radiusClassName:s,className:l,children:u,"data-testid":d})=>{let f=t!=null&&t!==``,p=s??ot[at(e)][r];return(0,o.jsxs)(`div`,{"data-testid":d,"data-group-position":r,className:(0,c.default)(`relative`,i,`overflow-hidden`,a,f&&`pb-0`,p,nt[e],rt[e],n&&`border`,n&&it[e],l),children:[u,f?(0,o.jsx)(`p`,{className:(0,c.default)(`whitespace-pre-wrap break-words leading-snug hyphens-manual`,`pb-2 pt-2`,`px-2`),children:t}):null]})},ct=({onClick:e,variant:t=`overlay`,ariaLabel:n=`Dismiss attachment`})=>(0,o.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e()},"aria-label":n,className:(0,c.default)(`flex size-6 items-center justify-center rounded-full text-white`,t===`overlay`?`bg-[#121110]/85 backdrop-blur`:`bg-white/15 hover:bg-white/25`),children:(0,o.jsx)(l.XIcon,{className:`size-3`,weight:`bold`})}),lt=e=>e===`received`?`light`:`dark`,ut=({firstOfGroup:e,endOfGroup:t,groupedByUser:n})=>!n||e&&t?`single`:e?`first`:t?`end`:`middle`,dt=({src:e,mimeType:t,filename:n,items:r})=>r&&r.length>0?r:e?[{src:e,mimeType:t,filename:n}]:[],ft=({item:e,preload:n,trailingAction:r})=>(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`audio`,{...t.a,src:e.src,controls:!0,preload:e.preload??n,className:`block min-w-0 flex-1`,children:e.mimeType?(0,o.jsx)(`source`,{src:e.src,type:e.mimeType}):null}),r??null]}),pt=({state:e,src:t,mimeType:n,filename:r,items:i,text:a,groupPosition:s,preload:c,onDismiss:l})=>{let u=lt(e),d=e===`composer`&&!!l,f=dt({src:t,mimeType:n,filename:r,items:i});if(f.length===0)return null;let p=c??(f.length>1?`none`:`metadata`);return(0,o.jsx)(st,{variant:u,text:a,groupPosition:s,"data-testid":`audio-attachment`,children:(0,o.jsx)(`div`,{className:`flex flex-col gap-2`,children:f.map((e,t)=>(0,o.jsx)(ft,{item:e,preload:p,trailingAction:d&&t===0?(0,o.jsx)(ct,{onClick:l,variant:`inline`}):void 0},`${e.src}-${t}`))})})},mt={Composer:e=>(0,o.jsx)(pt,{...e,state:`composer`}),Sent:e=>(0,o.jsx)(pt,{...e,state:`sent`}),Received:e=>(0,o.jsx)(pt,{...e,state:`received`})};function ht(e){return!Number.isFinite(e)||e<0?``:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(2)} MB`:`${(e/1073741824).toFixed(2)} GB`}var gt={pdf:`PDF`,doc:`DOC`,xls:`XLS`,csv:`CSV`,ppt:`PPT`,zip:`ZIP`,text:`TXT`,markdown:`MD`};function _t(e,n){if(n){let e=n.lastIndexOf(`.`);if(e>0&&e<n.length-1){let t=n.slice(e+1);if(t&&t.length<=5)return t.toUpperCase()}}if(!e)return;if(t.i(e)===`document`){let n=gt[t.r(e)];if(n)return n;if(e===`application/octet-stream`)return}let r=e.split(`/`)[1];if(!(!r||r===`*`))return r.toUpperCase()}function vt(e,t,n){return[_t(e,t),typeof n==`number`&&n>0?ht(n):void 0].filter(Boolean).join(` Β· `)||void 0}function Z(e){try{let t=new URL(e).pathname.split(`/`).pop();return t&&t.length>0?decodeURIComponent(t):`download`}catch{return`download`}}var yt={dark:`text-white/55`,light:`text-black/65`},bt={dark:`bg-white/10`,light:`bg-black/5`},xt={dark:`text-white/85`,light:`text-black/85`},St=({variant:e,filename:n,title:r,mimeType:i=`application/octet-stream`,fileSize:a,onActivate:s,activateLabel:l,trailingAction:u})=>{let d=r??n??`File`,f=vt(i,n,a),p=(0,o.jsx)(`div`,{className:(0,c.default)(`flex size-10 shrink-0 items-center justify-center rounded-sm`,bt[e]),"aria-hidden":!0,children:t.n(i,{className:(0,c.default)(`size-6`,xt[e]),weight:`regular`})}),m=(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col text-left`,children:[(0,o.jsx)(`p`,{className:`truncate font-medium leading-snug`,children:d}),f?(0,o.jsx)(`p`,{className:(0,c.default)(`truncate text-xs leading-4`,yt[e]),children:f}):null]}),h=s?(0,o.jsxs)(`button`,{type:`button`,onClick:s,"aria-label":l,className:(0,c.default)(`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:[p,m]}):(0,o.jsxs)(o.Fragment,{children:[p,m]});return(0,o.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2`,children:[h,u?(0,o.jsx)(`div`,{className:`shrink-0`,children:u}):null]})};async function Ct(e,t){let n=t??Z(e);try{let t=await fetch(e,{mode:`cors`});if(!t.ok)throw Error(`HTTP ${t.status}`);let r=await t.blob(),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n,a.style.display=`none`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}catch{if(!window.open(e,`_blank`,`noopener,noreferrer`)){let t=document.createElement(`a`);t.href=e,t.download=n,t.target=`_blank`,t.rel=`noopener noreferrer`,t.style.display=`none`,document.body.appendChild(t),t.click(),document.body.removeChild(t)}}}var wt=({src:e,filename:t,fileSize:n,mimeType:r,title:i,items:a})=>a&&a.length>0?a:e?[{src:e,filename:t,fileSize:n,mimeType:r,title:i}]:[],Tt=({variant:e,item:t,index:n,onActivate:r,trailingAction:i})=>{let a=t.filename??Z(t.src);return(0,o.jsx)(St,{variant:e,filename:a,title:t.title,mimeType:t.mimeType??`application/octet-stream`,fileSize:t.fileSize,onActivate:()=>r(n),activateLabel:`Download ${a}`,trailingAction:i})},Et=({state:e,src:t,filename:n,fileSize:r,mimeType:i,title:a,items:s,text:u,groupPosition:d,onClick:f,onDismiss:p})=>{let m=lt(e),h=e===`composer`&&!!p,g=wt({src:t,filename:n,fileSize:r,mimeType:i,title:a,items:s}),_=e=>{if(f?.(e)===!1)return;let t=g[e];if(!t)return;let n=t.filename??Z(t.src);Ct(t.src,n)};if(g.length===0)return null;let v=(0,o.jsx)(`span`,{className:(0,c.default)(`flex size-8 items-center justify-center rounded-full`,m===`dark`?`text-white/70`:`text-black/70`),"aria-hidden":!0,children:(0,o.jsx)(l.DownloadSimpleIcon,{className:`size-5`,weight:`bold`})});return(0,o.jsx)(st,{variant:m,text:u,groupPosition:d,"data-testid":`file-attachment`,children:(0,o.jsx)(`div`,{className:`flex flex-col gap-2`,children:g.map((e,t)=>(0,o.jsx)(Tt,{variant:m,item:e,index:t,onActivate:_,trailingAction:h&&t===0?(0,o.jsx)(ct,{onClick:p,variant:`inline`}):v},`${e.src}-${t}`))})})},Dt={Composer:e=>(0,o.jsx)(Et,{...e,state:`composer`}),Sent:e=>(0,o.jsx)(Et,{...e,state:`sent`}),Received:e=>(0,o.jsx)(Et,{...e,state:`received`})},Ot=`inline-flex size-10 items-center justify-center rounded-full border-0 bg-white/[0.12] p-0 text-white transition-colors duration-150 ease-[ease] hover:bg-white/[0.22] focus-visible:bg-white/[0.22] focus-visible:outline-none disabled:cursor-default disabled:opacity-40`,kt=`absolute top-1/2 z-[1] inline-flex size-12 -translate-y-1/2 items-center justify-center rounded-full border-0 bg-white/[0.12] p-0 text-white transition-colors duration-150 ease-[ease] hover:bg-white/[0.22] focus-visible:bg-white/[0.22] focus-visible:outline-none`,At=({onPrev:e,onNext:t,prevLabel:n=`Previous`,nextLabel:r=`Next`})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`button`,{type:`button`,onClick:e,"aria-label":n,className:`${kt} left-4`,children:(0,o.jsx)(l.CaretLeftIcon,{size:20,weight:`bold`,"aria-hidden":!0})}),(0,o.jsx)(`button`,{type:`button`,onClick:t,"aria-label":r,className:`${kt} right-4`,children:(0,o.jsx)(l.CaretRightIcon,{size:20,weight:`bold`,"aria-hidden":!0})})]}),jt=({url:e,filename:t,variant:r=`pill`,label:i=`Download`,iconOnly:a,tone:s=`dark`,onTriggered:u})=>{let[d,f]=(0,n.useState)(!1),p=(0,n.useCallback)(n=>{n.stopPropagation(),!d&&(f(!0),Ct(e,t).catch(()=>{}).finally(()=>{f(!1),u?.()}))},[d,e,t,u]),m=a??r!==`pill`,h={className:(0,c.default)(r===`pill`?`size-4`:`size-5`,`shrink-0`),weight:`bold`};return r===`inline`?(0,o.jsx)(`button`,{type:`button`,onClick:p,disabled:d,"aria-label":i,className:(0,c.default)(`flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70`,{dark:`text-white/70 hover:bg-white/[0.08] hover:text-white`,light:`text-black/70 hover:bg-black/[0.08] hover:text-black`}[s]),children:d?(0,o.jsx)(l.CircleNotchIcon,{className:`size-4 animate-spin`,weight:`bold`,"aria-hidden":!0}):(0,o.jsx)(l.DownloadSimpleIcon,{className:`size-5 shrink-0`,weight:`bold`,"aria-hidden":!0})}):r===`viewer`?(0,o.jsx)(`button`,{type:`button`,onClick:p,disabled:d,"aria-label":i,className:Ot,children:d?(0,o.jsx)(l.CircleNotchIcon,{size:20,weight:`bold`,"aria-hidden":!0}):(0,o.jsx)(l.DownloadSimpleIcon,{size:20,weight:`bold`,"aria-hidden":!0})}):(0,o.jsxs)(`button`,{type:`button`,onClick:p,disabled:d,"aria-label":m?i:void 0,className:(0,c.default)(`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`,s===`dark`?`bg-[#121110] text-white hover:bg-[#2a2928]`:`bg-white text-[#121110] hover:bg-white/90`),children:[d?(0,o.jsx)(l.CircleNotchIcon,{className:`size-4 animate-spin`,weight:`bold`,"aria-hidden":!0}):(0,o.jsx)(l.DownloadSimpleIcon,{...h,"aria-hidden":!0}),m?null:i]})},Mt=(e,t,n)=>Math.min(Math.max(e,t),n),Nt=({length:e,initialIndex:t,open:r})=>{let i=Mt(t,0,Math.max(e-1,0)),[a,o]=(0,n.useState)(i);(0,n.useEffect)(()=>{r&&o(Mt(t,0,Math.max(e-1,0)))},[r,t,e]),(0,n.useEffect)(()=>{o(t=>Mt(t,0,Math.max(e-1,0)))},[e]);let s=(0,n.useCallback)(()=>{e<=1||o(t=>t<=0?e-1:t-1)},[e]),c=(0,n.useCallback)(()=>{e<=1||o(t=>t>=e-1?0:t+1)},[e]);return(0,n.useEffect)(()=>{if(!r||e<=1)return;let t=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;let t=document.activeElement;t&&(t.tagName===`VIDEO`||t.tagName===`AUDIO`)||(e.preventDefault(),e.key===`ArrowLeft`?s():c())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[r,e,s,c]),{index:a,prev:s,next:c}},Pt=({open:e,onClose:t,ariaLabel:r,counter:i,actions:a,children:s,"data-testid":c})=>{let u=(0,n.useRef)(null),d=(0,n.useRef)(null);return(0,n.useEffect)(()=>{let t=u.current;if(t){if(e){if(!t.open){if(typeof t.showModal==`function`)try{t.showModal()}catch{t.setAttribute(`open`,``)}else t.setAttribute(`open`,``)}let e=typeof document<`u`?document.activeElement:null;return d.current?.focus(),()=>{if(t.open){if(typeof t.close==`function`)try{t.close()}catch{t.removeAttribute(`open`)}else t.removeAttribute(`open`)}e&&document.body.contains(e)&&e.focus()}}if(t.open){if(typeof t.close==`function`)try{t.close()}catch{t.removeAttribute(`open`)}else t.removeAttribute(`open`)}}},[e]),(0,o.jsxs)(`dialog`,{ref:u,className:`mes-media-viewer`,"aria-label":r??`Attachment viewer`,"data-testid":c,onClose:()=>{t()},onClick:e=>{e.target===u.current&&t()},children:[(0,o.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-3 top-3 z-[1] flex items-center justify-between gap-3`,children:[i?(0,o.jsx)(`span`,{className:`pointer-events-auto inline-flex items-center rounded-full bg-white/[0.12] px-3 py-1.5 text-[13px] font-medium leading-none tabular-nums text-white`,children:i}):null,(0,o.jsxs)(`div`,{className:`pointer-events-auto ml-auto inline-flex items-center gap-2`,children:[a,(0,o.jsx)(`button`,{ref:d,type:`button`,onClick:t,"aria-label":`Close viewer`,className:Ot,children:(0,o.jsx)(l.XIcon,{size:20,weight:`bold`,"aria-hidden":!0})})]})]}),(0,o.jsx)(`div`,{className:`box-border flex h-full w-full items-center justify-center px-6 py-16`,children:s})]})},Ft=({open:e,items:t,initialIndex:r=0,onClose:i})=>{let{index:a,prev:s,next:c}=Nt({length:t.length,initialIndex:r,open:e}),l=t[a],u=(0,n.useMemo)(()=>l?.filename??(l?Z(l.src):`image`),[l]);return l?(0,o.jsxs)(Pt,{open:e,onClose:i,ariaLabel:u,counter:t.length>1?`${a+1} / ${t.length}`:void 0,actions:(0,o.jsx)(jt,{url:l.src,filename:u,variant:`viewer`,label:`Download ${u}`}),"data-testid":`image-viewer`,children:[e?(0,o.jsx)(`img`,{src:l.src,alt:l.alt??u,draggable:!1,decoding:`async`,className:`block h-auto max-h-[calc(100dvh-128px)] w-auto max-w-[min(96vw,1400px)] select-none object-contain`},`${a}:${l.src}`):null,t.length>1?(0,o.jsx)(At,{onPrev:s,onNext:c,prevLabel:`Previous image`,nextLabel:`Next image`}):null]}):null},It=`relative block size-full overflow-hidden bg-black/5 outline-none after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-white/80 focus-visible:after:ring-offset-2 focus-visible:after:ring-offset-black`,Lt={1:[`rounded-[18px]`],2:[`rounded-l-[18px]`,`rounded-r-[18px]`],3:[`rounded-l-[18px]`,`rounded-tr-[18px]`,`rounded-br-[18px]`],4:[`rounded-tl-[18px]`,`rounded-tr-[18px]`,`rounded-bl-[18px]`,`rounded-br-[18px]`]},Rt=`--mes-single-width-cap`,zt=`[--mes-single-width-cap:309px] sm:[--mes-single-width-cap:326px]`,Bt=436,Vt=({tiles:e,onTileActivate:t,maxVisible:n=4,singleAspectRatio:r,className:i})=>{let a=e.length;if(a===0)return null;let s=e.slice(0,Math.min(a,n)),l=a-s.length,u=l>0?(0,o.jsxs)(`div`,{"aria-hidden":!0,className:`absolute inset-0 flex items-center justify-center bg-[#040403]/50 text-2xl font-bold leading-[28px] tracking-[-0.24px] text-white`,children:[`+`,l]}):null,d=(e,n,r)=>{let i=(0,c.default)(It,`h-full w-full`,Lt[s.length]?.[n]);return t?(0,o.jsxs)(`button`,{type:`button`,onClick:()=>t(n),"aria-label":e.ariaLabel??`Open media ${n+1}`,className:(0,c.default)(i,e.cursorClassName??`cursor-zoom-in`),children:[e.content,r]},n):(0,o.jsxs)(`div`,{className:i,children:[e.content,r]},n)},f;return r&&(f={aspectRatio:r,width:`min(var(${Rt}), ${Math.round(Bt*r*100)/100}px)`,maxWidth:`100%`}),s.length===1?(0,o.jsx)(`div`,{className:(0,c.default)(r?zt:`aspect-square w-full`,i),style:f,children:d(s[0],0,u)}):s.length===2?(0,o.jsx)(`div`,{className:(0,c.default)(`grid aspect-[16/9] w-full grid-cols-2 gap-0.5`,i),children:s.map((e,t)=>d(e,t,t===s.length-1?u:null))}):s.length===3?(0,o.jsxs)(`div`,{className:(0,c.default)(`grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5`,i),children:[(0,o.jsx)(`div`,{className:`row-span-2`,children:d(s[0],0)}),d(s[1],1),d(s[2],2,u)]}):(0,o.jsx)(`div`,{className:(0,c.default)(`grid aspect-[379/286] w-full grid-cols-2 grid-rows-2 gap-0.5`,i),children:s.map((e,t)=>{let n=l>0&&t===s.length-1;return d(e,t,n?u:null)})})},Ht=({src:e,suppliedRatio:t,fallbackRatio:r})=>{let[i,a]=n.default.useState(),o=n.default.useCallback(t=>{if(!t||t.naturalWidth<=0||t.naturalHeight<=0||e===void 0)return;let n=t.naturalWidth/t.naturalHeight;a(t=>t&&t.src===e&&t.ratio===n?t:{src:e,ratio:n})},[e]),s=n.default.useCallback(e=>o(e.currentTarget),[o]),c=i&&i.src===e?i.ratio:void 0;return{ratio:t??c??r,imgRef:o,onLoad:s}},Ut=e=>{let[t,r]=(0,n.useState)(!1),[i,a]=(0,n.useState)(0);return{viewerOpen:t,viewerIndex:i,handleActivate:(0,n.useCallback)(t=>{e?.(t)!==!1&&(a(t),r(!0))},[e]),closeViewer:(0,n.useCallback)(()=>r(!1),[])}},Wt=({item:e,index:n,totalCount:r,fallbackLoading:i,imgRef:a,onLoad:s})=>({ariaLabel:`Open image ${n+1} of ${r}`,content:(0,o.jsx)(`img`,{ref:a,src:t.s(e.src)??e.src,alt:e.alt??``,width:e.width,height:e.height,draggable:!1,loading:e.loading??i,decoding:`async`,onLoad:s,className:`absolute inset-0 size-full object-cover`})}),Gt=({src:e,alt:t,items:n})=>n&&n.length>0?n:e?[{src:e,alt:t}]:[],Kt=(e,t)=>e.map((n,r)=>({src:n.src,alt:n.alt,filename:t&&e.length===1?t:t?`${t} (${r+1})`:void 0})),qt=({src:e,alt:n,filename:r,loading:i=`lazy`,onClick:a,onDismiss:s})=>{let{viewerOpen:c,viewerIndex:l,handleActivate:u,closeViewer:d}=Ut(a);return(0,o.jsxs)(`div`,{className:`relative w-fit`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>u(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:(0,o.jsx)(`img`,{src:t.s(e)??e,alt:n??``,draggable:!1,loading:i,decoding:`async`,className:`size-full object-cover`})}),s?(0,o.jsx)(`div`,{className:`absolute right-2 top-2 z-10`,children:(0,o.jsx)(ct,{onClick:s})}):null,(0,o.jsx)(Ft,{open:c,items:Kt([{src:e,alt:n}],r),initialIndex:l,onClose:d})]})},Jt=326/246,Yt=({state:e,src:t,alt:n,filename:r,items:i,text:a,groupPosition:s,loading:c=`lazy`,onClick:l})=>{let u=Gt({src:t,alt:n,items:i}),d=lt(e),{viewerOpen:f,viewerIndex:p,handleActivate:m,closeViewer:h}=Ut(l),g=u.length===1,_=g?u[0]:void 0,v=Ht({src:_?.src,suppliedRatio:_?.width&&_?.height?_.width/_.height:void 0,fallbackRatio:Jt});if(u.length===0)return null;let y=u.map((e,t)=>Wt({item:e,index:t,totalCount:u.length,fallbackLoading:c,imgRef:g?v.imgRef:void 0,onLoad:g?v.onLoad:void 0}));return(0,o.jsxs)(st,{variant:d,text:a,groupPosition:s,bordered:!1,widthClassName:g?`w-fit max-w-[min(100%,313px)] sm:max-w-[min(100%,330px)]`:`w-[383px] max-w-full`,paddingClassName:`p-0.5`,radiusClassName:`rounded-[20px]`,"data-testid":`image-attachment`,children:[(0,o.jsx)(`div`,{className:`relative`,children:(0,o.jsx)(Vt,{tiles:y,onTileActivate:m,singleAspectRatio:g?v.ratio:void 0})}),(0,o.jsx)(Ft,{open:f,items:Kt(u,r),initialIndex:p,onClose:h})]})},Xt={Composer:e=>(0,o.jsx)(qt,{...e}),Sent:e=>(0,o.jsx)(Yt,{...e,state:`sent`}),Received:e=>(0,o.jsx)(Yt,{...e,state:`received`})},Zt=({open:e,items:t,initialIndex:r=0,onClose:i})=>{let{index:a,prev:s,next:c}=Nt({length:t.length,initialIndex:r,open:e}),l=t[a],u=(0,n.useMemo)(()=>l?.filename??(l?Z(l.src):`document`),[l]),d=(0,n.useMemo)(()=>l?Qt(l.src):void 0,[l]);return!l||!d?null:(0,o.jsxs)(Pt,{open:e,onClose:i,ariaLabel:u,counter:t.length>1?`${a+1} / ${t.length}`:void 0,"data-testid":`pdf-viewer`,children:[(0,o.jsx)(`iframe`,{src:d,title:u,className:`block h-[calc(100dvh-128px)] w-[min(96vw,1400px)] border-0 bg-white`,sandbox:`allow-scripts allow-forms allow-popups allow-downloads`},`${a}:${l.src}`),t.length>1?(0,o.jsx)(At,{onPrev:s,onNext:c,prevLabel:`Previous document`,nextLabel:`Next document`}):null]})},Qt=e=>{let t=e.indexOf(`#`),n=t===-1?e:e.slice(0,t),r=t===-1?``:e.slice(t+1),i=new URLSearchParams(r);return i.has(`toolbar`)||i.set(`toolbar`,`0`),i.has(`navpanes`)||i.set(`navpanes`,`0`),`${n}#${i.toString()}`},$t=({src:e,filename:t,fileSize:n,title:r,items:i})=>i&&i.length>0?i:e?[{src:e,filename:t,fileSize:n,title:r}]:[],en=({variant:e,item:t,index:n,onActivate:r,trailingAction:i})=>{let a=t.filename??Z(t.src);return(0,o.jsx)(St,{variant:e,filename:a,title:t.title,mimeType:`application/pdf`,fileSize:t.fileSize,onActivate:()=>r(n),activateLabel:`Open ${a}`,trailingAction:i})},tn=({state:e,src:t,filename:n,fileSize:r,title:i,items:a,text:s,groupPosition:c,onClick:l,onDismiss:u})=>{let d=lt(e),f=$t({src:t,filename:n,fileSize:r,title:i,items:a}),{viewerOpen:p,viewerIndex:m,handleActivate:h,closeViewer:g}=Ut(l),_=e===`composer`&&!!u;if(f.length===0)return null;let v=f.map(e=>({src:e.src,filename:e.filename??Z(e.src)}));return(0,o.jsxs)(st,{variant:d,text:s,groupPosition:c,"data-testid":`pdf-attachment`,children:[(0,o.jsx)(`div`,{className:`flex flex-col gap-2`,children:f.map((t,n)=>{let r=t.filename??Z(t.src),i=_&&n===0?(0,o.jsx)(ct,{onClick:u,variant:`inline`}):e===`composer`?void 0:(0,o.jsx)(jt,{url:t.src,filename:r,variant:`inline`,label:`Download ${r}`,tone:d});return(0,o.jsx)(en,{variant:d,item:t,index:n,onActivate:h,trailingAction:i},`${t.src}-${n}`)})}),(0,o.jsx)(Zt,{open:p,items:v,initialIndex:m,onClose:g})]})},nn={Composer:e=>(0,o.jsx)(tn,{...e,state:`composer`}),Sent:e=>(0,o.jsx)(tn,{...e,state:`sent`}),Received:e=>(0,o.jsx)(tn,{...e,state:`received`})},rn=150,an=({open:e,items:r,initialIndex:i=0,onClose:s})=>{let{index:c,prev:l,next:u}=Nt({length:r.length,initialIndex:i,open:e}),d=(0,n.useRef)(null),f=(0,a.useActiveAudioPlayer)();(0,n.useEffect)(()=>{e&&(f?.pause(),t.o(d.current))},[e,f]);let[p,m]=(0,n.useState)(e);e&&!p&&m(!0),(0,n.useEffect)(()=>{if(e||!p)return;d.current?.pause();let t=window.setTimeout(()=>m(!1),rn);return()=>window.clearTimeout(t)},[e,p]);let h=r[c],g=(0,n.useMemo)(()=>h?.filename??(h?Z(h.src):`video`),[h]);return h?(0,o.jsxs)(Pt,{open:e,onClose:s,ariaLabel:g,counter:r.length>1?`${c+1} / ${r.length}`:void 0,"data-testid":`video-viewer`,children:[p?(0,o.jsx)(`video`,{ref:d,"data-testid":`video-viewer-media`,src:h.src,poster:h.poster,controls:!0,autoPlay:!0,muted:!0,playsInline:!0,preload:h.preload??`metadata`,className:`block h-auto max-h-[calc(100dvh-128px)] w-auto max-w-[min(96vw,1400px)] bg-black`,children:h.mimeType?(0,o.jsx)(`source`,{src:h.src,type:h.mimeType}):null},`${c}:${h.src}`):null,r.length>1?(0,o.jsx)(At,{onPrev:l,onNext:u,prevLabel:`Previous video`,nextLabel:`Next video`}):null]}):null},on=1,sn=4/5,cn=16/9,ln=()=>(0,o.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:(0,o.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-full bg-black/25 text-white backdrop-blur-[20px]`,children:(0,o.jsx)(l.PlayIcon,{className:`size-6`,weight:`fill`,"aria-hidden":!0})})}),un=({item:e,index:t,showPlayBadge:n=!0,imgRef:r,onLoad:i})=>(0,o.jsxs)(`div`,{className:`absolute inset-0 size-full bg-[#0d0d0d]`,children:[e.poster?(0,o.jsx)(`img`,{ref:r,src:e.poster,alt:`Video ${t+1} thumbnail`,draggable:!1,loading:`lazy`,decoding:`async`,onLoad:i,className:`absolute inset-0 size-full object-cover`}):(0,o.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,o.jsx)(l.VideoCameraIcon,{className:`size-16 text-white/30`,weight:`regular`,"aria-hidden":!0})}),n?(0,o.jsx)(ln,{}):null]}),dn=({item:e,index:t,totalCount:n,isOverflowTile:r,imgRef:i,onLoad:a})=>({ariaLabel:`Play video ${t+1} of ${n}`,cursorClassName:`cursor-pointer`,content:(0,o.jsx)(un,{item:e,index:t,showPlayBadge:!r,imgRef:i,onLoad:a})}),fn=({src:e,poster:t,mimeType:n,preload:r,naturalAspectRatio:i,items:a})=>a&&a.length>0?r?a.map(e=>({...e,preload:e.preload??r})):a:e?[{src:e,poster:t,mimeType:n,preload:r,naturalAspectRatio:i}]:[],pn=(e,t)=>e.map((n,r)=>({src:n.src,poster:n.poster,mimeType:n.mimeType,preload:n.preload,filename:t&&e.length===1?t:t?`${t} (${r+1})`:void 0})),mn=({src:e,poster:t,mimeType:n,filename:r,preload:i,onClick:a,onDismiss:s})=>{let{viewerOpen:c,viewerIndex:l,handleActivate:u,closeViewer:d}=Ut(a);return(0,o.jsxs)(`div`,{className:`relative w-fit`,children:[(0,o.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:(0,o.jsx)(un,{item:{src:e,poster:t,mimeType:n},index:0})}),s?(0,o.jsx)(`div`,{className:`absolute right-2 top-2 z-10`,children:(0,o.jsx)(ct,{onClick:s})}):null,(0,o.jsx)(an,{open:c,items:pn([{src:e,poster:t,mimeType:n,preload:i}],r),initialIndex:l,onClose:d})]})},hn=({state:e,src:t,poster:n,mimeType:r,filename:i,items:a,text:s,groupPosition:c,preload:l,naturalAspectRatio:u,onClick:d})=>{let f=fn({src:t,poster:n,mimeType:r,preload:l,naturalAspectRatio:u,items:a}),p=lt(e),{viewerOpen:m,viewerIndex:h,handleActivate:g,closeViewer:_}=Ut(d),v=f.length===1,y=v?f[0]:void 0,b=Ht({src:y?.poster,suppliedRatio:y?.naturalAspectRatio,fallbackRatio:on});if(f.length===0)return null;let x=f.length>4?3:-1,S=f.map((e,t)=>dn({item:e,index:t,totalCount:f.length,isOverflowTile:t===x,imgRef:v?b.imgRef:void 0,onLoad:v?b.onLoad:void 0})),C=Math.min(Math.max(b.ratio,sn),cn);return(0,o.jsxs)(st,{variant:p,text:s,groupPosition:c,bordered:!1,widthClassName:v?`w-fit max-w-[313px] sm:max-w-[330px]`:`w-[383px] max-w-full`,paddingClassName:`p-0.5`,radiusClassName:c&&c!==`single`?void 0:`rounded-[20px]`,"data-testid":`video-attachment`,children:[(0,o.jsx)(`div`,{className:`relative`,children:(0,o.jsx)(Vt,{tiles:S,onTileActivate:g,singleAspectRatio:v?C:void 0})}),(0,o.jsx)(an,{open:m,items:pn(f,i),initialIndex:h,onClose:_})]})},Q={Image:Xt,Video:{Composer:e=>(0,o.jsx)(mn,{...e}),Sent:e=>(0,o.jsx)(hn,{...e,state:`sent`}),Received:e=>(0,o.jsx)(hn,{...e,state:`received`})},Audio:mt,Pdf:nn,File:Dt};function $(e){return e?.trim()||void 0}function gn(e){let{original_width:t,original_height:n}=e;if(typeof t==`number`&&typeof n==`number`&&!(!Number.isFinite(t)||!Number.isFinite(n))&&!(t<=0||n<=0))return t/n}function _n(e){return e.trim().replace(/^https?:\/\//i,``).replace(/\/+$/,``).toLowerCase()}function vn(e,t){if(!e?.trim()||!t?.trim())return!1;let n=_n(e),r=_n(t);if(n===r)return!0;if(!n.includes(r))return!1;let i=n.split(r).join(``);return!/[^\p{P}\p{Z}\p{C}]/u.test(i)}function yn(e){let n=$(e.og_scrape_url)??$(e.title_link),r=$(e.image_url)??$(e.thumb_url),i=$(e.mime_type),a=$(e.asset_url),o=r&&X(i,a)?void 0:a;return{title:$(e.title),description:$(e.text),url:n,thumbnailUrl:t.s(r),sourceUrl:o,layout:r||He(i,o)?`featured`:`classic`,mimeType:i,accentColor:$(e.accent_color),status:`ready`}}function bn(e){return V(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`:e.mime_type?.startsWith(`audio/`)?`audio`:`file`:null}function xn(e){if(!e?.length)return[];let t=[],n=(e,n)=>{let r=t[t.length-1];if(r?.type===`media`&&r.kind===e){r.attachments.push(n);return}t.push({type:`media`,kind:e,attachments:[n]})},r=e=>{let n=t[t.length-1];if(n?.type===`link`){n.attachments.push(e);return}t.push({type:`link`,attachments:[e]})};for(let t of e){if(V(t)){r(t);continue}let e=bn(t);e&&n(e,t)}return t}function Sn(e){return e.filter(e=>e.type===`media`).length}function Cn(e,t,n){return t<=1?n:e===0?`first`:e===t-1?`end`:`middle`}function wn(e){return $(e.image_url)??$(e.asset_url)??``}function Tn(e){switch(e){case`image`:return Q.Image;case`video`:return Q.Video;case`audio`:return Q.Audio;case`pdf`:return Q.Pdf;default:return Q.File}}function En(e,n){switch(e){case`image`:return{src:wn(n),alt:$(n.title)};case`video`:return{src:$(n.asset_url)??``,poster:t.s(n.thumb_url),mimeType:$(n.mime_type),naturalAspectRatio:gn(n)};case`audio`:return{src:$(n.asset_url)??``,mimeType:$(n.mime_type)??`audio/mpeg`,filename:$(n.title)};case`pdf`:return{src:$(n.asset_url)??``,filename:$(n.title),fileSize:n.file_size};case`file`:return{src:$(n.asset_url)??``,filename:$(n.title),fileSize:n.file_size,mimeType:$(n.mime_type)??`application/octet-stream`}}}function Dn(e,t){if(t.length>1)return{items:t.map(t=>En(e,t))};let n=t[0];return n?En(e,n):{}}function On({groupPosition:e,isMyMessage:t,segment:n}){let r=Tn(n.kind),i={...Dn(n.kind,n.attachments),groupPosition:e};return t?(0,o.jsx)(r.Sent,{...i}):(0,o.jsx)(r.Received,{...i})}var kn=({groupPosition:e,isMyMessage:t,message:n,renderText:r})=>{let i=xn(n.attachments);if(i.length===0)return null;let s=Sn(i),l=n.text?.trim(),u=i.find(e=>e.type===`link`),d=u?.type===`link`?yn(u.attachments[0]??{}).url:void 0,f=l&&vn(l,d)?void 0:l,p=0,m=[],h=f?`middle`:e,g=e===`single`||e===`end`,_=(e,n,r)=>{let i=t?tt.Sent:tt.Received;m.push((0,o.jsx)(i,{...yn(e),groupPosition:r?h:`middle`},n))},v=(n,r)=>{let i=Cn(p,s,e);p+=1,m.push((0,o.jsx)(On,{groupPosition:i,isMyMessage:t,segment:n},r))};return i.forEach((e,t)=>{let n=t===i.length-1;if(e.type===`link`){e.attachments.forEach((r,i)=>{_(r,`link-${t}-${i}`,n&&i===e.attachments.length-1)});return}v(e,`media-${t}`)}),(0,o.jsxs)(`div`,{className:`str-chat__message-bubble-wrapper`,children:[(0,o.jsxs)(`div`,{className:`str-chat__message-bubble`,"data-attachment-bubble":`true`,"data-testid":`message-attachment-bubble`,style:{background:`transparent`,borderRadius:0,overflow:`visible`,padding:0},children:[(0,o.jsx)(`div`,{"data-testid":`message-attachment-rows`,className:(0,c.default)(`flex flex-col gap-[4px]`,t?`items-end`:`items-start`),children:m}),!f&&(0,o.jsx)(a.MessageErrorIcon,{})]}),f?(0,o.jsxs)(`div`,{"data-testid":`message-caption-bubble`,className:(0,c.default)(`str-chat__message-bubble`,{"relative isolate":g}),children:[(0,o.jsx)(a.MessageText,{message:n,renderText:r}),(0,o.jsx)(a.MessageErrorIcon,{}),g&&(0,o.jsx)(ge,{side:t?`me`:`other`})]}):null]})},An=n.default.memo(e=>{let{additionalMessageInputProps:t,editing:r,endOfGroup:i,firstOfGroup:s,groupStyles:l,groupedByUser:u,handleAction:d,handleOpenThread:f,handleRetry:p,highlighted:m,isMessageAIGenerated:h,isMyMessage:g,message:_,renderText:v,threadList:y,viewerLanguage:b,onOutboundClick:x,resolvedOutbound:S}=e,{client:C}=(0,a.useChatContext)(`CustomMessage`),{channel:w}=(0,a.useChannelStateContext)(`CustomMessage`),{isUnlocking:T,onUnlockClick:E,onFetchSource:D,onDownloadClick:O}=ie(`LockedAttachment`),[k,A]=(0,n.useState)(!1),M=(0,a.useMessageReminder)(_.id),{Attachment:N=a.Attachment,EditMessageModal:P=a.EditMessageModal,MessageActions:F,MessageBlocked:I=a.MessageBlocked,MessageBouncePrompt:L=a.MessageBouncePrompt,MessageDeleted:R=a.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:ee=a.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:te=a.MessageRepliesCountButton,ReminderNotification:z=a.ReminderNotification,StreamedMessageText:ne=a.StreamedMessageText,PinIndicator:H}=(0,a.useComponentContext)(`CustomMessage`),re=(0,a.messageHasAttachments)(_),ae=(0,a.messageHasReactions)(_),oe=(0,n.useMemo)(()=>h?.(_),[h,_]),U=(0,n.useMemo)(()=>{let e=_.attachments??[],t=_.shared_location?[_.shared_location,...e]:e;if(!le(_))return t;let n=t.filter(e=>!(`type`in e)||!V(e));return n.length===t.length?t:n},[_]),ce=(0,n.useMemo)(()=>xn(U),[U]),W=(0,n.useMemo)(()=>{let e=B({message:_,viewerLanguage:b});return e===_.text?_:{..._,text:e}},[_,b]),pe=ce.length>0,he=ce.reduce((e,t)=>e+t.attachments.length,0)===(U?.length??0),G=l?.[0]??``,_e=G===`top`?`first`:G===`middle`?`middle`:G===`bottom`?`end`:`single`,K=G===`single`||G===`bottom`;if((0,a.isDateSeparatorMessage)(_))return null;if(_.deleted_at||_.type===`deleted`)return(0,o.jsx)(R,{message:_});if((0,a.isMessageBlocked)(_))return(0,o.jsx)(I,{});let ve=!y&&!!_.reply_count,ye=!y&&_.show_in_channel&&_.parent_id,be=_.status===`failed`&&_.error?.status!==403,Ce=(0,a.isMessageBounced)(_),q;be?q=()=>p(_):Ce&&(q=()=>A(!0));let J=g(),we=(0,c.default)(`str-chat__message str-chat__message-simple`,`str-chat__message--${_.type}`,`str-chat__message--${_.status}`,J?`str-chat__message--me str-chat__message-simple--me`:`str-chat__message--other`,_.text?`str-chat__message--has-text`:`has-no-text`,{"str-chat__message--has-attachment":re,"str-chat__message--highlighted":m,"str-chat__message--pinned pinned-message":_.pinned,"str-chat__message--with-reactions":ae,"str-chat__message-send-can-be-retried":_?.status===`failed`&&_?.error?.status!==403,"str-chat__message-with-thread-link":ve||ye,"str-chat__virtual-message__wrapper--end":i,"str-chat__virtual-message__wrapper--first":s,"str-chat__virtual-message__wrapper--group":u}),Te=_.poll_id&&C.polls.fromState(_.poll_id),De=xe(_),Y=le(_),Oe=ue(_),ke=!!(U?.length&&!_.quoted_message),Ae=Y&&J&&ke,je=pe&&he&&!_.quoted_message&&!Te&&!oe&&!Y,Me={contentType:`text`,amountText:_.metadata?.amount_text,paymentStatus:_.metadata?.payment_status,renderedText:_.text&&(0,o.jsx)(a.MessageText,{message:W,renderText:v})},Ne={contentType:`media`,title:_.metadata?.attachment_title,mimeType:_.metadata?.attachment_mime_type,thumbnailUrl:_.metadata?.attachment_thumbnail,amountText:_.metadata?.amount_text,detail:_.metadata?.attachment_detail,paymentStatus:_.metadata?.payment_status,onFetchSource:D?()=>D(_,w):void 0},Pe=(0,o.jsxs)(`div`,{className:(0,c.default)(`str-chat__message-bubble`,{"relative isolate":K}),children:[(0,o.jsx)(a.MessageText,{message:W,renderText:v}),K&&(0,o.jsx)(ge,{side:J?`me`:`other`})]});return(0,o.jsxs)(o.Fragment,{children:[r&&(0,o.jsx)(P,{additionalMessageInputProps:t}),k&&(0,o.jsx)(a.MessageBounceModal,{MessageBouncePrompt:L,onClose:()=>A(!1),open:k}),(0,o.jsxs)(`div`,{className:we,"data-message-id":_.id,"data-dd-privacy":`mask`,children:[H&&(0,o.jsx)(H,{}),!!M&&(0,o.jsx)(z,{reminder:M}),_.user&&(0,o.jsx)(j,{className:`str-chat__avatar str-chat__message-sender-avatar`,id:_.user.id,image:_.user.image,name:_.user.name||_.user.id,size:24,shape:`circle`,dmAgentEnabled:Y}),(0,o.jsx)(`div`,{className:(0,c.default)(`str-chat__message-inner`,{"str-chat__simple-message--error-failed":be||Ce}),"data-testid":`message-inner`,onClick:q,onKeyDown:q,role:q?`button`:void 0,tabIndex:q?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:De?(0,o.jsxs)(`div`,{className:`str-chat__message-bubble-wrapper message-tip-wrapper`,children:[(0,o.jsx)(Se,{message:_}),_.text?.trim()&&Pe]}):de(_)?(0,o.jsx)(`div`,{className:`str-chat__message-bubble-wrapper`,children:(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[J&&F&&(0,o.jsx)(F,{}),J?(0,o.jsx)(se,{...Me,isMine:!0}):(0,o.jsx)(se,{...Me,isMine:!1,isUnlocking:T(_.id),onUnlockClick:()=>E?.(_,w)}),!J&&F&&(0,o.jsx)(F,{})]})}):fe(_)?(0,o.jsxs)(`div`,{className:`str-chat__message-bubble-wrapper message-locked-attachment-wrapper`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[J&&F&&(0,o.jsx)(F,{}),J?(0,o.jsx)(se,{...Ne,isMine:!0,onPreviewClick:()=>E?E(_,w):void 0}):(0,o.jsx)(se,{...Ne,isMine:!1,isUnlocking:T(_.id),onUnlockClick:()=>E?E(_,w):void 0,onDownloadClick:()=>O?O(_,w):void 0}),!J&&F&&(0,o.jsx)(F,{})]}),_.text&&Pe]}):je?(0,o.jsx)(kn,{groupPosition:_e,isMyMessage:J,message:{...W,attachments:U,i18n:void 0},renderText:v}):(0,o.jsx)(`div`,{className:`str-chat__message-bubble-wrapper`,children:(0,o.jsxs)(`div`,{className:(0,c.default)(`str-chat__message-bubble`,{"relative isolate":K}),children:[Y&&!Ae&&(0,o.jsx)(me,{message:_,hasAttachment:ke,isMyMessage:J}),Te&&(0,o.jsx)(a.Poll,{poll:Te}),U?.length&&!_.quoted_message?(0,o.jsx)(N,{actionHandler:d,attachments:U}):null,oe?(0,o.jsx)(ne,{message:W,renderText:v}):(0,o.jsx)(a.MessageText,{message:W,renderText:v}),(0,o.jsx)(a.MessageErrorIcon,{}),K&&(0,o.jsx)(ge,{side:J?`me`:`other`})]})})}),!Oe&&!De&&(0,o.jsx)(`div`,{className:`str-chat__message-footer`,children:(!Y||Ae)&&(0,o.jsx)(me,{message:_,hasAttachment:ke,isMyMessage:J})}),(0,o.jsx)(Ee,{onOutboundClick:x,resolvedOutbound:S}),ve&&(0,o.jsx)(te,{onClick:f,reply_count:_.reply_count}),ye&&(0,o.jsx)(ee,{})]},_.id)]})},(e,t)=>e.viewerLanguage!==t.viewerLanguage||e.onOutboundClick!==t.onOutboundClick||e.resolvedOutbound?.id!==t.resolvedOutbound?.id||e.resolvedOutbound?.name!==t.resolvedOutbound?.name?!1:(0,a.areMessageUIPropsEqual)(e,t)),jn=e=>{let t=(0,a.useMessageContext)(`CustomMessage`),r=(0,n.useContext)(_e),i=t.message.metadata?.outbound_id,s=typeof i==`string`?r?.[i]:void 0;return(0,o.jsx)(An,{...t,...e,resolvedOutbound:s})},Mn=()=>{let{handleDelete:e,message:t}=(0,a.useMessageContext)(`CustomMessageActions`);return t.metadata?.payment_status===`paid`?null:(0,o.jsx)(u.DefaultDropdownActionButton,{onClick:e,"aria-label":`Delete`,title:`Delete`,className:`bg-marble rounded-full p-2 hover:bg-sand transition-all`,children:(0,o.jsx)(l.TrashSimpleIcon,{size:16,weight:`light`,"aria-hidden":!0})})},Nn=()=>{let{handleFlag:e}=(0,a.useMessageContext)(`CustomMessageActions`);return(0,o.jsx)(u.DefaultDropdownActionButton,{onClick:e,"aria-label":`Report`,title:`Report`,className:`bg-marble rounded-full p-2 hover:bg-sand transition-all`,children:(0,o.jsx)(l.FlagIcon,{size:16,weight:`light`,"aria-hidden":!0})})},Pn=()=>{let{message:e}=(0,a.useMessageContext)(`CustomMessageActions`);return e.metadata?.custom_type===s.MESSAGE_CUSTOM_TYPE.ATTACHMENT?(0,o.jsx)(u.MessageActions,{messageActionSet:[{Component:Mn,placement:`quick`,type:`delete`},{Component:Nn,placement:`quick`,type:`flag`}]}):null},Fn=e=>({linkPreviews:Array.from(e.previews.values()).filter(e=>i.LinkPreviewsManager.previewIsLoaded(e)||i.LinkPreviewsManager.previewIsLoading(e))}),In=()=>{let{linkPreviewsManager:e}=(0,a.useMessageComposer)(),{linkPreviews:t}=(0,a.useStateStore)(e.state,Fn),n=t=>{e.dismissPreview(t)};return t.length>0?(0,o.jsx)(`div`,{"data-testid":`link-preview-list`,className:`messaging-link-preview-list flex flex-col items-stretch w-full gap-2`,children:t.map(e=>{let t=i.LinkPreviewsManager.previewIsLoading(e);return(0,o.jsx)(tt.Composer,{title:e.title,url:e.og_scrape_url,thumbnailUrl:e.image_url,layout:t||e.image_url?`featured`:`classic`,status:t?`loading`:`ready`,onDismiss:()=>n(e.og_scrape_url)},e.og_scrape_url)})}):null},Ln=n.default.createContext(!1),Rn=200,zn=()=>(0,n.useContext)(Ln),Bn=({sendMessage:e,disabled:t,...n})=>(0,o.jsx)(`button`,{...n,type:`button`,"aria-label":`Send`,disabled:t,onPointerDown:e=>e.preventDefault(),onClick:e,children:(0,o.jsx)(l.ArrowUpIcon,{weight:`bold`,className:`size-4`})}),Vn=()=>{let e=(0,n.useContext)(Ln),{handleSubmit:t}=(0,a.useMessageInputContext)(),r=(0,a.useMessageComposerHasSendableData)(),i=e||!r,{SendButton:s=Bn,AttachmentPreviewList:c=a.AttachmentPreviewList}=(0,a.useComponentContext)(`CustomMessageInput`),l=n.default.useRef(null);return n.default.useEffect(()=>{let e=l.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{e.contains(document.activeElement)&&(e.scrollTop=e.scrollHeight)});return t.observe(e),()=>t.disconnect()},[]),n.default.useEffect(()=>{let e=l.current;if(!e)return;let t=e=>{Array.from(e.clipboardData?.items??[]).some(e=>e.kind===`file`)||e.stopPropagation()};return e.addEventListener(`paste`,t),()=>e.removeEventListener(`paste`,t)},[]),(0,o.jsxs)(`div`,{ref:l,"data-testid":`composer-card`,className:`central-container flex flex-col min-w-0 w-full max-h-[calc(var(--messaging-surface-height,100dvh)*0.5)] overflow-y-auto overscroll-contain bg-white rounded-[1.5rem] shadow-[0_4px_16px_0_rgba(0,0,0,0.08),0_1px_2px_0_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.04)] [&>:not(.messaging-composer-previews):not(.messaging-composer-row)]:p-2`,"data-dd-privacy":`mask`,children:[(0,o.jsxs)(`div`,{"data-testid":`composer-previews`,className:`messaging-composer-previews empty:hidden flex flex-col gap-2 px-2 pt-2`,children:[(0,o.jsx)(a.QuotedMessagePreview,{}),(0,o.jsx)(In,{}),(0,o.jsx)(c,{})]}),(0,o.jsxs)(`div`,{"data-testid":`composer-row`,className:`messaging-composer-row flex items-start`,children:[(0,o.jsx)(a.TextareaComposer,{"aria-disabled":e||void 0,containerClassName:`min-w-0 flex-1 leading-[0]`,className:`w-full resize-none overflow-hidden bg-transparent py-3.5 pl-4 pr-4 outline-none leading-5 placeholder:text-black/30 text-sm`,autoFocus:!e,enterKeyHint:`send`,maxRows:1/0,readOnly:e,tabIndex:e?-1:void 0}),(0,o.jsx)(`div`,{"data-testid":`send-button-wrapper`,className:`sticky bottom-2 mt-auto mb-2 mr-2 shrink-0 pt-2`,children:(0,o.jsx)(s,{sendMessage:t,"aria-label":`Send`,className:`str-chat__send-button relative flex justify-center items-center rounded-full size-8 bg-[#121110] disabled:bg-[#F1F0EE] disabled:text-black/20 text-white focus-ring before:absolute before:-inset-2 before:content-['']`,"data-testid":`send-button`,disabled:i,type:`button`})})]})]})},Hn=()=>(0,o.jsxs)(`div`,{className:`messaging-composer-backdrop`,"aria-hidden":`true`,children:[(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-blur`}),(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-blur`}),(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-blur`}),(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-blur`}),(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-blur`}),(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-gradient`})]}),Un=({renderActions:e,renderHeader:t,renderFooter:r,disabled:i=!1,disabledReason:s,composerInput:c})=>{let{channel:l}=(0,a.useChannelStateContext)(),u=l?.data?.frozen===!0,d=!!c,f=n.default.useRef(null);return n.default.useEffect(()=>{if(!d)return;let e=f.current,t=e?.parentElement;if(!e||!t)return;let n=e.offsetHeight,r=()=>{let r=e.offsetHeight,i=r>n;n=r;let a=Array.from(t.querySelectorAll(`.str-chat__list`)).find(e=>e.scrollHeight>e.clientHeight)??null,o=a?a.scrollHeight-a.scrollTop-a.clientHeight<Rn:!1;t.style.setProperty(`--messaging-composer-height`,`${r}px`),i&&o&&a&&(a.scrollTop=a.scrollHeight)};if(r(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(r);return i.observe(e),()=>{i.disconnect(),t.style.removeProperty(`--messaging-composer-height`)}},[d]),i?d?(0,o.jsxs)(`div`,{ref:f,"data-testid":`composer-chrome`,className:`messaging-composer-chrome messaging-composer-chrome--floating`,children:[(0,o.jsx)(Hn,{}),(0,o.jsxs)(`div`,{className:`relative z-10 flex flex-col`,children:[t?.(),(0,o.jsx)(`div`,{"data-testid":`composer-locked-panel`,className:`messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4`,children:s?(0,o.jsx)(`p`,{className:`max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40`,children:s}):null}),r?.()]})]}):(0,o.jsxs)(o.Fragment,{children:[t?.(),(0,o.jsx)(`div`,{"data-testid":`composer-locked-panel`,className:`messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4`,children:s?(0,o.jsx)(`p`,{className:`max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40`,children:s}):null}),r?.()]}):d?(0,o.jsxs)(`div`,{ref:f,"data-testid":`composer-chrome`,className:`messaging-composer-chrome messaging-composer-chrome--floating`,children:[(0,o.jsx)(Hn,{}),(0,o.jsxs)(`div`,{className:`relative z-10 flex min-h-0 flex-col`,children:[t?.(),(0,o.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-4 p-3 pb-5 md:p-5`,children:[(0,o.jsxs)(`div`,{inert:u?``:void 0,"aria-disabled":u||void 0,"data-testid":`message-input`,className:`message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40`,children:[e&&(0,o.jsx)(`div`,{className:`flex h-12 shrink-0 items-center justify-center`,children:e()}),(0,o.jsx)(Ln.Provider,{value:u,children:(0,o.jsx)(a.MessageInput,{Input:c??Vn})})]}),r?.()]})]})]}):(0,o.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-4 p-4`,children:[t?.(),(0,o.jsxs)(`div`,{inert:u?``:void 0,"aria-disabled":u||void 0,"data-testid":`message-input`,className:`message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40`,children:[e&&(0,o.jsx)(`div`,{className:`flex h-12 shrink-0 items-center justify-center`,children:e()}),(0,o.jsx)(Ln.Provider,{value:u,children:(0,o.jsx)(a.MessageInput,{Input:Vn})})]}),r?.()]})},Wn={SYSTEM_DM_AGENT_PAUSED:`DM Agent has left the conversation`,SYSTEM_DM_AGENT_RESUMED:`DM Agent has rejoined the conversation`},Gn=[`SYSTEM_AGE_SAFETY_BLOCKED`],Kn={SYSTEM_AGE_SAFETY_BLOCKED:`This user isnβt able to reply because they donβt meet our age safety guidelines.`},qn=`age safety guidelines.`,Jn=`https://linktr.ee/s/about/contact`,Yn=e=>Gn.includes(e),Xn=e=>Yn(e.metadata?.custom_type),Zn=e=>{let t=e.metadata?.custom_type;if((0,s.isDmAgentSystemType)(t))return{kind:`dm-agent`,type:t};if((0,s.isAgeSafetySystemType)(t))return{kind:`age-safety`,type:t};let n=e.dm_agent_system_type;if((0,s.isDmAgentSystemType)(n))return{kind:`dm-agent`,type:n}},Qn=e=>{let t=e.indexOf(qn);if(t===-1)return e;let n=t+22;return(0,o.jsxs)(o.Fragment,{children:[e.slice(0,t),(0,o.jsx)(`a`,{href:Jn,target:`_blank`,rel:`noopener noreferrer`,className:`mes-age-safety-system-message__emphasis font-medium text-inherit underline`,children:qn}),e.slice(n)]})},$n=e=>{let t=!Xn(e.message),n=Zn(e.message);if(n?.kind===`dm-agent`){let r=e.message.text?.trim()||Wn[n.type];return(0,o.jsxs)(`div`,{className:`str-chat__message--system`,"data-testid":`message-system`,children:[(0,o.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:[(0,o.jsx)(l.SparkleIcon,{size:16,weight:`regular`,"aria-hidden":!0,className:`mes-dm-agent-system-message__sparkle shrink-0`}),(0,o.jsx)(`p`,{className:`mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]`,children:r})]}),!t&&(0,o.jsx)(a.MessageTimestamp,{message:e.message})]})}if(n?.kind===`age-safety`){let r=e.message.text?.trim()||Kn[n.type];return(0,o.jsxs)(`div`,{className:`str-chat__message--system`,"data-testid":`message-system`,children:[(0,o.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:[(0,o.jsx)(l.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`}),(0,o.jsx)(`div`,{className:`mes-age-safety-system-message__content min-w-0 flex-[1_0_0]`,children:(0,o.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:Qn(r)})})]}),!t&&(0,o.jsx)(a.MessageTimestamp,{message:e.message})]})}return(0,o.jsxs)(`div`,{className:`str-chat__message--system`,"data-testid":`message-system`,children:[(0,o.jsxs)(`div`,{className:`str-chat__message--system__text`,children:[(0,o.jsx)(`div`,{className:`str-chat__message--system__line`}),(0,o.jsx)(`p`,{children:e.message.text}),(0,o.jsx)(`div`,{className:`str-chat__message--system__line`})]}),!t&&(0,o.jsx)(a.MessageTimestamp,{message:e.message})]})},er=(0,n.createContext)(!1),tr=({cx:e,index:t})=>(0,o.jsx)(`circle`,{cx:e,cy:`6.15`,r:`3.9`,fill:`#A0A0A0`,children:(0,o.jsx)(`animateTransform`,{attributeName:`transform`,type:`translate`,values:`0 0; 0 -2.25; 0 0;`,dur:`900ms`,begin:`${120*t}ms`,repeatCount:`indefinite`})}),nr=new Set([a.AIStates.Thinking,a.AIStates.Generating,a.AIStates.ExternalSources]),rr=({threadList:e})=>{let{channel:t,channelConfig:r,thread:i}=(0,a.useChannelStateContext)(),{client:s}=(0,a.useChatContext)(),{typing:c={}}=(0,a.useTypingContext)(),{aiState:l}=(0,a.useAIState)(t),u=(0,n.useContext)(er);if(!e&&u&&nr.has(l)){let e=ar(t,s.user?.id);return(0,o.jsx)(ir,{avatarId:e?.id??`ai-agent`,avatarName:e?.name??e?.id??`Agent`,avatarImage:e?.image,testId:`typing-indicator-ai`})}if(r?.typing_events===!1)return null;let d=e?[]:Object.values(c).filter(({parent_id:e,user:t})=>t?.id!==s.user?.id&&!e),f=e?Object.values(c).filter(({parent_id:e,user:t})=>t?.id!==s.user?.id&&e===i?.id):[],p=e?f:d;if(!p.length)return null;let m=p[0]?.user,h=m?.id&&t.state.members[m.id]?t.state.members[m.id].user:void 0;return(0,o.jsx)(ir,{avatarId:m?.id??h?.id??`typing-user`,avatarName:m?.name??h?.name??m?.id??`Typing user`,avatarImage:m?.image??h?.image,testId:`typing-indicator`})},ir=({avatarId:e,avatarName:t,avatarImage:n,testId:r})=>(0,o.jsx)(`div`,{className:`str-chat__li str-chat__li--single str-chat__typing-indicator !static`,"data-testid":r,style:{marginBottom:`var(--messaging-channel-input-spacer-height, 80px)`},children:(0,o.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:[(0,o.jsx)(j,{className:`str-chat__avatar str-chat__message-sender-avatar`,id:e,name:t,image:n??void 0,size:24,shape:`circle`}),(0,o.jsx)(`div`,{className:`str-chat__message-inner mx-0`,children:(0,o.jsx)(`div`,{className:`str-chat__message-bubble-wrapper`,children:(0,o.jsxs)(`div`,{className:`str-chat__message-bubble relative isolate`,children:[(0,o.jsx)(`div`,{className:`str-chat__message-text min-h-11 flex items-center`,children:(0,o.jsx)(`div`,{className:`str-chat__message-text-inner str-chat__message-simple-text-inner`,children:(0,o.jsxs)(`svg`,{"aria-hidden":`true`,className:`block overflow-visible`,viewBox:`0 0 32 12.3`,width:`32`,height:`13`,overflow:`visible`,children:[(0,o.jsx)(tr,{cx:`4`,index:0}),(0,o.jsx)(tr,{cx:`16`,index:1}),(0,o.jsx)(tr,{cx:`28`,index:2})]})})}),(0,o.jsx)(ge,{side:`other`})]})})})]})});function ar(e,t){let n=e?.state?.members??{};for(let e of Object.values(n)){let n=e?.user;if(n&&n.id!==t)return n}}var or=()=>null,sr=({className:e,message:t})=>(0,o.jsxs)(`div`,{className:(0,c.default)(`flex items-center justify-center h-full`,e),children:[(0,o.jsxs)(`svg`,{viewBox:`0 0 100 100`,className:`size-8 fill-pebble`,stroke:`none`,children:[(0,o.jsx)(`circle`,{cx:`6`,cy:`50`,r:`6`,children:(0,o.jsx)(`animateTransform`,{attributeName:`transform`,dur:`1s`,type:`translate`,values:`0 15 ; 0 -15; 0 15`,repeatCount:`indefinite`,begin:`0.1`})}),(0,o.jsx)(`circle`,{cx:`30`,cy:`50`,r:`6`,children:(0,o.jsx)(`animateTransform`,{attributeName:`transform`,dur:`1s`,type:`translate`,values:`0 10 ; 0 -10; 0 10`,repeatCount:`indefinite`,begin:`0.2`})}),(0,o.jsx)(`circle`,{cx:`54`,cy:`50`,r:`6`,children:(0,o.jsx)(`animateTransform`,{attributeName:`transform`,dur:`1s`,type:`translate`,values:`0 5 ; 0 -5; 0 5`,repeatCount:`indefinite`,begin:`0.3`})})]}),t&&(0,o.jsx)(`span`,{className:`text-stone`,children:t})]}),cr=n.default.memo(()=>(0,o.jsx)(`div`,{className:`messaging-loading-state flex items-center justify-center h-full`,children:(0,o.jsxs)(`div`,{className:`flex items-center`,children:[(0,o.jsx)(sr,{className:`w-6 h-6`}),(0,o.jsx)(`span`,{className:`text-sm text-stone`,children:`Loading messages`})]})}));cr.displayName=`LoadingState`;var lr=({onBack:e,showBackButton:t,renderMessageInputActions:r,renderMessageInputFooter:i,renderConversationFooter:s,onLeaveConversation:c,onBlockParticipant:l,showDeleteConversation:u=!0,onDeleteConversationClick:d,onBlockParticipantClick:f,onReportParticipantClick:p,showBlockParticipant:m=!0,showReportParticipant:h=!0,composerDisabled:g=!1,composerDisabledReason:_,showStarButton:v=!1,renderChannelBanner:y,customChannelActions:b,renderChannelActions:x,renderMessage:S,viewerLanguage:C,showChannelInfo:w=!0,onParticipantNameClick:T,onOutboundClick:E,resolveOutbound:D,composerInput:O})=>{let{channel:k,messages:A}=(0,a.useChannelStateContext)(),j=(0,n.useRef)(E);(0,n.useEffect)(()=>{j.current=E},[E]);let M=(0,n.useCallback)(e=>{j.current?.(e)},[]),N=E?M:void 0,P=be(A,D),F=k.state.messages.some(e=>e.type!==`deleted`),I=y?(0,o.jsx)(n.default.Fragment,{children:y()},`lt-channel-banner`):null,L=(0,o.jsx)(ee,{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:t,showChannelInfo:w,showStarButton:v,onLeaveConversation:c,onBlockParticipant:l,showDeleteConversation:u,showBlockParticipant:m,showReportParticipant:h,onDeleteConversationClick:d,onBlockParticipantClick:f,onReportParticipantClick:p,customChannelActions:b,renderChannelActions:x,onParticipantNameClick:T}),R=(0,n.useCallback)(e=>{let{message:t}=(0,a.useMessageContext)(`ChannelView`),n=(0,o.jsx)(jn,{...e,viewerLanguage:C,onOutboundClick:N});return!S||!t?n:S(n,t)},[N,S,C]);return(0,o.jsx)(_e.Provider,{value:P,children:(0,o.jsx)(a.WithComponents,{overrides:{Message:R,MessageActions:Pn,UnreadMessagesNotification:()=>null,UnreadMessagesSeparator:()=>null},children:(0,o.jsx)(a.Window,{children:O?(0,o.jsxs)(`div`,{className:`messaging-channel-layout relative flex min-h-0 flex-1 flex-col`,children:[(0,o.jsxs)(`div`,{className:`messaging-channel-message-list messaging-channel-message-list--floating relative min-h-0 flex-1 overflow-hidden`,children:[!F&&(0,o.jsx)(`div`,{className:`str-chat__list`,children:(0,o.jsxs)(`div`,{className:`str-chat__message-list-scroll`,children:[L,I]})}),(0,o.jsx)(a.MessageList,{head:F?(0,o.jsxs)(`div`,{className:`sticky top-0 z-10`,children:[L,I]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},`lt-channel-message-list`),(0,o.jsx)(Un,{...r&&{renderActions:()=>r?.(k)},...s&&{renderHeader:()=>s(k)},renderFooter:()=>i?.(k),disabled:g,disabledReason:_,composerInput:O},`lt-channel-message-input`)]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`flex-1 overflow-hidden relative`,children:[!F&&(0,o.jsx)(`div`,{className:`str-chat__list`,children:(0,o.jsxs)(`div`,{className:`str-chat__message-list-scroll`,children:[L,I]})}),(0,o.jsx)(a.MessageList,{head:F?(0,o.jsxs)(`div`,{className:`sticky top-0 z-10`,children:[L,I]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},`lt-channel-message-list`),s?(0,o.jsx)(n.default.Fragment,{children:s(k)},`lt-channel-conversation-footer`):null,(0,o.jsx)(Un,{...r&&{renderActions:()=>r?.(k)},renderFooter:()=>i?.(k),disabled:g,disabledReason:_,composerInput:O},`lt-channel-message-input`)]})})})})},ur=n.default.memo(({channel:e,onBack:t,showBackButton:r=!1,renderMessageInputActions:i,renderMessageInputFooter:l,renderConversationFooter:u,onLeaveConversation:d,onBlockParticipant:f,className:p,CustomChannelEmptyState:m=or,showDeleteConversation:h=!0,onDeleteConversationClick:g,onBlockParticipantClick:_,onReportParticipantClick:v,showBlockParticipant:y=!0,showReportParticipant:b=!0,composerDisabled:x=!1,composerDisabledReason:S,dmAgentEnabled:C,messageMetadata:w,onMessageSent:T,showStarButton:E=!1,renderChannelBanner:D,customChannelActions:O,renderChannelActions:k,renderMessage:A,onMessageLinkClick:j,sendButton:M,attachmentPreviewList:N,viewerLanguage:P,showChannelInfo:F=!0,onParticipantNameClick:I,onOutboundClick:L,resolveOutbound:R,composerInput:ee})=>{let z=(0,n.useCallback)(async(t,n,r)=>{let i=e.data?.chatbot_paused===!0,a=C&&!i,o={...n,...a&&{silent:!0},...w&&{metadata:{...n.metadata??{},...w}}},s={...r,...a&&{skip_push:!0}},c=await e.sendMessage(o,s);return T?.(c),c},[e,C,w,T]),B=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!j)return;let t=B.current;if(!t)return;let n=t=>{let n=t.target?.closest(`a[href]`),r=n?.getAttribute(`href`);if(!r)return;let i=(n?.closest(`[data-message-id]`))?.getAttribute(`data-message-id`);j(r,i?e.state.messages.find(e=>e.id===i):void 0)};return t.addEventListener(`click`,n),()=>t.removeEventListener(`click`,n)},[j,e]);let V=(0,s.isOfficialChannel)(e.type)?{"--lt-msg-card-width":`368px`}:void 0;return(0,o.jsx)(`div`,{ref:B,"data-testid":`channel-view`,className:(0,c.default)(`messaging-channel-view h-full flex flex-col`,p),style:V,children:(0,o.jsx)(er.Provider,{value:C??!1,children:(0,o.jsx)(a.Channel,{channel:e,MessageSystem:$n,EmptyStateIndicator:m,LoadingIndicator:cr,DateSeparator:te,TypingIndicator:rr,doSendMessageRequest:z,...M?{SendButton:M}:{},...N?{AttachmentPreviewList:N}:{},children:(0,o.jsx)(lr,{onBack:t,showBackButton:r,renderMessageInputActions:i,renderMessageInputFooter:l,renderConversationFooter:u,onLeaveConversation:d,onBlockParticipant:f,CustomChannelEmptyState:m,showDeleteConversation:h,onDeleteConversationClick:g,onBlockParticipantClick:_,onReportParticipantClick:v,showBlockParticipant:y,showReportParticipant:b,composerDisabled:x,composerDisabledReason:S,showStarButton:E,renderChannelBanner:D,customChannelActions:O,renderChannelActions:k,renderMessage:A,viewerLanguage:P,showChannelInfo:F,onParticipantNameClick:I,onOutboundClick:L,resolveOutbound:R,composerInput:ee})})})})});ur.displayName=`ChannelView`;var dr=n.default.memo(({message:e,onBack:t})=>(0,o.jsx)(`div`,{className:`messaging-error-state flex items-center justify-center h-full p-8`,children:(0,o.jsxs)(`div`,{className:`text-center max-w-sm`,children:[(0,o.jsx)(`div`,{className:`w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6`,children:(0,o.jsx)(`span`,{className:`text-4xl`,children:`β οΈ`})}),(0,o.jsx)(`h2`,{className:`font-semibold text-charcoal mb-2`,children:`Oops!`}),(0,o.jsx)(`p`,{className:`text-stone text-sm mb-6`,children:e}),t&&(0,o.jsx)(`button`,{type:`button`,onClick:t,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`})]})}));dr.displayName=`ErrorState`;var fr=({capabilities:e={},renderMessageInputActions:t,renderConversationFooter:r,onChannelSelect:i,onExitConversation:a,initialParticipantFilter:s,initialParticipantData:c,CustomChannelEmptyState:l,onBlockParticipantClick:u,onReportParticipantClick:d,dmAgentEnabled:f,onMessageSent:p,viewerLanguage:m,renderChannelBanner:h,customChannelActions:g,renderChannelActions:_,onParticipantNameClick:v,onOutboundClick:b,resolveOutbound:x,renderMessage:S,onMessageLinkClick:C,showChannelInfo:w,composerInput:T,attachmentPreviewList:E})=>{let{client:D,isConnected:O,isLoading:k,error:A,refreshConnection:j,service:M,debug:N}=y(),[P,F]=(0,n.useState)(null),[I,L]=(0,n.useState)(null),[R,ee]=(0,n.useState)(!1),{showDeleteConversation:te=!0}=e,z=(0,n.useRef)(c);z.current=c;let B=(0,n.useRef)(i);B.current=i;let V=(0,n.useRef)(null),ne=(0,n.useRef)(null);(0,n.useEffect)(()=>{ne.current=P},[P]),(0,n.useEffect)(()=>{if(!D||!O)return;let e=D.userID;if(!e)return;let t=`${e}::${s}`;if(V.current===t)return;V.current=t;let n=()=>{V.current===t&&(V.current=null)};(async()=>{try{N&&console.log(`[MessagingShell] Loading initial conversation with:`,s);let t=await D.queryChannels({type:`messaging`,members:{$eq:[e,s]}},{},{limit:1});if(t.length>0){F(t[0]),L(null),B.current?.(t[0]),N&&console.log(`[MessagingShell] Initial conversation loaded:`,t[0].id);return}let r=z.current;if(!r||!M){n(),L(`No conversation found with this account`),N&&console.log(`[MessagingShell] No conversation found for:`,s);return}try{let e=await M.startChannelWithParticipant({id:r.id,name:r.name,phone:r.phone});F(e),L(null),B.current?.(e),N&&console.log(`[MessagingShell] Channel created and loaded:`,e.id)}catch(e){console.error(`[MessagingShell] Failed to create conversation:`,e),n(),L(`Failed to create conversation`)}}catch(e){console.error(`[MessagingShell] Failed to load initial conversation:`,e),n(),ne.current||L(`Failed to load conversation`)}})()},[s,D,O,M,N]);let H=(0,n.useRef)(a);H.current=a;let re=(0,n.useCallback)(()=>{F(null),ee(!0),H.current?.()},[]);return k?(0,o.jsx)(cr,{}):A?(0,o.jsx)(dr,{message:A,onBack:j}):!O||!D?(0,o.jsx)(dr,{message:`Not connected to messaging service`,onBack:j}):I?(0,o.jsx)(dr,{message:I}):R&&!P?(0,o.jsx)(dr,{message:`Conversation ended`}):P?(0,o.jsx)(`div`,{className:`messaging-shell h-full bg-background-primary overflow-hidden`,children:(0,o.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:(0,o.jsx)(ur,{channel:P,renderMessageInputActions:t,renderConversationFooter:r,renderChannelBanner:h,onLeaveConversation:re,onBlockParticipant:re,CustomChannelEmptyState:l,showDeleteConversation:te,onBlockParticipantClick:u,onReportParticipantClick:d,dmAgentEnabled:f,onMessageSent:p,viewerLanguage:m,customChannelActions:g,renderChannelActions:_,onParticipantNameClick:v,onOutboundClick:b,resolveOutbound:x,renderMessage:S,onMessageLinkClick:C,showChannelInfo:w,composerInput:T,attachmentPreviewList:E},P.id)})}):(0,o.jsx)(cr,{})};function pr(e){let t=e.state.pending_messages;if(t?.length)for(let n of t)e.state.addMessageSorted(n.message)}var mr=n.default.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,channelPreview:void 0,viewerLanguage:void 0}),hr=mr.Provider,gr=()=>n.default.useContext(mr),_r=(e,t)=>{let n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),r=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate());return Math.floor((r-n)/864e5)},vr=e=>{let t=new Date;if(Math.floor((t.getTime()-e.getTime())/1e3)<60)return`Just now`;let n=_r(e,t);return n===0?e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`,hour12:!0}):n===1?`Yesterday`:n<7?e.toLocaleDateString(void 0,{weekday:`short`}):e.getFullYear()===t.getFullYear()?e.toLocaleDateString(void 0,{month:`short`,day:`numeric`}):e.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})},yr=n.default.memo(e=>{let{channel:t,unread:n}=e,{selectedChannel:r,onChannelSelect:i,debug:l,channelPreview:u,renderMessagePreview:d,viewerLanguage:f}=gr(),{client:p}=(0,a.useChatContext)(),m=r?.id===t?.id,h=b(t);if(u)return(0,o.jsx)(u,{...e,active:m,selectedChannel:r,onChannelSelect:i,viewerLanguage:f});let g=()=>{t&&i(t)},_=e=>{let t=e.key===`Enter`||e.key===` `,n=e.repeat;!t||n||(e.preventDefault(),g())},v=x(t?.state?.members,p?.userID,t?.type),y=T(v?.user),S=v?.user?.image,C=(()=>{let e=t?.state?.messages;if(e?.length){for(let t=e.length-1;t>=0;t--)if(e[t].type!==`system`)return e[t]}})(),w=(()=>{let e=B({message:C,viewerLanguage:f}),{custom_type:t,attachment_content_type:n}=C?.metadata||{};if(t===s.MESSAGE_CUSTOM_TYPE.TIP)return e||`Sent a tip`;if(t===s.MESSAGE_CUSTOM_TYPE.PAID)return e||`Sent a message`;if(t===s.MESSAGE_CUSTOM_TYPE.ATTACHMENT){if(n===`text`)return`π Sent a locked message`;if(n===`media`)return`π Sent a locked attachment`}if(e)return e;let r=C?.attachments?.[0];return r?r.og_scrape_url?r.og_scrape_url:r.type===`image`?`π· Sent an image`:r.type===`video`?`π₯ Sent a video`:r.type===`audio`?`π΅ Sent audio`:r.type===`file`?`π Sent a file`:`π Sent an attachment`:`No messages yet`})(),E=C?.created_at?vr(new Date(C.created_at)):``,D=C?le(C):!1,O=d?d(C,w):`${D?`β¨ `:``}${w}`,k=n??0;return l&&console.log(`πΊ [ChannelList] π CHANNEL PREVIEW RENDER`,{channelId:t?.id,isSelected:m,participantName:y,unreadCount:k,hasTimestamp:!!E}),(0,o.jsx)(`div`,{role:`button`,tabIndex:0,onClick:g,onKeyDown:_,className:(0,c.default)(`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]":m,"hover:bg-black/[0.02]":!m}),"data-dd-privacy":`mask`,children:(0,o.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,o.jsx)(j,{id:v?.user?.id||t.id||`unknown`,name:y,image:S,size:48,starred:h}),(0,o.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col gap-1`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,o.jsxs)(`h3`,{className:(0,c.default)(`text-sm font-medium truncate text-[#191918]`),children:[h&&(0,o.jsx)(`span`,{className:`sr-only`,children:`Starred conversation. `}),y]}),E&&(0,o.jsx)(`span`,{"data-testid":`channel-preview-timestamp`,className:`text-xs text-[#717070] flex-shrink-0`,children:E})]}),(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2 min-w-0`,children:[(0,o.jsx)(`p`,{className:`text-sm text-[#717070] flex-1 line-clamp-1`,children:O}),k>0&&(0,o.jsx)(`span`,{"data-testid":`channel-preview-unread-badge`,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:k>99?`99+`:k})]})]})]})})});yr.displayName=`CustomChannelPreview`;var br={last_message_at:-1},xr=n.default.memo(({onChannelSelect:e,selectedChannel:t,filters:r,allowNewMessagesFromUnfilteredChannels:i=!1,channelRenderFilterFn:s,sort:l=br,className:u,customEmptyStateIndicator:d,channelListPaginator:f=a.InfiniteScroll,channelPreview:p,renderMessagePreview:m,viewerLanguage:h,lockChannelOrder:g,onMessageNewHandler:v,onMessageNew:y,onChannelVisible:b,onAddedToChannel:x,onChannelUpdated:S})=>{let C=n.default.useRef(0);C.current++;let{debug:w=!1}=_(),T=n.default.useCallback(e=>{for(let t of e)pr(t);return s?s(e):e},[s]);w&&console.log(`πΊ [ChannelList] π RENDER START`,{renderCount:C.current,selectedChannelId:t?.id,filters:r});let E=n.default.useMemo(()=>({selectedChannel:t,onChannelSelect:e,debug:w,channelPreview:p,renderMessagePreview:m,viewerLanguage:h}),[t,e,w,p,m,h]);return(0,o.jsx)(`div`,{className:(0,c.default)(`messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden`,u),children:(0,o.jsx)(`div`,{className:`flex-1 overflow-hidden min-w-0`,children:(0,o.jsx)(hr,{value:E,children:(0,o.jsx)(a.ChannelList,{filters:r,sort:l,options:{limit:30},allowNewMessagesFromUnfilteredChannels:i,channelRenderFilterFn:T,lockChannelOrder:g,onMessageNewHandler:v,onMessageNew:y,onChannelVisible:b,onAddedToChannel:x,onChannelUpdated:S,Paginator:f,Preview:yr,EmptyStateIndicator:d},`${JSON.stringify(r)}:${JSON.stringify(l)}`)})})})});xr.displayName=`ChannelList`;var Sr=`line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.02em]`,Cr=`text-[14px] leading-5 tracking-[0.02em]`,wr=()=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`br`,{}),(0,o.jsx)(`span`,{"aria-hidden":!0,className:`block h-1.5`})]}),Tr=e=>e.split(/\r?\n/).map((e,t,r)=>(0,o.jsxs)(n.default.Fragment,{children:[e,t<r.length-1?(0,o.jsx)(wr,{}):null]},t)),Er=({surface:e,actions:t,layout:n})=>{if(t==null||t.length===0)return null;let r=n===`stacked`;return(0,o.jsx)(`div`,{className:(0,c.default)(`flex gap-2`,r?`mt-4 flex-col`:`min-w-0 max-w-[60%] flex-row flex-wrap justify-end`),children:t.map((t,n)=>(0,o.jsx)(Ae,{variant:e,cta:t,fullWidth:r,standalone:!0},`${t.label}-${n}`))})},Dr=({ctaSurface:e,chinTextColor:t,title:n,subtitle:r,subtitleLines:i=3,appIcon:a,actions:s})=>{let l=n!=null&&n.trim()!==``,u=r!=null&&r.trim()!==``,d=s!=null&&s.length>0;if(!l&&!u&&!d)return null;let f={color:t},p=i>1?{...f,display:`-webkit-box`,WebkitBoxOrient:`vertical`,WebkitLineClamp:i,overflow:`hidden`}:f,m=d&&(s?.[0]?.variant??`primary`)===`secondary`,h=(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-4`,children:[l&&(0,o.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[a?(0,o.jsx)(`span`,{className:`shrink-0`,children:a}):null,(0,o.jsx)(`p`,{className:(0,c.default)(`min-w-0`,Sr),style:f,children:n})]}),u&&(0,o.jsx)(`p`,{className:(0,c.default)(Cr,i<=1&&`truncate`),style:p,children:i>1?Tr(r??``):r})]});return(0,o.jsx)(`div`,{className:`shrink-0 px-4 py-3`,children:m?(0,o.jsxs)(`div`,{"data-testid":`rich-card-chin-row`,className:`flex items-center justify-between gap-3`,children:[h,(0,o.jsx)(Er,{surface:e,actions:s,layout:`row`})]}):(0,o.jsxs)(o.Fragment,{children:[h,(0,o.jsx)(Er,{surface:e,actions:s,layout:`stacked`})]})})},Or={dark:`bg-white/[0.06]`,light:`bg-black/[0.04]`},kr={1:[0],2:[-10,10],3:[-13,0,13]},Ar={1:[0],2:[-26,26],3:[-40,0,40]},jr={1:[0],2:[0,1],3:[1,3,2]},Mr={1:[1],2:[1,1],3:[1,1.08,1]},Nr=({variant:e,images:r})=>{let[i,a]=n.default.useState({}),s=r.join(`
|
|
2
|
-
`),[l,u]=n.default.useState(s);s!==l&&(u(s),a({}));let d=r.slice(0,3).map((e,t)=>({src:e,index:t})).filter(({index:e})=>!i[e]),f=d.length>=3?3:d.length===2?2:1,p=
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./AttachmentCard-BbsjzdLJ.cjs");let n=require("react");n=e.t(n,1);let r=require("@linktr.ee/messaging-core"),i=require("stream-chat"),a=require("stream-chat-react"),o=require("react/jsx-runtime"),s=require("@linktr.ee/messaging-taxonomy"),c=require("classnames");c=e.t(c,1);let l=require("@phosphor-icons/react"),u=require("stream-chat-react/experimental");var d={debug:(e,...t)=>console.log(e,...t),info:(e,...t)=>console.log(e,...t),warn:(e,...t)=>console.warn(e,...t),error:(e,...t)=>console.error(e,...t)},f=e=>({debug:e?.debug??d.debug,info:e?.info??d.info,warn:e?.warn??d.warn,error:e?.error??d.error}),p=(0,n.createContext)(d),m=({logger:e,children:t})=>{let r=(0,n.useMemo)(()=>f(e),[e]);return(0,o.jsx)(p.Provider,{value:r,children:t})},h=()=>(0,n.useContext)(p),g=(0,n.createContext)({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),_=()=>(0,n.useContext)(g),v=({children:e,user:t,serviceConfig:s,apiKey:c,capabilities:l={},debug:u=!1,client:d,logger:p})=>{let h=(0,n.useCallback)((e,...t)=>{u&&console.log(`π₯ [MessagingProvider] ${e}`,...t)},[u]);h(`π RENDER START`,{userId:t?.id,apiKey:c?.substring(0,8)+`...`,serviceConfig:!!s,capabilities:Object.keys(l)});let[_,v]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),[x,S]=(0,n.useState)(!1),[C,w]=(0,n.useState)(!1),[T,E]=(0,n.useState)(null),D=(0,n.useRef)(!1),O=(0,n.useRef)(null),k=(0,n.useRef)(s);k.current=s;let A=(0,n.useRef)(u);A.current=u;let j=(0,n.useRef)(p);j.current=p;let M=(0,n.useRef)({userId:t?.id,apiKey:c,serviceConfig:s,capabilities:l}),N=(0,n.useRef)(0);N.current++,h(`π RENDER INFO`,{renderCount:N.current,currentProps:{userId:t?.id,apiKey:c?.substring(0,8)+`...`},propChanges:{userChanged:M.current.userId!==t?.id,apiKeyChanged:M.current.apiKey!==c,serviceConfigChanged:M.current.serviceConfig!==s,capabilitiesChanged:M.current.capabilities!==l}}),M.current={userId:t?.id,apiKey:c,serviceConfig:s,capabilities:l};let P=(0,n.useRef)(null);!d&&c&&P.current?.apiKey!==c&&(P.current={apiKey:c,client:new i.StreamChat(c)});let F=d||(c?P.current?.client??null:null);(0,n.useEffect)(()=>{let e=N.current,t=k.current;if(d){O.current=null,v(null),b(null),S(!1),E(null),w(!1);return}if(!c||!F||!t){h(`β οΈ SERVICE INIT SKIPPED`,{renderCount:e,reason:`Missing apiKey, client, or serviceConfig`});return}h(`π CREATING SERVICE`,{renderCount:e,apiKey:c?.substring(0,8)+`...`});let n=new r.StreamChatService({...t,apiKey:c,debug:A.current,client:F,...t.logger||!j.current?{}:{logger:f(j.current)}});O.current=n,v(n),h(`β
SERVICE SET`,{renderCount:e,serviceInstance:!!n})},[c,F,d]);let I=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(h(`π USER CONNECTION EFFECT TRIGGERED`,{hasService:!!_,hasUser:!!t,userId:t?.id,isConnecting:D.current,isConnected:x,dependencies:{service:!!_,userId:t?.id}}),!d){if(!_||!t){h(`β οΈ USER CONNECTION SKIPPED`,`Missing service or user`);return}if(D.current){h(`β οΈ USER CONNECTION SKIPPED`,`Already connecting`);return}if(I.current?.serviceId===_&&I.current?.userId===t.id){h(`β οΈ USER CONNECTION SKIPPED`,`Already connected this user with this service`);return}(async()=>{h(`π STARTING USER CONNECTION`,{userId:t.id}),D.current=!0,w(!0),E(null);try{h(`π CALLING SERVICE.CONNECTUSER`,{userId:t.id});let e=await _.connectUser(t);b(e),S(!0),I.current={serviceId:_,userId:t.id},h(`β
USER CONNECTION SUCCESS`,{userId:t.id,clientId:e.userID})}catch(e){let n=e instanceof Error?e.message:`Connection failed`;E(n),h(`β USER CONNECTION ERROR`,{userId:t.id,error:n})}finally{w(!1),D.current=!1,h(`π USER CONNECTION FINISHED`,{userId:t.id,isConnected:x})}})()}},[_,t,h,x,d]),(0,n.useEffect)(()=>{let e=F;return()=>{e&&(I.current=null,O.current?.disconnectUser().catch(console.error))}},[F]);let L=(0,n.useCallback)(async()=>{if(h(`π REFRESH CONNECTION CALLED`,{hasService:!!_,hasUser:!!t}),!d){if(!_||!t){h(`β οΈ REFRESH CONNECTION SKIPPED`,`Missing service or user`);return}h(`π STARTING CONNECTION REFRESH`,{userId:t.id}),w(!0);try{h(`π DISCONNECTING FOR REFRESH`),await _.disconnectUser(),h(`π RECONNECTING FOR REFRESH`);let e=await _.connectUser(t);b(e),S(!0),E(null),h(`β
CONNECTION REFRESH SUCCESS`,{userId:t.id})}catch(e){let n=e instanceof Error?e.message:`Refresh failed`;E(n),h(`β CONNECTION REFRESH ERROR`,{userId:t.id,error:n})}finally{w(!1),h(`π CONNECTION REFRESH FINISHED`,{userId:t.id})}}},[_,t,h,d]),R=n.default.useMemo(()=>(h(`π« CONTEXT VALUE MEMOIZATION`,{hasService:!!_,hasClient:!!y,isConnected:x,isLoading:C,hasError:!!T,capabilitiesKeys:Object.keys(l)}),{service:d?null:_,client:d??y,isConnected:d?!0:x,isLoading:!d&&C,error:d?null:T,capabilities:l,refreshConnection:L,debug:u}),[_,y,d,x,C,T,l,L,u,h]);return h(`π RENDER END`,{renderCount:N.current,willRenderChat:!!F,contextValueReady:!!R}),(0,o.jsx)(m,{logger:p,children:(0,o.jsx)(g.Provider,{value:R,children:F?(0,o.jsx)(a.Chat,{client:F,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})})},y=()=>_(),b=e=>{let[t,r]=(0,n.useState)(!!e?.state?.membership?.pinned_at);return(0,n.useEffect)(()=>{if(!e){r(!1);return}r(!!e.state.membership?.pinned_at);let t=t=>{r(t?.member?!!t.member.pinned_at:!!e.state.membership?.pinned_at)};return e.on(`member.updated`,t),()=>{e.off(`member.updated`,t)}},[e]),t};function x(e,t,n){let r=Object.values(e||{});if((0,s.isOfficialChannel)(n)){let e=r.find(e=>e.user?.id===s.OFFICIAL_SENDER_USER_ID);if(e)return e}return r.find(e=>e.user?.id&&e.user.id!==t)}var S=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function C(e){return S.test(e.trim())}function w(e,t){let n=e?.trim();return!n||t&&n===t||t&&n===`Follower ${t}`?!1:!C(n)}function T(e){return w(e?.name,e?.id)?e.name.trim():w(e?.username,e?.id)?e.username.trim():`Unknown member`}var E=[{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 D(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t)}function O(e){return E[D(e)%E.length]}function k(e){return O(e).emoji}function A(e){return O(e).bgColor}var j=({id:e,image:t,size:n=40,className:r,starred:i=!1,shape:a=`squircle`,dmAgentEnabled:s=!1})=>{let u=k(e),d=A(e),f=n<32?Math.round(n*.45):n<56?14:n<120?18:36,p=n>=40?2:1,m=a===`circle`?{borderRadius:`50%`}:{borderRadius:`1rem`},h=(0,o.jsx)(`div`,{"data-testid":`avatar-inner`,className:`h-full w-full overflow-hidden`,style:m,children:t?(0,o.jsx)(`img`,{src:t,alt:``,className:`h-full w-full object-cover`}):(0,o.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`avatar-fallback`,className:(0,c.default)(`avatar-fallback flex h-full w-full items-center justify-center font-semibold select-none transition-colors`),style:{fontSize:f,lineHeight:1},children:u})});return(0,o.jsxs)(`div`,{"data-testid":`avatar`,className:(0,c.default)(`relative flex-shrink-0`,r),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`,backgroundColor:t?void 0:d,...m},children:[i&&(0,o.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`avatar-star`,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:(0,o.jsx)(l.StarIcon,{className:`size-3 text-yellow-600`,weight:`duotone`})}),(0,o.jsx)(`div`,{"data-testid":`avatar-ring`,className:(0,c.default)(`h-full w-full`,`bg-transparent`),style:{...m,...s&&{borderWidth:`${p}px`,borderStyle:`solid`,borderColor:`var(--AI-Gradient, #7F22FE)`,boxShadow:`inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)`}},children:h})]})},M=`https://linktr.ee/s/about/trust-center/report`,N=({channel:e,participant:t,showBlockParticipant:r=!0,enabled:i=!0,onLeaveConversation:a,onBlockParticipant:o,onDeleteConversationClick:s,onBlockParticipantClick:c,onReportParticipantClick:l,onActionComplete:u,logLabel:d=`useChannelModerationActions`})=>{let{service:f,debug:p}=_(),m=t?.user?.id,h=!!(i&&r&&f&&m),[g,v]=(0,n.useState)(!1),[y,b]=(0,n.useState)(null),[x,S]=(0,n.useState)(!1),[C,w]=(0,n.useState)(!1),T=h&&(y?.participantId!==m||y?.service!==f);return(0,n.useEffect)(()=>{if(!h||!f||!m){v(!1),b(null);return}let e=!1;return(async()=>{try{let t=await f.getBlockedUsers();if(e)return;v(t.some(e=>e.blocked_user_id===m))}catch(t){e||console.error(`[${d}] Failed to check blocked status:`,t)}finally{e||b({participantId:m,service:f})}})(),()=>{e=!0}},[h,f,m,d]),{isParticipantBlocked:g,isCheckingBlockedStatus:T,isLeaving:x,isUpdatingBlockStatus:C,handleLeaveConversation:async()=>{if(!x){s?.(),p&&console.log(`[${d}] Leave conversation`,e.cid),S(!0);try{let t=e._client?.userID??null;await e.hide(t,!1),a&&await a(e),u?.()}catch(e){console.error(`[${d}] Failed to leave conversation`,e)}finally{S(!1)}}},handleBlockUser:async()=>{if(!(C||!f)){c?.(),p&&console.log(`[${d}] Block member`,t?.user?.id),w(!0);try{await f.blockUser(t?.user?.id),o&&await o(t?.user?.id),u?.()}catch(e){console.error(`[${d}] Failed to block member`,e)}finally{w(!1)}}},handleUnblockUser:async()=>{if(!(C||!f)){c?.(),p&&console.log(`[${d}] Unblock member`,t?.user?.id),w(!0);try{await f.unBlockUser(t?.user?.id),o&&await o(t?.user?.id),u?.()}catch(e){console.error(`[${d}] Failed to unblock member`,e)}finally{w(!1)}}},handleReportUser:()=>{l?.(),u?.(),window.open(M,`_blank`,`noopener,noreferrer`)}}},P=({variant:e=`default`,className:t,children:n,...r})=>(0,o.jsx)(`button`,{type:`button`,className:(0,c.default)(`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`,e===`danger`?`text-danger hover:bg-danger/50`:`text-charcoal hover:bg-sand`,t),...r,children:n}),F=({channel:e,participant:t,showDeleteConversation:r=!0,showBlockParticipant:i=!0,showReportParticipant:a=!0,onLeaveConversation:s,onBlockParticipant:u,onDeleteConversationClick:d,onBlockParticipantClick:f,onReportParticipantClick:p,customChannelActions:m,triggerClassName:h})=>{let[g,_]=(0,n.useState)(!1),v=(0,n.useRef)(null),y=(0,n.useId)(),{isParticipantBlocked:b,isCheckingBlockedStatus:x,isLeaving:S,isUpdatingBlockStatus:C,handleLeaveConversation:w,handleBlockUser:T,handleUnblockUser:E,handleReportUser:D}=N({channel:e,participant:t,showBlockParticipant:i,enabled:g,onLeaveConversation:s,onBlockParticipant:u,onDeleteConversationClick:d,onBlockParticipantClick:f,onReportParticipantClick:p,onActionComplete:(0,n.useCallback)(()=>_(!1),[]),logLabel:`ChannelActionsMenu`});return(0,n.useEffect)(()=>{if(!g)return;let e=e=>{v.current&&!v.current.contains(e.target)&&_(!1)},t=e=>{e.key===`Escape`&&_(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[g]),!t||!(r||i||a||m)?null:(0,o.jsxs)(`div`,{ref:v,className:`relative`,children:[(0,o.jsxs)(`button`,{className:h,type:`button`,"aria-haspopup":`true`,"aria-expanded":g,"aria-controls":g?y:void 0,onClick:()=>_(e=>!e),children:[(0,o.jsx)(l.DotsThreeIcon,{className:`size-5 text-black/90`}),(0,o.jsx)(`span`,{className:`sr-only`,children:`More options`})]}),g&&(0,o.jsx)(`div`,{id:y,"aria-label":`Conversation options`,className:(0,c.default)(`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:(0,o.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[r&&(0,o.jsx)(`li`,{children:(0,o.jsxs)(P,{onClick:w,disabled:S,"aria-busy":S,children:[S?(0,o.jsx)(l.SpinnerGapIcon,{className:`h-5 w-5 animate-spin`}):(0,o.jsx)(l.SignOutIcon,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{children:`Delete Conversation`})]})}),i&&(0,o.jsx)(`li`,{children:x?(0,o.jsxs)(P,{disabled:!0,"aria-busy":!0,children:[(0,o.jsx)(l.SpinnerGapIcon,{className:`h-5 w-5 animate-spin`}),(0,o.jsx)(`span`,{children:`Block`})]}):b?(0,o.jsxs)(P,{onClick:E,disabled:C,"aria-busy":C,children:[C?(0,o.jsx)(l.SpinnerGapIcon,{className:`h-5 w-5 animate-spin`}):(0,o.jsx)(l.ProhibitInsetIcon,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{children:`Unblock`})]}):(0,o.jsxs)(P,{onClick:T,disabled:C,"aria-busy":C,children:[C?(0,o.jsx)(l.SpinnerGapIcon,{className:`h-5 w-5 animate-spin`}):(0,o.jsx)(l.ProhibitInsetIcon,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{children:`Block`})]})}),a&&(0,o.jsx)(`li`,{children:(0,o.jsxs)(P,{variant:`danger`,onClick:D,children:[(0,o.jsx)(l.FlagIcon,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{children:`Report`})]})}),m]})})]})},I=`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`,L=`CUSTOMER_PAID`,R=e=>typeof e==`string`&&e.trim().replace(/[\s-]+/g,`_`).toUpperCase()===L,ee=({className:e,onBack:t,showBackButton:r,showStarButton:i=!1,onLeaveConversation:s,onBlockParticipant:u,showDeleteConversation:d=!0,showBlockParticipant:f=!0,showReportParticipant:p=!0,onDeleteConversationClick:m,onBlockParticipantClick:h,onReportParticipantClick:g,customChannelActions:_,renderChannelActions:v,showChannelInfo:y=!0,onParticipantNameClick:S})=>{let{channel:C}=(0,a.useChannelStateContext)(),{client:w}=(0,a.useChatContext)(),E=n.default.useMemo(()=>x(C.state?.members,w?.userID,C.type),[C.state?.members,w?.userID,C.type]),D=T(E?.user),O=E?.user?.image,k=b(C),A=R(C.data?.customer_tag)&&E?.is_follower===!0,M=i&&k,N=A||M||!!S,P=async()=>{try{k?await C.unpin():await C.pin()}catch(e){console.error(`[ChannelHeaderRedesign] Failed to update pinned status:`,e)}},L=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(j,{id:E?.user?.id||C.id||`unknown`,name:D,image:O,shape:`circle`,size:48,className:`-mb-2`}),(0,o.jsx)(`span`,{className:(0,c.default)(`relative z-10 flex max-w-full flex-col items-center justify-center rounded-full border border-white/10 bg-white/65 py-1.5 shadow-[0px_0px_0px_0px_rgba(0,0,0,0.04),0px_1px_2px_0px_rgba(0,0,0,0.04),0px_8px_32px_0px_rgba(0,0,0,0.1)] backdrop-blur-[2px] transition-filter duration-150 group-hover:brightness-95`,N?`pl-3 pr-2`:`px-3`),children:(0,o.jsxs)(`span`,{className:`flex max-w-full items-center justify-center`,children:[(0,o.jsx)(`span`,{className:`min-w-0 truncate text-sm font-bold leading-[1.43] tracking-[0.28px] text-black/90`,children:D}),N&&(0,o.jsxs)(`span`,{className:`ml-2 flex gap-1`,children:[A&&(0,o.jsx)(`span`,{"aria-label":`Paid customer`,className:`flex size-4 shrink-0 items-center justify-center rounded-full bg-[#34C759] text-white`,children:(0,o.jsx)(l.CurrencyDollarIcon,{className:`size-2.5`,weight:`bold`})}),M&&(0,o.jsx)(`span`,{className:`messaging-header-star-badge flex overflow-hidden`,children:(0,o.jsx)(`span`,{"aria-label":`Starred conversation`,className:`flex size-4 shrink-0 items-center justify-center rounded-full bg-[#FFD60A] text-white`,children:(0,o.jsx)(l.StarIcon,{className:`size-2.5`,weight:`fill`})})}),S&&(0,o.jsx)(l.CaretRightIcon,{"aria-hidden":`true`,className:`size-4 shrink-0 text-black/65`,weight:`bold`})]})]})})]});return(0,o.jsx)(`div`,{className:(0,c.default)(`@container bg-[linear-gradient(180deg,#FBFAF9_0%,rgba(251,250,249,0.92)_58%,rgba(251,250,249,0)_100%)]`,e),children:(0,o.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:[(0,o.jsx)(`div`,{className:`flex items-start`,children:r&&(0,o.jsx)(`button`,{className:(0,c.default)(I,`messaging-channel-view-back-button-mobile messaging-channel-view-back-button-desktop`),onClick:t||(()=>{}),type:`button`,"aria-label":`Back to conversations`,children:(0,o.jsx)(l.ArrowLeftIcon,{className:`size-5 text-black/90`})})}),(0,o.jsx)(`div`,{className:`flex min-w-0 justify-center`,"data-dd-privacy":`mask`,children:S?(0,o.jsx)(`button`,{type:`button`,onClick:S,"aria-label":`View details for ${D}`,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:L}):(0,o.jsx)(`div`,{className:`flex min-w-0 max-w-full flex-col items-center px-2`,children:L})}),(0,o.jsxs)(`div`,{className:`flex items-start justify-end gap-2`,children:[i&&(0,o.jsx)(`button`,{className:I,onClick:P,type:`button`,"aria-pressed":k,"aria-label":k?`Unstar conversation`:`Star conversation`,children:(0,o.jsx)(l.StarIcon,{className:(0,c.default)(`size-5`,{"text-[#FFD60A]":k,"text-black/90":!k}),weight:k?`fill`:`regular`})}),y&&(v===void 0?(0,o.jsx)(F,{channel:C,participant:E,showDeleteConversation:d,showBlockParticipant:f,showReportParticipant:p,onLeaveConversation:s,onBlockParticipant:u,onDeleteConversationClick:m,onBlockParticipantClick:h,onReportParticipantClick:g,customChannelActions:_,triggerClassName:I}):v)]})]})})},te=e=>(0,o.jsx)(a.DateSeparator,{...e,position:`center`});function z(e){return e?.trim().toLowerCase().split(/[-_]/)[0]||void 0}function B({message:e,viewerLanguage:t}){let n=e?.text,r=z(t);return r?e?.i18n?.[`${r}_text`]??n:n}var V=/^([a-z][a-z0-9+.-]*):/i,ne=new Set([`http`,`https`,`mailto`,`tel`,`sms`]);function H(e){if(typeof e!=`string`)return;let t=e.trim();if(t===``)return;let n=V.exec(t);if(n){let e=n[1].toLowerCase();return ne.has(e)?t:void 0}return t.startsWith(`//`)||t.startsWith(`/`)?t:`https://${t}`}var re={dark:{primary:`bg-white text-[#121110] hover:bg-white/90`,secondary:`bg-white/15 text-white hover:bg-white/25`},light:{primary:`bg-[#121110] text-white hover:bg-[#2a2928]`,secondary:`bg-black/[0.06] text-[#121110] hover:bg-black/10`}},ie=({variant:e,cta:t,fullWidth:n=!0,standalone:r=!1})=>{let i=t.variant??`primary`,a=(0,c.default)(`inline-flex h-10 items-center justify-center rounded-full px-4 text-sm font-medium leading-none transition-colors`,n?`w-full`:`min-w-0`,!r&&`mt-2`,re[e][i]),s=n?t.label:(0,o.jsx)(`span`,{className:`min-w-0 truncate`,children:t.label}),l=H(t.href);return l?(0,o.jsx)(`a`,{href:l,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.stopPropagation(),t.onClick?.()},className:`${a} no-underline`,children:s}):(0,o.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),t.onClick?.()},className:a,children:s})},U={dark:`text-white`,light:`text-black/90`},ae=`text-white/30`,oe={dark:`text-white/55`,light:`text-black/55`},W={dark:`bg-white/25`,light:`bg-black/15`},se=({variant:e,ctaSurface:t,chinTextColor:n,title:r,placeholderTitle:i,description:a,descriptionLines:s=1,url:l,appIcon:u,cta:d,trailingAction:f,isLoading:p=!1})=>{let m=e===`dark`,h=r??(m?i:void 0)??``,g=h.trim()!==``,_=a!=null&&a.trim()!==``,v=typeof l==`string`?l.trim():``,y=v!==``,b=d!=null;if(!p&&!g&&!_&&!y&&!b)return null;let x=(0,c.default)(`line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.28px]`,n==null&&(m&&!r?ae:U[e])),S=(0,c.default)(`truncate text-[12px] leading-4 tracking-[0.24px]`,n==null&&oe[e]),C=(0,c.default)(`text-[12px] leading-4 tracking-[0.24px]`,s<=1&&`truncate`,n==null&&oe[e]);if(p){let t=(0,c.default)(`animate-pulse rounded`,W[e]);return(0,o.jsx)(`div`,{className:`shrink-0 px-4 py-3`,children:(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-[2px]`,children:[(0,o.jsx)(`div`,{"data-testid":`card-body-skeleton-bar`,className:(0,c.default)(`h-5 w-3/4`,t),"aria-hidden":!0}),(0,o.jsx)(`div`,{"data-testid":`card-body-skeleton-bar`,className:(0,c.default)(`h-4 w-1/2`,t),"aria-hidden":!0})]})})}let w=n?{color:n}:void 0,T=s>1?{...w,display:`-webkit-box`,WebkitBoxOrient:`vertical`,WebkitLineClamp:s,overflow:`hidden`}:w;return(0,o.jsxs)(`div`,{className:`shrink-0 px-4 py-3`,children:[(0,o.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[g&&(0,o.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[u?(0,o.jsx)(`span`,{className:`shrink-0`,children:u}):null,(0,o.jsx)(`p`,{className:(0,c.default)(`min-w-0`,x),style:w,children:h})]}),_&&(0,o.jsx)(`p`,{className:C,style:T,children:a}),!b&&y&&(0,o.jsx)(`p`,{className:S,style:w,"data-testid":`link-attachment-url`,children:v})]}),f&&(0,o.jsx)(`div`,{className:`shrink-0`,children:f})]}),d&&(0,o.jsx)(ie,{variant:t??e,cta:d})]})},ce=`Loading link preview`,G=(0,c.default)(`relative w-[var(--lt-msg-card-width,290px)] max-w-full select-none overflow-hidden`,`rounded-[20px]`),le=`flex h-[250px] flex-col`,K=({variant:e,children:t,href:n,onClick:r,ariaLabel:i,rootRef:a,topRight:s,bgClassName:l,accentHex:u,fixedHeight:d=!1,busy:f=!1,"data-testid":p=`link-card`})=>{let m=(0,c.default)(`messaging-link-card`,G,d?le:`block`,l??(e===`dark`?`bg-[#1e2330]`:`bg-[#f1f0ee]`),n!=null||r!=null?`cursor-pointer no-underline focus-ring`:null),h=f?{role:`status`,"aria-busy":!0,"aria-label":ce}:void 0,g=u?{"--accent":u}:void 0,_=s?(0,o.jsx)(`div`,{"data-testid":`card-shell-top-right`,className:`pointer-events-auto absolute right-3 top-3 z-10`,children:s}):null;return n?(0,o.jsxs)(`a`,{ref:a,href:n,target:`_blank`,rel:`noopener noreferrer`,onClick:r,"data-testid":p,"data-variant":e,className:m,style:g,...h,children:[t,_]}):r?(0,o.jsxs)(`button`,{ref:a,type:`button`,onClick:r,"aria-label":i,"data-testid":p,"data-variant":e,className:(0,c.default)(m,`text-left`),style:g,...h,children:[t,_]}):(0,o.jsxs)(`div`,{ref:a,"data-testid":p,"data-variant":e,className:m,style:g,...h,children:[t,_]})},ue={dark:`bg-white/10`,light:`bg-black/5`},de={dark:`size-16 text-white/25`,light:`size-16 text-black/25`},q=(e,n)=>!!n&&!!e&&t.i(e)===`audio`,fe=(e,n)=>{if(!n||!e)return!1;let r=t.i(e);return r===`video`||r===`audio`},J=`bg-[#F2F3F4]`,Y=({variant:e,thumbnailUrl:n,sourceUrl:r,title:i,mimeType:a=`image/*`,topLeft:s,topRight:l,isLoading:u=!1,onImageError:d})=>{let f=t.i(a),p=!!r&&f===`video`,m=t.s(n);return!u&&q(a,r)?(0,o.jsx)(`div`,{className:`p-3`,children:(0,o.jsx)(`audio`,{...t.a,"data-testid":`card-thumbnail-audio`,src:r,controls:!0,preload:`metadata`,className:`block w-full`,children:(0,o.jsx)(`track`,{kind:`captions`})})}):(0,o.jsxs)(`div`,{"data-testid":`card-thumbnail-hero`,className:(0,c.default)(`relative min-h-0 w-full flex-1 overflow-hidden`,p&&`bg-black`),children:[u?(0,o.jsx)(`div`,{"data-testid":`card-thumbnail-skeleton`,className:(0,c.default)(`h-full w-full animate-pulse`,ue[e]),"aria-hidden":!0}):p?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`video`,{"data-testid":`card-thumbnail-video`,src:r,poster:m,controls:!0,playsInline:!0,preload:`metadata`,className:`absolute inset-0 h-full w-full object-contain`,children:(0,o.jsx)(`track`,{kind:`captions`})}),m&&d?(0,o.jsx)(`img`,{src:m,alt:``,"aria-hidden":!0,onError:d,className:`hidden`}):null]}):n?(0,o.jsx)(`img`,{src:m??n,alt:i??``,draggable:!1,loading:`lazy`,decoding:`async`,onError:d,className:`absolute inset-0 h-full w-full object-cover`}):(0,o.jsx)(`div`,{"data-testid":`card-thumbnail-placeholder`,className:(0,c.default)(`flex h-full w-full items-center justify-center`,ue[e]),children:t.n(a,{className:de[e],weight:`regular`})}),s?(0,o.jsx)(`div`,{"data-testid":`card-thumbnail-top-left`,className:`pointer-events-auto absolute left-3 top-3 z-10`,children:s}):null,l?(0,o.jsx)(`div`,{"data-testid":`card-thumbnail-top-right`,className:`pointer-events-auto absolute right-3 top-3 z-10`,children:l}):null]})},pe=/^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;function me(e){let t=e.trim();return t.startsWith(`#`)?t:`#${t}`}var he=`#FFFFFF`,X=`#040403`,ge={dark:he,light:X};function Z({variant:e,accentColor:t,status:r=`ready`,layout:i=`featured`,thumbnailUrl:a,mimeType:o,sourceUrl:s}){let[c,l]=n.default.useState(!1);n.default.useEffect(()=>{l(!1)},[a]);let u=n.default.useCallback(()=>{l(!0)},[]),d=q(o,s),f=i===`featured`&&a&&!d&&!c&&r===`ready`&&t!=null&&pe.test(t.trim())?me(t):void 0,p=d?X:ge[e];return{thumbnailUrl:c?void 0:a,accentHex:f,chinTextColor:p,surface:d?`light`:e,isLoading:r===`loading`,onImageError:u}}var _e=`flex size-6 items-center justify-center rounded-full bg-[#121110] text-white transition-colors duration-150 hover:bg-[#2a2928] focus-ring`,ve=`relative before:absolute before:-inset-[10px] before:content-['']`,ye=({title:e,placeholderTitle:t,description:n,descriptionLines:r,url:i,mimeType:a,thumbnailUrl:s,sourceUrl:u,layout:d=`featured`,appIcon:f,cta:p,accentColor:m,status:h=`ready`,onDismiss:g,onEditClick:_,dismissLabel:v=`Dismiss attachment`})=>{let y=d===`classic`,b=q(a,u),x=Z({variant:`dark`,accentColor:m,status:h,layout:d,thumbnailUrl:s,mimeType:a,sourceUrl:u}),S=g?(0,o.jsx)(`button`,{type:`button`,onClick:g,"aria-label":v,className:(0,c.default)(_e,!b&&ve),children:(0,o.jsx)(l.XIcon,{className:`size-3`,weight:`bold`})}):void 0,C=_?(0,o.jsx)(`button`,{type:`button`,onClick:_,"aria-label":`Edit attachment`,className:`flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15`,children:(0,o.jsx)(l.PencilSimpleIcon,{className:`size-5`,weight:`regular`})}):void 0;return b&&!x.isLoading?(0,o.jsx)(K,{variant:`dark`,bgClassName:J,children:(0,o.jsxs)(`div`,{className:`flex items-center gap-2 pr-3`,children:[(0,o.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,o.jsx)(Y,{variant:`dark`,sourceUrl:u,title:e,mimeType:a})}),S&&(0,o.jsx)(`div`,{className:`shrink-0`,children:S})]})}):(0,o.jsxs)(K,{variant:`dark`,fixedHeight:!y,accentHex:x.accentHex,busy:x.isLoading,topRight:y?S:void 0,children:[!y&&(0,o.jsx)(Y,{variant:`dark`,thumbnailUrl:x.thumbnailUrl,sourceUrl:u,title:e,mimeType:a,topRight:S,isLoading:x.isLoading,onImageError:x.onImageError}),(0,o.jsx)(se,{chinTextColor:x.chinTextColor,variant:`dark`,ctaSurface:x.surface,title:e,placeholderTitle:t,description:n,descriptionLines:r,url:i,appIcon:f,cta:p,trailingAction:C,isLoading:x.isLoading})]})},be=({accentHex:e,side:t,visible:n,children:r})=>n?(0,o.jsxs)(`div`,{className:`relative isolate w-fit`,children:[r,(0,o.jsx)(`span`,{"aria-hidden":!0,"data-testid":`link-card-tail`,"data-variant":t===`sender`?`dark`:`light`,style:e?{"--accent":e}:void 0,className:(0,c.default)(`messaging-link-card-tail`,t===`receiver`&&`messaging-link-card-tail--received`)})]}):(0,o.jsx)(o.Fragment,{children:r}),xe={Composer:ye,Sent:({title:e,placeholderTitle:t,description:n,descriptionLines:r,url:i,mimeType:a,thumbnailUrl:s,sourceUrl:c,layout:l=`featured`,appIcon:u,cta:d,accentColor:f,status:p=`ready`,onClick:m,groupPosition:h=`single`})=>{let g=fe(a,c),_=H(i),v=d==null&&_!=null&&!g?_:void 0,y=d==null&&!g&&v!=null?m:void 0,b=p!==`loading`&&q(a,c),x=Z({variant:`dark`,accentColor:f,status:p,layout:l,thumbnailUrl:s,mimeType:a,sourceUrl:c});return(0,o.jsx)(be,{accentHex:x.accentHex,side:`sender`,visible:!b&&(h===`single`||h===`end`),children:(0,o.jsxs)(K,{variant:`dark`,href:v,onClick:y,fixedHeight:l===`featured`&&!b,accentHex:x.accentHex,busy:x.isLoading,bgClassName:b?J:void 0,children:[l===`featured`&&(0,o.jsx)(Y,{variant:`dark`,thumbnailUrl:x.thumbnailUrl,sourceUrl:c,title:e,mimeType:a,isLoading:x.isLoading,onImageError:x.onImageError}),(0,o.jsx)(se,{chinTextColor:x.chinTextColor,variant:`dark`,ctaSurface:x.surface,title:e,placeholderTitle:t,description:n,descriptionLines:r,url:i,appIcon:u,cta:d,isLoading:x.isLoading})]})})},Received:({title:e,description:t,descriptionLines:n,url:r,mimeType:i,thumbnailUrl:a,sourceUrl:s,layout:c=`featured`,appIcon:l,cta:u,accentColor:d,status:f=`ready`,onClick:p,groupPosition:m=`single`})=>{let h=fe(i,s),g=H(r),_=u==null&&g!=null&&!h?g:void 0,v=u==null&&!h?p:void 0,y=f!==`loading`&&q(i,s)?J:void 0,b=u&&p?{...u,onClick:()=>{p(),u.onClick?.()}}:u,x=Z({variant:`light`,accentColor:d,status:f,layout:c,thumbnailUrl:a,mimeType:i,sourceUrl:s});return(0,o.jsx)(be,{accentHex:x.accentHex,side:`receiver`,visible:y==null&&(m===`single`||m===`end`),children:(0,o.jsxs)(K,{variant:`light`,href:_,onClick:v,ariaLabel:e??`Open attachment preview`,fixedHeight:c===`featured`&&y==null,accentHex:x.accentHex,busy:x.isLoading,bgClassName:y,"data-testid":`link-attachment`,children:[c===`featured`&&(0,o.jsx)(Y,{variant:`light`,thumbnailUrl:x.thumbnailUrl,sourceUrl:s,title:e,mimeType:i,isLoading:x.isLoading,onImageError:x.onImageError}),(0,o.jsx)(se,{chinTextColor:x.chinTextColor,variant:`light`,ctaSurface:x.surface,title:e,description:t,descriptionLines:n,url:r,appIcon:l,cta:b,isLoading:x.isLoading})]})})}};function Se(e){return e.type===`link`||!!e.og_scrape_url?.trim()}var Ce={LockedAttachment:{isUnlocking:()=>!1}},we=(0,n.createContext)({}),Te=we.Provider;function Ee(e){return(0,n.useContext)(we)[e]??Ce[e]}var De=n.default.lazy(()=>Promise.resolve().then(()=>require("./Card-Ds1FMcUj.cjs"))),Oe=n.default.lazy(()=>Promise.resolve().then(()=>require("./Card-BS6Fza2a.cjs"))),ke=()=>(0,o.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}),Ae=e=>(0,o.jsx)(n.Suspense,{fallback:(0,o.jsx)(ke,{}),children:e.contentType===`text`?(0,o.jsx)(De,{...e}):(0,o.jsx)(Oe,{...e})}),je=({size:e=15})=>(0,o.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 15 15`,fill:`none`,"aria-hidden":`true`,children:(0,o.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})}),Me=e=>e.metadata?.custom_type===s.MESSAGE_CUSTOM_TYPE.PAID,Ne=e=>e.metadata?.custom_type===s.MESSAGE_CUSTOM_TYPE.CHATBOT,Pe=e=>e.metadata?.custom_type===s.MESSAGE_CUSTOM_TYPE.ATTACHMENT,Fe=e=>Pe(e)&&e.metadata?.attachment_content_type===`text`,Ie=e=>Pe(e)&&e.metadata?.attachment_content_type!==`text`,Le=e=>Me(e)&&!!e.metadata?.amount_text,Re=({message:e,isMyMessage:t=!1,hasAttachment:n=!1})=>{let r=Me(e),i=Ne(e);if(!r&&!i)return null;if(r){let t=e.metadata?.amount_text;return t?(0,o.jsxs)(`div`,{className:`message-tag--paid inline-flex items-center gap-1 text-[12px] font-medium leading-[2] text-[#016630]`,children:[(0,o.jsx)(l.GiftIcon,{size:12}),(0,o.jsxs)(`span`,{children:[`Delivered with `,t,` message`]})]}):null}let a=t&&n,s=a?`Sent with AI`:`Sent by AI Assistant`,c=a?`justify-end gap-2 text-black/30`:t?`w-full justify-start gap-1.5 mt-3 px-4 text-white/55`:`w-full justify-start gap-1.5 mt-3 px-4 text-black/30`,u=(0,o.jsx)(`span`,{className:`text-left`,children:s}),d=(0,o.jsx)(`span`,{className:`inline-flex items-center leading-none`,children:(0,o.jsx)(je,{size:a?12:15})});return(0,o.jsx)(`div`,{className:`inline-flex items-center text-[10px] font-normal leading-4 tracking-[0.2px] ${c}`,"data-testid":`message-chatbot-indicator`,children:t&&!a?(0,o.jsxs)(o.Fragment,{children:[u,d]}):(0,o.jsxs)(o.Fragment,{children:[d,u]})})},ze=`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%`,Be={me:`var(--str-chat__own-message-bubble-background-color, #1e2330)`,other:`var(--str-chat__message-bubble-background-color, #f1f0ee)`},Ve=({side:e})=>(0,o.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute bottom-0 z-[-1] h-[1.4375rem] w-5`,style:{insetInlineEnd:e===`me`?`calc(-1 * 0.3125rem)`:void 0,insetInlineStart:e===`other`?`calc(-1 * 0.3125rem)`:void 0,transform:e===`other`?`scaleX(-1)`:void 0,transformOrigin:`center`,backgroundColor:Be[e],WebkitMask:ze,mask:ze}}),He=(0,n.createContext)(void 0),Ue=e=>{let t=e.metadata?.outbound_id;return typeof t==`string`?t:void 0},We=(e,t)=>{if(!t||!e?.length)return;let n=new Set,r;for(let i of e){let e=Ue(i);if(!e||n.has(e))continue;n.add(e);let a=t(e);a&&(r??={},r[e]={id:a.id,...a.name===void 0?{}:{name:a.name}})}return r},Ge=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>e[n].id===t[n]?.id&&e[n].name===t[n]?.name)},Ke=(e,t)=>{let r=We(e,t),[i,a]=(0,n.useState)(r);return Ge(i,r)?i:(a(r),r)},qe=e=>e.metadata?.custom_type===s.MESSAGE_CUSTOM_TYPE.TIP,Je=({message:e})=>{let t=e.metadata?.amount_text;return t?(0,o.jsxs)(`div`,{className:`message-tip-pill inline-flex items-end gap-0.5 max-w-[520px] rounded-[1.5rem] bg-[#43e660] px-4 py-3 text-white`,children:[(0,o.jsx)(`span`,{className:`flex h-5 items-center text-[20px] leading-none`,"aria-hidden":`true`,children:`π`}),(0,o.jsxs)(`span`,{className:`text-[14px] font-bold leading-[1.43] tracking-[0.28px] text-[rgba(4,4,3,0.9)]`,children:[t,` tip!`]})]}):null},Ye=()=>{let{message:e}=(0,a.useMessageContext)(`SentMessageDeliveryStatus`),{messages:t}=(0,a.useChannelStateContext)(`SentMessageDeliveryStatus`),n=(()=>{if(t)for(let e=t.length-1;e>=0;--e){let n=t[e];if(n.type!==`system`&&n.type!==`ephemeral`&&n.type!==`deleted`)return n.id}})();return e.id===n},Xe=()=>Ye()?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(l.ChecksIcon,{weight:`bold`,"aria-hidden":`true`}),(0,o.jsx)(`span`,{"data-testid":`sent-message-delivery-status`,children:`Delivered`})]}):null,Ze=()=>Ye()?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(l.CircleNotchIcon,{className:`sent-message-status__spinner animate-spin`,weight:`bold`,"aria-hidden":`true`}),(0,o.jsx)(`span`,{"data-testid":`sent-message-sending-status`,children:`Sending`})]}):null,Qe=({outbound:e,onOutboundClick:t})=>{let n=e.name||`Broadcast`,r=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{className:`sent-message-outbound-badge`,"aria-hidden":`true`,children:(0,o.jsx)(l.MegaphoneIcon,{weight:`fill`})}),(0,o.jsx)(`span`,{className:(0,c.default)(`sent-message-outbound-name`,{"underline [text-decoration-skip-ink:auto]":!!t}),"data-testid":`sent-message-outbound-status`,children:n})]});return t?(0,o.jsx)(`button`,{type:`button`,className:`inline-flex cursor-pointer items-center gap-1 border-0 bg-transparent p-0 text-inherit [font:inherit]`,"aria-label":`View broadcast ${n}`,onClick:()=>t(e),children:r}):r},$e=()=>(0,o.jsxs)(`span`,{className:`str-chat__message-status sent-message-status--failed`,children:[(0,o.jsx)(l.WarningCircleIcon,{weight:`bold`,"aria-hidden":`true`}),(0,o.jsx)(`span`,{"data-testid":`sent-message-failed-status`,children:`Failed to send`})]}),et=({onOutboundClick:e,resolvedOutbound:t})=>{let{isMyMessage:n,message:r,threadList:i}=(0,a.useMessageContext)(`SentMessageDeliveryStatus`),s=n(),c=Ye();if(i)return null;if(r.status===`failed`&&s&&r.type!==`error`)return(0,o.jsx)($e,{});if(!s)return null;let l=r.metadata?.outbound_id,u=r.status!==`sending`&&r.status!==`failed`&&l&&t?(0,o.jsx)(Qe,{outbound:t,onOutboundClick:e}):null,d=Le(r)?null:(0,o.jsx)(a.MessageStatus,{MessageSentStatus:Xe,MessageDeliveredStatus:Xe,MessageReadStatus:Xe,MessageSendingStatus:qe(r)?Xe:Ze});return u?(0,o.jsxs)(`span`,{className:`sent-message-status-row`,children:[d,d&&c&&(0,o.jsx)(`span`,{className:`sent-message-outbound-separator`,"aria-hidden":`true`,children:`β’`}),u]}):d},tt={dark:`bg-[#1e2330]`,light:`bg-[#f2f1ef]`},nt={dark:`text-white`,light:`text-[#000000]`},rt={dark:`border-white/[0.08]`,light:`border-black/[0.08]`},it=e=>e===`dark`?`sender`:`receiver`,at={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]`}},ot=({variant:e,text:t,bordered:n=!0,groupPosition:r=`single`,widthClassName:i=`w-[280px]`,paddingClassName:a=`px-2 py-2`,radiusClassName:s,className:l,children:u,"data-testid":d})=>{let f=t!=null&&t!==``,p=s??at[it(e)][r];return(0,o.jsxs)(`div`,{"data-testid":d,"data-group-position":r,className:(0,c.default)(`relative`,i,`overflow-hidden`,a,f&&`pb-0`,p,tt[e],nt[e],n&&`border`,n&&rt[e],l),children:[u,f?(0,o.jsx)(`p`,{className:(0,c.default)(`whitespace-pre-wrap break-words leading-snug hyphens-manual`,`pb-2 pt-2`,`px-2`),children:t}):null]})},st=({onClick:e,variant:t=`overlay`,ariaLabel:n=`Dismiss attachment`})=>(0,o.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e()},"aria-label":n,className:(0,c.default)(`flex size-6 items-center justify-center rounded-full text-white`,t===`overlay`?`bg-[#121110]/85 backdrop-blur`:`bg-white/15 hover:bg-white/25`),children:(0,o.jsx)(l.XIcon,{className:`size-3`,weight:`bold`})}),ct=e=>e===`received`?`light`:`dark`,lt=({firstOfGroup:e,endOfGroup:t,groupedByUser:n})=>!n||e&&t?`single`:e?`first`:t?`end`:`middle`,ut=({src:e,mimeType:t,filename:n,items:r})=>r&&r.length>0?r:e?[{src:e,mimeType:t,filename:n}]:[],dt=({item:e,preload:n,trailingAction:r})=>(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`audio`,{...t.a,src:e.src,controls:!0,preload:e.preload??n,className:`block min-w-0 flex-1`,children:e.mimeType?(0,o.jsx)(`source`,{src:e.src,type:e.mimeType}):null}),r??null]}),ft=({state:e,src:t,mimeType:n,filename:r,items:i,text:a,groupPosition:s,preload:c,onDismiss:l})=>{let u=ct(e),d=e===`composer`&&!!l,f=ut({src:t,mimeType:n,filename:r,items:i});if(f.length===0)return null;let p=c??(f.length>1?`none`:`metadata`);return(0,o.jsx)(ot,{variant:u,text:a,groupPosition:s,"data-testid":`audio-attachment`,children:(0,o.jsx)(`div`,{className:`flex flex-col gap-2`,children:f.map((e,t)=>(0,o.jsx)(dt,{item:e,preload:p,trailingAction:d&&t===0?(0,o.jsx)(st,{onClick:l,variant:`inline`}):void 0},`${e.src}-${t}`))})})},pt={Composer:e=>(0,o.jsx)(ft,{...e,state:`composer`}),Sent:e=>(0,o.jsx)(ft,{...e,state:`sent`}),Received:e=>(0,o.jsx)(ft,{...e,state:`received`})};function mt(e){return!Number.isFinite(e)||e<0?``:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(2)} MB`:`${(e/1073741824).toFixed(2)} GB`}var ht={pdf:`PDF`,doc:`DOC`,xls:`XLS`,csv:`CSV`,ppt:`PPT`,zip:`ZIP`,text:`TXT`,markdown:`MD`};function gt(e,n){if(n){let e=n.lastIndexOf(`.`);if(e>0&&e<n.length-1){let t=n.slice(e+1);if(t&&t.length<=5)return t.toUpperCase()}}if(!e)return;if(t.i(e)===`document`){let n=ht[t.r(e)];if(n)return n;if(e===`application/octet-stream`)return}let r=e.split(`/`)[1];if(!(!r||r===`*`))return r.toUpperCase()}function _t(e,t,n){return[gt(e,t),typeof n==`number`&&n>0?mt(n):void 0].filter(Boolean).join(` Β· `)||void 0}function Q(e){try{let t=new URL(e).pathname.split(`/`).pop();return t&&t.length>0?decodeURIComponent(t):`download`}catch{return`download`}}var vt={dark:`text-white/55`,light:`text-black/65`},yt={dark:`bg-white/10`,light:`bg-black/5`},bt={dark:`text-white/85`,light:`text-black/85`},xt=({variant:e,filename:n,title:r,mimeType:i=`application/octet-stream`,fileSize:a,onActivate:s,activateLabel:l,trailingAction:u})=>{let d=r??n??`File`,f=_t(i,n,a),p=(0,o.jsx)(`div`,{className:(0,c.default)(`flex size-10 shrink-0 items-center justify-center rounded-sm`,yt[e]),"aria-hidden":!0,children:t.n(i,{className:(0,c.default)(`size-6`,bt[e]),weight:`regular`})}),m=(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col text-left`,children:[(0,o.jsx)(`p`,{className:`truncate font-medium leading-snug`,children:d}),f?(0,o.jsx)(`p`,{className:(0,c.default)(`truncate text-xs leading-4`,vt[e]),children:f}):null]}),h=s?(0,o.jsxs)(`button`,{type:`button`,onClick:s,"aria-label":l,className:(0,c.default)(`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:[p,m]}):(0,o.jsxs)(o.Fragment,{children:[p,m]});return(0,o.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2`,children:[h,u?(0,o.jsx)(`div`,{className:`shrink-0`,children:u}):null]})};async function St(e,t){let n=t??Q(e);try{let t=await fetch(e,{mode:`cors`});if(!t.ok)throw Error(`HTTP ${t.status}`);let r=await t.blob(),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n,a.style.display=`none`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}catch{if(!window.open(e,`_blank`,`noopener,noreferrer`)){let t=document.createElement(`a`);t.href=e,t.download=n,t.target=`_blank`,t.rel=`noopener noreferrer`,t.style.display=`none`,document.body.appendChild(t),t.click(),document.body.removeChild(t)}}}var Ct=({src:e,filename:t,fileSize:n,mimeType:r,title:i,items:a})=>a&&a.length>0?a:e?[{src:e,filename:t,fileSize:n,mimeType:r,title:i}]:[],wt=({variant:e,item:t,index:n,onActivate:r,trailingAction:i})=>{let a=t.filename??Q(t.src);return(0,o.jsx)(xt,{variant:e,filename:a,title:t.title,mimeType:t.mimeType??`application/octet-stream`,fileSize:t.fileSize,onActivate:()=>r(n),activateLabel:`Download ${a}`,trailingAction:i})},Tt=({state:e,src:t,filename:n,fileSize:r,mimeType:i,title:a,items:s,text:u,groupPosition:d,onClick:f,onDismiss:p})=>{let m=ct(e),h=e===`composer`&&!!p,g=Ct({src:t,filename:n,fileSize:r,mimeType:i,title:a,items:s}),_=e=>{if(f?.(e)===!1)return;let t=g[e];if(!t)return;let n=t.filename??Q(t.src);St(t.src,n)};if(g.length===0)return null;let v=(0,o.jsx)(`span`,{className:(0,c.default)(`flex size-8 items-center justify-center rounded-full`,m===`dark`?`text-white/70`:`text-black/70`),"aria-hidden":!0,children:(0,o.jsx)(l.DownloadSimpleIcon,{className:`size-5`,weight:`bold`})});return(0,o.jsx)(ot,{variant:m,text:u,groupPosition:d,"data-testid":`file-attachment`,children:(0,o.jsx)(`div`,{className:`flex flex-col gap-2`,children:g.map((e,t)=>(0,o.jsx)(wt,{variant:m,item:e,index:t,onActivate:_,trailingAction:h&&t===0?(0,o.jsx)(st,{onClick:p,variant:`inline`}):v},`${e.src}-${t}`))})})},Et={Composer:e=>(0,o.jsx)(Tt,{...e,state:`composer`}),Sent:e=>(0,o.jsx)(Tt,{...e,state:`sent`}),Received:e=>(0,o.jsx)(Tt,{...e,state:`received`})},Dt=`inline-flex size-10 items-center justify-center rounded-full border-0 bg-white/[0.12] p-0 text-white transition-colors duration-150 ease-[ease] hover:bg-white/[0.22] focus-visible:bg-white/[0.22] focus-visible:outline-none disabled:cursor-default disabled:opacity-40`,Ot=`absolute top-1/2 z-[1] inline-flex size-12 -translate-y-1/2 items-center justify-center rounded-full border-0 bg-white/[0.12] p-0 text-white transition-colors duration-150 ease-[ease] hover:bg-white/[0.22] focus-visible:bg-white/[0.22] focus-visible:outline-none`,kt=({onPrev:e,onNext:t,prevLabel:n=`Previous`,nextLabel:r=`Next`})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`button`,{type:`button`,onClick:e,"aria-label":n,className:`${Ot} left-4`,children:(0,o.jsx)(l.CaretLeftIcon,{size:20,weight:`bold`,"aria-hidden":!0})}),(0,o.jsx)(`button`,{type:`button`,onClick:t,"aria-label":r,className:`${Ot} right-4`,children:(0,o.jsx)(l.CaretRightIcon,{size:20,weight:`bold`,"aria-hidden":!0})})]}),At=({url:e,filename:t,variant:r=`pill`,label:i=`Download`,iconOnly:a,tone:s=`dark`,onTriggered:u})=>{let[d,f]=(0,n.useState)(!1),p=(0,n.useCallback)(n=>{n.stopPropagation(),!d&&(f(!0),St(e,t).catch(()=>{}).finally(()=>{f(!1),u?.()}))},[d,e,t,u]),m=a??r!==`pill`,h={className:(0,c.default)(r===`pill`?`size-4`:`size-5`,`shrink-0`),weight:`bold`};return r===`inline`?(0,o.jsx)(`button`,{type:`button`,onClick:p,disabled:d,"aria-label":i,className:(0,c.default)(`flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70`,{dark:`text-white/70 hover:bg-white/[0.08] hover:text-white`,light:`text-black/70 hover:bg-black/[0.08] hover:text-black`}[s]),children:d?(0,o.jsx)(l.CircleNotchIcon,{className:`size-4 animate-spin`,weight:`bold`,"aria-hidden":!0}):(0,o.jsx)(l.DownloadSimpleIcon,{className:`size-5 shrink-0`,weight:`bold`,"aria-hidden":!0})}):r===`viewer`?(0,o.jsx)(`button`,{type:`button`,onClick:p,disabled:d,"aria-label":i,className:Dt,children:d?(0,o.jsx)(l.CircleNotchIcon,{size:20,weight:`bold`,"aria-hidden":!0}):(0,o.jsx)(l.DownloadSimpleIcon,{size:20,weight:`bold`,"aria-hidden":!0})}):(0,o.jsxs)(`button`,{type:`button`,onClick:p,disabled:d,"aria-label":m?i:void 0,className:(0,c.default)(`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`,s===`dark`?`bg-[#121110] text-white hover:bg-[#2a2928]`:`bg-white text-[#121110] hover:bg-white/90`),children:[d?(0,o.jsx)(l.CircleNotchIcon,{className:`size-4 animate-spin`,weight:`bold`,"aria-hidden":!0}):(0,o.jsx)(l.DownloadSimpleIcon,{...h,"aria-hidden":!0}),m?null:i]})},jt=(e,t,n)=>Math.min(Math.max(e,t),n),Mt=({length:e,initialIndex:t,open:r})=>{let i=jt(t,0,Math.max(e-1,0)),[a,o]=(0,n.useState)(i);(0,n.useEffect)(()=>{r&&o(jt(t,0,Math.max(e-1,0)))},[r,t,e]),(0,n.useEffect)(()=>{o(t=>jt(t,0,Math.max(e-1,0)))},[e]);let s=(0,n.useCallback)(()=>{e<=1||o(t=>t<=0?e-1:t-1)},[e]),c=(0,n.useCallback)(()=>{e<=1||o(t=>t>=e-1?0:t+1)},[e]);return(0,n.useEffect)(()=>{if(!r||e<=1)return;let t=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;let t=document.activeElement;t&&(t.tagName===`VIDEO`||t.tagName===`AUDIO`)||(e.preventDefault(),e.key===`ArrowLeft`?s():c())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[r,e,s,c]),{index:a,prev:s,next:c}},Nt=({open:e,onClose:t,ariaLabel:r,counter:i,actions:a,children:s,"data-testid":c})=>{let u=(0,n.useRef)(null),d=(0,n.useRef)(null);return(0,n.useEffect)(()=>{let t=u.current;if(t){if(e){if(!t.open){if(typeof t.showModal==`function`)try{t.showModal()}catch{t.setAttribute(`open`,``)}else t.setAttribute(`open`,``)}let e=typeof document<`u`?document.activeElement:null;return d.current?.focus(),()=>{if(t.open){if(typeof t.close==`function`)try{t.close()}catch{t.removeAttribute(`open`)}else t.removeAttribute(`open`)}e&&document.body.contains(e)&&e.focus()}}if(t.open){if(typeof t.close==`function`)try{t.close()}catch{t.removeAttribute(`open`)}else t.removeAttribute(`open`)}}},[e]),(0,o.jsxs)(`dialog`,{ref:u,className:`mes-media-viewer`,"aria-label":r??`Attachment viewer`,"data-testid":c,onClose:()=>{t()},onClick:e=>{e.target===u.current&&t()},children:[(0,o.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-3 top-3 z-[1] flex items-center justify-between gap-3`,children:[i?(0,o.jsx)(`span`,{className:`pointer-events-auto inline-flex items-center rounded-full bg-white/[0.12] px-3 py-1.5 text-[13px] font-medium leading-none tabular-nums text-white`,children:i}):null,(0,o.jsxs)(`div`,{className:`pointer-events-auto ml-auto inline-flex items-center gap-2`,children:[a,(0,o.jsx)(`button`,{ref:d,type:`button`,onClick:t,"aria-label":`Close viewer`,className:Dt,children:(0,o.jsx)(l.XIcon,{size:20,weight:`bold`,"aria-hidden":!0})})]})]}),(0,o.jsx)(`div`,{className:`box-border flex h-full w-full items-center justify-center px-6 py-16`,children:s})]})},Pt=({open:e,items:t,initialIndex:r=0,onClose:i})=>{let{index:a,prev:s,next:c}=Mt({length:t.length,initialIndex:r,open:e}),l=t[a],u=(0,n.useMemo)(()=>l?.filename??(l?Q(l.src):`image`),[l]);return l?(0,o.jsxs)(Nt,{open:e,onClose:i,ariaLabel:u,counter:t.length>1?`${a+1} / ${t.length}`:void 0,actions:(0,o.jsx)(At,{url:l.src,filename:u,variant:`viewer`,label:`Download ${u}`}),"data-testid":`image-viewer`,children:[e?(0,o.jsx)(`img`,{src:l.src,alt:l.alt??u,draggable:!1,decoding:`async`,className:`block h-auto max-h-[calc(100dvh-128px)] w-auto max-w-[min(96vw,1400px)] select-none object-contain`},`${a}:${l.src}`):null,t.length>1?(0,o.jsx)(kt,{onPrev:s,onNext:c,prevLabel:`Previous image`,nextLabel:`Next image`}):null]}):null},Ft=`relative block size-full overflow-hidden bg-black/5 outline-none after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-white/80 focus-visible:after:ring-offset-2 focus-visible:after:ring-offset-black`,It={1:[`rounded-[18px]`],2:[`rounded-l-[18px]`,`rounded-r-[18px]`],3:[`rounded-l-[18px]`,`rounded-tr-[18px]`,`rounded-br-[18px]`],4:[`rounded-tl-[18px]`,`rounded-tr-[18px]`,`rounded-bl-[18px]`,`rounded-br-[18px]`]},Lt=`--mes-single-width-cap`,Rt=`[--mes-single-width-cap:309px] sm:[--mes-single-width-cap:326px]`,zt=436,Bt=({tiles:e,onTileActivate:t,maxVisible:n=4,singleAspectRatio:r,className:i})=>{let a=e.length;if(a===0)return null;let s=e.slice(0,Math.min(a,n)),l=a-s.length,u=l>0?(0,o.jsxs)(`div`,{"aria-hidden":!0,className:`absolute inset-0 flex items-center justify-center bg-[#040403]/50 text-2xl font-bold leading-[28px] tracking-[-0.24px] text-white`,children:[`+`,l]}):null,d=(e,n,r)=>{let i=(0,c.default)(Ft,`h-full w-full`,It[s.length]?.[n]);return t?(0,o.jsxs)(`button`,{type:`button`,onClick:()=>t(n),"aria-label":e.ariaLabel??`Open media ${n+1}`,className:(0,c.default)(i,e.cursorClassName??`cursor-zoom-in`),children:[e.content,r]},n):(0,o.jsxs)(`div`,{className:i,children:[e.content,r]},n)},f;return r&&(f={aspectRatio:r,width:`min(var(${Lt}), ${Math.round(zt*r*100)/100}px)`,maxWidth:`100%`}),s.length===1?(0,o.jsx)(`div`,{className:(0,c.default)(r?Rt:`aspect-square w-full`,i),style:f,children:d(s[0],0,u)}):s.length===2?(0,o.jsx)(`div`,{className:(0,c.default)(`grid aspect-[16/9] w-full grid-cols-2 gap-0.5`,i),children:s.map((e,t)=>d(e,t,t===s.length-1?u:null))}):s.length===3?(0,o.jsxs)(`div`,{className:(0,c.default)(`grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5`,i),children:[(0,o.jsx)(`div`,{className:`row-span-2`,children:d(s[0],0)}),d(s[1],1),d(s[2],2,u)]}):(0,o.jsx)(`div`,{className:(0,c.default)(`grid aspect-[379/286] w-full grid-cols-2 grid-rows-2 gap-0.5`,i),children:s.map((e,t)=>{let n=l>0&&t===s.length-1;return d(e,t,n?u:null)})})},Vt=({src:e,suppliedRatio:t,fallbackRatio:r})=>{let[i,a]=n.default.useState(),o=n.default.useCallback(t=>{if(!t||t.naturalWidth<=0||t.naturalHeight<=0||e===void 0)return;let n=t.naturalWidth/t.naturalHeight;a(t=>t&&t.src===e&&t.ratio===n?t:{src:e,ratio:n})},[e]),s=n.default.useCallback(e=>o(e.currentTarget),[o]),c=i&&i.src===e?i.ratio:void 0;return{ratio:t??c??r,imgRef:o,onLoad:s}},Ht=e=>{let[t,r]=(0,n.useState)(!1),[i,a]=(0,n.useState)(0);return{viewerOpen:t,viewerIndex:i,handleActivate:(0,n.useCallback)(t=>{e?.(t)!==!1&&(a(t),r(!0))},[e]),closeViewer:(0,n.useCallback)(()=>r(!1),[])}},Ut=({item:e,index:n,totalCount:r,fallbackLoading:i,imgRef:a,onLoad:s})=>({ariaLabel:`Open image ${n+1} of ${r}`,content:(0,o.jsx)(`img`,{ref:a,src:t.s(e.src)??e.src,alt:e.alt??``,width:e.width,height:e.height,draggable:!1,loading:e.loading??i,decoding:`async`,onLoad:s,className:`absolute inset-0 size-full object-cover`})}),Wt=({src:e,alt:t,items:n})=>n&&n.length>0?n:e?[{src:e,alt:t}]:[],Gt=(e,t)=>e.map((n,r)=>({src:n.src,alt:n.alt,filename:t&&e.length===1?t:t?`${t} (${r+1})`:void 0})),Kt=({src:e,alt:n,filename:r,loading:i=`lazy`,onClick:a,onDismiss:s})=>{let{viewerOpen:c,viewerIndex:l,handleActivate:u,closeViewer:d}=Ht(a);return(0,o.jsxs)(`div`,{className:`relative w-fit`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>u(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:(0,o.jsx)(`img`,{src:t.s(e)??e,alt:n??``,draggable:!1,loading:i,decoding:`async`,className:`size-full object-cover`})}),s?(0,o.jsx)(`div`,{className:`absolute right-2 top-2 z-10`,children:(0,o.jsx)(st,{onClick:s})}):null,(0,o.jsx)(Pt,{open:c,items:Gt([{src:e,alt:n}],r),initialIndex:l,onClose:d})]})},qt=326/246,Jt=({state:e,src:t,alt:n,filename:r,items:i,text:a,groupPosition:s,loading:c=`lazy`,onClick:l})=>{let u=Wt({src:t,alt:n,items:i}),d=ct(e),{viewerOpen:f,viewerIndex:p,handleActivate:m,closeViewer:h}=Ht(l),g=u.length===1,_=g?u[0]:void 0,v=Vt({src:_?.src,suppliedRatio:_?.width&&_?.height?_.width/_.height:void 0,fallbackRatio:qt});if(u.length===0)return null;let y=u.map((e,t)=>Ut({item:e,index:t,totalCount:u.length,fallbackLoading:c,imgRef:g?v.imgRef:void 0,onLoad:g?v.onLoad:void 0}));return(0,o.jsxs)(ot,{variant:d,text:a,groupPosition:s,bordered:!1,widthClassName:g?`w-fit max-w-[min(100%,313px)] sm:max-w-[min(100%,330px)]`:`w-[383px] max-w-full`,paddingClassName:`p-0.5`,radiusClassName:`rounded-[20px]`,"data-testid":`image-attachment`,children:[(0,o.jsx)(`div`,{className:`relative`,children:(0,o.jsx)(Bt,{tiles:y,onTileActivate:m,singleAspectRatio:g?v.ratio:void 0})}),(0,o.jsx)(Pt,{open:f,items:Gt(u,r),initialIndex:p,onClose:h})]})},Yt={Composer:e=>(0,o.jsx)(Kt,{...e}),Sent:e=>(0,o.jsx)(Jt,{...e,state:`sent`}),Received:e=>(0,o.jsx)(Jt,{...e,state:`received`})},Xt=({open:e,items:t,initialIndex:r=0,onClose:i})=>{let{index:a,prev:s,next:c}=Mt({length:t.length,initialIndex:r,open:e}),l=t[a],u=(0,n.useMemo)(()=>l?.filename??(l?Q(l.src):`document`),[l]),d=(0,n.useMemo)(()=>l?Zt(l.src):void 0,[l]);return!l||!d?null:(0,o.jsxs)(Nt,{open:e,onClose:i,ariaLabel:u,counter:t.length>1?`${a+1} / ${t.length}`:void 0,"data-testid":`pdf-viewer`,children:[(0,o.jsx)(`iframe`,{src:d,title:u,className:`block h-[calc(100dvh-128px)] w-[min(96vw,1400px)] border-0 bg-white`,sandbox:`allow-scripts allow-forms allow-popups allow-downloads`},`${a}:${l.src}`),t.length>1?(0,o.jsx)(kt,{onPrev:s,onNext:c,prevLabel:`Previous document`,nextLabel:`Next document`}):null]})},Zt=e=>{let t=e.indexOf(`#`),n=t===-1?e:e.slice(0,t),r=t===-1?``:e.slice(t+1),i=new URLSearchParams(r);return i.has(`toolbar`)||i.set(`toolbar`,`0`),i.has(`navpanes`)||i.set(`navpanes`,`0`),`${n}#${i.toString()}`},Qt=({src:e,filename:t,fileSize:n,title:r,items:i})=>i&&i.length>0?i:e?[{src:e,filename:t,fileSize:n,title:r}]:[],$t=({variant:e,item:t,index:n,onActivate:r,trailingAction:i})=>{let a=t.filename??Q(t.src);return(0,o.jsx)(xt,{variant:e,filename:a,title:t.title,mimeType:`application/pdf`,fileSize:t.fileSize,onActivate:()=>r(n),activateLabel:`Open ${a}`,trailingAction:i})},en=({state:e,src:t,filename:n,fileSize:r,title:i,items:a,text:s,groupPosition:c,onClick:l,onDismiss:u})=>{let d=ct(e),f=Qt({src:t,filename:n,fileSize:r,title:i,items:a}),{viewerOpen:p,viewerIndex:m,handleActivate:h,closeViewer:g}=Ht(l),_=e===`composer`&&!!u;if(f.length===0)return null;let v=f.map(e=>({src:e.src,filename:e.filename??Q(e.src)}));return(0,o.jsxs)(ot,{variant:d,text:s,groupPosition:c,"data-testid":`pdf-attachment`,children:[(0,o.jsx)(`div`,{className:`flex flex-col gap-2`,children:f.map((t,n)=>{let r=t.filename??Q(t.src),i=_&&n===0?(0,o.jsx)(st,{onClick:u,variant:`inline`}):e===`composer`?void 0:(0,o.jsx)(At,{url:t.src,filename:r,variant:`inline`,label:`Download ${r}`,tone:d});return(0,o.jsx)($t,{variant:d,item:t,index:n,onActivate:h,trailingAction:i},`${t.src}-${n}`)})}),(0,o.jsx)(Xt,{open:p,items:v,initialIndex:m,onClose:g})]})},tn={Composer:e=>(0,o.jsx)(en,{...e,state:`composer`}),Sent:e=>(0,o.jsx)(en,{...e,state:`sent`}),Received:e=>(0,o.jsx)(en,{...e,state:`received`})},nn=150,rn=({open:e,items:r,initialIndex:i=0,onClose:s})=>{let{index:c,prev:l,next:u}=Mt({length:r.length,initialIndex:i,open:e}),d=(0,n.useRef)(null),f=(0,a.useActiveAudioPlayer)();(0,n.useEffect)(()=>{e&&(f?.pause(),t.o(d.current))},[e,f]);let[p,m]=(0,n.useState)(e);e&&!p&&m(!0),(0,n.useEffect)(()=>{if(e||!p)return;d.current?.pause();let t=window.setTimeout(()=>m(!1),nn);return()=>window.clearTimeout(t)},[e,p]);let h=r[c],g=(0,n.useMemo)(()=>h?.filename??(h?Q(h.src):`video`),[h]);return h?(0,o.jsxs)(Nt,{open:e,onClose:s,ariaLabel:g,counter:r.length>1?`${c+1} / ${r.length}`:void 0,"data-testid":`video-viewer`,children:[p?(0,o.jsx)(`video`,{ref:d,"data-testid":`video-viewer-media`,src:h.src,poster:h.poster,controls:!0,autoPlay:!0,muted:!0,playsInline:!0,preload:h.preload??`metadata`,className:`block h-auto max-h-[calc(100dvh-128px)] w-auto max-w-[min(96vw,1400px)] bg-black`,children:h.mimeType?(0,o.jsx)(`source`,{src:h.src,type:h.mimeType}):null},`${c}:${h.src}`):null,r.length>1?(0,o.jsx)(kt,{onPrev:l,onNext:u,prevLabel:`Previous video`,nextLabel:`Next video`}):null]}):null},an=1,on=4/5,sn=16/9,cn=()=>(0,o.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:(0,o.jsx)(`span`,{className:`flex size-12 items-center justify-center rounded-full bg-black/25 text-white backdrop-blur-[20px]`,children:(0,o.jsx)(l.PlayIcon,{className:`size-6`,weight:`fill`,"aria-hidden":!0})})}),ln=e=>{let t=e.indexOf(`#`);if(t===-1)return`${e}#t=0.001`;let n=e.slice(t+1);return/(^|&)t=/.test(n)?e:`${e}&t=0.001`},un=({item:e,index:t,showPlayBadge:n=!0,imgRef:r,onLoad:i})=>(0,o.jsxs)(`div`,{className:`absolute inset-0 size-full bg-[#0d0d0d]`,children:[e.poster?(0,o.jsx)(`img`,{ref:r,src:e.poster,alt:`Video ${t+1} thumbnail`,draggable:!1,loading:`lazy`,decoding:`async`,onLoad:i,className:`absolute inset-0 size-full object-cover`}):e.src&&e.preload!==`none`?(0,o.jsx)(`video`,{src:ln(e.src),muted:!0,playsInline:!0,preload:`metadata`,"aria-label":`Video ${t+1} thumbnail`,className:`absolute inset-0 size-full object-cover`}):(0,o.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,o.jsx)(l.VideoCameraIcon,{className:`size-16 text-white/30`,weight:`regular`,"aria-hidden":!0})}),n?(0,o.jsx)(cn,{}):null]}),dn=({item:e,index:t,totalCount:n,isOverflowTile:r,imgRef:i,onLoad:a})=>({ariaLabel:`Play video ${t+1} of ${n}`,cursorClassName:`cursor-pointer`,content:(0,o.jsx)(un,{item:e,index:t,showPlayBadge:!r,imgRef:i,onLoad:a})}),fn=({src:e,poster:t,mimeType:n,preload:r,naturalAspectRatio:i,items:a})=>a&&a.length>0?r?a.map(e=>({...e,preload:e.preload??r})):a:e?[{src:e,poster:t,mimeType:n,preload:r,naturalAspectRatio:i}]:[],pn=(e,t)=>e.map((n,r)=>({src:n.src,poster:n.poster,mimeType:n.mimeType,preload:n.preload,filename:t&&e.length===1?t:t?`${t} (${r+1})`:void 0})),mn=({src:e,poster:t,mimeType:n,filename:r,preload:i,onClick:a,onDismiss:s})=>{let{viewerOpen:c,viewerIndex:l,handleActivate:u,closeViewer:d}=Ht(a);return(0,o.jsxs)(`div`,{className:`relative w-fit`,children:[(0,o.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:(0,o.jsx)(un,{item:{src:e,poster:t,mimeType:n,preload:i},index:0})}),s?(0,o.jsx)(`div`,{className:`absolute right-2 top-2 z-10`,children:(0,o.jsx)(st,{onClick:s})}):null,(0,o.jsx)(rn,{open:c,items:pn([{src:e,poster:t,mimeType:n,preload:i}],r),initialIndex:l,onClose:d})]})},hn=({state:e,src:t,poster:n,mimeType:r,filename:i,items:a,text:s,groupPosition:c,preload:l,naturalAspectRatio:u,onClick:d})=>{let f=fn({src:t,poster:n,mimeType:r,preload:l,naturalAspectRatio:u,items:a}),p=ct(e),{viewerOpen:m,viewerIndex:h,handleActivate:g,closeViewer:_}=Ht(d),v=f.length===1,y=v?f[0]:void 0,b=Vt({src:y?.poster,suppliedRatio:y?.naturalAspectRatio,fallbackRatio:an});if(f.length===0)return null;let x=f.length>4?3:-1,S=f.map((e,t)=>dn({item:e,index:t,totalCount:f.length,isOverflowTile:t===x,imgRef:v?b.imgRef:void 0,onLoad:v?b.onLoad:void 0})),C=Math.min(Math.max(b.ratio,on),sn);return(0,o.jsxs)(ot,{variant:p,text:s,groupPosition:c,bordered:!1,widthClassName:v?`w-fit max-w-[313px] sm:max-w-[330px]`:`w-[383px] max-w-full`,paddingClassName:`p-0.5`,radiusClassName:c&&c!==`single`?void 0:`rounded-[20px]`,"data-testid":`video-attachment`,children:[(0,o.jsx)(`div`,{className:`relative`,children:(0,o.jsx)(Bt,{tiles:S,onTileActivate:g,singleAspectRatio:v?C:void 0})}),(0,o.jsx)(rn,{open:m,items:pn(f,i),initialIndex:h,onClose:_})]})},gn={Image:Yt,Video:{Composer:e=>(0,o.jsx)(mn,{...e}),Sent:e=>(0,o.jsx)(hn,{...e,state:`sent`}),Received:e=>(0,o.jsx)(hn,{...e,state:`received`})},Audio:pt,Pdf:tn,File:Et};function $(e){return e?.trim()||void 0}function _n(e){let{original_width:t,original_height:n}=e;if(typeof t==`number`&&typeof n==`number`&&!(!Number.isFinite(t)||!Number.isFinite(n))&&!(t<=0||n<=0))return t/n}function vn(e){return e.trim().replace(/^https?:\/\//i,``).replace(/\/+$/,``).toLowerCase()}function yn(e,t){if(!e?.trim()||!t?.trim())return!1;let n=vn(e),r=vn(t);if(n===r)return!0;if(!n.includes(r))return!1;let i=n.split(r).join(``);return!/[^\p{P}\p{Z}\p{C}]/u.test(i)}function bn(e){let n=$(e.og_scrape_url)??$(e.title_link),r=$(e.image_url)??$(e.thumb_url),i=$(e.mime_type),a=$(e.asset_url),o=r&&q(i,a)?void 0:a;return{title:$(e.title),description:$(e.text),url:n,thumbnailUrl:t.s(r),sourceUrl:o,layout:r||fe(i,o)?`featured`:`classic`,mimeType:i,accentColor:$(e.accent_color),status:`ready`}}function xn(e){return Se(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`:e.mime_type?.startsWith(`audio/`)?`audio`:`file`:null}function Sn(e){if(!e?.length)return[];let t=[],n=(e,n)=>{let r=t[t.length-1];if(r?.type===`media`&&r.kind===e){r.attachments.push(n);return}t.push({type:`media`,kind:e,attachments:[n]})},r=e=>{let n=t[t.length-1];if(n?.type===`link`){n.attachments.push(e);return}t.push({type:`link`,attachments:[e]})};for(let t of e){if(Se(t)){r(t);continue}let e=xn(t);e&&n(e,t)}return t}function Cn(e){return e.filter(e=>e.type===`media`).length}function wn(e,t,n){return t<=1?n:e===0?`first`:e===t-1?`end`:`middle`}function Tn(e){return $(e.image_url)??$(e.asset_url)??``}function En(e){switch(e){case`image`:return gn.Image;case`video`:return gn.Video;case`audio`:return gn.Audio;case`pdf`:return gn.Pdf;default:return gn.File}}function Dn(e,n){switch(e){case`image`:return{src:Tn(n),alt:$(n.title)};case`video`:return{src:$(n.asset_url)??``,poster:t.s(n.thumb_url),mimeType:$(n.mime_type),naturalAspectRatio:_n(n)};case`audio`:return{src:$(n.asset_url)??``,mimeType:$(n.mime_type)??`audio/mpeg`,filename:$(n.title)};case`pdf`:return{src:$(n.asset_url)??``,filename:$(n.title),fileSize:n.file_size};case`file`:return{src:$(n.asset_url)??``,filename:$(n.title),fileSize:n.file_size,mimeType:$(n.mime_type)??`application/octet-stream`}}}function On(e,t){if(t.length>1)return{items:t.map(t=>Dn(e,t))};let n=t[0];return n?Dn(e,n):{}}function kn({groupPosition:e,isMyMessage:t,segment:n}){let r=En(n.kind),i={...On(n.kind,n.attachments),groupPosition:e};return t?(0,o.jsx)(r.Sent,{...i}):(0,o.jsx)(r.Received,{...i})}var An=({groupPosition:e,isMyMessage:t,message:n,renderText:r})=>{let i=Sn(n.attachments);if(i.length===0)return null;let s=Cn(i),l=n.text?.trim(),u=i.find(e=>e.type===`link`),d=u?.type===`link`?bn(u.attachments[0]??{}).url:void 0,f=l&&yn(l,d)?void 0:l,p=0,m=[],h=f?`middle`:e,g=e===`single`||e===`end`,_=(e,n,r)=>{let i=t?xe.Sent:xe.Received;m.push((0,o.jsx)(i,{...bn(e),groupPosition:r?h:`middle`},n))},v=(n,r)=>{let i=wn(p,s,e);p+=1,m.push((0,o.jsx)(kn,{groupPosition:i,isMyMessage:t,segment:n},r))};return i.forEach((e,t)=>{let n=t===i.length-1;if(e.type===`link`){e.attachments.forEach((r,i)=>{_(r,`link-${t}-${i}`,n&&i===e.attachments.length-1)});return}v(e,`media-${t}`)}),(0,o.jsxs)(`div`,{className:`str-chat__message-bubble-wrapper`,children:[(0,o.jsxs)(`div`,{className:`str-chat__message-bubble`,"data-attachment-bubble":`true`,"data-testid":`message-attachment-bubble`,style:{background:`transparent`,borderRadius:0,overflow:`visible`,padding:0},children:[(0,o.jsx)(`div`,{"data-testid":`message-attachment-rows`,className:(0,c.default)(`flex flex-col gap-[4px]`,t?`items-end`:`items-start`),children:m}),!f&&(0,o.jsx)(a.MessageErrorIcon,{})]}),f?(0,o.jsxs)(`div`,{"data-testid":`message-caption-bubble`,className:(0,c.default)(`str-chat__message-bubble`,{"relative isolate":g}),children:[(0,o.jsx)(a.MessageText,{message:n,renderText:r}),(0,o.jsx)(a.MessageErrorIcon,{}),g&&(0,o.jsx)(Ve,{side:t?`me`:`other`})]}):null]})},jn=n.default.memo(e=>{let{additionalMessageInputProps:t,editing:r,endOfGroup:i,firstOfGroup:s,groupStyles:l,groupedByUser:u,handleAction:d,handleOpenThread:f,handleRetry:p,highlighted:m,isMessageAIGenerated:h,isMyMessage:g,message:_,renderText:v,threadList:y,viewerLanguage:b,onOutboundClick:x,resolvedOutbound:S}=e,{client:C}=(0,a.useChatContext)(`CustomMessage`),{channel:w}=(0,a.useChannelStateContext)(`CustomMessage`),{isUnlocking:T,onUnlockClick:E,onFetchSource:D,onDownloadClick:O}=Ee(`LockedAttachment`),[k,A]=(0,n.useState)(!1),M=(0,a.useMessageReminder)(_.id),{Attachment:N=a.Attachment,EditMessageModal:P=a.EditMessageModal,MessageActions:F,MessageBlocked:I=a.MessageBlocked,MessageBouncePrompt:L=a.MessageBouncePrompt,MessageDeleted:R=a.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:ee=a.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:te=a.MessageRepliesCountButton,ReminderNotification:z=a.ReminderNotification,StreamedMessageText:V=a.StreamedMessageText,PinIndicator:ne}=(0,a.useComponentContext)(`CustomMessage`),H=(0,a.messageHasAttachments)(_),re=(0,a.messageHasReactions)(_),ie=(0,n.useMemo)(()=>h?.(_),[h,_]),U=(0,n.useMemo)(()=>{let e=_.attachments??[],t=_.shared_location?[_.shared_location,...e]:e;if(!Ne(_))return t;let n=t.filter(e=>!(`type`in e)||!Se(e));return n.length===t.length?t:n},[_]),ae=(0,n.useMemo)(()=>(_.attachments??[]).filter(Se),[_]),oe=(0,n.useMemo)(()=>Sn(U),[U]),W=(0,n.useMemo)(()=>{let e=B({message:_,viewerLanguage:b});return e===_.text?_:{..._,text:e}},[_,b]),se=oe.length>0,ce=oe.reduce((e,t)=>e+t.attachments.length,0)===(U?.length??0),G=l?.[0]??``,le=G===`top`?`first`:G===`middle`?`middle`:G===`bottom`?`end`:`single`,K=G===`single`||G===`bottom`;if((0,a.isDateSeparatorMessage)(_))return null;if(_.deleted_at||_.type===`deleted`)return(0,o.jsx)(R,{message:_});if((0,a.isMessageBlocked)(_))return(0,o.jsx)(I,{});let ue=!y&&!!_.reply_count,de=!y&&_.show_in_channel&&_.parent_id,q=_.status===`failed`&&_.error?.status!==403,fe=(0,a.isMessageBounced)(_),J;q?J=()=>p(_):fe&&(J=()=>A(!0));let Y=g(),pe=(0,c.default)(`str-chat__message str-chat__message-simple`,`str-chat__message--${_.type}`,`str-chat__message--${_.status}`,Y?`str-chat__message--me str-chat__message-simple--me`:`str-chat__message--other`,_.text?`str-chat__message--has-text`:`has-no-text`,{"str-chat__message--has-attachment":H,"str-chat__message--highlighted":m,"str-chat__message--pinned pinned-message":_.pinned,"str-chat__message--with-reactions":re,"str-chat__message-send-can-be-retried":_?.status===`failed`&&_?.error?.status!==403,"str-chat__message-with-thread-link":ue||de,"str-chat__virtual-message__wrapper--end":i,"str-chat__virtual-message__wrapper--first":s,"str-chat__virtual-message__wrapper--group":u}),me=_.poll_id&&C.polls.fromState(_.poll_id),he=qe(_),X=Ne(_),ge=Pe(_),Z=!!(U?.length&&!_.quoted_message),_e=X&&Y&&Z,ve=se&&ce&&!_.quoted_message&&!me&&!ie&&!X,ye={contentType:`text`,amountText:_.metadata?.amount_text,paymentStatus:_.metadata?.payment_status,renderedText:_.text&&(0,o.jsx)(a.MessageText,{message:W,renderText:v})},be={contentType:`media`,title:_.metadata?.attachment_title,mimeType:_.metadata?.attachment_mime_type,thumbnailUrl:_.metadata?.attachment_thumbnail,amountText:_.metadata?.amount_text,detail:_.metadata?.attachment_detail,paymentStatus:_.metadata?.payment_status,onFetchSource:D?()=>D(_,w):void 0},Ce=(0,o.jsxs)(`div`,{className:(0,c.default)(`str-chat__message-bubble`,{"relative isolate":K}),children:[(0,o.jsx)(a.MessageText,{message:W,renderText:v}),K&&(0,o.jsx)(Ve,{side:Y?`me`:`other`})]}),we=ae.length>0&&(0,o.jsx)(`div`,{className:(0,c.default)(`flex flex-col gap-[4px]`,Y?`items-end`:`items-start`),children:ae.map((e,t)=>{let n=Y?xe.Sent:xe.Received,r=t===ae.length-1&&!_.text;return(0,o.jsx)(n,{...bn(e),groupPosition:r?le:`middle`},`locked-link-${t}`)})});return(0,o.jsxs)(o.Fragment,{children:[r&&(0,o.jsx)(P,{additionalMessageInputProps:t}),k&&(0,o.jsx)(a.MessageBounceModal,{MessageBouncePrompt:L,onClose:()=>A(!1),open:k}),(0,o.jsxs)(`div`,{className:pe,"data-message-id":_.id,"data-dd-privacy":`mask`,children:[ne&&(0,o.jsx)(ne,{}),!!M&&(0,o.jsx)(z,{reminder:M}),_.user&&(0,o.jsx)(j,{className:`str-chat__avatar str-chat__message-sender-avatar`,id:_.user.id,image:_.user.image,name:_.user.name||_.user.id,size:24,shape:`circle`,dmAgentEnabled:X}),(0,o.jsx)(`div`,{className:(0,c.default)(`str-chat__message-inner`,{"str-chat__simple-message--error-failed":q||fe}),"data-testid":`message-inner`,onClick:J,onKeyDown:J,role:J?`button`:void 0,tabIndex:J?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:he?(0,o.jsxs)(`div`,{className:`str-chat__message-bubble-wrapper message-tip-wrapper`,children:[(0,o.jsx)(Je,{message:_}),_.text?.trim()&&Ce]}):Fe(_)?(0,o.jsxs)(`div`,{className:`str-chat__message-bubble-wrapper`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Y&&F&&(0,o.jsx)(F,{}),Y?(0,o.jsx)(Ae,{...ye,isMine:!0}):(0,o.jsx)(Ae,{...ye,isMine:!1,isUnlocking:T(_.id),onUnlockClick:()=>E?.(_,w)}),!Y&&F&&(0,o.jsx)(F,{})]}),we]}):Ie(_)?(0,o.jsxs)(`div`,{className:`str-chat__message-bubble-wrapper message-locked-attachment-wrapper`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Y&&F&&(0,o.jsx)(F,{}),Y?(0,o.jsx)(Ae,{...be,isMine:!0,onPreviewClick:()=>E?E(_,w):void 0}):(0,o.jsx)(Ae,{...be,isMine:!1,isUnlocking:T(_.id),onUnlockClick:()=>E?E(_,w):void 0,onDownloadClick:()=>O?O(_,w):void 0}),!Y&&F&&(0,o.jsx)(F,{})]}),we,_.text&&Ce]}):ve?(0,o.jsx)(An,{groupPosition:le,isMyMessage:Y,message:{...W,attachments:U,i18n:void 0},renderText:v}):(0,o.jsx)(`div`,{className:`str-chat__message-bubble-wrapper`,children:(0,o.jsxs)(`div`,{className:(0,c.default)(`str-chat__message-bubble`,{"relative isolate":K}),children:[X&&!_e&&(0,o.jsx)(Re,{message:_,hasAttachment:Z,isMyMessage:Y}),me&&(0,o.jsx)(a.Poll,{poll:me}),U?.length&&!_.quoted_message?(0,o.jsx)(N,{actionHandler:d,attachments:U}):null,ie?(0,o.jsx)(V,{message:W,renderText:v}):(0,o.jsx)(a.MessageText,{message:W,renderText:v}),(0,o.jsx)(a.MessageErrorIcon,{}),K&&(0,o.jsx)(Ve,{side:Y?`me`:`other`})]})})}),!ge&&!he&&(0,o.jsx)(`div`,{className:`str-chat__message-footer`,children:(!X||_e)&&(0,o.jsx)(Re,{message:_,hasAttachment:Z,isMyMessage:Y})}),(0,o.jsx)(et,{onOutboundClick:x,resolvedOutbound:S}),ue&&(0,o.jsx)(te,{onClick:f,reply_count:_.reply_count}),de&&(0,o.jsx)(ee,{})]},_.id)]})},(e,t)=>e.viewerLanguage!==t.viewerLanguage||e.onOutboundClick!==t.onOutboundClick||e.resolvedOutbound?.id!==t.resolvedOutbound?.id||e.resolvedOutbound?.name!==t.resolvedOutbound?.name?!1:(0,a.areMessageUIPropsEqual)(e,t)),Mn=e=>{let t=(0,a.useMessageContext)(`CustomMessage`),r=(0,n.useContext)(He),i=t.message.metadata?.outbound_id,s=typeof i==`string`?r?.[i]:void 0;return(0,o.jsx)(jn,{...t,...e,resolvedOutbound:s})},Nn=()=>{let{handleDelete:e,message:t}=(0,a.useMessageContext)(`CustomMessageActions`);return t.metadata?.payment_status===`paid`?null:(0,o.jsx)(u.DefaultDropdownActionButton,{onClick:e,"aria-label":`Delete`,title:`Delete`,className:`bg-marble rounded-full p-2 hover:bg-sand transition-all`,children:(0,o.jsx)(l.TrashSimpleIcon,{size:16,weight:`light`,"aria-hidden":!0})})},Pn=()=>{let{handleFlag:e}=(0,a.useMessageContext)(`CustomMessageActions`);return(0,o.jsx)(u.DefaultDropdownActionButton,{onClick:e,"aria-label":`Report`,title:`Report`,className:`bg-marble rounded-full p-2 hover:bg-sand transition-all`,children:(0,o.jsx)(l.FlagIcon,{size:16,weight:`light`,"aria-hidden":!0})})},Fn=()=>{let{message:e}=(0,a.useMessageContext)(`CustomMessageActions`);return e.metadata?.custom_type===s.MESSAGE_CUSTOM_TYPE.ATTACHMENT?(0,o.jsx)(u.MessageActions,{messageActionSet:[{Component:Nn,placement:`quick`,type:`delete`},{Component:Pn,placement:`quick`,type:`flag`}]}):null},In=e=>({linkPreviews:Array.from(e.previews.values()).filter(e=>i.LinkPreviewsManager.previewIsLoaded(e)||i.LinkPreviewsManager.previewIsLoading(e))}),Ln=()=>{let{linkPreviewsManager:e}=(0,a.useMessageComposer)(),{linkPreviews:t}=(0,a.useStateStore)(e.state,In),n=t=>{e.dismissPreview(t)};return t.length>0?(0,o.jsx)(`div`,{"data-testid":`link-preview-list`,className:`messaging-link-preview-list flex flex-col items-stretch w-full gap-2`,children:t.map(e=>{let t=i.LinkPreviewsManager.previewIsLoading(e);return(0,o.jsx)(xe.Composer,{title:e.title,url:e.og_scrape_url,thumbnailUrl:e.image_url,layout:t||e.image_url?`featured`:`classic`,status:t?`loading`:`ready`,onDismiss:()=>n(e.og_scrape_url)},e.og_scrape_url)})}):null},Rn=n.default.createContext(!1),zn=200,Bn=()=>(0,n.useContext)(Rn),Vn=({sendMessage:e,disabled:t,...n})=>(0,o.jsx)(`button`,{...n,type:`button`,"aria-label":`Send`,disabled:t,onPointerDown:e=>e.preventDefault(),onClick:e,children:(0,o.jsx)(l.ArrowUpIcon,{weight:`bold`,className:`size-4`})}),Hn=()=>{let e=(0,n.useContext)(Rn),{handleSubmit:t}=(0,a.useMessageInputContext)(),r=(0,a.useMessageComposerHasSendableData)(),i=e||!r,{SendButton:s=Vn,AttachmentPreviewList:c=a.AttachmentPreviewList}=(0,a.useComponentContext)(`CustomMessageInput`),l=n.default.useRef(null);return n.default.useEffect(()=>{let e=l.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{e.contains(document.activeElement)&&(e.scrollTop=e.scrollHeight)});return t.observe(e),()=>t.disconnect()},[]),n.default.useEffect(()=>{let e=l.current;if(!e)return;let t=e=>{Array.from(e.clipboardData?.items??[]).some(e=>e.kind===`file`)||e.stopPropagation()};return e.addEventListener(`paste`,t),()=>e.removeEventListener(`paste`,t)},[]),(0,o.jsxs)(`div`,{ref:l,"data-testid":`composer-card`,className:`central-container flex flex-col min-w-0 w-full max-h-[calc(var(--messaging-surface-height,100dvh)*0.5)] overflow-y-auto overscroll-contain bg-white rounded-[1.5rem] shadow-[0_4px_16px_0_rgba(0,0,0,0.08),0_1px_2px_0_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.04)] [&>:not(.messaging-composer-previews):not(.messaging-composer-row)]:p-2`,"data-dd-privacy":`mask`,children:[(0,o.jsxs)(`div`,{"data-testid":`composer-previews`,className:`messaging-composer-previews empty:hidden flex flex-col gap-2 px-2 pt-2`,children:[(0,o.jsx)(a.QuotedMessagePreview,{}),(0,o.jsx)(Ln,{}),(0,o.jsx)(c,{})]}),(0,o.jsxs)(`div`,{"data-testid":`composer-row`,className:`messaging-composer-row flex items-start`,children:[(0,o.jsx)(a.TextareaComposer,{"aria-disabled":e||void 0,containerClassName:`min-w-0 flex-1 leading-[0]`,className:`w-full resize-none overflow-hidden bg-transparent py-3.5 pl-4 pr-4 outline-none leading-5 placeholder:text-black/30 text-sm`,autoFocus:!e,enterKeyHint:`send`,maxRows:1/0,readOnly:e,tabIndex:e?-1:void 0}),(0,o.jsx)(`div`,{"data-testid":`send-button-wrapper`,className:`sticky bottom-2 mt-auto mb-2 mr-2 shrink-0 pt-2`,children:(0,o.jsx)(s,{sendMessage:t,"aria-label":`Send`,className:`str-chat__send-button relative flex justify-center items-center rounded-full size-8 bg-[#121110] disabled:bg-[#F1F0EE] disabled:text-black/20 text-white focus-ring before:absolute before:-inset-2 before:content-['']`,"data-testid":`send-button`,disabled:i,type:`button`})})]})]})},Un=()=>(0,o.jsxs)(`div`,{className:`messaging-composer-backdrop`,"aria-hidden":`true`,children:[(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-blur`}),(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-blur`}),(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-blur`}),(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-blur`}),(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-blur`}),(0,o.jsx)(`div`,{className:`messaging-composer-backdrop-gradient`})]}),Wn=({renderActions:e,renderHeader:t,renderFooter:r,disabled:i=!1,disabledReason:s,composerInput:c})=>{let{channel:l}=(0,a.useChannelStateContext)(),u=l?.data?.frozen===!0,d=!!c,f=n.default.useRef(null);return n.default.useEffect(()=>{if(!d)return;let e=f.current,t=e?.parentElement;if(!e||!t)return;let n=e.offsetHeight,r=()=>{let r=e.offsetHeight,i=r>n;n=r;let a=Array.from(t.querySelectorAll(`.str-chat__list`)).find(e=>e.scrollHeight>e.clientHeight)??null,o=a?a.scrollHeight-a.scrollTop-a.clientHeight<zn:!1;t.style.setProperty(`--messaging-composer-height`,`${r}px`),i&&o&&a&&(a.scrollTop=a.scrollHeight)};if(r(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(r);return i.observe(e),()=>{i.disconnect(),t.style.removeProperty(`--messaging-composer-height`)}},[d]),i?d?(0,o.jsxs)(`div`,{ref:f,"data-testid":`composer-chrome`,className:`messaging-composer-chrome messaging-composer-chrome--floating`,children:[(0,o.jsx)(Un,{}),(0,o.jsxs)(`div`,{className:`relative z-10 flex flex-col`,children:[t?.(),(0,o.jsx)(`div`,{"data-testid":`composer-locked-panel`,className:`messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4`,children:s?(0,o.jsx)(`p`,{className:`max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40`,children:s}):null}),r?.()]})]}):(0,o.jsxs)(o.Fragment,{children:[t?.(),(0,o.jsx)(`div`,{"data-testid":`composer-locked-panel`,className:`messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4`,children:s?(0,o.jsx)(`p`,{className:`max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40`,children:s}):null}),r?.()]}):d?(0,o.jsxs)(`div`,{ref:f,"data-testid":`composer-chrome`,className:`messaging-composer-chrome messaging-composer-chrome--floating`,children:[(0,o.jsx)(Un,{}),(0,o.jsxs)(`div`,{className:`relative z-10 flex min-h-0 flex-col`,children:[t?.(),(0,o.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-4 p-3 pb-5 md:p-5`,children:[(0,o.jsxs)(`div`,{inert:u?``:void 0,"aria-disabled":u||void 0,"data-testid":`message-input`,className:`message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40`,children:[e&&(0,o.jsx)(`div`,{className:`flex h-12 shrink-0 items-center justify-center`,children:e()}),(0,o.jsx)(Rn.Provider,{value:u,children:(0,o.jsx)(a.MessageInput,{Input:c??Hn})})]}),r?.()]})]})]}):(0,o.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-4 p-4`,children:[t?.(),(0,o.jsxs)(`div`,{inert:u?``:void 0,"aria-disabled":u||void 0,"data-testid":`message-input`,className:`message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40`,children:[e&&(0,o.jsx)(`div`,{className:`flex h-12 shrink-0 items-center justify-center`,children:e()}),(0,o.jsx)(Rn.Provider,{value:u,children:(0,o.jsx)(a.MessageInput,{Input:Hn})})]}),r?.()]})},Gn={SYSTEM_DM_AGENT_PAUSED:`DM Agent has left the conversation`,SYSTEM_DM_AGENT_RESUMED:`DM Agent has rejoined the conversation`},Kn=[`SYSTEM_AGE_SAFETY_BLOCKED`],qn={SYSTEM_AGE_SAFETY_BLOCKED:`This user isnβt able to reply because they donβt meet our age safety guidelines.`},Jn=`age safety guidelines.`,Yn=`https://linktr.ee/s/about/contact`,Xn=e=>Kn.includes(e),Zn=e=>Xn(e.metadata?.custom_type),Qn=e=>{let t=e.metadata?.custom_type;if((0,s.isDmAgentSystemType)(t))return{kind:`dm-agent`,type:t};if((0,s.isAgeSafetySystemType)(t))return{kind:`age-safety`,type:t};let n=e.dm_agent_system_type;if((0,s.isDmAgentSystemType)(n))return{kind:`dm-agent`,type:n}},$n=e=>{let t=e.indexOf(Jn);if(t===-1)return e;let n=t+22;return(0,o.jsxs)(o.Fragment,{children:[e.slice(0,t),(0,o.jsx)(`a`,{href:Yn,target:`_blank`,rel:`noopener noreferrer`,className:`mes-age-safety-system-message__emphasis font-medium text-inherit underline`,children:Jn}),e.slice(n)]})},er=e=>{let t=!Zn(e.message),n=Qn(e.message);if(n?.kind===`dm-agent`){let r=e.message.text?.trim()||Gn[n.type];return(0,o.jsxs)(`div`,{className:`str-chat__message--system`,"data-testid":`message-system`,children:[(0,o.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:[(0,o.jsx)(l.SparkleIcon,{size:16,weight:`regular`,"aria-hidden":!0,className:`mes-dm-agent-system-message__sparkle shrink-0`}),(0,o.jsx)(`p`,{className:`mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]`,children:r})]}),!t&&(0,o.jsx)(a.MessageTimestamp,{message:e.message})]})}if(n?.kind===`age-safety`){let r=e.message.text?.trim()||qn[n.type];return(0,o.jsxs)(`div`,{className:`str-chat__message--system`,"data-testid":`message-system`,children:[(0,o.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:[(0,o.jsx)(l.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`}),(0,o.jsx)(`div`,{className:`mes-age-safety-system-message__content min-w-0 flex-[1_0_0]`,children:(0,o.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:$n(r)})})]}),!t&&(0,o.jsx)(a.MessageTimestamp,{message:e.message})]})}return(0,o.jsxs)(`div`,{className:`str-chat__message--system`,"data-testid":`message-system`,children:[(0,o.jsxs)(`div`,{className:`str-chat__message--system__text`,children:[(0,o.jsx)(`div`,{className:`str-chat__message--system__line`}),(0,o.jsx)(`p`,{children:e.message.text}),(0,o.jsx)(`div`,{className:`str-chat__message--system__line`})]}),!t&&(0,o.jsx)(a.MessageTimestamp,{message:e.message})]})},tr=(0,n.createContext)(!1),nr=({cx:e,index:t})=>(0,o.jsx)(`circle`,{cx:e,cy:`6.15`,r:`3.9`,fill:`#A0A0A0`,children:(0,o.jsx)(`animateTransform`,{attributeName:`transform`,type:`translate`,values:`0 0; 0 -2.25; 0 0;`,dur:`900ms`,begin:`${120*t}ms`,repeatCount:`indefinite`})}),rr=new Set([a.AIStates.Thinking,a.AIStates.Generating,a.AIStates.ExternalSources]),ir=({threadList:e})=>{let{channel:t,channelConfig:r,thread:i}=(0,a.useChannelStateContext)(),{client:s}=(0,a.useChatContext)(),{typing:c={}}=(0,a.useTypingContext)(),{aiState:l}=(0,a.useAIState)(t),u=(0,n.useContext)(tr);if(!e&&u&&rr.has(l)){let e=or(t,s.user?.id);return(0,o.jsx)(ar,{avatarId:e?.id??`ai-agent`,avatarName:e?.name??e?.id??`Agent`,avatarImage:e?.image,testId:`typing-indicator-ai`})}if(r?.typing_events===!1)return null;let d=e?[]:Object.values(c).filter(({parent_id:e,user:t})=>t?.id!==s.user?.id&&!e),f=e?Object.values(c).filter(({parent_id:e,user:t})=>t?.id!==s.user?.id&&e===i?.id):[],p=e?f:d;if(!p.length)return null;let m=p[0]?.user,h=m?.id&&t.state.members[m.id]?t.state.members[m.id].user:void 0;return(0,o.jsx)(ar,{avatarId:m?.id??h?.id??`typing-user`,avatarName:m?.name??h?.name??m?.id??`Typing user`,avatarImage:m?.image??h?.image,testId:`typing-indicator`})},ar=({avatarId:e,avatarName:t,avatarImage:n,testId:r})=>(0,o.jsx)(`div`,{className:`str-chat__li str-chat__li--single str-chat__typing-indicator !static`,"data-testid":r,style:{marginBottom:`var(--messaging-channel-input-spacer-height, 80px)`},children:(0,o.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:[(0,o.jsx)(j,{className:`str-chat__avatar str-chat__message-sender-avatar`,id:e,name:t,image:n??void 0,size:24,shape:`circle`}),(0,o.jsx)(`div`,{className:`str-chat__message-inner mx-0`,children:(0,o.jsx)(`div`,{className:`str-chat__message-bubble-wrapper`,children:(0,o.jsxs)(`div`,{className:`str-chat__message-bubble relative isolate`,children:[(0,o.jsx)(`div`,{className:`str-chat__message-text min-h-11 flex items-center`,children:(0,o.jsx)(`div`,{className:`str-chat__message-text-inner str-chat__message-simple-text-inner`,children:(0,o.jsxs)(`svg`,{"aria-hidden":`true`,className:`block overflow-visible`,viewBox:`0 0 32 12.3`,width:`32`,height:`13`,overflow:`visible`,children:[(0,o.jsx)(nr,{cx:`4`,index:0}),(0,o.jsx)(nr,{cx:`16`,index:1}),(0,o.jsx)(nr,{cx:`28`,index:2})]})})}),(0,o.jsx)(Ve,{side:`other`})]})})})]})});function or(e,t){let n=e?.state?.members??{};for(let e of Object.values(n)){let n=e?.user;if(n&&n.id!==t)return n}}var sr=()=>null,cr=({className:e,message:t})=>(0,o.jsxs)(`div`,{className:(0,c.default)(`flex items-center justify-center h-full`,e),children:[(0,o.jsxs)(`svg`,{viewBox:`0 0 100 100`,className:`size-8 fill-pebble`,stroke:`none`,children:[(0,o.jsx)(`circle`,{cx:`6`,cy:`50`,r:`6`,children:(0,o.jsx)(`animateTransform`,{attributeName:`transform`,dur:`1s`,type:`translate`,values:`0 15 ; 0 -15; 0 15`,repeatCount:`indefinite`,begin:`0.1`})}),(0,o.jsx)(`circle`,{cx:`30`,cy:`50`,r:`6`,children:(0,o.jsx)(`animateTransform`,{attributeName:`transform`,dur:`1s`,type:`translate`,values:`0 10 ; 0 -10; 0 10`,repeatCount:`indefinite`,begin:`0.2`})}),(0,o.jsx)(`circle`,{cx:`54`,cy:`50`,r:`6`,children:(0,o.jsx)(`animateTransform`,{attributeName:`transform`,dur:`1s`,type:`translate`,values:`0 5 ; 0 -5; 0 5`,repeatCount:`indefinite`,begin:`0.3`})})]}),t&&(0,o.jsx)(`span`,{className:`text-stone`,children:t})]}),lr=n.default.memo(()=>(0,o.jsx)(`div`,{className:`messaging-loading-state flex items-center justify-center h-full`,children:(0,o.jsxs)(`div`,{className:`flex items-center`,children:[(0,o.jsx)(cr,{className:`w-6 h-6`}),(0,o.jsx)(`span`,{className:`text-sm text-stone`,children:`Loading messages`})]})}));lr.displayName=`LoadingState`;var ur=({onBack:e,showBackButton:t,renderMessageInputActions:r,renderMessageInputFooter:i,renderConversationFooter:s,onLeaveConversation:c,onBlockParticipant:l,showDeleteConversation:u=!0,onDeleteConversationClick:d,onBlockParticipantClick:f,onReportParticipantClick:p,showBlockParticipant:m=!0,showReportParticipant:h=!0,composerDisabled:g=!1,composerDisabledReason:_,showStarButton:v=!1,renderChannelBanner:y,customChannelActions:b,renderChannelActions:x,renderMessage:S,viewerLanguage:C,showChannelInfo:w=!0,onParticipantNameClick:T,onOutboundClick:E,resolveOutbound:D,composerInput:O})=>{let{channel:k,messages:A}=(0,a.useChannelStateContext)(),j=(0,n.useRef)(E);(0,n.useEffect)(()=>{j.current=E},[E]);let M=(0,n.useCallback)(e=>{j.current?.(e)},[]),N=E?M:void 0,P=Ke(A,D),F=k.state.messages.some(e=>e.type!==`deleted`),I=y?(0,o.jsx)(n.default.Fragment,{children:y()},`lt-channel-banner`):null,L=(0,o.jsx)(ee,{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:t,showChannelInfo:w,showStarButton:v,onLeaveConversation:c,onBlockParticipant:l,showDeleteConversation:u,showBlockParticipant:m,showReportParticipant:h,onDeleteConversationClick:d,onBlockParticipantClick:f,onReportParticipantClick:p,customChannelActions:b,renderChannelActions:x,onParticipantNameClick:T}),R=(0,n.useCallback)(e=>{let{message:t}=(0,a.useMessageContext)(`ChannelView`),n=(0,o.jsx)(Mn,{...e,viewerLanguage:C,onOutboundClick:N});return!S||!t?n:S(n,t)},[N,S,C]);return(0,o.jsx)(He.Provider,{value:P,children:(0,o.jsx)(a.WithComponents,{overrides:{Message:R,MessageActions:Fn,UnreadMessagesNotification:()=>null,UnreadMessagesSeparator:()=>null},children:(0,o.jsx)(a.Window,{children:O?(0,o.jsxs)(`div`,{className:`messaging-channel-layout relative flex min-h-0 flex-1 flex-col`,children:[(0,o.jsxs)(`div`,{className:`messaging-channel-message-list messaging-channel-message-list--floating relative min-h-0 flex-1 overflow-hidden`,children:[!F&&(0,o.jsx)(`div`,{className:`str-chat__list`,children:(0,o.jsxs)(`div`,{className:`str-chat__message-list-scroll`,children:[L,I]})}),(0,o.jsx)(a.MessageList,{head:F?(0,o.jsxs)(`div`,{className:`sticky top-0 z-10`,children:[L,I]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},`lt-channel-message-list`),(0,o.jsx)(Wn,{...r&&{renderActions:()=>r?.(k)},...s&&{renderHeader:()=>s(k)},renderFooter:()=>i?.(k),disabled:g,disabledReason:_,composerInput:O},`lt-channel-message-input`)]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`flex-1 overflow-hidden relative`,children:[!F&&(0,o.jsx)(`div`,{className:`str-chat__list`,children:(0,o.jsxs)(`div`,{className:`str-chat__message-list-scroll`,children:[L,I]})}),(0,o.jsx)(a.MessageList,{head:F?(0,o.jsxs)(`div`,{className:`sticky top-0 z-10`,children:[L,I]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},`lt-channel-message-list`),s?(0,o.jsx)(n.default.Fragment,{children:s(k)},`lt-channel-conversation-footer`):null,(0,o.jsx)(Wn,{...r&&{renderActions:()=>r?.(k)},renderFooter:()=>i?.(k),disabled:g,disabledReason:_,composerInput:O},`lt-channel-message-input`)]})})})})},dr=n.default.memo(({channel:e,onBack:t,showBackButton:r=!1,renderMessageInputActions:i,renderMessageInputFooter:l,renderConversationFooter:u,onLeaveConversation:d,onBlockParticipant:f,className:p,CustomChannelEmptyState:m=sr,showDeleteConversation:h=!0,onDeleteConversationClick:g,onBlockParticipantClick:_,onReportParticipantClick:v,showBlockParticipant:y=!0,showReportParticipant:b=!0,composerDisabled:x=!1,composerDisabledReason:S,dmAgentEnabled:C,messageMetadata:w,onMessageSent:T,showStarButton:E=!1,renderChannelBanner:D,customChannelActions:O,renderChannelActions:k,renderMessage:A,onMessageLinkClick:j,sendButton:M,attachmentPreviewList:N,viewerLanguage:P,showChannelInfo:F=!0,onParticipantNameClick:I,onOutboundClick:L,resolveOutbound:R,composerInput:ee})=>{let z=(0,n.useCallback)(async(t,n,r)=>{let i=e.data?.chatbot_paused===!0,a=C&&!i,o={...n,...a&&{silent:!0},...w&&{metadata:{...n.metadata??{},...w}}},s={...r,...a&&{skip_push:!0}},c=await e.sendMessage(o,s);return T?.(c),c},[e,C,w,T]),B=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!j)return;let t=B.current;if(!t)return;let n=t=>{let n=t.target?.closest(`a[href]`),r=n?.getAttribute(`href`);if(!r)return;let i=(n?.closest(`[data-message-id]`))?.getAttribute(`data-message-id`);j(r,i?e.state.messages.find(e=>e.id===i):void 0)};return t.addEventListener(`click`,n),()=>t.removeEventListener(`click`,n)},[j,e]);let V=(0,s.isOfficialChannel)(e.type)?{"--lt-msg-card-width":`368px`}:void 0;return(0,o.jsx)(`div`,{ref:B,"data-testid":`channel-view`,className:(0,c.default)(`messaging-channel-view h-full flex flex-col`,p),style:V,children:(0,o.jsx)(tr.Provider,{value:C??!1,children:(0,o.jsx)(a.Channel,{channel:e,MessageSystem:er,EmptyStateIndicator:m,LoadingIndicator:lr,DateSeparator:te,TypingIndicator:ir,doSendMessageRequest:z,...M?{SendButton:M}:{},...N?{AttachmentPreviewList:N}:{},children:(0,o.jsx)(ur,{onBack:t,showBackButton:r,renderMessageInputActions:i,renderMessageInputFooter:l,renderConversationFooter:u,onLeaveConversation:d,onBlockParticipant:f,CustomChannelEmptyState:m,showDeleteConversation:h,onDeleteConversationClick:g,onBlockParticipantClick:_,onReportParticipantClick:v,showBlockParticipant:y,showReportParticipant:b,composerDisabled:x,composerDisabledReason:S,showStarButton:E,renderChannelBanner:D,customChannelActions:O,renderChannelActions:k,renderMessage:A,viewerLanguage:P,showChannelInfo:F,onParticipantNameClick:I,onOutboundClick:L,resolveOutbound:R,composerInput:ee})})})})});dr.displayName=`ChannelView`;var fr=n.default.memo(({message:e,onBack:t})=>(0,o.jsx)(`div`,{className:`messaging-error-state flex items-center justify-center h-full p-8`,children:(0,o.jsxs)(`div`,{className:`text-center max-w-sm`,children:[(0,o.jsx)(`div`,{className:`w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6`,children:(0,o.jsx)(`span`,{className:`text-4xl`,children:`β οΈ`})}),(0,o.jsx)(`h2`,{className:`font-semibold text-charcoal mb-2`,children:`Oops!`}),(0,o.jsx)(`p`,{className:`text-stone text-sm mb-6`,children:e}),t&&(0,o.jsx)(`button`,{type:`button`,onClick:t,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`})]})}));fr.displayName=`ErrorState`;var pr=({capabilities:e={},renderMessageInputActions:t,renderConversationFooter:r,onChannelSelect:i,onExitConversation:a,initialParticipantFilter:s,initialParticipantData:c,CustomChannelEmptyState:l,onBlockParticipantClick:u,onReportParticipantClick:d,dmAgentEnabled:f,onMessageSent:p,viewerLanguage:m,renderChannelBanner:h,customChannelActions:g,renderChannelActions:_,onParticipantNameClick:v,onOutboundClick:b,resolveOutbound:x,renderMessage:S,onMessageLinkClick:C,showChannelInfo:w,composerInput:T,attachmentPreviewList:E})=>{let{client:D,isConnected:O,isLoading:k,error:A,refreshConnection:j,service:M,debug:N}=y(),[P,F]=(0,n.useState)(null),[I,L]=(0,n.useState)(null),[R,ee]=(0,n.useState)(!1),{showDeleteConversation:te=!0}=e,z=(0,n.useRef)(c);z.current=c;let B=(0,n.useRef)(i);B.current=i;let V=(0,n.useRef)(null),ne=(0,n.useRef)(null);(0,n.useEffect)(()=>{ne.current=P},[P]),(0,n.useEffect)(()=>{if(!D||!O)return;let e=D.userID;if(!e)return;let t=`${e}::${s}`;if(V.current===t)return;V.current=t;let n=()=>{V.current===t&&(V.current=null)};(async()=>{try{N&&console.log(`[MessagingShell] Loading initial conversation with:`,s);let t=await D.queryChannels({type:`messaging`,members:{$eq:[e,s]}},{},{limit:1});if(t.length>0){F(t[0]),L(null),B.current?.(t[0]),N&&console.log(`[MessagingShell] Initial conversation loaded:`,t[0].id);return}let r=z.current;if(!r||!M){n(),L(`No conversation found with this account`),N&&console.log(`[MessagingShell] No conversation found for:`,s);return}try{let e=await M.startChannelWithParticipant({id:r.id,name:r.name,phone:r.phone});F(e),L(null),B.current?.(e),N&&console.log(`[MessagingShell] Channel created and loaded:`,e.id)}catch(e){console.error(`[MessagingShell] Failed to create conversation:`,e),n(),L(`Failed to create conversation`)}}catch(e){console.error(`[MessagingShell] Failed to load initial conversation:`,e),n(),ne.current||L(`Failed to load conversation`)}})()},[s,D,O,M,N]);let H=(0,n.useRef)(a);H.current=a;let re=(0,n.useCallback)(()=>{F(null),ee(!0),H.current?.()},[]);return k?(0,o.jsx)(lr,{}):A?(0,o.jsx)(fr,{message:A,onBack:j}):!O||!D?(0,o.jsx)(fr,{message:`Not connected to messaging service`,onBack:j}):I?(0,o.jsx)(fr,{message:I}):R&&!P?(0,o.jsx)(fr,{message:`Conversation ended`}):P?(0,o.jsx)(`div`,{className:`messaging-shell h-full bg-background-primary overflow-hidden`,children:(0,o.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:(0,o.jsx)(dr,{channel:P,renderMessageInputActions:t,renderConversationFooter:r,renderChannelBanner:h,onLeaveConversation:re,onBlockParticipant:re,CustomChannelEmptyState:l,showDeleteConversation:te,onBlockParticipantClick:u,onReportParticipantClick:d,dmAgentEnabled:f,onMessageSent:p,viewerLanguage:m,customChannelActions:g,renderChannelActions:_,onParticipantNameClick:v,onOutboundClick:b,resolveOutbound:x,renderMessage:S,onMessageLinkClick:C,showChannelInfo:w,composerInput:T,attachmentPreviewList:E},P.id)})}):(0,o.jsx)(lr,{})};function mr(e){let t=e.state.pending_messages;if(t?.length)for(let n of t)e.state.addMessageSorted(n.message)}var hr=n.default.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,channelPreview:void 0,viewerLanguage:void 0}),gr=hr.Provider,_r=()=>n.default.useContext(hr),vr=(e,t)=>{let n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),r=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate());return Math.floor((r-n)/864e5)},yr=e=>{let t=new Date;if(Math.floor((t.getTime()-e.getTime())/1e3)<60)return`Just now`;let n=vr(e,t);return n===0?e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`,hour12:!0}):n===1?`Yesterday`:n<7?e.toLocaleDateString(void 0,{weekday:`short`}):e.getFullYear()===t.getFullYear()?e.toLocaleDateString(void 0,{month:`short`,day:`numeric`}):e.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})},br=n.default.memo(e=>{let{channel:t,unread:n}=e,{selectedChannel:r,onChannelSelect:i,debug:l,channelPreview:u,renderMessagePreview:d,viewerLanguage:f}=_r(),{client:p}=(0,a.useChatContext)(),m=r?.id===t?.id,h=b(t);if(u)return(0,o.jsx)(u,{...e,active:m,selectedChannel:r,onChannelSelect:i,viewerLanguage:f});let g=()=>{t&&i(t)},_=e=>{let t=e.key===`Enter`||e.key===` `,n=e.repeat;!t||n||(e.preventDefault(),g())},v=x(t?.state?.members,p?.userID,t?.type),y=T(v?.user),S=v?.user?.image,C=(()=>{let e=t?.state?.messages;if(e?.length){for(let t=e.length-1;t>=0;t--)if(e[t].type!==`system`)return e[t]}})(),w=(()=>{let e=B({message:C,viewerLanguage:f}),{custom_type:t,attachment_content_type:n}=C?.metadata||{};if(t===s.MESSAGE_CUSTOM_TYPE.TIP)return e||`Sent a tip`;if(t===s.MESSAGE_CUSTOM_TYPE.PAID)return e||`Sent a message`;if(t===s.MESSAGE_CUSTOM_TYPE.ATTACHMENT){if(n===`text`)return`π Sent a locked message`;if(n===`media`)return`π Sent a locked attachment`}if(e)return e;let r=C?.attachments?.[0];return r?r.og_scrape_url?r.og_scrape_url:r.type===`image`?`π· Sent an image`:r.type===`video`?`π₯ Sent a video`:r.type===`audio`?`π΅ Sent audio`:r.type===`file`?`π Sent a file`:`π Sent an attachment`:`No messages yet`})(),E=C?.created_at?yr(new Date(C.created_at)):``,D=C?Ne(C):!1,O=d?d(C,w):`${D?`β¨ `:``}${w}`,k=n??0;return l&&console.log(`πΊ [ChannelList] π CHANNEL PREVIEW RENDER`,{channelId:t?.id,isSelected:m,participantName:y,unreadCount:k,hasTimestamp:!!E}),(0,o.jsx)(`div`,{role:`button`,tabIndex:0,onClick:g,onKeyDown:_,className:(0,c.default)(`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]":m,"hover:bg-black/[0.02]":!m}),"data-dd-privacy":`mask`,children:(0,o.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,o.jsx)(j,{id:v?.user?.id||t.id||`unknown`,name:y,image:S,size:48,starred:h}),(0,o.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col gap-1`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,o.jsxs)(`h3`,{className:(0,c.default)(`text-sm font-medium truncate text-[#191918]`),children:[h&&(0,o.jsx)(`span`,{className:`sr-only`,children:`Starred conversation. `}),y]}),E&&(0,o.jsx)(`span`,{"data-testid":`channel-preview-timestamp`,className:`text-xs text-[#717070] flex-shrink-0`,children:E})]}),(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2 min-w-0`,children:[(0,o.jsx)(`p`,{className:`text-sm text-[#717070] flex-1 line-clamp-1`,children:O}),k>0&&(0,o.jsx)(`span`,{"data-testid":`channel-preview-unread-badge`,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:k>99?`99+`:k})]})]})]})})});br.displayName=`CustomChannelPreview`;var xr={last_message_at:-1},Sr=n.default.memo(({onChannelSelect:e,selectedChannel:t,filters:r,allowNewMessagesFromUnfilteredChannels:i=!1,channelRenderFilterFn:s,sort:l=xr,className:u,customEmptyStateIndicator:d,channelListPaginator:f=a.InfiniteScroll,channelPreview:p,renderMessagePreview:m,viewerLanguage:h,lockChannelOrder:g,onMessageNewHandler:v,onMessageNew:y,onChannelVisible:b,onAddedToChannel:x,onChannelUpdated:S})=>{let C=n.default.useRef(0);C.current++;let{debug:w=!1}=_(),T=n.default.useCallback(e=>{for(let t of e)mr(t);return s?s(e):e},[s]);w&&console.log(`πΊ [ChannelList] π RENDER START`,{renderCount:C.current,selectedChannelId:t?.id,filters:r});let E=n.default.useMemo(()=>({selectedChannel:t,onChannelSelect:e,debug:w,channelPreview:p,renderMessagePreview:m,viewerLanguage:h}),[t,e,w,p,m,h]);return(0,o.jsx)(`div`,{className:(0,c.default)(`messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden`,u),children:(0,o.jsx)(`div`,{className:`flex-1 overflow-hidden min-w-0`,children:(0,o.jsx)(gr,{value:E,children:(0,o.jsx)(a.ChannelList,{filters:r,sort:l,options:{limit:30},allowNewMessagesFromUnfilteredChannels:i,channelRenderFilterFn:T,lockChannelOrder:g,onMessageNewHandler:v,onMessageNew:y,onChannelVisible:b,onAddedToChannel:x,onChannelUpdated:S,Paginator:f,Preview:br,EmptyStateIndicator:d},`${JSON.stringify(r)}:${JSON.stringify(l)}`)})})})});Sr.displayName=`ChannelList`;var Cr=`line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.02em]`,wr=`text-[14px] leading-5 tracking-[0.02em]`,Tr=()=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`br`,{}),(0,o.jsx)(`span`,{"aria-hidden":!0,className:`block h-1.5`})]}),Er=e=>e.split(/\r?\n/).map((e,t,r)=>(0,o.jsxs)(n.default.Fragment,{children:[e,t<r.length-1?(0,o.jsx)(Tr,{}):null]},t)),Dr=({surface:e,actions:t,layout:n})=>{if(t==null||t.length===0)return null;let r=n===`stacked`;return(0,o.jsx)(`div`,{className:(0,c.default)(`flex gap-2`,r?`mt-4 flex-col`:`min-w-0 max-w-[60%] flex-row flex-wrap justify-end`),children:t.map((t,n)=>(0,o.jsx)(ie,{variant:e,cta:t,fullWidth:r,standalone:!0},`${t.label}-${n}`))})},Or=({ctaSurface:e,chinTextColor:t,title:n,subtitle:r,subtitleLines:i=3,appIcon:a,actions:s})=>{let l=n!=null&&n.trim()!==``,u=r!=null&&r.trim()!==``,d=s!=null&&s.length>0;if(!l&&!u&&!d)return null;let f={color:t},p=i>1?{...f,display:`-webkit-box`,WebkitBoxOrient:`vertical`,WebkitLineClamp:i,overflow:`hidden`}:f,m=d&&(s?.[0]?.variant??`primary`)===`secondary`,h=(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-4`,children:[l&&(0,o.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[a?(0,o.jsx)(`span`,{className:`shrink-0`,children:a}):null,(0,o.jsx)(`p`,{className:(0,c.default)(`min-w-0`,Cr),style:f,children:n})]}),u&&(0,o.jsx)(`p`,{className:(0,c.default)(wr,i<=1&&`truncate`),style:p,children:i>1?Er(r??``):r})]});return(0,o.jsx)(`div`,{className:`shrink-0 px-4 py-3`,children:m?(0,o.jsxs)(`div`,{"data-testid":`rich-card-chin-row`,className:`flex items-center justify-between gap-3`,children:[h,(0,o.jsx)(Dr,{surface:e,actions:s,layout:`row`})]}):(0,o.jsxs)(o.Fragment,{children:[h,(0,o.jsx)(Dr,{surface:e,actions:s,layout:`stacked`})]})})},kr={dark:`bg-white/[0.06]`,light:`bg-black/[0.04]`},Ar={1:[0],2:[-10,10],3:[-13,0,13]},jr={1:[0],2:[-26,26],3:[-40,0,40]},Mr={1:[0],2:[0,1],3:[1,3,2]},Nr={1:[1],2:[1,1],3:[1,1.08,1]},Pr=({variant:e,images:r})=>{let[i,a]=n.default.useState({}),s=r.join(`
|
|
2
|
+
`),[l,u]=n.default.useState(s);s!==l&&(u(s),a({}));let d=r.slice(0,3).map((e,t)=>({src:e,index:t})).filter(({index:e})=>!i[e]),f=d.length>=3?3:d.length===2?2:1,p=Ar[f],m=jr[f],h=Mr[f],g=Nr[f];return(0,o.jsx)(`div`,{className:(0,c.default)(`relative flex min-h-0 w-full flex-1 items-center justify-center overflow-hidden`,kr[e]),children:d.map(({src:e,index:n},r)=>(0,o.jsx)(`img`,{src:t.s(e)??e,alt:``,draggable:!1,loading:`lazy`,decoding:`async`,onError:()=>a(e=>({...e,[n]:!0})),className:`absolute left-1/2 top-1/2 w-[62%] aspect-[3/2] rounded-[12px] bg-[#ffffff] object-cover shadow-md`,style:{transform:`translate(-50%, -50%) translateX(${m[r]}px) rotate(${p[r]}deg) scale(${g[r]})`,zIndex:h[r]}},`${e}-${n}`))})},Fr=`flex h-[180px] w-full shrink-0 flex-col overflow-hidden`,Ir=({variant:e,presentation:t,images:n,title:r,heroUrl:i,onHeroError:a})=>(0,o.jsx)(`div`,{className:Fr,children:t===`fan`?(0,o.jsx)(Pr,{variant:e,images:n}):(0,o.jsx)(Y,{variant:e,thumbnailUrl:i,title:r,mimeType:`image/*`,onImageError:a})}),Lr=({variant:e,title:t,subtitle:n,subtitleLines:r,images:i=[],imagePresentation:a,actions:c,appIcon:l,accentColor:u,groupPosition:d=`single`})=>{let f=(0,s.resolveRichCardImagePresentation)({imagePresentation:a,images:i}),p=i.length>0,m=p&&f===`hero`,h=Z({variant:e,accentColor:u,layout:`featured`,thumbnailUrl:m?i[0]:void 0}),g=d===`single`||d===`end`;return(0,o.jsx)(be,{accentHex:h.accentHex,side:e===`dark`?`sender`:`receiver`,visible:g,children:(0,o.jsxs)(K,{variant:e,accentHex:h.accentHex,"data-testid":`rich-card`,children:[p&&(0,o.jsx)(Ir,{variant:e,presentation:f,images:i,title:t,heroUrl:m?h.thumbnailUrl:void 0,onHeroError:h.onImageError}),(0,o.jsx)(Or,{ctaSurface:h.surface,chinTextColor:h.chinTextColor,title:t,subtitle:n,subtitleLines:r,appIcon:l,actions:c})]})})},Rr={Sent:e=>(0,o.jsx)(Lr,{...e,variant:`dark`}),Received:e=>(0,o.jsx)(Lr,{...e,variant:`light`})},zr=`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%`,Br={sent:`var(--str-chat__own-message-bubble-background-color, #1e2330)`,received:`var(--str-chat__message-bubble-background-color, #f1f0ee)`},Vr=({variant:e})=>(0,o.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.3125rem)`:void 0,insetInlineStart:e===`received`?`calc(-1 * 0.3125rem)`:void 0,transform:e===`received`?`scaleX(-1)`:void 0,transformOrigin:`center`,backgroundColor:Br[e],WebkitMask:zr,mask:zr}}),Hr={sent:{backgroundColor:`var(--str-chat__own-message-bubble-background-color, #1e2330)`,color:`var(--str-chat__own-message-bubble-color, #fff)`},received:{backgroundColor:`var(--str-chat__message-bubble-background-color, #f1f0ee)`,color:`var(--str-chat__message-bubble-color, #000000)`}},Ur=({variant:e,text:t,tail:n=!0,header:r,className:i})=>(0,o.jsxs)(`div`,{"data-dd-privacy":`mask`,className:(0,c.default)(`relative px-4 py-3`,`text-[0.875rem] leading-[1.3125rem] tracking-[0.14px]`,i),style:{...Hr[e],borderRadius:`var(--str-chat__message-bubble-border-radius, 1.5rem)`,isolation:`isolate`},children:[r!=null&&(0,o.jsx)(`div`,{className:`mb-1 font-medium`,"data-testid":`message-bubble-header`,children:r}),(0,o.jsx)(`p`,{className:`m-0 whitespace-pre-wrap break-words hyphens-manual`,children:t}),n&&(0,o.jsx)(Vr,{variant:e})]}),Wr={Sent:({text:e,tail:t,className:n})=>(0,o.jsx)(Ur,{variant:`sent`,text:e,tail:t,className:n}),Received:({text:e,tail:t,header:n,className:r})=>(0,o.jsx)(Ur,{variant:`received`,text:e,tail:t,header:n,className:r})},Gr=({question:e,onClick:t,loading:n=!1,className:r})=>(0,o.jsx)(`button`,{type:`button`,onClick:t,disabled:n,style:{backgroundColor:`#E6E5E3`},className:(0,c.default)(`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},r),children:e}),Kr=({faqs:e,onFaqClick:t,loadingFaqId:n,headerText:r,className:i,avatarImage:a,avatarName:c})=>{let l=(0,s.selectEnabledFaqs)(e);return l.length===0?null:(0,o.jsx)(`div`,{className:i,children:(0,o.jsxs)(`div`,{className:`flex gap-3 items-end`,children:[(a||c)&&(0,o.jsx)(`div`,{className:`flex-none`,children:(0,o.jsx)(j,{id:c||`account`,name:c||`Account`,image:a,size:24,shape:`circle`})}),(0,o.jsxs)(`div`,{className:`flex-1 flex flex-col gap-3 rounded-lg p-4`,style:{backgroundColor:`#F1F0EE`},children:[r&&(0,o.jsx)(`p`,{"data-testid":`faq-list-header`,className:`text-md text-charcoal mb-4`,children:r}),l.map(e=>(0,o.jsx)(Gr,{question:e.question,onClick:()=>t(e.id),loading:n===e.id},e.id))]})]})})};exports.ActionButton=P,exports.Avatar=j,exports.ChannelEmptyState=sr,exports.ChannelList=Sr,exports.ChannelView=dr,exports.CustomMessageProvider=Te,exports.FaqList=Kr,exports.FaqListItem=Gr,exports.LinkAttachment=xe,exports.LockedAttachment=Ae,exports.MessageAttachment=gn,exports.MessageBubble=Wr,exports.MessagingLoggerProvider=m,exports.MessagingProvider=v,exports.MessagingShell=pr,exports.RichCard=Rr,exports.TipMessage=Je,exports.buildCompactMetaLabel=_t,exports.formatFileSize=mt,exports.formatRelativeTime=yr,exports.getFileExtensionLabel=gt,exports.getMessageDisplayText=B,exports.isLinkAttachment=Se,exports.isTipMessage=qe,exports.isUuidLike=C,exports.messageAttachmentGroupPositionFromStream=lt,exports.normalizeLanguageCode=z,exports.optimizeMessagingAttachmentUrl=t.s,exports.resolveConversationParticipant=x,exports.resolveParticipantDisplayName=T,exports.useComposerLocked=Bn,exports.useCustomMessage=Ee,exports.useMessaging=y,exports.useMessagingLogger=h;
|
|
3
3
|
//# sourceMappingURL=index.cjs.map
|