import{o as e}from"./chunk-QXcFz7f5.js";import{c as t,l as n,n as r,t as i}from"./app-G6wC4CCm.js";import{t as a}from"./AppNav-TQ3fvEZa.js";import{g as o,h as s}from"./ui-D0zPIw82.js";import{n as c}from"./shield-alert-DYj3LV8H.js";var l=e(t(),1),u=i();function d(e){return e===`viewer`?`Viewer`:e===`editor`?`Editor`:e}function f(e){if(!e)return``;let t=new Date(e).getTime();if(Number.isNaN(t))return``;let n=Math.ceil((t-Date.now())/864e5);return n<=0?`Expires soon`:n===1?`Expires in 1 day`:`Expires in ${n} days`}function p({invitations:e}){let[t,i]=(0,l.useState)(null),p=(e,t)=>{i(`${e}:${t}`),n.post(`/workspace/invitations/${e}/${t}`,{},{onFinish:()=>i(null)})};return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(r,{title:`Workspace invitations`}),(0,u.jsxs)(`div`,{className:`flex min-h-screen flex-col bg-background text-foreground`,children:[(0,u.jsx)(a,{}),(0,u.jsxs)(`main`,{className:`mx-auto w-full max-w-2xl flex-1 px-6 py-8`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Workspace invitations`}),(0,u.jsx)(`p`,{className:`mt-1 text-[12px] text-muted-foreground`,children:e.length>0?`${e.length} pending`:`No pending invitations.`})]}),(0,u.jsx)(s,{padding:`none`,className:`mt-5 overflow-hidden`,children:e.length===0?(0,u.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-6 py-16 text-center`,"data-testid":`invitations-empty`,children:[(0,u.jsx)(c,{className:`h-6 w-6 text-muted-foreground/50`,strokeWidth:1.5}),(0,u.jsx)(`p`,{className:`text-[12px] text-muted-foreground`,children:`You have no pending workspace invitations.`})]}):(0,u.jsx)(`ul`,{className:`divide-y divide-border`,children:e.map(e=>{let n=e.workspace??`a workspace`;return(0,u.jsxs)(`li`,{"data-testid":`invitation-row-${e.id}`,className:`flex flex-wrap items-center justify-between gap-3 px-4 py-4`,children:[(0,u.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,u.jsx)(`p`,{className:`text-[14px] font-medium text-foreground`,children:n}),(0,u.jsx)(`p`,{className:`mt-0.5 text-[12px] text-muted-foreground`,children:e.inviter?`${e.inviter} invited you as ${d(e.role)}`:`Invited as ${d(e.role)}`}),e.expires_at&&(0,u.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground/70`,children:f(e.expires_at)})]}),(0,u.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,u.jsx)(o,{size:`md`,onClick:()=>p(e.id,`accept`),disabled:t!==null,"data-testid":`invitation-accept-${e.id}`,children:t===`${e.id}:accept`?`Joining…`:`Accept`}),(0,u.jsx)(o,{size:`md`,variant:`secondary`,onClick:()=>p(e.id,`decline`),disabled:t!==null,"data-testid":`invitation-decline-${e.id}`,children:t===`${e.id}:decline`?`Declining…`:`Decline`})]})]},e.id)})})})]})]})]})}export{p as default};