@linktr.ee/messaging-react 2.2.3 → 2.3.0-rc-1779486690
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Card-DOws_Rs6.js → Card-4takoN_-.js} +2 -2
- package/dist/{Card-DOws_Rs6.js.map → Card-4takoN_-.js.map} +1 -1
- package/dist/{Card-Ccy5fPho.js → Card-BuROm0u7.js} +2 -2
- package/dist/{Card-Ccy5fPho.js.map → Card-BuROm0u7.js.map} +1 -1
- package/dist/{Card-DWH_vCQD.cjs → Card-CexShqpK.cjs} +2 -2
- package/dist/{Card-DWH_vCQD.cjs.map → Card-CexShqpK.cjs.map} +1 -1
- package/dist/{Card-CyszwESe.cjs → Card-CgpHBx-W.cjs} +2 -2
- package/dist/{Card-CyszwESe.cjs.map → Card-CgpHBx-W.cjs.map} +1 -1
- package/dist/{Card-BRub_HpW.js → Card-DdpdnSh_.js} +3 -3
- package/dist/{Card-BRub_HpW.js.map → Card-DdpdnSh_.js.map} +1 -1
- package/dist/{Card-imQIyJzJ.cjs → Card-ot16XqS2.cjs} +2 -2
- package/dist/{Card-imQIyJzJ.cjs.map → Card-ot16XqS2.cjs.map} +1 -1
- package/dist/{LockedThumbnail-D512VE6T.cjs → LockedThumbnail-CydtYOSA.cjs} +2 -2
- package/dist/{LockedThumbnail-D512VE6T.cjs.map → LockedThumbnail-CydtYOSA.cjs.map} +1 -1
- package/dist/{LockedThumbnail-C9eocsRT.js → LockedThumbnail-Drsh4B5o.js} +2 -2
- package/dist/{LockedThumbnail-C9eocsRT.js.map → LockedThumbnail-Drsh4B5o.js.map} +1 -1
- package/dist/assets/index.css +1 -1
- package/dist/{index-uxWUZe1M.js → index-BCbVXFHI.js} +1648 -1740
- package/dist/index-BCbVXFHI.js.map +1 -0
- package/dist/index-CQ913euH.cjs +2 -0
- package/dist/index-CQ913euH.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +22 -13
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/components/MessageAttachment/Image/ImageAttachment.stories.tsx +8 -5
- package/src/components/MessageAttachment/Image/index.tsx +7 -1
- package/src/components/MessageAttachment/MessageAttachment.test.tsx +200 -19
- package/src/components/MessageAttachment/Pdf/index.tsx +14 -15
- package/src/components/MessageAttachment/Video/VideoAttachment.stories.tsx +2 -2
- package/src/components/MessageAttachment/Video/index.tsx +11 -2
- package/src/components/MessageAttachment/_shared/CarouselNav.tsx +47 -0
- package/src/components/MessageAttachment/_shared/DownloadAction.tsx +27 -27
- package/src/components/MessageAttachment/_shared/ImageViewer.tsx +59 -261
- package/src/components/MessageAttachment/_shared/PdfViewer.tsx +56 -30
- package/src/components/MessageAttachment/_shared/VideoViewer.tsx +53 -109
- package/src/components/MessageAttachment/_shared/ViewerShell.tsx +127 -107
- package/src/components/MessageAttachment/_shared/useCarousel.ts +103 -0
- package/src/components/MessageAttachment/index.tsx +18 -9
- package/src/components/MessageAttachment/types.ts +1 -1
- package/src/styles.css +158 -1
- package/dist/index-IlgylJT2.cjs +0 -2
- package/dist/index-IlgylJT2.cjs.map +0 -1
- package/dist/index-uxWUZe1M.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),y=require("classnames"),m=require("react"),os=require("@linktr.ee/messaging-core"),C=require("stream-chat-react"),w=require("@phosphor-icons/react"),ft=require("stream-chat"),Ct=m.createContext({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),Fe=()=>m.useContext(Ct),ls=({children:t,user:s,serviceConfig:n,apiKey:a,capabilities:r={},debug:i=!1})=>{const l=m.useCallback((M,...A)=>{i&&console.log(`🔥 [MessagingProvider] ${M}`,...A)},[i]);l("🔄 RENDER START",{userId:s==null?void 0:s.id,apiKey:(a==null?void 0:a.substring(0,8))+"...",serviceConfig:!!n,capabilities:Object.keys(r)});const[o,d]=m.useState(null),[h,f]=m.useState(null),[u,x]=m.useState(!1),[c,g]=m.useState(!1),[v,p]=m.useState(null),N=m.useRef(!1),j=m.useRef({userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r}),k=m.useRef(0);k.current++,l("📊 RENDER INFO",{renderCount:k.current,currentProps:{userId:s==null?void 0:s.id,apiKey:(a==null?void 0:a.substring(0,8))+"..."},propChanges:{userChanged:j.current.userId!==(s==null?void 0:s.id),apiKeyChanged:j.current.apiKey!==a,serviceConfigChanged:j.current.serviceConfig!==n,capabilitiesChanged:j.current.capabilities!==r}}),j.current={userId:s==null?void 0:s.id,apiKey:a,serviceConfig:n,capabilities:r},m.useEffect(()=>{const M=k.current;if(l("🔧 SERVICE INIT EFFECT TRIGGERED",{renderCount:M,apiKey:!!a,serviceConfig:!!n,dependencies:{apiKey:(a==null?void 0:a.substring(0,8))+"...",serviceConfigRef:n,serviceConfigStable:j.current.serviceConfig===n,apiKeyStable:j.current.apiKey===a}}),!a||!n){l("⚠️ SERVICE INIT SKIPPED",{renderCount:M,reason:"Missing apiKey or serviceConfig"});return}l("🚀 CREATING NEW SERVICE",{renderCount:M,apiKey:(a==null?void 0:a.substring(0,8))+"...",serviceConfigChanged:j.current.serviceConfig!==n});const A=new os.StreamChatService({...n,apiKey:a,debug:i});return d(A),l("✅ SERVICE SET",{renderCount:M,serviceInstance:!!A}),()=>{l("🧹 SERVICE CLEANUP",{renderCount:M,reason:"Effect cleanup"}),A.disconnectUser().catch(console.error)}},[a,n,i,l]);const S=m.useRef(null);m.useEffect(()=>{var A,R;if(l("🔗 USER CONNECTION EFFECT TRIGGERED",{hasService:!!o,hasUser:!!s,userId:s==null?void 0:s.id,isConnecting:N.current,isConnected:u,dependencies:{service:!!o,userId:s==null?void 0:s.id}}),!o||!s){l("⚠️ USER CONNECTION SKIPPED","Missing service or user");return}if(N.current){l("⚠️ USER CONNECTION SKIPPED","Already connecting");return}if(((A=S.current)==null?void 0:A.serviceId)===o&&((R=S.current)==null?void 0:R.userId)===s.id){l("⚠️ USER CONNECTION SKIPPED","Already connected this user with this service");return}(async()=>{l("🚀 STARTING USER CONNECTION",{userId:s.id}),N.current=!0,g(!0),p(null);try{l("📞 CALLING SERVICE.CONNECTUSER",{userId:s.id});const D=await o.connectUser(s);f(D),x(!0),S.current={serviceId:o,userId:s.id},l("✅ USER CONNECTION SUCCESS",{userId:s.id,clientId:D.userID})}catch(D){const E=D instanceof Error?D.message:"Connection failed";p(E),l("❌ USER CONNECTION ERROR",{userId:s.id,error:E})}finally{g(!1),N.current=!1,l("🔄 USER CONNECTION FINISHED",{userId:s.id,isConnected:u})}})()},[o,s,l,u]),m.useEffect(()=>(l("🔌 CLEANUP EFFECT REGISTERED",{hasService:!!o,isConnected:u}),()=>{o&&u?(l("🧹 CLEANUP EFFECT TRIGGERED","Cleaning up connection on unmount"),S.current=null,o.disconnectUser().catch(console.error)):l("🔇 CLEANUP EFFECT SKIPPED",{hasService:!!o,isConnected:u})}),[o,u,l]);const I=m.useCallback(async()=>{if(l("🔄 REFRESH CONNECTION CALLED",{hasService:!!o,hasUser:!!s}),!o||!s){l("⚠️ REFRESH CONNECTION SKIPPED","Missing service or user");return}l("🚀 STARTING CONNECTION REFRESH",{userId:s.id}),g(!0);try{l("🔌 DISCONNECTING FOR REFRESH"),await o.disconnectUser(),l("📞 RECONNECTING FOR REFRESH");const M=await o.connectUser(s);f(M),x(!0),p(null),l("✅ CONNECTION REFRESH SUCCESS",{userId:s.id})}catch(M){const A=M instanceof Error?M.message:"Refresh failed";p(A),l("❌ CONNECTION REFRESH ERROR",{userId:s.id,error:A})}finally{g(!1),l("🔄 CONNECTION REFRESH FINISHED",{userId:s.id})}},[o,s,l]),O=m.useMemo(()=>(l("💫 CONTEXT VALUE MEMOIZATION",{hasService:!!o,hasClient:!!h,isConnected:u,isLoading:c,hasError:!!v,capabilitiesKeys:Object.keys(r)}),{service:o,client:h,isConnected:u,isLoading:c,error:v,capabilities:r,refreshConnection:I,debug:i}),[o,h,u,c,v,r,I,i,l]);return l("🔄 RENDER END",{renderCount:k.current,willRenderChat:!!(h&&u),contextValueReady:!!O}),e.jsx(Ct.Provider,{value:O,children:h&&u?e.jsx(C.Chat,{client:h,customClasses:{channelList:"str-chat__channel-list str-chat__channel-list-react bg-transparent lg:border-r-2 border-r-0 border-[#0000000A]"},children:t}):t})},Nt=()=>Fe();function cs(t){const s=t.state.pending_messages;if(s!=null&&s.length)for(const n of s)t.state.addMessageSorted(n.message)}const yt=m.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,viewerLanguage:void 0}),ds=yt.Provider,us=()=>m.useContext(yt),_t=t=>{var a,r;const[s,n]=m.useState(!!((r=(a=t==null?void 0:t.state)==null?void 0:a.membership)!=null&&r.pinned_at));return m.useEffect(()=>{var l;if(!t){n(!1);return}n(!!((l=t.state.membership)!=null&&l.pinned_at));const i=o=>{var d;n(o!=null&&o.member?!!o.member.pinned_at:!!((d=t.state.membership)!=null&&d.pinned_at))};return t.on("member.updated",i),()=>{t.off("member.updated",i)}},[t]),s},ms=(t,s)=>{const n=new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())),r=new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())).getTime()-n.getTime();return Math.floor(r/(1e3*60*60*24))},kt=t=>{const s=new Date;if(Math.floor((s.getTime()-t.getTime())/1e3)<60)return"Just now";const a=ms(t,s);return a===0?t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):a===1?"Yesterday":a<7?`${a}d`:a<28?`${Math.floor(a/7)}w`:t.toLocaleDateString("en-US",{month:"numeric",day:"numeric",year:"2-digit"})};function St(t){return(t==null?void 0:t.trim().toLowerCase().split(/[-_]/)[0])||void 0}function Oe({message:t,viewerLanguage:s}){var r;const n=t==null?void 0:t.text,a=St(s);return a?((r=t==null?void 0:t.i18n)==null?void 0:r[`${a}_text`])??n:n}const hs=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function It(t){return hs.test(t.trim())}function gt(t,s){const n=t==null?void 0:t.trim();return!n||s&&n===s?!1:!It(n)}function ye(t){return gt(t==null?void 0:t.name,t==null?void 0:t.id)?t.name.trim():gt(t==null?void 0:t.username,t==null?void 0:t.id)?t.username.trim():"Unknown member"}const bt=["🍎","🍌","🍇","🍊","🍓","🥥","🍒","🥭","🍉","🍋","🥝","🫒","🍈"];function xs(t){let s=0;for(let n=0;n<t.length;n++){const a=t.charCodeAt(n);s=(s<<5)-s+a,s=s&s}return Math.abs(s)}function fs(t){const n=xs(t)%bt.length;return bt[n]}const Q=({id:t,image:s,size:n=40,className:a,starred:r=!1,shape:i="squircle",dmAgentEnabled:l=!1})=>{const o=fs(t),h=n<32?"text-xs":n<56?"text-sm":n<120?"text-lg":"text-4xl",f=n>=40?2:1,u=i==="circle"?{borderRadius:"50%"}:{borderRadius:"33%",cornerShape:"superellipse(1.3)"},x=e.jsx("div",{className:"h-full w-full overflow-hidden",style:u,children:s?e.jsx("img",{src:s,alt:"",className:"h-full w-full object-cover"}):e.jsx("div",{"aria-hidden":"true",className:y("avatar-fallback flex h-full w-full items-center justify-center bg-[#E6E5E3] font-semibold select-none transition-colors",h),children:o})});return e.jsxs("div",{className:y("relative flex-shrink-0 !bg-transparent",a),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`},children:[r&&e.jsx("div",{"aria-hidden":"true",className:"absolute -left-1.5 -top-1.5 z-10 flex size-5 items-center justify-center rounded-full bg-white shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",children:e.jsx(w.StarIcon,{className:"size-3 text-yellow-600",weight:"duotone"})}),e.jsx("div",{"data-testid":"avatar-ring",className:y("h-full w-full","bg-transparent"),style:{...u,...l&&{borderWidth:`${f}px`,borderStyle:"solid",borderColor:"var(--AI-Gradient, #7F22FE)",boxShadow:"inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"}},children:x})]})},gs=({size:t=15})=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 15 15",fill:"none","aria-hidden":"true",children:e.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})}),bs=t=>{var s;return((s=t.metadata)==null?void 0:s.custom_type)==="MESSAGE_TIP"},ps=t=>{var s;return((s=t.metadata)==null?void 0:s.custom_type)==="MESSAGE_PAID"},je=t=>{var s;return((s=t.metadata)==null?void 0:s.custom_type)==="MESSAGE_CHATBOT"},vs=t=>{var s;return((s=t.metadata)==null?void 0:s.custom_type)==="MESSAGE_ATTACHMENT"},Et=t=>bs(t)||ps(t),js=t=>{var s;return Et(t)&&!((s=t.text)!=null&&s.trim())},Ee=({message:t,standalone:s=!1,isMyMessage:n=!1,hasAttachment:a=!1})=>{var u;const r=Et(t),i=je(t);if(!r&&!i)return null;if(r){const x=(u=t.metadata)==null?void 0:u.amount_text;if(!x)return null;const c=s?"message-tip-standalone":"message-tag message-tag--tip",g=s?`${x} tip`:`Delivered with ${x} tip`;return e.jsxs("div",{className:c,children:[e.jsx(w.GiftIcon,{size:s?14:12}),e.jsx("span",{children:g})]})}const l=n&&a,o=l?"Sent with AI":"Sent with DM Agent",d=["message-chatbot-indicator",n?"message-chatbot-indicator--sender":"message-chatbot-indicator--receiver",l?"message-chatbot-indicator--attachment":"message-chatbot-indicator--text"].join(" "),h=e.jsx("span",{className:"message-chatbot-indicator__label",children:o}),f=e.jsx("span",{className:"message-chatbot-indicator__icon",children:e.jsx(gs,{size:l?12:15})});return e.jsx("div",{className:d,"data-testid":"message-chatbot-indicator",children:n&&!l?e.jsxs(e.Fragment,{children:[h,f]}):e.jsxs(e.Fragment,{children:[f,h]})})},Tt=m.memo(({channel:t,unread:s})=>{var O,M,A;const{selectedChannel:n,onChannelSelect:a,debug:r,renderMessagePreview:i,viewerLanguage:l}=us(),o=(n==null?void 0:n.id)===(t==null?void 0:t.id),d=()=>{t&&a(t)},h=R=>{const D=R.key==="Enter"||R.key===" ",E=R.repeat;!D||E||(R.preventDefault(),d())},u=Object.values(((O=t==null?void 0:t.state)==null?void 0:O.members)||{}).find(R=>{var D,E;return((D=R.user)==null?void 0:D.id)&&R.user.id!==((E=t==null?void 0:t._client)==null?void 0:E.userID)}),x=ye(u==null?void 0:u.user),c=(M=u==null?void 0:u.user)==null?void 0:M.image,g=(()=>{var D;const R=(D=t==null?void 0:t.state)==null?void 0:D.messages;if(R!=null&&R.length){for(let E=R.length-1;E>=0;E--)if(R[E].type!=="system")return R[E]}})(),p=(()=>{var L,$;const R=Oe({message:g,viewerLanguage:l});if(R)return R;if(((L=g==null?void 0:g.metadata)==null?void 0:L.custom_type)==="MESSAGE_TIP")return"💵 Sent a tip";const E=($=g==null?void 0:g.attachments)==null?void 0:$[0];return E?E.og_scrape_url?E.og_scrape_url:E.type==="image"?"📷 Sent an image":E.type==="video"?"🎥 Sent a video":E.type==="audio"?"🎵 Sent audio":E.type==="file"?"📎 Sent a file":"📎 Sent an attachment":"No messages yet"})(),N=g!=null&&g.created_at?kt(new Date(g.created_at)):"",j=g?je(g):!1,k=i?i(g,p):`${j?"✨ ":""}${p}`,S=_t(t),I=s??0;return r&&console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER",{channelId:t==null?void 0:t.id,isSelected:o,participantName:x,unreadCount:I,hasTimestamp:!!N}),e.jsx("div",{role:"button",tabIndex:0,onClick:d,onKeyDown:h,className:y("group w-full px-4 py-3 transition-colors text-left max-w-full overflow-hidden focus-ring",{"bg-primary-alt/10 border-l-4 border-l-primary":o,"hover:bg-sand":!o}),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Q,{id:((A=u==null?void 0:u.user)==null?void 0:A.id)||t.id||"unknown",name:x,image:c,size:44,starred:S,className:"[&_.avatar-fallback]:group-hover:bg-[#eeeeee]"}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("h3",{className:y("text-sm font-medium truncate",o?"text-primary":"text-charcoal"),children:[S&&e.jsx("span",{className:"sr-only",children:"Starred conversation. "}),x]}),N&&e.jsx("span",{className:"text-xs text-stone flex-shrink-0",children:N})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[e.jsx("p",{className:"text-xs text-stone flex-1 line-clamp-1",children:k}),I>0&&e.jsx("span",{className:"bg-[#7f22fe] text-white text-xs px-2 py-0.5 rounded-full min-w-[20px] text-center flex-shrink-0",children:I>99?"99+":I})]})]})]})})});Tt.displayName="CustomChannelPreview";const ws={last_message_at:-1},Pe=m.memo(({onChannelSelect:t,selectedChannel:s,filters:n,allowNewMessagesFromUnfilteredChannels:a=!1,onMessageNew:r,onAddedToChannel:i,channelRenderFilterFn:l,sort:o=ws,className:d,customEmptyStateIndicator:h,renderMessagePreview:f,viewerLanguage:u})=>{const x=m.useRef(0);x.current++;const{debug:c=!1}=Fe(),g=m.useCallback(p=>{for(const N of p)cs(N);return l?l(p):p},[l]);c&&console.log("📺 [ChannelList] 🔄 RENDER START",{renderCount:x.current,selectedChannelId:s==null?void 0:s.id,filters:n});const v=m.useMemo(()=>({selectedChannel:s,onChannelSelect:t,debug:c,renderMessagePreview:f,viewerLanguage:u}),[s,t,c,f,u]);return e.jsx("div",{className:y("messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",d),children:e.jsx("div",{className:"flex-1 overflow-hidden min-w-0",children:e.jsx(ds,{value:v,children:e.jsx(C.ChannelList,{filters:n,sort:o,options:{limit:30},allowNewMessagesFromUnfilteredChannels:a,onMessageNew:r,onAddedToChannel:i,channelRenderFilterFn:g,Preview:Tt,EmptyStateIndicator:h},`${JSON.stringify(n)}:${JSON.stringify(o)}`)})})})});Pe.displayName="ChannelList";const de=({variant:t="default",className:s,children:n,...a})=>{const r=t==="danger";return e.jsx("button",{type:"button",className:y("flex w-full items-center gap-3 rounded-lg px-4 py-3 text-left text-sm transition-colors focus-ring disabled:cursor-not-allowed disabled:opacity-60",r?"text-danger hover:bg-danger/50":"text-charcoal hover:bg-sand",s),...a,children:n})};function Cs({label:t,className:s,children:n,...a}){return e.jsxs("button",{type:"button",className:y("inline-flex items-center justify-center rounded-full transition-colors focus-ring p-2",{"cursor-not-allowed opacity-50":a.disabled,"hover:bg-sand":!a.disabled},s),...a,children:[e.jsx("span",{className:"sr-only",children:t}),n]})}function Ns({onClick:t}){return e.jsx(Cs,{label:"Close",onClick:t,className:"p-1",children:e.jsx(w.XIcon,{className:"h-5 w-5 text-stone",weight:"bold"})})}const ys=({dialogRef:t,onClose:s,participant:n,participantDisplayName:a,channel:r,followerStatusLabel:i,onLeaveConversation:l,onBlockParticipant:o,showDeleteConversation:d=!0,onDeleteConversationClick:h,onBlockParticipantClick:f,onReportParticipantClick:u,customProfileContent:x,customChannelActions:c})=>{var G,F,V,U;const{service:g,debug:v}=Fe(),[p,N]=m.useState(!1),[j,k]=m.useState(!1),[S,I]=m.useState(!1),O=m.useCallback(async()=>{var T;if(!(!g||!((T=n==null?void 0:n.user)!=null&&T.id)))try{const b=(await g.getBlockedUsers()).some(_=>{var z;return _.blocked_user_id===((z=n==null?void 0:n.user)==null?void 0:z.id)});N(b)}catch(P){console.error("[ChannelInfoDialog] Failed to check blocked status:",P)}},[g,(G=n==null?void 0:n.user)==null?void 0:G.id]);m.useEffect(()=>{O()},[O]);const M=async()=>{var T;if(!j){h==null||h(),v&&console.log("[ChannelInfoDialog] Leave conversation",r.cid),k(!0);try{const P=((T=r._client)==null?void 0:T.userID)??null;await r.hide(P,!1),l&&await l(r),s()}catch(P){console.error("[ChannelInfoDialog] Failed to leave conversation",P)}finally{k(!1)}}},A=async()=>{var T,P,b;if(!(S||!g)){f==null||f(),v&&console.log("[ChannelInfoDialog] Block member",(T=n==null?void 0:n.user)==null?void 0:T.id),I(!0);try{await g.blockUser((P=n==null?void 0:n.user)==null?void 0:P.id),o&&await o((b=n==null?void 0:n.user)==null?void 0:b.id),s()}catch(_){console.error("[ChannelInfoDialog] Failed to block member",_)}finally{I(!1)}}},R=async()=>{var T,P,b;if(!(S||!g)){f==null||f(),v&&console.log("[ChannelInfoDialog] Unblock member",(T=n==null?void 0:n.user)==null?void 0:T.id),I(!0);try{await g.unBlockUser((P=n==null?void 0:n.user)==null?void 0:P.id),o&&await o((b=n==null?void 0:n.user)==null?void 0:b.id),s()}catch(_){console.error("[ChannelInfoDialog] Failed to unblock member",_)}finally{I(!1)}}},D=()=>{u==null||u(),s(),window.open("https://linktr.ee/s/about/trust-center/report","_blank","noopener,noreferrer")};if(!n)return null;const E=a??ye(n.user),L=(F=n.user)==null?void 0:F.image,$=(V=n.user)==null?void 0:V.username,Y=$?`linktr.ee/${$}`:void 0,H=((U=n.user)==null?void 0:U.id)||"unknown";return e.jsx("dialog",{ref:t,className:"mes-dialog group",onClose:s,onClick:T=>{T.target===t.current&&s()},children:e.jsxs("div",{className:"ml-auto flex h-full w-full flex-col bg-white shadow-none transition-shadow duration-200 group-open:shadow-max-elevation-light",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-sand px-4 py-3",children:[e.jsx("h2",{className:"text-base font-semibold text-charcoal",children:"Chat info"}),e.jsx(Ns,{onClick:s})]}),e.jsxs("div",{className:"flex-1 px-2 overflow-y-auto w-full",children:[e.jsxs("div",{className:"flex flex-col items-center gap-3 self-stretch px-4 py-2 mt-6 rounded-lg border border-black/[0.04]",style:{backgroundColor:"#FBFAF9"},children:[e.jsxs("div",{className:"flex items-center gap-3 w-full",children:[e.jsx(Q,{id:H,name:E,image:L,size:88,shape:"circle"}),e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-base font-semibold text-charcoal",children:E}),Y&&e.jsx("p",{className:"truncate text-sm text-[#00000055]",children:Y}),i&&!x&&e.jsx("span",{className:"mt-1 rounded-full text-xs font-normal w-fit",style:{padding:"4px 8px",backgroundColor:i==="Subscribed to you"?"#DCFCE7":"#F5F5F4",color:i==="Subscribed to you"?"#008236":"#78716C",lineHeight:"133.333%",letterSpacing:"0.21px"},children:i})]})]}),x&&e.jsx("div",{className:"w-full",children:x})]}),e.jsxs("ul",{className:"flex flex-col gap-2 mt-2",children:[d&&e.jsx("li",{children:e.jsxs(de,{onClick:M,disabled:j,"aria-busy":j,children:[j?e.jsx(w.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):e.jsx(w.SignOutIcon,{className:"h-5 w-5"}),e.jsx("span",{children:"Delete Conversation"})]})}),e.jsx("li",{children:p?e.jsxs(de,{onClick:R,disabled:S,"aria-busy":S,children:[S?e.jsx(w.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):e.jsx(w.ProhibitInsetIcon,{className:"h-5 w-5"}),e.jsx("span",{children:"Unblock"})]}):e.jsxs(de,{onClick:A,disabled:S,"aria-busy":S,children:[S?e.jsx(w.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):e.jsx(w.ProhibitInsetIcon,{className:"h-5 w-5"}),e.jsx("span",{children:"Block"})]})}),e.jsx("li",{children:e.jsxs(de,{variant:"danger",onClick:D,children:[e.jsx(w.FlagIcon,{className:"h-5 w-5"}),e.jsx("span",{children:"Report"})]})}),c]})]})]})})},_s=t=>e.jsx(C.DateSeparator,{...t,position:"center"}),Re="vote_up",Le="vote_down";function ks(t){return t!=null&&t.length?t.some(s=>s.type===Le)?"down":t.some(s=>s.type===Re)?"up":null:null}function Mt(t){const{channel:s}=C.useChannelStateContext(),{client:n}=C.useChatContext("useMessageVote"),a=m.useMemo(()=>ks(t.own_reactions),[t.own_reactions]),r=m.useCallback(async()=>{if(n!=null&&n.userID)try{a==="up"?await s.deleteReaction(t.id,Re):await s.sendReaction(t.id,{type:Re},{enforce_unique:!0,skip_push:!0})}catch{}},[s,n==null?void 0:n.userID,t.id,a]),i=m.useCallback(async()=>{if(n!=null&&n.userID)try{a==="down"?await s.deleteReaction(t.id,Le):await s.sendReaction(t.id,{type:Le},{enforce_unique:!0,skip_push:!0})}catch{}},[s,n==null?void 0:n.userID,t.id,a]);return{selected:a,voteUp:r,voteDown:i}}const Ss=m.lazy(()=>Promise.resolve().then(()=>require("./Card-ot16XqS2.cjs"))),Is=m.lazy(()=>Promise.resolve().then(()=>require("./Card-CgpHBx-W.cjs"))),Es=m.lazy(()=>Promise.resolve().then(()=>require("./Card-CexShqpK.cjs"))),ze=()=>e.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}),Ts=t=>e.jsx(m.Suspense,{fallback:e.jsx(ze,{}),children:e.jsx(Ss,{...t})}),At=t=>e.jsx(m.Suspense,{fallback:e.jsx(ze,{}),children:e.jsx(Is,{...t})}),Rt=t=>e.jsx(m.Suspense,{fallback:e.jsx(ze,{}),children:e.jsx(Es,{...t})}),Ms=At,As=Rt,De={Composer:Ts,Sent:At,Received:Rt,Creator:Ms,Visitor:As},Rs=[[/pdf/,"pdf"],[/wordprocessingml|msword|\.doc/,"doc"],[/spreadsheetml|ms-excel|\.xls/,"xls"],[/csv/,"csv"],[/presentationml|ms-powerpoint|\.ppt/,"ppt"],[/zip|x-rar|x-7z|x-tar|x-gzip/,"zip"],[/plain|rtf/,"text"],[/markdown/,"markdown"]];function te(t){return t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.startsWith("image/")?"image":"document"}function Lt(t){const s=Rs.find(([n])=>n.test(t));return s?s[1]:"generic"}const Ls={video:w.VideoCameraIcon,audio:w.SpeakerHighIcon,image:w.ImageIcon,document:w.FileIcon},Ds={pdf:w.FilePdfIcon,doc:w.FileDocIcon,xls:w.FileXlsIcon,csv:w.FileCsvIcon,ppt:w.FilePptIcon,zip:w.FileZipIcon,text:w.FileTextIcon,markdown:w.FileMdIcon,generic:w.FileIcon};function Fs(t){const s=te(t);return s!=="document"?Ls[s]:Ds[Lt(t)]}function ie(t,s){return m.createElement(Fs(t),s)}const Os=t=>{var s,n;return"touches"in t?((s=t.touches[0])==null?void 0:s.clientX)??((n=t.changedTouches[0])==null?void 0:n.clientX)??0:t.clientX},Ps=({source:t,mimeType:s,poster:n,autoPlay:a=!1,playing:r,loop:i=!1,controls:l=!0,showProgress:o=!1,muted:d=!1,onContainerClick:h})=>{const f=te(s),u=m.useRef(null),x=m.useRef(null),c=m.useRef(null),g=m.useRef(r),[v,p]=m.useState(a),[N,j]=m.useState(0),[k,S]=m.useState(!1),[I,O]=m.useState(!1),[M,A]=m.useState(!1),[R,D]=m.useState(!1),[E,L]=m.useState(!0),[$,Y]=m.useState(null),H=m.useCallback(()=>{A(!1),p(!0)},[]),G=m.useCallback(b=>{const _=x.current;if(!_)return 0;const z=_.getBoundingClientRect();return Math.max(0,Math.min(1,(Os(b)-z.left)/z.width))},[]),F=m.useCallback(b=>{const _=u.current;_&&_.duration&&(_.currentTime=b*_.duration)},[]),V=b=>{b.stopPropagation(),S(!0);const _=G(b);j(_),F(_)};m.useEffect(()=>{r!==void 0&&r!==g.current&&(g.current=r,p(r))},[r]),m.useEffect(()=>{if(!v){c.current!==null&&(cancelAnimationFrame(c.current),c.current=null);return}const b=()=>{const _=u.current;_&&_.duration&&!k&&j(_.currentTime/_.duration),c.current=requestAnimationFrame(b)};return c.current=requestAnimationFrame(b),()=>{c.current!==null&&cancelAnimationFrame(c.current)}},[v,k]),m.useEffect(()=>{const b=u.current;b&&(v?b.play().catch(_=>{p(!1),A(!0)}):b.pause())},[v]),m.useEffect(()=>{if(!k)return;const b=z=>j(G(z)),_=z=>{S(!1),F(G(z))};return window.addEventListener("mousemove",b),window.addEventListener("mouseup",_),window.addEventListener("touchmove",b,{passive:!0}),window.addEventListener("touchend",_),()=>{window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",_),window.removeEventListener("touchmove",b),window.removeEventListener("touchend",_)}},[k,G,F]);const U=$?{aspectRatio:String($)}:void 0,T=$?"":" aspect-video",P=Math.round(N*100);return e.jsxs("div",{role:"button",tabIndex:0,className:`relative cursor-pointer overflow-hidden bg-black ${T}`,style:U,onClick:b=>{if(h){h(b);return}M||l&&p(_=>!_)},onKeyDown:b=>{if(!(b.key!=="Enter"&&b.key!==" ")){if(b.preventDefault(),h){h(b);return}M||l&&p(_=>!_)}},children:[n&&(f==="audio"||E)&&e.jsx("img",{src:n,alt:"",className:"absolute inset-0 h-full w-full object-cover"}),!n&&(f==="audio"||E)&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:ie(s,{className:"size-12 text-black/20",weight:"regular"})}),e.jsx("div",{className:"absolute inset-0",children:f==="audio"?e.jsx("audio",{ref:u,src:t,loop:i,muted:d,style:{width:"100%",height:"100%"},onLoadStart:()=>D(!0),onCanPlay:()=>{D(!1),L(!1)},onWaiting:()=>D(!0),onPlay:()=>A(!1),onEnded:()=>{i||(p(!1),j(0))},children:e.jsx("track",{kind:"captions"})}):e.jsx("video",{ref:u,src:t,loop:i,muted:d,playsInline:!0,style:{width:"100%",height:"100%"},onLoadStart:()=>D(!0),onCanPlay:()=>{D(!1),L(!1)},onWaiting:()=>D(!0),onPlay:()=>A(!1),onLoadedMetadata:()=>{const b=u.current;b instanceof HTMLVideoElement&&b.videoWidth&&b.videoHeight&&Y(b.videoWidth/b.videoHeight)},onEnded:()=>{i||(p(!1),j(0))},children:e.jsx("track",{kind:"captions"})})}),R&&!M&&e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:e.jsx(w.CircleNotchIcon,{className:"size-8 animate-spin text-white/80",weight:"bold"})}),M&&!l&&e.jsx("div",{className:"absolute inset-0 z-30 flex cursor-pointer items-center justify-center bg-black/35",role:"button",tabIndex:0,"aria-label":"Play preview",onClick:b=>{b.stopPropagation(),H()},onKeyDown:b=>{b.key!=="Enter"&&b.key!==" "||(b.preventDefault(),b.stopPropagation(),H())},children:e.jsx("span",{className:"flex size-16 items-center justify-center rounded-full bg-white/20 text-white backdrop-blur-sm",children:e.jsx(w.PlayIcon,{className:"size-9 translate-x-0.5",weight:"fill"})})}),o&&!l&&e.jsx("div",{className:"absolute inset-x-0 bottom-0 px-3 pb-2.5 pt-6 bg-gradient-to-t from-black/40 to-transparent",children:e.jsx("div",{role:"slider","aria-label":"Playback position","aria-valuenow":P,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:x,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:V,onTouchStart:V,onClick:b=>b.stopPropagation(),onKeyDown:b=>{b.key==="ArrowRight"&&F(Math.min(1,N+.05)),b.key==="ArrowLeft"&&F(Math.max(0,N-.05))},children:e.jsx("div",{className:"w-full overflow-hidden rounded-full bg-white/30 h-1",children:e.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${P}%`}})})})}),l&&e.jsxs("div",{className:"absolute inset-x-0 bottom-0 flex items-center gap-2 bg-gradient-to-t from-black/60 to-transparent px-3 pb-2.5 pt-6 transition-all duration-200",children:[e.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),p(_=>!_)},className:"shrink-0 text-white","aria-label":v?"Pause":"Play",children:v?e.jsx(w.PauseIcon,{className:"size-5",weight:"fill"}):e.jsx(w.PlayIcon,{className:"size-5 translate-x-px",weight:"fill"})}),e.jsxs("div",{role:"slider","aria-label":"Playback position","aria-valuenow":P,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:x,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:V,onTouchStart:V,onClick:b=>b.stopPropagation(),onMouseEnter:()=>O(!0),onMouseLeave:()=>O(!1),onKeyDown:b=>{b.key==="ArrowRight"&&F(Math.min(1,N+.05)),b.key==="ArrowLeft"&&F(Math.max(0,N-.05))},children:[e.jsx("div",{className:`w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${I||k?"h-1.5":"h-1"}`,children:e.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${P}%`}})}),e.jsx("div",{className:`absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${I||k?"scale-100 opacity-100":"scale-0 opacity-0"}`,style:{left:`${P}%`}})]})]})]})},pt=t=>t==="dark"?"size-12 text-white/20":"size-12 text-black/20",zs=t=>t==="dark"?"aspect-video overflow-hidden bg-white/10":"aspect-video overflow-hidden bg-black/5",Be=({mimeType:t,sourceUrl:s,thumbnailUrl:n,title:a,variant:r,mediaPlayerProps:i,containedImage:l=!1})=>{const o=te(t),[d,h]=m.useState(!1);return s&&(o==="video"||o==="audio")?e.jsx(Ps,{source:s,mimeType:t,poster:n,controls:!0,...i}):s&&o==="image"?l?e.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:e.jsx("img",{src:s,alt:a??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${d?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>h(!0)})}):e.jsx("img",{src:s,alt:a??"",className:"block w-full",draggable:!1}):s&&o==="document"?n?l?e.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:e.jsx("img",{src:n,alt:a??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${d?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>h(!0)})}):e.jsx("img",{src:n,alt:"",className:"block w-full",draggable:!1}):e.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${r==="dark"?"bg-white/10":"bg-black/5"}`,children:ie(t,{className:pt(r),weight:"regular"})}):n?e.jsx("div",{className:`relative ${zs(r)}`,children:e.jsx("img",{src:n,alt:a??"",draggable:!1,className:"absolute inset-0 h-full w-full object-cover"})}):e.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${r==="dark"?"bg-white/10":"bg-black/5"}`,children:ie(t,{className:pt(r),weight:"regular"})})},Dt=({variant:t,thumbnail:s,title:n,placeholderTitle:a="Attachment title",mimeType:r,detail:i,statusBadge:l,action:o,topLeft:d,topRight:h,rootRef:f,"data-testid":u})=>{const x=t==="dark",c=x?n??a:n??"",g=x&&!n;return e.jsxs("div",{ref:f,"data-testid":u,className:y("relative w-[280px] select-none overflow-hidden rounded-[24px] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",x?"bg-[#121110]":"bg-white"),children:[d?e.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-50",children:d}):null,h?e.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-50",children:h}):null,s,e.jsxs("div",{className:"px-4 pb-3 pt-3",children:[c.trim()!==""&&e.jsx("p",{className:y("mb-0.5 truncate text-base font-medium",{"text-black":!x,"text-white/30":x&&g,"text-white":x&&!g}),children:c}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[ie(r,{className:y("size-5 shrink-0",x?"text-white/55":"text-black/55"),weight:"regular"}),i!=null&&i!==""&&e.jsx("span",{className:y("text-xs font-medium",x?"text-white/55":"text-black/55"),children:i}),l]}),o]})]})};function Ft(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function $e(t){return`w-[280px] select-none overflow-hidden rounded-[24px] ${t?"bg-[#121110]":"bg-[#F3F3F1]"} shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]`}function Bs(t){return t?"bg-white/10":"bg-black/5"}function $s(t){return t?"text-white":"text-black"}function Vs(t){return t?"text-white/55":"text-black/55"}function Us(t){return t?"text-white/40":"text-black/40"}function Gs(t){return t?"text-white/20":"text-black/20"}const Ve=({attachment:t,isMyMessage:s})=>{const{title:n,text:a,image_url:r,og_scrape_url:i,title_link:l}=t,o=i??l,d=typeof o=="string"&&o.trim()!==""?o:void 0,h=e.jsxs(m.Fragment,{children:[e.jsx("div",{className:"p-2",children:r?e.jsx("img",{src:r,alt:n??"",className:"aspect-video w-full rounded-[20px] object-cover"}):e.jsx("div",{className:`aspect-video w-full rounded-[20px] ${Bs(s)} flex items-center justify-center`,children:e.jsx(w.LinkIcon,{className:`size-12 ${Gs(s)}`})})}),e.jsxs("div",{className:"px-3 pb-3",children:[n&&e.jsx("p",{className:`truncate text-[14px] font-medium leading-5 ${$s(s)}`,children:n}),a&&e.jsx("p",{className:`truncate text-[12px] leading-4 ${Vs(s)}`,children:a}),d&&e.jsx("p",{className:`mt-1 truncate text-[12px] leading-4 ${Us(s)}`,children:d})]})]});return d?e.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"block no-underline",children:h}):e.jsx("div",{className:"block",children:h})};function Ue(t){return t.type==="link"||!!t.og_scrape_url&&!t.asset_url}function _e(t){var s;return(s=t.attachments)==null?void 0:s.find(Ue)}async function Hs(t,s){let n;try{n=s??new URL(t).pathname.split("/").pop()??"download"}catch{n=s??"download"}const a=await fetch(t,{mode:"cors"});if(!a.ok)throw new Error(`HTTP ${a.status}`);const r=await a.blob(),i=URL.createObjectURL(r),l=document.createElement("a");l.href=i,l.download=n,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)}const Ys=({url:t,filename:s})=>{const[n,a]=m.useState(!1),r=i=>{i.stopPropagation();const l=window.open("","_blank","noopener,noreferrer");a(!0),Hs(t,s).then(()=>{l==null||l.close()}).catch(()=>{l&&(l.location.href=t)}).finally(()=>a(!1))};return e.jsx("button",{type:"button",onClick:r,disabled:n,className:"mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounded-full bg-[#121110] px-4 text-sm font-medium leading-none text-white hover:bg-[#2a2928] disabled:opacity-70",children:n?e.jsx(w.CircleNotchIcon,{className:"size-4 animate-spin text-white",weight:"bold"}):e.jsxs(m.Fragment,{children:[e.jsx(w.DownloadSimpleIcon,{className:"size-4 text-white",weight:"bold"}),"Download"]})})};function ke(t){var u,x,c,g;const s=(u=t.attachments)==null?void 0:u.find(v=>v.type==="video"&&v.asset_url),n=(x=t.attachments)==null?void 0:x.find(v=>v.type==="image"&&v.image_url),a=(c=t.attachments)==null?void 0:c.find(v=>v.type==="audio"&&v.asset_url),r=(g=t.attachments)==null?void 0:g.find(v=>v.type==="file"&&v.asset_url),i=s??n??a??r,l=(s==null?void 0:s.asset_url)??(n==null?void 0:n.image_url)??(a==null?void 0:a.asset_url)??(r==null?void 0:r.asset_url);if(!l)return null;const o=(i==null?void 0:i.mime_type)??((i==null?void 0:i.type)==="image"?"image/jpeg":(i==null?void 0:i.type)==="video"?"video/mp4":(i==null?void 0:i.type)==="audio"?"audio/mpeg":"application/octet-stream"),d=i==null?void 0:i.title,h=i==null?void 0:i.file_size,f=s==null?void 0:s.thumb_url;return{resolvedUrl:l,resolvedType:o,title:d,fileSize:h,thumbnailUrl:f}}const Ot=({resolvedUrl:t,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=a!==void 0?Ft(a):void 0;return e.jsx(Dt,{variant:"dark",title:n,placeholderTitle:"",mimeType:s,detail:i,thumbnail:e.jsx(Be,{mimeType:s,sourceUrl:t,thumbnailUrl:r,title:n,variant:"dark"})})},Pt=({resolvedUrl:t,resolvedType:s,title:n,fileSize:a,thumbnailUrl:r})=>{const i=te(s),l=a!==void 0?Ft(a):void 0;return e.jsx(Dt,{variant:"light",title:n,mimeType:s,detail:l,thumbnail:e.jsx(Be,{mimeType:s,sourceUrl:t,thumbnailUrl:r,title:n,variant:"light",containedImage:i==="image"||i==="document"}),action:e.jsx(Ys,{url:t,filename:n})})},qs=({message:t,isMyMessage:s=!1})=>{const n=_e(t),a=ke(t);if(!n&&!a)return null;const r=s?"str-chat__message str-chat__message-simple str-chat__message--me str-chat__message-simple--me":"str-chat__message str-chat__message-simple str-chat__message--other";return e.jsxs("div",{className:r,children:[!s&&t.user&&e.jsx(Q,{className:"str-chat__avatar str-chat__message-sender-avatar",id:t.user.id,image:t.user.image,name:t.user.name??t.user.id}),e.jsx("div",{className:"str-chat__message-inner",style:{marginInlineEnd:0,marginInlineStart:0},children:e.jsx("div",{className:"str-chat__message-bubble-wrapper",children:e.jsx("div",{className:"str-chat__message-bubble",style:{padding:0,borderRadius:0,overflow:"visible",background:"transparent"},children:n?e.jsx("div",{className:$e(s),children:e.jsx(Ve,{attachment:n,isMyMessage:s})}):s?e.jsx(Ot,{...a}):e.jsx(Pt,{...a})})})})]})},Ws=({message:t})=>{const s=_e(t);if(s)return e.jsx("div",{className:$e(!0),children:e.jsx(Ve,{attachment:s,isMyMessage:!0})});const n=ke(t);return n?e.jsx(Ot,{...n}):null},Xs=({message:t})=>{const s=_e(t);if(s)return e.jsx("div",{className:$e(!1),children:e.jsx(Ve,{attachment:s,isMyMessage:!1})});const n=ke(t);return n?e.jsx(Pt,{...n}):null},Zs=Object.assign(qs,{Creator:Ws,Visitor:Xs}),Ks={isUnlocking:()=>!1},Js={LockedAttachment:Ks},zt=m.createContext({}),Qs=zt.Provider;function Bt(t){return m.useContext(zt)[t]??Js[t]}const $t=({selected:t,onVoteUp:s,onVoteDown:n})=>e.jsxs("div",{className:"message-vote-buttons",children:[e.jsx("button",{type:"button",className:y("message-vote-button focus-ring",{"message-vote-button--selected":t==="up"}),onClick:s,"aria-label":"Good response","aria-pressed":t==="up","data-tooltip":"Good response",children:e.jsx(w.ThumbsUpIcon,{size:16,weight:t==="up"?"fill":"regular"})}),e.jsx("button",{type:"button",className:y("message-vote-button focus-ring",{"message-vote-button--selected":t==="down"}),onClick:n,"aria-label":"Bad response","aria-pressed":t==="down","data-tooltip":"Bad response",children:e.jsx(w.ThumbsDownIcon,{size:16,weight:t==="down"?"fill":"regular"})})]}),en=t=>{var Qe,et,tt,st,nt,at,rt,it,ot,lt,ct,dt,ut,mt;const{additionalMessageInputProps:s,chatbotVotingEnabled:n,editing:a,endOfGroup:r,firstOfGroup:i,groupedByUser:l,handleAction:o,handleOpenThread:d,handleRetry:h,highlighted:f,isMessageAIGenerated:u,isMyMessage:x,message:c,renderText:g,threadList:v,viewerLanguage:p}=t,{client:N}=C.useChatContext("CustomMessage"),{channel:j}=C.useChannelStateContext("CustomMessage"),{isUnlocking:k,onUnlockClick:S,onFetchSource:I,onDownloadClick:O}=Bt("LockedAttachment"),[M,A]=m.useState(!1),R=C.useMessageReminder(c.id),{selected:D,voteUp:E,voteDown:L}=Mt(c),{Attachment:$=C.Attachment,EditMessageModal:Y=C.EditMessageModal,MessageBlocked:H=C.MessageBlocked,MessageBouncePrompt:G=C.MessageBouncePrompt,MessageDeleted:F=C.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:V=C.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:U=C.MessageRepliesCountButton,ReminderNotification:T=C.ReminderNotification,StreamedMessageText:P=C.StreamedMessageText,PinIndicator:b}=C.useComponentContext("CustomMessage"),_=C.messageHasAttachments(c),z=C.messageHasReactions(c),q=m.useMemo(()=>u==null?void 0:u(c),[u,c]),W=m.useMemo(()=>{const ce=c.attachments??[],pe=c.shared_location?[c.shared_location,...ce]:ce;if(!je(c))return pe;const ht=pe.filter(xt=>!("type"in xt)||!Ue(xt));return ht.length===pe.length?pe:ht},[c]),K=m.useMemo(()=>{const ce=Oe({message:c,viewerLanguage:p});return ce===c.text?c:{...c,text:ce}},[c,p]);if(C.isDateSeparatorMessage(c))return null;if(c.deleted_at||c.type==="deleted")return e.jsx(F,{message:c});if(C.isMessageBlocked(c))return e.jsx(H,{});const fe=!v&&!!c.reply_count,ge=!v&&c.show_in_channel&&c.parent_id,ae=c.status==="failed"&&((Qe=c.error)==null?void 0:Qe.status)!==403,J=C.isMessageBounced(c);let se;ae?se=()=>h(c):J&&(se=()=>A(!0));const re=x(),Ie=y("str-chat__message str-chat__message-simple",`str-chat__message--${c.type}`,`str-chat__message--${c.status}`,re?"str-chat__message--me str-chat__message-simple--me":"str-chat__message--other",c.text?"str-chat__message--has-text":"has-no-text",{"str-chat__message--has-attachment":_,"str-chat__message--highlighted":f,"str-chat__message--pinned pinned-message":c.pinned,"str-chat__message--with-reactions":z,"str-chat__message-send-can-be-retried":(c==null?void 0:c.status)==="failed"&&((et=c==null?void 0:c.error)==null?void 0:et.status)!==403,"str-chat__message-with-thread-link":fe||ge,"str-chat__virtual-message__wrapper--end":r,"str-chat__virtual-message__wrapper--first":i,"str-chat__virtual-message__wrapper--group":l}),be=c.poll_id&&N.polls.fromState(c.poll_id),oe=js(c),B=je(c),X=vs(c),Z=!!(W!=null&&W.length&&!c.quoted_message),ne=B&&re&&Z;return e.jsxs(e.Fragment,{children:[a&&e.jsx(Y,{additionalMessageInputProps:s}),M&&e.jsx(C.MessageBounceModal,{MessageBouncePrompt:G,onClose:()=>A(!1),open:M}),e.jsxs("div",{className:Ie,children:[b&&e.jsx(b,{}),!!R&&e.jsx(T,{reminder:R}),c.user&&e.jsx(Q,{className:"str-chat__avatar str-chat__message-sender-avatar",id:c.user.id,image:c.user.image,name:c.user.name||c.user.id,size:B?24:28,shape:"circle",dmAgentEnabled:B}),e.jsx("div",{className:y("str-chat__message-inner",{"str-chat__simple-message--error-failed":ae||J}),"data-testid":"message-inner",onClick:se,onKeyDown:se,role:se?"button":void 0,tabIndex:se?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:X?e.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[re?e.jsx(De.Sent,{title:(tt=c.metadata)==null?void 0:tt.attachment_title,mimeType:(st=c.metadata)==null?void 0:st.attachment_mime_type,thumbnailUrl:(nt=c.metadata)==null?void 0:nt.attachment_thumbnail,amountText:(at=c.metadata)==null?void 0:at.amount_text,detail:(rt=c.metadata)==null?void 0:rt.attachment_detail,paymentStatus:(it=c.metadata)==null?void 0:it.payment_status,onPreviewClick:()=>S==null?void 0:S(c,j),onFetchSource:async()=>await(I==null?void 0:I(c,j))}):e.jsx(De.Received,{title:(ot=c.metadata)==null?void 0:ot.attachment_title,mimeType:(lt=c.metadata)==null?void 0:lt.attachment_mime_type,thumbnailUrl:(ct=c.metadata)==null?void 0:ct.attachment_thumbnail,amountText:(dt=c.metadata)==null?void 0:dt.amount_text,detail:(ut=c.metadata)==null?void 0:ut.attachment_detail,paymentStatus:(mt=c.metadata)==null?void 0:mt.payment_status,isUnlocking:k(c.id),onUnlockClick:()=>S==null?void 0:S(c,j),onFetchSource:async()=>await(I==null?void 0:I(c,j)),onDownloadClick:()=>O==null?void 0:O(c,j)}),c.text&&e.jsx("div",{className:"str-chat__message-bubble",children:e.jsx(C.MessageText,{message:K,renderText:g})})]}):oe?e.jsx(Ee,{message:c,standalone:!0}):e.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[e.jsxs("div",{className:"str-chat__message-bubble",children:[B&&!ne&&e.jsx(Ee,{message:c,hasAttachment:Z,isMyMessage:re}),be&&e.jsx(C.Poll,{poll:be}),W!=null&&W.length&&!c.quoted_message?e.jsx($,{actionHandler:o,attachments:W}):null,q?e.jsx(P,{message:K,renderText:g}):e.jsx(C.MessageText,{message:K,renderText:g}),e.jsx(C.MessageErrorIcon,{})]}),(!B||ne)&&e.jsx(Ee,{message:c,hasAttachment:Z,isMyMessage:re}),n&&B&&e.jsx($t,{selected:D,onVoteUp:E,onVoteDown:L})]})}),fe&&e.jsx(U,{onClick:d,reply_count:c.reply_count}),ge&&e.jsx(V,{})]},c.id)]})},tn=m.memo(en,(t,s)=>t.chatbotVotingEnabled!==s.chatbotVotingEnabled||t.viewerLanguage!==s.viewerLanguage?!1:C.areMessageUIPropsEqual(t,s)),sn=t=>{const s=C.useMessageContext("CustomMessage");return e.jsx(tn,{...s,...t})},nn=t=>({linkPreviews:Array.from(t.previews.values()).filter(s=>ft.LinkPreviewsManager.previewIsLoaded(s)||ft.LinkPreviewsManager.previewIsLoading(s))}),an=({link:t,onDismiss:s})=>{const{og_scrape_url:n,title:a,image_url:r}=t,i=l=>{l.preventDefault(),s(n)};return e.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"relative w-full block rounded-[24px] bg-[#121110] p-2 no-underline transition-opacity hover:opacity-90",children:[r&&e.jsx("img",{src:r,alt:a||"",className:"h-[148px] w-full rounded-[20px] object-cover"}),e.jsx("button",{type:"button",onClick:i,className:"absolute right-4 top-4 flex size-6 items-center justify-center rounded-full border border-white/40 bg-white/70 backdrop-blur-2xl focus-ring","aria-label":"Close link preview",children:e.jsx(w.XIcon,{className:"size-4 text-black/90"})}),e.jsxs("div",{className:"p-2",children:[a&&e.jsx("div",{className:"text-[14px] font-medium leading-5 text-white",children:a}),e.jsx("div",{className:"text-[12px] leading-4 text-white/55",children:n})]})]})},rn=()=>{const{linkPreviewsManager:t}=C.useMessageComposer(),{linkPreviews:s}=C.useStateStore(t.state,nn),n=r=>{t.dismissPreview(r)};return s.length>0?e.jsx("div",{className:"flex flex-col items-center w-full gap-2 mb-4",children:s.map(r=>e.jsx(an,{link:r,onDismiss:n},r.og_scrape_url))}):null},on=({sendMessage:t,disabled:s,...n})=>e.jsx("button",{...n,type:"button","aria-label":"Send",disabled:s,onClick:t,children:e.jsx(w.ArrowUpIcon,{weight:"bold",className:"size-4"})}),ln=()=>{var o;const{channel:t}=C.useChannelStateContext(),s=((o=t==null?void 0:t.data)==null?void 0:o.frozen)===!0,{handleSubmit:n}=C.useMessageInputContext(),{SendButton:a}=C.useComponentContext("CustomMessageInput"),r=a??on,i=C.useMessageComposerHasSendableData(),l=s||!i;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"left-container",children:e.jsx(C.SimpleAttachmentSelector,{})}),e.jsxs("div",{className:"central-container min-w-0 w-full p-2 bg-white rounded-[1.5rem] shadow-[0_4px_16px_0_rgba(0,0,0,0.08),0_1px_2px_0_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.04)]",children:[e.jsx(C.QuotedMessagePreview,{}),e.jsx(rn,{}),e.jsx(C.AttachmentPreviewList,{}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"w-full ml-2 mr-4 self-center leading-[0]",children:e.jsx(C.TextareaComposer,{"aria-disabled":s||void 0,className:"w-full resize-none outline-none leading-6",maxRows:4,readOnly:s,tabIndex:s?-1:void 0})}),e.jsx(r,{sendMessage:n,"aria-label":"Send",className:"str-chat__send-button mt-auto flex justify-center items-center flex-shrink-0 rounded-full size-8 bg-[#121110] disabled:bg-[#F1F0EE] disabled:text-black/20 text-white focus-ring","data-testid":"send-button",disabled:l,type:"button"})]})]})]})},cn=({renderActions:t})=>{var a;const{channel:s}=C.useChannelStateContext(),n=((a=s==null?void 0:s.data)==null?void 0:a.frozen)===!0;return e.jsxs("div",{inert:n?"":void 0,"aria-disabled":n||void 0,className:"message-input flex items-center gap-2 p-4 aria-disabled:opacity-40",children:[t==null?void 0:t(),e.jsx(C.MessageInput,{Input:ln})]})},dn=["SYSTEM_DM_AGENT_PAUSED","SYSTEM_DM_AGENT_RESUMED"],un={SYSTEM_DM_AGENT_PAUSED:"DM Agent has left the conversation",SYSTEM_DM_AGENT_RESUMED:"DM Agent has rejoined the conversation"},mn=["SYSTEM_AGE_SAFETY_BLOCKED"],hn={SYSTEM_AGE_SAFETY_BLOCKED:"This user isn’t able to reply because they don’t meet our age safety guidelines."},Te="age safety guidelines.",xn="https://linktr.ee/s/about/contact",vt=t=>dn.includes(t),fn=t=>mn.includes(t),gn=t=>{var a;const s=(a=t.metadata)==null?void 0:a.custom_type;if(vt(s))return{kind:"dm-agent",type:s};if(fn(s))return{kind:"age-safety",type:s};const n=t.dm_agent_system_type;if(vt(n))return{kind:"dm-agent",type:n}},bn=t=>{const s=t.indexOf(Te);if(s===-1)return t;const n=s+Te.length;return e.jsxs(e.Fragment,{children:[t.slice(0,s),e.jsx("a",{href:xn,target:"_blank",rel:"noopener noreferrer",className:"mes-age-safety-system-message__emphasis font-medium text-inherit underline",children:Te}),t.slice(n)]})},pn=t=>{var a,r;const s=t.message.hide_date===!0,n=gn(t.message);if((n==null?void 0:n.kind)==="dm-agent"){const i=((a=t.message.text)==null?void 0:a.trim())||un[n.type];return e.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[e.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:[e.jsx(w.SparkleIcon,{size:16,weight:"regular","aria-hidden":!0,className:"mes-dm-agent-system-message__sparkle shrink-0"}),e.jsx("p",{className:"mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]",children:i})]}),!s&&e.jsx(C.MessageTimestamp,{message:t.message})]})}if((n==null?void 0:n.kind)==="age-safety"){const i=((r=t.message.text)==null?void 0:r.trim())||hn[n.type];return e.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[e.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:[e.jsx(w.ProhibitIcon,{size:24,weight:"duotone","aria-hidden":!0,className:"mes-age-safety-system-message__icon shrink-0 text-[color:var(--text-warning-on-warning,#894b00)]","data-testid":"age-safety-system-message-icon"}),e.jsx("div",{className:"mes-age-safety-system-message__content min-w-0 flex-[1_0_0]",children:e.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:bn(i)})})]}),!s&&e.jsx(C.MessageTimestamp,{message:t.message})]})}return e.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[e.jsxs("div",{className:"str-chat__message--system__text",children:[e.jsx("div",{className:"str-chat__message--system__line"}),e.jsx("p",{children:t.message.text}),e.jsx("div",{className:"str-chat__message--system__line"})]}),!s&&e.jsx(C.MessageTimestamp,{message:t.message})]})},Vt=m.createContext(!1),Me=({cx:t,index:s})=>e.jsx("circle",{cx:t,cy:"4",r:"3.9",fill:"#A0A0A0",children:e.jsx("animateTransform",{attributeName:"transform",type:"translate",values:"0 0; 0 -2.25; 0 0;",dur:"900ms",begin:`${120*s}ms`,repeatCount:"indefinite"})}),vn=new Set([C.AIStates.Thinking,C.AIStates.Generating,C.AIStates.ExternalSources]),jn=({threadList:t})=>{var g,v;const{channel:s,channelConfig:n,thread:a}=C.useChannelStateContext(),{client:r}=C.useChatContext(),{typing:i={}}=C.useTypingContext(),{aiState:l}=C.useAIState(s),o=m.useContext(Vt);if(!t&&o&&vn.has(l)){const p=wn(s,(g=r.user)==null?void 0:g.id);return e.jsx(jt,{avatarId:(p==null?void 0:p.id)??"ai-agent",avatarName:(p==null?void 0:p.name)??(p==null?void 0:p.id)??"Agent",avatarImage:p==null?void 0:p.image,testId:"typing-indicator-ai"})}if((n==null?void 0:n.typing_events)===!1)return null;const h=t?[]:Object.values(i).filter(({parent_id:p,user:N})=>{var j;return(N==null?void 0:N.id)!==((j=r.user)==null?void 0:j.id)&&!p}),f=t?Object.values(i).filter(({parent_id:p,user:N})=>{var j;return(N==null?void 0:N.id)!==((j=r.user)==null?void 0:j.id)&&p===(a==null?void 0:a.id)}):[],u=t?f:h;if(!u.length)return null;const x=(v=u[0])==null?void 0:v.user,c=x!=null&&x.id&&s.state.members[x.id]?s.state.members[x.id].user:void 0;return e.jsx(jt,{avatarId:(x==null?void 0:x.id)??(c==null?void 0:c.id)??"typing-user",avatarName:(x==null?void 0:x.name)??(c==null?void 0:c.name)??(x==null?void 0:x.id)??"Typing user",avatarImage:(x==null?void 0:x.image)??(c==null?void 0:c.image),testId:"typing-indicator"})},jt=({avatarId:t,avatarName:s,avatarImage:n,testId:a})=>e.jsxs("div",{className:"str-chat__typing-indicator !items-end !bg-transparent","data-testid":a,style:{insetInlineStart:0,insetInlineEnd:"auto"},children:[e.jsx("div",{className:"shrink-0","aria-hidden":"true",children:e.jsx(Q,{id:t,name:s,image:n??void 0,size:24,shape:"circle"})}),e.jsx("div",{className:"px-4 py-3 rounded-lg bg-[#E9EAED] h-12 flex flex-col justify-end",children:e.jsxs("svg",{"aria-hidden":"true",className:"block overflow-visible mb-[0.2rem]",viewBox:"0 0 32 8",width:"32",height:"8",overflow:"visible",children:[e.jsx(Me,{cx:"4",index:0}),e.jsx(Me,{cx:"16",index:1}),e.jsx(Me,{cx:"28",index:2})]})})]});function wn(t,s){var a;const n=((a=t==null?void 0:t.state)==null?void 0:a.members)??{};for(const r of Object.values(n)){const i=r==null?void 0:r.user;if(i&&i.id!==s)return i}}const Ut=()=>null,Cn=({className:t,message:s})=>e.jsxs("div",{className:y("flex items-center justify-center h-full",t),children:[e.jsxs("svg",{viewBox:"0 0 100 100",className:"size-8 fill-pebble",stroke:"none",children:[e.jsx("circle",{cx:"6",cy:"50",r:"6",children:e.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 15 ; 0 -15; 0 15",repeatCount:"indefinite",begin:"0.1"})}),e.jsx("circle",{cx:"30",cy:"50",r:"6",children:e.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 10 ; 0 -10; 0 10",repeatCount:"indefinite",begin:"0.2"})}),e.jsx("circle",{cx:"54",cy:"50",r:"6",children:e.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 5 ; 0 -5; 0 5",repeatCount:"indefinite",begin:"0.3"})})]}),s&&e.jsx("span",{className:"text-stone",children:s})]}),we=m.memo(()=>e.jsx("div",{className:"messaging-loading-state flex items-center justify-center h-full",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(Cn,{className:"w-6 h-6"}),e.jsx("span",{className:"text-sm text-stone",children:"Loading messages"})]})}));we.displayName="LoadingState";const le="size-10 rounded-full bg-[#F1F0EE] hover:bg-[#E5E4E1] flex items-center justify-center transition-colors duration-150 focus-ring",wt="Replies instantly with AI assistant",Nn=({onBack:t,showBackButton:s,onShowInfo:n,canShowInfo:a,showStarButton:r=!1,dmAgentEnabled:i=!1,getParticipantDisplayName:l})=>{var c,g,v,p,N;const{channel:o}=C.useChannelStateContext(),d=m.useMemo(()=>{var S,I;const j=(S=o._client)==null?void 0:S.userID;return j?Object.values(((I=o.state)==null?void 0:I.members)||{}).find(O=>{var M;return((M=O.user)==null?void 0:M.id)&&O.user.id!==j}):void 0},[(c=o._client)==null?void 0:c.userID,(g=o.state)==null?void 0:g.members]),h=l(d),f=(v=d==null?void 0:d.user)==null?void 0:v.image,u=_t(o),x=async()=>{try{u?await o.unpin():await o.pin()}catch(j){console.error("[CustomChannelHeader] Failed to update pinned status:",j)}};return e.jsxs("div",{className:"@container",children:[e.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] w-full items-center @lg:hidden",children:[e.jsx("div",{className:"flex items-center gap-2",children:s&&e.jsx("button",{className:le,onClick:t||(()=>{}),type:"button","aria-label":"Back to conversations",children:e.jsx(w.ArrowLeftIcon,{className:"size-5 text-black/90"})})}),e.jsxs("div",{className:"flex flex-col gap-1 items-center",children:[e.jsx(Q,{id:((p=d==null?void 0:d.user)==null?void 0:p.id)||o.id||"unknown",name:h,image:f,starred:r&&u,dmAgentEnabled:i,size:40}),e.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-0.5 rounded-full bg-black/[0.05] px-3 py-1 text-xs font-medium text-black/90 hover:bg-black/[0.08] transition-colors","aria-label":`View info for ${h}`,children:[h,e.jsx(w.CaretRightIcon,{className:"size-3 shrink-0"})]}),i&&e.jsxs("div",{className:"flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[e.jsx(w.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),e.jsx("span",{children:wt})]})]}),e.jsxs("div",{className:"flex justify-end items-center gap-2",children:[r&&e.jsx("button",{className:le,onClick:x,type:"button","aria-label":u?"Unstar conversation":"Star conversation",children:e.jsx(w.StarIcon,{className:y("size-5",{"text-yellow-600":u,"text-black/90":!u}),weight:u?"duotone":"regular"})}),e.jsx("button",{className:le,onClick:n,type:"button","aria-label":"Show info",children:e.jsx(w.DotsThreeIcon,{className:"size-5 text-black/90"})})]})]}),e.jsxs("div",{className:"hidden @lg:flex items-center justify-between gap-3 min-h-12",children:[e.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[s&&t&&e.jsx("button",{type:"button",onClick:t,className:le,"aria-label":"Back to conversations",children:e.jsx(w.ArrowLeftIcon,{className:"size-5 text-black/90"})}),e.jsx(Q,{id:((N=d==null?void 0:d.user)==null?void 0:N.id)||o.id||"unknown",name:h,image:f,starred:r&&u,dmAgentEnabled:i,size:40}),e.jsxs("div",{className:"min-w-0",children:[a?e.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-1 font-medium text-black/90 truncate hover:text-black/70 transition-colors","aria-label":`View info for ${h}`,children:[e.jsx("span",{className:"truncate",children:h}),e.jsx(w.CaretRightIcon,{className:"size-4 shrink-0"})]}):e.jsx("h1",{className:"font-medium text-black/90 truncate",children:h}),i&&e.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[e.jsx(w.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),e.jsx("span",{className:"truncate",children:wt})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[r&&e.jsx("button",{className:le,onClick:x,type:"button","aria-label":u?"Unstar conversation":"Star conversation",children:e.jsx(w.StarIcon,{className:y("size-5",{"text-yellow-600":u,"text-black/90":!u}),weight:u?"duotone":"regular"})}),a&&n&&e.jsx("button",{className:le,onClick:n,type:"button","aria-label":"Show info",children:e.jsx(w.DotsThreeIcon,{className:"size-5 text-black/90"})})]})]})]})},yn=({onBack:t,showBackButton:s,renderMessageInputActions:n,renderConversationFooter:a,onLeaveConversation:r,onBlockParticipant:i,showDeleteConversation:l=!0,onDeleteConversationClick:o,onBlockParticipantClick:d,onReportParticipantClick:h,showStarButton:f=!1,chatbotVotingEnabled:u=!1,renderChannelBanner:x,customProfileContent:c,customChannelActions:g,renderMessage:v,dmAgentEnabled:p=!1,viewerLanguage:N,getParticipantDisplayName:j})=>{var Y,H,G,F,V,U;const{channel:k}=C.useChannelStateContext(),S=m.useRef(null),I=m.useMemo(()=>{var b,_;const T=(b=k._client)==null?void 0:b.userID;return T?Object.values(((_=k.state)==null?void 0:_.members)||{}).find(z=>{var q;return((q=z.user)==null?void 0:q.id)&&z.user.id!==T}):void 0},[(Y=k._client)==null?void 0:Y.userID,(H=k.state)==null?void 0:H.members]),O=m.useMemo(()=>{var b,_;const T=(b=k._client)==null?void 0:b.userID;return T?Object.values(((_=k.state)==null?void 0:_.members)||{}).find(z=>{var q;return((q=z.user)==null?void 0:q.id)===T}):void 0},[(G=k._client)==null?void 0:G.userID,(F=k.state)==null?void 0:F.members]),M=((V=O==null?void 0:O.user)==null?void 0:V.is_account)??(O==null?void 0:O.is_account),A=((U=I==null?void 0:I.user)==null?void 0:U.is_account)??(I==null?void 0:I.is_account),R=p&&M===!1&&A===!0,D=m.useMemo(()=>{const T=k.data??{};if(T.followerStatus)return String(T.followerStatus);if(T.isFollower!==void 0)return T.isFollower?"Subscribed to you":"Not subscribed"},[k.data]),E=m.useCallback(()=>{var T;(T=S.current)==null||T.showModal()},[]),L=m.useCallback(()=>{var T;(T=S.current)==null||T.close()},[]),$=m.useCallback(T=>{const{message:P}=C.useMessageContext("ChannelView"),b=e.jsx(sn,{...T,chatbotVotingEnabled:u,viewerLanguage:N});return!v||!P?b:v(b,P)},[u,v,N]);return e.jsxs(e.Fragment,{children:[e.jsx(C.WithComponents,{overrides:{Message:$},children:e.jsxs(C.Window,{children:[e.jsx("div",{className:"p-4",children:e.jsx(Nn,{onBack:t,showBackButton:s,onShowInfo:E,canShowInfo:!!I,showStarButton:f,dmAgentEnabled:R,getParticipantDisplayName:j})},"lt-channel-header"),x?e.jsx(m.Fragment,{children:x()},"lt-channel-banner"):null,e.jsx("div",{className:"flex-1 overflow-hidden relative",children:e.jsx(C.MessageList,{hideDeletedMessages:!0,hideNewMessageSeparator:!1,messageActions:void 0})},"lt-channel-message-list"),a?e.jsx(m.Fragment,{children:a(k)},"lt-channel-conversation-footer"):null,e.jsx(cn,{renderActions:()=>n==null?void 0:n(k)},"lt-channel-message-input")]})}),e.jsx(ys,{dialogRef:S,onClose:L,participant:I,participantDisplayName:j(I),channel:k,followerStatusLabel:D,onLeaveConversation:r,onBlockParticipant:i,showDeleteConversation:l,onDeleteConversationClick:o,onBlockParticipantClick:d,onReportParticipantClick:h,customProfileContent:c,customChannelActions:g})]})},Ge=m.memo(({channel:t,onBack:s,showBackButton:n=!1,renderMessageInputActions:a,renderConversationFooter:r,onLeaveConversation:i,onBlockParticipant:l,className:o,CustomChannelEmptyState:d=Ut,showDeleteConversation:h=!0,onDeleteConversationClick:f,onBlockParticipantClick:u,onReportParticipantClick:x,dmAgentEnabled:c,messageMetadata:g,onMessageSent:v,showStarButton:p=!1,chatbotVotingEnabled:N=!1,renderChannelBanner:j,customProfileContent:k,customChannelActions:S,renderMessage:I,sendButton:O,viewerLanguage:M,getParticipantDisplayName:A})=>{const R=m.useCallback(E=>(A==null?void 0:A(E))??ye(E==null?void 0:E.user),[A]),D=m.useCallback(async(E,L,$)=>{var U;const Y=((U=t.data)==null?void 0:U.chatbot_paused)===!0,H=c&&!Y,G={...L,...H&&{silent:!0},...g&&{metadata:{...L.metadata??{},...g}}},F={...$,...H&&{skip_push:!0}},V=await t.sendMessage(G,F);return v==null||v(V),V},[t,c,g,v]);return e.jsx("div",{className:y("messaging-channel-view h-full flex flex-col",o),children:e.jsx(Vt.Provider,{value:c??!1,children:e.jsx(C.Channel,{channel:t,MessageSystem:pn,EmptyStateIndicator:d,LoadingIndicator:we,DateSeparator:_s,TypingIndicator:jn,doSendMessageRequest:D,...O?{SendButton:O}:{},children:e.jsx(yn,{onBack:s,showBackButton:n,renderMessageInputActions:a,renderConversationFooter:r,onLeaveConversation:i,onBlockParticipant:l,CustomChannelEmptyState:d,showDeleteConversation:h,onDeleteConversationClick:f,onBlockParticipantClick:u,onReportParticipantClick:x,showStarButton:p,dmAgentEnabled:c,chatbotVotingEnabled:N,renderChannelBanner:j,customProfileContent:k,customChannelActions:S,renderMessage:I,viewerLanguage:M,getParticipantDisplayName:R})})})})});Ge.displayName="ChannelView";const _n=({className:t})=>e.jsxs("svg",{width:"140",height:"120",viewBox:"44 -2 144 126",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[e.jsxs("g",{clipPath:"url(#clip0_empty_state)",children:[e.jsx("path",{d:"M123.68 82.1932C123.383 103.675 105.839 121 84.2417 121C77.4724 121 71.0986 119.297 65.5327 116.299L52.5873 119.687L53.8036 106.673C48.1776 99.8701 44.7994 91.1453 44.7994 81.6356C44.7994 59.8965 62.4554 42.2754 84.2374 42.2754C89.1328 42.2754 93.8175 43.1633 98.1413 44.789",fill:"#D7D4CE"}),e.jsx("path",{d:"M84.2458 86.0364C82.2851 86.0364 80.6957 84.4501 80.6957 82.4933C80.6957 80.5365 82.2851 78.9502 84.2458 78.9502C86.2065 78.9502 87.7959 80.5365 87.7959 82.4933C87.7959 84.4501 86.2065 86.0364 84.2458 86.0364Z",fill:"white"}),e.jsx("path",{d:"M68.3044 86.0364C66.3437 86.0364 64.7543 84.4501 64.7543 82.4933C64.7543 80.5365 66.3437 78.9502 68.3044 78.9502C70.2651 78.9502 71.8545 80.5365 71.8545 82.4933C71.8545 84.4501 70.2651 86.0364 68.3044 86.0364Z",fill:"white"}),e.jsx("path",{d:"M100.183 86.0364C98.2226 86.0364 96.6332 84.4501 96.6332 82.4933C96.6332 80.5365 98.2226 78.9502 100.183 78.9502C102.144 78.9502 103.733 80.5365 103.733 82.4933C103.733 84.4501 102.144 86.0364 100.183 86.0364Z",fill:"white"}),e.jsxs("g",{filter:"url(#filter0_empty_state)",children:[e.jsx("path",{d:"M171.522 68.7154C177.443 61.4539 181 52.1488 181 42C181 18.8027 162.421 0 139.5 0C116.579 0 98 18.8027 98 42C98 65.1973 116.579 84 139.5 84C146.622 84 153.328 82.1857 159.184 78.9829L172.801 82.5993L171.522 68.7154Z",fill:"white"}),e.jsx("path",{d:"M171.522 68.7154C177.443 61.4539 181 52.1488 181 42C181 18.8027 162.421 0 139.5 0C116.579 0 98 18.8027 98 42C98 65.1973 116.579 84 139.5 84C146.622 84 153.328 82.1857 159.184 78.9829L172.801 82.5993L171.522 68.7154Z",stroke:"#D7D4CE",strokeWidth:"2",strokeMiterlimit:"10"})]}),e.jsx("path",{d:"M139.502 45.5431C137.541 45.5431 135.952 43.9568 135.952 42C135.952 40.0432 137.541 38.4569 139.502 38.4569C141.462 38.4569 143.052 40.0432 143.052 42C143.052 43.9568 141.462 45.5431 139.502 45.5431Z",fill:"#D7D4CE"}),e.jsx("path",{d:"M123.561 45.5431C121.601 45.5431 120.011 43.9568 120.011 42C120.011 40.0432 121.601 38.4569 123.561 38.4569C125.522 38.4569 127.111 40.0432 127.111 42C127.111 43.9568 125.522 45.5431 123.561 45.5431Z",fill:"#D7D4CE"}),e.jsx("path",{d:"M155.439 45.5431C153.478 45.5431 151.889 43.9568 151.889 42C151.889 40.0432 153.478 38.4569 155.439 38.4569C157.4 38.4569 158.989 40.0432 158.989 42C158.989 43.9568 157.4 45.5431 155.439 45.5431Z",fill:"#D7D4CE"})]}),e.jsxs("defs",{children:[e.jsxs("filter",{id:"filter0_empty_state",x:"97",y:"-1",width:"89",height:"90",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[e.jsx("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),e.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),e.jsx("feOffset",{dx:"4",dy:"4"}),e.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),e.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.8428 0 0 0 0 0.830064 0 0 0 0 0.8095 0 0 0 1 0"}),e.jsx("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow"}),e.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect1_dropShadow",result:"shape"})]}),e.jsx("clipPath",{id:"clip0_empty_state",children:e.jsx("rect",{width:"233",height:"233",fill:"white"})})]})]}),Gt=m.memo(({hasChannels:t,channelsLoaded:s})=>e.jsx("div",{className:"messaging-empty-state flex items-center justify-center h-full p-8 text-balance",children:e.jsxs("div",{className:"flex flex-col items-center max-w-sm text-center",children:[e.jsx(_n,{}),s&&!t&&e.jsxs("div",{className:"mt-8",children:[e.jsx("h2",{className:"font-medium text-black text-[18px] mb-2",children:"Your inbox is empty"}),e.jsx("p",{className:"text-[#676B5F] text-sm mb-6",children:"Share with your followers to start receiving messages"})]})]})}));Gt.displayName="EmptyState";const ve=m.memo(({message:t,onBack:s})=>e.jsx("div",{className:"messaging-error-state flex items-center justify-center h-full p-8",children:e.jsxs("div",{className:"text-center max-w-sm",children:[e.jsx("div",{className:"w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6",children:e.jsx("span",{className:"text-4xl",children:"⚠️"})}),e.jsx("h2",{className:"font-semibold text-charcoal mb-2",children:"Oops!"}),e.jsx("p",{className:"text-stone text-sm mb-6",children:t}),s&&e.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-[#7f22fe] hover:bg-primary-alt rounded-lg transition-colors focus-ring",children:"Go Back"})]})}));ve.displayName="ErrorState";const kn=({capabilities:t={},className:s,renderMessageInputActions:n,renderConversationFooter:a,onChannelSelect:r,initialParticipantFilter:i,initialParticipantData:l,CustomChannelEmptyState:o,showChannelList:d=!0,filters:h,channelRenderFilterFn:f,channelListCustomEmptyStateIndicator:u,onDeleteConversationClick:x,onBlockParticipantClick:c,onReportParticipantClick:g,dmAgentEnabled:v,messageMetadata:p,onMessageSent:N,showStarButton:j=!1,chatbotVotingEnabled:k=!1,viewerLanguage:S,renderMessagePreview:I,renderChannelBanner:O,customProfileContent:M,customChannelActions:A,renderMessage:R,sendButton:D})=>{const{service:E,client:L,isConnected:$,isLoading:Y,error:H,refreshConnection:G,debug:F}=Nt(),[V,U]=m.useState(null),[T,P]=m.useState(!1),[b,_]=m.useState(!1),[z,q]=m.useState(!1),[W,K]=m.useState(null),{showDeleteConversation:fe=!0}=t,ge=m.useMemo(()=>{const B=L==null?void 0:L.userID;return{...{type:"messaging",last_message_at:{$exists:!0},...B&&{members:{$in:[B]},hidden:!1}},...h}},[h,L==null?void 0:L.userID]),ae=m.useRef(null),J=m.useCallback(async()=>{if(!L||!$)return;const B=L.userID;if(B)try{F&&console.log("[MessagingShell] Syncing channels for user:",B);const X=await L.queryChannels({type:"messaging",members:{$in:[B]}},{},{limit:100});P(X.length>0),_(!0),ae.current=B,F&&console.log("[MessagingShell] Channels synced successfully:",{channelCount:X.length})}catch(X){console.error("[MessagingShell] Failed to sync channels:",X)}},[L,$,F]);m.useEffect(()=>{if(!L||!$)return;const B=L.userID;B&&ae.current!==B&&J()},[L,$,J]),m.useEffect(()=>{if(!i||!L||!$)return;(async()=>{const X=L.userID;if(X)try{F&&console.log("[MessagingShell] Loading initial conversation with:",i);const Z=await L.queryChannels({type:"messaging",members:{$eq:[X,i]}},{},{limit:1});if(Z.length>0)U(Z[0]),q(!0),K(null),r&&r(Z[0]),F&&console.log("[MessagingShell] Initial conversation loaded:",Z[0].id);else if(l&&E){F&&console.log("[MessagingShell] No conversation found, creating one for:",l);try{const ne=await E.startChannelWithParticipant({id:l.id,name:l.name,phone:l.phone});U(ne),q(!0),K(null),r&&r(ne),F&&console.log("[MessagingShell] Channel created and loaded:",ne.id)}catch(ne){console.error("[MessagingShell] Failed to create conversation:",ne),K("Failed to create conversation")}}else K("No conversation found with this account"),F&&console.log("[MessagingShell] No conversation found for:",i)}catch(Z){console.error("[MessagingShell] Failed to load initial conversation:",Z),K("Failed to load conversation")}})()},[i,l,L,$,E,F,r]);const se=m.useCallback(B=>{U(B),r==null||r(B)},[r]),re=m.useCallback(()=>{z||U(null)},[z]),Ie=m.useCallback(async B=>{F&&console.log("[MessagingShell] Leaving conversation:",B.id),U(null),q(!1),ae.current=null,await J()},[J,F]),be=m.useCallback(async B=>{F&&console.log("[MessagingShell] Blocking participant:",B),U(null),q(!1),ae.current=null,await J()},[J,F]),oe=!!V;return Y?e.jsx("div",{className:y("h-full",s),children:e.jsx(we,{})}):H?e.jsx("div",{className:y("h-full",s),children:e.jsx(ve,{message:H,onBack:G})}):!$||!L?e.jsx("div",{className:y("h-full",s),children:e.jsx(ve,{message:"Not connected to messaging service",onBack:G})}):W?e.jsx("div",{className:y("h-full",s),children:e.jsx(ve,{message:W})}):e.jsx("div",{className:y("messaging-shell h-full bg-background-primary overflow-hidden",s),children:e.jsxs("div",{className:"flex h-full min-h-0",children:[e.jsx("div",{className:y("messaging-channel-list-sidebar min-h-0 min-w-0 lg:flex lg:flex-col",{"!hidden":d===!1||z,"hidden lg:flex lg:flex-1 lg:max-w-2xl":d!==!1&&!z&&oe,"flex flex-col w-full lg:flex-1 lg:max-w-2xl":d!==!1&&!z&&!oe}),children:e.jsx(Pe,{onChannelSelect:se,selectedChannel:V||void 0,filters:ge,channelRenderFilterFn:f,customEmptyStateIndicator:u,renderMessagePreview:I,viewerLanguage:S})}),e.jsx("div",{className:y("messaging-conversation-view flex-1 flex-col min-w-0 min-h-0",{flex:z||oe||i,"hidden lg:flex":!z&&!oe&&!i}),children:V?e.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:e.jsx(Ge,{channel:V,onBack:re,showBackButton:!z,renderMessageInputActions:n,renderConversationFooter:a,renderChannelBanner:O,onLeaveConversation:Ie,onBlockParticipant:be,CustomChannelEmptyState:o,showDeleteConversation:fe,onDeleteConversationClick:x,onBlockParticipantClick:c,onReportParticipantClick:g,dmAgentEnabled:v,messageMetadata:p,onMessageSent:N,showStarButton:j,chatbotVotingEnabled:k,viewerLanguage:S,customProfileContent:M,customChannelActions:A,renderMessage:R,sendButton:D},V.id)}):i?e.jsx(we,{}):e.jsx(Gt,{hasChannels:T,channelsLoaded:b})})]})})},Sn=/^([a-z][a-z0-9+.-]*):/i,In=new Set(["http","https","mailto","tel","sms"]);function Ht(t){if(typeof t!="string")return;const s=t.trim();if(s==="")return;const n=Sn.exec(s);if(n){const a=n[1].toLowerCase();return In.has(a)?s:void 0}return s.startsWith("//")||s.startsWith("/")?s:`https://${s}`}const En={dark:"bg-white text-[#121110] hover:bg-white/90",light:"bg-[#121110] text-white hover:bg-[#2a2928]"},Tn=({variant:t,cta:s})=>{const n=y("mt-2 inline-flex h-10 w-full items-center justify-center rounded-full px-4 text-sm font-medium leading-none transition-colors",En[t]),a=Ht(s.href);return a?e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:r=>{var i;r.stopPropagation(),(i=s.onClick)==null||i.call(s)},className:`${n} no-underline`,children:s.label}):e.jsx("button",{type:"button",onClick:r=>{var i;r.stopPropagation(),(i=s.onClick)==null||i.call(s)},className:n,children:s.label})},Mn={dark:"text-white",light:"text-black/90"},An="text-white/30",Rn={dark:"text-white/55",light:"text-black/55"},He=({variant:t,title:s,placeholderTitle:n,description:a,url:r,appIcon:i,cta:l,trailingAction:o})=>{const d=t==="dark",h=s??(d?n:void 0)??"",f=h.trim()!=="",u=a!=null&&a.trim()!=="",x=typeof r=="string"?r.trim():"",c=x!=="",g=l!=null;if(!f&&!u&&!c&&!g)return null;const p=y("truncate text-base font-medium leading-6",d&&!s?An:Mn[t]),N=y("truncate text-xs leading-4",Rn[t]);return e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[f&&e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[i?e.jsx("span",{className:"shrink-0",children:i}):null,e.jsx("p",{className:y("min-w-0",p),children:h})]}),u&&e.jsx("p",{className:N,children:a})]}),!g&&c&&e.jsx("p",{className:N,children:x})]}),o&&e.jsx("div",{className:"shrink-0",children:o})]}),l&&e.jsx(Tn,{variant:t,cta:l})]})},Ln=y("relative block w-[280px] select-none overflow-hidden rounded-md","border border-black/[0.08]","shadow-[0_1px_2px_rgba(0,0,0,0.04),0_8px_32px_rgba(0,0,0,0.1)]"),Ce=({variant:t,children:s,href:n,onClick:a,ariaLabel:r,rootRef:i,topRight:l,bgClassName:o,"data-testid":d})=>{const h=n!=null||a!=null,f=y(Ln,o??(t==="dark"?"bg-[#121110]":"bg-white"),h?"cursor-pointer no-underline focus-ring":null),u=l?e.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:l}):null;return n?e.jsxs("a",{ref:i,href:n,target:"_blank",rel:"noopener noreferrer",onClick:a,"data-testid":d,className:f,children:[s,u]}):a?e.jsxs("button",{ref:i,type:"button",onClick:a,"aria-label":r,"data-testid":d,className:y(f,"text-left"),children:[s,u]}):e.jsxs("div",{ref:i,"data-testid":d,className:f,children:[s,u]})},Dn={dark:"bg-white/10",light:"bg-black/5"},Fn={dark:"size-16 text-white/25",light:"size-16 text-black/25"},Se=(t,s)=>!!s&&!!t&&te(t)==="audio",On=(t,s)=>{if(!s||!t)return!1;const n=te(t);return n==="video"||n==="audio"},Ye="bg-[#F2F3F4]",Ne=({variant:t,thumbnailUrl:s,sourceUrl:n,title:a,mimeType:r="image/*",topLeft:i,topRight:l})=>{const o=te(r),d=!!n&&o==="video";return Se(r,n)?e.jsx("div",{className:"p-3",children:e.jsx("audio",{src:n,controls:!0,preload:"metadata",className:"block w-full",children:e.jsx("track",{kind:"captions"})})}):e.jsxs("div",{className:y("relative h-[180px] w-full overflow-hidden",d&&"bg-black"),children:[d?e.jsx("video",{src:n,poster:s,controls:!0,playsInline:!0,preload:"metadata",className:"absolute inset-0 h-full w-full object-contain",children:e.jsx("track",{kind:"captions"})}):s?e.jsx("img",{src:s,alt:a??"",draggable:!1,className:"absolute inset-0 h-full w-full object-cover"}):e.jsx("div",{className:y("flex h-full w-full items-center justify-center",Dn[t]),children:ie(r,{className:Fn[t],weight:"regular"})}),i?e.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-10",children:i}):null,l?e.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:l}):null]})},Pn=({title:t,placeholderTitle:s,description:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:l,layout:o="featured",appIcon:d,cta:h,onDismiss:f,onEditClick:u})=>{const x=o==="classic",c=Se(r,l),g=f?e.jsx("button",{type:"button",onClick:f,"aria-label":"Dismiss attachment",className:"flex size-6 items-center justify-center rounded-full bg-[#121110] text-white",children:e.jsx(w.XIcon,{className:"size-3",weight:"bold"})}):void 0,v=u?e.jsx("button",{type:"button",onClick:u,"aria-label":"Edit attachment",className:"flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",children:e.jsx(w.PencilSimpleIcon,{className:"size-5",weight:"regular"})}):void 0;return c?e.jsx(Ce,{variant:"dark",bgClassName:Ye,children:e.jsxs("div",{className:"flex items-center gap-2 pr-3",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Ne,{variant:"dark",sourceUrl:l,title:t,mimeType:r})}),g&&e.jsx("div",{className:"shrink-0",children:g})]})}):e.jsxs(Ce,{variant:"dark",topRight:x?g:void 0,children:[!x&&e.jsx(Ne,{variant:"dark",thumbnailUrl:i,sourceUrl:l,title:t,mimeType:r,topRight:g}),e.jsx(He,{variant:"dark",title:t,placeholderTitle:s,description:n,url:a,appIcon:d,cta:h,trailingAction:v})]})},zn=({title:t,description:s,url:n,mimeType:a,thumbnailUrl:r,sourceUrl:i,layout:l="featured",appIcon:o,cta:d,onClick:h})=>{const f=On(a,i),u=Ht(n),x=d==null&&u!=null&&!f?u:void 0,c=d==null&&!f?h:void 0,g=Se(a,i)?Ye:void 0,v=d&&h?{...d,onClick:()=>{var p;h(),(p=d.onClick)==null||p.call(d)}}:d;return e.jsxs(Ce,{variant:"light",href:x,onClick:c,ariaLabel:t??"Open attachment preview",bgClassName:g,"data-testid":"link-attachment",children:[l==="featured"&&e.jsx(Ne,{variant:"light",thumbnailUrl:r,sourceUrl:i,title:t,mimeType:a}),e.jsx(He,{variant:"light",title:t,description:s,url:n,appIcon:o,cta:v})]})},Bn=({title:t,placeholderTitle:s,description:n,url:a,mimeType:r,thumbnailUrl:i,sourceUrl:l,layout:o="featured",appIcon:d,cta:h})=>e.jsxs(Ce,{variant:"dark",bgClassName:Se(r,l)?Ye:void 0,children:[o==="featured"&&e.jsx(Ne,{variant:"dark",thumbnailUrl:i,sourceUrl:l,title:t,mimeType:r}),e.jsx(He,{variant:"dark",title:t,placeholderTitle:s,description:n,url:a,appIcon:d,cta:h})]}),$n={Composer:Pn,Sent:Bn,Received:zn},Vn={dark:"bg-[#121110]",light:"bg-[#e9eaed]"},Un={dark:"text-white",light:"text-[#080707]"},Gn={dark:"border-white/[0.08]",light:"border-black/[0.08]"},Hn=t=>t==="dark"?"sender":"receiver",Yn={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]"}},ue=({variant:t,text:s,bordered:n=!0,groupPosition:a="single",className:r,children:i,"data-testid":l})=>{const o=s!=null&&s!=="",d=Yn[Hn(t)][a];return e.jsxs("div",{"data-testid":l,"data-group-position":a,className:y("relative w-[280px] overflow-hidden px-2 py-2",d,Vn[t],Un[t],n&&"border",n&&Gn[t],r),children:[i,o?e.jsx("p",{className:y("whitespace-pre-wrap break-words leading-snug","pt-2","px-2"),children:s}):null]})},me=({onClick:t,variant:s="overlay",ariaLabel:n="Dismiss attachment"})=>e.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),t()},"aria-label":n,className:y("flex size-6 items-center justify-center rounded-full text-white",s==="overlay"?"bg-[#121110]/85 backdrop-blur":"bg-white/15 hover:bg-white/25"),children:e.jsx(w.XIcon,{className:"size-3",weight:"bold"})}),he=t=>t==="received"?"light":"dark",qn=({firstOfGroup:t,endOfGroup:s,groupedByUser:n})=>!n||t&&s?"single":t?"first":s?"end":"middle",Wn=({src:t,mimeType:s,filename:n,items:a})=>a&&a.length>0?a:t?[{src:t,mimeType:s,filename:n}]:[],Xn=({item:t,preload:s,trailingAction:n})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("audio",{src:t.src,controls:!0,preload:t.preload??s,className:"block min-w-0 flex-1",children:t.mimeType?e.jsx("source",{src:t.src,type:t.mimeType}):null}),n??null]}),qe=({state:t,src:s,mimeType:n,filename:a,items:r,text:i,groupPosition:l,preload:o,onDismiss:d})=>{const h=he(t),f=t==="composer"&&!!d,u=Wn({src:s,mimeType:n,filename:a,items:r});if(u.length===0)return null;const x=o??(u.length>1?"none":"metadata");return e.jsx(ue,{variant:h,text:i,groupPosition:l,"data-testid":"audio-attachment",children:e.jsx("div",{className:"flex flex-col gap-2",children:u.map((c,g)=>e.jsx(Xn,{item:c,preload:x,trailingAction:f&&g===0?e.jsx(me,{onClick:d,variant:"inline"}):void 0},`${c.src}-${g}`))})})},Zn=t=>e.jsx(qe,{...t,state:"composer"}),Kn=t=>e.jsx(qe,{...t,state:"sent"}),Jn=t=>e.jsx(qe,{...t,state:"received"}),Qn={Composer:Zn,Sent:Kn,Received:Jn};function Yt(t){return!Number.isFinite(t)||t<0?"":t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(2)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}const ea={pdf:"PDF",doc:"DOC",xls:"XLS",csv:"CSV",ppt:"PPT",zip:"ZIP",text:"TXT",markdown:"MD"};function qt(t,s){if(s){const r=s.lastIndexOf(".");if(r>0&&r<s.length-1){const i=s.slice(r+1);if(i&&i.length<=5)return i.toUpperCase()}}if(!t)return;if(te(t)==="document"){const r=Lt(t),i=ea[r];if(i)return i;if(t==="application/octet-stream")return}const a=t.split("/")[1];if(!(!a||a==="*"))return a.toUpperCase()}function Wt(t,s,n){const a=qt(t,s),r=typeof n=="number"&&n>0?Yt(n):void 0;return[a,r].filter(Boolean).join(" · ")||void 0}function ee(t){try{const n=new URL(t).pathname.split("/").pop();return n&&n.length>0?decodeURIComponent(n):"download"}catch{return"download"}}const ta={dark:"text-white/55",light:"text-black/65"},sa={dark:"bg-white/10",light:"bg-black/5"},na={dark:"text-white/85",light:"text-black/85"},Xt=({variant:t,filename:s,title:n,mimeType:a="application/octet-stream",fileSize:r,onActivate:i,activateLabel:l,trailingAction:o})=>{const d=n??s??"File",h=Wt(a,s,r),f=e.jsx("div",{className:y("flex size-10 shrink-0 items-center justify-center rounded-sm",sa[t]),"aria-hidden":!0,children:ie(a,{className:y("size-6",na[t]),weight:"regular"})}),u=e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col text-left",children:[e.jsx("p",{className:"truncate font-medium leading-snug",children:d}),h?e.jsx("p",{className:y("truncate text-xs leading-4",ta[t]),children:h}):null]}),x=i?e.jsxs("button",{type:"button",onClick:i,"aria-label":l,className:y("flex min-w-0 flex-1 items-center gap-3 rounded-sm text-left transition-colors",t==="dark"?"hover:bg-white/[0.04]":"hover:bg-black/[0.04]"),children:[f,u]}):e.jsxs(e.Fragment,{children:[f,u]});return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[x,o?e.jsx("div",{className:"shrink-0",children:o}):null]})};async function Zt(t,s){const n=s??ee(t);try{const a=await fetch(t,{mode:"cors"});if(!a.ok)throw new Error(`HTTP ${a.status}`);const r=await a.blob(),i=URL.createObjectURL(r),l=document.createElement("a");l.href=i,l.download=n,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)}catch{if(!window.open(t,"_blank","noopener,noreferrer")){const r=document.createElement("a");r.href=t,r.download=n,r.target="_blank",r.rel="noopener noreferrer",r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r)}}}const aa=({src:t,filename:s,fileSize:n,mimeType:a,title:r,items:i})=>i&&i.length>0?i:t?[{src:t,filename:s,fileSize:n,mimeType:a,title:r}]:[],ra=({variant:t,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??ee(s.src);return e.jsx(Xt,{variant:t,filename:i,title:s.title,mimeType:s.mimeType??"application/octet-stream",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Download ${i}`,trailingAction:r})},We=({state:t,src:s,filename:n,fileSize:a,mimeType:r,title:i,items:l,text:o,groupPosition:d,onClick:h,onDismiss:f})=>{const u=he(t),x=t==="composer"&&!!f,c=aa({src:s,filename:n,fileSize:a,mimeType:r,title:i,items:l}),g=p=>{if((h==null?void 0:h(p))===!1)return;const N=c[p];if(!N)return;const j=N.filename??ee(N.src);Zt(N.src,j)};if(c.length===0)return null;const v=e.jsx("span",{className:y("flex size-8 items-center justify-center rounded-full",u==="dark"?"text-white/70":"text-black/70"),"aria-hidden":!0,children:e.jsx(w.DownloadSimpleIcon,{className:"size-5",weight:"bold"})});return e.jsx(ue,{variant:u,text:o,groupPosition:d,"data-testid":"file-attachment",children:e.jsx("div",{className:"flex flex-col gap-2",children:c.map((p,N)=>{const j=x&&N===0?e.jsx(me,{onClick:f,variant:"inline"}):v;return e.jsx(ra,{variant:u,item:p,index:N,onActivate:g,trailingAction:j},`${p.src}-${N}`)})})})},ia=t=>e.jsx(We,{...t,state:"composer"}),oa=t=>e.jsx(We,{...t,state:"sent"}),la=t=>e.jsx(We,{...t,state:"received"}),ca={Composer:ia,Sent:oa,Received:la},Xe=({onPrev:t,onNext:s,prevLabel:n="Previous",nextLabel:a="Next"})=>e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:t,"aria-label":n,className:"mes-media-viewer__nav mes-media-viewer__nav--prev",children:e.jsx(w.CaretLeftIcon,{size:20,weight:"bold","aria-hidden":!0})}),e.jsx("button",{type:"button",onClick:s,"aria-label":a,className:"mes-media-viewer__nav mes-media-viewer__nav--next",children:e.jsx(w.CaretRightIcon,{size:20,weight:"bold","aria-hidden":!0})})]}),Kt=({url:t,filename:s,variant:n="pill",label:a="Download",iconOnly:r,tone:i="dark",onTriggered:l})=>{const[o,d]=m.useState(!1),h=m.useCallback(c=>{c.stopPropagation(),!o&&(d(!0),Zt(t,s).catch(()=>{}).finally(()=>{d(!1),l==null||l()}))},[o,t,s,l]),f=r??n!=="pill",x={className:y(n==="pill"?"size-4":"size-5","shrink-0"),weight:"bold"};if(n==="inline"){const c={dark:"text-white/70 hover:bg-white/[0.08] hover:text-white",light:"text-black/70 hover:bg-black/[0.08] hover:text-black"};return e.jsx("button",{type:"button",onClick:h,disabled:o,"aria-label":a,className:y("flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70",c[i]),children:o?e.jsx(w.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):e.jsx(w.DownloadSimpleIcon,{className:"size-5 shrink-0",weight:"bold","aria-hidden":!0})})}return n==="viewer"?e.jsx("button",{type:"button",onClick:h,disabled:o,"aria-label":a,className:"mes-media-viewer__action",children:o?e.jsx(w.CircleNotchIcon,{size:20,weight:"bold","aria-hidden":!0}):e.jsx(w.DownloadSimpleIcon,{size:20,weight:"bold","aria-hidden":!0})}):e.jsxs("button",{type:"button",onClick:h,disabled:o,"aria-label":f?a:void 0,className:y("mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounded-full px-4 text-sm font-medium leading-none transition-colors disabled:opacity-70",i==="dark"?"bg-[#121110] text-white hover:bg-[#2a2928]":"bg-white text-[#121110] hover:bg-white/90"),children:[o?e.jsx(w.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):e.jsx(w.DownloadSimpleIcon,{...x,"aria-hidden":!0}),f?null:a]})},Ae=(t,s,n)=>Math.min(Math.max(t,s),n),Ze=({length:t,initialIndex:s,open:n})=>{const a=Ae(s,0,Math.max(t-1,0)),[r,i]=m.useState(a);m.useEffect(()=>{n&&i(Ae(s,0,Math.max(t-1,0)))},[n,s,t]),m.useEffect(()=>{i(d=>Ae(d,0,Math.max(t-1,0)))},[t]);const l=m.useCallback(()=>{t<=1||i(d=>d<=0?t-1:d-1)},[t]),o=m.useCallback(()=>{t<=1||i(d=>d>=t-1?0:d+1)},[t]);return m.useEffect(()=>{if(!n||t<=1)return;const d=h=>{if(h.key!=="ArrowLeft"&&h.key!=="ArrowRight")return;const f=document.activeElement;f&&(f.tagName==="VIDEO"||f.tagName==="AUDIO")||(h.preventDefault(),h.key==="ArrowLeft"?l():o())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n,t,l,o]),{index:r,prev:l,next:o}},Ke=({open:t,onClose:s,ariaLabel:n,counter:a,actions:r,children:i,"data-testid":l})=>{const o=m.useRef(null),d=m.useRef(null);m.useEffect(()=>{var x;const u=o.current;if(u){if(t){if(!u.open)if(typeof u.showModal=="function")try{u.showModal()}catch{u.setAttribute("open","")}else u.setAttribute("open","");const c=typeof document<"u"?document.activeElement:null;return(x=d.current)==null||x.focus(),()=>{if(u.open)if(typeof u.close=="function")try{u.close()}catch{u.removeAttribute("open")}else u.removeAttribute("open");c&&document.body.contains(c)&&c.focus()}}if(u.open)if(typeof u.close=="function")try{u.close()}catch{u.removeAttribute("open")}else u.removeAttribute("open")}},[t]);const h=()=>{s()},f=u=>{u.target===o.current&&s()};return e.jsxs("dialog",{ref:o,className:"mes-media-viewer","aria-label":n??"Attachment viewer","data-testid":l,onClose:h,onClick:f,children:[e.jsxs("div",{className:"mes-media-viewer__chrome",children:[a?e.jsx("span",{className:"mes-media-viewer__counter",children:a}):null,e.jsxs("div",{className:"mes-media-viewer__actions",children:[r,e.jsx("button",{ref:d,type:"button",onClick:s,"aria-label":"Close viewer",className:"mes-media-viewer__action",children:e.jsx(w.XIcon,{size:20,weight:"bold","aria-hidden":!0})})]})]}),e.jsx("div",{className:"mes-media-viewer__body",children:i})]})},Jt=({open:t,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=Ze({length:s.length,initialIndex:n,open:t}),o=s[r],d=m.useMemo(()=>(o==null?void 0:o.filename)??(o?ee(o.src):"image"),[o]);return o?e.jsxs(Ke,{open:t,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,actions:e.jsx(Kt,{url:o.src,filename:d,variant:"viewer",label:`Download ${d}`}),"data-testid":"image-viewer",children:[e.jsx("img",{src:o.src,alt:o.alt??d,draggable:!1,loading:"eager",decoding:"async",className:"mes-media-viewer__image"},`${r}:${o.src}`),s.length>1?e.jsx(Xe,{onPrev:i,onNext:l,prevLabel:"Previous image",nextLabel:"Next image"}):null]}):null},da="relative block size-full overflow-hidden bg-black/5 outline-none focus-visible:ring-2 focus-visible:ring-white/80 focus-visible:ring-offset-2 focus-visible:ring-offset-black",Qt=({tiles:t,onTileActivate:s,maxVisible:n=4,className:a})=>{const r=t.length;if(r===0)return null;const i=t.slice(0,Math.min(r,n)),l=r-i.length,o=(d,h,f)=>{const u=y(da,"h-full w-full");return s?e.jsxs("button",{type:"button",onClick:()=>s(h),"aria-label":d.ariaLabel??`Open media ${h+1}`,className:y(u,"cursor-zoom-in"),children:[d.content,f]},h):e.jsxs("div",{className:u,children:[d.content,f]},h)};return i.length===1?e.jsx("div",{className:y("aspect-square w-full",a),children:o(i[0],0)}):i.length===2?e.jsx("div",{className:y("grid aspect-[16/9] w-full grid-cols-2 gap-0.5",a),children:i.map((d,h)=>o(d,h))}):i.length===3?e.jsxs("div",{className:y("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:[e.jsx("div",{className:"row-span-2",children:o(i[0],0)}),o(i[1],1),o(i[2],2)]}):e.jsx("div",{className:y("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:i.map((d,h)=>{const f=l>0&&h===i.length-1;return o(d,h,f?e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-black/55 text-2xl font-semibold text-white",children:["+",l]}):null)})})},xe=t=>{const[s,n]=m.useState(!1),[a,r]=m.useState(0),i=m.useCallback(o=>{(t==null?void 0:t(o))!==!1&&(r(o),n(!0))},[t]),l=m.useCallback(()=>n(!1),[]);return{viewerOpen:s,viewerIndex:a,handleActivate:i,closeViewer:l}},ua=(t,s,n,a)=>({ariaLabel:`Open image ${s+1} of ${n}`,content:e.jsx("img",{src:t.src,alt:t.alt??"",width:t.width,height:t.height,draggable:!1,loading:t.loading??a,decoding:"async",className:"absolute inset-0 size-full rounded-md object-cover"})}),ma=({src:t,alt:s,items:n})=>n&&n.length>0?n:t?[{src:t,alt:s}]:[],es=(t,s)=>t.map((n,a)=>({src:n.src,alt:n.alt,filename:s&&t.length===1?s:s?`${s} (${a+1})`:void 0})),ha=({src:t,alt:s,filename:n,loading:a="lazy",onClick:r,onDismiss:i})=>{const{viewerOpen:l,viewerIndex:o,handleActivate:d,closeViewer:h}=xe(r);return e.jsxs("div",{className:"relative w-fit",children:[e.jsx("button",{type:"button",onClick:()=>d(0),"aria-label":"Open image",className:"block size-[280px] cursor-zoom-in overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",children:e.jsx("img",{src:t,alt:s??"",draggable:!1,loading:a,decoding:"async",className:"size-full object-cover"})}),i?e.jsx("div",{className:"absolute right-2 top-2 z-10",children:e.jsx(me,{onClick:i})}):null,e.jsx(Jt,{open:l,items:es([{src:t,alt:s}],n),initialIndex:o,onClose:h})]})},ts=({state:t,src:s,alt:n,filename:a,items:r,text:i,groupPosition:l,loading:o="lazy",onClick:d})=>{const h=ma({src:s,alt:n,items:r}),f=he(t),{viewerOpen:u,viewerIndex:x,handleActivate:c,closeViewer:g}=xe(d);if(h.length===0)return null;const v=h.map((p,N)=>ua(p,N,h.length,o));return e.jsxs(ue,{variant:f,text:i,groupPosition:l,"data-testid":"image-attachment",children:[e.jsx("div",{className:"relative",children:e.jsx(Qt,{tiles:v,onTileActivate:c})}),e.jsx(Jt,{open:u,items:es(h,a),initialIndex:x,onClose:g})]})},xa=t=>e.jsx(ha,{...t}),fa=t=>e.jsx(ts,{...t,state:"sent"}),ga=t=>e.jsx(ts,{...t,state:"received"}),ba={Composer:xa,Sent:fa,Received:ga},pa=({open:t,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=Ze({length:s.length,initialIndex:n,open:t}),o=s[r],d=m.useMemo(()=>(o==null?void 0:o.filename)??(o?ee(o.src):"document"),[o]),h=m.useMemo(()=>o?va(o.src):void 0,[o]);return!o||!h?null:e.jsxs(Ke,{open:t,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,"data-testid":"pdf-viewer",children:[e.jsx("iframe",{src:h,title:d,className:"mes-media-viewer__iframe",sandbox:"allow-scripts allow-forms allow-popups allow-downloads"},`${r}:${o.src}`),s.length>1?e.jsx(Xe,{onPrev:i,onNext:l,prevLabel:"Previous document",nextLabel:"Next document"}):null]})},va=t=>{const s=t.indexOf("#"),n=s===-1?t:t.slice(0,s),a=s===-1?"":t.slice(s+1),r=new URLSearchParams(a);return r.has("toolbar")||r.set("toolbar","0"),r.has("navpanes")||r.set("navpanes","0"),`${n}#${r.toString()}`},ja=({src:t,filename:s,fileSize:n,title:a,items:r})=>r&&r.length>0?r:t?[{src:t,filename:s,fileSize:n,title:a}]:[],wa=({variant:t,item:s,index:n,onActivate:a,trailingAction:r})=>{const i=s.filename??ee(s.src);return e.jsx(Xt,{variant:t,filename:i,title:s.title,mimeType:"application/pdf",fileSize:s.fileSize,onActivate:()=>a(n),activateLabel:`Open ${i}`,trailingAction:r})},Je=({state:t,src:s,filename:n,fileSize:a,title:r,items:i,text:l,groupPosition:o,onClick:d,onDismiss:h})=>{const f=he(t),u=ja({src:s,filename:n,fileSize:a,title:r,items:i}),{viewerOpen:x,viewerIndex:c,handleActivate:g,closeViewer:v}=xe(d),p=t==="composer"&&!!h;if(u.length===0)return null;const N=u.map(j=>({src:j.src,filename:j.filename??ee(j.src)}));return e.jsxs(ue,{variant:f,text:l,groupPosition:o,"data-testid":"pdf-attachment",children:[e.jsx("div",{className:"flex flex-col gap-2",children:u.map((j,k)=>{const S=j.filename??ee(j.src),I=p&&k===0?e.jsx(me,{onClick:h,variant:"inline"}):t==="composer"?void 0:e.jsx(Kt,{url:j.src,filename:S,variant:"inline",label:`Download ${S}`,tone:f});return e.jsx(wa,{variant:f,item:j,index:k,onActivate:g,trailingAction:I},`${j.src}-${k}`)})}),e.jsx(pa,{open:x,items:N,initialIndex:c,onClose:v})]})},Ca=t=>e.jsx(Je,{...t,state:"composer"}),Na=t=>e.jsx(Je,{...t,state:"sent"}),ya=t=>e.jsx(Je,{...t,state:"received"}),_a={Composer:Ca,Sent:Na,Received:ya},ss=({open:t,items:s,initialIndex:n=0,onClose:a})=>{const{index:r,prev:i,next:l}=Ze({length:s.length,initialIndex:n,open:t}),o=s[r],d=m.useMemo(()=>(o==null?void 0:o.filename)??(o?ee(o.src):"video"),[o]);return o?e.jsxs(Ke,{open:t,onClose:a,ariaLabel:d,counter:s.length>1?`${r+1} / ${s.length}`:void 0,"data-testid":"video-viewer",children:[e.jsx("video",{src:o.src,poster:o.poster,controls:!0,autoPlay:!0,muted:!0,playsInline:!0,preload:o.preload??"metadata",className:"mes-media-viewer__video",children:o.mimeType?e.jsx("source",{src:o.src,type:o.mimeType}):null},`${r}:${o.src}`),s.length>1?e.jsx(Xe,{onPrev:i,onNext:l,prevLabel:"Previous video",nextLabel:"Next video"}):null]}):null},ka=()=>e.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:e.jsx("span",{className:"flex size-12 items-center justify-center rounded-full bg-black/55 text-white backdrop-blur",children:e.jsx(w.PlayIcon,{className:"size-6",weight:"fill","aria-hidden":!0})})}),ns=({item:t,index:s})=>e.jsxs("div",{className:"absolute inset-0 size-full bg-[#0d0d0d]",children:[t.poster?e.jsx("img",{src:t.poster,alt:`Video ${s+1} thumbnail`,draggable:!1,loading:"lazy",decoding:"async",className:"absolute inset-0 size-full rounded-md object-cover"}):e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(w.VideoCameraIcon,{className:"size-16 rounded-md text-white/30",weight:"regular","aria-hidden":!0})}),e.jsx(ka,{})]}),Sa=(t,s,n)=>({ariaLabel:`Play video ${s+1} of ${n}`,content:e.jsx(ns,{item:t,index:s})}),Ia=({src:t,poster:s,mimeType:n,preload:a,items:r})=>r&&r.length>0?a?r.map(i=>({...i,preload:i.preload??a})):r:t?[{src:t,poster:s,mimeType:n,preload:a}]:[],as=(t,s)=>t.map((n,a)=>({src:n.src,poster:n.poster,mimeType:n.mimeType,preload:n.preload,filename:s&&t.length===1?s:s?`${s} (${a+1})`:void 0})),Ea=({src:t,poster:s,mimeType:n,filename:a,preload:r,onClick:i,onDismiss:l})=>{const{viewerOpen:o,viewerIndex:d,handleActivate:h,closeViewer:f}=xe(i);return e.jsxs("div",{className:"relative w-fit",children:[e.jsx("button",{type:"button",onClick:()=>h(0),"aria-label":"Play video",className:"relative block size-[280px] cursor-pointer overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",children:e.jsx(ns,{item:{src:t,poster:s,mimeType:n},index:0})}),l?e.jsx("div",{className:"absolute right-2 top-2 z-10",children:e.jsx(me,{onClick:l})}):null,e.jsx(ss,{open:o,items:as([{src:t,poster:s,mimeType:n,preload:r}],a),initialIndex:d,onClose:f})]})},rs=({state:t,src:s,poster:n,mimeType:a,filename:r,items:i,text:l,groupPosition:o,preload:d,onClick:h})=>{const f=Ia({src:s,poster:n,mimeType:a,preload:d,items:i}),u=he(t),{viewerOpen:x,viewerIndex:c,handleActivate:g,closeViewer:v}=xe(h);if(f.length===0)return null;const p=f.map((N,j)=>Sa(N,j,f.length));return e.jsxs(ue,{variant:u,text:l,groupPosition:o,"data-testid":"video-attachment",children:[e.jsx("div",{className:"relative",children:e.jsx(Qt,{tiles:p,onTileActivate:g,className:"overflow-hidden rounded-md"})}),e.jsx(ss,{open:x,items:as(f,r),initialIndex:c,onClose:v})]})},Ta=t=>e.jsx(Ea,{...t}),Ma=t=>e.jsx(rs,{...t,state:"sent"}),Aa=t=>e.jsx(rs,{...t,state:"received"}),Ra={Composer:Ta,Sent:Ma,Received:Aa},La={Image:ba,Video:Ra,Audio:Qn,Pdf:_a,File:ca},is=({question:t,onClick:s,loading:n=!1,className:a})=>e.jsx("button",{type:"button",onClick:s,disabled:n,style:{backgroundColor:"#E6E5E3"},className:y("w-full text-center p-4 rounded-xl text-charcoal font-medium transition-colors focus-ring",{"hover:brightness-95 active:brightness-90":!n,"opacity-50 cursor-not-allowed":n},a),children:t}),Da=({faqs:t,onFaqClick:s,loadingFaqId:n,headerText:a,className:r,avatarImage:i,avatarName:l})=>{const o=t.filter(d=>d.enabled).sort((d,h)=>(d.order??0)-(h.order??0));return o.length===0?null:e.jsx("div",{className:r,children:e.jsxs("div",{className:"flex gap-3 items-end",children:[(i||l)&&e.jsx("div",{className:"flex-none",children:e.jsx(Q,{id:l||"account",name:l||"Account",image:i,size:24,shape:"circle"})}),e.jsxs("div",{className:"flex-1 flex flex-col gap-3 rounded-lg p-4",style:{backgroundColor:"#F1F0EE"},children:[a&&e.jsx("p",{className:"text-md text-charcoal mb-4",children:a}),o.map(d=>e.jsx(is,{question:d.question,onClick:()=>s(d.id),loading:n===d.id},d.id))]})]})})};exports.ActionButton=de;exports.AttachmentThumbnail=Be;exports.Avatar=Q;exports.ChannelEmptyState=Ut;exports.ChannelList=Pe;exports.ChannelView=Ge;exports.CustomMessageProvider=Qs;exports.FaqList=Da;exports.FaqListItem=is;exports.LinkAttachment=$n;exports.LockedAttachment=De;exports.MediaMessage=Zs;exports.MessageAttachment=La;exports.MessageVoteButtons=$t;exports.MessagingProvider=ls;exports.MessagingShell=kn;exports.bubbleGroupPositionFromStream=qn;exports.buildCompactMetaLabel=Wt;exports.formatFileSize=Yt;exports.formatRelativeTime=kt;exports.getFileExtensionLabel=qt;exports.getMessageDisplayText=Oe;exports.getSourceType=te;exports.isLinkAttachment=Ue;exports.isUuidLike=It;exports.normalizeLanguageCode=St;exports.renderTypeIcon=ie;exports.resolveLinkAttachment=_e;exports.resolveMediaFromMessage=ke;exports.resolveParticipantDisplayName=ye;exports.useCustomMessage=Bt;exports.useMessageVote=Mt;exports.useMessaging=Nt;
|
|
2
|
+
//# sourceMappingURL=index-CQ913euH.cjs.map
|