import{t as e}from"./vendor-react-CAGJwf-T.js";import{t}from"./arrow-right-lxz0iUkq.js";import{t as n}from"./circle-x-BmjkkTIE.js";import{t as r}from"./clock-Dhn93nlC.js";import{t as i}from"./format-BVO_kFTb.js";import{Dt as a,Ot as o,S as s,at as c,vt as l}from"./index-Z_bdWDpJ.js";import{T as u}from"./workflowRtkApi-CinPa_NH.js";import{t as d}from"./Card-CBjYg7NQ.js";var f=e(),p=new Set([`STEP_TRANSITIONED`,`CREATED`,`STARTED`,`COMPLETED`]);function m(e){switch(e.toUpperCase()){case`STARTED`:case`STEP_TRANSITIONED`:return(0,f.jsx)(t,{className:`w-4 h-4 text-blue-500`});case`STEP_COMPLETED`:case`APPROVED`:case`COMPLETED`:return(0,f.jsx)(a,{className:`w-4 h-4 text-emerald-500`});case`REJECTED`:case`FAILED`:return(0,f.jsx)(n,{className:`w-4 h-4 text-red-500`});case`DELEGATED`:return(0,f.jsx)(c,{className:`w-4 h-4 text-orange-500`});case`ESCALATED`:return(0,f.jsx)(o,{className:`w-4 h-4 text-red-500`});case`CANCELLED`:return(0,f.jsx)(n,{className:`w-4 h-4 text-slate-500`});default:return(0,f.jsx)(r,{className:`w-4 h-4 text-[var(--color-text-muted)]`})}}function h(e){let t=e.actor_details;return t&&(t.full_name||[t.first_name,t.last_name].filter(Boolean).join(` `)||t.username||t.email)||null}function g({instanceId:e}){let{data:t,isLoading:n}=u(e);if(n)return(0,f.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-center`,children:[(0,f.jsx)(l,{className:`w-6 h-6 animate-spin text-[var(--color-text-muted)]`}),(0,f.jsx)(`p`,{className:`text-sm text-[var(--color-text-muted)] mt-2`,children:`Loading history…`})]});if(!t||t.length===0)return(0,f.jsx)(`p`,{className:`py-8 text-center text-sm text-[var(--color-text-muted)]`,children:`No history available`});let r=t.filter(e=>!p.has((e.action||``).toUpperCase()));return r.length===0?(0,f.jsx)(`p`,{className:`py-8 text-center text-sm text-[var(--color-text-muted)]`,children:`No approval actions yet`}):(0,f.jsx)(`div`,{className:`space-y-3`,children:r.map((e,t)=>{let n=e.timestamp||e.performed_at,r=h(e);return(0,f.jsx)(d,{padding:`sm`,children:(0,f.jsxs)(`div`,{className:`flex gap-3`,children:[(0,f.jsx)(`div`,{className:`flex-shrink-0 mt-0.5`,children:m(e.action)}),(0,f.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,f.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-1`,children:[(0,f.jsx)(s,{variant:`outline`,size:`sm`,children:(e.action||``).replace(/_/g,` `)}),(0,f.jsx)(`span`,{className:`text-xs text-[var(--color-text-muted)] flex-shrink-0`,children:n&&!isNaN(new Date(n).getTime())?i(new Date(n),`MMM d, h:mm a`):`—`})]}),r&&(0,f.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,f.jsx)(c,{className:`w-3 h-3 text-[var(--color-text-muted)]`}),(0,f.jsx)(`span`,{className:`text-sm text-[var(--color-text-secondary)]`,children:r})]}),e.comments&&!e.comments.startsWith(`Auto-transition`)&&!e.comments.startsWith(`Workflow completed`)&&(0,f.jsxs)(`div`,{className:`mt-1.5 text-sm text-[var(--color-text-secondary)] bg-slate-50 dark:bg-slate-800/40 p-2.5 rounded-lg`,children:[(0,f.jsx)(`p`,{className:`font-medium text-xs text-[var(--color-text-muted)] mb-0.5`,children:`Comments`}),(0,f.jsx)(`p`,{children:e.comments})]})]})]})},e.id||t)})})}export{g as t};