1import{r as f,i as b,u as $,a as C,d as U,j as t,S as g,I as S,K as _,B as A,g as F}from"./index-WHULU0jW.js";import{C as m}from"./card-BlH5Drk3.js";import{A as L,a as I,b as M}from"./avatar-CiHUCdk-.js";import{B as T}from"./badge-eSQGmkpG.js";import{U as k}from"./user-badge-Dv8r1xDL.js";import{U as h}from"./users-B3UdF1il.js";import{M as B}from"./message-circle-DmKz51ba.js";import"./circle-check-big-CfzjSlYs.js";import"./star-DOWfXQTG.js";function D(){const[r,N]=f.useState(""),{toast:j}=b(),[,w]=$(),{user:i}=C(),n=(i==null?void 0:i._id)||(i==null?void 0:i.id),{data:l,isLoading:c}=U({queryKey:["/api/users/following",n],queryFn:async()=>{const e=await F(`/api/users/following/${n}?page=1&limit=100`);if(!e.ok)throw new Error("Failed to fetch following");const s=await e.json(),a=s.data||s;return{users:Array.isArray(a.users)?a.users:[],total:Number(s.totalDoc??a.totalDoc??0)}},enabled:!!n}),o=(l==null?void 0:l.users)||[],u=(l==null?void 0:l.total)??o.length,d=f.useMemo(()=>{if(!r.trim())return o;const e=r.toLowerCase();return o.filter(s=>{const a=`${s.firstName||""} ${s.lastName||""}`.trim(),v=s.userName||"";return a.toLowerCase().includes(e)||v.toLowerCase().includes(e)})},[o,r]),p=e=>{w(`/inbox/${e._id}`);const s=e.userName||`${e.firstName||""} ${e.lastName||""}`.trim()||"User";j({title:"Opening Messages",description:`Starting conversation with ${s}`})},x=e=>e.userName?e.userName:e.firstName||e.lastName?`${e.firstName||""} ${e.lastName||""}`.trim():"Unknown User",y=e=>{var s,a;return e.firstName||e.lastName?`${((s=e.firstName)==null?void 0:s[0])||""}${((a=e.lastName)==null?void 0:a[0])||""}`.toUpperCase():e.userName?e.userName[0].toUpperCase():"U"};return t.jsx("div",{className:"min-h-screen bg-background","data-testid":"page-friends",children:t.jsxs("div",{className:"w-full p-4 sm:p-6 space-y-4 sm:space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold text-foreground","data-testid":"heading-friends",children:"People I Follow"}),t.jsxs("p",{className:"text-sm text-muted-foreground mt-1","data-testid":"text-description",children:["Users you're following ⢠",u," total"]})]}),t.jsxs(T,{variant:"secondary",className:"text-base px-3 py-1","data-testid":"badge-count-total",children:[t.jsx(h,{className:"h-4 w-4 mr-1.5"}),u]})]}),t.jsxs("div",{className:"relative max-w-xl",children:[t.jsx(g,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(S,{placeholder:"Search people you follow...",value:r,onChange:e=>N(e.target.value),className:"pl-10","data-testid":"input-search-following"})]}),c&&t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx(_,{className:"h-8 w-8 animate-spin text-primary"})}),!c&&t.jsx("div",{className:"space-y-3",children:d.length>0?t.jsxs(t.Fragment,{children:[r&&t.jsxs("p",{className:"text-sm text-muted-foreground","data-testid":"text-search-results",children:["Found ",d.length," ",d.length!==1?"people":"person"]}),t.jsx("div",{className:"space-y-3",children:d.map(e=>t.jsx(m,{className:"p-4 hover-elevate","data-testid":`card-following-${e._id}`,children:t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs(L,{className:"h-14 w-14","data-testid":`avatar-${e._id}`,children:[t.jsx(I,{src:e.profilePhoto,alt:x(e)}),t.jsx(M,{className:"bg-primary text-primary-foreground text-lg",children:y(e)})]}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("p",{className:"font-semibold text-foreground text-base","data-testid":`text-name-${e._id}`,children:x(e)}),(e.badge||e.badgeTier)&&t.jsx(k,{badge:e.badge,badgeTier:e.badgeTier,size:"md"})]}),e.userName&&t.jsxs("p",{className:"text-sm text-muted-foreground","data-testid":`text-username-${e._id}`,children:["@",e.userName]}),t.jsx("div",{className:"flex items-center gap-3 mt-1",children:(e.followersCount??e.followerCount)!==void 0&&t.jsxs("p",{className:"text-xs text-muted-foreground","data-testid":`text-followers-${e._id}
1`,children:[(e.followersCount??e.followerCount??0).toLocaleString()," followers"]})})]}),t.jsxs(A,{size:"default",variant:"default",onClick:()=>p(e),"data-testid":`button-message-${e._id}`,children:[t.jsx(B,{className:"h-4 w-4 mr-2"}),"Message"]})]})},e._id))})]}):r?t.jsx(m,{className:"p-12","data-testid":"card-no-results",children:t.jsxs("div",{className:"text-center",children:[t.jsx(g,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),t.jsx("p",{className:"text-foreground font-medium text-lg","data-testid":"text-no-results",children:"No one found"}),t.jsx("p",{className:"text-sm text-muted-foreground mt-2","data-testid":"text-no-results-description",children:"Try searching with a different name or username"})]})}):t.jsx(m,{className:"p-12","data-testid":"card-empty-following",children:t.jsxs("div",{className:"text-center",children:[t.jsx(h,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),t.jsx("p",{className:"text-foreground font-medium text-lg","data-testid":"text-empty-following",children:"Not following anyone yet"}),t.jsx("p",{className:"text-sm text-muted-foreground mt-2","data-testid":"text-empty-following-description",children:"Start following people to see them here"})]})})})]})})}export{D as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.