import{i as e,n as t,t as n}from"./jsx-runtime-bzQ4Vb5N.js";import{t as r}from"./link-HXBcj0tw.js";import{r as i}from"./index-t_-MMk0R.js";import{t as a}from"./page-header-CqpDR1d0.js";import{n as o,t as s}from"./card-2XLQ4Sqm.js";import{a as c,n as l,o as u,r as d,s as f,t as p}from"./table-CVkwN17b.js";import{t as m}from"./badge-7GJDNue6.js";import{t as h}from"./button-CpC4WAFQ.js";import{t as g}from"./createLucideIcon-DeQrcgrh.js";import{t as _}from"./arrow-left-DWsA1N-W.js";import{t as v}from"./eye-ktzBPylu.js";import{t as y}from"./upload-DsjEK5H6.js";import{n as b,t as x}from"./calculations-Djz1Ahac.js";import{n as S,t as C}from"./aen-hooks-BIg43l8E.js";var w=g(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),T=e(t()),E=n();function D(){let{division:e}=i.useParams(),t=e,n=x.includes(t),{data:g=[]}=S(n?t:void 0),{data:D=[]}=C(n?t:void 0),O=(0,T.useMemo)(()=>{let e=new Map;for(let t of D){if(!t.aen)continue;let n=e.get(t.aen)??[];n.push(t),e.set(t.aen,n)}return e},[D]);return n?(0,E.jsxs)(`div`,{className:`p-6 max-w-[1400px] mx-auto`,children:[(0,E.jsx)(a,{title:`${t} — AEN Upload Dashboard`,subtitle:`${g.length} AENs · click an AEN to upload, view or edit sheets`,right:(0,E.jsx)(h,{variant:`outline`,asChild:!0,children:(0,E.jsxs)(r,{to:`/upload`,children:[(0,E.jsx)(_,{className:`h-4 w-4 mr-2`}),`Back`]})})}),(0,E.jsx)(s,{children:(0,E.jsx)(o,{className:`p-0`,children:(0,E.jsxs)(p,{children:[(0,E.jsx)(u,{children:(0,E.jsxs)(f,{children:[(0,E.jsx)(c,{children:`AEN`}),(0,E.jsx)(c,{children:`Upload Status`}),(0,E.jsx)(c,{children:`Last Uploaded`}),(0,E.jsx)(c,{children:`Uploaded Month`}),(0,E.jsx)(c,{children:`Versions`}),(0,E.jsx)(c,{className:`text-right`,children:`Actions`})]})}),(0,E.jsxs)(l,{children:[g.map(e=>{let n=O.get(e.aen_code)??[],i=n[0],a=i?`${b[i.month-1].label} ${i.year}`:`—`,o=n.length;return(0,E.jsxs)(f,{children:[(0,E.jsx)(d,{className:`font-medium`,children:e.aen_code}),(0,E.jsx)(d,{children:i?(0,E.jsx)(m,{className:`bg-success text-success-foreground`,children:`Uploaded`}):(0,E.jsx)(m,{variant:`outline`,children:`Pending`})}),(0,E.jsx)(d,{className:`text-sm text-muted-foreground`,children:i?new Date(i.uploaded_at).toLocaleString():`—`}),(0,E.jsx)(d,{className:`text-sm`,children:a}),(0,E.jsx)(d,{className:`text-sm`,children:o||`—`}),(0,E.jsxs)(d,{className:`text-right space-x-1`,children:[(0,E.jsx)(h,{size:`sm`,asChild:!0,children:(0,E.jsxs)(r,{to:`/upload/$division/$aen`,params:{division:t,aen:e.aen_code},children:[(0,E.jsx)(y,{className:`h-3.5 w-3.5 mr-1`}),`Upload`]})}),i&&(0,E.jsx)(h,{size:`sm`,variant:`outline`,asChild:!0,children:(0,E.jsxs)(r,{to:`/upload/$division/$aen/$uploadId`,params:{division:t,aen:e.aen_code,uploadId:i.id},children:[(0,E.jsx)(v,{className:`h-3.5 w-3.5 mr-1`}),`View`]})}),o>1&&(0,E.jsx)(h,{size:`sm`,variant:`ghost`,asChild:!0,children:(0,E.jsxs)(r,{to:`/upload/$division/$aen`,params:{division:t,aen:e.aen_code},children:[(0,E.jsx)(w,{className:`h-3.5 w-3.5 mr-1`}),`History`]})})]})]},e.id)}),g.length===0&&(0,E.jsx)(f,{children:(0,E.jsxs)(d,{colSpan:6,className:`text-center text-sm text-muted-foreground py-8`,children:[`No AENs seeded for `,t,`.`]})})]})]})})})]}):(0,E.jsx)(`div`,{className:`p-6`,children:`Unknown division.`})}export{D as component};