1import{j as e,F as P,H as ce,m as ee,a5 as U,e as b,aI as ve,af as ns,aG as ls,aH as ds,aa as be,B as k,ao as Pe,D as He,bi as Z,a as Ve,aJ as Ge,aC as Ne,i as we,am as ke,cl as Le,aK as cs,aE as os,n as fe,ab as ms,K as xs,_ as ps,$ as us,a0 as gs,a1 as hs,a2 as je,b5 as ys,E as fs,G as js,I as Ue,J as _e,C as V,d as G,c as Me,be as bs,cm as $e,b as qe,a3 as vs,k as Ns,aA as ws,ac as Qe,aZ as ks,a_ as Ss,a$ as Es,b0 as Cs,b1 as As,ae as Fs,X as Ds,cn as Ms}from"./index-Byg2HWAE.js";import{r as d}from"./vendor-Qgthw7N1.js";import{F as Ze,D as Je,R as Xe,u as $s,c as Ts}from"./useFileAccessUrl-6aqd6eyh.js";import{G as Ps}from"./grid-3x3-Dl22D3mL.js";import{A as Te}from"./activity-DlNiJWQy.js";import{C as Ls}from"./copy-DV8e8Olv.js";import"./file-image-Er1ZOYVg.js";import"./hard-drive-436CTEuo.js";import"./share-2-BwzmsqEz.js";import"./maximize-2-D7IQEluU.js";import"./circle-x-C3yul9_R.js";function Is(x){if(!x)return"";let h=x.replace(/\*\*/g,"").replace(/\*([^*]+)\*/g,"<strong>$1</strong>").trim();const o=[];return h.split(/(?=\*\*[A-Z][^*]*\*\*)|(?=\*[A-Z][^*]*\*)/).forEach(l=>{if(!l.trim())return;const i=l.match(/^(.+?):\s*(.+)$/);if(i){const[,c,C]=i;o.push({title:c.replace(/^\*+|\*+$/g,"").trim(),content:C.trim(),type:"field"});return}if(l.includes("â¢")||/^\d+\./.test(l.trim())){o.push({title:"",content:l.trim(),type:"list"});return}if(l.startsWith("**")||/^[A-Z\s]+:/.test(l)){o.push({title:l.replace(/^\*+|\*+$/g,"").replace(/:$/,"").trim(),content:"",type:"header"});return}o.push({title:"",content:l.trim(),type:"text"})}),o.filter(l=>l.title||l.content).map(l=>{switch(l.type){case"header":return`<div class="ai-summary-header">${l.title}</div>`;case"field":return` 2 <div class="ai-summary-field"> 3 <span class="ai-summary-field-label">${l.title}:</span> 4 <span class="ai-summary-field-value">${l.content}</span> 5 </div> 6 `;case"list":return`<ul class="ai-summary-list">${l.content.split(/[â¢\n]/).filter(c=>c.trim()).map(c=>`<li>${c.trim()}</li>`).join("")}</ul>`;case"text":return`<div class="ai-summary-text">${l.content}</div>`;default:return`<div class="ai-summary-text">${l.content}</div>`}}).join("")}function Be(x){if(!x)return"";const h=x.split(` 7`).map(i=>i.trim()).filter(i=>i.length>0);let o="",v="",l=[];for(let i=0;i<h.length;i++){const c=h[i];if(!c)continue;if(c.includes("&")&&c.includes("Purpose:")){const[N,A]=c.split("&");o+=`<div class="ai-summary-document-type">${N.trim()}</div>`,A&&(o+=`<div class="ai-summary-section-title">${A.trim()}</div>`);continue}const C=c.match(/^([^:]+):\s*(.+)$/);if(C){const[,N,A]=C;if(["Property Address","Client","Date","Total Amount","Vendor/Contractor","Type","Address","Phone","Email"].some(g=>N.trim().toLowerCase().includes(g.toLowerCase()))){l.push({label:N.trim(),value:A.trim()});continue}}if(c.toLowerCase().includes("work description")||c.toLowerCase().includes("description")){l.length>0&&(o+='<div class="ai-summary-key-info">',l.forEach(N=>{o+=` 8 <div class="ai-summary-info-item"> 9 <span class="ai-summary-info-label">${N.label}:</span> 10 <span class="ai-summary-info-value">${N.value}</span> 11 </div> 12 `}),o+="</div>",l=[]),o+=`<div class="ai-summary-section-title">${c}</div>`,v="description";continue}if(v==="description"){const N=c.replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>");if(c.includes(" - ")||c.includes("⢠")){const A=c.split(/\s*-\s*|\s*â¢\s*/).filter(F=>F.trim());o+='<ul class="ai-summary-list">',A.forEach(F=>{F.trim()&&(o+=`<li>${F.trim()}</li>`)}),o+="</ul>"}else o+=`<div class="ai-summary-description-text">${N}</div>`}else{const N=c.replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>");o+=`<div class="ai-summary-text">${N}</div>`}}return l.length>0&&(o+='<div class="ai-summary-key-info">',l.forEach(i=>{o+=` 13 <div class="ai-summary-info-item"> 14 <span class="ai-summary-info-label">${i.label}:</span> 15 <span class="ai-summary-info-value">${i.value}</span> 16 </div> 17 `}),o+="</div>"),o||Is(x)}function Os({entryWithFiles:x,onPreview:h,onDownload:o,onDelete:v,getFileIcon:l,getAnalysisStatusBadge:i,getActivityTypeColor:c,formatActivityType:C,properties:N=[]}){const[A,F]=d.useState(!1),{timeEntry:g,files:L}=x,I=()=>
17{if(g.property&&typeof g.property=="object"&&"nickname"in g.property)return g.property.nickname;if(g.property&&typeof g.property=="object"&&"name"in g.property)return g.property.name;if(typeof g.property=="string")return g.property;if(g.propertyId&&N.length>0){const u=N.find(D=>D.id===g.propertyId);if(u)return u.nickname||u.address}return"No Property"};return e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl mb-4 border border-gray-100 dark:border-gray-700 shadow-sm overflow-hidden",children:[e.jsx("div",{className:"p-4 active:bg-gray-50 dark:active:bg-gray-700/50 transition-colors",onClick:()=>F(!A),children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(ce,{className:"w-4 h-4 text-emerald-600 flex-shrink-0"}),e.jsx("h3",{className:"font-semibold text-gray-900 dark:text-gray-100 truncate",children:I()})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500 mb-2",children:[e.jsx(ee,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:U(new Date(g.date),"MMM d")}),e.jsx("span",{children:"â¢"}),e.jsxs("span",{children:[g.hours," hrs"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(b,{className:ve("text-xs font-normal",c(g.activityType)),children:C(g.activityType)}),e.jsxs(b,{variant:"secondary",className:"text-xs",children:[L.length," ",L.length===1?"file":"files"]})]})]}),e.jsx(ns,{className:ve("w-5 h-5 text-gray-400 transition-transform duration-200 mt-1",A&&"rotate-90")})]})}),e.jsx(ls,{children:A&&e.jsx(ds.div,{initial:{height:0},animate:{height:"auto"},exit:{height:0},className:"overflow-hidden bg-gray-50 dark:bg-gray-800/50 border-t border-gray-100 dark:border-gray-700",children:e.jsx("div",{className:"p-4 space-y-4",children:L.map((u,D)=>e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg p-3 border border-gray-200 dark:border-gray-700 shadow-sm",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[l(u.fileName,"w-8 h-8 flex-shrink-0"),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex justify-between items-start gap-2",children:[e.jsx("h4",{className:"font-medium text-sm truncate text-gray-900 dark:text-gray-100",children:u.originalName||u.fileName}),e.jsx("div",{className:"flex-shrink-0",children:i(u.aiAnalysisStatus,u.fileName,u.aiSummary)})]}),u.aiSummary&&u.aiAnalysisStatus==="completed"&&e.jsxs("div",{className:"mt-2 text-xs text-gray-600 dark:text-gray-400 line-clamp-2",children:[e.jsx(be,{className:"w-3 h-3 inline mr-1 text-purple-500"}),u.aiSummary.replace(/<[^>]*>?/gm,"")]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(k,{variant:"outline",size:"sm",className:"flex-1 h-8 text-xs bg-white dark:bg-gray-800",onClick:()=>h(L,D),children:[e.jsx(Pe,{className:"w-3.5 h-3.5 mr-1.5 text-green-600"}),"Preview"]}),e.jsx(k,{variant:"outline",size:"icon",className:"h-8 w-8 text-gray-500",onClick:()=>o(u.fileUrl,u.originalName||u.fileName),children:e.jsx(He,{className:"w-4 h-4"})}),e.jsx(k,{variant:"outline",size:"icon",className:"h-8 w-8 text-red-500 hover:text-red-600 hover:bg-red-50",onClick:()=>v(u),children:e.jsx(Z,{className:"w-4 h-4"})})]})]},u.id))})})})]})}function Ye(x){return x.entries.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center text-gray-500",children:[e.jsx(P,{className:"w-12 h-12 mb-3 text-gray-300"}),e.jsx("p",{children:"No files found"})]}):e.jsx("div",{className:"space-y-4",children:x.entries.map(h=>e.jsx(Os,{entryWithFiles:h,...x,properties:x.properties},h.timeEntry.id))})}const zs=x=>{const h=new Date(x).getTime()-Date.now();return Math.ceil(h/(1e3*60*60*24))};function Ks({activeTab:x,onTabChange:h,activeCount:o,deletedCount:v}){const l=[{value:"active",label:"Active",count:o,icon:e.jsx(P,{className:"h-3.5 w-3.5"})},{value:"deleted",label:"Deleted",count:v,icon:e.jsx(Z,{className:"h-3.5 w-3.5"})}];return e.jsx("div",{className:"mb-5 rounded-2xl border border-gray-100 bg-white/90 p-1.5 shadow-sm backdrop-blur dark:border-gray-800 dark:bg-gray-800/90",children:e.jsx("div",{className:"flex gap-1",role:"tablist","aria-label":"File status",children:l.map(i=>{const c=x===i.value;return e.jsxs("button",{type:"button",role:"tab","aria-selected":c,onClick:()=>
17h(i.value),className:ve("flex min-h-[40px] flex-1 items-center justify-center gap-1.5 rounded-xl px-3 py-2 text-xs font-semibold transition-all active:scale-[0.98] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-green-500",c?"bg-green-100 text-green-700 shadow-sm dark:bg-green-950/50 dark:text-green-300":"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"),children:[i.icon,e.jsx("span",{children:i.label}),e.jsx("span",{className:ve("rounded-full px-1.5 py-0.5 text-[10px] leading-none",c?"bg-white/80 text-green-700 dark:bg-gray-900/70 dark:text-green-300":"bg-gray-100 text-gray-500 dark:bg-gray-700 dark:text-gray-300"),children:i.count})]},i.value)})})})}function Rs({deletedFiles:x,isLoading:h,hasError:o,onRestore:v,getFileIcon:l}){return h?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-2xl bg-white py-12 text-center text-gray-500 shadow-sm dark:bg-gray-800 dark:text-gray-400",children:[e.jsx(we,{className:"mb-3 h-10 w-10 animate-pulse text-gray-300"}),e.jsx("p",{children:"Loading deleted files..."})]}):o?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-2xl border border-red-100 bg-red-50 py-12 text-center text-red-600 dark:border-red-900 dark:bg-red-950/30 dark:text-red-300",children:[e.jsx(ke,{className:"mb-3 h-10 w-10"}),e.jsx("p",{children:"Deleted files could not be loaded."})]}):x.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-2xl bg-white py-12 text-center text-gray-500 shadow-sm dark:bg-gray-800 dark:text-gray-400",children:[e.jsx(Z,{className:"mb-3 h-12 w-12 text-gray-300"}),e.jsx("p",{className:"font-semibold text-gray-700 dark:text-gray-300",children:"No deleted files"}),e.jsx("p",{className:"mt-1 max-w-[260px] text-sm",children:"Deleted files will appear here for 30 days before permanent removal."})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-2xl border border-amber-200 bg-amber-50 p-4 dark:border-amber-800 dark:bg-amber-950/30",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(ke,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-amber-800 dark:text-amber-300",children:"30-day restoration period"}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-amber-700 dark:text-amber-400",children:"Restore files here before their scheduled permanent deletion date."})]})]})}),x.map(i=>{const c=zs(i.scheduledDeletionAt);return e.jsxs("div",{className:"rounded-xl border border-gray-100 bg-white p-4 shadow-sm dark:border-gray-700 dark:bg-gray-800",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[l(i.fileName,"h-9 w-9 flex-shrink-0"),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"truncate text-sm font-semibold text-gray-900 dark:text-gray-100",children:i.originalName||i.fileName}),e.jsxs("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:["Deleted ",U(new Date(i.deletedAt),"MMM d, yyyy")]}),i.fileSize&&e.jsxs("p",{className:"mt-0.5 text-xs text-gray-400",children:[Math.round(i.fileSize/1024)," KB"]})]})]}),e.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[e.jsxs(b,{variant:c<=7?"destructive":"secondary",className:"h-8 rounded-full px-3 text-xs",children:[e.jsx(we,{className:"mr-1 h-3 w-3"}),c>0?`${c} day${c!==1?"s":""} left`:"Expires today"]}),e.jsxs(k,{type:"button",variant:"outline",size:"sm",onClick:()=>v(i),className:"ml-auto h-8 rounded-full border-green-200 px-3 text-xs font-semibold text-green-700 hover:bg-green-50 dark:border-green-900 dark:text-green-300 dark:hover:bg-green-950/30",children:[e.jsx(Le,{className:"mr-1.5 h-3.5 w-3.5"}),"Restore"]})]})]},i.id)})]})}function Us({entries:x,deletedFiles:h=[],isLoadingDeleted:o=!1,deletedFilesError:v,onDownload:l,getFileIcon:i,getAnalysisStatusBadge:c,getActivityTypeColor:C,formatActivityType:N,properties:A=[]}){const[F,g]=d.useState("active"),[L,I]=d.useState(null),[u,D]=d.useState([]),[$,Se]=d.useState(0),[J,oe]=d.useState(!1),[w,_]=d.useState(null),[X,se]=d.useState(!1),[S,me]=d.useState(null),[xe,te]=d.useState(!1),{toast:O}=Ve(),z=Ge(),q=d.useMemo(()=>x.reduce((p,E)=>p+E.files.length,0),[x]),y=Ne({mutationFn:async p=>{const E=await fetch(`/api/evidence-files/${p}`,{method:"DELETE",credentials:"include"});if(!E.ok){const Y=await E.json().catch(()=>({}));throw new Error(Y.message||"Failed to delete file")}return E.json()},onSuccess:async()=>{await z.invalidateQueries({queryKey:["/api/evidence-files"]}),await z.invalidateQueries({queryKey:["/api/evidence-files/deleted"]}),await z.invalidateQueries({queryKey:["/api/time-entries"]}),O({title:"File Deleted",description:"The file has been moved to trash."}),se(!1),_(null)},onError:p=>{O({title:"Delete Failed",description:p.message,variant:"destructive"})}}),ae=Ne({mutationFn:async p=>{const E=await fetch(`/api/evidence-files/${p}/restore`,{method:"POST",credentials:"include"});if(!E.ok){const Y=await E.json().catch(()=>({}));throw new Error(Y.message||"Failed to restore file")}return E.json()},onSuccess:async()=>{await z.invalidateQueries({queryKey:["/api/evidence-files"]}),await z.invalidateQueries({queryKey:["/api/evidence-files/deleted"]}),await z.invalidateQueries({queryKey:["/api/time-entries"]}),O({title:"File Restored",description:"The file has been restored to active files."}),te(!1),me(null),g("active")},onError:p=>{O({title:"Restore Failed",description:p.message,variant:"destructive"})}}),f=p=>{_(p),se(!0)}
17,pe=()=>{w!=null&&w.numericId&&y.mutate(w.numericId)},T=p=>{me(p),te(!0)},Ee=()=>{S!=null&&S.id&&ae.mutate(S.id)},K=(p,E)=>{D(p),Se(E),I(p[E]),oe(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 px-4 py-6 w-full container-mobile",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100 mb-2",children:"File Vault"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:F==="active"?`${x.length} entr${x.length!==1?"ies":"y"} ⢠${q} file${q!==1?"s":""}`:`${h.length} deleted file${h.length!==1?"s":""}`})]}),e.jsx(Ks,{activeTab:F,onTabChange:g,activeCount:q,deletedCount:h.length}),F==="active"?e.jsx(Ye,{entries:x,onPreview:K,onDownload:l,onDelete:f,getFileIcon:i,getAnalysisStatusBadge:c,getActivityTypeColor:C,formatActivityType:N,properties:A}):e.jsx(Rs,{deletedFiles:h,isLoading:o,hasError:!!v,onRestore:T,getFileIcon:i})]}),L&&e.jsx(Ze,{file:L,isOpen:J,onClose:()=>{oe(!1),I(null)},hasActiveSubscription:!0,allFiles:u,currentFileIndex:$,onFileChange:p=>{u[p]&&(Se(p),I(u[p]))}}),e.jsx(Je,{open:X,onOpenChange:se,fileName:(w==null?void 0:w.originalName)||(w==null?void 0:w.fileName)||"",onConfirm:pe,isDeleting:y.isPending}),S&&e.jsx(Xe,{open:xe,onOpenChange:te,fileName:S.originalName||S.fileName,scheduledDeletionAt:S.scheduledDeletionAt,onConfirm:Ee,isRestoring:ae.isPending})]})}function et(){const x=cs(),[h,o]=d.useState(!1),[v,l]=d.useState("grid"),[i,c]=d.useState(""),[C,N]=d.useState("all"),[A,F]=d.useState("active"),[g,L]=d.useState(new Set),[I,u]=d.useState(new Set),[D,$]=d.useState(null),[Se,J]=d.useState([]),[oe,w]=d.useState(0),[_,X]=d.useState(null),[se,S]=d.useState(!1),[me,xe]=d.useState(!1),[te,O]=d.useState(!1),[z,q]=d.useState(!1),[y,ae]=d.useState(null),[f,pe]=d.useState(null),{toast:T}=Ve(),{hasActiveSubscription:Ee}=os(),K=Ge();$s();const p=d.useRef(!1);d.useEffect(()=>{o(!0)},[]);const E=Ne({mutationFn:async s=>{const t=await fetch(`/api/evidence-files/${s}`,{method:"DELETE",credentials:"include"});if(!t.ok){const a=await t.json().catch(()=>({}));throw new Error(a.message||"Failed to delete file")}return t.json()},onSuccess:async s=>{await K.invalidateQueries({queryKey:["/api/evidence-files"]}),await K.invalidateQueries({queryKey:["/api/evidence-files/deleted"]}),await K.invalidateQueries({queryKey:["/api/time-entries"]}),Ts(y==null?void 0:y.numericId),T({title:"File Deleted",description:`"${(y==null?void 0:y.originalName)||(y==null?void 0:y.fileName)}" has been moved to deleted files. You have 30 days to restore it.`}),O(!1),ae(null)},onError:s=>{T({title:"Delete Failed",description:s.message,variant:"destructive"})}}),Y=Ne({mutationFn:async s=>{const t=await fetch(`/api/evidence-files/${s}/restore`,{method:"POST",credentials:"include"});if(!t.ok){const a=await t.json().catch(()=>({}));throw new Error(a.message||"Failed to restore file")}return t.json()},onSuccess:async()=>{await K.invalidateQueries({queryKey:["/api/evidence-files"]}),await K.invalidateQueries({queryKey:["/api/evidence-files/deleted"]}),await K.invalidateQueries({queryKey:["/api/time-entries"]}),T({title:"File Restored",description:`"${(f==null?void 0:f.originalName)||(f==null?void 0:f.fileName)}" has been restored successfully.`}),q(!1),pe(null)},onError:s=>{T({title:"Restore Failed",description:s.message,variant:"destructive"})}}),Ce=s=>{ae(s),O(!0)},Ie=s=>{pe(s),q(!0)},We=()=>{y!=null&&y.numericId&&E.mutate(y.numericId)},es=()=>{f!=null&&f.id&&Y.mutate(f.id)},ss=s=>{if(s.evidenceFiles&&s.evidenceFiles.length>0){const t=s.evidenceFiles.filter(n=>!n.isDeleted),a=t[0],m=t.map(n=>({id:`evidence-${s.id}-${n.fileName}`,numericId:n.id,originalName:n.originalName,fileName:n.fileName,fileUrl:n.fileUrl,mimeType:n.mimeType||Fe(n.fileName),uploadedAt:n.uploadedAt||n.createdAt,fileSize:n.fileSize,aiSummary:n.aiSummary||s.aiSummary,aiAnalysisStatus:n.aiAnalysisStatus||s.evidenceAiAnalysisStatus||"pending",timeEntryId:s.id,isLegacy:!1,r2Key:n.r2Key,storageType:n.storageType,publicToken:n.publicToken}));$({id:a.id,numericId:a.id,originalName:a.originalName,fileName:a.fileName,fileUrl:a.fileUrl,mimeType:a.mimeType||Fe(a.fileName),uploadedAt:a.uploadedAt||a.createdAt,fileSize:a.fileSize,aiSummary:a.aiSummary||s.aiSummary,aiAnalysisStatus:a.aiAnalysisStatus||s.evidenceAiAnalysisStatus||"pending",allFiles:m,r2Key:a.r2Key,storageType:a.storageType,publicToken:a.publicToken}),w(0),S(!0)}},Oe=s=>{const t=new Set(I);t.has(s)?t.delete(s):t.add(s),u(t)},ue=s=>({"property-management":"bg-blue-100 text-blue-800 border-blue-200","leasing-tenant-relations":"bg-green-100 text-green-800 border-green-200","maintenance-repairs":"bg-orange-100 text-orange-800 border-orange-200","bookkeeping-recordkeeping":"bg-purple-100 text-purple-800 border-purple-200","property-acquisition":"bg-indigo-100 text-indigo-800 border-indigo-200","property-sale":"bg-red-100 text-red-800 border-red-200","vendor-contractor-management":"bg-yellow-100 text-yellow-800 border-yellow-200","compliance-legal":"bg-gray-100 text-gray-800 border-gray-200","travel-property-related":"bg-pink-100 text-pink-800 border-pink-200","strategic-planning":"bg-cyan-100 text-cyan-800 border-cyan-200","education-training":"bg-emerald-100 text-emerald-800 border-emerald-200","communication-correspondence":"bg-teal-100 text-teal-800 border-teal-200","evidence-collection":"bg-slate-100 text-slate-800 border-slate-200"})[s]||"bg-gray-100 text-gray-800 border-gray-200",W=s=>s.replace(/-/g," ").replace(/\b\w/g,t=>t.toUpperCase()),ts=async s=>{try{const t=`${window.location.origin}/api/public/evidence/${s}`;await navigator.clipboard.writeText(t),T({title:"Link Copied",description:"Public file link copied to clipboard."})}catch{T({title:"Copy Failed",description:"Failed to copy link to clipboard.",variant:"destructive"})}};d.useEffect(()=>{const t=new URLSearchParams(window.location.search).get("entry");if(t){const a=parseInt(t);isNaN(a)||X(a)}},[]);const{data:re=[],isLoading:as}=fe({queryKey:["/api/time-entries"]}),{data:ze=[]}=fe({queryKey:["/api/evidence-files"]}),{data:Ke=[]}=fe({queryKey:["/api/properties"]}),{data:ie=[],isLoading:Re,error:rs}=fe({queryKey:["/api/evidence-files/deleted"],queryFn:async()=>{const s=await fetch("/api/evidence-files/deleted",{credentials:"include"});if(!s.ok){const a=await s.text();throw console.error("â Failed to fetch deleted files:",s.status,a),new Error("Failed to fetch deleted files")}return await s.json()}}),ge=[],he=new Map;ze.forEach(s=>{if(s.isDeleted)return;const t=s.timeEntryId||s.time_entry_id,a=re.find(m=>m.id===t);if(a){const m=parseInt(String(s.id)),n={id:`new-${s.id}`,numericId:m,timeEntryId:t,fileName:s.fileName||s.file_name,originalName:s.originalName||s.originalFileName||s.original_name||s.file_name,fileUrl:"",filePath:s.filePath||s.file_path,r2Key:s.r2Key||s.r2_key,storageType:s.storageType||s.storage_type,aiSummary:s.aiSummary||s.ai_summary||void 0,aiAnalysisStatus:s.aiAnalysisStatus||s.ai_analysis_status,accessCount:s.accessCount||s.access_count,expiresAt:s.expiresAt||s.expires_at,uploadedAt:s.createdAt||s.created_at,timeEntry:a,mimeType:s.mimeType||s.mime_type,fileSize:s.fileSize||s.file_size};he.has(t)||he.set(t,[]),he.get(t).push(n)}}),he.forEach((s,t)=>{const a=re.find(m=>m.id===t);a&&s.length>0&&ge.push({timeEntry:a,files:s.sort((m,n)=>new Date(n.uploadedAt).getTime()-new Date(m.uploadedAt).getTime())})});const R=ge.filter(s=>s.files.some(a=>{var B,H;const m=a.fileName||"",n=((B=s.timeEntry)==null?void 0:B.description)||"",r=((H=s.timeEntry)==null?void 0:H.activityType)||"",M=!i||m.toLowerCase().includes(i.toLowerCase())||n.toLowerCase().includes(i.toLowerCase())||r.toLowerCase().includes(i.toLowerCase()),Q=C==="all"||C==="pdf"&&m.toLowerCase().endsWith(".pdf")||C==="image"&&/\.(jpg|jpeg|png|gif)$/i.test(m)||C==="document"&&/\.(doc|docx)$/i.test(m);return M&&Q})).sort((s,t)=>new Date(t.timeEntry.date).getTime()-new Date(s.timeEntry.date).getTime()),ne=R.reduce((s,t)=>s+t.files.length,0),j=d.useMemo(()=>_?ge.find(t=>t.timeEntry.id===_):null,[_,ge]);d.useEffect(()=>{if(p.current,j&&(j.timeEntry.id,j.files.length),!p.current&&j&&j.files.length>0,!p.current&&j&&j.files.length>0){j.files.map(t=>({id:t.id,fileName:t.fileName})),j.files[0].id,j.files[0].fileName,J(j.files),w(0),$(j.files[0]),S(!0),p.current=!0;const s=window.location.pathname;window.history.replaceState({},"",s)}},[j]),d.useEffect(()=>{p.current=!1},[_]);const ye=R.flatMap(s=>s.files);d.useEffect(()=>{const s=new URLSearchParams(window.location.search),t=s.get("expand"),a=s.get("fileId"),m=s.get("entry");if(t&&(a||m)&&ye.length>0){let n=null;a?n=ye.find(r=>r.id===`new-${a}`):m&&(n=ye.find(r=>r.timeEntryId===parseInt(m)&&r.fileName===decodeURIComponent(t))),n&&($(n),S(!0),window.history.replaceState({},document.title,window.location.pathname))}},[ye,re,ze]);const le=(s,t="h-8 w-8")=>
17{if(!s||typeof s!="string")return e.jsx(P,{className:`${t} text-gray-500`});switch(s.toLowerCase().split(".").pop()){case"pdf":return e.jsx(P,{className:`${t} text-red-500`});case"jpg":case"jpeg":case"png":case"gif":return e.jsx("div",{className:`${t} bg-green-500 rounded flex items-center justify-center text-white text-xs`,children:"IMG"});case"doc":case"docx":return e.jsx("div",{className:`${t} bg-blue-600 rounded flex items-center justify-center text-white text-xs`,children:"DOC"});default:return e.jsx(P,{className:`${t} text-gray-500`})}},Ae=async(s,t)=>{try{let a=s;if(!s.includes("/api/public/evidence/"))throw new Error("Invalid file URL - Legacy downloads not supported");const m=await fetch(a,{credentials:"include"});if(!m.ok)throw new Error("Download failed");const n=await m.blob(),r=window.URL.createObjectURL(n),M=document.createElement("a");M.href=r,M.download=t,document.body.appendChild(M),M.click(),document.body.removeChild(M),window.URL.revokeObjectURL(r)}catch{T({title:"Download Error",description:"Failed to download file. Please try again.",variant:"destructive"})}},Fe=s=>{var m;const t=(m=s.split(".").pop())==null?void 0:m.toLowerCase();return{pdf:"application/pdf",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",txt:"text/plain"}[t||""]||"application/octet-stream"},De=(s,t,a)=>{if(!s)return null;const m=(t==null?void 0:t.startsWith("calendar_attachment_"))||(a==null?void 0:a.includes("Calendar attachment from Google Drive"));switch(s){case"pending":return e.jsxs(b,{variant:"outline",className:"text-blue-600 border-blue-200 bg-blue-50",children:[e.jsx(Qe,{className:"h-3 w-3 mr-1 animate-spin"}),"Analyzing..."]});case"completed":return m?e.jsxs(b,{variant:"outline",className:"text-purple-600 border-purple-200 bg-purple-50",children:[e.jsx(ee,{className:"h-3 w-3 mr-1"}),"Calendar Attachment"]}):e.jsxs(b,{variant:"outline",className:"text-green-600 border-green-200 bg-green-50",children:[e.jsx(be,{className:"h-3 w-3 mr-1"}),"AI Summary"]});case"failed":return e.jsxs(b,{variant:"outline",className:"text-red-600 border-red-200 bg-red-50",children:[e.jsx(ke,{className:"h-3 w-3 mr-1"}),"Analysis Failed"]});case"skipped":return e.jsx(b,{variant:"outline",className:"text-gray-600 border-gray-200 bg-gray-50",children:"File Type Not Supported"});default:return null}};return h&&x?e.jsx(Us,{entries:R,deletedFiles:ie,isLoadingDeleted:Re,deletedFilesError:rs,onDownload:Ae,getFileIcon:le,getAnalysisStatusBadge:De,getActivityTypeColor:ue,formatActivityType:W,properties:Ke}):as?e.jsx("div",{className:"container mx-auto p-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"h-8 bg-gray-200 rounded animate-pulse"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(6)].map((s,t)=>e.jsx("div",{className:"h-48 bg-gray-200 rounded animate-pulse"},t))})]})}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"container-mobile py-12 space-y-12",children:[e.jsxs("div",{className:"flex flex-col space-y-4",children:[e.jsxs("div",{className:"flex flex-col mb-6",children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-gray-900 dark:text-gray-100 mb-2 md:hidden","data-tour":"files-header",children:"File Vault"}),e.jsx("h1",{className:"text-3xl md:text-4xl font-extrabold tracking-tight text-gray-900 dark:text-gray-100 hidden md:block","data-tour":"files-header",children:"File Vault"}),e.jsxs("p",{className:"text-gray-500 dark:text-gray-400 mt-1 text-sm md:text-base",children:["Secure storage and management of all uploaded evidence files from your time entries â"," ",e.jsxs("span",{className:"text-green-600 font-semibold",children:[R.length," entr",R.length!==1?"ies":"y"," ⢠",ne," ","file",ne!==1?"s":""]})]})]}),e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4 lg:items-center lg:justify-between mb-6","data-tour":"files-upload",children:[e.jsxs("div",{className:"hidden md:flex flex-col sm:flex-row gap-3 lg:items-center",children:[e.jsxs("div",{className:"relative flex-1 sm:flex-none sm:w-80",children:[e.jsx(ms,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}
17),e.jsx(xs,{placeholder:"Search files, descriptions, or activities...",value:i,onChange:s=>c(s.target.value),className:"pl-10 text-md rounded-lg border-gray-300 dark:border-gray-700 focus:ring-2 focus:ring-green-500"})]}),e.jsxs(ps,{value:C,onValueChange:N,children:[e.jsx(us,{className:"w-full sm:w-44 text-sm rounded-lg border-gray-300 dark:border-gray-700 focus:ring-2 focus:ring-green-500",children:e.jsx(gs,{placeholder:"Filter files..."})}),e.jsxs(hs,{children:[e.jsx(je,{value:"all",children:"All Files"}),e.jsx(je,{value:"pdf",children:"PDF Documents"}),e.jsx(je,{value:"image",children:"Images"}),e.jsx(je,{value:"document",children:"Word Documents"})]})]})]}),e.jsxs("div",{className:"hidden md:flex gap-2",children:[e.jsx(k,{variant:v==="grid"?"default":"outline",size:"icon",onClick:()=>l("grid"),className:"h-9 w-9 rounded-lg shadow-sm transition-colors",children:e.jsx(Ps,{className:"h-4 w-4"})}),e.jsx(k,{variant:v==="list"?"default":"outline",size:"icon",onClick:()=>l("list"),className:"h-9 w-9 rounded-lg shadow-sm transition-colors",children:e.jsx(ys,{className:"h-4 w-4"})})]})]}),e.jsxs(fs,{value:A,onValueChange:s=>F(s),className:"mt-4",children:[e.jsxs(js,{className:"grid w-full max-w-md grid-cols-2",children:[e.jsxs(Ue,{value:"active",className:"flex items-center gap-2",children:[e.jsx(P,{className:"h-4 w-4"}),"Active Files",ne>0&&e.jsx(b,{variant:"secondary",className:"ml-1",children:ne})]}),e.jsxs(Ue,{value:"deleted",className:"flex items-center gap-2",children:[e.jsx(Z,{className:"h-4 w-4"}),"Deleted Files",ie.length>0&&e.jsx(b,{variant:"destructive",className:"ml-1",children:ie.length})]})]}),e.jsx(_e,{value:"active",className:"mt-6",children:R.length===0?e.jsx(V,{children:e.jsxs(G,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(P,{className:"h-12 w-12 text-gray-400 mb-4 text-green-600"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-600 dark:text-gray-400 mb-2",children:"NO ENTRIES WITH FILES FOUND"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-center text-sm italic",children:ne===0?"Upload evidence files in your time entries to see them here.":"No entries match your current search or filter criteria."})]})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"md:hidden",children:e.jsx(Ye,{entries:R,onPreview:(s,t)=>{J(s),w(t),$(s[t]),S(!0)},onDownload:Ae,onDelete:Ce,getFileIcon:le,getAnalysisStatusBadge:De,getActivityTypeColor:ue,formatActivityType:W,properties:Ke})}),e.jsx("div",{className:`${v==="grid"?"hidden md:grid md:grid-cols-2 lg:grid-cols-4 gap-6":"hidden md:block space-y-4"} files-table`,"data-tour":"files-management",children:R.map(s=>{var a,m,n;const t=g.has(s.timeEntry.id);return v==="list"?e.jsx(V,{className:"border border-gray-200 dark:border-gray-700 rounded-xl transition-colors duration-200 hover:border-green-600 focus:outline-none",children:e.jsx(G,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row justify-between gap-4 md:gap-6",children:[e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:gap-3",children:[e.jsxs(Me,{className:"flex items-center gap-2 text-lg font-semibold text-gray-900 dark:text-gray-100",children:[e.jsx(ce,{className:"h-5 w-5 text-green-600 flex-shrink-0"}),e.jsx("span",{children:((a=s.timeEntry.property)==null?void 0:a.nickname)||"No Property Assigned"})]}),e.jsxs("span",{className:"mt-1 sm:mt-0 inline-flex items-center text-xs px-2 py-0.5 rounded-md border bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300",children:[e.jsx(ee,{className:"h-3.5 w-3.5 mr-1 text-green-600 flex-shrink-0"}),U(new Date(s.timeEntry.date),"MMM dd")]})]}),s.timeEntry.property&&e.jsxs("p",{className:"flex items-center gap-2 text-sm text-gray-500 leading-relaxed",children:[e.jsx(bs,{className:"h-4 w-4 text-green-600 flex-shrink-0"}),e.jsxs("span",{children:[s.timeEntry.property.address,","," ",s.timeEntry.property.city,","," ",s.timeEntry.property.state]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 mt-2",children:[e.jsxs(b,{className:`text-xs font-medium px-3 py-1 rounded-md ${ue(s.timeEntry.activityType)}`,children:[e.jsx(Te,{className:"h-3.5 w-3.5 mr-1"}),W(s.timeEntry.activityType)]}),e.jsxs(b,{variant:"outline",className:"text-xs font-medium px-3 py-1 rounded-md",children:[$e(s.timeEntry.hours)," ","hrs"]}),e.jsxs(b,{variant:"secondary",className:"text-xs font-medium px-3 py-1 rounded-md",children:[s.files.length," file",s.files.length!==1&&"s"]})]})]}),s.files.length>0&&e.jsx("div",{className:"flex items-center gap-2 mt-2",children:e.jsxs(k,{onClick:()=>{J(s.files),w(0),$(s.files[0]),S(!0)},className:"flex-1 flex items-center justify-center gap-2 text-sm font-medium bg-white text-green-600 border border-green-600 rounded-md hover:bg-green-50 hover:text-green-700 transition-colors",children:[e.jsx(Pe,{className:"h-4 w-4 text-green-600"}),e.jsx("span",{children:"View Evidence"})]})})]})})},s.timeEntry.id):e.jsxs(V,{className:"border border-gray-200 dark:border-gray-700 hover:border-green-500 dark:hover:border-green-500 transition-colors duration-200 rounded-2xl shadow-sm bg-white dark:bg-gray-900 overflow-hidden",children:[e.jsxs(qe,{className:"p-4 sm:p-6 space-y-4 sm:sp
17ace-y-6 min-w-0",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2 sm:gap-4 min-w-0",children:[e.jsxs(b,{variant:"outline",className:"flex items-center text-[10px] sm:text-[11px] font-medium px-2 sm:px-2.5 py-1.5 rounded-md flex-shrink-0 w-fit max-w-full",children:[e.jsx(ee,{className:"h-3 w-3 sm:h-3.5 sm:w-3.5 mr-1 text-green-600 flex-shrink-0"}),e.jsx("span",{className:"whitespace-nowrap overflow-hidden text-ellipsis",children:U(new Date(s.timeEntry.date),"MMM dd, yyyy")})]}),e.jsxs(b,{variant:"secondary",className:"flex items-center bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-gray-700 text-[10px] sm:text-[11px] font-medium px-2 sm:px-2.5 py-1.5 rounded-md flex-shrink-0 w-fit max-w-full",children:[e.jsx(we,{className:"h-3 w-3 sm:h-3.5 sm:w-3.5 mr-1 flex-shrink-0"}),e.jsxs("span",{className:"whitespace-nowrap overflow-hidden text-ellipsis",children:[$e(s.timeEntry.hours)," ","hrs"]})]})]}),e.jsxs(Me,{className:"text-lg sm:text-xl font-semibold tracking-tight flex items-center gap-2 text-gray-900 dark:text-gray-100 min-w-0 max-w-full",children:[e.jsx(ce,{className:"h-4 w-4 sm:h-5 sm:w-5 text-emerald-600 flex-shrink-0"}),e.jsx("span",{className:"truncate min-w-0",title:((m=s.timeEntry.property)==null?void 0:m.nickname)||"No Property Assigned",children:((n=s.timeEntry.property)==null?void 0:n.nickname)||"No Property Assigned"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 sm:gap-4 min-w-0",children:[e.jsx("div",{className:"min-w-0 max-w-full",children:e.jsxs(b,{className:`${ue(s.timeEntry.activityType)} flex items-center border text-[10px] sm:text-[11px] font-medium px-2 sm:px-2.5 py-1.5 rounded-md flex-shrink-0 w-fit max-w-full`,children:[e.jsx(Te,{className:"h-3 w-3 sm:h-3.5 sm:w-3.5 mr-1 flex-shrink-0"}),e.jsx("span",{className:"whitespace-nowrap overflow-hidden text-ellipsis",children:W(s.timeEntry.activityType)})]})}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 min-w-0",children:[e.jsx("span",{className:"text-xs font-medium text-gray-500 whitespace-nowrap overflow-hidden text-ellipsis",children:"Entry Files"}),e.jsx(b,{variant:"secondary",className:"flex-shrink-0",children:s.files.length})]})]}),e.jsx("div",{className:"p-3 sm:p-4 bg-gray-50 dark:bg-gray-800 rounded-lg h-24 sm:h-28 overflow-hidden",children:e.jsx("div",{className:"h-full overflow-y-auto",children:s.timeEntry.description?e.jsx("p",{className:"text-xs sm:text-sm italic text-gray-700 dark:text-gray-300 leading-relaxed whitespace-pre-line break-words",children:s.timeEntry.description}):e.jsx("p",{className:"text-xs sm:text-sm italic text-gray-400 dark:text-gray-500 flex items-center justify-center h-full",children:"No description provided"})})}),s.files.length>0&&e.jsx("div",{className:"flex items-center gap-2 mt-2 min-w-0",children:e.jsxs(k,{onClick:()=>ss(s.timeEntry),className:"w-full flex items-center justify-center gap-2 text-xs sm:text-sm font-medium bg-green-600 text-white hover:bg-green-700 px-4 py-3 min-h-[44px]",children:[e.jsx(P,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"whitespace-nowrap overflow-hidden text-ellipsis",children:"Preview Evidence"})]})})]}),t&&e.jsx(G,{className:"pt-0 border-t bg-gray-50 dark:bg-gray-800",children:e.jsxs("div",{className:"py-6",children:[e.jsxs("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-6 flex items-center",children:[e.jsx(P,{className:"h-5 w-5 mr-2 text-green-600"}),"Evidence Files & AI Analysis"]}),e.jsx("div",{className:"space-y-6 pl-4 dark:border-gray-700",children:s.files.map((r,M)=>e.jsxs("div",{className:"border rounded-xl p-5 hover:border-gray-300 transition-colors bg-white dark:bg-gray-900 shadow-sm ml-8 relative",children:[e.jsx("div",{className:"absolute -left-8 top-5 w-6 h-6 bg-blue-500 text-white rounded-full flex items-center justify-center text-xs font-bold",children:M+1}),e.jsxs("div",{className:"flex items-start gap-4",children:[le(r.fileName,"h-10 w-10"),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("h4",{className:"font-medium text-sm md:text-base text-gray-900 dark:text-gray-100 truncate",children:r.originalName||r.fileName}),r.filePath&&(r.filePath.startsWith("http://")||r.filePath.startsWith("https://"))&&e.jsxs(b,{variant:"outline",className:"text-xs flex-shrink-0",children:[e.jsx(vs,{className:"w-3 h-3 mr-1"}),"External"]}
17)]}),e.jsx("div",{className:"flex gap-2 ml-4",children:De(r.aiAnalysisStatus,r.fileName,r.aiSummary)})]}),e.jsx("div",{className:"flex justify-end mb-4",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(k,{size:"sm",variant:"outline",onClick:()=>{const Q=s.files,B=Q.findIndex(H=>H.id===r.id);J(Q),w(B),$(r),S(!0)},className:"h-8 px-3 text-xs",children:[e.jsx(Pe,{className:"h-4 w-4 mr-1 text-green-600"}),"Preview"]}),e.jsxs(k,{size:"sm",variant:"outline",onClick:()=>Ae(r.fileUrl,r.originalName||r.fileName),className:"h-8 px-3 text-xs",children:[e.jsx(He,{className:"h-4 w-4 mr-1 text-green-600"}),"Download"]}),r.publicToken&&e.jsxs(k,{size:"sm",variant:"outline",onClick:()=>ts(r.publicToken),className:"h-8 px-3 text-xs",children:[e.jsx(Ls,{className:"h-4 w-4 mr-1 text-green-600"}),"Copy Link"]}),e.jsxs(k,{size:"sm",variant:"outline",onClick:()=>Ce(r),className:"h-8 px-3 text-xs hover:bg-red-50 hover:border-red-300 dark:hover:bg-red-900/20",children:[e.jsx(Z,{className:"h-4 w-4 mr-1 text-red-500"}),"Delete"]})]})}),Ee?r.aiSummary&&r.aiAnalysisStatus==="completed"&&e.jsxs("div",{className:"mt-4 p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:[e.jsxs("div",{className:"flex items-center mb-3",children:[e.jsx(be,{className:"h-4 w-4 mr-2"}),e.jsx("span",{className:"font-semibold text-xs",children:"AI Analysis Summary"})]}),e.jsx("div",{className:"ai-summary-formatted text-sm text-gray-700 dark:text-gray-300",children:I.has(parseInt(r.id.replace(/^(new-|legacy-)/,"")))?e.jsxs(e.Fragment,{children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:Be(r.aiSummary)}}),e.jsx("button",{onClick:()=>Oe(parseInt(r.id.replace(/^(new-|legacy-)/,""))),className:"text-blue-600 hover:text-blue-800 ml-2 font-medium text-xs mt-2 inline-block",children:"Show less"})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:Be(r.aiSummary.substring(0,400))}}),r.aiSummary.length>400&&e.jsx("button",{onClick:()=>Oe(parseInt(r.id.replace(/^(new-|legacy-)/,""))),className:"text-blue-600 hover:text-blue-800 ml-2 font-medium text-xs mt-2 inline-block",children:"Read more..."})]})})]}):r.aiSummary&&r.aiAnalysisStatus==="completed"&&e.jsxs("div",{className:"mt-4 p-4 border border-yellow-200 bg-yellow-50 dark:bg-yellow-900/20 dark:border-yellow-800 rounded-lg",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx(be,{className:"h-4 w-4 mr-2 text-gray-400"}),e.jsx("span",{className:"font-semibold text-xs text-gray-500",children:"AI Analysis Summary"})]}),e.jsx(Ns,{className:"h-4 w-4 text-yellow-500"})]}),e.jsxs("div",{className:"text-gray-500 text-center py-3",children:[e.jsx(ws,{className:"h-5 w-5 mx-auto mb-2 text-gray-400"}),e.jsx("p",{className:"text-sm mb-2",children:"Upgrade to Pro to access AI file analysis"}),e.jsx(k,{size:"sm",className:"mt-1 h-8 text-xs px-3",onClick:()=>xe(!0),children:"Upgrade Now"})]})]})]})]})]},r.id))})]})})]},s.timeEntry.id)})})]})}),e.jsx(_e,{value:"deleted",className:"mt-6",children:Re?e.jsx(V,{children:e.jsx(G,{className:"flex items-center justify-center py-12",children:e.jsx(Qe,{className:"h-8 w-8 animate-spin text-gray-400"})})}):ie.length===0?e.jsx(V,{children:e.jsxs(G,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Z,{className:"h-12 w-12 text-gray-400 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-600 dark:text-gray-400 mb-2",children:"No Deleted Files"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-center text-sm italic",children:"Files you delete will appear here for 30 days before being permanently removed."})]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-950/30 p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ke,{className:"h-5 w-5 text-amber-600 dark:text-amber-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-amber-800 dark:text-amber-300",children:"30-Day Restoration Period"}),e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-400 mt-1",children:'These files will be permanently deleted after their scheduled deletion date. Click "Restore" to move a file back to your active files.'})]})]})}),e.jsx("div",{className:`${v==="grid"?"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6":"space-y-4"}`,children:ie.map(s=>{var M,Q,B,H;const t=new Date(s.scheduledDeletionAt),a=new Date,m=t.getTime()-a.getTime(),n=Math.ceil(m/(1e3*60*60*24));if(v==="list"){const de=re.find(is=>is.id===s.timeEntryId);return e.jsx(V,{className:"border border-gray-200 dark:border-gray-700",children:e.jsx(G,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[le(s.fileName,"h-8 w-8"),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 truncate",children:s.originalName||s.fileName}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-sm text-gray-500",children:[e.jsxs("span",{children:["Deleted"," ",U(new Date(s.deletedAt),"MMM d, yyyy")]}),s.fileSize&&e.jsxs("span",{children:[Math.round(s.fileSize/1024)," KB"]}
17),de&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),e.jsxs("span",{className:"flex items-center gap-1",title:(M=de.property)==null?void 0:M.nickname,children:[e.jsx(ce,{className:"h-3 w-3"}),((Q=de.property)==null?void 0:Q.nickname)||"No Property"]})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[e.jsxs(b,{variant:n<=7?"destructive":"secondary",className:"whitespace-nowrap",children:[e.jsx(we,{className:"h-3 w-3 mr-1"}),n>0?`${n} day${n!==1?"s":""} left`:"Expires today"]}),e.jsxs(k,{size:"sm",variant:"outline",onClick:()=>Ie(s),className:"whitespace-nowrap",children:[e.jsx(Le,{className:"h-4 w-4 mr-1 text-green-600"}),"Restore"]})]})]})})},s.id)}const r=re.find(de=>de.id===s.timeEntryId);return e.jsxs(V,{className:"border border-gray-200 dark:border-gray-700 hover:border-green-500 dark:hover:border-green-500 transition-colors duration-200 flex flex-col h-full",children:[e.jsxs(qe,{className:"p-4 pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"p-2 bg-gray-100 dark:bg-gray-800 rounded-lg",children:le(s.fileName,"h-6 w-6")}),e.jsx(b,{variant:n<=7?"destructive":"secondary",className:"whitespace-nowrap text-[10px]",children:n>0?`${n} days left`:"Expires today"})]}),e.jsx(Me,{className:"text-base font-medium mt-3 truncate",title:s.originalName||s.fileName,children:s.originalName||s.fileName})]}),e.jsxs(G,{className:"p-4 pt-0 flex-1 flex flex-col justify-between",children:[e.jsxs("div",{className:"space-y-3 mb-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-xs text-gray-500 flex items-center",children:[e.jsx(Z,{className:"h-3 w-3 mr-1.5"}),"Deleted"," ",U(new Date(s.deletedAt),"MMM d, yyyy")]}),s.fileSize&&e.jsxs("p",{className:"text-xs text-gray-500 pl-4.5",children:[Math.round(s.fileSize/1024)," KB"]})]}),r&&e.jsxs("div",{className:"pt-3 border-t border-gray-100 dark:border-gray-800 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx(ce,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",title:(B=r.property)==null?void 0:B.nickname,children:((H=r.property)==null?void 0:H.nickname)||"No Property"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx(Te,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",title:W(r.activityType),children:W(r.activityType)})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx(ee,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{children:U(new Date(r.date),"MMM d, yyyy")})]})]})]}),e.jsxs(k,{size:"sm",variant:"outline",onClick:()=>Ie(s),className:"w-full mt-auto",children:[e.jsx(Le,{className:"h-3.5 w-3.5 mr-1.5 text-green-600"}),"Restore File"]})]})]},s.id)})})]})})]})]}),j&&e.jsx(ks,{open:!!j,onOpenChange:()=>X(null),children:e.jsxs(Ss,{className:"max-w-4xl max-h-[80vh] overflow-y-auto rounded-xl shadow-lg",children:[e.jsxs(Es,{className:"pb-4 border-b",children:[e.jsxs(Cs,{className:"flex items-center space-x-2 text-xl font-bold text-gray-900 dark:text-gray-100",children:[e.jsx(ee,{className:"h-5 w-5 text-green-600"}),e.jsxs("span",{children:["Activity Entry Files â"," ",U(new Date(j.timeEntry.date),"MMM dd, yyyy")]})]}),e.jsx(As,{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:"Review all files attached to this activity entry, including AI analysis summaries and file actions."})]}),e.jsxs("div",{className:"space-y-6 pt-4",children:[e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 p-5 rounded-lg",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:"Activity:"}),e.jsx("span",{className:"ml-2",children:j.timeEntry.activityType})]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:"Hours:"}),e.jsx("span",{className:"ml-2",children:$e(j.timeEntry.hours)})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:"Description:"}),e.jsx("span",{className:"ml-2",children:j.timeEntry.description})]}),j.timeEntry.property&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:"Property:"}),e.jsx("span",{className:"ml-2",children:j.timeEntry.property.nickname})]})]})}),e.jsxs("div",{className:"flex justify-between items-center pt-5 border-t",children:[e.jsxs(k,{variant:"outline",onClick:()=>{X(null),window.location.href="/activity-ledger"},className:"flex items-center space-x-2",children:[e.jsx(Fs,{className:"h-4 w-4 text-emerald-600"}),e.jsx("span",{children:"Back to Activity Ledger"})]}),e.jsxs(k,{variant:"ghost",onClick:()=>X(null),className:"flex items-center space-x-2",children:[e.jsx(Ds,{className:"h-4 w-4 text-emerald-600"}),e.jsx("span",{children:"Close"})]})]})]})]})}),D&&e.jsx(Ze,{file:D,isOpen:se,onClose:()=>{S(!1),$(null),w(0)},hasActiveSubscription:!0,allFiles:D.allFiles||[],currentFileIndex:oe,onFileChange:s=>{if(D.allFiles&&D.allFiles[s]){const t=D.allFiles[s];w(s),$({...D,id:t.numericId||t.id,numericId:t.numericId||t.id,originalName:t.originalName||t.fileName,fileName:t.fileName,fileUrl:t.fileUrl,uploadedAt:t.uploadedAt||t.createdAt,fileSize:t.fileSize,mimeType:t.mimeType||Fe(t.fileName),aiSummary:t.aiSummary,aiAnalysisStatus:t.aiAnalysisStatus,r2Key:t.r2Key,storageType:t.storageType,publicToken:t.publicToken})}},onDelete:Ce}),e.jsx(Ms,{isOpen:me,onClose:()=>xe(!1)}),e.jsx(Je,{open:te,onOpenChange:O,fileName:(y==null?void 0:y.originalName)||(y==null?void 0:y.fileName)||"",onConfirm:We,isDeleting:E.isPending}),e.jsx(Xe,{open:z,onOpenChange:q,fileName:(f==null?void 0:f.originalName)||(f==null?void 0:f.fileName)||"",scheduledDeletionAt:(f==null?void 0:f.scheduledDeletionAt)||new Date,onConfirm:es,isRestoring:Y.isPending})]})})}export{et 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.