import{u as $}from"./useUserRecruitment-CrLCOi1l.js";import{D as j,ac as c,d as A,P as F,k as M,E as z,c as o,a as e,f as r,t as i,F as f,e as x,n as D,g as R,o as n,a4 as I,r as J}from"./index-CU1_ljpG.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:b,actionError:g,actionInProgressId:E,load:N,acceptInvite:P,rejectInvite:L,withdrawRequest:B}=$(),_=J({}),k=R(()=>u.value.map(s=>({invite:s,name:_.value[s.community.id]??"Loading...",isRemote:c(s.community.homeServer)!==c(d.homeDomain)}))),w=R(()=>h.value.map(s=>({request:s,name:_.value[s.community.id]??"Loading...",isRemote:c(s.community.homeServer)!==c(d.homeDomain)})));async function V(s){const a={..._.value};await Promise.all(s.map(async t=>{const l=t.community.id;if(a[l])return;const p=d.clientForCommunity(t.community);a[l]=await T(t.community,p,d.homeDomain)})),_.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 E.value===s}return z(()=>{N()}),(s,a)=>(n(),o("section",U,[a[2]||(a[2]=e("header",{class:"mb-6"},[e("p",{class:"text-xs uppercase tracking-wide text-slate-400"},"Direct messages"),e("h1",{class:"mt-1 text-2xl font-semibold text-slate-100"},"Invitations")],-1)),r(y)?(n(),o("p",W,"Loading invitations...")):r(b)?(n(),o("p",G,i(r(b)),1)):(n(),o(f,{key:2},[r(g)?(n(),o("p",H,i(r(g)),1)):x("",!0),e("section",K,[a[0]||(a[0]=e("h2",{class:"mb-3 text-sm font-semibold uppercase tracking-wide text-slate-400"},"Invitations",-1)),e("ul",O,[(n(!0),o(f,null,D(k.value,({invite:t,name:l,isRemote:p})=>(n(),o("li",{key:t.id,class:"flex flex-wrap items-center gap-2 rounded-lg border border-slate-800 bg-slate-900/70 px-3 py-3"},[e("div",Q,[e("p",X,i(l),1),e("p",Y,[p?(n(),o("span",Z,"@ "+i(t.community.homeServer)+" · ",1)):x("",!0),I(" Expires "+i(S(t.dateExpires)),1)])]),e("div",q,[e("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(t.id),onClick:C=>{r(P)(t)}}," Accept ",8,ee),e("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(t.id),onClick:C=>{r(L)(t)}}," Reject ",8,te)])]))),128)),k.value.length===0?(n(),o("li",se,"No pending invitations.")):x("",!0)])]),e("section",null,[a[1]||(a[1]=e("h2",{class:"mb-3 text-sm font-semibold uppercase tracking-wide text-slate-400"},"Join requests",-1)),e("ul",oe,[(n(!0),o(f,null,D(w.value,({request:t,name:l,isRemote:p})=>(n(),o("li",{key:t.id,class:"flex flex-wrap items-center gap-2 rounded-lg border border-slate-800 bg-slate-900/70 px-3 py-3"},[e("div",ne,[e("p",ae,i(l),1),e("p",re,[p?(n(),o("span",ie,"@ "+i(t.community.homeServer)+" · ",1)):x("",!0),I(" Expires "+i(S(t.dateExpires)),1)])]),e("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(t.id),onClick:C=>{r(B)(t)}}," 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-ybiwovud.js.map
