import{d as k,o as t,c as o,p as w,e as d,a as m,t as a,a4 as T,D as j,X as D,f as c,F as _,n as E,g as C,m as z}from"./index-BhMpD06x.js";import{u as H,r as M,a as U}from"./useCommunityBrowser-B0bzLltT.js";import{u as X}from"./useUserRecruitment-CJpxhdxR.js";const G={key:0,class:"absolute -right-0.5 -top-0.5 rounded border border-emerald-400/40 bg-emerald-500/15 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-emerald-200"},O={class:"truncate pr-6 text-base font-semibold text-slate-100"},Q={class:"mt-1 text-xs text-slate-400"},W={key:0},Y={key:1,class:"mt-3 line-clamp-3 flex-1 text-sm text-slate-400"},Z={key:2,class:"mt-3 flex-1 text-sm text-slate-500 italic"},ee=["disabled"],te=k({__name:"CommunityBrowserCommunityCard",props:{community:{},action:{},actionLabel:{},actionButtonClass:{},actionInProgress:{type:Boolean}},emits:["action"],setup(s,{emit:l}){const b=l;return(x,u)=>(t(),o("article",{class:w(["relative flex flex-col rounded-xl border border-slate-800 bg-slate-900/70 p-4",s.action==="member"?"opacity-60":""])},[s.action==="member"?(t(),o("span",G," Member ")):d("",!0),m("h3",O,a(s.community.name),1),m("p",Q,[T(a(s.community.isPrivate?"Private":"Public")+" ",1),s.community.allowsJoinRequests?(t(),o("span",W," · Join requests")):d("",!0)]),s.community.description?(t(),o("p",Y,a(s.community.description),1)):(t(),o("p",Z," No description ")),s.actionLabel?(t(),o("button",{key:3,type:"button",class:w(["mt-4 w-full rounded-md border px-3 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-50",s.actionButtonClass]),disabled:s.actionInProgress,onClick:u[0]||(u[0]=y=>b("action"))},a(s.actionLabel),11,ee)):d("",!0)],2))}}),oe={class:"h-full overflow-y-auto p-6"},se={class:"mb-6"},ne={class:"mt-1 text-2xl font-semibold text-slate-100"},ie={key:0,class:"text-sm text-slate-400"},ae={key:1,class:"text-sm text-rose-300"},re={key:0,class:"mb-4 rounded-md border border-rose-500/40 bg-rose-500/10 px-3 py-2 text-sm text-rose-200"},ce={key:1,class:"grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3"},le={key:2,class:"text-sm text-slate-400"},me={key:3,class:"text-sm text-slate-400"},xe=k({__name:"CommunityBrowserHomeView",setup(s){const l=H(),b=X(),x=j(),{communities:u}=D(x),{loading:y,error:p,selectedServer:v,communitiesForSelectedServer:B}=l,{invites:q,requests:$,actionError:f,actionInProgressId:S,acceptInvite:I,withdrawRequest:L,requestJoin:A}=b,P=C(()=>v.value?.label??"Browse communities"),h=C(()=>{const e=new Set(u.value.map(r=>r.id)),n=q.value,i=$.value;return B.value.map(r=>{const g=M(r,e,n,i);return{community:r,action:g,actionKey:U(r,g,n,i)}})});function R(e){return S.value===e}function F(e){const n=l.inviteForCommunity(e);n&&I(n)}function N(e){const n=l.requestForCommunity(e);n&&L(n)}function J(e){switch(e){case"accept-invite":return"Accept invitation";case"cancel-request":return"Cancel request";case"join":return"Join";default:return null}}function V(e){switch(e){case"accept-invite":return"border-emerald-400/50 bg-emerald-500/20 text-emerald-100 hover:bg-emerald-500/30";case"cancel-request":return"border-rose-400/50 bg-rose-500/10 text-rose-100 hover:bg-rose-500/20";default:return"border-blue-400/50 bg-blue-500/20 text-blue-100 hover:bg-blue-500/30"}}function K(e){if(e.action==="accept-invite"){F(e.community.id);return}if(e.action==="cancel-request"){N(e.community.id);return}e.action==="join"&&A(e.community)}return(e,n)=>(t(),o("section",oe,[m("header",se,[n[0]||(n[0]=m("p",{class:"text-xs uppercase tracking-wide text-slate-400"},"Communities",-1)),m("h1",ne,a(P.value),1)]),c(y)?(t(),o("p",ie,"Loading communities...")):c(p)?(t(),o("p",ae,a(c(p)),1)):(t(),o(_,{key:2},[c(f)?(t(),o("p",re,a(c(f)),1)):d("",!0),h.value.length>0?(t(),o("div",ce,[(t(!0),o(_,null,E(h.value,i=>(t(),z(te,{key:i.community.id,community:i.community,action:i.action,"action-label":J(i.action),"action-button-class":V(i.action),"action-in-progress":R(i.actionKey),onAction:r=>K(i)},null,8,["community","action","action-label","action-button-class","action-in-progress","onAction"]))),128))])):c(v)?(t(),o("p",le," No communities to browse on this server. ")):(t(),o("p",me," Select a server in the sidebar to browse its communities. "))],64))]))}});export{xe as default};
//# sourceMappingURL=CommunityBrowserHomeView-PUFDU1Di.js.map
