// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0-or-later
// @source: https://gitlab.com/soapbox-pub/ditto/-/tree/f0a3877c
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{qi as t}from"./lucide-icons-BdRF0moN.js";import{t as n}from"./jsx-runtime-By8HlURe.js";import{u as r}from"./esm-CRVqHnq2.js";import{o as i,r as a}from"./react-intl-eZirkCBg.js";import{l as o}from"./useCurrentUser-C6OJJlWo.js";import{n as s,o as c,r as l,t as u}from"./avatar--oX_CTF4.js";import{n as d}from"./chunk-62JRHF6Z-yJW_vgm4.js";import{n as f}from"./CustomEmoji-DRcU63lJ.js";import{t as p}from"./skeleton-CVls4GW9.js";import{t as m}from"./timeAgo-BXjjbyXp.js";import{t as h}from"./useOpenPost-DKpHsp1A.js";import{i as g}from"./useTrending-DsL3v2RN.js";import{y as _}from"./index-CYEZWNq6.js";var v=e(t(),1),y=n();function b(){let{data:e,isLoading:t}=g(`hot`,5),{isMuted:n}=_(),r=(0,v.useMemo)(()=>e&&e.filter(e=>!n(e)),[e,n]);return t?(0,y.jsx)(`div`,{className:`space-y-3 p-1`,children:Array.from({length:3}).map((e,t)=>(0,y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(p,{className:`size-5 rounded-full`}),(0,y.jsx)(p,{className:`h-3 w-20`})]}),(0,y.jsx)(p,{className:`h-3.5 w-full`}),(0,y.jsx)(p,{className:`h-3.5 w-3/4`})]},t))}):!r||r.length===0?(0,y.jsx)(`p`,{className:`text-sm text-muted-foreground p-1`,children:(0,y.jsx)(a,{id:`widgets.hotPosts.empty`,defaultMessage:`No hot posts right now.`})}):(0,y.jsxs)(`div`,{className:`space-y-0.5`,children:[r.slice(0,5).map(e=>(0,y.jsx)(x,{event:e},e.id)),(0,y.jsx)(`div`,{className:`pt-1 px-2`,children:(0,y.jsx)(d,{to:`/trends`,className:`text-xs text-primary hover:underline`,children:(0,y.jsx)(a,{id:`widgets.hotPosts.viewAll`,defaultMessage:`View all on Trends`})})})]})}function x({event:e}){let t=i(),n=o(e.pubkey),a=n.data?.metadata,d=c(a),p=a?.name||a?.display_name||t.formatMessage({id:`common.anonymous`,defaultMessage:`Anonymous`}),{onClick:g,onAuxClick:_}=h(`/${(0,v.useMemo)(()=>r.neventEncode({id:e.id,author:e.pubkey}),[e])}`,e),b=(0,v.useMemo)(()=>{let n=e.content.replace(/https?:\/\/\S+/g,``).trim();return n.length>100?n.slice(0,100)+`…`:n||t.formatMessage({id:`widgets.common.media`,defaultMessage:`(media)`})},[e.content,t]);return(0,y.jsxs)(`button`,{onClick:g,onAuxClick:_,className:`block w-full text-left hover:bg-secondary/40 px-2 py-2 rounded-lg transition-colors`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[(0,y.jsxs)(u,{shape:d,className:`size-4`,children:[(0,y.jsx)(l,{src:a?.picture,alt:p}),(0,y.jsx)(s,{className:`bg-primary/20 text-primary text-[8px]`,children:p[0]?.toUpperCase()})]}),(0,y.jsx)(`span`,{className:`text-xs font-semibold truncate`,children:n.data?.event?(0,y.jsx)(f,{tags:n.data.event.tags,children:p}):p}),(0,y.jsxs)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:[`· `,m(e.created_at)]})]}),(0,y.jsx)(`p`,{className:`text-[13px] text-muted-foreground leading-snug line-clamp-2`,children:b})]})}export{b as HotPostsWidget};
// @license-end
