PageSourceSearch

https://closethegapinseniorcare.org/assets/BoardReportsPage-CoymvQUO.js

js closethegapinseniorcare.org collected 2026-10-08 05:36:34 UTC 62,361 bytes, 31 lines download raw bytes

1import{I as fe,u as We,b as te,c as Ee,r as v,m as Y,j as e,C as Me,w as Oe,F as Le,x as Ue,y as ze,B as w,d as Ze,f as L,n as A,q as B,h as G,bJ as be,E as et,o as $,bj as tt,bw as st,a1 as Ie}from"./index-DbHtWmcn.js";import{L as at}from"./Layout-0N5DPfFC.js";import{I as P}from"./input-BesI745p.js";import{T as He}from"./textarea-Btt46j-R.js";import{C as we}from"./checkbox--WfCPPIb.js";import{S as Ve,a as qe,b as Ge,c as Je,d as ue}from"./select-CacXA43e.js";import{D as se,b as ae,c as ne,d as ie,f as re,e as le}from"./dialog-CJAr76rq.js";import{T as Ne,d as De,a as nt,b as _e,c as H,e as V}from"./table-BYi60KW6.js";import{A as it,a as rt,b as lt,c as ot,d as ct,e as dt,f as mt,g as ut}from"./alert-dialog-CutoPhd9.js";import{T as xt,a as ht,b as ke}from"./tabs-BjEqBRS5.js";import{D as pt,a as gt,b as ft,e as bt,d as Se,c as U}from"./dropdown-menu-Jv2coS-f.js";import{P as Ce}from"./plus-Cmp8Rbiu.js";import{U as Te}from"./upload-CqrTrVx1.js";import{T as $e}from"./trash-2-Dqtw6YOV.js";import{P as xe}from"./paperclip-CXpDu06E.js";import{E as jt}from"./ellipsis-vertical-D6ZJ5Ecj.js";import{E as me}from"./external-link-DD5csDqZ.js";import{D as he}from"./download-BGDZiA1Q.js";import{P as vt}from"./pencil-Cwu7Oi7H.js";import{C as Ke}from"./circle-check-B7-iGcX8.js";import{R as Fe}from"./rotate-ccw-CZeNJVf8.js";import{S as Ae}from"./send-BxkI05hJ.js";import{H as Qe}from"./history-BybOW0yH.js";import{A as yt}from"./arrow-up-CtRKfAsr.js";import{A as wt}from"./arrow-down-BMqKSDgN.js";import{T as Nt}from"./triangle-alert-CcMOzBxg.js";import"./check-C-Eu5ZIk.js";import"./index-BdQq_4o_.js";import"./index-7YlhdsjK.js";import"./Combination-BJteQ9EU.js";import"./index-Co8PgbWr.js";import"./index-CUuqMYbs.js";import"./circle-DWT-A1-I.js";/**
2 * @license lucide-react v0.453.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Dt=fe("MailCheck",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/**
7 * @license lucide-react v0.453.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const kt=fe("MailOpen",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);/**
12 * @license lucide-react v0.453.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const St=fe("MailX",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h9",key:"1j9vog"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m17 17 4 4",key:"1b3523"}],["path",{d:"m21 17-4 4",key:"uinynz"}]]);/**
17 * @license lucide-react v0.453.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const Ct=fe("MousePointerClick",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]),W="Heather McAdoo, Executive Director",Re={executive_director:"Executive Director Report",annual:"Annual Report"},pe={executive_director:"bg-[#084E7F]/10 text-[#084E7F] border border-[#084E7F]/30",annual:"bg-[#B93E2C]/10 text-[#B93E2C] border border-[#B93E2C]/30"},ge={draft:{label:"Draft",className:"bg-white text-ctg-dark-gray border border-ctg-med-gray/40"},finalized:{label:"Finalized",className:"bg-ctg-blue/10 text-ctg-blue border border-ctg-blue/30"}};function Z(){return Math.random().toString(36).slice(2,10)}const $t=".pdf,.doc,.docx,.txt,.png,.jpg,.jpeg,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,text/plain,image/png,image/jpeg",Et=25*1024*1024;function Tt(s,m){const o=new Date(s,m+1,0),c=(o.getDay()-5+7)%7;return o.setDate(o.getDate()-c),o}function Ft(s){if(!s)return null;const m=s.trim();if(!m)return null;
21try{const o=new URL(m),c=o.pathname.split("/").filter(Boolean),u=c.indexOf("design");if(u>=0&&c[u+1]){const d=c[u+1],h=c[u+2],x=h&&h!=="view"&&h!=="edit"?`/${h}`:"";return`https://www.canva.com/design/${d}${x}/view?embed`}const f=o.search?"&":"?";return`${m}${f}embed`}catch{return null}}function At(s){return s.split(`
22`).map(m=>{const o=m.match(/^( *)([-*])\s+(.*)$/);if(!o)return m;const c=o[1],u=c.length>=2?"–":"•";return`${c}${u} ${o[3]}`}).join(`
23`)}const Rt=[{title:"Executive Summary",content:""},{title:"Program Updates",content:["- Grab The Bars","- Shifting Gears","- The Paceline","- Tech Caregivers"].join(`
24`)},{title:"Fundraising & Development",content:""},{title:"Marketing & Communications",content:""},{title:"Outreach",content:""},{title:"Board & Governance",content:""},{title:"Financial Overview",content:""},{title:"Strategic Priorities & Next Steps",content:""}],Pt=[{title:"Executive Summary",content:""},{title:"Year in Review",content:""},{title:"Programs",content:""},{title:"Financial Performance",content:""},{title:"Board & Governance",content:""},{title:"Strategic Outlook",content:""}];function Pe(s){return(s==="annual"?Pt:Rt).map(o=>({...o,id:Z()}))}function q(s,m,o){const c=Re[s]||"Report",u=m.trim();if(u)return`${c} — ${u}`;if(o){const f=new Date(o);if(!isNaN(f.getTime()))return`${c} — ${f.toLocaleDateString(void 0,{year:"numeric",month:"long"})}`}return c}function Xe(s){if(!s)return"—";const m=typeof s=="string"?new Date(s):s;return isNaN(m.getTime())?"—":m.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function ee(s){if(!s)return"";const m=typeof s=="string"?new Date(s):s;if(isNaN(m.getTime()))return"";const o=m.getFullYear(),c=String(m.getMonth()+1).padStart(2,"0"),u=String(m.getDate()).padStart(2,"0");return`${o}-${c}-${u}`}function Mt({text:s}){const m=s.split(`
25`);return e.jsx("div",{className:"mt-2 font-body text-[15px] text-ctg-dark-gray",children:m.map((o,c)=>{var x;if(o.trim()==="")return e.jsx("div",{className:"h-2","aria-hidden":!0},c);const u=o.match(/^([\s\t]*)([-*•–—])\s+(.*)$/);if(u){const p=u[1].replace(/\t/g,"    ").length,b=p===0?0:p<=3?1:Math.min(4,Math.floor(p/4)),i=b===0?"•":"–";return e.jsxs("div",{className:"flex items-start gap-2 leading-snug py-[2px]",style:{paddingLeft:`${b*1.75}rem`},children:[e.jsx("span",{className:"text-ctg-coral select-none w-3 flex-none text-center",children:i}),e.jsx("span",{className:"flex-1",children:u[3]})]},c)}const d=(((x=o.match(/^([\s\t]*)/))==null?void 0:x[1])??"").replace(/\t/g,"    ").length,h=d===0?0:d<=3?1:Math.min(4,Math.floor(d/4));return e.jsx("div",{className:"leading-snug py-[2px]",style:{paddingLeft:`${h*1.75}rem`},children:o.trimStart()},c)})})}function Be(s="executive_director"){return{title:"",titleAutoFill:!0,reportType:s,reportDate:ee(new Date),periodLabel:"",author:W,sections:Pe(s),canvaDesignUrl:"",baselineSections:{},existingSectionAttachments:[],clonedFromEmptyPrior:!1}}function Ot(s){const o=(s.sections||[]).map(c=>({id:(c==null?void 0:c.id)||Z(),title:(c==null?void 0:c.title)||"",content:(c==null?void 0:c.content)||""}));return{title:s.title,titleAutoFill:!1,reportType:s.reportType||"executive_director",reportDate:ee(s.reportDate),periodLabel:s.periodLabel||"",author:s.author||"",sections:o,canvaDesignUrl:s.canvaDesignUrl||"",baselineSections:{},existingSectionAttachments:s.sectionAttachments||[],clonedFromEmptyPrior:!1}}function Lt(s,m){const c=(s.sections||[]).map(j=>({id:Z(),title:(j==null?void 0:j.title)||"",content:(j==null?void 0:j.content)||""})),f=!c.some(j=>j.content.trim().length>0),d={};c.forEach(j=>{d[j.id]=j.content});const h=new Set(c.map(j=>j.title.trim().toLowerCase()));Pe(m).forEach(j=>{h.has(j.title.trim().toLowerCase())||c.push({id:Z(),title:j.title,content:""})});const p=s.reportDate?new Date(s.reportDate):new Date,b=isNaN(p.getTime())?new Date:p,i=Tt(b.getFullYear(),b.getMonth()+1);return{title:"",titleAutoFill:!0,reportType:m,reportDate:ee(i),periodLabel:"",author:s.author||W,sections:c,canvaDesignUrl:"",baselineSections:d,existingSectionAttachments:[],clonedFromEmptyPrior:f}}function Ut({sectionId:s,existing:m,pendingNew:o,pendingDeletions:c,onAddFiles:u,onRemovePendingNew:f,onMarkDelete:d,onUndoDelete:h}){const x=v.useRef(null),p=m.length>0||o.length>0;return e.jsxs("div",{className:"mt-3 rounded-md border border-dashed border-ctg-blue/30 bg-ctg-blue/[0.02] p-3","data-testid":`section-attachments-control-${s}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-ctg-blue",children:[e.jsx(xe,{className:"h-4 w-4"}),"Attachments",e.jsx("span",{className:"text-xs font-normal text-ctg-med-gray",children:"(PDF, DOC, image — up to 25MB each)"})]}),e.jsxs("div",{children:[e.jsx("input",{ref:x,type:"file",multiple:!0,accept:$t,className:"hidden","data-testid":`input-section-attachment-${s}
25`,onChange:b=>{const i=Array.from(b.target.files||[]);i.length!==0&&(u(i),b.target.value="")}}),e.jsxs(w,{type:"button",size:"sm",variant:"outline",onClick:()=>{var b;return(b=x.current)==null?void 0:b.click()},"data-testid":`button-section-attachment-choose-${s}`,children:[e.jsx(Te,{className:"h-3.5 w-3.5 mr-1"})," Choose files"]})]})]}),p?e.jsxs("ul",{className:"mt-2 space-y-1.5",children:[m.map(b=>{const i=c.has(b.id);return e.jsxs("li",{className:`flex items-center justify-between gap-2 rounded border border-ctg-med-gray/30 bg-white px-2 py-1.5 text-sm ${i?"opacity-60 line-through":""}`,"data-testid":`section-attachment-existing-${b.id}`,children:[e.jsx("span",{className:"truncate flex-1 text-ctg-dark-gray",children:b.name}),i?e.jsxs(w,{type:"button",size:"sm",variant:"ghost",className:"h-7 px-2 text-xs text-ctg-blue hover:bg-ctg-blue/10",onClick:()=>h(b.id),"data-testid":`button-section-attachment-undo-${b.id}`,children:[e.jsx(Fe,{className:"h-3 w-3 mr-1"})," Undo"]}):e.jsxs(w,{type:"button",size:"sm",variant:"ghost",className:"h-7 px-2 text-xs text-ctg-red hover:bg-ctg-red/10",onClick:()=>d(b.id),"data-testid":`button-section-attachment-delete-${b.id}`,children:[e.jsx(Ie,{className:"h-3 w-3 mr-1"})," Remove"]})]},`existing-${b.id}`)}),o.map((b,i)=>e.jsxs("li",{className:"flex items-center justify-between gap-2 rounded border border-ctg-blue/30 bg-ctg-blue/[0.04] px-2 py-1.5 text-sm","data-testid":`section-attachment-pending-${s}-${i}`,children:[e.jsxs("span",{className:"truncate flex-1 text-ctg-dark-gray",children:[b.name,e.jsx("span",{className:"ml-1 text-xs text-ctg-med-gray",children:"(pending upload)"})]}),e.jsxs(w,{type:"button",size:"sm",variant:"ghost",className:"h-7 px-2 text-xs text-ctg-red hover:bg-ctg-red/10",onClick:()=>f(i),"data-testid":`button-section-attachment-cancel-${s}-${i}`,children:[e.jsx(Ie,{className:"h-3 w-3 mr-1"})," Cancel"]})]},`pending-${i}`))]}):e.jsx("p",{className:"mt-2 text-xs text-ctg-med-gray italic",children:"No documents attached to this section."})]})}function zt({current:s,baseline:m}){const o=new Set(m.split(`
26`).map(u=>u.trim()).filter(u=>u.length>0)),c=s.split(`
27`);return e.jsxs("div",{className:"mt-2 rounded border border-ctg-med-gray/20 bg-ctg-light-gray/30 p-2 font-body text-[13px] leading-snug",children:[c.map((u,f)=>{if(u.trim()==="")return e.jsx("div",{className:"h-2","aria-hidden":!0},f);const d=o.has(u.trim());return e.jsx("div",{className:d?"text-ctg-med-gray":"text-[#084E7F] font-medium",children:u},f)}),c.every(u=>u.trim()==="")&&e.jsx("div",{className:"text-ctg-med-gray italic",children:"Empty — anything you type here will appear as new."})]})}function It(s){return{title:s.title.trim()||q(s.reportType,s.periodLabel,s.reportDate),reportType:s.reportType,reportDate:s.reportDate?new Date(s.reportDate+"T12:00:00").toISOString():new Date().toISOString(),periodLabel:s.periodLabel.trim()||null,author:s.author.trim()||null,sections:s.sections.map(o=>({id:o.id,title:o.title,content:o.content||""})),canvaDesignUrl:s.canvaDesignUrl.trim()||null}}function _t({open:s,onOpenChange:m,initial:o,mode:c,reportId:u}){const{toast:f}=te(),[d,h]=v.useState(o),[x,p]=v.useState({}),[b,i]=v.useState(new Set),j=`ctg-board-report-draft:${c==="create"?"new":`edit:${u}`}`,[k,N]=v.useState(null),M=v.useMemo(()=>o.titleAutoFill?{...o,title:q(o.reportType,o.periodLabel,o.reportDate)}:o,[o]),S=v.useMemo(()=>s&&JSON.stringify(d)!==JSON.stringify(M)&&JSON.stringify(d)!==JSON.stringify(o),[s,d,M,o]),E=a=>!!a&&typeof a.savedAt=="string"&&!!a.form&&typeof a.form.title=="string"&&typeof a.form.reportType=="string"&&Array.isArray(a.form.sections)&&a.form.sections.every(l=>l&&typeof l.id=="string"&&typeof l.title=="string");v.useEffect(()=>{if(s){h(o),p({}),i(new Set);try{const a=localStorage.getItem(j),l=a?JSON.parse(a):null;E(l)&&JSON.stringify(l.form)!==JSON.stringify(o)&&JSON.stringify(l.form)!==JSON.stringify(M)?N(l):(a&&localStorage.removeItem(j),N(null))}catch{try{localStorage.removeItem(j)}catch{}N(null)}}},[s,o,j]);const R=a=>{try{return localStorage.setItem(j,JSON.stringify({savedAt:new Date().toISOString(),form:a})),!0}catch{return!1}};v.useEffect(()=>{if(!s||!S)return;const a=setTimeout(()=>R(d),800);return()=>clearTimeout(a)},[s,S,d,j]),v.useEffect(()=>{if(!s||!S)return;const a=l=>{R(d),l.preventDefault(),l.returnValue=""};return window.addEventListener("beforeunload",a),()=>window.removeEventListener("beforeunload",a)},[s,S,d,j]);const T=()=>{try{localStorage.removeItem(j)}catch{}N(null)},C=a=>
27{if(!a&&S){const l=R(d);if(!window.confirm(l?`You have unsaved changes. Close anyway?
28
29Your work has been auto-saved in this browser and will be offered for restore next time you open this report.`:"You have unsaved changes that could NOT be auto-saved in this browser. Closing now will lose them. Close anyway?"))return}m(a)};v.useEffect(()=>{h(a=>{if(!a.titleAutoFill)return a;const l=q(a.reportType,a.periodLabel,a.reportDate);return l===a.title?a:{...a,title:l}})},[d.reportType,d.periodLabel,d.reportDate,d.titleAutoFill]);const[n,D]=v.useState(new Set),O=a=>{const l=(a||"").trim().toLowerCase();return l==="executive summary"?"executive_summary":l==="strategic priorities & next steps"||l==="strategic outlook"?"strategic_priorities":null},oe={executive_summary:"Generate a board-ready summary paragraph from the other sections. You can edit everything afterward.",strategic_priorities:"Generate recommended to-dos based on the other sections. You can edit everything afterward."},z=async(a,l)=>{D(r=>{const t=new Set(r);return t.add(a),t});try{const r=await A("POST","/api/board-reports/suggest-section-content",{target:l,reportType:d.reportType,periodLabel:d.periodLabel,sections:d.sections.map(g=>({title:g.title,content:g.content}))}),{suggestion:t}=await r.json();h(g=>({...g,sections:g.sections.map(y=>{if(y.id!==a)return y;const F=(y.content||"").trimEnd(),ye=F?`${F}
30
31${t}`:t;return{...y,content:ye}})})),f({title:"Suggestion added",description:"Review and edit the AI-generated content below."})}catch(r){f({title:"Could not generate suggestions",description:(r==null?void 0:r.message)||"Please try again.",variant:"destructive"})}finally{D(r=>{const t=new Set(r);return t.delete(a),t})}},I=async a=>{const l=[];for(const r of Array.from(b))try{await A("DELETE",`/api/board-reports/${a}/attachments/${r}`)}catch(t){l.push(`Delete attachment #${r}: ${(t==null?void 0:t.message)||"failed"}`)}for(const[r,t]of Object.entries(x))for(const g of t)try{const y=new FormData;y.append("file",g);const F=await fetch(`/api/board-reports/${a}/sections/${r}/attachments`,{method:"POST",credentials:"include",body:y});if(!F.ok){const ye=await F.text().catch(()=>"")||`Upload failed (${F.status})`;l.push(`${g.name}: ${ye}`)}}catch(y){l.push(`${g.name}: ${(y==null?void 0:y.message)||"upload failed"}`)}if(l.length>0)throw new Error(l.join("; "))},J=Y({mutationFn:async a=>{const r=await(await A("POST","/api/board-reports",a.payload)).json();try{await I(r.id)}catch(y){f({title:"Report saved, but one or more attachments did not sync",description:(y==null?void 0:y.message)||"Re-open the report and try the uploads again.",variant:"destructive"})}let t=r;return a.finalize&&(t=await(await A("POST",`/api/board-reports/${r.id}/finalize`)).json()),await(await A("GET",`/api/board-reports/${r.id}`)).json()||t},onSuccess:a=>{B.setQueryData(["/api/board-reports"],l=>[a,...(l||[]).filter(t=>t.id!==a.id)]),B.invalidateQueries({queryKey:["/api/board-reports"]}),T(),f({title:"Report saved",description:"Your report has been saved."}),m(!1)},onError:a=>f({title:"Save failed — your report was NOT saved",description:`${a.message}. Your work is still in this window (and auto-saved in this browser) — please try saving again.`,variant:"destructive"})}),K=Y({mutationFn:async a=>{if(!u)throw new Error("Missing report id");let r=await(await A("PATCH",`/api/board-reports/${u}`,a.payload)).json();try{await I(u)}catch(g){f({title:"Report saved, but one or more attachments did not sync",description:(g==null?void 0:g.message)||"Try the uploads again.",variant:"destructive"})}return a.finalize&&r.status==="draft"&&await A("POST",`/api/board-reports/${u}/finalize`),await(await A("GET",`/api/board-reports/${u}`)).json()||r},onSuccess:a=>{B.setQueryData(["/api/board-reports"],l=>{const r=l||[],t=r.findIndex(y=>y.id===a.id);if(t===-1)return[a,...r];const g=r.slice();return g[t]=a,g}),B.invalidateQueries({queryKey:["/api/board-reports"]}),T(),f({title:"Report updated",description:"Your changes have been saved."}),m(!1)},onError:a=>f({title:"Save failed — your changes were NOT saved",description:`${a.message}. Your work is still in this window (and auto-saved in this browser) — please try saving again.`,variant:"destructive"})}),_=J.isPending||K.isPending,Q=a=>{const l=It(d);c==="create"?J.mutate({payload:l,finalize:a}):K.mutate({payload:l,finalize:a})},X=(a,l)=>{h(r=>({...r,sections:r.sections.map(t=>
31t.id===a?{...t,...l}:t)}))},je=()=>{h(a=>({...a,sections:[...a.sections,{id:Z(),title:"New Section",content:""}]}))},ve=a=>{h(l=>({...l,sections:l.sections.filter(r=>r.id!==a)})),i(l=>{const r=new Set(l);for(const t of d.existingSectionAttachments)t.sectionId===a&&r.add(t.id);return r}),p(l=>{if(!(a in l))return l;const r={...l};return delete r[a],r})},ce=(a,l)=>{h(r=>{const t=r.sections.findIndex(F=>F.id===a);if(t<0)return r;const g=t+l;if(g<0||g>=r.sections.length)return r;const y=[...r.sections];return[y[t],y[g]]=[y[g],y[t]],{...r,sections:y}})},de=()=>{h(a=>({...a,sections:Pe(a.reportType),baselineSections:{}}))};return e.jsx(se,{open:s,onOpenChange:C,children:e.jsxs(ae,{className:"max-w-3xl max-h-[90vh] overflow-y-auto","data-testid":"dialog-report-composer",children:[e.jsxs(ne,{children:[e.jsx(ie,{className:"text-ctg-blue font-montserrat",children:c==="create"?"New Board Report":"Edit Board Report"}),e.jsxs(re,{children:["Compose a section-based report. Use ",e.jsx("code",{className:"px-1 rounded bg-ctg-light-gray/60",children:"- "})," at the start of a line for bullet points (indent with spaces for nested items). Your work auto-saves in this browser as you type."]})]}),k&&e.jsxs("div",{className:"rounded-md border border-ctg-amber/50 bg-ctg-amber/[0.08] p-3 text-sm text-ctg-dark-gray","data-testid":"banner-recovered-draft",children:[e.jsx("div",{className:"font-semibold text-ctg-amber mb-0.5",children:"Unsaved work found"}),"We found an auto-saved draft from"," ",new Date(k.savedAt).toLocaleString()," that was never saved to the server. Would you like to restore it?",e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(w,{type:"button",size:"sm",className:"bg-[#084E7F] hover:bg-[#084E7F]/90 text-white",onClick:()=>{h(k.form),N(null)},"data-testid":"button-restore-draft",children:"Restore draft"}),e.jsx(w,{type:"button",size:"sm",variant:"outline",onClick:T,"data-testid":"button-discard-draft",children:"Discard"})]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx($,{htmlFor:"report-type",children:"Type"}),e.jsxs(Ve,{value:d.reportType,onValueChange:a=>h(l=>({...l,reportType:a,baselineSections:{}})),children:[e.jsx(qe,{id:"report-type","data-testid":"select-report-type",children:e.jsx(Ge,{})}),e.jsxs(Je,{children:[e.jsx(ue,{value:"executive_director",children:"Executive Director Report"}),e.jsx(ue,{value:"annual",children:"Annual Report"})]})]})]}),e.jsxs("div",{children:[e.jsx($,{htmlFor:"report-date",children:"Report Date"}),e.jsx(P,{id:"report-date",type:"date",value:d.reportDate,onChange:a=>h(l=>({...l,reportDate:a.target.value})),"data-testid":"input-report-date"})]}),e.jsxs("div",{children:[e.jsx($,{htmlFor:"report-period",children:"Period (e.g. May 2026, Q2 2026, FY 2025)"}),e.jsx(P,{id:"report-period",value:d.periodLabel,onChange:a=>h(l=>({...l,periodLabel:a.target.value})),placeholder:"May 2026","data-testid":"input-report-period"})]}),e.jsxs("div",{children:[e.jsx($,{htmlFor:"report-author",children:"Author"}),e.jsx(P,{id:"report-author",value:d.author,onChange:a=>h(l=>({...l,author:a.target.value})),placeholder:W,"data-testid":"input-report-author"})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx($,{htmlFor:"report-title",children:"Title"}),e.jsx(P,{id:"report-title",value:d.title,onChange:a=>h(l=>({...l,title:a.target.value,titleAutoFill:!1})),placeholder:q(d.reportType,d.periodLabel,d.reportDate),"data-testid":"input-report-title"}),d.titleAutoFill&&e.jsx("p",{className:"text-xs text-ctg-med-gray mt-1",children:"Auto-generated from type and period — type to override."})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsxs($,{htmlFor:"report-canva",className:"flex items-center gap-2",children:[e.jsx(be,{className:"h-3.5 w-3.5 text-[#084E7F]"}),"Canva design link ",e.jsx("span",{className:"text-ctg-med-gray font-normal",children:"(optional)"})]}),e.jsx(P,{id:"report-canva",type:"url",value:d.canvaDesignUrl,onChange:a=>h(l=>({...l,canvaDesignUrl:a.target.value})),placeholder:"https://www.canva.com/design/DAFxxxxxxxx/view","data-testid":"input-report-canva-url"}),e.jsxs("p",{className:"text-xs text-ctg-med-gray mt-1",children:["In Canva: ",e.jsx("strong",{children:"Share → Public link to view"}),", then copy the link here. The board will see the design embedded in the report and can click through to view it in Canva."]})]})]}),e.jsxs("div",{className:"border-t border-ctg-med-gray/30 pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"font-montserrat text-ctg-blue text-sm font-semibold",children:"Sections"}),c==="create"&&Object.keys(d.baselineSections).length>0&&e.jsxs("div",{className:"flex items-center gap-3 text-xs text-ctg-med-gray mr-auto ml-4",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-sm bg-ctg-med-gray/60"}),"Carried over"]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-sm bg-[#084E7F]"}),"New / changed"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{type:"button",size:"sm",variant:"outline",onClick:de,"data-testid":"button-reset-template",children:[e.jsx(Fe,{className:"h-3.5 w-3.5 mr-1"})," Reset to template"]}),e.jsxs(w,{type:"button",size:"sm",variant:"outline",onClick:je,"data-testid":"button-add-section",children:[e.jsx(Ce,{className:"h-3.5 w-3.5 mr-1"})," Add Section"]})]})]}),c==="create"&&d.clonedFromEmptyPrior&&e.jsxs("div",{className:"rounded-md border border-ctg-amber/50 bg-ctg-amber/[0.08] p-3 text-sm text-ctg-dark-gray","data-testid":"banner-cloned-from-empty-prior",children:[e.jsx("div",{className:"font-semibold text-ctg-amber mb-0.5",children:"Nothing to carry over from the previous report"}),"The previous Executive Director report was added as an upload (no in-app sections), so there's no section content to clone. The date and section outline have been pre-filled from the template — just write this month's content in each section.",e.jsx("div",{className:"mt-1 text-xs text-ctg-med-gray",children:"Tip: if you'd like the next month's report to auto-clone, fill out the previous report's sections in the composer (Edit → paste in content)."})]}),e.jsxs("div",{className:"space-y-3",children:[d.sections.map((a,l)=>e.jsxs("div",{className:"rounded-md border border-ctg-med-gray/30 bg-white p-3","data-testid":`section-editor-${a.id}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(P,{value:a.title,onChange:r=>X(a.id,{title:r.target.value}),placeholder:"Section title",className:"flex-1 font-montserrat font-semibold text-ctg-blue","data-testid":`input-section-title-${a.id}`}),e.jsx(w,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>ce(a.id,-1),disabled:l===0,title:"Move up","data-testid":`button-section-up-${a.id}`,children:e.jsx(yt,{className:"h-4 w-4"})}),e.jsx(w,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>ce(a.id,1),disabled:l===d.sections.length-1,title:"Move down","data-testid":`button-section-down-${a.id}`,children:e.jsx(wt,{className:"h-4 w-4"})}),e.jsx(w,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8 text-ctg-red hover:bg-ctg-red/10",onClick:()=>ve(a.id),title:"Remove","data-testid":`button-section-remove-${a.id}`,children:e.jsx($e,{className:"h-4 w-4"})})]}),(()=>{const r=O(a.title);if(!r)return null;const t=n.has(a.id);return e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 rounded-md border border-dashed border-ctg-blue/40 bg-ctg-blue/[0.04] px-3 py-2",children:[e.jsxs("div",{className:"text-xs text-ctg-dark-gray",children:[e.jsx("span",{className:"font-medium text-ctg-blue",children:"AI suggestions:"})," ",oe[r]]}),e.jsxs(w,{type:"button",size:"sm",variant:"outline",className:"flex-none",disabled:t,onClick:()=>z(a.id,r),"data-testid":`button-ai-suggest-${r}-${a.id}`,children:[t?e.jsx(L,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):e.jsx(tt,{className:"h-3.5 w-3.5 mr-1"}),"Suggest with AI"]})]})})(),e.jsx(He,{value:a.content,onChange:r=>
31X(a.id,{content:At(r.target.value)}),rows:5,placeholder:"Write the section here. Start a line with '- ' for a bullet.","data-testid":`textarea-section-content-${a.id}`}),c==="create"&&Object.keys(d.baselineSections).length>0&&(a.id in d.baselineSections?e.jsx(zt,{current:a.content,baseline:d.baselineSections[a.id]||""}):e.jsx("div",{className:"mt-2 rounded border border-[#084E7F]/30 bg-[#084E7F]/5 px-2 py-1 text-xs text-[#084E7F]","data-testid":`badge-section-new-${a.id}`,children:"New section — wasn't in the previous report."})),e.jsx(Ut,{sectionId:a.id,existing:d.existingSectionAttachments.filter(r=>r.sectionId===a.id),pendingNew:x[a.id]||[],pendingDeletions:b,onAddFiles:r=>{const t=[];for(const g of r){if(g.size>Et){f({title:`${g.name} is too large`,description:"Maximum file size is 25MB.",variant:"destructive"});continue}t.push(g)}t.length!==0&&p(g=>({...g,[a.id]:[...g[a.id]||[],...t]}))},onRemovePendingNew:r=>{p(t=>{const g=(t[a.id]||[]).slice();g.splice(r,1);const y={...t};return g.length===0?delete y[a.id]:y[a.id]=g,y})},onMarkDelete:r=>{i(t=>{const g=new Set(t);return g.add(r),g})},onUndoDelete:r=>{i(t=>{const g=new Set(t);return g.delete(r),g})}})]},a.id)),d.sections.length===0&&e.jsxs("p",{className:"text-sm text-ctg-med-gray italic",children:["No sections yet — click ",e.jsx("em",{children:"Add Section"})," or ",e.jsx("em",{children:"Reset to template"}),"."]})]})]})]}),e.jsxs(le,{className:"gap-2",children:[e.jsx(w,{variant:"outline",onClick:()=>C(!1),disabled:_,"data-testid":"button-composer-cancel",children:"Cancel"}),e.jsxs(w,{variant:"outline",onClick:()=>Q(!1),disabled:_,"data-testid":"button-composer-save-draft",children:[_?e.jsx(L,{className:"h-4 w-4 mr-1 animate-spin"}):null,"Save as Draft"]}),e.jsxs(w,{className:"bg-[#084E7F] hover:bg-[#084E7F]/90 text-white",onClick:()=>Q(!0),disabled:_,"data-testid":"button-composer-finalize",children:[_?e.jsx(L,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Ke,{className:"h-4 w-4 mr-1"}),"Save & Finalize"]})]})]})})}function Bt({open:s,onOpenChange:m}){const{toast:o}=te(),[c,u]=v.useState(null),[f,d]=v.useState("annual"),[h,x]=v.useState(ee(new Date)),[p,b]=v.useState(""),[i,j]=v.useState(W),[k,N]=v.useState(""),[M,S]=v.useState(!0),[E,R]=v.useState(""),T=v.useRef(null);v.useEffect(()=>{s&&(u(null),d("annual"),x(ee(new Date)),b(""),j(W),N(""),S(!0),R(""))},[s]),v.useEffect(()=>{if(!M)return;const n=q(f,p,h);N(D=>D===n?D:n)},[f,p,h,M]);const C=Y({mutationFn:async()=>{if(!c)throw new Error("Please choose a file to upload.");const n=new FormData;n.append("file",c),n.append("title",k.trim()||q(f,p,h)),n.append("reportType",f),n.append("reportDate",h?new Date(h+"T12:00:00").toISOString():new Date().toISOString()),p.trim()&&n.append("periodLabel",p.trim()),i.trim()&&n.append("author",i.trim()),E.trim()&&n.append("canvaDesignUrl",E.trim());const D=await fetch("/api/board-reports/upload",{method:"POST",body:n,credentials:"include"});if(!D.ok){const O=await D.text().catch(()=>"Upload failed");throw new Error(O||"Upload failed")}return D.json()},onSuccess:()=>{B.invalidateQueries({queryKey:["/api/board-reports"]}),o({title:"Report uploaded",description:"The report has been added to the library."}),m(!1)},onError:n=>o({title:"Upload failed",description:n.message,variant:"destructive"})});return e.jsx(se,{open:s,onOpenChange:m,children:e.jsxs(ae,{className:"max-w-xl","data-testid":"dialog-report-upload",children:[e.jsxs(ne,{children:[e.jsx(ie,{className:"text-ctg-blue font-montserrat",children:"Upload Past Report"}),e.jsx(re,{children:"Add an existing PDF, DOC, or DOCX (annual reports, archived ED reports) to the library."})]}),e.jsxs("div",{className:"space-y-3 py-2",children:[e.jsxs("div",{children:[e.jsx($,{htmlFor:"upload-file",children:"File (PDF, DOC, DOCX, TXT, PNG, JPG — max 25 MB)"}),e.jsx(P,{ref:T,id:"upload-file",type:"file",accept:".pdf,.doc,.docx,.txt,.png,.jpg,.jpeg,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,text/plain,image/png,image/jpeg",onChange:n=>{var D;return u(((D=n.target.files)==null?void 0:D[0])??null)},"data-testid":"input-upload-file"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx($,{htmlFor:"upload-type",children:"Type"}),e.jsxs(Ve,{value:f,onValueChange:n=>d(n),children:[e.jsx(qe,{id:"upload-type","data-testid":"select-upload-type",children:e.jsx(Ge,{})}),e.jsxs(Je,{children:[e.jsx(ue,{value:"executive_director",children:"Executive Director Report"}),e.jsx(ue,{value:"annual",children:"Annual Report"})]})]})]}),e.jsxs("div",{children:[e.jsx($,{htmlFor:"upload-date",children:"Report Date"}),e.jsx(P,{id:"upload-date",type:"date",value:h,onChange:n=>x(n.target.value),"data-testid":"input-upload-date"})]}),e.jsxs("div",{children:[e.jsx($,{htmlFor:"upload-period",children:"Period"}),e.jsx(P,{id:"upload-period",value:p,onChange:n=>b(n.target.value),placeholder:"FY 2025","data-testid":"input-upload-period"})]}),e.jsxs("div",{children:[e.jsx($,{htmlFor:"upload-author",children:"Author"}),e.jsx(P,{id:"upload-author",value:i,onChange:n=>j(n.target.value),"data-testid":"input-upload-author"})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx($,{htmlFor:"upload-title",children:"Title"}),e.jsx(P,{id:"upload-title",value:k,onChange:n=>{N(n.target.value),S(!1)},placeholder:q(f,p,h),"data-testid":"input-upload-title"})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsxs($,{htmlFor:"upload-canva",className:"flex items-center gap-2",children:[e.jsx(be,{className:"h-3.5 w-3.5 text-[#084E7F]"}),"Canva design link ",e.jsx("span",{className:"text-ctg-med-gray font-normal",children:"(optional)"})]}),e.jsx(P,{id:"upload-canva",type:"url",value:E,onChange:n=>R(n.target.value),placeholder:"https://www.canva.com/design/DAFxxxxxxxx/view","data-testid":"input-upload-canva-url"}),e.jsx("p",{className:"text-xs text-ctg-med-gray mt-1",children:"Optional — paste the public Canva share link if this report was designed in Canva."})]})]})]}),e.jsxs(le,{children:[e.jsx(w,{variant:"outline",onClick:()=>m(!1),disabled:C.isPending,"data-testid":"button-upload-cancel",children:"Cancel"}),e.jsxs(w,{className:"bg-[#084E7F] hover:bg-[#084E7F]/90 text-white",onClick:()=>C.mutate(),disabled:C.isPending||!c,"data-testid":"button-upload-submit",children:[C.isPending?e.jsx(L,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Te,{className:"h-4 w-4 mr-1"}),"Upload"]})]})]})})}function Yt({report:s,open:m,onOpenChange:o}){if(!s)return null;const c=s.sections||[],u=pe[s.reportType]||pe.executive_director,f=ge[s.status]||ge.draft,d=new Map;for(const x of s.sectionAttachments||[]){const p=d.get(x.sectionId)||[];p.push(x),d.set(x.sectionId,p)}const h=x=>{const p=`/api/board-reports/${s.id}/attachments/${x.id}?inline=1`,b=`/api/board-reports/${s.id}/attachments/${x.id}`,i=(x.mime||"").startsWith("image/"),j=(x.mime||"")==="application/pdf";return e.jsxs("div",{className:"rounded-md border border-ctg-blue/20 bg-white p-2","data-testid":`view-attachment-${x.id}`,children:[i?e.jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer","data-testid":`link-view-attachment-image-${x.id}`,children:e.jsx("img",{src:p,alt:x.name,className:"max-h-64 roun
31ded-md object-contain mx-auto"})}):null,e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(xe,{className:"h-3.5 w-3.5 text-ctg-blue flex-none"}),e.jsx("span",{className:"text-sm text-ctg-dark-gray truncate","data-testid":`text-view-attachment-name-${x.id}`,children:x.name})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-none",children:[(i||j)&&e.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-sm font-medium text-ctg-blue hover:underline","data-testid":`link-view-attachment-open-${x.id}`,children:[e.jsx(me,{className:"h-3.5 w-3.5 mr-1"})," View"]}),e.jsxs("a",{href:b,className:"inline-flex items-center text-sm font-medium text-ctg-blue hover:underline","data-testid":`link-view-attachment-download-${x.id}`,children:[e.jsx(he,{className:"h-3.5 w-3.5 mr-1"})," Download"]})]})]})]},x.id)};return e.jsx(se,{open:m,onOpenChange:o,children:e.jsxs(ae,{className:"max-w-3xl max-h-[90vh] overflow-y-auto","data-testid":`dialog-view-report-${s.id}`,children:[e.jsx(ne,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(ie,{className:"text-ctg-blue font-montserrat text-xl","data-testid":`text-view-title-${s.id}`,children:s.title}),e.jsx(re,{className:"mt-1",children:e.jsxs("span",{className:"text-ctg-dark-gray",children:[Xe(s.reportDate),s.periodLabel?` · ${s.periodLabel}`:"",s.author?` · ${s.author}`:""]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{className:u,"data-testid":`badge-view-type-${s.id}`,children:Re[s.reportType]||s.reportType}),e.jsx(G,{className:f.className,"data-testid":`badge-view-status-${s.id}`,children:f.label})]})]})}),e.jsxs("div",{className:"space-y-5 py-2",children:[s.canvaDesignUrl&&(()=>{const x=Ft(s.canvaDesignUrl);return e.jsxs("div",{className:"rounded-md border border-ctg-blue/30 bg-ctg-blue/[0.04] overflow-hidden","data-testid":`canva-embed-${s.id}`,children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-ctg-blue/20",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-ctg-blue",children:[e.jsx(be,{className:"h-4 w-4"}),"Designed in Canva"]}),e.jsxs("a",{href:s.canvaDesignUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-sm font-medium text-ctg-blue hover:underline","data-testid":`link-canva-open-${s.id}`,children:["Open in Canva ",e.jsx(me,{className:"h-3.5 w-3.5 ml-1"})]})]}),x?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"relative w-full bg-white",style:{paddingTop:"75%"},children:e.jsx("iframe",{src:x,title:`Canva design — ${s.title}`,loading:"lazy",allow:"fullscreen",allowFullScreen:!0,className:"absolute inset-0 w-full h-full border-0","data-testid":`iframe-canva-${s.id}`})}),e.jsxs("p",{className:"text-xs text-ctg-med-gray px-3 py-2 border-t border-ctg-blue/20 bg-white",children:['Preview blank or showing "content blocked"? Make sure the design is set to ',e.jsx("strong",{children:"Share → Public link to view"}),' in Canva, then use the "Open in Canva" link above.']})]}):e.jsx("p",{className:"text-sm text-ctg-med-gray italic px-3 py-4",children:'Canva preview unavailable — use the "Open in Canva" link above.'})]})})(),s.attachmentUrl&&e.jsxs("div",{className:"flex items-center justify-between rounded-md border border-ctg-blue/30 bg-ctg-blue/[0.04] p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(xe,{className:"h-4 w-4 text-ctg-blue flex-none"}),e.jsx("span",{className:"text-sm text-ctg-dark-gray truncate","data-testid":`text-attachment-name-${s.id}`,children:s.attachmentName||"Attached document"})]}),e.jsxs("a",{href:`/api/board-reports/${s.id}/attachment`,className:"inline-flex items-center text-sm font-medium text-ctg-blue hover:underline","data-testid":`link-download-attachment-${s.id}`,children:[e.jsx(he,{className:"h-4 w-4 mr-1"})," Download"]})]}),c.length===0&&!s.attachmentUrl&&!s.canvaDesignUrl&&e.jsx("p",{className:"text-sm text-ctg-med-gray italic",children:"This report has no content yet."}),c.map(x=>{var b;const p=d.get(x.id)||[];return e.jsxs("section",{"data-testid":`section-view-${x.id}`,children:[e.jsx("h3",{className:"font-montserrat font-semibold text-ctg-blue text-base",children:x.title}),(b=x.content)!=null&&b.trim()?e.jsx(Mt,{text:x.content}):p.length===0?e.jsx("p",{className:"mt-1 text-sm text-ctg-med-gray italic",children:"— empty —"}):null,p.length>0&&e.jsx("div",{className:"mt-3 space-y-2","data-testid":`view-section-attachments-${x.id}`,children:p.map(h)})]},x.id)})]}),e.jsxs(le,{className:"gap-2",children:[e.jsxs("a",{href:`/admin/board/reports/${s.id}/preview`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center rounded-md bg-[#084E7F] hover:bg-[#084E7F]/90 text-white text-sm font-medium px-4 py-2","data-testid":`button-view-fullpreview-${s.id}`,children:[e.jsx(me,{className:"h-4 w-4 mr-1"})," Open full preview"]}),e.jsx(w,{variant:"outline",onClick:()=>o(!1),"data-testid":`button-view-close-${s.id}`,children:"Close"})]})]})})}function Ye(s){if(!s)return"—";const m=new Date(s);
31return Number.isNaN(m.getTime())?"—":m.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function Ht(s){return s.status==="bounced"?{label:"Bounced",icon:St,className:"bg-ctg-red/10 text-ctg-red border-ctg-red/30"}:s.status==="failed"?{label:"Failed",icon:Nt,className:"bg-ctg-red/10 text-ctg-red border-ctg-red/30"}:s.status==="clicked"?{label:"Clicked",icon:Ct,className:"bg-emerald-100 text-emerald-700 border-emerald-300"}:s.status==="opened"||s.opens>0?{label:"Opened",icon:kt,className:"bg-emerald-100 text-emerald-700 border-emerald-300"}:s.status==="delivered"||s.deliveredAt?{label:"Delivered",icon:Dt,className:"bg-ctg-blue/10 text-ctg-blue border-ctg-blue/30"}:s.status==="sent"?{label:"Sent",icon:Ae,className:"bg-ctg-blue/10 text-ctg-blue border-ctg-blue/30"}:{label:"Queued",icon:L,className:"bg-ctg-light-gray text-ctg-dark-gray border-ctg-med-gray/40"}}function Vt({report:s,open:m,onClose:o}){const{toast:c}=te(),u=s==null?void 0:s.id,{data:f,isLoading:d,refetch:h}=Ee({queryKey:["/api/board-reports",u,"sends"],enabled:!!u&&m,refetchInterval:m?3e4:!1}),x=Y({mutationFn:async i=>(await A("POST",`/api/board-reports/${i}/sends/refresh`)).json(),onSuccess:i=>{c({title:i.refreshed>0?`Updated ${i.refreshed} of ${i.total??i.refreshed} send${(i.total??i.refreshed)===1?"":"s"}`:i.message||"No new updates from Mailgun."}),h()},onError:i=>c({title:"Could not refresh status",description:i.message,variant:"destructive"})}),p=(f==null?void 0:f.sends)||[],b=v.useMemo(()=>{const i=p.length,j=p.filter(N=>N.opens>0).length,k=p.filter(N=>N.status==="bounced"||N.status==="failed").length;return{total:i,opened:j,bounced:k}},[p]);return e.jsx(se,{open:m,onOpenChange:i=>{i||o()},children:e.jsxs(ae,{className:"max-w-3xl","data-testid":"dialog-send-history",children:[e.jsxs(ne,{children:[e.jsxs(ie,{className:"flex items-center gap-2",children:[e.jsx(Qe,{className:"h-5 w-5 text-ctg-blue"}),"Send history"]}),e.jsx(re,{children:s?e.jsxs(e.Fragment,{children:["Delivery status for ",e.jsx("strong",{children:s.title}),". Open and click data is best-effort and depends on each recipient's email client."]}):null})]}),d?e.jsxs("div",{className:"flex items-center justify-center py-12 text-ctg-dark-gray",children:[e.jsx(L,{className:"h-4 w-4 mr-2 animate-spin"})," Loading send history…"]}):p.length===0?e.jsx("div",{className:"py-10 text-center text-sm text-ctg-dark-gray","data-testid":"text-no-sends",children:"This report hasn't been sent yet."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{className:"rounded-md border bg-ctg-blue/5 px-3 py-2","data-testid":"stat-sends-total",children:[e.jsx("div",{className:"text-2xl font-semibold text-ctg-blue",children:b.total}),e.jsx("div",{className:"text-xs text-ctg-dark-gray uppercase tracking-wide",children:"Sent"})]}),e.jsxs("div",{className:"rounded-md border bg-emerald-50 px-3 py-2","data-testid":"stat-sends-opened",children:[e.jsx("div",{className:"text-2xl font-semibold text-emerald-700",children:b.opened}),e.jsx("div",{className:"text-xs text-ctg-dark-gray uppercase tracking-wide",children:"Opened"})]}),e.jsxs("div",{className:"rounded-md border bg-ctg-red/5 px-3 py-2","data-testid":"stat-sends-bounced",children:[e.jsx("div",{className:"text-2xl font-semibold text-ctg-red",children:b.bounced}),e.jsx("div",{className:"text-xs text-ctg-dark-gray uppercase tracking-wide",children:"Bounced / Failed"})]})]}),e.jsx("div",{className:"border rounded-md max-h-[420px] overflow-y-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-ctg-light-gray/40 sticky top-0",children:e.jsxs("tr",{className:"text-left text-xs uppercase tracking-wide text-ctg-dark-gray",children:[e.jsx("th",{className:"px-3 py-2 font-medium",children:"Recipient"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Status"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Sent"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Opened"})]})}),e.jsx("tbody",{className:"divide-y",children:p.map(i=>{const j=Ht(i),k=j.icon;return e.jsxs("tr",{"data-testid":`row-send-${i.id}`,children:[e.jsxs("td",{className:"px-3 py-2 align-top",children:[e.jsx("div",{className:"font-medium text-ctg-blue",children:i.recipientName||i.recipientEmail}),e.jsx("div",{className:"text-xs text-ctg-dark-gray font-mono",children:i.recipientEmail}),i.bounceReason?e.jsx("div",{className:"text-xs text-ctg-red mt-1","data-testid":`text-bounce-reason-${i.id}`,children:i.bounceReason}):null,i.errorMessage&&i.status==="failed"?e.jsx("div",{className:"text-xs text-ctg-red mt-1",children:i.errorMessage}):null]}),e.jsxs("td",{className:"px-3 py-2 align-top",children:[e.jsxs(G,{variant:"outline",className:`${j.className} gap-1`,"data-testid":`badge-status-${i.id}`,children:[e.jsx(k,{className:"h-3 w-3"}),j.label]}),i.clicks>0?e.jsxs("div",{className:"text-xs text-ctg-dark-gray mt-1",children:[i.clicks," 
31click",i.clicks===1?"":"s"]}):null]}),e.jsx("td",{className:"px-3 py-2 align-top text-ctg-dark-gray text-xs",children:Ye(i.sentAt)}),e.jsx("td",{className:"px-3 py-2 align-top text-xs",children:i.opens>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-emerald-700 font-medium","data-testid":`text-last-opened-${i.id}`,children:Ye(i.lastOpenedAt)}),e.jsxs("div",{className:"text-ctg-dark-gray",children:[i.opens," open",i.opens===1?"":"s"]})]}):e.jsx("span",{className:"text-ctg-dark-gray",children:"—"})})]},i.id)})})]})})]}),e.jsxs(le,{className:"flex sm:justify-between items-center",children:[e.jsx("p",{className:"text-xs text-ctg-dark-gray",children:"Updates arrive live from Mailgun. Use Refresh to fetch the latest manually."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:"outline",onClick:()=>u&&x.mutate(u),disabled:!u||x.isPending||p.length===0,"data-testid":"button-refresh-sends",children:[x.isPending?e.jsx(L,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(st,{className:"h-4 w-4 mr-1"}),"Refresh"]}),e.jsx(w,{onClick:o,"data-testid":"button-close-history",children:"Close"})]})]})]})})}function qt({report:s,onClose:m}){const{toast:o}=te(),c=s!==null,{data:u,isLoading:f}=Ee({queryKey:["/api/board-reports",s==null?void 0:s.id,"send-recipients"],enabled:!!(s!=null&&s.id),queryFn:async()=>{const n=await fetch(`/api/board-reports/${s.id}/send-recipients`,{credentials:"include"});if(!n.ok)throw new Error(`Failed to load recipients (${n.status})`);return n.json()}}),d=Y({mutationFn:async n=>(await A("POST",`/api/board-reports/${n.id}/send`,{recipientIds:n.recipientIds,extraEmails:n.extraEmails,includeExecutiveDirector:n.includeExecutiveDirector})).json(),onSuccess:n=>{n.failed>0?o({title:`Sent to ${n.sent}, ${n.failed} failed`,description:"Check the server logs for details on failed deliveries.",variant:"destructive"}):o({title:`Report sent to ${n.sent} board member${n.sent===1?"":"s"}`,description:n.attachmentsIncluded>0?`Included ${n.attachmentsIncluded} attachment${n.attachmentsIncluded===1?"":"s"}.`:void 0}),m()},onError:n=>o({title:"Could not send report",description:n.message,variant:"destructive"})}),h=(u==null?void 0:u.recipients)||[],x=(u==null?void 0:u.executiveDirectorEmail)||"",[p,b]=v.useState(new Set),[i,j]=v.useState(!1),[k,N]=v.useState("");v.useEffect(()=>{c&&(b(new Set(h.map(n=>n.id))),j(!1),N(""))},[c,s==null?void 0:s.id,h.length]);const M=k.split(",").map(n=>n.trim()).filter(n=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)),S=p.size+(i?1:0)+M.length,E=h.length>0&&p.size===h.length,R=p.size>0&&!E,T=()=>{b(E?new Set:new Set(h.map(n=>n.id)))},C=n=>{b(D=>{const O=new Set(D);return O.has(n)?O.delete(n):O.add(n),O})};return e.jsx(se,{open:c,onOpenChange:n=>{n||m()},children:e.jsxs(ae,{className:"max-w-lg","data-testid":"dialog-send-report",children:[e.jsxs(ne,{children:[e.jsx(ie,{children:"Send report to board members"}),e.jsx(re,{children:s?e.jsxs(e.Fragment,{children:["Email ",e.jsx("strong",{children:s.title})," to the board members you choose below. Each person receives their own copy with all section attachments included."]}):null})]}),e.jsx("div",{className:"border rounded-md max-h-72 overflow-y-auto",children:f?e.jsxs("div",{className:"flex items-center justify-center py-8 text-ctg-dark-gray",children:[e.jsx(L,{className:"h-4 w-4 mr-2 animate-spin"})," Loading recipients…"]}):h.length===0?e.jsx("div",{className:"px-4 py-6 text-sm text-ctg-dark-gray",children:"No active board members found. Mark members as Active on the Members page first."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-3 py-2 border-b bg-ctg-light-gray/40 flex items-center justify-between sticky top-0","data-testid":"row-recipients-select-all",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-ctg-dark-gray cursor-pointer",children:[e.jsx(we,{checked:E?!0:R?"indeterminate":!1,onCheckedChange:T,"data-testid":"checkbox-recipients-select-all"}),E?"Deselect all":"Select all"]}),e.jsxs("span",{className:"text-xs text-ctg-dark-gray","data-testid":"text-recipients-selected-count",children:[p.size," of ",h.length," selected"]})]}),e.jsx("ul",{className:"divide-y","data-testid":"list-send-recipients",children:h.map(n=>{const D=p.has(n.id);return e.jsxs("li",{className:"px-3 py-2 text-sm flex items-center gap-3","data-testid":`row-recipient-${n.id}`,children:[e.jsx(we,{checked:D,onCheckedChange:()=>C(n.id),"data-testid":`checkbox-recipient-${n.id}`}),e.jsxs("button",{type:"button",onClick:()=>C(n.id),className:"flex-1 flex items-center justify-between gap-3 text-left",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-ctg-blue",children:n.fullName}),n.title?e.jsx("div",{className:"text-xs text-ctg-dark-gray",children:n.title}):null]}),e.jsx("div",{className:"text-ctg-dark-gray font-mono text-xs",children:n.email})]})]},n.id)})})]})}),e.jsxs("div",{className:"space-y-3 pt-1",children:[e.jsxs("label",{className:"flex items-start gap-2 text-sm cursor-pointer","data-testid":"row-report-include-ed",children:[e.jsx(we,{checked:i,onCheckedChange:n=>j(n===!0),className:"mt-0.5","data-testid":"checkbox-report-include-ed"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium text-ctg-dark-gray",children:"Also send to Executive Director"}),x?e.jsx("span",{className:"block text-xs font-mono text-ctg-dark-gray/70",children:x}):null]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs($,{htmlFor:"report-extra-emails",className:"text-sm font-medium text-ctg-dark-gray",children:["Guest emails ",e.jsx("span",{className:"text-ctg-dark-gray/60 font-normal",children:"(comma-separated)"})]}),e.jsx(He,{id:"report-extra-emails",rows:2,value:k,onChange:n=>N(n.target.value),placeholder:"[email protected], [email protected]","data-testid":"textarea-report-extra-emails"})]})]}),e.jsxs(le,{children:[e.jsx(w,{variant:"outline",onClick:m,disabled:d.isPending,"data-testid":"button-send-cancel",children:"Cancel"}),e.jsxs(w,{onClick:()=>s&&d.mutate({id:s.id,recipientIds:Array.from(p),extraEmails:M,includeExecutiveDirector:i}),disabled:f||S===0||d.isPending,className:"bg-ctg-blue hover:bg-ctg-blue/90 text-white","data-testid":"button-send-confirm",children:[d.isPending?e.jsx(L,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Ae,{className:"h-4 w-4 mr-1"}),"Send to ",S," recipient",S===1?"":"s"]})]})]})})}function Ss(){const{user:s}=We(),{toast:m}=te(),o=(s==null?void 0:s.role)==="superadmin",{data:c=[],isLoading:u}=Ee({queryKey:["/api/board-reports"]}),[f,d]=v.useState("all"),[h,x]=v.useState(!1),[p,b]=v.useState(Be()),[i,j]=v.useState("create"),[k,N]=v.useState(void 0),[M,S]=v.useState(!1),[E,R]=v.useState(null),[T,C]=v.useState(null),[n,D]=v.useState(null),[O,oe]=v.useState(null),z=v.useMemo(()=>f==="all"?c:c.filter(t=>t.reportType===f),[c,f]),I=new Date().getFullYear(),J=t=>new Date(t.reportDate).getFullYear(),K=v.useMemo(()=>z.filter(t=>t.status==="draft"),[z]),_=v.useMemo(()=>z.filter(t=>t.status==="finalized"&&J(t)>=I),[z,I]),Q=v.useMemo(()=>z.filter(t=>t.status==="finalized"&&J(t)<I),[z,I]),X=t=>{const g=t==="executive_director"?c.filter(y=>y.reportType===t).slice().sort((y,F)=>+new Date(F.reportDate)-+new Date(y.reportDate))[0]:void 0;b(g?Lt(g,t):Be(t)),j("create"),N(void 0),x(!0)},je=t=>{b(Ot(t)),j("edit"),N(t.id),x(!0)},ve=Y({mutationFn:async t=>A("POST",`/api/board-reports/${t}/reopen`),onSuccess:()=>{B.invalidateQueries({queryKey:["/api/board-reports"]}),m({title:"Report re-opened",description:"You can now edit this report again."})},onError:t=>m({title:"Could not re-open",description:t.message,variant:"destructive"})}),ce=Y({mutationFn:async t=>A("POST",`/api/board-reports/${t}/finalize`),onSuccess:()=>{B.invalidateQueries({queryKey:["/api/board-reports"]}),m({title:"Report finalized"})},onError:t=>m({title:"Could not finalize",description:t.message,variant:"destructive"})}),de=Y({mutationFn:async t=>A("DELETE",`/api/board-reports/${t}`),onSuccess:()=>{B.invalidateQueries({queryKey:["/api/board-reports"]}),m({title:"Report deleted"}),C(null)},onError:t=>m({title:"Could not delete",description:t.message,variant:"destructive"})}),a=t=>t.canvaDesignUrl?t.canvaDesignUrl:t.attachmentUrl?`/api/board-reports/${t.id}/attachment?inline=1`:t.reportType!=="annual"?`/admin/board/reports/${t.id}/preview`:null,l=()=>e.jsx(nt,{children:e.jsxs(_e,{children:[e.jsx(H,{className:"w-[28%]",children:"Title"}),e.jsx(H,{className:"w-[14%]",children:"Type"}),e.jsx(H,{className:"w-[12%]",children:"Date"}),e.jsx(H,{className:"w-[12%]",children:"Period"}),e.jsx(H,{className:"w-[11%]",children:"Status"}),e.jsx(H,{className:"w-[10%]",children:"File"}),e.jsx(H,{className:"w-[13%] text-right",children:"Actions"})]})}),r=t=>{const g=a(t),y=pe[t.reportType]||pe.executive_director,F=ge[t.status]||ge.draft;return e.jsxs(_e,{"data-testid":`row-report-${t.id}`,children:[e.jsxs(V,{className:"max-w-xs",children:[g&&(t.canvaDesignUrl||t.attachmentUrl)?e.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",className:"text-left font-medium text-ctg-blue hover:underline truncate block w-full","data-testid":`button-open-report-${t.id}`,children:t.title}):e.jsx("button",{type:"button",onClick:()=>R(t),className:"text-left font-medium text-ctg-blue hover:underline truncate block w-full","data-testid":`button-open-report-${t.id}`,children:t.title}),t.author&&e.jsx("div",{className:"text-xs text-ctg-med-gray truncate",children:t.author})]}),e.jsx(V,{children:e.jsx(G,{className:y,"data-testid":`badge-row-type-${t.id}`,children:Re[t.reportType]||t.reportType})}),e.jsx(V,{className:"whitespace-nowrap text-sm text-ctg-dark-gray","data-testid":`text-row-date-${t.id}`,children:Xe(t.reportDate)}),e.jsx(V,{className:"text-sm text-ctg-dark-gray","data-testid":`text-row-period-${t.id}`,children:t.periodLabel||"—"}),e.jsx(V,{children:e.jsx(G,{className:F.className,"data-testid":`badge-row-status-${t.id}`,children:F.label})}),e.jsx(V,{children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.attachmentUrl&&e.jsxs("a",{href:`/api/board-reports/${t.id}/attachment?inline=1`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-ctg-blue hover:underline","data-testid":`link-row-file-${t.id}`,title:t.attachmentName||"Open file",children:[e.jsx(xe,{className:"h-3.5 w-3.5"})," File"]}),t.canvaDesignUrl&&e.jsxs(G,{className:"bg-[#084E7F]/10 text-[#084E7F] border border-[#084E7F]/30 gap-1","data-testid":`badge-row-canva-${t.id}`,title:"Includes a Canva design",children:[e.jsx(be,{className:"h-3 w-3"})," Canva"]}),!t.attachmentUrl&&!t.canvaDesignUrl&&e.jsx("span",{className:"text-xs text-ctg-med-gray",children:"—"})]})}),e.jsx(V,{className:"text-right",children:e.jsx("div",{className:"flex items-center justify-end gap-1",children:e.jsxs(pt,{children:[e.jsx(gt,{asChild:!0,children:e.jsx(w,{size:"icon",variant:"ghost",className:"h-8 w-8 text-ctg-dark-gray hover:text-ctg-blue hover:bg-ctg-blue/10",title:"Actions","data-testid":`button-row-menu-${t.id}`,children:e.jsx(jt,{className:"h-4 w-4"})})}),e.jsxs(ft,{align:"end",className:"w-48",children:[e.jsx(bt,{className:"text-ctg-blue font-montserrat",children:"Actions"}),e.jsx(Se,{}),g?e.jsx(U,{asChild:!0,"data-testid":`menu-view-${t.id}`,children:e.jsxs("a",{href:g,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(me,{className:"h-4 w-4 mr-2 text-ctg-blue"})," View in new tab"]})}):e.jsxs(U,{onClick:()=>R(t),"data-testid":`menu-view-${t.id}`,children:[e.jsx(et,{className:"h-4 w-4 mr-2 text-ctg-blue"})," View"]}),e.jsx(U,{asChild:!0,"data-testid":`menu-download-pdf-${t.id}`,children:e.jsxs("a",{href:`/admin/board/reports/${t.id}/preview?print=1`,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(he,{className:"h-4 w-4 mr-2 text-ctg-blue"})," Download as PDF"]})}),t.attachmentUrl&&e.jsx(U,{asChild:!0,"data-testid":`menu-download-${t.id}`,children:e.jsxs("a",{href:`/api/board-reports/${t.id}/attachment`,download:t.attachmentName||void 0,children:[e.jsx(he,{className:"h-4 w-4 mr-2 text-ctg-blue"})," Download file"]})}),o&&e.jsxs(e.Fragment,{children:[e.jsx(Se,{}),e.jsxs(U,{onClick:()=>je(t),"data-testid":`menu-edit-${t.id}`,children:[e.jsx(vt,{className:"h-4 w-4 mr-2 text-ctg-blue"})," Edit"]}),t.status==="draft"&&e.jsxs(U,{onClick:()=>ce.mutate(t.id),"data-testid":`menu-finalize-${t.id}`,children:[e.jsx(Ke,{className:"h-4 w-4 mr-2 text-ctg-blue"})," Finalize"]}),t.status==="finalized"&&e.jsxs(U,{onClick:()=>ve.mutate(t.id),"data-testid":`menu-reopen-${t.id}`,children:[e.jsx(Fe,{className:"h-4 w-4 mr-2 text-ctg-blue"})," Re-open as Draft"]}),e.jsxs(U,{onClick:()=>D(t),"data-testid":`menu-send-${t.id}`,children:[e.jsx(Ae,{className:"h-4 w-4 mr-2 text-ctg-blue"})," Send to board"]}),e.jsxs(U,{onClick:()=>oe(t),"data-testid":`menu-send-history-${t.id}`,children:[e.jsx(Qe,{className:"h-4 w-4 mr-2 text-ctg-blue"})," Send history"]}),e.jsx(Se,{}),e.jsxs(U,{onClick:()=>C(t),className:"text-ctg-red focus:text-ctg-red","data-testid":`menu-delete-${t.id}`,children:[e.jsx($e,{className:"h-4 w-4 mr-2"})," Delete"]})]})]})]})})})]},t.id)};return e.jsxs(at,{navigationKey:"admin",title:"Board Reports",subtitle:"Compose Executive Director reports and browse the archive of ED and Annual reports.",children:[e.jsxs("div",{className:"space-y-6",children:[o&&e.jsx(Me,{"data-testid":"card-composer-launcher",children:e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-lg bg-[#084E7F]/10 p-2",children:e.jsx(Le,{className:"h-5 w-5 text-[#084E7F]"})}),e.jsxs("div",{children:[e.jsx(Ue,{className:"text-ctg-blue font-montserrat",children:"Compose a Report"}),e.jsx(ze,{children:"Start a new Executive Director or Annual report from a section template, or upload a finished document."})]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(w,{onClick:()=>X("executive_director"),className:"bg-[#084E7F] hover:bg-[#084E7F]/90 text-white","data-testid":"button-new-ed-report",children:[e.jsx(Ce,{className:"h-4 w-4 mr-1"})," New ED Report"]}),e.jsxs(w,{onClick:()=>X("annual"),variant:"outline",className:"border-[#B93E2C] text-[#B93E2C] hover:bg-[#B93E2C]/10","data-testid":"button-new-annual-report",children:[e.jsx(Ce,{className:"h-4 w-4 mr-1"})," New Annual Report"]}),e.jsxs(w,{onClick:()=>S(!0),variant:"outline","data-testid":"button-upload-past-report",children:[e.jsx(Te,{className:"h-4 w-4 mr-1"})," Upload Past Report"]})]})]})})}),e.jsxs(Me,{"data-testid":"card-reports-library",children:[e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{children:[e.jsx(Ue,{className:"text-ctg-blue font-montserrat",children:"Report Library"}),e.jsx(ze,{children:"Find, view and download every ED report and Annual report on file."})]}),e.jsx(xt,{value:f,onValueChange:t=>d(t),children:e.jsxs(ht,{"data-testid":"tabs-report-types",children:[e.jsx(ke,{value:"all","data-testid":"tab-all",children:"All"}),e.jsx(ke,{value:"executive_director","data-testid":"tab-ed",children:"Executive Director"}),e.jsx(ke,{value:"annual","data-testid":"tab-annual",children:"Annual"})]})})]})}),e.jsx(Ze,{children:u?e.jsxs("div",{className:"flex items-center justify-center py-12 text-ctg-med-gray",children:[e.jsx(L,{className:"h-5 w-5 animate-spin mr-2"})," Loading reports…"]}):z.length===0?e.jsxs("div",{className:"text-center py-10 text-ctg-med-gray",children:[e.jsx(Le,{className:"h-10 w-10 mx-auto mb-2 text-ctg-med-gray/60"}),e.jsx("p",{className:"text-sm",children:"No reports yet."}),o&&e.jsx("p",{className:"text-xs mt-1",children:"Use the buttons above to compose a new report or upload a past one."})]}):e.jsxs("div",{className:"space-y-6",children:[K.length>0&&e.jsxs("section",{"data-testid":"section-drafts",children:[e.jsx("h2",{className:"font-montserrat text-ctg-blue text-sm font-semibold uppercase tracking-wide mb-2",children:"Drafts"}),e.jsx("div",{className:"rounded-md border border-ctg-med-gray/30 overflow-hidden",children:e.jsxs(Ne,{className:"table-fixed",children:[e.jsx(l,{}),e.jsx(De,{children:K.map(r)})]})})]}),e.jsxs("section",{"data-testid":"section-finalized",children:[e.jsxs("h2",{className:"font-montserrat text-ctg-blue text-sm font-semibold uppercase tracking-wide mb-2",children:["Fi
31nalized ",e.jsxs("span",{className:"text-ctg-med-gray font-normal normal-case",children:["(FY ",I,")"]})]}),_.length===0?e.jsx("p",{className:"text-sm text-ctg-med-gray italic",children:"No finalized reports in this view."}):e.jsx("div",{className:"rounded-md border border-ctg-med-gray/30 overflow-hidden",children:e.jsxs(Ne,{className:"table-fixed",children:[e.jsx(l,{}),e.jsx(De,{children:_.map(r)})]})})]}),Q.length>0&&e.jsxs("section",{"data-testid":"section-archived",children:[e.jsxs("h2",{className:"font-montserrat text-ctg-blue text-sm font-semibold uppercase tracking-wide mb-2",children:["Archived ",e.jsx("span",{className:"text-ctg-med-gray font-normal normal-case",children:"(prior fiscal years)"})]}),e.jsx("div",{className:"rounded-md border border-ctg-med-gray/30 overflow-hidden",children:e.jsxs(Ne,{className:"table-fixed",children:[e.jsx(l,{}),e.jsx(De,{children:Q.map(r)})]})})]})]})})]})]}),e.jsx(_t,{open:h,onOpenChange:x,initial:p,mode:i,reportId:k}),e.jsx(Bt,{open:M,onOpenChange:S}),e.jsx(Yt,{report:E,open:E!==null,onOpenChange:t=>{t||R(null)}}),e.jsx(qt,{report:n,onClose:()=>D(null)}),e.jsx(Vt,{report:O,open:O!==null,onClose:()=>oe(null)}),e.jsx(it,{open:T!==null,onOpenChange:t=>{t||C(null)},children:e.jsxs(rt,{"data-testid":"dialog-delete-confirm",children:[e.jsxs(lt,{children:[e.jsx(ot,{children:"Delete this report?"}),e.jsx(ct,{children:T?e.jsxs(e.Fragment,{children:["This will permanently remove ",e.jsx("strong",{children:T.title})," and any attached file. This cannot be undone."]}):null})]}),e.jsxs(dt,{children:[e.jsx(mt,{"data-testid":"button-delete-cancel",children:"Cancel"}),e.jsxs(ut,{onClick:()=>T&&de.mutate(T.id),className:"bg-[#B93E2C] hover:bg-[#B93E2C]/90 text-white","data-testid":"button-delete-confirm",children:[de.isPending?e.jsx(L,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx($e,{className:"h-4 w-4 mr-1"}),"Delete"]})]})]})})]})}export{Ss as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.