import{u as $}from"./useUserRecruitment-CVnGe1PI.js";import{D as j,a8 as c,d as A,P as F,k as M,E as z,c as o,f as r,t as i,F as f,e as x,a as t,n as R,g as D,o as n,a0 as E,r as J}from"./index-B4jeNr7A.js";async function T(m,d,u){const y=j().communityById(m.id);if(y)return y.name;try{return(await d.getCommunity(m.id)).name}catch{return c(m.homeServer)!==c(u)?`Private community @ ${m.homeServer}`:"Private community"}}const U={class:"h-full overflow-y-auto p-6"},W={key:0,class:"text-sm text-slate-400"},G={key:1,class:"text-sm text-rose-300"},H={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"},K={class:"mb-8"},O={class:"space-y-2"},Q={class:"min-w-0 flex-1"},X={class:"truncate text-sm font-medium text-slate-100"},Y={class:"truncate text-xs text-slate-400"},Z={key:0},q={class:"flex shrink-0 gap-2"},ee=["disabled","onClick"],te=["disabled","onClick"],se={key:0,class:"text-sm text-slate-400"},oe={class:"space-y-2"},ne={class:"min-w-0 flex-1"},ae={class:"truncate text-sm font-medium text-slate-100"},re={class:"truncate text-xs text-slate-400"},ie={key:0},de=["disabled","onClick"],le={key:0,class:"text-sm text-slate-400"},ue=A({__name:"DirectMessagesInvitationsView",setup(m){const d=F(),{invites:u,requests:h,loading:y,error:_,actionError:g,actionInProgressId:I,load:N,acceptInvite:P,rejectInvite:L,withdrawRequest:B}=$(),b=J({}),k=D(()=>u.value.map(s=>({invite:s,name:b.value[s.community.id]??"Loading...",isRemote:c(s.community.homeServer)!==c(d.homeDomain)}))),w=D(()=>h.value.map(s=>({request:s,name:b.value[s.community.id]??"Loading...",isRemote:c(s.community.homeServer)!==c(d.homeDomain)})));async function V(s){const a={...b.value};await Promise.all(s.map(async e=>{const l=e.community.id;if(a[l])return;const p=d.clientForCommunity(e.community);a[l]=await T(e.community,p,d.homeDomain)})),b.value=a}M([u,h],()=>{V([...u.value,...h.value])});function S(s){return new Date(s).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function v(s){return I.value===s}return z(()=>{N()}),(s,a)=>(n(),o("section",U,[r(y)?(n(),o("p",W,"Loading invitations...")):r(_)?(n(),o("p",G,i(r(_)),1)):(n(),o(f,{key:2},[r(g)?(n(),o("p",H,i(r(g)),1)):x("",!0),t("section",K,[a[0]||(a[0]=t("h2",{class:"mb-3 text-lg font-semibold uppercase tracking-wide text-slate-400"},"Invitations",-1)),t("ul",O,[(n(!0),o(f,null,R(k.value,({invite:e,name:l,isRemote:p})=>(n(),o("li",{key:e.id,class:"flex flex-wrap items-center gap-2 rounded-lg border border-slate-800 bg-slate-900/70 px-3 py-3"},[t("div",Q,[t("p",X,i(l),1),t("p",Y,[p?(n(),o("span",Z,"@ "+i(e.community.homeServer)+" · ",1)):x("",!0),E(" Expires "+i(S(e.dateExpires)),1)])]),t("div",q,[t("button",{type:"button",class:"rounded-md border border-emerald-400/50 bg-emerald-500/20 px-3 py-1.5 text-xs font-medium text-emerald-100 transition hover:bg-emerald-500/30 disabled:cursor-not-allowed disabled:opacity-50",disabled:v(e.id),onClick:C=>{r(P)(e)}}," Accept ",8,ee),t("button",{type:"button",class:"rounded-md border border-slate-600 px-3 py-1.5 text-xs font-medium text-slate-200 transition hover:bg-slate-800 disabled:cursor-not-allowed disabled:opacity-50",disabled:v(e.id),onClick:C=>{r(L)(e)}}," Reject ",8,te)])]))),128)),k.value.length===0?(n(),o("li",se,"No pending invitations.")):x("",!0)])]),t("section",null,[a[1]||(a[1]=t("h2",{class:"mb-3 text-lg font-semibold uppercase tracking-wide text-slate-400"},"Join requests",-1)),t("ul",oe,[(n(!0),o(f,null,R(w.value,({request:e,name:l,isRemote:p})=>(n(),o("li",{key:e.id,class:"flex flex-wrap items-center gap-2 rounded-lg border border-slate-800 bg-slate-900/70 px-3 py-3"},[t("div",ne,[t("p",ae,i(l),1),t("p",re,[p?(n(),o("span",ie,"@ "+i(e.community.homeServer)+" · ",1)):x("",!0),E(" Expires "+i(S(e.dateExpires)),1)])]),t("button",{type:"button",class:"shrink-0 rounded-md border border-rose-400/50 bg-rose-500/10 px-3 py-1.5 text-xs font-medium text-rose-100 transition hover:bg-rose-500/20 disabled:cursor-not-allowed disabled:opacity-50",disabled:v(e.id),onClick:C=>{r(B)(e)}}," Withdraw ",8,de)]))),128)),w.value.length===0?(n(),o("li",le,"No pending join requests.")):x("",!0)])])],64))]))}});export{ue as default};
//# sourceMappingURL=DirectMessagesInvitationsView-Ca7jcrr0.js.map
