// @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{Ft as t,_n as n,li as r,qi as i}from"./lucide-icons-BdRF0moN.js";import{t as a}from"./jsx-runtime-By8HlURe.js";import{t as o}from"./dist-DQ82bf9M.js";import{t as s}from"./useQuery-rCAlChE8.js";import{t as c}from"./useCurrentUser-C6OJJlWo.js";import{t as l}from"./button-Cs26nq0r.js";import{r as u}from"./appRelays-Clm5NPIe.js";import{t as d}from"./skeleton-CVls4GW9.js";import{l as f}from"./ComposeDialogContent-YxhSZA-Y.js";import{a as p}from"./extraKinds-BydAXtVV.js";import{r as m}from"./NoteCard-COwLfrJJ.js";import{t as h}from"./useFeedSettings-DkFDaYIY.js";import{t as g}from"./usePageRefresh-BuJEOs2u.js";import{C as _,b as v,y}from"./index-CYEZWNq6.js";import{t as b}from"./PageHeader-CMi4aeE4.js";var x=e(i(),1);function S(e,t){let n=e.trim();if(!n)return[];if(t!==`#t`)return[n];let r=[n,n.toLowerCase(),n.toUpperCase()];return Array.from(new Set(r))}var C=a();function w(){return(0,C.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:5}).map((e,t)=>(0,C.jsx)(`div`,{className:`px-4 py-3`,children:(0,C.jsxs)(`div`,{className:`flex gap-3`,children:[(0,C.jsx)(d,{className:`size-11 rounded-full`}),(0,C.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,C.jsx)(d,{className:`h-4 w-48`}),(0,C.jsx)(d,{className:`h-4 w-full`}),(0,C.jsx)(d,{className:`h-4 w-3/4`})]})]})},t))})}function T({tag:e,filterKey:i,icon:a,title:d,followable:T=!1,search:E,emptyMessage:D}){let{nostr:O}=o(),{user:k}=c(),{feedSettings:A}=h(),{isMuted:j}=y(),{hasInterest:M,addInterest:N,removeInterest:P}=v(i===`#g`?`g`:`t`),F=T?M(e):!1,I=N.isPending||P.isPending,L=p(A).filter(e=>!f(e)),R=[...L].sort().join(`,`),z=(0,x.useMemo)(()=>S(e,i),[e,i]),B=z.join(`|`),V=(0,x.useMemo)(()=>[`tag-feed`,i,B,R],[i,B,R]),H=g(V),{data:U,isLoading:W}=s({queryKey:V,queryFn:async({signal:e})=>{let t=O.group(u),n={kinds:L,limit:40,...E?{search:E}:{}};return n[i]=z,t.query([n],{signal:AbortSignal.any([e,AbortSignal.timeout(1e4)])})},enabled:z.length>0}),G=(0,x.useMemo)(()=>U&&U.filter(e=>!j(e)),[U,j]);return(0,C.jsxs)(`main`,{className:``,children:[(0,C.jsx)(b,{title:d,icon:a?(0,C.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:a}):void 0,children:T&&k&&e&&(0,C.jsx)(l,{size:`sm`,variant:F?`outline`:`default`,className:`rounded-full gap-1.5 shrink-0`,disabled:I,onClick:()=>F?P.mutate(e):N.mutate(e),children:I?(0,C.jsx)(n,{className:`size-3.5 animate-spin`}):F?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(r,{className:`size-3.5`}),` Following`]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(t,{className:`size-3.5`}),` Follow`]})})}),(0,C.jsx)(_,{onRefresh:H,children:W?(0,C.jsx)(w,{}):G&&G.length>0?(0,C.jsx)(`div`,{children:G.map(e=>(0,C.jsx)(m,{event:e},e.id))}):(0,C.jsx)(`div`,{className:`py-16 text-center text-muted-foreground px-4`,children:(0,C.jsx)(`span`,{className:`break-all`,children:D})})})]})}export{T as t};
// @license-end
