@linktr.ee/messaging-react 2.3.3 → 2.3.4-rc-1779841404
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-D2KIDqPs.cjs → Card-9X9RSzWd.cjs} +2 -2
- package/dist/{Card-D2KIDqPs.cjs.map → Card-9X9RSzWd.cjs.map} +1 -1
- package/dist/{Card-CBWof9at.cjs → Card-B0y7S-V2.cjs} +2 -2
- package/dist/{Card-CBWof9at.cjs.map → Card-B0y7S-V2.cjs.map} +1 -1
- package/dist/{Card-D9iWkHKh.js → Card-C-dmAFJG.js} +2 -2
- package/dist/{Card-D9iWkHKh.js.map → Card-C-dmAFJG.js.map} +1 -1
- package/dist/{Card-Bz1cMPwJ.js → Card-Cmfkr70L.js} +3 -3
- package/dist/{Card-Bz1cMPwJ.js.map → Card-Cmfkr70L.js.map} +1 -1
- package/dist/{Card-DgXoTo6c.cjs → Card-W7jCeHUe.cjs} +2 -2
- package/dist/{Card-DgXoTo6c.cjs.map → Card-W7jCeHUe.cjs.map} +1 -1
- package/dist/{Card-DFG3rvzF.js → Card-a6NQp99K.js} +2 -2
- package/dist/{Card-DFG3rvzF.js.map → Card-a6NQp99K.js.map} +1 -1
- package/dist/LockedThumbnail-CtZQCl64.cjs +2 -0
- package/dist/LockedThumbnail-CtZQCl64.cjs.map +1 -0
- package/dist/{LockedThumbnail-BkeCwTCw.js → LockedThumbnail-DPVq7iJu.js} +4 -4
- package/dist/LockedThumbnail-DPVq7iJu.js.map +1 -0
- package/dist/{index-v6yofqub.js → index-BfCt0dJa.js} +2 -2
- package/dist/{index-v6yofqub.js.map → index-BfCt0dJa.js.map} +1 -1
- package/dist/{index-DuGzAVyy.cjs → index-C0RXJhLE.cjs} +2 -2
- package/dist/{index-DuGzAVyy.cjs.map → index-C0RXJhLE.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/components/LockedAttachment/components/_shared/GalleryThumbnail.tsx +1 -1
- package/src/components/LockedAttachment/components/_shared/LockedThumbnail.tsx +1 -1
- package/dist/LockedThumbnail-BkeCwTCw.js.map +0 -1
- package/dist/LockedThumbnail-CD9YTQ0r.cjs +0 -2
- package/dist/LockedThumbnail-CD9YTQ0r.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const o=require("react/jsx-runtime"),V=require("classnames"),m=require("react"),co=require("@linktr.ee/messaging-core"),F=require("stream-chat-react"),P=require("@phosphor-icons/react"),De=require("stream-chat"),Hs=require("react-dom");function Ws(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Y=Ws(m),lo=Ws(Hs),Ys=m.createContext({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),bn=()=>m.useContext(Ys),uo=({children:e,user:t,serviceConfig:n,apiKey:s,capabilities:r={},debug:a=!1})=>{const i=m.useCallback((O,...z)=>{a&&console.log(`🔥 [MessagingProvider] ${O}`,...z)},[a]);i("🔄 RENDER START",{userId:t==null?void 0:t.id,apiKey:(s==null?void 0:s.substring(0,8))+"...",serviceConfig:!!n,capabilities:Object.keys(r)});const[c,u]=m.useState(null),[d,h]=m.useState(null),[f,p]=m.useState(!1),[l,g]=m.useState(!1),[x,b]=m.useState(null),v=m.useRef(!1),w=m.useRef({userId:t==null?void 0:t.id,apiKey:s,serviceConfig:n,capabilities:r}),E=m.useRef(0);E.current++,i("📊 RENDER INFO",{renderCount:E.current,currentProps:{userId:t==null?void 0:t.id,apiKey:(s==null?void 0:s.substring(0,8))+"..."},propChanges:{userChanged:w.current.userId!==(t==null?void 0:t.id),apiKeyChanged:w.current.apiKey!==s,serviceConfigChanged:w.current.serviceConfig!==n,capabilitiesChanged:w.current.capabilities!==r}}),w.current={userId:t==null?void 0:t.id,apiKey:s,serviceConfig:n,capabilities:r},m.useEffect(()=>{const O=E.current;if(i("🔧 SERVICE INIT EFFECT TRIGGERED",{renderCount:O,apiKey:!!s,serviceConfig:!!n,dependencies:{apiKey:(s==null?void 0:s.substring(0,8))+"...",serviceConfigRef:n,serviceConfigStable:w.current.serviceConfig===n,apiKeyStable:w.current.apiKey===s}}),!s||!n){i("⚠️ SERVICE INIT SKIPPED",{renderCount:O,reason:"Missing apiKey or serviceConfig"});return}i("🚀 CREATING NEW SERVICE",{renderCount:O,apiKey:(s==null?void 0:s.substring(0,8))+"...",serviceConfigChanged:w.current.serviceConfig!==n});const z=new co.StreamChatService({...n,apiKey:s,debug:a});return u(z),i("✅ SERVICE SET",{renderCount:O,serviceInstance:!!z}),()=>{i("🧹 SERVICE CLEANUP",{renderCount:O,reason:"Effect cleanup"}),z.disconnectUser().catch(console.error)}},[s,n,a,i]);const j=m.useRef(null);m.useEffect(()=>{var z,B;if(i("🔗 USER CONNECTION EFFECT TRIGGERED",{hasService:!!c,hasUser:!!t,userId:t==null?void 0:t.id,isConnecting:v.current,isConnected:f,dependencies:{service:!!c,userId:t==null?void 0:t.id}}),!c||!t){i("⚠️ USER CONNECTION SKIPPED","Missing service or user");return}if(v.current){i("⚠️ USER CONNECTION SKIPPED","Already connecting");return}if(((z=j.current)==null?void 0:z.serviceId)===c&&((B=j.current)==null?void 0:B.userId)===t.id){i("⚠️ USER CONNECTION SKIPPED","Already connected this user with this service");return}(async()=>{i("🚀 STARTING USER CONNECTION",{userId:t.id}),v.current=!0,g(!0),b(null);try{i("📞 CALLING SERVICE.CONNECTUSER",{userId:t.id});const T=await c.connectUser(t);h(T),p(!0),j.current={serviceId:c,userId:t.id},i("✅ USER CONNECTION SUCCESS",{userId:t.id,clientId:T.userID})}catch(T){const M=T instanceof Error?T.message:"Connection failed";b(M),i("❌ USER CONNECTION ERROR",{userId:t.id,error:M})}finally{g(!1),v.current=!1,i("🔄 USER CONNECTION FINISHED",{userId:t.id,isConnected:f})}})()},[c,t,i,f]),m.useEffect(()=>(i("🔌 CLEANUP EFFECT REGISTERED",{hasService:!!c,isConnected:f}),()=>{c&&f?(i("🧹 CLEANUP EFFECT TRIGGERED","Cleaning up connection on unmount"),j.current=null,c.disconnectUser().catch(console.error)):i("🔇 CLEANUP EFFECT SKIPPED",{hasService:!!c,isConnected:f})}),[c,f,i]);const R=m.useCallback(async()=>{if(i("🔄 REFRESH CONNECTION CALLED",{hasService:!!c,hasUser:!!t}),!c||!t){i("⚠️ REFRESH CONNECTION SKIPPED","Missing service or user");return}i("🚀 STARTING CONNECTION REFRESH",{userId:t.id}),g(!0);try{i("🔌 DISCONNECTING FOR REFRESH"),await c.disconnectUser(),i("📞 RECONNECTING FOR REFRESH");const O=await c.connectUser(t);h(O),p(!0),b(null),i("✅ CONNECTION REFRESH SUCCESS",{userId:t.id})}catch(O){const z=O instanceof Error?O.message:"Refresh failed";b(z),i("❌ CONNECTION REFRESH ERROR",{userId:t.id,error:z})}finally{g(!1),i("🔄 CONNECTION REFRESH FINISHED",{userId:t.id})}},[c,t,i]),D=m.useMemo(()=>(i("💫 CONTEXT VALUE MEMOIZATION",{hasService:!!c,hasClient:!!d,isConnected:f,isLoading:l,hasError:!!x,capabilitiesKeys:Object.keys(r)}),{service:c,client:d,isConnected:f,isLoading:l,error:x,capabilities:r,refreshConnection:R,debug:a}),[c,d,f,l,x,r,R,a,i]);return i("🔄 RENDER END",{renderCount:E.current,willRenderChat:!!(d&&f),contextValueReady:!!D}),o.jsx(Ys.Provider,{value:D,children:d&&f?o.jsx(F.Chat,{client:d,customClasses:{channelList:"str-chat__channel-list str-chat__channel-list-react bg-transparent lg:border-r-2 border-r-0 border-[#0000000A]"},children:e}):e})},Gs=()=>bn();function fo(e){const t=e.state.pending_messages;if(t!=null&&t.length)for(const n of t)e.state.addMessageSorted(n.message)}const qs=m.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,viewerLanguage:void 0}),mo=qs.Provider,ho=()=>m.useContext(qs),Ks=e=>{var s,r;const[t,n]=m.useState(!!((r=(s=e==null?void 0:e.state)==null?void 0:s.membership)!=null&&r.pinned_at));return m.useEffect(()=>{var i;if(!e){n(!1);return}n(!!((i=e.state.membership)!=null&&i.pinned_at));const a=c=>{var u;n(c!=null&&c.member?!!c.member.pinned_at:!!((u=e.state.membership)!=null&&u.pinned_at))};return e.on("member.updated",a),()=>{e.off("member.updated",a)}},[e]),t},po=(e,t)=>{const n=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())),r=new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())).getTime()-n.getTime();return Math.floor(r/(1e3*60*60*24))},Xs=e=>{const t=new Date;if(Math.floor((t.getTime()-e.getTime())/1e3)<60)return"Just now";const s=po(e,t);return s===0?e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):s===1?"Yesterday":s<7?`${s}d`:s<28?`${Math.floor(s/7)}w`:e.toLocaleDateString("en-US",{month:"numeric",day:"numeric",year:"2-digit"})};function Zs(e){return(e==null?void 0:e.trim().toLowerCase().split(/[-_]/)[0])||void 0}function vn({message:e,viewerLanguage:t}){var r;const n=e==null?void 0:e.text,s=Zs(t);return s?((r=e==null?void 0:e.i18n)==null?void 0:r[`${s}_text`])??n:n}const go=/^[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 Js(e){return go.test(e.trim())}function fs(e,t){const n=e==null?void 0:e.trim();return!n||t&&n===t?!1:!Js(n)}function Ot(e){return fs(e==null?void 0:e.name,e==null?void 0:e.id)?e.name.trim():fs(e==null?void 0:e.username,e==null?void 0:e.id)?e.username.trim():"Unknown member"}const ms=["🍎","🍌","🍇","🍊","🍓","🥥","🍒","🥭","🍉","🍋","🥝","🫒","🍈"];function xo(e){let t=0;for(let n=0;n<e.length;n++){const s=e.charCodeAt(n);t=(t<<5)-t+s,t=t&t}return Math.abs(t)}function bo(e){const n=xo(e)%ms.length;return ms[n]}const ke=({id:e,image:t,size:n=40,className:s,starred:r=!1,shape:a="squircle",dmAgentEnabled:i=!1})=>{const c=bo(e),d=n<32?"text-xs":n<56?"text-sm":n<120?"text-lg":"text-4xl",h=n>=40?2:1,f=a==="circle"?{borderRadius:"50%"}:{borderRadius:"33%",cornerShape:"superellipse(1.3)"},p=o.jsx("div",{className:"h-full w-full overflow-hidden",style:f,children:t?o.jsx("img",{src:t,alt:"",className:"h-full w-full object-cover"}):o.jsx("div",{"aria-hidden":"true",className:V("avatar-fallback flex h-full w-full items-center justify-center bg-[#E6E5E3] font-semibold select-none transition-colors",d),children:c})});return o.jsxs("div",{className:V("relative flex-shrink-0 !bg-transparent",s),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`},children:[r&&o.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:o.jsx(P.StarIcon,{className:"size-3 text-yellow-600",weight:"duotone"})}),o.jsx("div",{"data-testid":"avatar-ring",className:V("h-full w-full","bg-transparent"),style:{...f,...i&&{borderWidth:`${h}px`,borderStyle:"solid",borderColor:"var(--AI-Gradient, #7F22FE)",boxShadow:"inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"}},children:p})]})},vo=({size:e=15})=>o.jsx("svg",{width:e,height:e,viewBox:"0 0 15 15",fill:"none","aria-hidden":"true",children:o.jsx("path",{d:"M12.003 9a.985.985 0 0 1-.652.934l-3.223 1.191-1.188 3.226a.995.995 0 0 1-1.867 0l-1.195-3.226L.65 9.937a.995.995 0 0 1 0-1.867l3.227-1.195 1.187-3.226a.995.995 0 0 1 1.868 0l1.195 3.226 3.226 1.187a.99.99 0 0 1 .649.938m3-5.83a.52.52 0 0 1-.344.492l-1.702.63-.627 1.703a.525.525 0 0 1-.986 0l-.63-1.704-1.704-.627a.525.525 0 0 1 0-.986l1.703-.63.627-1.704a.526.526 0 0 1 .986 0l.631 1.703 1.704.627a.52.52 0 0 1 .342.495",fill:"currentColor",fillOpacity:.55})}),wo=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)==="MESSAGE_TIP"},yo=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)==="MESSAGE_PAID"},Nt=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)==="MESSAGE_CHATBOT"},_o=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)==="MESSAGE_ATTACHMENT"},Qs=e=>wo(e)||yo(e),Eo=e=>{var t;return Qs(e)&&!((t=e.text)!=null&&t.trim())},qt=({message:e,standalone:t=!1,isMyMessage:n=!1,hasAttachment:s=!1})=>{var f;const r=Qs(e),a=Nt(e);if(!r&&!a)return null;if(r){const p=(f=e.metadata)==null?void 0:f.amount_text;if(!p)return null;const l=t?"message-tip-standalone":"message-tag message-tag--tip",g=t?`${p} tip`:`Delivered with ${p} tip`;return o.jsxs("div",{className:l,children:[o.jsx(P.GiftIcon,{size:t?14:12}),o.jsx("span",{children:g})]})}const i=n&&s,c=i?"Sent with AI":"Sent with DM Agent",u=["message-chatbot-indicator",n?"message-chatbot-indicator--sender":"message-chatbot-indicator--receiver",i?"message-chatbot-indicator--attachment":"message-chatbot-indicator--text"].join(" "),d=o.jsx("span",{className:"message-chatbot-indicator__label",children:c}),h=o.jsx("span",{className:"message-chatbot-indicator__icon",children:o.jsx(vo,{size:i?12:15})});return o.jsx("div",{className:u,"data-testid":"message-chatbot-indicator",children:n&&!i?o.jsxs(o.Fragment,{children:[d,h]}):o.jsxs(o.Fragment,{children:[h,d]})})},er=m.memo(({channel:e,unread:t})=>{var D,O,z;const{selectedChannel:n,onChannelSelect:s,debug:r,renderMessagePreview:a,viewerLanguage:i}=ho(),c=(n==null?void 0:n.id)===(e==null?void 0:e.id),u=()=>{e&&s(e)},d=B=>{const T=B.key==="Enter"||B.key===" ",M=B.repeat;!T||M||(B.preventDefault(),u())},f=Object.values(((D=e==null?void 0:e.state)==null?void 0:D.members)||{}).find(B=>{var T,M;return((T=B.user)==null?void 0:T.id)&&B.user.id!==((M=e==null?void 0:e._client)==null?void 0:M.userID)}),p=Ot(f==null?void 0:f.user),l=(O=f==null?void 0:f.user)==null?void 0:O.image,g=(()=>{var T;const B=(T=e==null?void 0:e.state)==null?void 0:T.messages;if(B!=null&&B.length){for(let M=B.length-1;M>=0;M--)if(B[M].type!=="system")return B[M]}})(),b=(()=>{var U,W;const B=vn({message:g,viewerLanguage:i});if(B)return B;if(((U=g==null?void 0:g.metadata)==null?void 0:U.custom_type)==="MESSAGE_TIP")return"💵 Sent a tip";const M=(W=g==null?void 0:g.attachments)==null?void 0:W[0];return M?M.og_scrape_url?M.og_scrape_url:M.type==="image"?"📷 Sent an image":M.type==="video"?"🎥 Sent a video":M.type==="audio"?"🎵 Sent audio":M.type==="file"?"📎 Sent a file":"📎 Sent an attachment":"No messages yet"})(),v=g!=null&&g.created_at?Xs(new Date(g.created_at)):"",w=g?Nt(g):!1,E=a?a(g,b):`${w?"✨ ":""}${b}`,j=Ks(e),R=t??0;return r&&console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER",{channelId:e==null?void 0:e.id,isSelected:c,participantName:p,unreadCount:R,hasTimestamp:!!v}),o.jsx("div",{role:"button",tabIndex:0,onClick:u,onKeyDown:d,className:V("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":c,"hover:bg-sand":!c}),children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(ke,{id:((z=f==null?void 0:f.user)==null?void 0:z.id)||e.id||"unknown",name:p,image:l,size:44,starred:j,className:"[&_.avatar-fallback]:group-hover:bg-[#eeeeee]"}),o.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsxs("h3",{className:V("text-sm font-medium truncate",c?"text-primary":"text-charcoal"),children:[j&&o.jsx("span",{className:"sr-only",children:"Starred conversation. "}),p]}),v&&o.jsx("span",{className:"text-xs text-stone flex-shrink-0",children:v})]}),o.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[o.jsx("p",{className:"text-xs text-stone flex-1 line-clamp-1",children:E}),R>0&&o.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:R>99?"99+":R})]})]})]})})});er.displayName="CustomChannelPreview";const Co={last_message_at:-1},wn=m.memo(({onChannelSelect:e,selectedChannel:t,filters:n,allowNewMessagesFromUnfilteredChannels:s=!1,onMessageNew:r,onAddedToChannel:a,channelRenderFilterFn:i,sort:c=Co,className:u,customEmptyStateIndicator:d,renderMessagePreview:h,viewerLanguage:f})=>{const p=m.useRef(0);p.current++;const{debug:l=!1}=bn(),g=m.useCallback(b=>{for(const v of b)fo(v);return i?i(b):b},[i]);l&&console.log("📺 [ChannelList] 🔄 RENDER START",{renderCount:p.current,selectedChannelId:t==null?void 0:t.id,filters:n});const x=m.useMemo(()=>({selectedChannel:t,onChannelSelect:e,debug:l,renderMessagePreview:h,viewerLanguage:f}),[t,e,l,h,f]);return o.jsx("div",{className:V("messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",u),children:o.jsx("div",{className:"flex-1 overflow-hidden min-w-0",children:o.jsx(mo,{value:x,children:o.jsx(F.ChannelList,{filters:n,sort:c,options:{limit:30},allowNewMessagesFromUnfilteredChannels:s,onMessageNew:r,onAddedToChannel:a,channelRenderFilterFn:g,Preview:er,EmptyStateIndicator:d},`${JSON.stringify(n)}:${JSON.stringify(c)}`)})})})});wn.displayName="ChannelList";const st=({variant:e="default",className:t,children:n,...s})=>{const r=e==="danger";return o.jsx("button",{type:"button",className:V("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",t),...s,children:n})};function No({label:e,className:t,children:n,...s}){return o.jsxs("button",{type:"button",className:V("inline-flex items-center justify-center rounded-full transition-colors focus-ring p-2",{"cursor-not-allowed opacity-50":s.disabled,"hover:bg-sand":!s.disabled},t),...s,children:[o.jsx("span",{className:"sr-only",children:e}),n]})}function So({onClick:e}){return o.jsx(No,{label:"Close",onClick:e,className:"p-1",children:o.jsx(P.XIcon,{className:"h-5 w-5 text-stone",weight:"bold"})})}const jo=({dialogRef:e,onClose:t,participant:n,participantDisplayName:s,channel:r,followerStatusLabel:a,onLeaveConversation:i,onBlockParticipant:c,showDeleteConversation:u=!0,onDeleteConversationClick:d,onBlockParticipantClick:h,onReportParticipantClick:f,customProfileContent:p,customChannelActions:l})=>{var C,S,y,k;const{service:g,debug:x}=bn(),[b,v]=m.useState(!1),[w,E]=m.useState(!1),[j,R]=m.useState(!1),D=m.useCallback(async()=>{var _;if(!(!g||!((_=n==null?void 0:n.user)!=null&&_.id)))try{const N=(await g.getBlockedUsers()).some(A=>{var H;return A.blocked_user_id===((H=n==null?void 0:n.user)==null?void 0:H.id)});v(N)}catch(I){console.error("[ChannelInfoDialog] Failed to check blocked status:",I)}},[g,(C=n==null?void 0:n.user)==null?void 0:C.id]);m.useEffect(()=>{D()},[D]);const O=async()=>{var _;if(!w){d==null||d(),x&&console.log("[ChannelInfoDialog] Leave conversation",r.cid),E(!0);try{const I=((_=r._client)==null?void 0:_.userID)??null;await r.hide(I,!1),i&&await i(r),t()}catch(I){console.error("[ChannelInfoDialog] Failed to leave conversation",I)}finally{E(!1)}}},z=async()=>{var _,I,N;if(!(j||!g)){h==null||h(),x&&console.log("[ChannelInfoDialog] Block member",(_=n==null?void 0:n.user)==null?void 0:_.id),R(!0);try{await g.blockUser((I=n==null?void 0:n.user)==null?void 0:I.id),c&&await c((N=n==null?void 0:n.user)==null?void 0:N.id),t()}catch(A){console.error("[ChannelInfoDialog] Failed to block member",A)}finally{R(!1)}}},B=async()=>{var _,I,N;if(!(j||!g)){h==null||h(),x&&console.log("[ChannelInfoDialog] Unblock member",(_=n==null?void 0:n.user)==null?void 0:_.id),R(!0);try{await g.unBlockUser((I=n==null?void 0:n.user)==null?void 0:I.id),c&&await c((N=n==null?void 0:n.user)==null?void 0:N.id),t()}catch(A){console.error("[ChannelInfoDialog] Failed to unblock member",A)}finally{R(!1)}}},T=()=>{f==null||f(),t(),window.open("https://linktr.ee/s/about/trust-center/report","_blank","noopener,noreferrer")};if(!n)return null;const M=s??Ot(n.user),U=(S=n.user)==null?void 0:S.image,W=(y=n.user)==null?void 0:y.username,L=W?`linktr.ee/${W}`:void 0,$=((k=n.user)==null?void 0:k.id)||"unknown";return o.jsx("dialog",{ref:e,className:"mes-dialog group",onClose:t,onClick:_=>{_.target===e.current&&t()},children:o.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:[o.jsxs("div",{className:"flex items-center justify-between border-b border-sand px-4 py-3",children:[o.jsx("h2",{className:"text-base font-semibold text-charcoal",children:"Chat info"}),o.jsx(So,{onClick:t})]}),o.jsxs("div",{className:"flex-1 px-2 overflow-y-auto w-full",children:[o.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:[o.jsxs("div",{className:"flex items-center gap-3 w-full",children:[o.jsx(ke,{id:$,name:M,image:U,size:88,shape:"circle"}),o.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[o.jsx("p",{className:"truncate text-base font-semibold text-charcoal",children:M}),L&&o.jsx("p",{className:"truncate text-sm text-[#00000055]",children:L}),a&&!p&&o.jsx("span",{className:"mt-1 rounded-full text-xs font-normal w-fit",style:{padding:"4px 8px",backgroundColor:a==="Subscribed to you"?"#DCFCE7":"#F5F5F4",color:a==="Subscribed to you"?"#008236":"#78716C",lineHeight:"133.333%",letterSpacing:"0.21px"},children:a})]})]}),p&&o.jsx("div",{className:"w-full",children:p})]}),o.jsxs("ul",{className:"flex flex-col gap-2 mt-2",children:[u&&o.jsx("li",{children:o.jsxs(st,{onClick:O,disabled:w,"aria-busy":w,children:[w?o.jsx(P.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):o.jsx(P.SignOutIcon,{className:"h-5 w-5"}),o.jsx("span",{children:"Delete Conversation"})]})}),o.jsx("li",{children:b?o.jsxs(st,{onClick:B,disabled:j,"aria-busy":j,children:[j?o.jsx(P.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):o.jsx(P.ProhibitInsetIcon,{className:"h-5 w-5"}),o.jsx("span",{children:"Unblock"})]}):o.jsxs(st,{onClick:z,disabled:j,"aria-busy":j,children:[j?o.jsx(P.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):o.jsx(P.ProhibitInsetIcon,{className:"h-5 w-5"}),o.jsx("span",{children:"Block"})]})}),o.jsx("li",{children:o.jsxs(st,{variant:"danger",onClick:T,children:[o.jsx(P.FlagIcon,{className:"h-5 w-5"}),o.jsx("span",{children:"Report"})]})}),l]})]})]})})},ko=e=>o.jsx(F.DateSeparator,{...e,position:"center"}),on="vote_up",an="vote_down";function $o(e){return e!=null&&e.length?e.some(t=>t.type===an)?"down":e.some(t=>t.type===on)?"up":null:null}function tr(e){const{channel:t}=F.useChannelStateContext(),{client:n}=F.useChatContext("useMessageVote"),s=m.useMemo(()=>$o(e.own_reactions),[e.own_reactions]),r=m.useCallback(async()=>{if(n!=null&&n.userID)try{s==="up"?await t.deleteReaction(e.id,on):await t.sendReaction(e.id,{type:on},{enforce_unique:!0,skip_push:!0})}catch{}},[t,n==null?void 0:n.userID,e.id,s]),a=m.useCallback(async()=>{if(n!=null&&n.userID)try{s==="down"?await t.deleteReaction(e.id,an):await t.sendReaction(e.id,{type:an},{enforce_unique:!0,skip_push:!0})}catch{}},[t,n==null?void 0:n.userID,e.id,s]);return{selected:s,voteUp:r,voteDown:a}}const Mo=m.lazy(()=>Promise.resolve().then(()=>require("./Card-CBWof9at.cjs"))),Ro=m.lazy(()=>Promise.resolve().then(()=>require("./Card-DgXoTo6c.cjs"))),To=m.lazy(()=>Promise.resolve().then(()=>require("./Card-D2KIDqPs.cjs"))),yn=()=>o.jsx("div",{className:"w-[280px] min-h-[200px] animate-pulse rounded-md bg-black/[0.06] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_1px_2px_rgba(0,0,0,0.04),0_8px_32px_rgba(0,0,0,0.1)]","aria-hidden":!0}),Io=e=>o.jsx(m.Suspense,{fallback:o.jsx(yn,{}),children:o.jsx(Mo,{...e})}),nr=e=>o.jsx(m.Suspense,{fallback:o.jsx(yn,{}),children:o.jsx(Ro,{...e})}),sr=e=>o.jsx(m.Suspense,{fallback:o.jsx(yn,{}),children:o.jsx(To,{...e})}),Lo=nr,Do=sr,cn={Composer:Io,Sent:nr,Received:sr,Creator:Lo,Visitor:Do},Ao=[[/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 Re(e){return e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.startsWith("image/")?"image":"document"}function rr(e){const t=Ao.find(([n])=>n.test(e));return t?t[1]:"generic"}const Oo={video:P.VideoCameraIcon,audio:P.SpeakerHighIcon,image:P.ImageIcon,document:P.FileIcon},Fo={pdf:P.FilePdfIcon,doc:P.FileDocIcon,xls:P.FileXlsIcon,csv:P.FileCsvIcon,ppt:P.FilePptIcon,zip:P.FileZipIcon,text:P.FileTextIcon,markdown:P.FileMdIcon,generic:P.FileIcon};function Po(e){const t=Re(e);return t!=="document"?Oo[t]:Fo[rr(e)]}function Ue(e,t){return m.createElement(Po(e),t)}const zo=e=>{var t,n;return"touches"in e?((t=e.touches[0])==null?void 0:t.clientX)??((n=e.changedTouches[0])==null?void 0:n.clientX)??0:e.clientX},Bo=({source:e,mimeType:t,poster:n,autoPlay:s=!1,playing:r,loop:a=!1,controls:i=!0,showProgress:c=!1,muted:u=!1,onContainerClick:d})=>{const h=Re(t),f=m.useRef(null),p=m.useRef(null),l=m.useRef(null),g=m.useRef(r),[x,b]=m.useState(s),[v,w]=m.useState(0),[E,j]=m.useState(!1),[R,D]=m.useState(!1),[O,z]=m.useState(!1),[B,T]=m.useState(!1),[M,U]=m.useState(!0),[W,L]=m.useState(null),$=m.useCallback(()=>{z(!1),b(!0)},[]),C=m.useCallback(N=>{const A=p.current;if(!A)return 0;const H=A.getBoundingClientRect();return Math.max(0,Math.min(1,(zo(N)-H.left)/H.width))},[]),S=m.useCallback(N=>{const A=f.current;A&&A.duration&&(A.currentTime=N*A.duration)},[]),y=N=>{N.stopPropagation(),j(!0);const A=C(N);w(A),S(A)};m.useEffect(()=>{r!==void 0&&r!==g.current&&(g.current=r,b(r))},[r]),m.useEffect(()=>{if(!x){l.current!==null&&(cancelAnimationFrame(l.current),l.current=null);return}const N=()=>{const A=f.current;A&&A.duration&&!E&&w(A.currentTime/A.duration),l.current=requestAnimationFrame(N)};return l.current=requestAnimationFrame(N),()=>{l.current!==null&&cancelAnimationFrame(l.current)}},[x,E]),m.useEffect(()=>{const N=f.current;N&&(x?N.play().catch(A=>{b(!1),z(!0)}):N.pause())},[x]),m.useEffect(()=>{if(!E)return;const N=H=>w(C(H)),A=H=>{j(!1),S(C(H))};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",A),window.addEventListener("touchmove",N,{passive:!0}),window.addEventListener("touchend",A),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",A),window.removeEventListener("touchmove",N),window.removeEventListener("touchend",A)}},[E,C,S]);const k=W?{aspectRatio:String(W)}:void 0,_=W?"":" aspect-video",I=Math.round(v*100);return o.jsxs("div",{role:"button",tabIndex:0,className:`relative cursor-pointer overflow-hidden bg-black ${_}`,style:k,onClick:N=>{if(d){d(N);return}O||i&&b(A=>!A)},onKeyDown:N=>{if(!(N.key!=="Enter"&&N.key!==" ")){if(N.preventDefault(),d){d(N);return}O||i&&b(A=>!A)}},children:[n&&(h==="audio"||M)&&o.jsx("img",{src:n,alt:"",className:"absolute inset-0 h-full w-full object-cover"}),!n&&(h==="audio"||M)&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:Ue(t,{className:"size-12 text-black/20",weight:"regular"})}),o.jsx("div",{className:"absolute inset-0",children:h==="audio"?o.jsx("audio",{ref:f,src:e,loop:a,muted:u,style:{width:"100%",height:"100%"},onLoadStart:()=>T(!0),onCanPlay:()=>{T(!1),U(!1)},onWaiting:()=>T(!0),onPlay:()=>z(!1),onEnded:()=>{a||(b(!1),w(0))},children:o.jsx("track",{kind:"captions"})}):o.jsx("video",{ref:f,src:e,loop:a,muted:u,playsInline:!0,style:{width:"100%",height:"100%"},onLoadStart:()=>T(!0),onCanPlay:()=>{T(!1),U(!1)},onWaiting:()=>T(!0),onPlay:()=>z(!1),onLoadedMetadata:()=>{const N=f.current;N instanceof HTMLVideoElement&&N.videoWidth&&N.videoHeight&&L(N.videoWidth/N.videoHeight)},onEnded:()=>{a||(b(!1),w(0))},children:o.jsx("track",{kind:"captions"})})}),B&&!O&&o.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:o.jsx(P.CircleNotchIcon,{className:"size-8 animate-spin text-white/80",weight:"bold"})}),O&&!i&&o.jsx("div",{className:"absolute inset-0 z-30 flex cursor-pointer items-center justify-center bg-black/35",role:"button",tabIndex:0,"aria-label":"Play preview",onClick:N=>{N.stopPropagation(),$()},onKeyDown:N=>{N.key!=="Enter"&&N.key!==" "||(N.preventDefault(),N.stopPropagation(),$())},children:o.jsx("span",{className:"flex size-16 items-center justify-center rounded-full bg-white/20 text-white backdrop-blur-sm",children:o.jsx(P.PlayIcon,{className:"size-9 translate-x-0.5",weight:"fill"})})}),c&&!i&&o.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:o.jsx("div",{role:"slider","aria-label":"Playback position","aria-valuenow":I,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:p,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:y,onTouchStart:y,onClick:N=>N.stopPropagation(),onKeyDown:N=>{N.key==="ArrowRight"&&S(Math.min(1,v+.05)),N.key==="ArrowLeft"&&S(Math.max(0,v-.05))},children:o.jsx("div",{className:"w-full overflow-hidden rounded-full bg-white/30 h-1",children:o.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${I}%`}})})})}),i&&o.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:[o.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),b(A=>!A)},className:"shrink-0 text-white","aria-label":x?"Pause":"Play",children:x?o.jsx(P.PauseIcon,{className:"size-5",weight:"fill"}):o.jsx(P.PlayIcon,{className:"size-5 translate-x-px",weight:"fill"})}),o.jsxs("div",{role:"slider","aria-label":"Playback position","aria-valuenow":I,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:p,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:y,onTouchStart:y,onClick:N=>N.stopPropagation(),onMouseEnter:()=>D(!0),onMouseLeave:()=>D(!1),onKeyDown:N=>{N.key==="ArrowRight"&&S(Math.min(1,v+.05)),N.key==="ArrowLeft"&&S(Math.max(0,v-.05))},children:[o.jsx("div",{className:`w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${R||E?"h-1.5":"h-1"}`,children:o.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${I}%`}})}),o.jsx("div",{className:`absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${R||E?"scale-100 opacity-100":"scale-0 opacity-0"}`,style:{left:`${I}%`}})]})]})]})},hs=e=>e==="dark"?"size-12 text-white/20":"size-12 text-black/20",Vo=e=>e==="dark"?"aspect-video overflow-hidden bg-white/10":"aspect-video overflow-hidden bg-black/5",_n=({mimeType:e,sourceUrl:t,thumbnailUrl:n,title:s,variant:r,mediaPlayerProps:a,containedImage:i=!1})=>{const c=Re(e),[u,d]=m.useState(!1);return t&&(c==="video"||c==="audio")?o.jsx(Bo,{source:t,mimeType:e,poster:n,controls:!0,...a}):t&&c==="image"?i?o.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:o.jsx("img",{src:t,alt:s??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${u?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>d(!0)})}):o.jsx("img",{src:t,alt:s??"",className:"block w-full",draggable:!1}):t&&c==="document"?n?i?o.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:o.jsx("img",{src:n,alt:s??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${u?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>d(!0)})}):o.jsx("img",{src:n,alt:"",className:"block w-full",draggable:!1}):o.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${r==="dark"?"bg-white/10":"bg-black/5"}`,children:Ue(e,{className:hs(r),weight:"regular"})}):n?o.jsx("div",{className:`relative ${Vo(r)}`,children:o.jsx("img",{src:n,alt:s??"",draggable:!1,className:"absolute inset-0 h-full w-full object-cover"})}):o.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${r==="dark"?"bg-white/10":"bg-black/5"}`,children:Ue(e,{className:hs(r),weight:"regular"})})},or=({variant:e,thumbnail:t,title:n,placeholderTitle:s="Attachment title",mimeType:r,detail:a,statusBadge:i,action:c,topLeft:u,topRight:d,rootRef:h,"data-testid":f})=>{const p=e==="dark",l=p?n??s:n??"",g=p&&!n;return o.jsxs("div",{ref:h,"data-testid":f,className:V("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)]",p?"bg-[#121110]":"bg-white"),children:[u?o.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-50",children:u}):null,d?o.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-50",children:d}):null,t,o.jsxs("div",{className:"px-4 pb-3 pt-3",children:[l.trim()!==""&&o.jsx("p",{className:V("mb-0.5 truncate text-base font-medium",{"text-black":!p,"text-white/30":p&&g,"text-white":p&&!g}),children:l}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[Ue(r,{className:V("size-5 shrink-0",p?"text-white/55":"text-black/55"),weight:"regular"}),a!=null&&a!==""&&o.jsx("span",{className:V("text-xs font-medium",p?"text-white/55":"text-black/55"),children:a}),i]}),c]})]})};function ar(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function En(e){return`w-[280px] select-none overflow-hidden rounded-[24px] ${e?"bg-[#121110]":"bg-[#F3F3F1]"} shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]`}function Uo(e){return e?"bg-white/10":"bg-black/5"}function Ho(e){return e?"text-white":"text-black"}function Wo(e){return e?"text-white/55":"text-black/55"}function Yo(e){return e?"text-white/40":"text-black/40"}function Go(e){return e?"text-white/20":"text-black/20"}const Cn=({attachment:e,isMyMessage:t})=>{const{title:n,text:s,image_url:r,og_scrape_url:a,title_link:i}=e,c=a??i,u=typeof c=="string"&&c.trim()!==""?c:void 0,d=o.jsxs(m.Fragment,{children:[o.jsx("div",{className:"p-2",children:r?o.jsx("img",{src:r,alt:n??"",className:"aspect-video w-full rounded-[20px] object-cover"}):o.jsx("div",{className:`aspect-video w-full rounded-[20px] ${Uo(t)} flex items-center justify-center`,children:o.jsx(P.LinkIcon,{className:`size-12 ${Go(t)}`})})}),o.jsxs("div",{className:"px-3 pb-3",children:[n&&o.jsx("p",{className:`truncate text-[14px] font-medium leading-5 ${Ho(t)}`,children:n}),s&&o.jsx("p",{className:`truncate text-[12px] leading-4 ${Wo(t)}`,children:s}),u&&o.jsx("p",{className:`mt-1 truncate text-[12px] leading-4 ${Yo(t)}`,children:u})]})]});return u?o.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"block no-underline",children:d}):o.jsx("div",{className:"block",children:d})};function Nn(e){return e.type==="link"||!!e.og_scrape_url&&!e.asset_url}function Ft(e){var t;return(t=e.attachments)==null?void 0:t.find(Nn)}async function qo(e,t){let n;try{n=t??new URL(e).pathname.split("/").pop()??"download"}catch{n=t??"download"}const s=await fetch(e,{mode:"cors"});if(!s.ok)throw new Error(`HTTP ${s.status}`);const r=await s.blob(),a=URL.createObjectURL(r),i=document.createElement("a");i.href=a,i.download=n,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(a)}const Ko=({url:e,filename:t})=>{const[n,s]=m.useState(!1),r=a=>{a.stopPropagation();const i=window.open("","_blank","noopener,noreferrer");s(!0),qo(e,t).then(()=>{i==null||i.close()}).catch(()=>{i&&(i.location.href=e)}).finally(()=>s(!1))};return o.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?o.jsx(P.CircleNotchIcon,{className:"size-4 animate-spin text-white",weight:"bold"}):o.jsxs(m.Fragment,{children:[o.jsx(P.DownloadSimpleIcon,{className:"size-4 text-white",weight:"bold"}),"Download"]})})};function Pt(e){var f,p,l,g;const t=(f=e.attachments)==null?void 0:f.find(x=>x.type==="video"&&x.asset_url),n=(p=e.attachments)==null?void 0:p.find(x=>x.type==="image"&&x.image_url),s=(l=e.attachments)==null?void 0:l.find(x=>x.type==="audio"&&x.asset_url),r=(g=e.attachments)==null?void 0:g.find(x=>x.type==="file"&&x.asset_url),a=t??n??s??r,i=(t==null?void 0:t.asset_url)??(n==null?void 0:n.image_url)??(s==null?void 0:s.asset_url)??(r==null?void 0:r.asset_url);if(!i)return null;const c=(a==null?void 0:a.mime_type)??((a==null?void 0:a.type)==="image"?"image/jpeg":(a==null?void 0:a.type)==="video"?"video/mp4":(a==null?void 0:a.type)==="audio"?"audio/mpeg":"application/octet-stream"),u=a==null?void 0:a.title,d=a==null?void 0:a.file_size,h=t==null?void 0:t.thumb_url;return{resolvedUrl:i,resolvedType:c,title:u,fileSize:d,thumbnailUrl:h}}const ir=({resolvedUrl:e,resolvedType:t,title:n,fileSize:s,thumbnailUrl:r})=>{const a=s!==void 0?ar(s):void 0;return o.jsx(or,{variant:"dark",title:n,placeholderTitle:"",mimeType:t,detail:a,thumbnail:o.jsx(_n,{mimeType:t,sourceUrl:e,thumbnailUrl:r,title:n,variant:"dark"})})},cr=({resolvedUrl:e,resolvedType:t,title:n,fileSize:s,thumbnailUrl:r})=>{const a=Re(t),i=s!==void 0?ar(s):void 0;return o.jsx(or,{variant:"light",title:n,mimeType:t,detail:i,thumbnail:o.jsx(_n,{mimeType:t,sourceUrl:e,thumbnailUrl:r,title:n,variant:"light",containedImage:a==="image"||a==="document"}),action:o.jsx(Ko,{url:e,filename:n})})},Xo=({message:e,isMyMessage:t=!1})=>{const n=Ft(e),s=Pt(e);if(!n&&!s)return null;const r=t?"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 o.jsxs("div",{className:r,children:[!t&&e.user&&o.jsx(ke,{className:"str-chat__avatar str-chat__message-sender-avatar",id:e.user.id,image:e.user.image,name:e.user.name??e.user.id}),o.jsx("div",{className:"str-chat__message-inner",style:{marginInlineEnd:0,marginInlineStart:0},children:o.jsx("div",{className:"str-chat__message-bubble-wrapper",children:o.jsx("div",{className:"str-chat__message-bubble",style:{padding:0,borderRadius:0,overflow:"visible",background:"transparent"},children:n?o.jsx("div",{className:En(t),children:o.jsx(Cn,{attachment:n,isMyMessage:t})}):t?o.jsx(ir,{...s}):o.jsx(cr,{...s})})})})]})},Zo=({message:e})=>{const t=Ft(e);if(t)return o.jsx("div",{className:En(!0),children:o.jsx(Cn,{attachment:t,isMyMessage:!0})});const n=Pt(e);return n?o.jsx(ir,{...n}):null},Jo=({message:e})=>{const t=Ft(e);if(t)return o.jsx("div",{className:En(!1),children:o.jsx(Cn,{attachment:t,isMyMessage:!1})});const n=Pt(e);return n?o.jsx(cr,{...n}):null},Qo=Object.assign(Xo,{Creator:Zo,Visitor:Jo}),ea={isUnlocking:()=>!1},ta={LockedAttachment:ea},lr=m.createContext({}),na=lr.Provider;function ur(e){return m.useContext(lr)[e]??ta[e]}const dr=({selected:e,onVoteUp:t,onVoteDown:n})=>o.jsxs("div",{className:"message-vote-buttons",children:[o.jsx("button",{type:"button",className:V("message-vote-button focus-ring",{"message-vote-button--selected":e==="up"}),onClick:t,"aria-label":"Good response","aria-pressed":e==="up","data-tooltip":"Good response",children:o.jsx(P.ThumbsUpIcon,{size:16,weight:e==="up"?"fill":"regular"})}),o.jsx("button",{type:"button",className:V("message-vote-button focus-ring",{"message-vote-button--selected":e==="down"}),onClick:n,"aria-label":"Bad response","aria-pressed":e==="down","data-tooltip":"Bad response",children:o.jsx(P.ThumbsDownIcon,{size:16,weight:e==="down"?"fill":"regular"})})]}),sa=e=>{var Xn,Zn,Jn,Qn,es,ts,ns,ss,rs,os,as,is,cs,ls;const{additionalMessageInputProps:t,chatbotVotingEnabled:n,editing:s,endOfGroup:r,firstOfGroup:a,groupedByUser:i,handleAction:c,handleOpenThread:u,handleRetry:d,highlighted:h,isMessageAIGenerated:f,isMyMessage:p,message:l,renderText:g,threadList:x,viewerLanguage:b}=e,{client:v}=F.useChatContext("CustomMessage"),{channel:w}=F.useChannelStateContext("CustomMessage"),{isUnlocking:E,onUnlockClick:j,onFetchSource:R,onDownloadClick:D}=ur("LockedAttachment"),[O,z]=m.useState(!1),B=F.useMessageReminder(l.id),{selected:T,voteUp:M,voteDown:U}=tr(l),{Attachment:W=F.Attachment,EditMessageModal:L=F.EditMessageModal,MessageActions:$,MessageBlocked:C=F.MessageBlocked,MessageBouncePrompt:S=F.MessageBouncePrompt,MessageDeleted:y=F.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:k=F.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:_=F.MessageRepliesCountButton,ReminderNotification:I=F.ReminderNotification,StreamedMessageText:N=F.StreamedMessageText,PinIndicator:A}=F.useComponentContext("CustomMessage"),H=F.messageHasAttachments(l),G=F.messageHasReactions(l),re=m.useMemo(()=>f==null?void 0:f(l),[f,l]),X=m.useMemo(()=>{const tt=l.attachments??[],pt=l.shared_location?[l.shared_location,...tt]:tt;if(!Nt(l))return pt;const us=pt.filter(ds=>!("type"in ds)||!Nn(ds));return us.length===pt.length?pt:us},[l]),me=m.useMemo(()=>{const tt=vn({message:l,viewerLanguage:b});return tt===l.text?l:{...l,text:tt}},[l,b]);if(F.isDateSeparatorMessage(l))return null;if(l.deleted_at||l.type==="deleted")return o.jsx(y,{message:l});if(F.isMessageBlocked(l))return o.jsx(C,{});const le=!x&&!!l.reply_count,K=!x&&l.show_in_channel&&l.parent_id,Q=l.status==="failed"&&((Xn=l.error)==null?void 0:Xn.status)!==403,xe=F.isMessageBounced(l);let ae;Q?ae=()=>d(l):xe&&(ae=()=>z(!0));const Fe=p(),Gt=V("str-chat__message str-chat__message-simple",`str-chat__message--${l.type}`,`str-chat__message--${l.status}`,Fe?"str-chat__message--me str-chat__message-simple--me":"str-chat__message--other",l.text?"str-chat__message--has-text":"has-no-text",{"str-chat__message--has-attachment":H,"str-chat__message--highlighted":h,"str-chat__message--pinned pinned-message":l.pinned,"str-chat__message--with-reactions":G,"str-chat__message-send-can-be-retried":(l==null?void 0:l.status)==="failed"&&((Zn=l==null?void 0:l.error)==null?void 0:Zn.status)!==403,"str-chat__message-with-thread-link":le||K,"str-chat__virtual-message__wrapper--end":r,"str-chat__virtual-message__wrapper--first":a,"str-chat__virtual-message__wrapper--group":i}),Pe=l.poll_id&&v.polls.fromState(l.poll_id),Z=Eo(l),se=Nt(l),Ce=_o(l),Ne=!!(X!=null&&X.length&&!l.quoted_message),Kn=se&&Fe&&Ne;return o.jsxs(o.Fragment,{children:[s&&o.jsx(L,{additionalMessageInputProps:t}),O&&o.jsx(F.MessageBounceModal,{MessageBouncePrompt:S,onClose:()=>z(!1),open:O}),o.jsxs("div",{className:Gt,children:[A&&o.jsx(A,{}),!!B&&o.jsx(I,{reminder:B}),l.user&&o.jsx(ke,{className:"str-chat__avatar str-chat__message-sender-avatar",id:l.user.id,image:l.user.image,name:l.user.name||l.user.id,size:se?24:28,shape:"circle",dmAgentEnabled:se}),o.jsxs("div",{className:V("str-chat__message-inner",{"str-chat__simple-message--error-failed":Q||xe}),"data-testid":"message-inner",onClick:ae,onKeyDown:ae,role:ae?"button":void 0,tabIndex:ae?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:[Ce?o.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[Fe?o.jsx(cn.Sent,{title:(Jn=l.metadata)==null?void 0:Jn.attachment_title,mimeType:(Qn=l.metadata)==null?void 0:Qn.attachment_mime_type,thumbnailUrl:(es=l.metadata)==null?void 0:es.attachment_thumbnail,amountText:(ts=l.metadata)==null?void 0:ts.amount_text,detail:(ns=l.metadata)==null?void 0:ns.attachment_detail,paymentStatus:(ss=l.metadata)==null?void 0:ss.payment_status,onPreviewClick:()=>j==null?void 0:j(l,w),onFetchSource:async()=>await(R==null?void 0:R(l,w))}):o.jsx(cn.Received,{title:(rs=l.metadata)==null?void 0:rs.attachment_title,mimeType:(os=l.metadata)==null?void 0:os.attachment_mime_type,thumbnailUrl:(as=l.metadata)==null?void 0:as.attachment_thumbnail,amountText:(is=l.metadata)==null?void 0:is.amount_text,detail:(cs=l.metadata)==null?void 0:cs.attachment_detail,paymentStatus:(ls=l.metadata)==null?void 0:ls.payment_status,isUnlocking:E(l.id),onUnlockClick:()=>j==null?void 0:j(l,w),onFetchSource:async()=>await(R==null?void 0:R(l,w)),onDownloadClick:()=>D==null?void 0:D(l,w)}),l.text&&o.jsx("div",{className:"str-chat__message-bubble",children:o.jsx(F.MessageText,{message:me,renderText:g})})]}):Z?o.jsx(qt,{message:l,standalone:!0}):o.jsx("div",{className:"str-chat__message-bubble-wrapper",children:o.jsxs("div",{className:"str-chat__message-bubble",children:[se&&!Kn&&o.jsx(qt,{message:l,hasAttachment:Ne,isMyMessage:Fe}),Pe&&o.jsx(F.Poll,{poll:Pe}),X!=null&&X.length&&!l.quoted_message?o.jsx(W,{actionHandler:c,attachments:X}):null,re?o.jsx(N,{message:me,renderText:g}):o.jsx(F.MessageText,{message:me,renderText:g}),o.jsx(F.MessageErrorIcon,{})]})}),$&&o.jsx($,{})]}),!Ce&&!Z&&o.jsxs("div",{className:"str-chat__message-footer",children:[(!se||Kn)&&o.jsx(qt,{message:l,hasAttachment:Ne,isMyMessage:Fe}),n&&se&&o.jsx(dr,{selected:T,onVoteUp:M,onVoteDown:U})]}),le&&o.jsx(_,{onClick:u,reply_count:l.reply_count}),K&&o.jsx(k,{})]},l.id)]})},ra=m.memo(sa,(e,t)=>e.chatbotVotingEnabled!==t.chatbotVotingEnabled||e.viewerLanguage!==t.viewerLanguage?!1:F.areMessageUIPropsEqual(e,t)),oa=e=>{const t=F.useMessageContext("CustomMessage");return o.jsx(ra,{...t,...e})};function fr(e){var t,n,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=fr(e[t]))&&(s&&(s+=" "),s+=n)}else for(n in e)e[n]&&(s&&(s+=" "),s+=n);return s}function $e(){for(var e,t,n=0,s="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=fr(e))&&(s&&(s+=" "),s+=t);return s}const aa=m.createContext(void 0),Sn=e=>{const t=m.useContext(aa);return t||(console.warn(`The useChannelStateContext hook was called outside of the ChannelStateContext provider. Make sure this hook is called within a child of the Channel component. The errored call is located in the ${e} component.`),{})},ia=m.createContext(void 0),He=e=>{const t=m.useContext(ia);return t||(console.warn(`The useChatContext hook was called outside of the ChatContext provider. Make sure this hook is called within a child of the Chat component. The errored call is located in the ${e} component.`),{})},ca=m.createContext({}),mr=e=>m.useContext(ca);function jn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var gt={exports:{}},Kt={};/**
|
|
1
|
+
"use strict";const o=require("react/jsx-runtime"),V=require("classnames"),m=require("react"),co=require("@linktr.ee/messaging-core"),F=require("stream-chat-react"),P=require("@phosphor-icons/react"),De=require("stream-chat"),Hs=require("react-dom");function Ws(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Y=Ws(m),lo=Ws(Hs),Ys=m.createContext({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),bn=()=>m.useContext(Ys),uo=({children:e,user:t,serviceConfig:n,apiKey:s,capabilities:r={},debug:a=!1})=>{const i=m.useCallback((O,...z)=>{a&&console.log(`🔥 [MessagingProvider] ${O}`,...z)},[a]);i("🔄 RENDER START",{userId:t==null?void 0:t.id,apiKey:(s==null?void 0:s.substring(0,8))+"...",serviceConfig:!!n,capabilities:Object.keys(r)});const[c,u]=m.useState(null),[d,h]=m.useState(null),[f,p]=m.useState(!1),[l,g]=m.useState(!1),[x,b]=m.useState(null),v=m.useRef(!1),w=m.useRef({userId:t==null?void 0:t.id,apiKey:s,serviceConfig:n,capabilities:r}),E=m.useRef(0);E.current++,i("📊 RENDER INFO",{renderCount:E.current,currentProps:{userId:t==null?void 0:t.id,apiKey:(s==null?void 0:s.substring(0,8))+"..."},propChanges:{userChanged:w.current.userId!==(t==null?void 0:t.id),apiKeyChanged:w.current.apiKey!==s,serviceConfigChanged:w.current.serviceConfig!==n,capabilitiesChanged:w.current.capabilities!==r}}),w.current={userId:t==null?void 0:t.id,apiKey:s,serviceConfig:n,capabilities:r},m.useEffect(()=>{const O=E.current;if(i("🔧 SERVICE INIT EFFECT TRIGGERED",{renderCount:O,apiKey:!!s,serviceConfig:!!n,dependencies:{apiKey:(s==null?void 0:s.substring(0,8))+"...",serviceConfigRef:n,serviceConfigStable:w.current.serviceConfig===n,apiKeyStable:w.current.apiKey===s}}),!s||!n){i("⚠️ SERVICE INIT SKIPPED",{renderCount:O,reason:"Missing apiKey or serviceConfig"});return}i("🚀 CREATING NEW SERVICE",{renderCount:O,apiKey:(s==null?void 0:s.substring(0,8))+"...",serviceConfigChanged:w.current.serviceConfig!==n});const z=new co.StreamChatService({...n,apiKey:s,debug:a});return u(z),i("✅ SERVICE SET",{renderCount:O,serviceInstance:!!z}),()=>{i("🧹 SERVICE CLEANUP",{renderCount:O,reason:"Effect cleanup"}),z.disconnectUser().catch(console.error)}},[s,n,a,i]);const j=m.useRef(null);m.useEffect(()=>{var z,B;if(i("🔗 USER CONNECTION EFFECT TRIGGERED",{hasService:!!c,hasUser:!!t,userId:t==null?void 0:t.id,isConnecting:v.current,isConnected:f,dependencies:{service:!!c,userId:t==null?void 0:t.id}}),!c||!t){i("⚠️ USER CONNECTION SKIPPED","Missing service or user");return}if(v.current){i("⚠️ USER CONNECTION SKIPPED","Already connecting");return}if(((z=j.current)==null?void 0:z.serviceId)===c&&((B=j.current)==null?void 0:B.userId)===t.id){i("⚠️ USER CONNECTION SKIPPED","Already connected this user with this service");return}(async()=>{i("🚀 STARTING USER CONNECTION",{userId:t.id}),v.current=!0,g(!0),b(null);try{i("📞 CALLING SERVICE.CONNECTUSER",{userId:t.id});const T=await c.connectUser(t);h(T),p(!0),j.current={serviceId:c,userId:t.id},i("✅ USER CONNECTION SUCCESS",{userId:t.id,clientId:T.userID})}catch(T){const M=T instanceof Error?T.message:"Connection failed";b(M),i("❌ USER CONNECTION ERROR",{userId:t.id,error:M})}finally{g(!1),v.current=!1,i("🔄 USER CONNECTION FINISHED",{userId:t.id,isConnected:f})}})()},[c,t,i,f]),m.useEffect(()=>(i("🔌 CLEANUP EFFECT REGISTERED",{hasService:!!c,isConnected:f}),()=>{c&&f?(i("🧹 CLEANUP EFFECT TRIGGERED","Cleaning up connection on unmount"),j.current=null,c.disconnectUser().catch(console.error)):i("🔇 CLEANUP EFFECT SKIPPED",{hasService:!!c,isConnected:f})}),[c,f,i]);const R=m.useCallback(async()=>{if(i("🔄 REFRESH CONNECTION CALLED",{hasService:!!c,hasUser:!!t}),!c||!t){i("⚠️ REFRESH CONNECTION SKIPPED","Missing service or user");return}i("🚀 STARTING CONNECTION REFRESH",{userId:t.id}),g(!0);try{i("🔌 DISCONNECTING FOR REFRESH"),await c.disconnectUser(),i("📞 RECONNECTING FOR REFRESH");const O=await c.connectUser(t);h(O),p(!0),b(null),i("✅ CONNECTION REFRESH SUCCESS",{userId:t.id})}catch(O){const z=O instanceof Error?O.message:"Refresh failed";b(z),i("❌ CONNECTION REFRESH ERROR",{userId:t.id,error:z})}finally{g(!1),i("🔄 CONNECTION REFRESH FINISHED",{userId:t.id})}},[c,t,i]),D=m.useMemo(()=>(i("💫 CONTEXT VALUE MEMOIZATION",{hasService:!!c,hasClient:!!d,isConnected:f,isLoading:l,hasError:!!x,capabilitiesKeys:Object.keys(r)}),{service:c,client:d,isConnected:f,isLoading:l,error:x,capabilities:r,refreshConnection:R,debug:a}),[c,d,f,l,x,r,R,a,i]);return i("🔄 RENDER END",{renderCount:E.current,willRenderChat:!!(d&&f),contextValueReady:!!D}),o.jsx(Ys.Provider,{value:D,children:d&&f?o.jsx(F.Chat,{client:d,customClasses:{channelList:"str-chat__channel-list str-chat__channel-list-react bg-transparent lg:border-r-2 border-r-0 border-[#0000000A]"},children:e}):e})},Gs=()=>bn();function fo(e){const t=e.state.pending_messages;if(t!=null&&t.length)for(const n of t)e.state.addMessageSorted(n.message)}const qs=m.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,viewerLanguage:void 0}),mo=qs.Provider,ho=()=>m.useContext(qs),Ks=e=>{var s,r;const[t,n]=m.useState(!!((r=(s=e==null?void 0:e.state)==null?void 0:s.membership)!=null&&r.pinned_at));return m.useEffect(()=>{var i;if(!e){n(!1);return}n(!!((i=e.state.membership)!=null&&i.pinned_at));const a=c=>{var u;n(c!=null&&c.member?!!c.member.pinned_at:!!((u=e.state.membership)!=null&&u.pinned_at))};return e.on("member.updated",a),()=>{e.off("member.updated",a)}},[e]),t},po=(e,t)=>{const n=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())),r=new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())).getTime()-n.getTime();return Math.floor(r/(1e3*60*60*24))},Xs=e=>{const t=new Date;if(Math.floor((t.getTime()-e.getTime())/1e3)<60)return"Just now";const s=po(e,t);return s===0?e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):s===1?"Yesterday":s<7?`${s}d`:s<28?`${Math.floor(s/7)}w`:e.toLocaleDateString("en-US",{month:"numeric",day:"numeric",year:"2-digit"})};function Zs(e){return(e==null?void 0:e.trim().toLowerCase().split(/[-_]/)[0])||void 0}function vn({message:e,viewerLanguage:t}){var r;const n=e==null?void 0:e.text,s=Zs(t);return s?((r=e==null?void 0:e.i18n)==null?void 0:r[`${s}_text`])??n:n}const go=/^[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 Js(e){return go.test(e.trim())}function fs(e,t){const n=e==null?void 0:e.trim();return!n||t&&n===t?!1:!Js(n)}function Ot(e){return fs(e==null?void 0:e.name,e==null?void 0:e.id)?e.name.trim():fs(e==null?void 0:e.username,e==null?void 0:e.id)?e.username.trim():"Unknown member"}const ms=["🍎","🍌","🍇","🍊","🍓","🥥","🍒","🥭","🍉","🍋","🥝","🫒","🍈"];function xo(e){let t=0;for(let n=0;n<e.length;n++){const s=e.charCodeAt(n);t=(t<<5)-t+s,t=t&t}return Math.abs(t)}function bo(e){const n=xo(e)%ms.length;return ms[n]}const ke=({id:e,image:t,size:n=40,className:s,starred:r=!1,shape:a="squircle",dmAgentEnabled:i=!1})=>{const c=bo(e),d=n<32?"text-xs":n<56?"text-sm":n<120?"text-lg":"text-4xl",h=n>=40?2:1,f=a==="circle"?{borderRadius:"50%"}:{borderRadius:"33%",cornerShape:"superellipse(1.3)"},p=o.jsx("div",{className:"h-full w-full overflow-hidden",style:f,children:t?o.jsx("img",{src:t,alt:"",className:"h-full w-full object-cover"}):o.jsx("div",{"aria-hidden":"true",className:V("avatar-fallback flex h-full w-full items-center justify-center bg-[#E6E5E3] font-semibold select-none transition-colors",d),children:c})});return o.jsxs("div",{className:V("relative flex-shrink-0 !bg-transparent",s),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`},children:[r&&o.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:o.jsx(P.StarIcon,{className:"size-3 text-yellow-600",weight:"duotone"})}),o.jsx("div",{"data-testid":"avatar-ring",className:V("h-full w-full","bg-transparent"),style:{...f,...i&&{borderWidth:`${h}px`,borderStyle:"solid",borderColor:"var(--AI-Gradient, #7F22FE)",boxShadow:"inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"}},children:p})]})},vo=({size:e=15})=>o.jsx("svg",{width:e,height:e,viewBox:"0 0 15 15",fill:"none","aria-hidden":"true",children:o.jsx("path",{d:"M12.003 9a.985.985 0 0 1-.652.934l-3.223 1.191-1.188 3.226a.995.995 0 0 1-1.867 0l-1.195-3.226L.65 9.937a.995.995 0 0 1 0-1.867l3.227-1.195 1.187-3.226a.995.995 0 0 1 1.868 0l1.195 3.226 3.226 1.187a.99.99 0 0 1 .649.938m3-5.83a.52.52 0 0 1-.344.492l-1.702.63-.627 1.703a.525.525 0 0 1-.986 0l-.63-1.704-1.704-.627a.525.525 0 0 1 0-.986l1.703-.63.627-1.704a.526.526 0 0 1 .986 0l.631 1.703 1.704.627a.52.52 0 0 1 .342.495",fill:"currentColor",fillOpacity:.55})}),wo=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)==="MESSAGE_TIP"},yo=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)==="MESSAGE_PAID"},Nt=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)==="MESSAGE_CHATBOT"},_o=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)==="MESSAGE_ATTACHMENT"},Qs=e=>wo(e)||yo(e),Eo=e=>{var t;return Qs(e)&&!((t=e.text)!=null&&t.trim())},qt=({message:e,standalone:t=!1,isMyMessage:n=!1,hasAttachment:s=!1})=>{var f;const r=Qs(e),a=Nt(e);if(!r&&!a)return null;if(r){const p=(f=e.metadata)==null?void 0:f.amount_text;if(!p)return null;const l=t?"message-tip-standalone":"message-tag message-tag--tip",g=t?`${p} tip`:`Delivered with ${p} tip`;return o.jsxs("div",{className:l,children:[o.jsx(P.GiftIcon,{size:t?14:12}),o.jsx("span",{children:g})]})}const i=n&&s,c=i?"Sent with AI":"Sent with DM Agent",u=["message-chatbot-indicator",n?"message-chatbot-indicator--sender":"message-chatbot-indicator--receiver",i?"message-chatbot-indicator--attachment":"message-chatbot-indicator--text"].join(" "),d=o.jsx("span",{className:"message-chatbot-indicator__label",children:c}),h=o.jsx("span",{className:"message-chatbot-indicator__icon",children:o.jsx(vo,{size:i?12:15})});return o.jsx("div",{className:u,"data-testid":"message-chatbot-indicator",children:n&&!i?o.jsxs(o.Fragment,{children:[d,h]}):o.jsxs(o.Fragment,{children:[h,d]})})},er=m.memo(({channel:e,unread:t})=>{var D,O,z;const{selectedChannel:n,onChannelSelect:s,debug:r,renderMessagePreview:a,viewerLanguage:i}=ho(),c=(n==null?void 0:n.id)===(e==null?void 0:e.id),u=()=>{e&&s(e)},d=B=>{const T=B.key==="Enter"||B.key===" ",M=B.repeat;!T||M||(B.preventDefault(),u())},f=Object.values(((D=e==null?void 0:e.state)==null?void 0:D.members)||{}).find(B=>{var T,M;return((T=B.user)==null?void 0:T.id)&&B.user.id!==((M=e==null?void 0:e._client)==null?void 0:M.userID)}),p=Ot(f==null?void 0:f.user),l=(O=f==null?void 0:f.user)==null?void 0:O.image,g=(()=>{var T;const B=(T=e==null?void 0:e.state)==null?void 0:T.messages;if(B!=null&&B.length){for(let M=B.length-1;M>=0;M--)if(B[M].type!=="system")return B[M]}})(),b=(()=>{var U,W;const B=vn({message:g,viewerLanguage:i});if(B)return B;if(((U=g==null?void 0:g.metadata)==null?void 0:U.custom_type)==="MESSAGE_TIP")return"💵 Sent a tip";const M=(W=g==null?void 0:g.attachments)==null?void 0:W[0];return M?M.og_scrape_url?M.og_scrape_url:M.type==="image"?"📷 Sent an image":M.type==="video"?"🎥 Sent a video":M.type==="audio"?"🎵 Sent audio":M.type==="file"?"📎 Sent a file":"📎 Sent an attachment":"No messages yet"})(),v=g!=null&&g.created_at?Xs(new Date(g.created_at)):"",w=g?Nt(g):!1,E=a?a(g,b):`${w?"✨ ":""}${b}`,j=Ks(e),R=t??0;return r&&console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER",{channelId:e==null?void 0:e.id,isSelected:c,participantName:p,unreadCount:R,hasTimestamp:!!v}),o.jsx("div",{role:"button",tabIndex:0,onClick:u,onKeyDown:d,className:V("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":c,"hover:bg-sand":!c}),children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(ke,{id:((z=f==null?void 0:f.user)==null?void 0:z.id)||e.id||"unknown",name:p,image:l,size:44,starred:j,className:"[&_.avatar-fallback]:group-hover:bg-[#eeeeee]"}),o.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsxs("h3",{className:V("text-sm font-medium truncate",c?"text-primary":"text-charcoal"),children:[j&&o.jsx("span",{className:"sr-only",children:"Starred conversation. "}),p]}),v&&o.jsx("span",{className:"text-xs text-stone flex-shrink-0",children:v})]}),o.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[o.jsx("p",{className:"text-xs text-stone flex-1 line-clamp-1",children:E}),R>0&&o.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:R>99?"99+":R})]})]})]})})});er.displayName="CustomChannelPreview";const Co={last_message_at:-1},wn=m.memo(({onChannelSelect:e,selectedChannel:t,filters:n,allowNewMessagesFromUnfilteredChannels:s=!1,onMessageNew:r,onAddedToChannel:a,channelRenderFilterFn:i,sort:c=Co,className:u,customEmptyStateIndicator:d,renderMessagePreview:h,viewerLanguage:f})=>{const p=m.useRef(0);p.current++;const{debug:l=!1}=bn(),g=m.useCallback(b=>{for(const v of b)fo(v);return i?i(b):b},[i]);l&&console.log("📺 [ChannelList] 🔄 RENDER START",{renderCount:p.current,selectedChannelId:t==null?void 0:t.id,filters:n});const x=m.useMemo(()=>({selectedChannel:t,onChannelSelect:e,debug:l,renderMessagePreview:h,viewerLanguage:f}),[t,e,l,h,f]);return o.jsx("div",{className:V("messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",u),children:o.jsx("div",{className:"flex-1 overflow-hidden min-w-0",children:o.jsx(mo,{value:x,children:o.jsx(F.ChannelList,{filters:n,sort:c,options:{limit:30},allowNewMessagesFromUnfilteredChannels:s,onMessageNew:r,onAddedToChannel:a,channelRenderFilterFn:g,Preview:er,EmptyStateIndicator:d},`${JSON.stringify(n)}:${JSON.stringify(c)}`)})})})});wn.displayName="ChannelList";const st=({variant:e="default",className:t,children:n,...s})=>{const r=e==="danger";return o.jsx("button",{type:"button",className:V("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",t),...s,children:n})};function No({label:e,className:t,children:n,...s}){return o.jsxs("button",{type:"button",className:V("inline-flex items-center justify-center rounded-full transition-colors focus-ring p-2",{"cursor-not-allowed opacity-50":s.disabled,"hover:bg-sand":!s.disabled},t),...s,children:[o.jsx("span",{className:"sr-only",children:e}),n]})}function So({onClick:e}){return o.jsx(No,{label:"Close",onClick:e,className:"p-1",children:o.jsx(P.XIcon,{className:"h-5 w-5 text-stone",weight:"bold"})})}const jo=({dialogRef:e,onClose:t,participant:n,participantDisplayName:s,channel:r,followerStatusLabel:a,onLeaveConversation:i,onBlockParticipant:c,showDeleteConversation:u=!0,onDeleteConversationClick:d,onBlockParticipantClick:h,onReportParticipantClick:f,customProfileContent:p,customChannelActions:l})=>{var C,S,y,k;const{service:g,debug:x}=bn(),[b,v]=m.useState(!1),[w,E]=m.useState(!1),[j,R]=m.useState(!1),D=m.useCallback(async()=>{var _;if(!(!g||!((_=n==null?void 0:n.user)!=null&&_.id)))try{const N=(await g.getBlockedUsers()).some(A=>{var H;return A.blocked_user_id===((H=n==null?void 0:n.user)==null?void 0:H.id)});v(N)}catch(I){console.error("[ChannelInfoDialog] Failed to check blocked status:",I)}},[g,(C=n==null?void 0:n.user)==null?void 0:C.id]);m.useEffect(()=>{D()},[D]);const O=async()=>{var _;if(!w){d==null||d(),x&&console.log("[ChannelInfoDialog] Leave conversation",r.cid),E(!0);try{const I=((_=r._client)==null?void 0:_.userID)??null;await r.hide(I,!1),i&&await i(r),t()}catch(I){console.error("[ChannelInfoDialog] Failed to leave conversation",I)}finally{E(!1)}}},z=async()=>{var _,I,N;if(!(j||!g)){h==null||h(),x&&console.log("[ChannelInfoDialog] Block member",(_=n==null?void 0:n.user)==null?void 0:_.id),R(!0);try{await g.blockUser((I=n==null?void 0:n.user)==null?void 0:I.id),c&&await c((N=n==null?void 0:n.user)==null?void 0:N.id),t()}catch(A){console.error("[ChannelInfoDialog] Failed to block member",A)}finally{R(!1)}}},B=async()=>{var _,I,N;if(!(j||!g)){h==null||h(),x&&console.log("[ChannelInfoDialog] Unblock member",(_=n==null?void 0:n.user)==null?void 0:_.id),R(!0);try{await g.unBlockUser((I=n==null?void 0:n.user)==null?void 0:I.id),c&&await c((N=n==null?void 0:n.user)==null?void 0:N.id),t()}catch(A){console.error("[ChannelInfoDialog] Failed to unblock member",A)}finally{R(!1)}}},T=()=>{f==null||f(),t(),window.open("https://linktr.ee/s/about/trust-center/report","_blank","noopener,noreferrer")};if(!n)return null;const M=s??Ot(n.user),U=(S=n.user)==null?void 0:S.image,W=(y=n.user)==null?void 0:y.username,L=W?`linktr.ee/${W}`:void 0,$=((k=n.user)==null?void 0:k.id)||"unknown";return o.jsx("dialog",{ref:e,className:"mes-dialog group",onClose:t,onClick:_=>{_.target===e.current&&t()},children:o.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:[o.jsxs("div",{className:"flex items-center justify-between border-b border-sand px-4 py-3",children:[o.jsx("h2",{className:"text-base font-semibold text-charcoal",children:"Chat info"}),o.jsx(So,{onClick:t})]}),o.jsxs("div",{className:"flex-1 px-2 overflow-y-auto w-full",children:[o.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:[o.jsxs("div",{className:"flex items-center gap-3 w-full",children:[o.jsx(ke,{id:$,name:M,image:U,size:88,shape:"circle"}),o.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[o.jsx("p",{className:"truncate text-base font-semibold text-charcoal",children:M}),L&&o.jsx("p",{className:"truncate text-sm text-[#00000055]",children:L}),a&&!p&&o.jsx("span",{className:"mt-1 rounded-full text-xs font-normal w-fit",style:{padding:"4px 8px",backgroundColor:a==="Subscribed to you"?"#DCFCE7":"#F5F5F4",color:a==="Subscribed to you"?"#008236":"#78716C",lineHeight:"133.333%",letterSpacing:"0.21px"},children:a})]})]}),p&&o.jsx("div",{className:"w-full",children:p})]}),o.jsxs("ul",{className:"flex flex-col gap-2 mt-2",children:[u&&o.jsx("li",{children:o.jsxs(st,{onClick:O,disabled:w,"aria-busy":w,children:[w?o.jsx(P.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):o.jsx(P.SignOutIcon,{className:"h-5 w-5"}),o.jsx("span",{children:"Delete Conversation"})]})}),o.jsx("li",{children:b?o.jsxs(st,{onClick:B,disabled:j,"aria-busy":j,children:[j?o.jsx(P.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):o.jsx(P.ProhibitInsetIcon,{className:"h-5 w-5"}),o.jsx("span",{children:"Unblock"})]}):o.jsxs(st,{onClick:z,disabled:j,"aria-busy":j,children:[j?o.jsx(P.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):o.jsx(P.ProhibitInsetIcon,{className:"h-5 w-5"}),o.jsx("span",{children:"Block"})]})}),o.jsx("li",{children:o.jsxs(st,{variant:"danger",onClick:T,children:[o.jsx(P.FlagIcon,{className:"h-5 w-5"}),o.jsx("span",{children:"Report"})]})}),l]})]})]})})},ko=e=>o.jsx(F.DateSeparator,{...e,position:"center"}),on="vote_up",an="vote_down";function $o(e){return e!=null&&e.length?e.some(t=>t.type===an)?"down":e.some(t=>t.type===on)?"up":null:null}function tr(e){const{channel:t}=F.useChannelStateContext(),{client:n}=F.useChatContext("useMessageVote"),s=m.useMemo(()=>$o(e.own_reactions),[e.own_reactions]),r=m.useCallback(async()=>{if(n!=null&&n.userID)try{s==="up"?await t.deleteReaction(e.id,on):await t.sendReaction(e.id,{type:on},{enforce_unique:!0,skip_push:!0})}catch{}},[t,n==null?void 0:n.userID,e.id,s]),a=m.useCallback(async()=>{if(n!=null&&n.userID)try{s==="down"?await t.deleteReaction(e.id,an):await t.sendReaction(e.id,{type:an},{enforce_unique:!0,skip_push:!0})}catch{}},[t,n==null?void 0:n.userID,e.id,s]);return{selected:s,voteUp:r,voteDown:a}}const Mo=m.lazy(()=>Promise.resolve().then(()=>require("./Card-B0y7S-V2.cjs"))),Ro=m.lazy(()=>Promise.resolve().then(()=>require("./Card-W7jCeHUe.cjs"))),To=m.lazy(()=>Promise.resolve().then(()=>require("./Card-9X9RSzWd.cjs"))),yn=()=>o.jsx("div",{className:"w-[280px] min-h-[200px] animate-pulse rounded-md bg-black/[0.06] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_1px_2px_rgba(0,0,0,0.04),0_8px_32px_rgba(0,0,0,0.1)]","aria-hidden":!0}),Io=e=>o.jsx(m.Suspense,{fallback:o.jsx(yn,{}),children:o.jsx(Mo,{...e})}),nr=e=>o.jsx(m.Suspense,{fallback:o.jsx(yn,{}),children:o.jsx(Ro,{...e})}),sr=e=>o.jsx(m.Suspense,{fallback:o.jsx(yn,{}),children:o.jsx(To,{...e})}),Lo=nr,Do=sr,cn={Composer:Io,Sent:nr,Received:sr,Creator:Lo,Visitor:Do},Ao=[[/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 Re(e){return e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.startsWith("image/")?"image":"document"}function rr(e){const t=Ao.find(([n])=>n.test(e));return t?t[1]:"generic"}const Oo={video:P.VideoCameraIcon,audio:P.SpeakerHighIcon,image:P.ImageIcon,document:P.FileIcon},Fo={pdf:P.FilePdfIcon,doc:P.FileDocIcon,xls:P.FileXlsIcon,csv:P.FileCsvIcon,ppt:P.FilePptIcon,zip:P.FileZipIcon,text:P.FileTextIcon,markdown:P.FileMdIcon,generic:P.FileIcon};function Po(e){const t=Re(e);return t!=="document"?Oo[t]:Fo[rr(e)]}function Ue(e,t){return m.createElement(Po(e),t)}const zo=e=>{var t,n;return"touches"in e?((t=e.touches[0])==null?void 0:t.clientX)??((n=e.changedTouches[0])==null?void 0:n.clientX)??0:e.clientX},Bo=({source:e,mimeType:t,poster:n,autoPlay:s=!1,playing:r,loop:a=!1,controls:i=!0,showProgress:c=!1,muted:u=!1,onContainerClick:d})=>{const h=Re(t),f=m.useRef(null),p=m.useRef(null),l=m.useRef(null),g=m.useRef(r),[x,b]=m.useState(s),[v,w]=m.useState(0),[E,j]=m.useState(!1),[R,D]=m.useState(!1),[O,z]=m.useState(!1),[B,T]=m.useState(!1),[M,U]=m.useState(!0),[W,L]=m.useState(null),$=m.useCallback(()=>{z(!1),b(!0)},[]),C=m.useCallback(N=>{const A=p.current;if(!A)return 0;const H=A.getBoundingClientRect();return Math.max(0,Math.min(1,(zo(N)-H.left)/H.width))},[]),S=m.useCallback(N=>{const A=f.current;A&&A.duration&&(A.currentTime=N*A.duration)},[]),y=N=>{N.stopPropagation(),j(!0);const A=C(N);w(A),S(A)};m.useEffect(()=>{r!==void 0&&r!==g.current&&(g.current=r,b(r))},[r]),m.useEffect(()=>{if(!x){l.current!==null&&(cancelAnimationFrame(l.current),l.current=null);return}const N=()=>{const A=f.current;A&&A.duration&&!E&&w(A.currentTime/A.duration),l.current=requestAnimationFrame(N)};return l.current=requestAnimationFrame(N),()=>{l.current!==null&&cancelAnimationFrame(l.current)}},[x,E]),m.useEffect(()=>{const N=f.current;N&&(x?N.play().catch(A=>{b(!1),z(!0)}):N.pause())},[x]),m.useEffect(()=>{if(!E)return;const N=H=>w(C(H)),A=H=>{j(!1),S(C(H))};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",A),window.addEventListener("touchmove",N,{passive:!0}),window.addEventListener("touchend",A),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",A),window.removeEventListener("touchmove",N),window.removeEventListener("touchend",A)}},[E,C,S]);const k=W?{aspectRatio:String(W)}:void 0,_=W?"":" aspect-video",I=Math.round(v*100);return o.jsxs("div",{role:"button",tabIndex:0,className:`relative cursor-pointer overflow-hidden bg-black ${_}`,style:k,onClick:N=>{if(d){d(N);return}O||i&&b(A=>!A)},onKeyDown:N=>{if(!(N.key!=="Enter"&&N.key!==" ")){if(N.preventDefault(),d){d(N);return}O||i&&b(A=>!A)}},children:[n&&(h==="audio"||M)&&o.jsx("img",{src:n,alt:"",className:"absolute inset-0 h-full w-full object-cover"}),!n&&(h==="audio"||M)&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:Ue(t,{className:"size-12 text-black/20",weight:"regular"})}),o.jsx("div",{className:"absolute inset-0",children:h==="audio"?o.jsx("audio",{ref:f,src:e,loop:a,muted:u,style:{width:"100%",height:"100%"},onLoadStart:()=>T(!0),onCanPlay:()=>{T(!1),U(!1)},onWaiting:()=>T(!0),onPlay:()=>z(!1),onEnded:()=>{a||(b(!1),w(0))},children:o.jsx("track",{kind:"captions"})}):o.jsx("video",{ref:f,src:e,loop:a,muted:u,playsInline:!0,style:{width:"100%",height:"100%"},onLoadStart:()=>T(!0),onCanPlay:()=>{T(!1),U(!1)},onWaiting:()=>T(!0),onPlay:()=>z(!1),onLoadedMetadata:()=>{const N=f.current;N instanceof HTMLVideoElement&&N.videoWidth&&N.videoHeight&&L(N.videoWidth/N.videoHeight)},onEnded:()=>{a||(b(!1),w(0))},children:o.jsx("track",{kind:"captions"})})}),B&&!O&&o.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:o.jsx(P.CircleNotchIcon,{className:"size-8 animate-spin text-white/80",weight:"bold"})}),O&&!i&&o.jsx("div",{className:"absolute inset-0 z-30 flex cursor-pointer items-center justify-center bg-black/35",role:"button",tabIndex:0,"aria-label":"Play preview",onClick:N=>{N.stopPropagation(),$()},onKeyDown:N=>{N.key!=="Enter"&&N.key!==" "||(N.preventDefault(),N.stopPropagation(),$())},children:o.jsx("span",{className:"flex size-16 items-center justify-center rounded-full bg-white/20 text-white backdrop-blur-sm",children:o.jsx(P.PlayIcon,{className:"size-9 translate-x-0.5",weight:"fill"})})}),c&&!i&&o.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:o.jsx("div",{role:"slider","aria-label":"Playback position","aria-valuenow":I,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:p,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:y,onTouchStart:y,onClick:N=>N.stopPropagation(),onKeyDown:N=>{N.key==="ArrowRight"&&S(Math.min(1,v+.05)),N.key==="ArrowLeft"&&S(Math.max(0,v-.05))},children:o.jsx("div",{className:"w-full overflow-hidden rounded-full bg-white/30 h-1",children:o.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${I}%`}})})})}),i&&o.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:[o.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),b(A=>!A)},className:"shrink-0 text-white","aria-label":x?"Pause":"Play",children:x?o.jsx(P.PauseIcon,{className:"size-5",weight:"fill"}):o.jsx(P.PlayIcon,{className:"size-5 translate-x-px",weight:"fill"})}),o.jsxs("div",{role:"slider","aria-label":"Playback position","aria-valuenow":I,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:p,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:y,onTouchStart:y,onClick:N=>N.stopPropagation(),onMouseEnter:()=>D(!0),onMouseLeave:()=>D(!1),onKeyDown:N=>{N.key==="ArrowRight"&&S(Math.min(1,v+.05)),N.key==="ArrowLeft"&&S(Math.max(0,v-.05))},children:[o.jsx("div",{className:`w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${R||E?"h-1.5":"h-1"}`,children:o.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${I}%`}})}),o.jsx("div",{className:`absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${R||E?"scale-100 opacity-100":"scale-0 opacity-0"}`,style:{left:`${I}%`}})]})]})]})},hs=e=>e==="dark"?"size-12 text-white/20":"size-12 text-black/20",Vo=e=>e==="dark"?"aspect-video overflow-hidden bg-white/10":"aspect-video overflow-hidden bg-black/5",_n=({mimeType:e,sourceUrl:t,thumbnailUrl:n,title:s,variant:r,mediaPlayerProps:a,containedImage:i=!1})=>{const c=Re(e),[u,d]=m.useState(!1);return t&&(c==="video"||c==="audio")?o.jsx(Bo,{source:t,mimeType:e,poster:n,controls:!0,...a}):t&&c==="image"?i?o.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:o.jsx("img",{src:t,alt:s??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${u?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>d(!0)})}):o.jsx("img",{src:t,alt:s??"",className:"block w-full",draggable:!1}):t&&c==="document"?n?i?o.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:o.jsx("img",{src:n,alt:s??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${u?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>d(!0)})}):o.jsx("img",{src:n,alt:"",className:"block w-full",draggable:!1}):o.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${r==="dark"?"bg-white/10":"bg-black/5"}`,children:Ue(e,{className:hs(r),weight:"regular"})}):n?o.jsx("div",{className:`relative ${Vo(r)}`,children:o.jsx("img",{src:n,alt:s??"",draggable:!1,className:"absolute inset-0 h-full w-full object-cover"})}):o.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${r==="dark"?"bg-white/10":"bg-black/5"}`,children:Ue(e,{className:hs(r),weight:"regular"})})},or=({variant:e,thumbnail:t,title:n,placeholderTitle:s="Attachment title",mimeType:r,detail:a,statusBadge:i,action:c,topLeft:u,topRight:d,rootRef:h,"data-testid":f})=>{const p=e==="dark",l=p?n??s:n??"",g=p&&!n;return o.jsxs("div",{ref:h,"data-testid":f,className:V("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)]",p?"bg-[#121110]":"bg-white"),children:[u?o.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-50",children:u}):null,d?o.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-50",children:d}):null,t,o.jsxs("div",{className:"px-4 pb-3 pt-3",children:[l.trim()!==""&&o.jsx("p",{className:V("mb-0.5 truncate text-base font-medium",{"text-black":!p,"text-white/30":p&&g,"text-white":p&&!g}),children:l}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[Ue(r,{className:V("size-5 shrink-0",p?"text-white/55":"text-black/55"),weight:"regular"}),a!=null&&a!==""&&o.jsx("span",{className:V("text-xs font-medium",p?"text-white/55":"text-black/55"),children:a}),i]}),c]})]})};function ar(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function En(e){return`w-[280px] select-none overflow-hidden rounded-[24px] ${e?"bg-[#121110]":"bg-[#F3F3F1]"} shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]`}function Uo(e){return e?"bg-white/10":"bg-black/5"}function Ho(e){return e?"text-white":"text-black"}function Wo(e){return e?"text-white/55":"text-black/55"}function Yo(e){return e?"text-white/40":"text-black/40"}function Go(e){return e?"text-white/20":"text-black/20"}const Cn=({attachment:e,isMyMessage:t})=>{const{title:n,text:s,image_url:r,og_scrape_url:a,title_link:i}=e,c=a??i,u=typeof c=="string"&&c.trim()!==""?c:void 0,d=o.jsxs(m.Fragment,{children:[o.jsx("div",{className:"p-2",children:r?o.jsx("img",{src:r,alt:n??"",className:"aspect-video w-full rounded-[20px] object-cover"}):o.jsx("div",{className:`aspect-video w-full rounded-[20px] ${Uo(t)} flex items-center justify-center`,children:o.jsx(P.LinkIcon,{className:`size-12 ${Go(t)}`})})}),o.jsxs("div",{className:"px-3 pb-3",children:[n&&o.jsx("p",{className:`truncate text-[14px] font-medium leading-5 ${Ho(t)}`,children:n}),s&&o.jsx("p",{className:`truncate text-[12px] leading-4 ${Wo(t)}`,children:s}),u&&o.jsx("p",{className:`mt-1 truncate text-[12px] leading-4 ${Yo(t)}`,children:u})]})]});return u?o.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"block no-underline",children:d}):o.jsx("div",{className:"block",children:d})};function Nn(e){return e.type==="link"||!!e.og_scrape_url&&!e.asset_url}function Ft(e){var t;return(t=e.attachments)==null?void 0:t.find(Nn)}async function qo(e,t){let n;try{n=t??new URL(e).pathname.split("/").pop()??"download"}catch{n=t??"download"}const s=await fetch(e,{mode:"cors"});if(!s.ok)throw new Error(`HTTP ${s.status}`);const r=await s.blob(),a=URL.createObjectURL(r),i=document.createElement("a");i.href=a,i.download=n,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(a)}const Ko=({url:e,filename:t})=>{const[n,s]=m.useState(!1),r=a=>{a.stopPropagation();const i=window.open("","_blank","noopener,noreferrer");s(!0),qo(e,t).then(()=>{i==null||i.close()}).catch(()=>{i&&(i.location.href=e)}).finally(()=>s(!1))};return o.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?o.jsx(P.CircleNotchIcon,{className:"size-4 animate-spin text-white",weight:"bold"}):o.jsxs(m.Fragment,{children:[o.jsx(P.DownloadSimpleIcon,{className:"size-4 text-white",weight:"bold"}),"Download"]})})};function Pt(e){var f,p,l,g;const t=(f=e.attachments)==null?void 0:f.find(x=>x.type==="video"&&x.asset_url),n=(p=e.attachments)==null?void 0:p.find(x=>x.type==="image"&&x.image_url),s=(l=e.attachments)==null?void 0:l.find(x=>x.type==="audio"&&x.asset_url),r=(g=e.attachments)==null?void 0:g.find(x=>x.type==="file"&&x.asset_url),a=t??n??s??r,i=(t==null?void 0:t.asset_url)??(n==null?void 0:n.image_url)??(s==null?void 0:s.asset_url)??(r==null?void 0:r.asset_url);if(!i)return null;const c=(a==null?void 0:a.mime_type)??((a==null?void 0:a.type)==="image"?"image/jpeg":(a==null?void 0:a.type)==="video"?"video/mp4":(a==null?void 0:a.type)==="audio"?"audio/mpeg":"application/octet-stream"),u=a==null?void 0:a.title,d=a==null?void 0:a.file_size,h=t==null?void 0:t.thumb_url;return{resolvedUrl:i,resolvedType:c,title:u,fileSize:d,thumbnailUrl:h}}const ir=({resolvedUrl:e,resolvedType:t,title:n,fileSize:s,thumbnailUrl:r})=>{const a=s!==void 0?ar(s):void 0;return o.jsx(or,{variant:"dark",title:n,placeholderTitle:"",mimeType:t,detail:a,thumbnail:o.jsx(_n,{mimeType:t,sourceUrl:e,thumbnailUrl:r,title:n,variant:"dark"})})},cr=({resolvedUrl:e,resolvedType:t,title:n,fileSize:s,thumbnailUrl:r})=>{const a=Re(t),i=s!==void 0?ar(s):void 0;return o.jsx(or,{variant:"light",title:n,mimeType:t,detail:i,thumbnail:o.jsx(_n,{mimeType:t,sourceUrl:e,thumbnailUrl:r,title:n,variant:"light",containedImage:a==="image"||a==="document"}),action:o.jsx(Ko,{url:e,filename:n})})},Xo=({message:e,isMyMessage:t=!1})=>{const n=Ft(e),s=Pt(e);if(!n&&!s)return null;const r=t?"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 o.jsxs("div",{className:r,children:[!t&&e.user&&o.jsx(ke,{className:"str-chat__avatar str-chat__message-sender-avatar",id:e.user.id,image:e.user.image,name:e.user.name??e.user.id}),o.jsx("div",{className:"str-chat__message-inner",style:{marginInlineEnd:0,marginInlineStart:0},children:o.jsx("div",{className:"str-chat__message-bubble-wrapper",children:o.jsx("div",{className:"str-chat__message-bubble",style:{padding:0,borderRadius:0,overflow:"visible",background:"transparent"},children:n?o.jsx("div",{className:En(t),children:o.jsx(Cn,{attachment:n,isMyMessage:t})}):t?o.jsx(ir,{...s}):o.jsx(cr,{...s})})})})]})},Zo=({message:e})=>{const t=Ft(e);if(t)return o.jsx("div",{className:En(!0),children:o.jsx(Cn,{attachment:t,isMyMessage:!0})});const n=Pt(e);return n?o.jsx(ir,{...n}):null},Jo=({message:e})=>{const t=Ft(e);if(t)return o.jsx("div",{className:En(!1),children:o.jsx(Cn,{attachment:t,isMyMessage:!1})});const n=Pt(e);return n?o.jsx(cr,{...n}):null},Qo=Object.assign(Xo,{Creator:Zo,Visitor:Jo}),ea={isUnlocking:()=>!1},ta={LockedAttachment:ea},lr=m.createContext({}),na=lr.Provider;function ur(e){return m.useContext(lr)[e]??ta[e]}const dr=({selected:e,onVoteUp:t,onVoteDown:n})=>o.jsxs("div",{className:"message-vote-buttons",children:[o.jsx("button",{type:"button",className:V("message-vote-button focus-ring",{"message-vote-button--selected":e==="up"}),onClick:t,"aria-label":"Good response","aria-pressed":e==="up","data-tooltip":"Good response",children:o.jsx(P.ThumbsUpIcon,{size:16,weight:e==="up"?"fill":"regular"})}),o.jsx("button",{type:"button",className:V("message-vote-button focus-ring",{"message-vote-button--selected":e==="down"}),onClick:n,"aria-label":"Bad response","aria-pressed":e==="down","data-tooltip":"Bad response",children:o.jsx(P.ThumbsDownIcon,{size:16,weight:e==="down"?"fill":"regular"})})]}),sa=e=>{var Xn,Zn,Jn,Qn,es,ts,ns,ss,rs,os,as,is,cs,ls;const{additionalMessageInputProps:t,chatbotVotingEnabled:n,editing:s,endOfGroup:r,firstOfGroup:a,groupedByUser:i,handleAction:c,handleOpenThread:u,handleRetry:d,highlighted:h,isMessageAIGenerated:f,isMyMessage:p,message:l,renderText:g,threadList:x,viewerLanguage:b}=e,{client:v}=F.useChatContext("CustomMessage"),{channel:w}=F.useChannelStateContext("CustomMessage"),{isUnlocking:E,onUnlockClick:j,onFetchSource:R,onDownloadClick:D}=ur("LockedAttachment"),[O,z]=m.useState(!1),B=F.useMessageReminder(l.id),{selected:T,voteUp:M,voteDown:U}=tr(l),{Attachment:W=F.Attachment,EditMessageModal:L=F.EditMessageModal,MessageActions:$,MessageBlocked:C=F.MessageBlocked,MessageBouncePrompt:S=F.MessageBouncePrompt,MessageDeleted:y=F.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:k=F.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:_=F.MessageRepliesCountButton,ReminderNotification:I=F.ReminderNotification,StreamedMessageText:N=F.StreamedMessageText,PinIndicator:A}=F.useComponentContext("CustomMessage"),H=F.messageHasAttachments(l),G=F.messageHasReactions(l),re=m.useMemo(()=>f==null?void 0:f(l),[f,l]),X=m.useMemo(()=>{const tt=l.attachments??[],pt=l.shared_location?[l.shared_location,...tt]:tt;if(!Nt(l))return pt;const us=pt.filter(ds=>!("type"in ds)||!Nn(ds));return us.length===pt.length?pt:us},[l]),me=m.useMemo(()=>{const tt=vn({message:l,viewerLanguage:b});return tt===l.text?l:{...l,text:tt}},[l,b]);if(F.isDateSeparatorMessage(l))return null;if(l.deleted_at||l.type==="deleted")return o.jsx(y,{message:l});if(F.isMessageBlocked(l))return o.jsx(C,{});const le=!x&&!!l.reply_count,K=!x&&l.show_in_channel&&l.parent_id,Q=l.status==="failed"&&((Xn=l.error)==null?void 0:Xn.status)!==403,xe=F.isMessageBounced(l);let ae;Q?ae=()=>d(l):xe&&(ae=()=>z(!0));const Fe=p(),Gt=V("str-chat__message str-chat__message-simple",`str-chat__message--${l.type}`,`str-chat__message--${l.status}`,Fe?"str-chat__message--me str-chat__message-simple--me":"str-chat__message--other",l.text?"str-chat__message--has-text":"has-no-text",{"str-chat__message--has-attachment":H,"str-chat__message--highlighted":h,"str-chat__message--pinned pinned-message":l.pinned,"str-chat__message--with-reactions":G,"str-chat__message-send-can-be-retried":(l==null?void 0:l.status)==="failed"&&((Zn=l==null?void 0:l.error)==null?void 0:Zn.status)!==403,"str-chat__message-with-thread-link":le||K,"str-chat__virtual-message__wrapper--end":r,"str-chat__virtual-message__wrapper--first":a,"str-chat__virtual-message__wrapper--group":i}),Pe=l.poll_id&&v.polls.fromState(l.poll_id),Z=Eo(l),se=Nt(l),Ce=_o(l),Ne=!!(X!=null&&X.length&&!l.quoted_message),Kn=se&&Fe&&Ne;return o.jsxs(o.Fragment,{children:[s&&o.jsx(L,{additionalMessageInputProps:t}),O&&o.jsx(F.MessageBounceModal,{MessageBouncePrompt:S,onClose:()=>z(!1),open:O}),o.jsxs("div",{className:Gt,children:[A&&o.jsx(A,{}),!!B&&o.jsx(I,{reminder:B}),l.user&&o.jsx(ke,{className:"str-chat__avatar str-chat__message-sender-avatar",id:l.user.id,image:l.user.image,name:l.user.name||l.user.id,size:se?24:28,shape:"circle",dmAgentEnabled:se}),o.jsxs("div",{className:V("str-chat__message-inner",{"str-chat__simple-message--error-failed":Q||xe}),"data-testid":"message-inner",onClick:ae,onKeyDown:ae,role:ae?"button":void 0,tabIndex:ae?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:[Ce?o.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[Fe?o.jsx(cn.Sent,{title:(Jn=l.metadata)==null?void 0:Jn.attachment_title,mimeType:(Qn=l.metadata)==null?void 0:Qn.attachment_mime_type,thumbnailUrl:(es=l.metadata)==null?void 0:es.attachment_thumbnail,amountText:(ts=l.metadata)==null?void 0:ts.amount_text,detail:(ns=l.metadata)==null?void 0:ns.attachment_detail,paymentStatus:(ss=l.metadata)==null?void 0:ss.payment_status,onPreviewClick:()=>j==null?void 0:j(l,w),onFetchSource:async()=>await(R==null?void 0:R(l,w))}):o.jsx(cn.Received,{title:(rs=l.metadata)==null?void 0:rs.attachment_title,mimeType:(os=l.metadata)==null?void 0:os.attachment_mime_type,thumbnailUrl:(as=l.metadata)==null?void 0:as.attachment_thumbnail,amountText:(is=l.metadata)==null?void 0:is.amount_text,detail:(cs=l.metadata)==null?void 0:cs.attachment_detail,paymentStatus:(ls=l.metadata)==null?void 0:ls.payment_status,isUnlocking:E(l.id),onUnlockClick:()=>j==null?void 0:j(l,w),onFetchSource:async()=>await(R==null?void 0:R(l,w)),onDownloadClick:()=>D==null?void 0:D(l,w)}),l.text&&o.jsx("div",{className:"str-chat__message-bubble",children:o.jsx(F.MessageText,{message:me,renderText:g})})]}):Z?o.jsx(qt,{message:l,standalone:!0}):o.jsx("div",{className:"str-chat__message-bubble-wrapper",children:o.jsxs("div",{className:"str-chat__message-bubble",children:[se&&!Kn&&o.jsx(qt,{message:l,hasAttachment:Ne,isMyMessage:Fe}),Pe&&o.jsx(F.Poll,{poll:Pe}),X!=null&&X.length&&!l.quoted_message?o.jsx(W,{actionHandler:c,attachments:X}):null,re?o.jsx(N,{message:me,renderText:g}):o.jsx(F.MessageText,{message:me,renderText:g}),o.jsx(F.MessageErrorIcon,{})]})}),$&&o.jsx($,{})]}),!Ce&&!Z&&o.jsxs("div",{className:"str-chat__message-footer",children:[(!se||Kn)&&o.jsx(qt,{message:l,hasAttachment:Ne,isMyMessage:Fe}),n&&se&&o.jsx(dr,{selected:T,onVoteUp:M,onVoteDown:U})]}),le&&o.jsx(_,{onClick:u,reply_count:l.reply_count}),K&&o.jsx(k,{})]},l.id)]})},ra=m.memo(sa,(e,t)=>e.chatbotVotingEnabled!==t.chatbotVotingEnabled||e.viewerLanguage!==t.viewerLanguage?!1:F.areMessageUIPropsEqual(e,t)),oa=e=>{const t=F.useMessageContext("CustomMessage");return o.jsx(ra,{...t,...e})};function fr(e){var t,n,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=fr(e[t]))&&(s&&(s+=" "),s+=n)}else for(n in e)e[n]&&(s&&(s+=" "),s+=n);return s}function $e(){for(var e,t,n=0,s="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=fr(e))&&(s&&(s+=" "),s+=t);return s}const aa=m.createContext(void 0),Sn=e=>{const t=m.useContext(aa);return t||(console.warn(`The useChannelStateContext hook was called outside of the ChannelStateContext provider. Make sure this hook is called within a child of the Channel component. The errored call is located in the ${e} component.`),{})},ia=m.createContext(void 0),He=e=>{const t=m.useContext(ia);return t||(console.warn(`The useChatContext hook was called outside of the ChatContext provider. Make sure this hook is called within a child of the Chat component. The errored call is located in the ${e} component.`),{})},ca=m.createContext({}),mr=e=>m.useContext(ca);function jn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var gt={exports:{}},Kt={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* use-sync-external-store-shim.production.js
|
|
4
4
|
*
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
17
|
*/var gs;function ua(){return gs||(gs=1,process.env.NODE_ENV!=="production"&&(function(){function e(l,g){return l===g&&(l!==0||1/l===1/g)||l!==l&&g!==g}function t(l,g){h||r.startTransition===void 0||(h=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var x=g();if(!f){var b=g();a(x,b)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),f=!0)}b=i({inst:{value:x,getSnapshot:g}});var v=b[0].inst,w=b[1];return u(function(){v.value=x,v.getSnapshot=g,n(v)&&w({inst:v})},[l,x,g]),c(function(){return n(v)&&w({inst:v}),l(function(){n(v)&&w({inst:v})})},[l]),d(x),x}function n(l){var g=l.getSnapshot;l=l.value;try{var x=g();return!a(l,x)}catch{return!0}}function s(l,g){return g()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var r=m,a=typeof Object.is=="function"?Object.is:e,i=r.useState,c=r.useEffect,u=r.useLayoutEffect,d=r.useDebugValue,h=!1,f=!1,p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?s:t;Xt.useSyncExternalStore=r.useSyncExternalStore!==void 0?r.useSyncExternalStore:p,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Xt}var xs;function da(){return xs||(xs=1,process.env.NODE_ENV==="production"?gt.exports=la():gt.exports=ua()),gt.exports}var fa=da();const ma=()=>{};function hr(e,t){const n=m.useCallback(a=>(e==null?void 0:e.subscribeWithSelector(t,a))??ma,[e,t]),s=m.useMemo(()=>{let a;return()=>{const i=e==null?void 0:e.getLatestValue();if(!i)return;if(a&&a[0]===i)return a[1];const c=t(i);if(a){let u=!0;for(const d in a[1])if(a[1][d]!==c[d]){u=!1;break}if(u)return a[1]}return a=[i,c],a[1]}},[e,t]);return fa.useSyncExternalStore(n,s)}const kn=({dialogManagerId:e,id:t})=>{const{dialogManager:n}=Mn({dialogManagerId:e});return m.useEffect(()=>()=>{n.markForRemoval(t)},[n,t]),n.getOrCreate({id:t})},$n=({id:e})=>{const{dialogManager:t}=ga()??{};return{dialog:kn({dialogManagerId:t==null?void 0:t.id,id:e}),dialogManager:t}},Ke=(e,t)=>{const{dialogManager:n}=Mn({dialogManagerId:t}),s=m.useCallback(({dialogsById:r})=>{var a;return{isOpen:!!((a=r[e])!=null&&a.isOpen)}},[e]);return hr(n.state,s).isOpen},ha=({children:e,getPortalDestination:t,isOpen:n})=>{const[s,r]=m.useState(null);return m.useLayoutEffect(()=>{const a=t();!a||!n||r(a)},[t,n]),s?Hs.createPortal(e,s):null},pa=({children:e,dialogId:t,dialogManagerId:n})=>{const{dialogManager:s}=Mn({dialogId:t,dialogManagerId:n}),r=Ke(t,n),a=m.useCallback(()=>document.querySelector(`div[data-str-chat__portal-id="${s.id}"]`),[s.id]);return m.createElement(ha,{getPortalDestination:a,isOpen:r},e)},bs=new De.StateStore({}),pr=m.createContext(void 0),vs=({dialogId:e,dialogManagerId:t,newState:n,previousState:s})=>{var i,c;let r,a;return t?e?((i=n[t])!=null&&i.get(e)&&(r=n[t]),(c=s==null?void 0:s[t])!=null&&c.get(e)&&(a=s[t])):(r=n[t],a=s==null?void 0:s[t]):e&&(r=Object.values(n).find(u=>e&&(u==null?void 0:u.get(e))),a=s&&Object.values(s).find(u=>e&&(u==null?void 0:u.get(e)))),{managerInNewState:r,managerInPrevState:a}},Mn=({dialogId:e,dialogManagerId:t}={})=>{const n=m.useContext(pr),[s,r]=m.useState(()=>{const{managerInNewState:a}=vs({dialogId:e,dialogManagerId:t,newState:bs.getLatestValue(),previousState:void 0});return a?{dialogManager:a}:n});return m.useEffect(()=>{if(!e&&!t)return;const a=bs.subscribeWithSelector(i=>i,(i,c)=>{const{managerInNewState:u,managerInPrevState:d}=vs({dialogId:e,dialogManagerId:t,newState:i,previousState:c});(!d||(u==null?void 0:u.id)!==d.id)&&r(h=>(h==null?void 0:h.dialogManager.id)===(u==null?void 0:u.id)?h:{dialogManager:u||(n==null?void 0:n.dialogManager)})});return()=>{a()}},[e,t,n==null?void 0:n.dialogManager]),s!=null&&s.dialogManager||console.warn(`Dialog manager (manager id: ${t}, dialog id: ${e}) is not available`),s},ga=()=>m.useContext(pr),xa=m.createContext(void 0),te=e=>{const t=m.useContext(xa);return t||{}};var wt={exports:{}},ba=wt.exports,ws;function va(){return ws||(ws=1,(function(e,t){(function(n,s){e.exports=s()})(ba,(function(){var n=1e3,s=6e4,r=36e5,a="millisecond",i="second",c="minute",u="hour",d="day",h="week",f="month",p="quarter",l="year",g="date",x="Invalid Date",b=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,v=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,w={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(L){var $=["th","st","nd","rd"],C=L%100;return"["+L+($[(C-20)%10]||$[C]||$[0])+"]"}},E=function(L,$,C){var S=String(L);return!S||S.length>=$?L:""+Array($+1-S.length).join(C)+L},j={s:E,z:function(L){var $=-L.utcOffset(),C=Math.abs($),S=Math.floor(C/60),y=C%60;return($<=0?"+":"-")+E(S,2,"0")+":"+E(y,2,"0")},m:function L($,C){if($.date()<C.date())return-L(C,$);var S=12*(C.year()-$.year())+(C.month()-$.month()),y=$.clone().add(S,f),k=C-y<0,_=$.clone().add(S+(k?-1:1),f);return+(-(S+(C-y)/(k?y-_:_-y))||0)},a:function(L){return L<0?Math.ceil(L)||0:Math.floor(L)},p:function(L){return{M:f,y:l,w:h,d,D:g,h:u,m:c,s:i,ms:a,Q:p}[L]||String(L||"").toLowerCase().replace(/s$/,"")},u:function(L){return L===void 0}},R="en",D={};D[R]=w;var O="$isDayjsObject",z=function(L){return L instanceof U||!(!L||!L[O])},B=function L($,C,S){var y;if(!$)return R;if(typeof $=="string"){var k=$.toLowerCase();D[k]&&(y=k),C&&(D[k]=C,y=k);var _=$.split("-");if(!y&&_.length>1)return L(_[0])}else{var I=$.name;D[I]=$,y=I}return!S&&y&&(R=y),y||!S&&R},T=function(L,$){if(z(L))return L.clone();var C=typeof $=="object"?$:{};return C.date=L,C.args=arguments,new U(C)},M=j;M.l=B,M.i=z,M.w=function(L,$){return T(L,{locale:$.$L,utc:$.$u,x:$.$x,$offset:$.$offset})};var U=(function(){function L(C){this.$L=B(C.locale,null,!0),this.parse(C),this.$x=this.$x||C.x||{},this[O]=!0}var $=L.prototype;return $.parse=function(C){this.$d=(function(S){var y=S.date,k=S.utc;if(y===null)return new Date(NaN);if(M.u(y))return new Date;if(y instanceof Date)return new Date(y);if(typeof y=="string"&&!/Z$/i.test(y)){var _=y.match(b);if(_){var I=_[2]-1||0,N=(_[7]||"0").substring(0,3);return k?new Date(Date.UTC(_[1],I,_[3]||1,_[4]||0,_[5]||0,_[6]||0,N)):new Date(_[1],I,_[3]||1,_[4]||0,_[5]||0,_[6]||0,N)}}return new Date(y)})(C),this.init()},$.init=function(){var C=this.$d;this.$y=C.getFullYear(),this.$M=C.getMonth(),this.$D=C.getDate(),this.$W=C.getDay(),this.$H=C.getHours(),this.$m=C.getMinutes(),this.$s=C.getSeconds(),this.$ms=C.getMilliseconds()},$.$utils=function(){return M},$.isValid=function(){return this.$d.toString()!==x},$.isSame=function(C,S){var y=T(C);return this.startOf(S)<=y&&y<=this.endOf(S)},$.isAfter=function(C,S){return T(C)<this.startOf(S)},$.isBefore=function(C,S){return this.endOf(S)<T(C)},$.$g=function(C,S,y){return M.u(C)?this[S]:this.set(y,C)},$.unix=function(){return Math.floor(this.valueOf()/1e3)},$.valueOf=function(){return this.$d.getTime()},$.startOf=function(C,S){var y=this,k=!!M.u(S)||S,_=M.p(C),I=function(le,K){var Q=M.w(y.$u?Date.UTC(y.$y,K,le):new Date(y.$y,K,le),y);return k?Q:Q.endOf(d)},N=function(le,K){return M.w(y.toDate()[le].apply(y.toDate("s"),(k?[0,0,0,0]:[23,59,59,999]).slice(K)),y)},A=this.$W,H=this.$M,G=this.$D,re="set"+(this.$u?"UTC":"");switch(_){case l:return k?I(1,0):I(31,11);case f:return k?I(1,H):I(0,H+1);case h:var X=this.$locale().weekStart||0,me=(A<X?A+7:A)-X;return I(k?G-me:G+(6-me),H);case d:case g:return N(re+"Hours",0);case u:return N(re+"Minutes",1);case c:return N(re+"Seconds",2);case i:return N(re+"Milliseconds",3);default:return this.clone()}},$.endOf=function(C){return this.startOf(C,!1)},$.$set=function(C,S){var y,k=M.p(C),_="set"+(this.$u?"UTC":""),I=(y={},y[d]=_+"Date",y[g]=_+"Date",y[f]=_+"Month",y[l]=_+"FullYear",y[u]=_+"Hours",y[c]=_+"Minutes",y[i]=_+"Seconds",y[a]=_+"Milliseconds",y)[k],N=k===d?this.$D+(S-this.$W):S;if(k===f||k===l){var A=this.clone().set(g,1);A.$d[I](N),A.init(),this.$d=A.set(g,Math.min(this.$D,A.daysInMonth())).$d}else I&&this.$d[I](N);return this.init(),this},$.set=function(C,S){return this.clone().$set(C,S)},$.get=function(C){return this[M.p(C)]()},$.add=function(C,S){var y,k=this;C=Number(C);var _=M.p(S),I=function(H){var G=T(k);return M.w(G.date(G.date()+Math.round(H*C)),k)};if(_===f)return this.set(f,this.$M+C);if(_===l)return this.set(l,this.$y+C);if(_===d)return I(1);if(_===h)return I(7);var N=(y={},y[c]=s,y[u]=r,y[i]=n,y)[_]||1,A=this.$d.getTime()+C*N;return M.w(A,this)},$.subtract=function(C,S){return this.add(-1*C,S)},$.format=function(C){var S=this,y=this.$locale();if(!this.isValid())return y.invalidDate||x;var k=C||"YYYY-MM-DDTHH:mm:ssZ",_=M.z(this),I=this.$H,N=this.$m,A=this.$M,H=y.weekdays,G=y.months,re=y.meridiem,X=function(K,Q,xe,ae){return K&&(K[Q]||K(S,k))||xe[Q].slice(0,ae)},me=function(K){return M.s(I%12||12,K,"0")},le=re||function(K,Q,xe){var ae=K<12?"AM":"PM";return xe?ae.toLowerCase():ae};return k.replace(v,(function(K,Q){return Q||(function(xe){switch(xe){case"YY":return String(S.$y).slice(-2);case"YYYY":return M.s(S.$y,4,"0");case"M":return A+1;case"MM":return M.s(A+1,2,"0");case"MMM":return X(y.monthsShort,A,G,3);case"MMMM":return X(G,A);case"D":return S.$D;case"DD":return M.s(S.$D,2,"0");case"d":return String(S.$W);case"dd":return X(y.weekdaysMin,S.$W,H,2);case"ddd":return X(y.weekdaysShort,S.$W,H,3);case"dddd":return H[S.$W];case"H":return String(I);case"HH":return M.s(I,2,"0");case"h":return me(1);case"hh":return me(2);case"a":return le(I,N,!0);case"A":return le(I,N,!1);case"m":return String(N);case"mm":return M.s(N,2,"0");case"s":return String(S.$s);case"ss":return M.s(S.$s,2,"0");case"SSS":return M.s(S.$ms,3,"0");case"Z":return _}return null})(K)||_.replace(":","")}))},$.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},$.diff=function(C,S,y){var k,_=this,I=M.p(S),N=T(C),A=(N.utcOffset()-this.utcOffset())*s,H=this-N,G=function(){return M.m(_,N)};switch(I){case l:k=G()/12;break;case f:k=G();break;case p:k=G()/3;break;case h:k=(H-A)/6048e5;break;case d:k=(H-A)/864e5;break;case u:k=H/r;break;case c:k=H/s;break;case i:k=H/n;break;default:k=H}return y?k:M.a(k)},$.daysInMonth=function(){return this.endOf(f).$D},$.$locale=function(){return D[this.$L]},$.locale=function(C,S){if(!C)return this.$L;var y=this.clone(),k=B(C,S,!0);return k&&(y.$L=k),y},$.clone=function(){return M.w(this.$d,this)},$.toDate=function(){return new Date(this.valueOf())},$.toJSON=function(){return this.isValid()?this.toISOString():null},$.toISOString=function(){return this.$d.toISOString()},$.toString=function(){return this.$d.toUTCString()},L})(),W=U.prototype;return T.prototype=W,[["$ms",a],["$s",i],["$m",c],["$H",u],["$W",d],["$M",f],["$y",l],["$D",g]].forEach((function(L){W[L[1]]=function($){return this.$g($,L[0],L[1])}})),T.extend=function(L,$){return L.$i||(L($,U,T),L.$i=!0),T},T.locale=B,T.isDayjs=z,T.unix=function(L){return T(1e3*L)},T.en=D[R],T.Ls=D,T.p={},T}))})(wt)),wt.exports}var wa=va();const Rn=jn(wa);var yt={exports:{}},ya=yt.exports,ys;function _a(){return ys||(ys=1,(function(e,t){(function(n,s){e.exports=s()})(ya,(function(){return function(n,s,r){var a="h:mm A",i={lastDay:"[Yesterday at] "+a,sameDay:"[Today at] "+a,nextDay:"[Tomorrow at] "+a,nextWeek:"dddd [at] "+a,lastWeek:"[Last] dddd [at] "+a,sameElse:"MM/DD/YYYY"};s.prototype.calendar=function(c,u){var d=u||this.$locale().calendar||i,h=r(c||void 0).startOf("d"),f=this.diff(h,"d",!0),p="sameElse",l=f<-6?p:f<-1?"lastWeek":f<0?"lastDay":f<1?"sameDay":f<2?"nextDay":f<7?"nextWeek":p,g=d[l]||i[l];return typeof g=="function"?g.call(this,r()):this.format(g)}}}))})(yt)),yt.exports}var Ea=_a();const Ca=jn(Ea);var _t={exports:{}},Na=_t.exports,_s;function Sa(){return _s||(_s=1,(function(e,t){(function(n,s){e.exports=s()})(Na,(function(){var n={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(s,r,a){var i=r.prototype,c=i.format;a.en.formats=n,i.format=function(u){u===void 0&&(u="YYYY-MM-DDTHH:mm:ssZ");var d=this.$locale().formats,h=(function(f,p){return f.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(l,g,x){var b=x&&x.toUpperCase();return g||p[x]||n[x]||p[b].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(v,w,E){return w||E.slice(1)}))}))})(u,d===void 0?{}:d);return c.call(this,h)}}}))})(_t)),_t.exports}var ja=Sa();const ka=jn(ja),$a=(e=>e),Ma=e=>Rn(e);Rn.extend(Ca);Rn.extend(ka);const Ra=m.createContext({t:$a,tDateTimeParser:Ma,userLanguage:"en"}),oe=e=>{const t=m.useContext(Ra);return t||(console.warn(`The useTranslationContext hook was called outside of the TranslationContext provider. Make sure this hook is called within a child of the Chat component. The errored call is located in the ${e} component.`),{})},Ta=m.createContext(void 0),Ia=()=>m.useContext(Ta),La={User:e=>m.createElement("svg",{className:"str-chat__icon str-chat__icon--user",fill:"none",height:"16",viewBox:"0 0 16 16",width:"16",xmlns:"http://www.w3.org/2000/svg",...e},m.createElement("path",{d:"M8 2C9.1 2 10 2.9 10 4C10 5.1 9.1 6 8 6C6.9 6 6 5.1 6 4C6 2.9 6.9 2 8 2ZM8 12C10.7 12 13.8 13.29 14 14H2C2.23 13.28 5.31 12 8 12ZM8 0C5.79 0 4 1.79 4 4C4 6.21 5.79 8 8 8C10.21 8 12 6.21 12 4C12 1.79 10.21 0 8 0ZM8 10C5.33 10 0 11.34 0 14V16H16V14C16 11.34 10.67 10 8 10Z",fill:"currentColor"}))},Da=(e,t)=>{const n=e.charCodeAt(t);if(Number.isNaN(n))return"";if(n<55296||n>57343)return e.charAt(t);if(55296<=n&&n<=56319){if(e.length<=t+1)throw"High surrogate without following low surrogate";const s=e.charCodeAt(t+1);if(56320>s||s>57343)throw"High surrogate without following low surrogate";return e.charAt(t)+e.charAt(t+1)}throw"Low surrogate without preceding high surrogate"},Aa=e=>{const{className:t,image:n,name:s,onClick:r=()=>{},onMouseOver:a=()=>{}}=e,[i,c]=m.useState(!1);m.useEffect(()=>{c(!1)},[n]);const u=(s==null?void 0:s.toString())||"",d=Da(u,0),h=n&&!i;return m.createElement("div",{className:$e("str-chat__avatar str-chat__message-sender-avatar",t,{"str-chat__avatar--multiple-letters":d.length>1,"str-chat__avatar--no-letters":!d.length,"str-chat__avatar--one-letter":d.length===1}),"data-testid":"avatar",onClick:r,onMouseOver:a,role:"button",title:s},h?m.createElement("img",{alt:d,className:"str-chat__avatar-image","data-testid":"avatar-img",onError:()=>c(!0),src:n}):m.createElement(m.Fragment,null,!!d.length&&m.createElement("div",{className:$e("str-chat__avatar-fallback"),"data-testid":"avatar-fallback"},d),!d.length&&m.createElement(La.User,null)))},Oa=(e,t)=>!t||!e?!1:!!t.filter(s=>{var r;return s.target.id===((r=e.user)==null?void 0:r.id)}).length,Zt={markUnread:"markUnread",pin:"pin",reply:"reply"},Fa=[Zt.pin,Zt.reply,Zt.markUnread],Pa=(e,t,n)=>{var w,E,j;const{channel:s,channelCapabilities:r={}}=Sn("useUserRole"),{client:a}=He("useUserRole"),i=((w=a.user)==null?void 0:w.role)==="admin"||s.state.membership.role==="admin",c=s.state.membership.role==="owner",u=((E=a.user)==null?void 0:E.role)==="channel_moderator"||s.state.membership.role==="channel_moderator"||s.state.membership.role==="moderator"||s.state.membership.is_moderator===!0||s.state.membership.channel_role==="channel_moderator",d=a.userID===((j=e.user)==null?void 0:j.id),h=!e.poll&&(r["update-any-message"]||d&&r["update-own-message"]),f=r["delete-any-message"]||d&&r["delete-own-message"],p=!d&&r["flag-message"],l=r["read-events"],g=!d&&r["mute-channel"],x=r["quote-message"],b=r["send-reaction"],v=r["send-reply"];return{canDelete:f,canEdit:h,canFlag:p,canMarkUnread:l,canMute:g,canQuote:x,canReact:b,canReply:v,isAdmin:i,isModerator:u,isMyMessage:d,isOwner:c}},za=e=>{const{client:t}=He(),n=m.useCallback(r=>({reminder:r.reminders.get(e)}),[e]),{reminder:s}=hr(t.reminders.state,n);return s},ee=e=>(e==null?void 0:e.ownerDocument)??document,Je=e=>e&&"window"in e&&e.window===e?e:ee(e).defaultView||window;function Ba(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function Va(e){return Ba(e)&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}let Ua=!1;function zt(){return Ua}function St(e,t){if(!zt())return t&&e?e.contains(t):!1;if(!e||!t)return!1;let n=t;for(;n!==null;){if(n===e)return!0;n.tagName==="SLOT"&&n.assignedSlot?n=n.assignedSlot.parentNode:Va(n)?n=n.host:n=n.parentNode}return!1}const pe=(e=document)=>{var n;if(!zt())return e.activeElement;let t=e.activeElement;for(;t&&"shadowRoot"in t&&((n=t.shadowRoot)!=null&&n.activeElement);)t=t.shadowRoot.activeElement;return t};function de(e){if(zt()&&e.target instanceof Element&&e.target.shadowRoot){if("composedPath"in e)return e.composedPath()[0]??null;if("composedPath"in e.nativeEvent)return e.nativeEvent.composedPath()[0]??null}return e.target}class Ha{constructor(t,n,s,r){this._walkerStack=[],this._currentSetFor=new Set,this._acceptNode=i=>{var c;if(i.nodeType===Node.ELEMENT_NODE){const u=i.shadowRoot;if(u){const d=this._doc.createTreeWalker(u,this.whatToShow,{acceptNode:this._acceptNode});return this._walkerStack.unshift(d),NodeFilter.FILTER_ACCEPT}else{if(typeof this.filter=="function")return this.filter(i);if((c=this.filter)!=null&&c.acceptNode)return this.filter.acceptNode(i);if(this.filter===null)return NodeFilter.FILTER_ACCEPT}}return NodeFilter.FILTER_SKIP},this._doc=t,this.root=n,this.filter=r??null,this.whatToShow=s??NodeFilter.SHOW_ALL,this._currentNode=n,this._walkerStack.unshift(t.createTreeWalker(n,s,this._acceptNode));const a=n.shadowRoot;if(a){const i=this._doc.createTreeWalker(a,this.whatToShow,{acceptNode:this._acceptNode});this._walkerStack.unshift(i)}}get currentNode(){return this._currentNode}set currentNode(t){if(!St(this.root,t))throw new Error("Cannot set currentNode to a node that is not contained by the root node.");const n=[];let s=t,r=t;for(this._currentNode=t;s&&s!==this.root;)if(s.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const i=s,c=this._doc.createTreeWalker(i,this.whatToShow,{acceptNode:this._acceptNode});n.push(c),c.currentNode=r,this._currentSetFor.add(c),s=r=i.host}else s=s.parentNode;const a=this._doc.createTreeWalker(this.root,this.whatToShow,{acceptNode:this._acceptNode});n.push(a),a.currentNode=r,this._currentSetFor.add(a),this._walkerStack=n}get doc(){return this._doc}firstChild(){let t=this.currentNode,n=this.nextNode();return St(t,n)?(n&&(this.currentNode=n),n):(this.currentNode=t,null)}lastChild(){let n=this._walkerStack[0].lastChild();return n&&(this.currentNode=n),n}nextNode(){var n;const t=this._walkerStack[0].nextNode();if(t){if(t.shadowRoot){let r;if(typeof this.filter=="function"?r=this.filter(t):(n=this.filter)!=null&&n.acceptNode&&(r=this.filter.acceptNode(t)),r===NodeFilter.FILTER_ACCEPT)return this.currentNode=t,t;let a=this.nextNode();return a&&(this.currentNode=a),a}return t&&(this.currentNode=t),t}else if(this._walkerStack.length>1){this._walkerStack.shift();let s=this.nextNode();return s&&(this.currentNode=s),s}else return null}previousNode(){var s;const t=this._walkerStack[0];if(t.currentNode===t.root){if(this._currentSetFor.has(t))if(this._currentSetFor.delete(t),this._walkerStack.length>1){this._walkerStack.shift();let r=this.previousNode();return r&&(this.currentNode=r),r}else return null;return null}const n=t.previousNode();if(n){if(n.shadowRoot){let a;if(typeof this.filter=="function"?a=this.filter(n):(s=this.filter)!=null&&s.acceptNode&&(a=this.filter.acceptNode(n)),a===NodeFilter.FILTER_ACCEPT)return n&&(this.currentNode=n),n;let i=this.lastChild();return i&&(this.currentNode=i),i}return n&&(this.currentNode=n),n}else if(this._walkerStack.length>1){this._walkerStack.shift();let r=this.previousNode();return r&&(this.currentNode=r),r}else return null}nextSibling(){return null}previousSibling(){return null}parentNode(){return null}}function Wa(e,t,n,s){return zt()?new Ha(e,t,n,s):e.createTreeWalker(t,n,s)}function ln(e){if(Ya())e.focus({preventScroll:!0});else{let t=Ga(e);e.focus(),qa(t)}}let xt=null;function Ya(){if(xt==null){xt=!1;try{document.createElement("div").focus({get preventScroll(){return xt=!0,!0}})}catch{}}return xt}function Ga(e){let t=e.parentNode,n=[],s=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==s;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return s instanceof HTMLElement&&n.push({element:s,scrollTop:s.scrollTop,scrollLeft:s.scrollLeft}),n}function qa(e){for(let{element:t,scrollTop:n,scrollLeft:s}of e)t.scrollTop=n,t.scrollLeft=s}const Ka=typeof Element<"u"&&"checkVisibility"in Element.prototype;function Xa(e){const t=Je(e);if(!(e instanceof t.HTMLElement)&&!(e instanceof t.SVGElement))return!1;let{display:n,visibility:s}=e.style,r=n!=="none"&&s!=="hidden"&&s!=="collapse";if(r){const{getComputedStyle:a}=e.ownerDocument.defaultView;let{display:i,visibility:c}=a(e);r=i!=="none"&&c!=="hidden"&&c!=="collapse"}return r}function Za(e,t){return!e.hasAttribute("hidden")&&!e.hasAttribute("data-react-aria-prevent-focus")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function Tn(e,t){return Ka?e.checkVisibility({visibilityProperty:!0})&&!e.closest("[data-react-aria-prevent-focus]"):e.nodeName!=="#comment"&&Xa(e)&&Za(e,t)&&(!e.parentElement||Tn(e.parentElement,e))}const In=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","a[href]","area[href]","summary","iframe","object","embed","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable^="false"])',"permission"],Ja=In.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])";In.push('[tabindex]:not([tabindex="-1"]):not([disabled])');const Qa=In.join(':not([hidden]):not([tabindex="-1"]),');function ei(e,t){return e.matches(Ja)&&!gr(e)&&((t==null?void 0:t.skipVisibilityCheck)||Tn(e))}function ti(e){return e.matches(Qa)&&Tn(e)&&!gr(e)}function gr(e){let t=e;for(;t!=null;){if(t instanceof t.ownerDocument.defaultView.HTMLElement&&t.inert)return!0;t=t.parentElement}return!1}const ve=typeof document<"u"?m.useLayoutEffect:()=>{};let ni=!1;function Bt(e){var n;if(typeof window>"u"||window.navigator==null)return!1;let t=(n=window.navigator.userAgentData)==null?void 0:n.brands;return Array.isArray(t)&&t.some(s=>e.test(s.brand))||e.test(window.navigator.userAgent)}function Ln(e){var t;return typeof window<"u"&&window.navigator!=null?e.test(((t=window.navigator.userAgentData)==null?void 0:t.platform)||window.navigator.platform):!1}function Te(e){if(process.env.NODE_ENV==="test")return e;let t=null;return()=>(t==null&&(t=e()),t)}const at=Te(function(){return Ln(/^Mac/i)}),si=Te(function(){return Ln(/^iPhone/i)}),xr=Te(function(){return Ln(/^iPad/i)||at()&&navigator.maxTouchPoints>1}),ri=Te(function(){return si()||xr()});Te(function(){return at()||ri()});const oi=Te(function(){return Bt(/AppleWebKit/i)&&!br()}),br=Te(function(){return Bt(/Chrome/i)}),vr=Te(function(){return Bt(/Android/i)}),ai=Te(function(){return Bt(/Firefox/i)});function ii(e){return e.pointerType===""&&e.isTrusted?!0:vr()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function it(e,t,n=!0){var u,d;let{metaKey:s,ctrlKey:r,altKey:a,shiftKey:i}=t;ai()&&((d=(u=window.event)==null?void 0:u.type)!=null&&d.startsWith("key"))&&e.target==="_blank"&&(at()?s=!0:r=!0);let c=oi()&&at()&&!xr()&&process.env.NODE_ENV!=="test"?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:s,ctrlKey:r,altKey:a,shiftKey:i}):new MouseEvent("click",{metaKey:s,ctrlKey:r,altKey:a,shiftKey:i,detail:1,bubbles:!0,cancelable:!0});it.isOpening=n,ln(e),e.dispatchEvent(c),it.isOpening=!1}it.isOpening=!1;let lt=null;const ci=new Set;let ot=new Map,We=!1,un=!1;function Dn(e,t){for(let n of ci)n(e,t)}function li(e){return!(e.metaKey||!at()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function jt(e){We=!0,!it.isOpening&&li(e)&&(lt="keyboard",Dn("keyboard",e))}function ue(e){lt="pointer","pointerType"in e&&e.pointerType,(e.type==="mousedown"||e.type==="pointerdown")&&(We=!0,Dn("pointer",e))}function wr(e){!it.isOpening&&ii(e)&&(We=!0,lt="virtual")}function yr(e){let t=Je(de(e)),n=ee(de(e));de(e)===t||de(e)===n||ni||!e.isTrusted||(!We&&!un&&(lt="virtual",Dn("virtual",e)),We=!1,un=!1)}function _r(){We=!1,un=!0}function Es(e){if(typeof window>"u"||typeof document>"u")return;const t=Je(e),n=ee(e);if(ot.get(t))return;let s=t.HTMLElement.prototype.focus;t.HTMLElement.prototype.focus=function(){We=!0,s.apply(this,arguments)},n.addEventListener("keydown",jt,!0),n.addEventListener("keyup",jt,!0),n.addEventListener("click",wr,!0),t.addEventListener("focus",yr,!0),t.addEventListener("blur",_r,!1),typeof PointerEvent<"u"?(n.addEventListener("pointerdown",ue,!0),n.addEventListener("pointermove",ue,!0),n.addEventListener("pointerup",ue,!0)):process.env.NODE_ENV==="test"&&(n.addEventListener("mousedown",ue,!0),n.addEventListener("mousemove",ue,!0),n.addEventListener("mouseup",ue,!0)),t.addEventListener("beforeunload",()=>{Er(e)},{once:!0}),ot.set(t,{focus:s})}const Er=(e,t)=>{const n=Je(e),s=ee(e);t&&s.removeEventListener("DOMContentLoaded",t),ot.has(n)&&(n.HTMLElement.prototype.focus=ot.get(n).focus,s.removeEventListener("keydown",jt,!0),s.removeEventListener("keyup",jt,!0),s.removeEventListener("click",wr,!0),n.removeEventListener("focus",yr,!0),n.removeEventListener("blur",_r,!1),typeof PointerEvent<"u"?(s.removeEventListener("pointerdown",ue,!0),s.removeEventListener("pointermove",ue,!0),s.removeEventListener("pointerup",ue,!0)):process.env.NODE_ENV==="test"&&(s.removeEventListener("mousedown",ue,!0),s.removeEventListener("mousemove",ue,!0),s.removeEventListener("mouseup",ue,!0)),ot.delete(n))};function ui(e){const t=ee(e);let n;return t.readyState!=="loading"?Es(e):(n=()=>{Es(e)},t.addEventListener("DOMContentLoaded",n)),()=>Er(e,n)}typeof document<"u"&&ui();function Cr(){return lt}let Le=new Map,dn=new Set;function Cs(){if(typeof window>"u")return;function e(s){return"propertyName"in s}let t=s=>{let r=de(s);if(!e(s)||!r)return;let a=Le.get(r);a||(a=new Set,Le.set(r,a),r.addEventListener("transitioncancel",n,{once:!0})),a.add(s.propertyName)},n=s=>{let r=de(s);if(!e(s)||!r)return;let a=Le.get(r);if(a&&(a.delete(s.propertyName),a.size===0&&(r.removeEventListener("transitioncancel",n),Le.delete(r)),Le.size===0)){for(let i of dn)i();dn.clear()}};document.body.addEventListener("transitionrun",t),document.body.addEventListener("transitionend",n)}typeof document<"u"&&(document.readyState!=="loading"?Cs():document.addEventListener("DOMContentLoaded",Cs));function di(){for(const[e]of Le)"isConnected"in e&&!e.isConnected&&Le.delete(e)}function fi(e){requestAnimationFrame(()=>{di(),Le.size===0?e():dn.add(e)})}function mi(e){if(!e.isConnected)return;const t=ee(e);if(Cr()==="virtual"){let n=pe(t);fi(()=>{const s=pe(t);(s===n||s===t.body)&&e.isConnected&&ln(e)})}else ln(e)}const Ns=m.createContext(null),fn="react-aria-focus-scope-restore";let q=null;function hi(e){let{children:t,contain:n,restoreFocus:s,autoFocus:r}=e,a=m.useRef(null),i=m.useRef(null),c=m.useRef([]),{parentNode:u}=m.useContext(Ns)||{},d=m.useMemo(()=>new hn({scopeRef:c}),[c]);ve(()=>{let p=u||J.root;if(J.getTreeNode(p.scopeRef)&&q&&!kt(q,p.scopeRef)){let l=J.getTreeNode(q);l&&(p=l)}p.addChild(d),J.addNode(d)},[d,u]),ve(()=>{let p=J.getTreeNode(c);p&&(p.contain=!!n)},[n]),ve(()=>{var x;let p=(x=a.current)==null?void 0:x.nextSibling,l=[],g=b=>b.stopPropagation();for(;p&&p!==i.current;)l.push(p),p.addEventListener(fn,g),p=p.nextSibling;return c.current=l,()=>{for(let b of l)b.removeEventListener(fn,g)}},[t]),wi(c,s,n),bi(c,n),yi(c,s,n),vi(c,r),m.useEffect(()=>{const p=pe(ee(c.current?c.current[0]:void 0));let l=null;if(fe(p,c.current)){for(let g of J.traverse())g.scopeRef&&fe(p,g.scopeRef.current)&&(l=g);l===J.getTreeNode(c)&&(q=l.scopeRef)}},[c]),ve(()=>()=>{var l,g;let p=((g=(l=J.getTreeNode(c))==null?void 0:l.parent)==null?void 0:g.scopeRef)??null;(c===q||kt(c,q))&&(!p||J.getTreeNode(p))&&(q=p),J.removeTreeNode(c)},[c]);let h=m.useMemo(()=>pi(c),[]),f=m.useMemo(()=>({focusManager:h,parentNode:d}),[d,h]);return m.createElement(Ns.Provider,{value:f},m.createElement("span",{"data-focus-scope-start":!0,hidden:!0,ref:a}),t,m.createElement("span",{"data-focus-scope-end":!0,hidden:!0,ref:i}))}function pi(e){return{focusNext(t={}){let n=e.current,{from:s,tabbable:r,wrap:a,accept:i}=t,c=s||pe(ee(n[0]??void 0)),u=n[0].previousElementSibling,d=Be(n),h=Ae(d,{tabbable:r,accept:i},n);h.currentNode=fe(c,n)?c:u;let f=h.nextNode();return!f&&a&&(h.currentNode=u,f=h.nextNode()),f&&Se(f,!0),f},focusPrevious(t={}){let n=e.current,{from:s,tabbable:r,wrap:a,accept:i}=t,c=s||pe(ee(n[0]??void 0)),u=n[n.length-1].nextElementSibling,d=Be(n),h=Ae(d,{tabbable:r,accept:i},n);h.currentNode=fe(c,n)?c:u;let f=h.previousNode();return!f&&a&&(h.currentNode=u,f=h.previousNode()),f&&Se(f,!0),f},focusFirst(t={}){let n=e.current,{tabbable:s,accept:r}=t,a=Be(n),i=Ae(a,{tabbable:s,accept:r},n);i.currentNode=n[0].previousElementSibling;let c=i.nextNode();return c&&Se(c,!0),c},focusLast(t={}){let n=e.current,{tabbable:s,accept:r}=t,a=Be(n),i=Ae(a,{tabbable:s,accept:r},n);i.currentNode=n[n.length-1].nextElementSibling;let c=i.previousNode();return c&&Se(c,!0),c}}}function Be(e){return e[0].parentElement}function rt(e){let t=J.getTreeNode(q);for(;t&&t.scopeRef!==e;){if(t.contain)return!1;t=t.parent}return!0}function gi(e){if(!e.form)return Array.from(ee(e).querySelectorAll(`input[type="radio"][name="${CSS.escape(e.name)}"]`)).filter(s=>!s.form);const t=e.form.elements.namedItem(e.name);let n=Je(e);return t instanceof n.RadioNodeList?Array.from(t).filter(s=>s instanceof n.HTMLInputElement):t instanceof n.HTMLInputElement?[t]:[]}function xi(e){if(e.checked)return!0;const t=gi(e);return t.length>0&&!t.some(n=>n.checked)}function bi(e,t){let n=m.useRef(void 0),s=m.useRef(void 0);ve(()=>{let r=e.current;if(!t){s.current&&(cancelAnimationFrame(s.current),s.current=void 0);return}const a=ee(r?r[0]:void 0);let i=d=>{if(d.key!=="Tab"||d.altKey||d.ctrlKey||d.metaKey||!rt(e)||d.isComposing)return;let h=pe(a),f=e.current;if(!f||!fe(h,f))return;let p=Be(f),l=Ae(p,{tabbable:!0},f);if(!h)return;l.currentNode=h;let g=d.shiftKey?l.previousNode():l.nextNode();g||(l.currentNode=d.shiftKey?f[f.length-1].nextElementSibling:f[0].previousElementSibling,g=d.shiftKey?l.previousNode():l.nextNode()),d.preventDefault(),g&&(Se(g,!0),g instanceof Je(g).HTMLInputElement&&g.select())},c=d=>{(!q||kt(q,e))&&fe(de(d),e.current)?(q=e,n.current=de(d)):rt(e)&&!Ve(de(d),e)?n.current?n.current.focus():q&&q.current&&mn(q.current):rt(e)&&(n.current=de(d))},u=d=>{s.current&&cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{var l;let h=Cr(),f=(h==="virtual"||h===null)&&vr()&&br(),p=pe(a);if(!f&&p&&rt(e)&&!Ve(p,e)){q=e;let g=de(d);g&&g.isConnected?(n.current=g,(l=n.current)==null||l.focus()):q.current&&mn(q.current)}})};return a.addEventListener("keydown",i,!1),a.addEventListener("focusin",c,!1),r==null||r.forEach(d=>d.addEventListener("focusin",c,!1)),r==null||r.forEach(d=>d.addEventListener("focusout",u,!1)),()=>{a.removeEventListener("keydown",i,!1),a.removeEventListener("focusin",c,!1),r==null||r.forEach(d=>d.removeEventListener("focusin",c,!1)),r==null||r.forEach(d=>d.removeEventListener("focusout",u,!1))}},[e,t]),ve(()=>()=>{s.current&&cancelAnimationFrame(s.current)},[s])}function Nr(e){return Ve(e)}function fe(e,t){return!e||!t?!1:t.some(n=>St(n,e))}function Ve(e,t=null){if(e instanceof Element&&e.closest("[data-react-aria-top-layer]"))return!0;for(let{scopeRef:n}of J.traverse(J.getTreeNode(t)))if(n&&fe(e,n.current))return!0;return!1}function kt(e,t){var s;let n=(s=J.getTreeNode(t))==null?void 0:s.parent;for(;n;){if(n.scopeRef===e)return!0;n=n.parent}return!1}function Se(e,t=!1){if(e!=null&&!t)try{mi(e)}catch{}else if(e!=null)try{e.focus()}catch{}}function Sr(e,t=!0){let n=e[0].previousElementSibling,s=Be(e),r=Ae(s,{tabbable:t},e);r.currentNode=n;let a=r.nextNode();return t&&!a&&(s=Be(e),r=Ae(s,{tabbable:!1},e),r.currentNode=n,a=r.nextNode()),a}function mn(e,t=!0){Se(Sr(e,t))}function vi(e,t){const n=m.useRef(t);m.useEffect(()=>{if(n.current){q=e;const s=ee(e.current?e.current[0]:void 0);!fe(pe(s),q.current)&&e.current&&mn(e.current)}n.current=!1},[e])}function wi(e,t,n){ve(()=>{if(t||n)return;let s=e.current;const r=ee(s?s[0]:void 0);let a=i=>{let c=de(i);fe(c,e.current)?q=e:Nr(c)||(q=null)};return r.addEventListener("focusin",a,!1),s==null||s.forEach(i=>i.addEventListener("focusin",a,!1)),()=>{r.removeEventListener("focusin",a,!1),s==null||s.forEach(i=>i.removeEventListener("focusin",a,!1))}},[e,t,n])}function Ss(e){let t=J.getTreeNode(q);for(;t&&t.scopeRef!==e;){if(t.nodeToRestore)return!1;t=t.parent}return(t==null?void 0:t.scopeRef)===e}function yi(e,t,n){const s=m.useRef(typeof document<"u"?pe(ee(e.current?e.current[0]:void 0)):null);ve(()=>{let r=e.current;const a=ee(r?r[0]:void 0);if(!t||n)return;let i=()=>{(!q||kt(q,e))&&fe(pe(a),e.current)&&(q=e)};return a.addEventListener("focusin",i,!1),r==null||r.forEach(c=>c.addEventListener("focusin",i,!1)),()=>{a.removeEventListener("focusin",i,!1),r==null||r.forEach(c=>c.removeEventListener("focusin",i,!1))}},[e,n]),ve(()=>{const r=ee(e.current?e.current[0]:void 0);if(!t)return;let a=i=>{if(i.key!=="Tab"||i.altKey||i.ctrlKey||i.metaKey||!rt(e)||i.isComposing)return;let c=r.activeElement;if(!Ve(c,e)||!Ss(e))return;let u=J.getTreeNode(e);if(!u)return;let d=u.nodeToRestore,h=Ae(r.body,{tabbable:!0});h.currentNode=c;let f=i.shiftKey?h.previousNode():h.nextNode();if((!d||!d.isConnected||d===r.body)&&(d=void 0,u.nodeToRestore=void 0),(!f||!Ve(f,e))&&d){h.currentNode=d;do f=i.shiftKey?h.previousNode():h.nextNode();while(Ve(f,e));i.preventDefault(),i.stopPropagation(),f?Se(f,!0):Nr(d)?Se(d,!0):c.blur()}};return n||r.addEventListener("keydown",a,!0),()=>{n||r.removeEventListener("keydown",a,!0)}},[e,t,n]),ve(()=>{const r=ee(e.current?e.current[0]:void 0);if(!t)return;let a=J.getTreeNode(e);if(a)return a.nodeToRestore=s.current??void 0,()=>{let i=J.getTreeNode(e);if(!i)return;let c=i.nodeToRestore,u=pe(r);if(t&&c&&(u&&Ve(u,e)||u===r.body&&Ss(e))){let d=J.clone();requestAnimationFrame(()=>{if(r.activeElement===r.body){let h=d.getTreeNode(e);for(;h;){if(h.nodeToRestore&&h.nodeToRestore.isConnected){js(h.nodeToRestore);return}h=h.parent}for(h=d.getTreeNode(e);h;){if(h.scopeRef&&h.scopeRef.current&&J.getTreeNode(h.scopeRef)){let f=Sr(h.scopeRef.current,!0);js(f);return}h=h.parent}}})}}},[e,t])}function js(e){e.dispatchEvent(new CustomEvent(fn,{bubbles:!0,cancelable:!0}))&&Se(e)}function Ae(e,t,n){let s=t!=null&&t.tabbable?ti:ei,r=(e==null?void 0:e.nodeType)===Node.ELEMENT_NODE?e:null,a=ee(r),i=Wa(a,e||a,NodeFilter.SHOW_ELEMENT,{acceptNode(c){return St(t==null?void 0:t.from,c)||t!=null&&t.tabbable&&c.tagName==="INPUT"&&c.getAttribute("type")==="radio"&&(!xi(c)||i.currentNode.tagName==="INPUT"&&i.currentNode.type==="radio"&&i.currentNode.name===c.name)?NodeFilter.FILTER_REJECT:s(c)&&(!n||fe(c,n))&&(!(t!=null&&t.accept)||t.accept(c))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return t!=null&&t.from&&(i.currentNode=t.from),i}class An{constructor(){this.fastMap=new Map,this.root=new hn({scopeRef:null}),this.fastMap.set(null,this.root)}get size(){return this.fastMap.size}getTreeNode(t){return this.fastMap.get(t)}addTreeNode(t,n,s){let r=this.fastMap.get(n??null);if(!r)return;let a=new hn({scopeRef:t});r.addChild(a),a.parent=r,this.fastMap.set(t,a),s&&(a.nodeToRestore=s)}addNode(t){this.fastMap.set(t.scopeRef,t)}removeTreeNode(t){if(t===null)return;let n=this.fastMap.get(t);if(!n)return;let s=n.parent;for(let a of this.traverse())a!==n&&n.nodeToRestore&&a.nodeToRestore&&n.scopeRef&&n.scopeRef.current&&fe(a.nodeToRestore,n.scopeRef.current)&&(a.nodeToRestore=n.nodeToRestore);let r=n.children;s&&(s.removeChild(n),r.size>0&&r.forEach(a=>s&&s.addChild(a))),this.fastMap.delete(n.scopeRef)}*traverse(t=this.root){if(t.scopeRef!=null&&(yield t),t.children.size>0)for(let n of t.children)yield*this.traverse(n)}clone(){var n;let t=new An;for(let s of this.traverse())t.addTreeNode(s.scopeRef,((n=s.parent)==null?void 0:n.scopeRef)??null,s.nodeToRestore);return t}}class hn{constructor(t){this.children=new Set,this.contain=!1,this.scopeRef=t.scopeRef}addChild(t){this.children.add(t),t.parent=this}removeChild(t){this.children.delete(t),t.parent=void 0}}let J=new An;function Vt(){return typeof window<"u"}function Qe(e){return jr(e)?(e.nodeName||"").toLowerCase():"#document"}function ce(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ee(e){var t;return(t=(jr(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function jr(e){return Vt()?e instanceof Node||e instanceof ce(e).Node:!1}function ne(e){return Vt()?e instanceof Element||e instanceof ce(e).Element:!1}function Ie(e){return Vt()?e instanceof HTMLElement||e instanceof ce(e).HTMLElement:!1}function ks(e){return!Vt()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ce(e).ShadowRoot}function ut(e){const{overflow:t,overflowX:n,overflowY:s,display:r}=ge(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&r!=="inline"&&r!=="contents"}function _i(e){return/^(table|td|th)$/.test(Qe(e))}function Ut(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Ei=/transform|translate|scale|rotate|perspective|filter/,Ci=/paint|layout|strict|content/,ze=e=>!!e&&e!=="none";let Jt;function On(e){const t=ne(e)?ge(e):e;return ze(t.transform)||ze(t.translate)||ze(t.scale)||ze(t.rotate)||ze(t.perspective)||!Fn()&&(ze(t.backdropFilter)||ze(t.filter))||Ei.test(t.willChange||"")||Ci.test(t.contain||"")}function Ni(e){let t=Oe(e);for(;Ie(t)&&!Xe(t);){if(On(t))return t;if(Ut(t))return null;t=Oe(t)}return null}function Fn(){return Jt==null&&(Jt=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Jt}function Xe(e){return/^(html|body|#document)$/.test(Qe(e))}function ge(e){return ce(e).getComputedStyle(e)}function Ht(e){return ne(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Oe(e){if(Qe(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ks(e)&&e.host||Ee(e);return ks(t)?t.host:t}function kr(e){const t=Oe(e);return Xe(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ie(t)&&ut(t)?t:kr(t)}function ct(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=kr(e),a=r===((s=e.ownerDocument)==null?void 0:s.body),i=ce(r);if(a){const c=pn(i);return t.concat(i,i.visualViewport||[],ut(r)?r:[],c&&n?ct(c):[])}else return t.concat(r,ct(r,[],n))}function pn(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const Si=["top","right","bottom","left"],$s=["start","end"],Ms=Si.reduce((e,t)=>e.concat(t,t+"-"+$s[0],t+"-"+$s[1]),[]),Ze=Math.min,ie=Math.max,$t=Math.round,bt=Math.floor,we=e=>({x:e,y:e}),ji={left:"right",right:"left",bottom:"top",top:"bottom"};function Rs(e,t,n){return ie(e,Ze(t,n))}function et(e,t){return typeof e=="function"?e(t):e}function _e(e){return e.split("-")[0]}function ye(e){return e.split("-")[1]}function $r(e){return e==="x"?"y":"x"}function Mr(e){return e==="y"?"height":"width"}function je(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Rr(e){return $r(je(e))}function Tr(e,t,n){n===void 0&&(n=!1);const s=ye(e),r=Rr(e),a=Mr(r);let i=r==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=Rt(i)),[i,Rt(i)]}function ki(e){const t=Rt(e);return[Mt(e),t,Mt(t)]}function Mt(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Ts=["left","right"],Is=["right","left"],$i=["top","bottom"],Mi=["bottom","top"];function Ri(e,t,n){switch(e){case"top":case"bottom":return n?t?Is:Ts:t?Ts:Is;case"left":case"right":return t?$i:Mi;default:return[]}}function Ti(e,t,n,s){const r=ye(e);let a=Ri(_e(e),n==="start",s);return r&&(a=a.map(i=>i+"-"+r),t&&(a=a.concat(a.map(Mt)))),a}function Rt(e){const t=_e(e);return ji[t]+e.slice(t.length)}function Ii(e){return{top:0,right:0,bottom:0,left:0,...e}}function Li(e){return typeof e!="number"?Ii(e):{top:e,right:e,bottom:e,left:e}}function Tt(e){const{x:t,y:n,width:s,height:r}=e;return{width:s,height:r,top:n,left:t,right:t+s,bottom:n+r,x:t,y:n}}var Di=typeof document<"u",Ai=function(){},gn=Di?m.useLayoutEffect:Ai;const Oi={...Y},Fi=Oi.useInsertionEffect,Pi=Fi||(e=>e());function zi(e){const t=Y.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return Pi(()=>{t.current=e}),Y.useCallback(function(){for(var n=arguments.length,s=new Array(n),r=0;r<n;r++)s[r]=arguments[r];return t.current==null?void 0:t.current(...s)},[])}function Ls(e,t,n){let{reference:s,floating:r}=e;const a=je(t),i=Rr(t),c=Mr(i),u=_e(t),d=a==="y",h=s.x+s.width/2-r.width/2,f=s.y+s.height/2-r.height/2,p=s[c]/2-r[c]/2;let l;switch(u){case"top":l={x:h,y:s.y-r.height};break;case"bottom":l={x:h,y:s.y+s.height};break;case"right":l={x:s.x+s.width,y:f};break;case"left":l={x:s.x-r.width,y:f};break;default:l={x:s.x,y:s.y}}switch(ye(t)){case"start":l[i]-=p*(n&&d?-1:1);break;case"end":l[i]+=p*(n&&d?-1:1);break}return l}async function Bi(e,t){var n;t===void 0&&(t={});const{x:s,y:r,platform:a,rects:i,elements:c,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:h="viewport",elementContext:f="floating",altBoundary:p=!1,padding:l=0}=et(t,e),g=Li(l),b=c[p?f==="floating"?"reference":"floating":f],v=Tt(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(b)))==null||n?b:b.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:d,rootBoundary:h,strategy:u})),w=f==="floating"?{x:s,y:r,width:i.floating.width,height:i.floating.height}:i.reference,E=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),j=await(a.isElement==null?void 0:a.isElement(E))?await(a.getScale==null?void 0:a.getScale(E))||{x:1,y:1}:{x:1,y:1},R=Tt(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:w,offsetParent:E,strategy:u}):w);return{top:(v.top-R.top+g.top)/j.y,bottom:(R.bottom-v.bottom+g.bottom)/j.y,left:(v.left-R.left+g.left)/j.x,right:(R.right-v.right+g.right)/j.x}}const Vi=50,Ui=async(e,t,n)=>{const{placement:s="bottom",strategy:r="absolute",middleware:a=[],platform:i}=n,c=i.detectOverflow?i:{...i,detectOverflow:Bi},u=await(i.isRTL==null?void 0:i.isRTL(t));let d=await i.getElementRects({reference:e,floating:t,strategy:r}),{x:h,y:f}=Ls(d,s,u),p=s,l=0;const g={};for(let x=0;x<a.length;x++){const b=a[x];if(!b)continue;const{name:v,fn:w}=b,{x:E,y:j,data:R,reset:D}=await w({x:h,y:f,initialPlacement:s,placement:p,strategy:r,middlewareData:g,rects:d,platform:c,elements:{reference:e,floating:t}});h=E??h,f=j??f,g[v]={...g[v],...R},D&&l<Vi&&(l++,typeof D=="object"&&(D.placement&&(p=D.placement),D.rects&&(d=D.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:r}):D.rects),{x:h,y:f}=Ls(d,p,u)),x=-1)}return{x:h,y:f,placement:p,strategy:r,middlewareData:g}};function Hi(e,t,n){return(e?[...n.filter(r=>ye(r)===e),...n.filter(r=>ye(r)!==e)]:n.filter(r=>_e(r)===r)).filter(r=>e?ye(r)===e||(t?Mt(r)!==r:!1):!0)}const Wi=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,async fn(t){var n,s,r;const{rects:a,middlewareData:i,placement:c,platform:u,elements:d}=t,{crossAxis:h=!1,alignment:f,allowedPlacements:p=Ms,autoAlignment:l=!0,...g}=et(e,t),x=f!==void 0||p===Ms?Hi(f||null,l,p):p,b=await u.detectOverflow(t,g),v=((n=i.autoPlacement)==null?void 0:n.index)||0,w=x[v];if(w==null)return{};const E=Tr(w,a,await(u.isRTL==null?void 0:u.isRTL(d.floating)));if(c!==w)return{reset:{placement:x[0]}};const j=[b[_e(w)],b[E[0]],b[E[1]]],R=[...((s=i.autoPlacement)==null?void 0:s.overflows)||[],{placement:w,overflows:j}],D=x[v+1];if(D)return{data:{index:v+1,overflows:R},reset:{placement:D}};const O=R.map(T=>{const M=ye(T.placement);return[T.placement,M&&h?T.overflows.slice(0,2).reduce((U,W)=>U+W,0):T.overflows[0],T.overflows]}).sort((T,M)=>T[1]-M[1]),B=((r=O.filter(T=>T[2].slice(0,ye(T[0])?2:3).every(M=>M<=0))[0])==null?void 0:r[0])||O[0][0];return B!==c?{data:{index:v+1,overflows:R},reset:{placement:B}}:{}}}},Yi=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:r,middlewareData:a,rects:i,initialPlacement:c,platform:u,elements:d}=t,{mainAxis:h=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:l="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:x=!0,...b}=et(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const v=_e(r),w=je(c),E=_e(c)===c,j=await(u.isRTL==null?void 0:u.isRTL(d.floating)),R=p||(E||!x?[Rt(c)]:ki(c)),D=g!=="none";!p&&D&&R.push(...Ti(c,x,g,j));const O=[c,...R],z=await u.detectOverflow(t,b),B=[];let T=((s=a.flip)==null?void 0:s.overflows)||[];if(h&&B.push(z[v]),f){const L=Tr(r,i,j);B.push(z[L[0]],z[L[1]])}if(T=[...T,{placement:r,overflows:B}],!B.every(L=>L<=0)){var M,U;const L=(((M=a.flip)==null?void 0:M.index)||0)+1,$=O[L];if($&&(!(f==="alignment"?w!==je($):!1)||T.every(y=>je(y.placement)===w?y.overflows[0]>0:!0)))return{data:{index:L,overflows:T},reset:{placement:$}};let C=(U=T.filter(S=>S.overflows[0]<=0).sort((S,y)=>S.overflows[1]-y.overflows[1])[0])==null?void 0:U.placement;if(!C)switch(l){case"bestFit":{var W;const S=(W=T.filter(y=>{if(D){const k=je(y.placement);return k===w||k==="y"}return!0}).map(y=>[y.placement,y.overflows.filter(k=>k>0).reduce((k,_)=>k+_,0)]).sort((y,k)=>y[1]-k[1])[0])==null?void 0:W[0];S&&(C=S);break}case"initialPlacement":C=c;break}if(r!==C)return{reset:{placement:C}}}return{}}}},Gi=new Set(["left","top"]);async function qi(e,t){const{placement:n,platform:s,elements:r}=e,a=await(s.isRTL==null?void 0:s.isRTL(r.floating)),i=_e(n),c=ye(n),u=je(n)==="y",d=Gi.has(i)?-1:1,h=a&&u?-1:1,f=et(t,e);let{mainAxis:p,crossAxis:l,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return c&&typeof g=="number"&&(l=c==="end"?g*-1:g),u?{x:l*h,y:p*d}:{x:p*d,y:l*h}}const Ki=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:r,y:a,placement:i,middlewareData:c}=t,u=await qi(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(s=c.arrow)!=null&&s.alignmentOffset?{}:{x:r+u.x,y:a+u.y,data:{...u,placement:i}}}}},Xi=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:r,platform:a}=t,{mainAxis:i=!0,crossAxis:c=!1,limiter:u={fn:v=>{let{x:w,y:E}=v;return{x:w,y:E}}},...d}=et(e,t),h={x:n,y:s},f=await a.detectOverflow(t,d),p=je(_e(r)),l=$r(p);let g=h[l],x=h[p];if(i){const v=l==="y"?"top":"left",w=l==="y"?"bottom":"right",E=g+f[v],j=g-f[w];g=Rs(E,g,j)}if(c){const v=p==="y"?"top":"left",w=p==="y"?"bottom":"right",E=x+f[v],j=x-f[w];x=Rs(E,x,j)}const b=u.fn({...t,[l]:g,[p]:x});return{...b,data:{x:b.x-n,y:b.y-s,enabled:{[l]:i,[p]:c}}}}}},Zi=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:r,rects:a,platform:i,elements:c}=t,{apply:u=()=>{},...d}=et(e,t),h=await i.detectOverflow(t,d),f=_e(r),p=ye(r),l=je(r)==="y",{width:g,height:x}=a.floating;let b,v;f==="top"||f==="bottom"?(b=f,v=p===(await(i.isRTL==null?void 0:i.isRTL(c.floating))?"start":"end")?"left":"right"):(v=f,b=p==="end"?"top":"bottom");const w=x-h.top-h.bottom,E=g-h.left-h.right,j=Ze(x-h[b],w),R=Ze(g-h[v],E),D=!t.middlewareData.shift;let O=j,z=R;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(z=E),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(O=w),D&&!p){const T=ie(h.left,0),M=ie(h.right,0),U=ie(h.top,0),W=ie(h.bottom,0);l?z=g-2*(T!==0||M!==0?T+M:ie(h.left,h.right)):O=x-2*(U!==0||W!==0?U+W:ie(h.top,h.bottom))}await u({...t,availableWidth:z,availableHeight:O});const B=await i.getDimensions(c.floating);return g!==B.width||x!==B.height?{reset:{rects:!0}}:{}}}};function Ir(e){const t=ge(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const r=Ie(e),a=r?e.offsetWidth:n,i=r?e.offsetHeight:s,c=$t(n)!==a||$t(s)!==i;return c&&(n=a,s=i),{width:n,height:s,$:c}}function Pn(e){return ne(e)?e:e.contextElement}function qe(e){const t=Pn(e);if(!Ie(t))return we(1);const n=t.getBoundingClientRect(),{width:s,height:r,$:a}=Ir(t);let i=(a?$t(n.width):n.width)/s,c=(a?$t(n.height):n.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const Ji=we(0);function Lr(e){const t=ce(e);return!Fn()||!t.visualViewport?Ji:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Qi(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ce(e)?!1:t}function Ye(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),a=Pn(e);let i=we(1);t&&(s?ne(s)&&(i=qe(s)):i=qe(e));const c=Qi(a,n,s)?Lr(a):we(0);let u=(r.left+c.x)/i.x,d=(r.top+c.y)/i.y,h=r.width/i.x,f=r.height/i.y;if(a){const p=ce(a),l=s&&ne(s)?ce(s):s;let g=p,x=pn(g);for(;x&&s&&l!==g;){const b=qe(x),v=x.getBoundingClientRect(),w=ge(x),E=v.left+(x.clientLeft+parseFloat(w.paddingLeft))*b.x,j=v.top+(x.clientTop+parseFloat(w.paddingTop))*b.y;u*=b.x,d*=b.y,h*=b.x,f*=b.y,u+=E,d+=j,g=ce(x),x=pn(g)}}return Tt({width:h,height:f,x:u,y:d})}function Wt(e,t){const n=Ht(e).scrollLeft;return t?t.left+n:Ye(Ee(e)).left+n}function Dr(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Wt(e,n),r=n.top+t.scrollTop;return{x:s,y:r}}function ec(e){let{elements:t,rect:n,offsetParent:s,strategy:r}=e;const a=r==="fixed",i=Ee(s),c=t?Ut(t.floating):!1;if(s===i||c&&a)return n;let u={scrollLeft:0,scrollTop:0},d=we(1);const h=we(0),f=Ie(s);if((f||!f&&!a)&&((Qe(s)!=="body"||ut(i))&&(u=Ht(s)),f)){const l=Ye(s);d=qe(s),h.x=l.x+s.clientLeft,h.y=l.y+s.clientTop}const p=i&&!f&&!a?Dr(i,u):we(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+h.x+p.x,y:n.y*d.y-u.scrollTop*d.y+h.y+p.y}}function tc(e){return Array.from(e.getClientRects())}function nc(e){const t=Ee(e),n=Ht(e),s=e.ownerDocument.body,r=ie(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),a=ie(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let i=-n.scrollLeft+Wt(e);const c=-n.scrollTop;return ge(s).direction==="rtl"&&(i+=ie(t.clientWidth,s.clientWidth)-r),{width:r,height:a,x:i,y:c}}const Ds=25;function sc(e,t){const n=ce(e),s=Ee(e),r=n.visualViewport;let a=s.clientWidth,i=s.clientHeight,c=0,u=0;if(r){a=r.width,i=r.height;const h=Fn();(!h||h&&t==="fixed")&&(c=r.offsetLeft,u=r.offsetTop)}const d=Wt(s);if(d<=0){const h=s.ownerDocument,f=h.body,p=getComputedStyle(f),l=h.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(s.clientWidth-f.clientWidth-l);g<=Ds&&(a-=g)}else d<=Ds&&(a+=d);return{width:a,height:i,x:c,y:u}}function rc(e,t){const n=Ye(e,!0,t==="fixed"),s=n.top+e.clientTop,r=n.left+e.clientLeft,a=Ie(e)?qe(e):we(1),i=e.clientWidth*a.x,c=e.clientHeight*a.y,u=r*a.x,d=s*a.y;return{width:i,height:c,x:u,y:d}}function As(e,t,n){let s;if(t==="viewport")s=sc(e,n);else if(t==="document")s=nc(Ee(e));else if(ne(t))s=rc(t,n);else{const r=Lr(e);s={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return Tt(s)}function Ar(e,t){const n=Oe(e);return n===t||!ne(n)||Xe(n)?!1:ge(n).position==="fixed"||Ar(n,t)}function oc(e,t){const n=t.get(e);if(n)return n;let s=ct(e,[],!1).filter(c=>ne(c)&&Qe(c)!=="body"),r=null;const a=ge(e).position==="fixed";let i=a?Oe(e):e;for(;ne(i)&&!Xe(i);){const c=ge(i),u=On(i);!u&&c.position==="fixed"&&(r=null),(a?!u&&!r:!u&&c.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||ut(i)&&!u&&Ar(e,i))?s=s.filter(h=>h!==i):r=c,i=Oe(i)}return t.set(e,s),s}function ac(e){let{element:t,boundary:n,rootBoundary:s,strategy:r}=e;const i=[...n==="clippingAncestors"?Ut(t)?[]:oc(t,this._c):[].concat(n),s],c=As(t,i[0],r);let u=c.top,d=c.right,h=c.bottom,f=c.left;for(let p=1;p<i.length;p++){const l=As(t,i[p],r);u=ie(l.top,u),d=Ze(l.right,d),h=Ze(l.bottom,h),f=ie(l.left,f)}return{width:d-f,height:h-u,x:f,y:u}}function ic(e){const{width:t,height:n}=Ir(e);return{width:t,height:n}}function cc(e,t,n){const s=Ie(t),r=Ee(t),a=n==="fixed",i=Ye(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const u=we(0);function d(){u.x=Wt(r)}if(s||!s&&!a)if((Qe(t)!=="body"||ut(r))&&(c=Ht(t)),s){const l=Ye(t,!0,a,t);u.x=l.x+t.clientLeft,u.y=l.y+t.clientTop}else r&&d();a&&!s&&r&&d();const h=r&&!s&&!a?Dr(r,c):we(0),f=i.left+c.scrollLeft-u.x-h.x,p=i.top+c.scrollTop-u.y-h.y;return{x:f,y:p,width:i.width,height:i.height}}function Qt(e){return ge(e).position==="static"}function Os(e,t){if(!Ie(e)||ge(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ee(e)===n&&(n=n.ownerDocument.body),n}function Or(e,t){const n=ce(e);if(Ut(e))return n;if(!Ie(e)){let r=Oe(e);for(;r&&!Xe(r);){if(ne(r)&&!Qt(r))return r;r=Oe(r)}return n}let s=Os(e,t);for(;s&&_i(s)&&Qt(s);)s=Os(s,t);return s&&Xe(s)&&Qt(s)&&!On(s)?n:s||Ni(e)||n}const lc=async function(e){const t=this.getOffsetParent||Or,n=this.getDimensions,s=await n(e.floating);return{reference:cc(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function uc(e){return ge(e).direction==="rtl"}const dc={convertOffsetParentRelativeRectToViewportRelativeRect:ec,getDocumentElement:Ee,getClippingRect:ac,getOffsetParent:Or,getElementRects:lc,getClientRects:tc,getDimensions:ic,getScale:qe,isElement:ne,isRTL:uc};function Fr(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function fc(e,t){let n=null,s;const r=Ee(e);function a(){var c;clearTimeout(s),(c=n)==null||c.disconnect(),n=null}function i(c,u){c===void 0&&(c=!1),u===void 0&&(u=1),a();const d=e.getBoundingClientRect(),{left:h,top:f,width:p,height:l}=d;if(c||t(),!p||!l)return;const g=bt(f),x=bt(r.clientWidth-(h+p)),b=bt(r.clientHeight-(f+l)),v=bt(h),E={rootMargin:-g+"px "+-x+"px "+-b+"px "+-v+"px",threshold:ie(0,Ze(1,u))||1};let j=!0;function R(D){const O=D[0].intersectionRatio;if(O!==u){if(!j)return i();O?i(!1,O):s=setTimeout(()=>{i(!1,1e-7)},1e3)}O===1&&!Fr(d,e.getBoundingClientRect())&&i(),j=!1}try{n=new IntersectionObserver(R,{...E,root:r.ownerDocument})}catch{n=new IntersectionObserver(R,E)}n.observe(e)}return i(!0),a}function mc(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:r=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=s,d=Pn(e),h=r||a?[...d?ct(d):[],...t?ct(t):[]]:[];h.forEach(v=>{r&&v.addEventListener("scroll",n,{passive:!0}),a&&v.addEventListener("resize",n)});const f=d&&c?fc(d,n):null;let p=-1,l=null;i&&(l=new ResizeObserver(v=>{let[w]=v;w&&w.target===d&&l&&t&&(l.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var E;(E=l)==null||E.observe(t)})),n()}),d&&!u&&l.observe(d),t&&l.observe(t));let g,x=u?Ye(e):null;u&&b();function b(){const v=Ye(e);x&&!Fr(x,v)&&n(),x=v,g=requestAnimationFrame(b)}return n(),()=>{var v;h.forEach(w=>{r&&w.removeEventListener("scroll",n),a&&w.removeEventListener("resize",n)}),f==null||f(),(v=l)==null||v.disconnect(),l=null,u&&cancelAnimationFrame(g)}}const hc=Ki,pc=Wi,gc=Xi,xc=Yi,bc=Zi,vc=(e,t,n)=>{const s=new Map,r={platform:dc,...n},a={...r.platform,_c:s};return Ui(e,t,{...r,platform:a})};var wc=typeof document<"u",yc=function(){},Et=wc?m.useLayoutEffect:yc;function It(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,s,r;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!It(e[s],t[s]))return!1;return!0}if(r=Object.keys(e),n=r.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,r[s]))return!1;for(s=n;s--!==0;){const a=r[s];if(!(a==="_owner"&&e.$$typeof)&&!It(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function Pr(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Fs(e,t){const n=Pr(e);return Math.round(t*n)/n}function en(e){const t=Y.useRef(e);return Et(()=>{t.current=e}),t}function _c(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:r,elements:{reference:a,floating:i}={},transform:c=!0,whileElementsMounted:u,open:d}=e,[h,f]=Y.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,l]=Y.useState(s);It(p,s)||l(s);const[g,x]=Y.useState(null),[b,v]=Y.useState(null),w=Y.useCallback(y=>{y!==D.current&&(D.current=y,x(y))},[]),E=Y.useCallback(y=>{y!==O.current&&(O.current=y,v(y))},[]),j=a||g,R=i||b,D=Y.useRef(null),O=Y.useRef(null),z=Y.useRef(h),B=u!=null,T=en(u),M=en(r),U=en(d),W=Y.useCallback(()=>{if(!D.current||!O.current)return;const y={placement:t,strategy:n,middleware:p};M.current&&(y.platform=M.current),vc(D.current,O.current,y).then(k=>{const _={...k,isPositioned:U.current!==!1};L.current&&!It(z.current,_)&&(z.current=_,lo.flushSync(()=>{f(_)}))})},[p,t,n,M,U]);Et(()=>{d===!1&&z.current.isPositioned&&(z.current.isPositioned=!1,f(y=>({...y,isPositioned:!1})))},[d]);const L=Y.useRef(!1);Et(()=>(L.current=!0,()=>{L.current=!1}),[]),Et(()=>{if(j&&(D.current=j),R&&(O.current=R),j&&R){if(T.current)return T.current(j,R,W);W()}},[j,R,W,T,B]);const $=Y.useMemo(()=>({reference:D,floating:O,setReference:w,setFloating:E}),[w,E]),C=Y.useMemo(()=>({reference:j,floating:R}),[j,R]),S=Y.useMemo(()=>{const y={position:n,left:0,top:0};if(!C.floating)return y;const k=Fs(C.floating,h.x),_=Fs(C.floating,h.y);return c?{...y,transform:"translate("+k+"px, "+_+"px)",...Pr(C.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:k,top:_}},[n,c,C.floating,h.x,h.y]);return Y.useMemo(()=>({...h,update:W,refs:$,elements:C,floatingStyles:S}),[h,W,$,C,S])}const tn=(e,t)=>{const n=hc(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ec=(e,t)=>{const n=gc(e);return{name:n.name,fn:n.fn,options:[e,t]}},Cc=(e,t)=>{const n=xc(e);return{name:n.name,fn:n.fn,options:[e,t]}},Nc=(e,t)=>{const n=bc(e);return{name:n.name,fn:n.fn,options:[e,t]}},Sc=(e,t)=>{const n=pc(e);return{name:n.name,fn:n.fn,options:[e,t]}},jc={...Y};let Ps=!1,kc=0;const zs=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+kc++;function $c(){const[e,t]=Y.useState(()=>Ps?zs():void 0);return gn(()=>{e==null&&t(zs())},[]),Y.useEffect(()=>{Ps=!0},[]),e}const Mc=jc.useId,Rc=Mc||$c;let xn;process.env.NODE_ENV!=="production"&&(xn=new Set);function Tc(){for(var e,t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];const r="Floating UI: "+n.join(" ");if(!((e=xn)!=null&&e.has(r))){var a;(a=xn)==null||a.add(r),console.error(r)}}function Ic(){const e=new Map;return{emit(t,n){var s;(s=e.get(t))==null||s.forEach(r=>r(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){var s;(s=e.get(t))==null||s.delete(n)}}}const Lc=Y.createContext(null),Dc=Y.createContext(null),Ac=()=>{var e;return((e=Y.useContext(Lc))==null?void 0:e.id)||null},Oc=()=>Y.useContext(Dc);function Fc(e){const{open:t=!1,onOpenChange:n,elements:s}=e,r=Rc(),a=Y.useRef({}),[i]=Y.useState(()=>Ic()),c=Ac()!=null;if(process.env.NODE_ENV!=="production"){const l=s.reference;l&&!ne(l)&&Tc("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[u,d]=Y.useState(s.reference),h=zi((l,g,x)=>{a.current.openEvent=l?g:void 0,i.emit("openchange",{open:l,event:g,reason:x,nested:c}),n==null||n(l,g,x)}),f=Y.useMemo(()=>({setPositionReference:d}),[]),p=Y.useMemo(()=>({reference:u||s.reference||null,floating:s.floating||null,domReference:s.reference}),[u,s.reference,s.floating]);return Y.useMemo(()=>({dataRef:a,open:t,onOpenChange:h,elements:p,events:i,floatingId:r,refs:f}),[t,h,p,i,r,f])}function Pc(e){e===void 0&&(e={});const{nodeId:t}=e,n=Fc({...e,elements:{reference:null,floating:null,...e.elements}}),s=e.rootContext||n,r=s.elements,[a,i]=Y.useState(null),[c,u]=Y.useState(null),h=(r==null?void 0:r.domReference)||a,f=Y.useRef(null),p=Oc();gn(()=>{h&&(f.current=h)},[h]);const l=_c({...e,elements:{...r,...c&&{reference:c}}}),g=Y.useCallback(E=>{const j=ne(E)?{getBoundingClientRect:()=>E.getBoundingClientRect(),getClientRects:()=>E.getClientRects(),contextElement:E}:E;u(j),l.refs.setReference(j)},[l.refs]),x=Y.useCallback(E=>{(ne(E)||E===null)&&(f.current=E,i(E)),(ne(l.refs.reference.current)||l.refs.reference.current===null||E!==null&&!ne(E))&&l.refs.setReference(E)},[l.refs]),b=Y.useMemo(()=>({...l.refs,setReference:x,setPositionReference:g,domReference:f}),[l.refs,x,g]),v=Y.useMemo(()=>({...l.elements,domReference:h}),[l.elements,h]),w=Y.useMemo(()=>({...l,...s,refs:b,elements:v,nodeId:t}),[l,b,v,t,s]);return gn(()=>{s.dataRef.current.floatingContext=w;const E=p==null?void 0:p.nodesRef.current.find(j=>j.id===t);E&&(E.context=w)}),Y.useMemo(()=>({...l,context:w,refs:b,elements:v}),[l,b,v,w])}const zc=typeof window<"u"&&"ResizeObserver"in window;function Bc(e){return String(e).startsWith("auto")?Sc({alignment:e==="auto-start"?"start":e==="auto-end"?"end":void 0}):null}function Vc(e){if(e==null)return null;if(Array.isArray(e)){const[t,n]=e;return tn({crossAxis:t,mainAxis:n})}return tn(e)}function Uc({allowFlip:e=!0,allowShift:t=!0,autoUpdateOptions:n,fitAvailableSpace:s=!1,freeze:r=!1,offset:a,placement:i="bottom-start"}){const c=Bc(i),u=Vc(a),d=i.startsWith("left")||i.startsWith("right"),h=[...u?[u]:[],...c?[c]:e&&!d?[Cc()]:[],...t?[Ec({padding:8})]:[],...s?[Nc({apply:()=>{}})]:[]],f=String(i).startsWith("auto")?"bottom":i;return Pc({middleware:h,placement:f,strategy:"fixed",whileElementsMounted:r?void 0:(p,l,g)=>mc(p,l,g,{ancestorResize:!0,ancestorScroll:!0,animationFrame:!1,elementResize:zc,...n})})}function zr({allowFlip:e,open:t,placement:n,referenceElement:s}){const[r,a]=m.useState(null),{refs:i,strategy:c,update:u,x:d,y:h}=Uc({allowFlip:e,freeze:!0,placement:n});return m.useEffect(()=>{i.setReference(s)},[s,i]),m.useEffect(()=>{i.setFloating(r)},[r,i]),m.useEffect(()=>{t&&r&&(u==null||u())},[t,n,r,u]),r&&!t&&a(null),{setPopperElement:a,styles:{left:d??0,position:c,top:h??0}}}const Br=({allowFlip:e=!0,children:t,className:n,dialogManagerId:s,focus:r=!0,id:a,placement:i="auto",referenceElement:c=null,tabIndex:u,trapFocus:d,...h})=>{const f=kn({dialogManagerId:s,id:a}),p=Ke(a,s),{setPopperElement:l,styles:g}=zr({allowFlip:e,open:p,placement:i,referenceElement:c});return m.useEffect(()=>{if(!p)return;const x=b=>{b.key==="Escape"&&(f==null||f.close())};return document.addEventListener("keyup",x),()=>{document.removeEventListener("keyup",x)}},[f,p]),p?m.createElement(pa,{dialogId:a,dialogManagerId:s},m.createElement(hi,{autoFocus:r,contain:d,restoreFocus:!0},m.createElement("div",{...h,className:$e("str-chat__dialog-contents",n),"data-testid":"str-chat__dialog-contents",ref:l,style:g,tabIndex:typeof u<"u"?u:0},t))):null},Hc=({children:e,className:t,placement:n,Submenu:s,submenuContainerProps:r,...a})=>{const i=m.useRef(null),[c,u]=m.useState(null),d=m.useRef(!1),h=m.useRef(null),f=m.useMemo(()=>`submenu-${Math.random().toString(36).slice(2)}`,[]),{dialog:p,dialogManager:l}=$n({id:f}),g=Ke(f,l==null?void 0:l.id),{setPopperElement:x,styles:b}=zr({open:g,placement:n,referenceElement:i.current}),v=m.useCallback(()=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{d.current||p.close()},100)},[p]),w=m.useCallback(j=>{const R=i.current;!g||!R||(j.stopPropagation(),v(),R.focus())},[v,g,i]),E=()=>{g||(p.open(),d.current=!0)};return m.useEffect(()=>{const j=i.current;if(!g||!j)return;const R=D=>{D.key==="Escape"&&(w(D),d.current=!1)};return document.addEventListener("keyup",R,{capture:!0}),()=>{document.removeEventListener("keyup",R,{capture:!0})}},[g,w]),m.createElement(m.Fragment,null,m.createElement("button",{"aria-selected":"false",className:$e(t,"str_chat__button-with-submenu",{"str_chat__button-with-submenu--submenu-open":g}),onBlur:()=>{d.current=!1,v()},onClick:j=>{j.stopPropagation(),p.toggle()},onFocus:E,onMouseEnter:E,onMouseLeave:()=>{d.current=!1,v()},ref:i,role:"option",...a},e),g&&m.createElement("div",{onBlur:j=>{j.relatedTarget instanceof Node&&(c!=null&&c.contains(j.relatedTarget))||(d.current=!1,v())},onFocus:()=>{d.current=!0},onMouseEnter:()=>{d.current=!0},onMouseLeave:()=>{d.current=!1,v()},ref:j=>{x(j),u(j)},style:b,tabIndex:-1,...r},m.createElement(s,null)))},Wc=({className:e,isMine:t})=>{const{t:n}=oe();return m.createElement(Hc,{"aria-selected":"false",className:e,placement:t?"left-start":"right-start",Submenu:Yc},n("Remind Me"))},Yc=()=>{const{t:e}=oe(),{client:t}=He(),{message:n}=te();return m.createElement("div",{"aria-label":e("aria/Remind Me Options"),className:"str-chat__message-actions-box__submenu",role:"listbox"},t.reminders.scheduledOffsetsMs.map(s=>m.createElement("button",{className:"str-chat__message-actions-list-item-button",key:`reminder-offset-option--${s}`,onClick:()=>{t.reminders.upsertReminder({messageId:n.id,remind_at:new Date(new Date().getTime()+s).toISOString()})}},e("duration/Remind Me",{milliseconds:s}))))},Gc=({className:e=""})=>m.createElement("svg",{className:e,height:"4",viewBox:"0 0 11 4",width:"11",xmlns:"http://www.w3.org/2000/svg"},m.createElement("path",{d:"M1.5 3a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3zm4 0a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3zm4 0a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3z",fillRule:"nonzero"})),qc=({className:e=""})=>m.createElement("svg",{className:e,height:"12",viewBox:"0 0 12 12",width:"12",xmlns:"http://www.w3.org/2000/svg"},m.createElement("g",{clipRule:"evenodd",fillRule:"evenodd"},m.createElement("path",{d:"M6 1.2C3.3 1.2 1.2 3.3 1.2 6c0 2.7 2.1 4.8 4.8 4.8 2.7 0 4.8-2.1 4.8-4.8 0-2.7-2.1-4.8-4.8-4.8zM0 6c0-3.3 2.7-6 6-6s6 2.7 6 6-2.7 6-6 6-6-2.7-6-6z"}),m.createElement("path",{d:"M5.4 4.5c0 .5-.4.9-.9.9s-.9-.4-.9-.9.4-.9.9-.9.9.4.9.9zM8.4 4.5c0 .5-.4.9-.9.9s-.9-.4-.9-.9.4-.9.9-.9.9.4.9.9zM3.3 6.7c.3-.2.6-.1.8.1.3.4.8.9 1.5 1 .6.2 1.4.1 2.4-1 .2-.2.6-.3.8 0 .2.2.3.6 0 .8-1.1 1.3-2.4 1.7-3.5 1.5-1-.2-1.8-.9-2.2-1.5-.2-.3-.1-.7.2-.9z"}))),Kc=({className:e=""})=>m.createElement("svg",{className:e,height:"10",width:"14",xmlns:"http://www.w3.org/2000/svg"},m.createElement("path",{d:"M8.516 3c4.78 0 4.972 6.5 4.972 6.5-1.6-2.906-2.847-3.184-4.972-3.184v2.872L3.772 4.994 8.516.5V3zM.484 5l4.5-4.237v1.78L2.416 5l2.568 2.125v1.828L.484 5z",fillRule:"evenodd"})),Xc=e=>{const{children:t,customWrapperClass:n,inline:s,toggleOpen:r}=e,a=$e("str-chat__message-simple__actions__action","str-chat__message-simple__actions__action--options","str-chat__message-actions-container"),i={className:n||a,"data-testid":"message-actions",onClick:r};return s?m.createElement("span",{...i},t):m.createElement("div",{...i},t)},Zc=e=>e?e.current!==void 0:!1,Jc=e=>new Promise((t,n)=>{const s=new Image;s.addEventListener("load",()=>{t([s.width,s.height])},{once:!0}),s.addEventListener("error",()=>n(`Couldn't load image from ${e}`),{once:!0}),s.src=e}),Qc=({columns:e,fallback:t,height:n,position:s,rows:r,spriteUrl:a,style:i,width:c})=>{const[[u,d],h]=m.useState([0,0]);m.useEffect(()=>{Jc(a).then(h).catch(console.error)},[a]);const[f,p]=s;return!d||!u?m.createElement(m.Fragment,null,t):m.createElement("div",{"data-testid":"sprite-image",style:{...i,"--str-chat__sprite-image-resize-ratio":"var(--str-chat__sprite-image-resize-ratio-x, var(--str-chat__sprite-image-resize-ratio-y, 1))","--str-chat__sprite-image-resize-ratio-x":"calc(var(--str-chat__sprite-image-width) / var(--str-chat__sprite-item-width))","--str-chat__sprite-image-resize-ratio-y":"calc(var(--str-chat__sprite-image-height) / var(--str-chat__sprite-item-height))","--str-chat__sprite-item-height":`${d/r}`,"--str-chat__sprite-item-width":`${u/e}`,...Number.isFinite(n)?{"--str-chat__sprite-image-height":`${n}px`}:{},...Number.isFinite(c)?{"--str-chat__sprite-image-width":`${c}px`}:{},backgroundImage:`url('${a}')`,backgroundPosition:`${f*(100/(e-1))}% ${p*(100/(r-1))}%`,backgroundSize:`${e*100}% ${r*100}%`,height:"var(--str-chat__sprite-image-height, calc(var(--str-chat__sprite-item-height) * var(--str-chat__sprite-image-resize-ratio)))",width:"var(--str-chat__sprite-image-width, calc(var(--str-chat__sprite-item-width) * var(--str-chat__sprite-image-resize-ratio)))"}})},el={angry:[1,1],haha:[1,0],like:[0,0],love:[1,2],sad:[0,1],wow:[0,2]},tl="https://getstream.imgix.net/images/emoji-sprite.png",nt=({fallback:e,type:t})=>{const n=el[t];return m.createElement(Qc,{columns:2,fallback:e,position:n,rows:3,spriteUrl:tl,style:{"--str-chat__sprite-image-height":"var(--str-chat__stream-emoji-size, 18px)"}})},nl=[{type:"haha",Component:()=>m.createElement(nt,{fallback:"😂",type:"haha"}),name:"Joy"},{type:"like",Component:()=>m.createElement(nt,{fallback:"👍",type:"like"}),name:"Thumbs up"},{type:"love",Component:()=>m.createElement(nt,{fallback:"❤️",type:"love"}),name:"Heart"},{type:"sad",Component:()=>m.createElement(nt,{fallback:"😔",type:"sad"}),name:"Sad"},{type:"wow",Component:()=>m.createElement(nt,{fallback:"😲",type:"wow"}),name:"Astonished"}],sl=e=>{var y;const{Avatar:t,detailedView:n=!0,handleReaction:s,latest_reactions:r,own_reactions:a,reaction_groups:i,reactionOptions:c,reverse:u=!1}=e,{Avatar:d,reactionOptions:h=nl}=mr(),{closeReactionSelectorOnClick:f,handleReaction:p,message:l}=te(),g=`reaction-selector--${l.id}`,x=kn({id:g}),b=c??h,v=t||d||Aa,w=s||p,E=r||(l==null?void 0:l.latest_reactions)||[],j=a||(l==null?void 0:l.own_reactions)||[],R=i||(l==null?void 0:l.reaction_groups)||{},[D,O]=m.useState(null),[z,B]=m.useState(null),T=m.useRef(null),M=m.useRef(null),U=m.useRef(null),W=m.useCallback((k,_)=>{M.current=k.currentTarget,O(_)},[]),L=m.useCallback(()=>{O(null),B(null)},[]);m.useEffect(()=>{var H,G,re;if(!D||!T.current)return;const k=(H=U.current)==null?void 0:H.getBoundingClientRect(),_=(G=M.current)==null?void 0:G.getBoundingClientRect(),I=Zc(T)?(re=T.current)==null?void 0:re.getBoundingClientRect():null;if(!k||!_||!I)return;const N=k.width===I.width||k.x<I.x?0:_.left+_.width/2-I.left-k.width/2,A=_.x-k.x+_.width/2-N;B({arrow:A,tooltip:N})},[D,T]);const $=k=>E.map(_=>{var I,N;return _.type===k?((I=_.user)==null?void 0:I.name)||((N=_.user)==null?void 0:N.id):null}).filter(Boolean),C=k=>j.find(_=>_.type===k),S=k=>{var _;return((_=E.find(I=>I.type===k&&!!I.user))==null?void 0:_.user)||void 0};return m.createElement("div",{className:$e("str-chat__reaction-selector str-chat__message-reaction-selector str-chat-react__message-reaction-selector",{"str-chat__reaction-selector--reverse":u}),"data-testid":"reaction-selector",ref:T},!!D&&n&&m.createElement("div",{className:"str-chat__reaction-selector-tooltip",ref:U,style:{left:z==null?void 0:z.tooltip,visibility:z?"visible":"hidden"}},m.createElement("div",{className:"arrow",style:{left:z==null?void 0:z.arrow}}),(y=$(D))==null?void 0:y.map((k,_,I)=>m.createElement("span",{className:"latest-user-username",key:`key-${_}-${k}`},`${k}${_<I.length-1?", ":""}`))),m.createElement("ul",{className:"str-chat__message-reactions-list str-chat__message-reactions-options"},b.map(({Component:k,name:_,type:I})=>{var H;const N=S(I),A=((H=R[I])==null?void 0:H.count)??0;return m.createElement("li",{key:I},m.createElement("button",{"aria-label":`Select Reaction: ${_||I}`,className:$e("str-chat__message-reactions-list-item str-chat__message-reactions-option",{"str-chat__message-reactions-option-selected":C(I)}),"data-testid":"select-reaction-button","data-text":I,onClick:G=>{w(I,G),f&&x.close()}},!!A&&n&&m.createElement("div",{className:"latest-user str-chat__message-reactions-last-user",onClick:L,onMouseEnter:G=>W(G,I),onMouseLeave:L},N?m.createElement(v,{image:N.image,name:N.name,size:20,user:N}):m.createElement("div",{className:"latest-user-not-found"})),m.createElement("span",{className:"str-chat__message-reaction-emoji"},m.createElement(k,null)),!!A&&n&&m.createElement("span",{className:"str-chat__message-reactions-list-item__count"},A||"")))})))},rl=m.memo(sl),ol=({ReactionIcon:e})=>{const{t}=oe("ReactionSelectorWithButton"),{isMyMessage:n,message:s,threadList:r}=te(),{ReactionSelector:a=rl}=mr(),i=m.useRef(null),u=`reaction-selector${r?"-thread-":""}--${s.id}`,{dialog:d,dialogManager:h}=$n({id:u}),f=Ke(u,h==null?void 0:h.id);return m.createElement(m.Fragment,null,m.createElement(Br,{dialogManagerId:h==null?void 0:h.id,id:u,placement:n()?"top-end":"top-start",referenceElement:i.current,trapFocus:!0},m.createElement(a,null)),m.createElement("button",{"aria-expanded":f,"aria-label":t("aria/Open Reaction Selector"),className:"str-chat__message-reactions-button","data-testid":"message-reaction-action",onClick:()=>d==null?void 0:d.toggle(),ref:i},m.createElement(e,{className:"str-chat__message-action-icon"})))},al=m.createContext({legacyThread:void 0}),il=()=>m.useContext(al),vt=new De.FixedSizeQueueCache(64),cl=()=>{const{client:e}=He(),{channel:t}=Sn(),{editing:n,message:s}=te(),{legacyThread:r}=il(),a=Ia(),i=m.useMemo(()=>{if(s)return s},[s==null?void 0:s.id]),c=m.useMemo(()=>{if(r)return r},[r==null?void 0:r.id]),u=m.useMemo(()=>{if(n&&i){const d=De.MessageComposer.constructTag(i),h=vt.get(d);return h?(h.editedMessage=i,h):new De.MessageComposer({client:e,composition:i,compositionContext:i})}else{if(a)return a.messageComposer;if(c){const d={...c,legacyThreadId:c.id},h=De.MessageComposer.constructTag(d),f=vt.get(h);return f||new De.MessageComposer({client:e,compositionContext:d})}else return t.messageComposer}},[i,c,t,e,n,a]);return["legacy_thread","message"].includes(u.contextType)&&!vt.peek(u.tag)&&vt.add(u.tag,u),m.useEffect(()=>{const d=u.registerSubscriptions();return()=>{d()}},[u]),u},ll=(e,t=!1)=>{const{initialMessage:n,message:s}=te(),{channelConfig:r}=Sn(),{canDelete:a,canEdit:i,canFlag:c,canMarkUnread:u,canMute:d,canQuote:h,canReact:f,canReply:p}=Pa(s),l=typeof s.parent_id=="string";return m.useMemo(()=>t?e:n||!s.type||s.type==="error"||s.type==="system"||s.type==="ephemeral"||s.status==="failed"||s.status==="sending"?[]:e.filter(({type:g})=>!(Fa.includes(g)&&l||g==="delete"&&!a||g==="edit"&&!i||g==="flag"&&!c||g==="markUnread"&&!u||g==="mute"&&!d||g==="quote"&&!h||g==="react"&&!f||g==="reply"&&!p||g==="remindMe"&&!(r!=null&&r.user_message_reminders)||g==="saveForLater"&&!(r!=null&&r.user_message_reminders))),[a,i,c,u,d,h,f,p,r,n,l,s.status,s.type,t,e])},ul=e=>m.useMemo(()=>{const t=[],n=[];for(const s of e)s.placement==="quick"&&t.push(s),s.placement==="dropdown"&&n.push(s);return{dropdownActionSet:n,quickActionSet:t}},[e]),Vr="str-chat__message-actions-list-item-button",be=({"aria-selected":e="false",children:t,className:n=Vr,role:s="option",...r})=>m.createElement("button",{"aria-selected":e,className:n,role:s,...r},t),he={dropdown:{Quote(){const{message:e}=te(),{t}=oe(),n=cl(),s=()=>{n.setQuotedMessage(e);const a=(e.parent_id?document.querySelectorAll(".str-chat__thread .str-chat__textarea__textarea"):document.getElementsByClassName("str-chat__textarea__textarea")).item(0);a instanceof HTMLTextAreaElement&&a.focus()};return m.createElement(be,{onClick:s},t("Quote"))},Pin(){const{handlePin:e,message:t}=te(),{t:n}=oe();return m.createElement(be,{onClick:e},t.pinned?n("Unpin"):n("Pin"))},MarkUnread(){const{handleMarkUnread:e}=te(),{t}=oe();return m.createElement(be,{onClick:e},t("Mark as unread"))},Flag(){const{handleFlag:e}=te(),{t}=oe();return m.createElement(be,{onClick:e},t("Flag"))},Mute(){const{handleMute:e,message:t}=te(),{mutes:n}=He(),{t:s}=oe();return m.createElement(be,{onClick:e},Oa(t,n)?s("Unmute"):s("Mute"))},Edit(){const{handleEdit:e}=te(),{t}=oe();return m.createElement(be,{onClick:e},t("Edit Message"))},Delete(){const{handleDelete:e}=te(),{t}=oe();return m.createElement(be,{onClick:e},t("Delete"))},RemindMe(){const{isMyMessage:e}=te();return m.createElement(Wc,{className:Vr,isMine:e()})},SaveForLater(){const{client:e}=He(),{message:t}=te(),{t:n}=oe(),s=za(t.id);return m.createElement(be,{onClick:()=>s?e.reminders.deleteReminder(s.id):e.reminders.createReminder({messageId:t.id})},n(s?"Remove reminder":"Save for later"))}},quick:{React(){return m.createElement(ol,{ReactionIcon:qc})},Reply(){const{handleOpenThread:e}=te(),{t}=oe();return m.createElement("button",{"aria-label":t("aria/Open Thread"),className:"str-chat__message-reply-in-thread-button","data-testid":"thread-action",onClick:e},m.createElement(Kc,{className:"str-chat__message-action-icon"}))}}},dl=[{Component:he.quick.Reply,placement:"quick",type:"reply"},{Component:he.quick.React,placement:"quick",type:"react"},{Component:he.dropdown.Delete,placement:"dropdown",type:"delete"},{Component:he.dropdown.Edit,placement:"dropdown",type:"edit"},{Component:he.dropdown.Mute,placement:"dropdown",type:"mute"},{Component:he.dropdown.Flag,placement:"dropdown",type:"flag"},{Component:he.dropdown.Pin,placement:"dropdown",type:"pin"},{Component:he.dropdown.Quote,placement:"dropdown",type:"quote"},{Component:he.dropdown.MarkUnread,placement:"dropdown",type:"markUnread"},{Component:he.dropdown.RemindMe,placement:"dropdown",type:"remindMe"},{Component:he.dropdown.SaveForLater,placement:"dropdown",type:"saveForLater"}],fl=({disableBaseMessageActionSetFilter:e=!1,messageActionSet:t=dl})=>{const{theme:n}=He(),{isMyMessage:s,message:r}=te(),{t:a}=oe(),[i,c]=m.useState(null),u=ll(t,e),{dropdownActionSet:d,quickActionSet:h}=ul(u),f=`message-actions--${r.id}`,p=`reaction-selector--${r.id}`,{dialog:l,dialogManager:g}=$n({id:f}),x=Ke(f,g==null?void 0:g.id),b=Ke(p,g==null?void 0:g.id);return d.length+h.length===0?null:m.createElement("div",{className:$e(`str-chat__message-${n}__actions str-chat__message-options`,{"str-chat__message-options--active":x||b})},d.length>0&&m.createElement(Xc,{inline:!1,toggleOpen:l==null?void 0:l.toggle},m.createElement("button",{"aria-expanded":x,"aria-haspopup":"true","aria-label":a("aria/Open Message Actions Menu"),className:"str-chat__message-actions-box-button","data-testid":"message-actions-toggle-button",ref:c},m.createElement(Gc,{className:"str-chat__message-action-icon"})),m.createElement(Br,{dialogManagerId:g==null?void 0:g.id,id:f,placement:s()?"top-end":"top-start",referenceElement:i,tabIndex:-1,trapFocus:!0},m.createElement(ml,{open:x},d.map(({Component:v,type:w})=>m.createElement(v,{key:w}))))),h.map(({Component:v,type:w})=>m.createElement(v,{key:w})))},ml=({children:e,open:t})=>{const{t:n}=oe();return m.createElement("div",{className:$e("str-chat__message-actions-box",{"str-chat__message-actions-box--open":t})},m.createElement("div",{"aria-label":n("aria/Message Options"),className:"str-chat__message-actions-list",role:"listbox"},e))},hl=()=>{const{handleDelete:e}=F.useMessageContext("CustomMessageActions"),{t}=F.useTranslationContext("CustomMessageActions");return o.jsx(be,{onClick:e,children:t("Delete")})},pl=()=>{const{handleFlag:e}=F.useMessageContext("CustomMessageActions");return o.jsx(be,{onClick:e,children:"Report"})},gl=[{Component:hl,placement:"dropdown",type:"delete"},{Component:pl,placement:"dropdown",type:"flag"}],xl=()=>o.jsx(fl,{messageActionSet:gl}),bl=e=>({linkPreviews:Array.from(e.previews.values()).filter(t=>De.LinkPreviewsManager.previewIsLoaded(t)||De.LinkPreviewsManager.previewIsLoading(t))}),vl=({link:e,onDismiss:t})=>{const{og_scrape_url:n,title:s,image_url:r}=e,a=i=>{i.preventDefault(),t(n)};return o.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&&o.jsx("img",{src:r,alt:s||"",className:"h-[148px] w-full rounded-[20px] object-cover"}),o.jsx("button",{type:"button",onClick:a,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:o.jsx(P.XIcon,{className:"size-4 text-black/90"})}),o.jsxs("div",{className:"p-2",children:[s&&o.jsx("div",{className:"text-[14px] font-medium leading-5 text-white",children:s}),o.jsx("div",{className:"text-[12px] leading-4 text-white/55",children:n})]})]})},wl=()=>{const{linkPreviewsManager:e}=F.useMessageComposer(),{linkPreviews:t}=F.useStateStore(e.state,bl),n=r=>{e.dismissPreview(r)};return t.length>0?o.jsx("div",{className:"flex flex-col items-center w-full gap-2 mb-4",children:t.map(r=>o.jsx(vl,{link:r,onDismiss:n},r.og_scrape_url))}):null},yl=({sendMessage:e,disabled:t,...n})=>o.jsx("button",{...n,type:"button","aria-label":"Send",disabled:t,onClick:e,children:o.jsx(P.ArrowUpIcon,{weight:"bold",className:"size-4"})}),_l=()=>{var c;const{channel:e}=F.useChannelStateContext(),t=((c=e==null?void 0:e.data)==null?void 0:c.frozen)===!0,{handleSubmit:n}=F.useMessageInputContext(),{SendButton:s}=F.useComponentContext("CustomMessageInput"),r=s??yl,a=F.useMessageComposerHasSendableData(),i=t||!a;return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"left-container",children:o.jsx(F.SimpleAttachmentSelector,{})}),o.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:[o.jsx(F.QuotedMessagePreview,{}),o.jsx(wl,{}),o.jsx(F.AttachmentPreviewList,{}),o.jsxs("div",{className:"flex",children:[o.jsx("div",{className:"w-full ml-2 mr-4 self-center leading-[0]",children:o.jsx(F.TextareaComposer,{"aria-disabled":t||void 0,className:"w-full resize-none outline-none leading-6",autoFocus:!t,maxRows:4,readOnly:t,tabIndex:t?-1:void 0})}),o.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:i,type:"button"})]})]})]})},El=({renderActions:e})=>{var s;const{channel:t}=F.useChannelStateContext(),n=((s=t==null?void 0:t.data)==null?void 0:s.frozen)===!0;return o.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:[e==null?void 0:e(),o.jsx(F.MessageInput,{Input:_l})]})},Cl=["SYSTEM_DM_AGENT_PAUSED","SYSTEM_DM_AGENT_RESUMED"],Nl={SYSTEM_DM_AGENT_PAUSED:"DM Agent has left the conversation",SYSTEM_DM_AGENT_RESUMED:"DM Agent has rejoined the conversation"},Sl=["SYSTEM_AGE_SAFETY_BLOCKED"],jl={SYSTEM_AGE_SAFETY_BLOCKED:"This user isn’t able to reply because they don’t meet our age safety guidelines."},nn="age safety guidelines.",kl="https://linktr.ee/s/about/contact",Bs=e=>Cl.includes(e),$l=e=>Sl.includes(e),Ml=e=>{var s;const t=(s=e.metadata)==null?void 0:s.custom_type;if(Bs(t))return{kind:"dm-agent",type:t};if($l(t))return{kind:"age-safety",type:t};const n=e.dm_agent_system_type;if(Bs(n))return{kind:"dm-agent",type:n}},Rl=e=>{const t=e.indexOf(nn);if(t===-1)return e;const n=t+nn.length;return o.jsxs(o.Fragment,{children:[e.slice(0,t),o.jsx("a",{href:kl,target:"_blank",rel:"noopener noreferrer",className:"mes-age-safety-system-message__emphasis font-medium text-inherit underline",children:nn}),e.slice(n)]})},Tl=e=>{var s,r;const t=e.message.hide_date===!0,n=Ml(e.message);if((n==null?void 0:n.kind)==="dm-agent"){const a=((s=e.message.text)==null?void 0:s.trim())||Nl[n.type];return o.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[o.jsxs("div",{className:"mes-dm-agent-system-message mx-auto mb-2 inline-flex w-fit max-w-[min(100%,480px)] items-center justify-center gap-[10px] rounded-[12px] border border-[rgba(0,0,0,0.08)] p-3 text-[rgba(0,0,0,0.55)]","data-testid":"dm-agent-system-message","data-dm-agent-system-type":n.type,children:[o.jsx(P.SparkleIcon,{size:16,weight:"regular","aria-hidden":!0,className:"mes-dm-agent-system-message__sparkle shrink-0"}),o.jsx("p",{className:"mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]",children:a})]}),!t&&o.jsx(F.MessageTimestamp,{message:e.message})]})}if((n==null?void 0:n.kind)==="age-safety"){const a=((r=e.message.text)==null?void 0:r.trim())||jl[n.type];return o.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[o.jsxs("div",{className:"mes-age-safety-system-message box-border mx-auto mb-2 flex w-full max-w-[329px] items-start justify-center gap-3 rounded-[12px] border border-[var(--border-secondary,rgba(0,0,0,0.08))] bg-[var(--bg-warning-subtle,#fef3c6)] px-2 py-4 pl-5 text-[color:var(--text-warning-on-warning,#894b00)]","data-testid":"age-safety-system-message","data-age-safety-system-type":n.type,children:[o.jsx(P.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"}),o.jsx("div",{className:"mes-age-safety-system-message__content min-w-0 flex-[1_0_0]",children:o.jsx("p",{className:"m-0 text-balance text-left text-[12px] font-normal leading-4 tracking-[0.21px] text-[color:var(--text-warning-on-warning,#894b00)]",children:Rl(a)})})]}),!t&&o.jsx(F.MessageTimestamp,{message:e.message})]})}return o.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[o.jsxs("div",{className:"str-chat__message--system__text",children:[o.jsx("div",{className:"str-chat__message--system__line"}),o.jsx("p",{children:e.message.text}),o.jsx("div",{className:"str-chat__message--system__line"})]}),!t&&o.jsx(F.MessageTimestamp,{message:e.message})]})},Ur=m.createContext(!1),sn=({cx:e,index:t})=>o.jsx("circle",{cx:e,cy:"4",r:"3.9",fill:"#A0A0A0",children:o.jsx("animateTransform",{attributeName:"transform",type:"translate",values:"0 0; 0 -2.25; 0 0;",dur:"900ms",begin:`${120*t}ms`,repeatCount:"indefinite"})}),Il=new Set([F.AIStates.Thinking,F.AIStates.Generating,F.AIStates.ExternalSources]),Ll=({threadList:e})=>{var g,x;const{channel:t,channelConfig:n,thread:s}=F.useChannelStateContext(),{client:r}=F.useChatContext(),{typing:a={}}=F.useTypingContext(),{aiState:i}=F.useAIState(t),c=m.useContext(Ur);if(!e&&c&&Il.has(i)){const b=Dl(t,(g=r.user)==null?void 0:g.id);return o.jsx(Vs,{avatarId:(b==null?void 0:b.id)??"ai-agent",avatarName:(b==null?void 0:b.name)??(b==null?void 0:b.id)??"Agent",avatarImage:b==null?void 0:b.image,testId:"typing-indicator-ai"})}if((n==null?void 0:n.typing_events)===!1)return null;const d=e?[]:Object.values(a).filter(({parent_id:b,user:v})=>{var w;return(v==null?void 0:v.id)!==((w=r.user)==null?void 0:w.id)&&!b}),h=e?Object.values(a).filter(({parent_id:b,user:v})=>{var w;return(v==null?void 0:v.id)!==((w=r.user)==null?void 0:w.id)&&b===(s==null?void 0:s.id)}):[],f=e?h:d;if(!f.length)return null;const p=(x=f[0])==null?void 0:x.user,l=p!=null&&p.id&&t.state.members[p.id]?t.state.members[p.id].user:void 0;return o.jsx(Vs,{avatarId:(p==null?void 0:p.id)??(l==null?void 0:l.id)??"typing-user",avatarName:(p==null?void 0:p.name)??(l==null?void 0:l.name)??(p==null?void 0:p.id)??"Typing user",avatarImage:(p==null?void 0:p.image)??(l==null?void 0:l.image),testId:"typing-indicator"})},Vs=({avatarId:e,avatarName:t,avatarImage:n,testId:s})=>o.jsxs("div",{className:"str-chat__typing-indicator !items-end !bg-transparent","data-testid":s,style:{insetInlineStart:0,insetInlineEnd:"auto"},children:[o.jsx("div",{className:"shrink-0","aria-hidden":"true",children:o.jsx(ke,{id:e,name:t,image:n??void 0,size:24,shape:"circle"})}),o.jsx("div",{className:"px-4 py-3 rounded-lg bg-[#E9EAED] h-12 flex flex-col justify-end",children:o.jsxs("svg",{"aria-hidden":"true",className:"block overflow-visible mb-[0.2rem]",viewBox:"0 0 32 8",width:"32",height:"8",overflow:"visible",children:[o.jsx(sn,{cx:"4",index:0}),o.jsx(sn,{cx:"16",index:1}),o.jsx(sn,{cx:"28",index:2})]})})]});function Dl(e,t){var s;const n=((s=e==null?void 0:e.state)==null?void 0:s.members)??{};for(const r of Object.values(n)){const a=r==null?void 0:r.user;if(a&&a.id!==t)return a}}const Hr=()=>null,Al=({className:e,message:t})=>o.jsxs("div",{className:V("flex items-center justify-center h-full",e),children:[o.jsxs("svg",{viewBox:"0 0 100 100",className:"size-8 fill-pebble",stroke:"none",children:[o.jsx("circle",{cx:"6",cy:"50",r:"6",children:o.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 15 ; 0 -15; 0 15",repeatCount:"indefinite",begin:"0.1"})}),o.jsx("circle",{cx:"30",cy:"50",r:"6",children:o.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 10 ; 0 -10; 0 10",repeatCount:"indefinite",begin:"0.2"})}),o.jsx("circle",{cx:"54",cy:"50",r:"6",children:o.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 5 ; 0 -5; 0 5",repeatCount:"indefinite",begin:"0.3"})})]}),t&&o.jsx("span",{className:"text-stone",children:t})]}),Lt=m.memo(()=>o.jsx("div",{className:"messaging-loading-state flex items-center justify-center h-full",children:o.jsxs("div",{className:"flex items-center",children:[o.jsx(Al,{className:"w-6 h-6"}),o.jsx("span",{className:"text-sm text-stone",children:"Loading messages"})]})}));Lt.displayName="LoadingState";const Ge="size-10 rounded-full bg-[#F1F0EE] hover:bg-[#E5E4E1] flex items-center justify-center transition-colors duration-150 focus-ring",Us="Replies instantly with AI assistant",Ol=({onBack:e,showBackButton:t,onShowInfo:n,canShowInfo:s,showStarButton:r=!1,dmAgentEnabled:a=!1,getParticipantDisplayName:i})=>{var l,g,x,b,v;const{channel:c}=F.useChannelStateContext(),u=m.useMemo(()=>{var j,R;const w=(j=c._client)==null?void 0:j.userID;return w?Object.values(((R=c.state)==null?void 0:R.members)||{}).find(D=>{var O;return((O=D.user)==null?void 0:O.id)&&D.user.id!==w}):void 0},[(l=c._client)==null?void 0:l.userID,(g=c.state)==null?void 0:g.members]),d=i(u),h=(x=u==null?void 0:u.user)==null?void 0:x.image,f=Ks(c),p=async()=>{try{f?await c.unpin():await c.pin()}catch(w){console.error("[CustomChannelHeader] Failed to update pinned status:",w)}};return o.jsxs("div",{className:"@container",children:[o.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] w-full items-center @lg:hidden",children:[o.jsx("div",{className:"flex items-center gap-2",children:t&&o.jsx("button",{className:Ge,onClick:e||(()=>{}),type:"button","aria-label":"Back to conversations",children:o.jsx(P.ArrowLeftIcon,{className:"size-5 text-black/90"})})}),o.jsxs("div",{className:"flex flex-col gap-1 items-center",children:[o.jsx(ke,{id:((b=u==null?void 0:u.user)==null?void 0:b.id)||c.id||"unknown",name:d,image:h,starred:r&&f,dmAgentEnabled:a,size:40}),o.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 ${d}`,children:[d,o.jsx(P.CaretRightIcon,{className:"size-3 shrink-0"})]}),a&&o.jsxs("div",{className:"flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[o.jsx(P.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),o.jsx("span",{children:Us})]})]}),o.jsxs("div",{className:"flex justify-end items-center gap-2",children:[r&&o.jsx("button",{className:Ge,onClick:p,type:"button","aria-label":f?"Unstar conversation":"Star conversation",children:o.jsx(P.StarIcon,{className:V("size-5",{"text-yellow-600":f,"text-black/90":!f}),weight:f?"duotone":"regular"})}),o.jsx("button",{className:Ge,onClick:n,type:"button","aria-label":"Show info",children:o.jsx(P.DotsThreeIcon,{className:"size-5 text-black/90"})})]})]}),o.jsxs("div",{className:"hidden @lg:flex items-center justify-between gap-3 min-h-12",children:[o.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[t&&e&&o.jsx("button",{type:"button",onClick:e,className:Ge,"aria-label":"Back to conversations",children:o.jsx(P.ArrowLeftIcon,{className:"size-5 text-black/90"})}),o.jsx(ke,{id:((v=u==null?void 0:u.user)==null?void 0:v.id)||c.id||"unknown",name:d,image:h,starred:r&&f,dmAgentEnabled:a,size:40}),o.jsxs("div",{className:"min-w-0",children:[s?o.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 ${d}`,children:[o.jsx("span",{className:"truncate",children:d}),o.jsx(P.CaretRightIcon,{className:"size-4 shrink-0"})]}):o.jsx("h1",{className:"font-medium text-black/90 truncate",children:d}),a&&o.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-[10px] leading-3 text-black/55",children:[o.jsx(P.SparkleIcon,{className:"size-3 shrink-0 text-black/55"}),o.jsx("span",{className:"truncate",children:Us})]})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[r&&o.jsx("button",{className:Ge,onClick:p,type:"button","aria-label":f?"Unstar conversation":"Star conversation",children:o.jsx(P.StarIcon,{className:V("size-5",{"text-yellow-600":f,"text-black/90":!f}),weight:f?"duotone":"regular"})}),s&&n&&o.jsx("button",{className:Ge,onClick:n,type:"button","aria-label":"Show info",children:o.jsx(P.DotsThreeIcon,{className:"size-5 text-black/90"})})]})]})]})},Fl=({onBack:e,showBackButton:t,renderMessageInputActions:n,renderConversationFooter:s,onLeaveConversation:r,onBlockParticipant:a,showDeleteConversation:i=!0,onDeleteConversationClick:c,onBlockParticipantClick:u,onReportParticipantClick:d,showStarButton:h=!1,chatbotVotingEnabled:f=!1,renderChannelBanner:p,customProfileContent:l,customChannelActions:g,renderMessage:x,dmAgentEnabled:b=!1,viewerLanguage:v,getParticipantDisplayName:w})=>{var L,$,C,S,y,k;const{channel:E}=F.useChannelStateContext(),j=m.useRef(null),R=m.useMemo(()=>{var N,A;const _=(N=E._client)==null?void 0:N.userID;return _?Object.values(((A=E.state)==null?void 0:A.members)||{}).find(H=>{var G;return((G=H.user)==null?void 0:G.id)&&H.user.id!==_}):void 0},[(L=E._client)==null?void 0:L.userID,($=E.state)==null?void 0:$.members]),D=m.useMemo(()=>{var N,A;const _=(N=E._client)==null?void 0:N.userID;return _?Object.values(((A=E.state)==null?void 0:A.members)||{}).find(H=>{var G;return((G=H.user)==null?void 0:G.id)===_}):void 0},[(C=E._client)==null?void 0:C.userID,(S=E.state)==null?void 0:S.members]),O=((y=D==null?void 0:D.user)==null?void 0:y.is_account)??(D==null?void 0:D.is_account),z=((k=R==null?void 0:R.user)==null?void 0:k.is_account)??(R==null?void 0:R.is_account),B=b&&O===!1&&z===!0,T=m.useMemo(()=>{const _=E.data??{};if(_.followerStatus)return String(_.followerStatus);if(_.isFollower!==void 0)return _.isFollower?"Subscribed to you":"Not subscribed"},[E.data]),M=m.useCallback(()=>{var _;(_=j.current)==null||_.showModal()},[]),U=m.useCallback(()=>{var _;(_=j.current)==null||_.close()},[]),W=m.useCallback(_=>{const{message:I}=F.useMessageContext("ChannelView"),N=o.jsx(oa,{..._,chatbotVotingEnabled:f,viewerLanguage:v});return!x||!I?N:x(N,I)},[f,x,v]);return o.jsxs(o.Fragment,{children:[o.jsx(F.WithComponents,{overrides:{Message:W,MessageActions:xl},children:o.jsxs(F.Window,{children:[o.jsx("div",{className:"p-4",children:o.jsx(Ol,{onBack:e,showBackButton:t,onShowInfo:M,canShowInfo:!!R,showStarButton:h,dmAgentEnabled:B,getParticipantDisplayName:w})},"lt-channel-header"),p?o.jsx(m.Fragment,{children:p()},"lt-channel-banner"):null,o.jsx("div",{className:"flex-1 overflow-hidden relative",children:o.jsx(F.MessageList,{hideDeletedMessages:!0,hideNewMessageSeparator:!1})},"lt-channel-message-list"),s?o.jsx(m.Fragment,{children:s(E)},"lt-channel-conversation-footer"):null,o.jsx(El,{renderActions:()=>n==null?void 0:n(E)},"lt-channel-message-input")]})}),o.jsx(jo,{dialogRef:j,onClose:U,participant:R,participantDisplayName:w(R),channel:E,followerStatusLabel:T,onLeaveConversation:r,onBlockParticipant:a,showDeleteConversation:i,onDeleteConversationClick:c,onBlockParticipantClick:u,onReportParticipantClick:d,customProfileContent:l,customChannelActions:g})]})},zn=m.memo(({channel:e,onBack:t,showBackButton:n=!1,renderMessageInputActions:s,renderConversationFooter:r,onLeaveConversation:a,onBlockParticipant:i,className:c,CustomChannelEmptyState:u=Hr,showDeleteConversation:d=!0,onDeleteConversationClick:h,onBlockParticipantClick:f,onReportParticipantClick:p,dmAgentEnabled:l,messageMetadata:g,onMessageSent:x,showStarButton:b=!1,chatbotVotingEnabled:v=!1,renderChannelBanner:w,customProfileContent:E,customChannelActions:j,renderMessage:R,sendButton:D,viewerLanguage:O,getParticipantDisplayName:z})=>{const B=m.useCallback(M=>(z==null?void 0:z(M))??Ot(M==null?void 0:M.user),[z]),T=m.useCallback(async(M,U,W)=>{var k;const L=((k=e.data)==null?void 0:k.chatbot_paused)===!0,$=l&&!L,C={...U,...$&&{silent:!0},...g&&{metadata:{...U.metadata??{},...g}}},S={...W,...$&&{skip_push:!0}},y=await e.sendMessage(C,S);return x==null||x(y),y},[e,l,g,x]);return o.jsx("div",{className:V("messaging-channel-view h-full flex flex-col",c),children:o.jsx(Ur.Provider,{value:l??!1,children:o.jsx(F.Channel,{channel:e,MessageSystem:Tl,EmptyStateIndicator:u,LoadingIndicator:Lt,DateSeparator:ko,TypingIndicator:Ll,doSendMessageRequest:T,...D?{SendButton:D}:{},children:o.jsx(Fl,{onBack:t,showBackButton:n,renderMessageInputActions:s,renderConversationFooter:r,onLeaveConversation:a,onBlockParticipant:i,CustomChannelEmptyState:u,showDeleteConversation:d,onDeleteConversationClick:h,onBlockParticipantClick:f,onReportParticipantClick:p,showStarButton:b,dmAgentEnabled:l,chatbotVotingEnabled:v,renderChannelBanner:w,customProfileContent:E,customChannelActions:j,renderMessage:R,viewerLanguage:O,getParticipantDisplayName:B})})})})});zn.displayName="ChannelView";const Pl=({className:e})=>o.jsxs("svg",{width:"140",height:"120",viewBox:"44 -2 144 126",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:[o.jsxs("g",{clipPath:"url(#clip0_empty_state)",children:[o.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"}),o.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"}),o.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"}),o.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"}),o.jsxs("g",{filter:"url(#filter0_empty_state)",children:[o.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"}),o.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"})]}),o.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"}),o.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"}),o.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"})]}),o.jsxs("defs",{children:[o.jsxs("filter",{id:"filter0_empty_state",x:"97",y:"-1",width:"89",height:"90",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[o.jsx("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),o.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"}),o.jsx("feOffset",{dx:"4",dy:"4"}),o.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),o.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"}),o.jsx("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow"}),o.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect1_dropShadow",result:"shape"})]}),o.jsx("clipPath",{id:"clip0_empty_state",children:o.jsx("rect",{width:"233",height:"233",fill:"white"})})]})]}),Wr=m.memo(({hasChannels:e,channelsLoaded:t})=>o.jsx("div",{className:"messaging-empty-state flex items-center justify-center h-full p-8 text-balance",children:o.jsxs("div",{className:"flex flex-col items-center max-w-sm text-center",children:[o.jsx(Pl,{}),t&&!e&&o.jsxs("div",{className:"mt-8",children:[o.jsx("h2",{className:"font-medium text-black text-[18px] mb-2",children:"Your inbox is empty"}),o.jsx("p",{className:"text-[#676B5F] text-sm mb-6",children:"Share with your followers to start receiving messages"})]})]})}));Wr.displayName="EmptyState";const Ct=m.memo(({message:e,onBack:t})=>o.jsx("div",{className:"messaging-error-state flex items-center justify-center h-full p-8",children:o.jsxs("div",{className:"text-center max-w-sm",children:[o.jsx("div",{className:"w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6",children:o.jsx("span",{className:"text-4xl",children:"⚠️"})}),o.jsx("h2",{className:"font-semibold text-charcoal mb-2",children:"Oops!"}),o.jsx("p",{className:"text-stone text-sm mb-6",children:e}),t&&o.jsx("button",{type:"button",onClick:t,className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-[#7f22fe] hover:bg-primary-alt rounded-lg transition-colors focus-ring",children:"Go Back"})]})}));Ct.displayName="ErrorState";const zl=({capabilities:e={},className:t,renderMessageInputActions:n,renderConversationFooter:s,onChannelSelect:r,initialParticipantFilter:a,initialParticipantData:i,CustomChannelEmptyState:c,showChannelList:u=!0,filters:d,channelRenderFilterFn:h,channelListCustomEmptyStateIndicator:f,onDeleteConversationClick:p,onBlockParticipantClick:l,onReportParticipantClick:g,dmAgentEnabled:x,messageMetadata:b,onMessageSent:v,showStarButton:w=!1,chatbotVotingEnabled:E=!1,viewerLanguage:j,renderMessagePreview:R,renderChannelBanner:D,customProfileContent:O,customChannelActions:z,renderMessage:B,sendButton:T})=>{const{service:M,client:U,isConnected:W,isLoading:L,error:$,refreshConnection:C,debug:S}=Gs(),[y,k]=m.useState(null),[_,I]=m.useState(!1),[N,A]=m.useState(!1),[H,G]=m.useState(!1),[re,X]=m.useState(null),{showDeleteConversation:me=!0}=e,le=m.useMemo(()=>{const Z=U==null?void 0:U.userID;return{...{type:"messaging",last_message_at:{$exists:!0},...Z&&{members:{$in:[Z]},hidden:!1}},...d}},[d,U==null?void 0:U.userID]),K=m.useRef(null),Q=m.useCallback(async()=>{if(!U||!W)return;const Z=U.userID;if(Z)try{S&&console.log("[MessagingShell] Syncing channels for user:",Z);const se=await U.queryChannels({type:"messaging",members:{$in:[Z]}},{},{limit:100});I(se.length>0),A(!0),K.current=Z,S&&console.log("[MessagingShell] Channels synced successfully:",{channelCount:se.length})}catch(se){console.error("[MessagingShell] Failed to sync channels:",se)}},[U,W,S]);m.useEffect(()=>{if(!U||!W)return;const Z=U.userID;Z&&K.current!==Z&&Q()},[U,W,Q]),m.useEffect(()=>{if(!a||!U||!W)return;(async()=>{const se=U.userID;if(se)try{S&&console.log("[MessagingShell] Loading initial conversation with:",a);const Ce=await U.queryChannels({type:"messaging",members:{$eq:[se,a]}},{},{limit:1});if(Ce.length>0)k(Ce[0]),G(!0),X(null),r&&r(Ce[0]),S&&console.log("[MessagingShell] Initial conversation loaded:",Ce[0].id);else if(i&&M){S&&console.log("[MessagingShell] No conversation found, creating one for:",i);try{const Ne=await M.startChannelWithParticipant({id:i.id,name:i.name,phone:i.phone});k(Ne),G(!0),X(null),r&&r(Ne),S&&console.log("[MessagingShell] Channel created and loaded:",Ne.id)}catch(Ne){console.error("[MessagingShell] Failed to create conversation:",Ne),X("Failed to create conversation")}}else X("No conversation found with this account"),S&&console.log("[MessagingShell] No conversation found for:",a)}catch(Ce){console.error("[MessagingShell] Failed to load initial conversation:",Ce),X("Failed to load conversation")}})()},[a,i,U,W,M,S,r]);const xe=m.useCallback(Z=>{k(Z),r==null||r(Z)},[r]),ae=m.useCallback(()=>{H||k(null)},[H]),Fe=m.useCallback(async Z=>{S&&console.log("[MessagingShell] Leaving conversation:",Z.id),k(null),G(!1),K.current=null,await Q()},[Q,S]),Gt=m.useCallback(async Z=>{S&&console.log("[MessagingShell] Blocking participant:",Z),k(null),G(!1),K.current=null,await Q()},[Q,S]),Pe=!!y;return L?o.jsx("div",{className:V("h-full",t),children:o.jsx(Lt,{})}):$?o.jsx("div",{className:V("h-full",t),children:o.jsx(Ct,{message:$,onBack:C})}):!W||!U?o.jsx("div",{className:V("h-full",t),children:o.jsx(Ct,{message:"Not connected to messaging service",onBack:C})}):re?o.jsx("div",{className:V("h-full",t),children:o.jsx(Ct,{message:re})}):o.jsx("div",{className:V("messaging-shell h-full bg-background-primary overflow-hidden",t),children:o.jsxs("div",{className:"flex h-full min-h-0",children:[o.jsx("div",{className:V("messaging-channel-list-sidebar min-h-0 min-w-0 lg:flex lg:flex-col",{"!hidden":u===!1||H,"hidden lg:flex lg:flex-1 lg:max-w-2xl":u!==!1&&!H&&Pe,"flex flex-col w-full lg:flex-1 lg:max-w-2xl":u!==!1&&!H&&!Pe}),children:o.jsx(wn,{onChannelSelect:xe,selectedChannel:y||void 0,filters:le,channelRenderFilterFn:h,customEmptyStateIndicator:f,renderMessagePreview:R,viewerLanguage:j})}),o.jsx("div",{className:V("messaging-conversation-view flex-1 flex-col min-w-0 min-h-0",{flex:H||Pe||a,"hidden lg:flex":!H&&!Pe&&!a}),children:y?o.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:o.jsx(zn,{channel:y,onBack:ae,showBackButton:!H,renderMessageInputActions:n,renderConversationFooter:s,renderChannelBanner:D,onLeaveConversation:Fe,onBlockParticipant:Gt,CustomChannelEmptyState:c,showDeleteConversation:me,onDeleteConversationClick:p,onBlockParticipantClick:l,onReportParticipantClick:g,dmAgentEnabled:x,messageMetadata:b,onMessageSent:v,showStarButton:w,chatbotVotingEnabled:E,viewerLanguage:j,customProfileContent:O,customChannelActions:z,renderMessage:B,sendButton:T},y.id)}):a?o.jsx(Lt,{}):o.jsx(Wr,{hasChannels:_,channelsLoaded:N})})]})})},Bl=/^([a-z][a-z0-9+.-]*):/i,Vl=new Set(["http","https","mailto","tel","sms"]);function Yr(e){if(typeof e!="string")return;const t=e.trim();if(t==="")return;const n=Bl.exec(t);if(n){const s=n[1].toLowerCase();return Vl.has(s)?t:void 0}return t.startsWith("//")||t.startsWith("/")?t:`https://${t}`}const Ul={dark:"bg-white text-[#121110] hover:bg-white/90",light:"bg-[#121110] text-white hover:bg-[#2a2928]"},Hl=({variant:e,cta:t})=>{const n=V("mt-2 inline-flex h-10 w-full items-center justify-center rounded-full px-4 text-sm font-medium leading-none transition-colors",Ul[e]),s=Yr(t.href);return s?o.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",onClick:r=>{var a;r.stopPropagation(),(a=t.onClick)==null||a.call(t)},className:`${n} no-underline`,children:t.label}):o.jsx("button",{type:"button",onClick:r=>{var a;r.stopPropagation(),(a=t.onClick)==null||a.call(t)},className:n,children:t.label})},Wl={dark:"text-white",light:"text-black/90"},Yl="text-white/30",Gl={dark:"text-white/55",light:"text-black/55"},Bn=({variant:e,title:t,placeholderTitle:n,description:s,url:r,appIcon:a,cta:i,trailingAction:c})=>{const u=e==="dark",d=t??(u?n:void 0)??"",h=d.trim()!=="",f=s!=null&&s.trim()!=="",p=typeof r=="string"?r.trim():"",l=p!=="",g=i!=null;if(!h&&!f&&!l&&!g)return null;const b=V("truncate text-base font-medium leading-6",u&&!t?Yl:Wl[e]),v=V("truncate text-xs leading-4",Gl[e]);return o.jsxs("div",{className:"px-4 py-3",children:[o.jsxs("div",{className:"flex items-end gap-3",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[o.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[h&&o.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[a?o.jsx("span",{className:"shrink-0",children:a}):null,o.jsx("p",{className:V("min-w-0",b),children:d})]}),f&&o.jsx("p",{className:v,children:s})]}),!g&&l&&o.jsx("p",{className:v,children:p})]}),c&&o.jsx("div",{className:"shrink-0",children:c})]}),i&&o.jsx(Hl,{variant:e,cta:i})]})},ql=V("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)]"),Dt=({variant:e,children:t,href:n,onClick:s,ariaLabel:r,rootRef:a,topRight:i,bgClassName:c,"data-testid":u})=>{const d=n!=null||s!=null,h=V(ql,c??(e==="dark"?"bg-[#121110]":"bg-white"),d?"cursor-pointer no-underline focus-ring":null),f=i?o.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:i}):null;return n?o.jsxs("a",{ref:a,href:n,target:"_blank",rel:"noopener noreferrer",onClick:s,"data-testid":u,className:h,children:[t,f]}):s?o.jsxs("button",{ref:a,type:"button",onClick:s,"aria-label":r,"data-testid":u,className:V(h,"text-left"),children:[t,f]}):o.jsxs("div",{ref:a,"data-testid":u,className:h,children:[t,f]})},Kl={dark:"bg-white/10",light:"bg-black/5"},Xl={dark:"size-16 text-white/25",light:"size-16 text-black/25"},Yt=(e,t)=>!!t&&!!e&&Re(e)==="audio",Zl=(e,t)=>{if(!t||!e)return!1;const n=Re(e);return n==="video"||n==="audio"},Vn="bg-[#F2F3F4]",At=({variant:e,thumbnailUrl:t,sourceUrl:n,title:s,mimeType:r="image/*",topLeft:a,topRight:i})=>{const c=Re(r),u=!!n&&c==="video";return Yt(r,n)?o.jsx("div",{className:"p-3",children:o.jsx("audio",{src:n,controls:!0,preload:"metadata",className:"block w-full",children:o.jsx("track",{kind:"captions"})})}):o.jsxs("div",{className:V("relative h-[180px] w-full overflow-hidden",u&&"bg-black"),children:[u?o.jsx("video",{src:n,poster:t,controls:!0,playsInline:!0,preload:"metadata",className:"absolute inset-0 h-full w-full object-contain",children:o.jsx("track",{kind:"captions"})}):t?o.jsx("img",{src:t,alt:s??"",draggable:!1,className:"absolute inset-0 h-full w-full object-cover"}):o.jsx("div",{className:V("flex h-full w-full items-center justify-center",Kl[e]),children:Ue(r,{className:Xl[e],weight:"regular"})}),a?o.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-10",children:a}):null,i?o.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:i}):null]})},Jl=({title:e,placeholderTitle:t,description:n,url:s,mimeType:r,thumbnailUrl:a,sourceUrl:i,layout:c="featured",appIcon:u,cta:d,onDismiss:h,onEditClick:f})=>{const p=c==="classic",l=Yt(r,i),g=h?o.jsx("button",{type:"button",onClick:h,"aria-label":"Dismiss attachment",className:"flex size-6 items-center justify-center rounded-full bg-[#121110] text-white",children:o.jsx(P.XIcon,{className:"size-3",weight:"bold"})}):void 0,x=f?o.jsx("button",{type:"button",onClick:f,"aria-label":"Edit attachment",className:"flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",children:o.jsx(P.PencilSimpleIcon,{className:"size-5",weight:"regular"})}):void 0;return l?o.jsx(Dt,{variant:"dark",bgClassName:Vn,children:o.jsxs("div",{className:"flex items-center gap-2 pr-3",children:[o.jsx("div",{className:"min-w-0 flex-1",children:o.jsx(At,{variant:"dark",sourceUrl:i,title:e,mimeType:r})}),g&&o.jsx("div",{className:"shrink-0",children:g})]})}):o.jsxs(Dt,{variant:"dark",topRight:p?g:void 0,children:[!p&&o.jsx(At,{variant:"dark",thumbnailUrl:a,sourceUrl:i,title:e,mimeType:r,topRight:g}),o.jsx(Bn,{variant:"dark",title:e,placeholderTitle:t,description:n,url:s,appIcon:u,cta:d,trailingAction:x})]})},Ql=({title:e,description:t,url:n,mimeType:s,thumbnailUrl:r,sourceUrl:a,layout:i="featured",appIcon:c,cta:u,onClick:d})=>{const h=Zl(s,a),f=Yr(n),p=u==null&&f!=null&&!h?f:void 0,l=u==null&&!h?d:void 0,g=Yt(s,a)?Vn:void 0,x=u&&d?{...u,onClick:()=>{var b;d(),(b=u.onClick)==null||b.call(u)}}:u;return o.jsxs(Dt,{variant:"light",href:p,onClick:l,ariaLabel:e??"Open attachment preview",bgClassName:g,"data-testid":"link-attachment",children:[i==="featured"&&o.jsx(At,{variant:"light",thumbnailUrl:r,sourceUrl:a,title:e,mimeType:s}),o.jsx(Bn,{variant:"light",title:e,description:t,url:n,appIcon:c,cta:x})]})},eu=({title:e,placeholderTitle:t,description:n,url:s,mimeType:r,thumbnailUrl:a,sourceUrl:i,layout:c="featured",appIcon:u,cta:d})=>o.jsxs(Dt,{variant:"dark",bgClassName:Yt(r,i)?Vn:void 0,children:[c==="featured"&&o.jsx(At,{variant:"dark",thumbnailUrl:a,sourceUrl:i,title:e,mimeType:r}),o.jsx(Bn,{variant:"dark",title:e,placeholderTitle:t,description:n,url:s,appIcon:u,cta:d})]}),tu={Composer:Jl,Sent:eu,Received:Ql},nu={dark:"bg-[#121110]",light:"bg-[#e9eaed]"},su={dark:"text-white",light:"text-[#080707]"},ru={dark:"border-white/[0.08]",light:"border-black/[0.08]"},ou=e=>e==="dark"?"sender":"receiver",au={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]"}},dt=({variant:e,text:t,bordered:n=!0,groupPosition:s="single",className:r,children:a,"data-testid":i})=>{const c=t!=null&&t!=="",u=au[ou(e)][s];return o.jsxs("div",{"data-testid":i,"data-group-position":s,className:V("relative w-[280px] overflow-hidden px-2 py-2",u,nu[e],su[e],n&&"border",n&&ru[e],r),children:[a,c?o.jsx("p",{className:V("whitespace-pre-wrap break-words leading-snug","pt-2","px-2"),children:t}):null]})},ft=({onClick:e,variant:t="overlay",ariaLabel:n="Dismiss attachment"})=>o.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),e()},"aria-label":n,className:V("flex size-6 items-center justify-center rounded-full text-white",t==="overlay"?"bg-[#121110]/85 backdrop-blur":"bg-white/15 hover:bg-white/25"),children:o.jsx(P.XIcon,{className:"size-3",weight:"bold"})}),mt=e=>e==="received"?"light":"dark",iu=({firstOfGroup:e,endOfGroup:t,groupedByUser:n})=>!n||e&&t?"single":e?"first":t?"end":"middle",cu=({src:e,mimeType:t,filename:n,items:s})=>s&&s.length>0?s:e?[{src:e,mimeType:t,filename:n}]:[],lu=({item:e,preload:t,trailingAction:n})=>o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("audio",{src:e.src,controls:!0,preload:e.preload??t,className:"block min-w-0 flex-1",children:e.mimeType?o.jsx("source",{src:e.src,type:e.mimeType}):null}),n??null]}),Un=({state:e,src:t,mimeType:n,filename:s,items:r,text:a,groupPosition:i,preload:c,onDismiss:u})=>{const d=mt(e),h=e==="composer"&&!!u,f=cu({src:t,mimeType:n,filename:s,items:r});if(f.length===0)return null;const p=c??(f.length>1?"none":"metadata");return o.jsx(dt,{variant:d,text:a,groupPosition:i,"data-testid":"audio-attachment",children:o.jsx("div",{className:"flex flex-col gap-2",children:f.map((l,g)=>o.jsx(lu,{item:l,preload:p,trailingAction:h&&g===0?o.jsx(ft,{onClick:u,variant:"inline"}):void 0},`${l.src}-${g}`))})})},uu=e=>o.jsx(Un,{...e,state:"composer"}),du=e=>o.jsx(Un,{...e,state:"sent"}),fu=e=>o.jsx(Un,{...e,state:"received"}),mu={Composer:uu,Sent:du,Received:fu};function Gr(e){return!Number.isFinite(e)||e<0?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(2)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}const hu={pdf:"PDF",doc:"DOC",xls:"XLS",csv:"CSV",ppt:"PPT",zip:"ZIP",text:"TXT",markdown:"MD"};function qr(e,t){if(t){const r=t.lastIndexOf(".");if(r>0&&r<t.length-1){const a=t.slice(r+1);if(a&&a.length<=5)return a.toUpperCase()}}if(!e)return;if(Re(e)==="document"){const r=rr(e),a=hu[r];if(a)return a;if(e==="application/octet-stream")return}const s=e.split("/")[1];if(!(!s||s==="*"))return s.toUpperCase()}function Kr(e,t,n){const s=qr(e,t),r=typeof n=="number"&&n>0?Gr(n):void 0;return[s,r].filter(Boolean).join(" · ")||void 0}function Me(e){try{const n=new URL(e).pathname.split("/").pop();return n&&n.length>0?decodeURIComponent(n):"download"}catch{return"download"}}const pu={dark:"text-white/55",light:"text-black/65"},gu={dark:"bg-white/10",light:"bg-black/5"},xu={dark:"text-white/85",light:"text-black/85"},Xr=({variant:e,filename:t,title:n,mimeType:s="application/octet-stream",fileSize:r,onActivate:a,activateLabel:i,trailingAction:c})=>{const u=n??t??"File",d=Kr(s,t,r),h=o.jsx("div",{className:V("flex size-10 shrink-0 items-center justify-center rounded-sm",gu[e]),"aria-hidden":!0,children:Ue(s,{className:V("size-6",xu[e]),weight:"regular"})}),f=o.jsxs("div",{className:"flex min-w-0 flex-1 flex-col text-left",children:[o.jsx("p",{className:"truncate font-medium leading-snug",children:u}),d?o.jsx("p",{className:V("truncate text-xs leading-4",pu[e]),children:d}):null]}),p=a?o.jsxs("button",{type:"button",onClick:a,"aria-label":i,className:V("flex min-w-0 flex-1 items-center gap-3 rounded-sm text-left transition-colors",e==="dark"?"hover:bg-white/[0.04]":"hover:bg-black/[0.04]"),children:[h,f]}):o.jsxs(o.Fragment,{children:[h,f]});return o.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[p,c?o.jsx("div",{className:"shrink-0",children:c}):null]})};async function Zr(e,t){const n=t??Me(e);try{const s=await fetch(e,{mode:"cors"});if(!s.ok)throw new Error(`HTTP ${s.status}`);const r=await s.blob(),a=URL.createObjectURL(r),i=document.createElement("a");i.href=a,i.download=n,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(a)}catch{if(!window.open(e,"_blank","noopener,noreferrer")){const r=document.createElement("a");r.href=e,r.download=n,r.target="_blank",r.rel="noopener noreferrer",r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r)}}}const bu=({src:e,filename:t,fileSize:n,mimeType:s,title:r,items:a})=>a&&a.length>0?a:e?[{src:e,filename:t,fileSize:n,mimeType:s,title:r}]:[],vu=({variant:e,item:t,index:n,onActivate:s,trailingAction:r})=>{const a=t.filename??Me(t.src);return o.jsx(Xr,{variant:e,filename:a,title:t.title,mimeType:t.mimeType??"application/octet-stream",fileSize:t.fileSize,onActivate:()=>s(n),activateLabel:`Download ${a}`,trailingAction:r})},Hn=({state:e,src:t,filename:n,fileSize:s,mimeType:r,title:a,items:i,text:c,groupPosition:u,onClick:d,onDismiss:h})=>{const f=mt(e),p=e==="composer"&&!!h,l=bu({src:t,filename:n,fileSize:s,mimeType:r,title:a,items:i}),g=b=>{if((d==null?void 0:d(b))===!1)return;const v=l[b];if(!v)return;const w=v.filename??Me(v.src);Zr(v.src,w)};if(l.length===0)return null;const x=o.jsx("span",{className:V("flex size-8 items-center justify-center rounded-full",f==="dark"?"text-white/70":"text-black/70"),"aria-hidden":!0,children:o.jsx(P.DownloadSimpleIcon,{className:"size-5",weight:"bold"})});return o.jsx(dt,{variant:f,text:c,groupPosition:u,"data-testid":"file-attachment",children:o.jsx("div",{className:"flex flex-col gap-2",children:l.map((b,v)=>{const w=p&&v===0?o.jsx(ft,{onClick:h,variant:"inline"}):x;return o.jsx(vu,{variant:f,item:b,index:v,onActivate:g,trailingAction:w},`${b.src}-${v}`)})})})},wu=e=>o.jsx(Hn,{...e,state:"composer"}),yu=e=>o.jsx(Hn,{...e,state:"sent"}),_u=e=>o.jsx(Hn,{...e,state:"received"}),Eu={Composer:wu,Sent:yu,Received:_u},Wn=({onPrev:e,onNext:t,prevLabel:n="Previous",nextLabel:s="Next"})=>o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",onClick:e,"aria-label":n,className:"mes-media-viewer__nav mes-media-viewer__nav--prev",children:o.jsx(P.CaretLeftIcon,{size:20,weight:"bold","aria-hidden":!0})}),o.jsx("button",{type:"button",onClick:t,"aria-label":s,className:"mes-media-viewer__nav mes-media-viewer__nav--next",children:o.jsx(P.CaretRightIcon,{size:20,weight:"bold","aria-hidden":!0})})]}),Jr=({url:e,filename:t,variant:n="pill",label:s="Download",iconOnly:r,tone:a="dark",onTriggered:i})=>{const[c,u]=m.useState(!1),d=m.useCallback(l=>{l.stopPropagation(),!c&&(u(!0),Zr(e,t).catch(()=>{}).finally(()=>{u(!1),i==null||i()}))},[c,e,t,i]),h=r??n!=="pill",p={className:V(n==="pill"?"size-4":"size-5","shrink-0"),weight:"bold"};if(n==="inline"){const l={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 o.jsx("button",{type:"button",onClick:d,disabled:c,"aria-label":s,className:V("flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70",l[a]),children:c?o.jsx(P.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):o.jsx(P.DownloadSimpleIcon,{className:"size-5 shrink-0",weight:"bold","aria-hidden":!0})})}return n==="viewer"?o.jsx("button",{type:"button",onClick:d,disabled:c,"aria-label":s,className:"mes-media-viewer__action",children:c?o.jsx(P.CircleNotchIcon,{size:20,weight:"bold","aria-hidden":!0}):o.jsx(P.DownloadSimpleIcon,{size:20,weight:"bold","aria-hidden":!0})}):o.jsxs("button",{type:"button",onClick:d,disabled:c,"aria-label":h?s:void 0,className:V("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",a==="dark"?"bg-[#121110] text-white hover:bg-[#2a2928]":"bg-white text-[#121110] hover:bg-white/90"),children:[c?o.jsx(P.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):o.jsx(P.DownloadSimpleIcon,{...p,"aria-hidden":!0}),h?null:s]})},rn=(e,t,n)=>Math.min(Math.max(e,t),n),Yn=({length:e,initialIndex:t,open:n})=>{const s=rn(t,0,Math.max(e-1,0)),[r,a]=m.useState(s);m.useEffect(()=>{n&&a(rn(t,0,Math.max(e-1,0)))},[n,t,e]),m.useEffect(()=>{a(u=>rn(u,0,Math.max(e-1,0)))},[e]);const i=m.useCallback(()=>{e<=1||a(u=>u<=0?e-1:u-1)},[e]),c=m.useCallback(()=>{e<=1||a(u=>u>=e-1?0:u+1)},[e]);return m.useEffect(()=>{if(!n||e<=1)return;const u=d=>{if(d.key!=="ArrowLeft"&&d.key!=="ArrowRight")return;const h=document.activeElement;h&&(h.tagName==="VIDEO"||h.tagName==="AUDIO")||(d.preventDefault(),d.key==="ArrowLeft"?i():c())};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[n,e,i,c]),{index:r,prev:i,next:c}},Gn=({open:e,onClose:t,ariaLabel:n,counter:s,actions:r,children:a,"data-testid":i})=>{const c=m.useRef(null),u=m.useRef(null);m.useEffect(()=>{var p;const f=c.current;if(f){if(e){if(!f.open)if(typeof f.showModal=="function")try{f.showModal()}catch{f.setAttribute("open","")}else f.setAttribute("open","");const l=typeof document<"u"?document.activeElement:null;return(p=u.current)==null||p.focus(),()=>{if(f.open)if(typeof f.close=="function")try{f.close()}catch{f.removeAttribute("open")}else f.removeAttribute("open");l&&document.body.contains(l)&&l.focus()}}if(f.open)if(typeof f.close=="function")try{f.close()}catch{f.removeAttribute("open")}else f.removeAttribute("open")}},[e]);const d=()=>{t()},h=f=>{f.target===c.current&&t()};return o.jsxs("dialog",{ref:c,className:"mes-media-viewer","aria-label":n??"Attachment viewer","data-testid":i,onClose:d,onClick:h,children:[o.jsxs("div",{className:"mes-media-viewer__chrome",children:[s?o.jsx("span",{className:"mes-media-viewer__counter",children:s}):null,o.jsxs("div",{className:"mes-media-viewer__actions",children:[r,o.jsx("button",{ref:u,type:"button",onClick:t,"aria-label":"Close viewer",className:"mes-media-viewer__action",children:o.jsx(P.XIcon,{size:20,weight:"bold","aria-hidden":!0})})]})]}),o.jsx("div",{className:"mes-media-viewer__body",children:a})]})},Qr=({open:e,items:t,initialIndex:n=0,onClose:s})=>{const{index:r,prev:a,next:i}=Yn({length:t.length,initialIndex:n,open:e}),c=t[r],u=m.useMemo(()=>(c==null?void 0:c.filename)??(c?Me(c.src):"image"),[c]);return c?o.jsxs(Gn,{open:e,onClose:s,ariaLabel:u,counter:t.length>1?`${r+1} / ${t.length}`:void 0,actions:o.jsx(Jr,{url:c.src,filename:u,variant:"viewer",label:`Download ${u}`}),"data-testid":"image-viewer",children:[o.jsx("img",{src:c.src,alt:c.alt??u,draggable:!1,loading:"eager",decoding:"async",className:"mes-media-viewer__image"},`${r}:${c.src}`),t.length>1?o.jsx(Wn,{onPrev:a,onNext:i,prevLabel:"Previous image",nextLabel:"Next image"}):null]}):null},Cu="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",eo=({tiles:e,onTileActivate:t,maxVisible:n=4,className:s})=>{const r=e.length;if(r===0)return null;const a=e.slice(0,Math.min(r,n)),i=r-a.length,c=(u,d,h)=>{const f=V(Cu,"h-full w-full");return t?o.jsxs("button",{type:"button",onClick:()=>t(d),"aria-label":u.ariaLabel??`Open media ${d+1}`,className:V(f,"cursor-zoom-in"),children:[u.content,h]},d):o.jsxs("div",{className:f,children:[u.content,h]},d)};return a.length===1?o.jsx("div",{className:V("aspect-square w-full",s),children:c(a[0],0)}):a.length===2?o.jsx("div",{className:V("grid aspect-[16/9] w-full grid-cols-2 gap-0.5",s),children:a.map((u,d)=>c(u,d))}):a.length===3?o.jsxs("div",{className:V("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",s),children:[o.jsx("div",{className:"row-span-2",children:c(a[0],0)}),c(a[1],1),c(a[2],2)]}):o.jsx("div",{className:V("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",s),children:a.map((u,d)=>{const h=i>0&&d===a.length-1;return c(u,d,h?o.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-black/55 text-2xl font-semibold text-white",children:["+",i]}):null)})})},ht=e=>{const[t,n]=m.useState(!1),[s,r]=m.useState(0),a=m.useCallback(c=>{(e==null?void 0:e(c))!==!1&&(r(c),n(!0))},[e]),i=m.useCallback(()=>n(!1),[]);return{viewerOpen:t,viewerIndex:s,handleActivate:a,closeViewer:i}},Nu=(e,t,n,s)=>({ariaLabel:`Open image ${t+1} of ${n}`,content:o.jsx("img",{src:e.src,alt:e.alt??"",width:e.width,height:e.height,draggable:!1,loading:e.loading??s,decoding:"async",className:"absolute inset-0 size-full rounded-md object-cover"})}),Su=({src:e,alt:t,items:n})=>n&&n.length>0?n:e?[{src:e,alt:t}]:[],to=(e,t)=>e.map((n,s)=>({src:n.src,alt:n.alt,filename:t&&e.length===1?t:t?`${t} (${s+1})`:void 0})),ju=({src:e,alt:t,filename:n,loading:s="lazy",onClick:r,onDismiss:a})=>{const{viewerOpen:i,viewerIndex:c,handleActivate:u,closeViewer:d}=ht(r);return o.jsxs("div",{className:"relative w-fit",children:[o.jsx("button",{type:"button",onClick:()=>u(0),"aria-label":"Open image",className:"block size-[280px] cursor-zoom-in overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",children:o.jsx("img",{src:e,alt:t??"",draggable:!1,loading:s,decoding:"async",className:"size-full object-cover"})}),a?o.jsx("div",{className:"absolute right-2 top-2 z-10",children:o.jsx(ft,{onClick:a})}):null,o.jsx(Qr,{open:i,items:to([{src:e,alt:t}],n),initialIndex:c,onClose:d})]})},no=({state:e,src:t,alt:n,filename:s,items:r,text:a,groupPosition:i,loading:c="lazy",onClick:u})=>{const d=Su({src:t,alt:n,items:r}),h=mt(e),{viewerOpen:f,viewerIndex:p,handleActivate:l,closeViewer:g}=ht(u);if(d.length===0)return null;const x=d.map((b,v)=>Nu(b,v,d.length,c));return o.jsxs(dt,{variant:h,text:a,groupPosition:i,"data-testid":"image-attachment",children:[o.jsx("div",{className:"relative",children:o.jsx(eo,{tiles:x,onTileActivate:l})}),o.jsx(Qr,{open:f,items:to(d,s),initialIndex:p,onClose:g})]})},ku=e=>o.jsx(ju,{...e}),$u=e=>o.jsx(no,{...e,state:"sent"}),Mu=e=>o.jsx(no,{...e,state:"received"}),Ru={Composer:ku,Sent:$u,Received:Mu},Tu=({open:e,items:t,initialIndex:n=0,onClose:s})=>{const{index:r,prev:a,next:i}=Yn({length:t.length,initialIndex:n,open:e}),c=t[r],u=m.useMemo(()=>(c==null?void 0:c.filename)??(c?Me(c.src):"document"),[c]),d=m.useMemo(()=>c?Iu(c.src):void 0,[c]);return!c||!d?null:o.jsxs(Gn,{open:e,onClose:s,ariaLabel:u,counter:t.length>1?`${r+1} / ${t.length}`:void 0,"data-testid":"pdf-viewer",children:[o.jsx("iframe",{src:d,title:u,className:"mes-media-viewer__iframe",sandbox:"allow-scripts allow-forms allow-popups allow-downloads"},`${r}:${c.src}`),t.length>1?o.jsx(Wn,{onPrev:a,onNext:i,prevLabel:"Previous document",nextLabel:"Next document"}):null]})},Iu=e=>{const t=e.indexOf("#"),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+1),r=new URLSearchParams(s);return r.has("toolbar")||r.set("toolbar","0"),r.has("navpanes")||r.set("navpanes","0"),`${n}#${r.toString()}`},Lu=({src:e,filename:t,fileSize:n,title:s,items:r})=>r&&r.length>0?r:e?[{src:e,filename:t,fileSize:n,title:s}]:[],Du=({variant:e,item:t,index:n,onActivate:s,trailingAction:r})=>{const a=t.filename??Me(t.src);return o.jsx(Xr,{variant:e,filename:a,title:t.title,mimeType:"application/pdf",fileSize:t.fileSize,onActivate:()=>s(n),activateLabel:`Open ${a}`,trailingAction:r})},qn=({state:e,src:t,filename:n,fileSize:s,title:r,items:a,text:i,groupPosition:c,onClick:u,onDismiss:d})=>{const h=mt(e),f=Lu({src:t,filename:n,fileSize:s,title:r,items:a}),{viewerOpen:p,viewerIndex:l,handleActivate:g,closeViewer:x}=ht(u),b=e==="composer"&&!!d;if(f.length===0)return null;const v=f.map(w=>({src:w.src,filename:w.filename??Me(w.src)}));return o.jsxs(dt,{variant:h,text:i,groupPosition:c,"data-testid":"pdf-attachment",children:[o.jsx("div",{className:"flex flex-col gap-2",children:f.map((w,E)=>{const j=w.filename??Me(w.src),R=b&&E===0?o.jsx(ft,{onClick:d,variant:"inline"}):e==="composer"?void 0:o.jsx(Jr,{url:w.src,filename:j,variant:"inline",label:`Download ${j}`,tone:h});return o.jsx(Du,{variant:h,item:w,index:E,onActivate:g,trailingAction:R},`${w.src}-${E}`)})}),o.jsx(Tu,{open:p,items:v,initialIndex:l,onClose:x})]})},Au=e=>o.jsx(qn,{...e,state:"composer"}),Ou=e=>o.jsx(qn,{...e,state:"sent"}),Fu=e=>o.jsx(qn,{...e,state:"received"}),Pu={Composer:Au,Sent:Ou,Received:Fu},so=({open:e,items:t,initialIndex:n=0,onClose:s})=>{const{index:r,prev:a,next:i}=Yn({length:t.length,initialIndex:n,open:e}),c=t[r],u=m.useMemo(()=>(c==null?void 0:c.filename)??(c?Me(c.src):"video"),[c]);return c?o.jsxs(Gn,{open:e,onClose:s,ariaLabel:u,counter:t.length>1?`${r+1} / ${t.length}`:void 0,"data-testid":"video-viewer",children:[o.jsx("video",{src:c.src,poster:c.poster,controls:!0,autoPlay:!0,muted:!0,playsInline:!0,preload:c.preload??"metadata",className:"mes-media-viewer__video",children:c.mimeType?o.jsx("source",{src:c.src,type:c.mimeType}):null},`${r}:${c.src}`),t.length>1?o.jsx(Wn,{onPrev:a,onNext:i,prevLabel:"Previous video",nextLabel:"Next video"}):null]}):null},zu=()=>o.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:o.jsx("span",{className:"flex size-12 items-center justify-center rounded-full bg-black/55 text-white backdrop-blur",children:o.jsx(P.PlayIcon,{className:"size-6",weight:"fill","aria-hidden":!0})})}),ro=({item:e,index:t})=>o.jsxs("div",{className:"absolute inset-0 size-full bg-[#0d0d0d]",children:[e.poster?o.jsx("img",{src:e.poster,alt:`Video ${t+1} thumbnail`,draggable:!1,loading:"lazy",decoding:"async",className:"absolute inset-0 size-full rounded-md object-cover"}):o.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:o.jsx(P.VideoCameraIcon,{className:"size-16 rounded-md text-white/30",weight:"regular","aria-hidden":!0})}),o.jsx(zu,{})]}),Bu=(e,t,n)=>({ariaLabel:`Play video ${t+1} of ${n}`,content:o.jsx(ro,{item:e,index:t})}),Vu=({src:e,poster:t,mimeType:n,preload:s,items:r})=>r&&r.length>0?s?r.map(a=>({...a,preload:a.preload??s})):r:e?[{src:e,poster:t,mimeType:n,preload:s}]:[],oo=(e,t)=>e.map((n,s)=>({src:n.src,poster:n.poster,mimeType:n.mimeType,preload:n.preload,filename:t&&e.length===1?t:t?`${t} (${s+1})`:void 0})),Uu=({src:e,poster:t,mimeType:n,filename:s,preload:r,onClick:a,onDismiss:i})=>{const{viewerOpen:c,viewerIndex:u,handleActivate:d,closeViewer:h}=ht(a);return o.jsxs("div",{className:"relative w-fit",children:[o.jsx("button",{type:"button",onClick:()=>d(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:o.jsx(ro,{item:{src:e,poster:t,mimeType:n},index:0})}),i?o.jsx("div",{className:"absolute right-2 top-2 z-10",children:o.jsx(ft,{onClick:i})}):null,o.jsx(so,{open:c,items:oo([{src:e,poster:t,mimeType:n,preload:r}],s),initialIndex:u,onClose:h})]})},ao=({state:e,src:t,poster:n,mimeType:s,filename:r,items:a,text:i,groupPosition:c,preload:u,onClick:d})=>{const h=Vu({src:t,poster:n,mimeType:s,preload:u,items:a}),f=mt(e),{viewerOpen:p,viewerIndex:l,handleActivate:g,closeViewer:x}=ht(d);if(h.length===0)return null;const b=h.map((v,w)=>Bu(v,w,h.length));return o.jsxs(dt,{variant:f,text:i,groupPosition:c,"data-testid":"video-attachment",children:[o.jsx("div",{className:"relative",children:o.jsx(eo,{tiles:b,onTileActivate:g,className:"overflow-hidden rounded-md"})}),o.jsx(so,{open:p,items:oo(h,r),initialIndex:l,onClose:x})]})},Hu=e=>o.jsx(Uu,{...e}),Wu=e=>o.jsx(ao,{...e,state:"sent"}),Yu=e=>o.jsx(ao,{...e,state:"received"}),Gu={Composer:Hu,Sent:Wu,Received:Yu},qu={Image:Ru,Video:Gu,Audio:mu,Pdf:Pu,File:Eu},io=({question:e,onClick:t,loading:n=!1,className:s})=>o.jsx("button",{type:"button",onClick:t,disabled:n,style:{backgroundColor:"#E6E5E3"},className:V("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},s),children:e}),Ku=({faqs:e,onFaqClick:t,loadingFaqId:n,headerText:s,className:r,avatarImage:a,avatarName:i})=>{const c=e.filter(u=>u.enabled).sort((u,d)=>(u.order??0)-(d.order??0));return c.length===0?null:o.jsx("div",{className:r,children:o.jsxs("div",{className:"flex gap-3 items-end",children:[(a||i)&&o.jsx("div",{className:"flex-none",children:o.jsx(ke,{id:i||"account",name:i||"Account",image:a,size:24,shape:"circle"})}),o.jsxs("div",{className:"flex-1 flex flex-col gap-3 rounded-lg p-4",style:{backgroundColor:"#F1F0EE"},children:[s&&o.jsx("p",{className:"text-md text-charcoal mb-4",children:s}),c.map(u=>o.jsx(io,{question:u.question,onClick:()=>t(u.id),loading:n===u.id},u.id))]})]})})};exports.ActionButton=st;exports.AttachmentThumbnail=_n;exports.Avatar=ke;exports.ChannelEmptyState=Hr;exports.ChannelList=wn;exports.ChannelView=zn;exports.CustomMessageProvider=na;exports.FaqList=Ku;exports.FaqListItem=io;exports.LinkAttachment=tu;exports.LockedAttachment=cn;exports.MediaMessage=Qo;exports.MessageAttachment=qu;exports.MessageVoteButtons=dr;exports.MessagingProvider=uo;exports.MessagingShell=zl;exports.bubbleGroupPositionFromStream=iu;exports.buildCompactMetaLabel=Kr;exports.formatFileSize=Gr;exports.formatRelativeTime=Xs;exports.getFileExtensionLabel=qr;exports.getMessageDisplayText=vn;exports.getSourceType=Re;exports.isLinkAttachment=Nn;exports.isUuidLike=Js;exports.normalizeLanguageCode=Zs;exports.renderTypeIcon=Ue;exports.resolveLinkAttachment=Ft;exports.resolveMediaFromMessage=Pt;exports.resolveParticipantDisplayName=Ot;exports.useCustomMessage=ur;exports.useMessageVote=tr;exports.useMessaging=Gs;
|
|
18
|
-
//# sourceMappingURL=index-
|
|
18
|
+
//# sourceMappingURL=index-C0RXJhLE.cjs.map
|