1import{z as ts,a7 as Q,j as e,bx as ye,q as de,aJ as qe,c$ as rs,aK as J,bo as ve,bO as is,H as ns,e as T,d0 as oe,aL as se,B as w,bn as Be,aB as we,ao as ls,C as H,d as me,aZ as Oe,U as Ye,aM as ge,a as ae,aE as ke,r as Ke,p as cs,aH as ds,d1 as os,k as ce,cu as De,aC as ms,Z as xs,d2 as us,d3 as hs,d4 as gs,b1 as xe,b2 as ue,b3 as Te,b4 as he,b5 as $e,aq as Fe,d5 as ps,cU as ys,b6 as js,W as Se,D as fs,ae as ee,Y as Ne,F as le,bg as bs,a5 as je,aT as Ns,aU as vs,aV as Pe,aW as L,aX as ws,aY as z,i as ks,bj as Ts,cz as Fs,b_ as He,cX as Ms,b$ as Ve,c0 as _e,c1 as Ge,c2 as Xe,c3 as Ze,c4 as Je,c5 as es,aN as Me,d6 as Cs,L as R,bL as Ds,d7 as Ss,d8 as Ps,a0 as As,a1 as Es,a2 as Is,a3 as Us,a4 as Ae,bp as Ee,aF as Ls,X as zs,bX as Rs,b7 as Qs,d9 as Ws,da as qs,bb as Bs,bc as Os,bd as Ys,db as Ks,aG as $s,cy as Hs,dc as Vs,R as _s,V as Gs,b as G,aS as X,c as Z,G as Xs,I as Zs,J as Ie,K as Ue}from"./index-DGo-vssZ.js";import{r as g}from"./vendor-Qgthw7N1.js";import{M as Js,m as te}from"./memberService-B-f_co3d.js";import{u as ss}from"./useMemberProfile-C1TnB_eM.js";import{M as ea}from"./maximize-2-6AmOphWr.js";import{F as Le}from"./file-image-DUgfxpHG.js";import{u as sa,a as fe}from"./use-transform-CDjFxHsE.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 ze=ts("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);function aa({entry:s,onEdit:l,onDelete:t,onView:n,showRecordedBy:i=!1}){const{impactMedium:c}=rs(),x=sa(0),f=fe(x,[-100,0,100],["#ef4444","#ffffff","#22c55e"]),o=fe(x,[-100,-50,0],[1,.5,0]),p=fe(x,[0,50,100],[0,.5,1]),j=(y,N)=>{N.offset.x<-100&&t?(c(),t(s)):N.offset.x>100&&l&&(c(),l(s))},d=y=>
6{const N=Math.floor(y),u=Math.round((y-N)*60);return N===0?`${u}m`:u===0?`${N}h`:`${N}h ${u}m`},h=()=>s.property?s.property.nickname||s.property.address:"No property";return e.jsxs("div",{className:"relative overflow-hidden rounded-xl border border-gray-100 bg-white shadow-sm dark:border-gray-800 dark:bg-gray-900",children:[e.jsxs(J.div,{className:"absolute inset-0 flex items-center justify-between px-6",style:{background:f},children:[e.jsx(J.div,{className:"flex items-center text-white",style:{opacity:o},children:e.jsx(ve,{className:"w-4 h-4 mr-2"})}),e.jsx(J.div,{className:"flex items-center text-white",style:{opacity:p},children:e.jsx(is,{className:"w-4 h-4 ml-2"})})]}),e.jsxs(J.div,{drag:"x",dragConstraints:{left:0,right:0},dragElastic:.1,onDragEnd:j,style:{x},className:se("relative z-10 flex cursor-pointer items-start justify-between bg-white px-4 py-4 active:bg-gray-50 dark:bg-gray-900 dark:active:bg-gray-800"),whileTap:{scale:.995},onClick:y=>{y.target.closest("button")||n==null||n(s)},children:[e.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 pr-4 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-1.5 truncate text-sm font-semibold text-gray-900 dark:text-gray-100",children:[e.jsx(ns,{className:"h-3.5 w-3.5 flex-shrink-0 text-green-600"}),h()]}),e.jsx("span",{className:"truncate text-xs text-gray-500 dark:text-gray-400",children:s.activityType}),s.description&&e.jsx("span",{className:"truncate text-xs text-gray-400 dark:text-gray-500",children:s.description.length>45?`${s.description.substring(0,45)}...`:s.description}),i&&s.recordedBy&&e.jsxs(T,{variant:"secondary",className:"mt-1 w-fit bg-blue-50 text-[10px] text-blue-700",children:["By: ",s.recordedBy]}),e.jsxs("div",{className:"flex gap-1 mt-1 flex-wrap",children:[s.isMaterialParticipation&&e.jsx(T,{variant:"default",className:"px-1 py-0 text-[9px]",children:"Material"}),s.isQualifiedNonMaterial&&e.jsx(T,{variant:"secondary",className:"px-1 py-0 text-[9px]",children:"Qualified"}),s.evidenceFiles&&s.evidenceFiles.length>0&&e.jsxs(T,{variant:"outline",className:"flex items-center gap-0.5 px-1 py-0 text-[9px]",children:[e.jsx(oe,{className:"w-2.5 h-2.5"}),s.evidenceFiles.length]})]})]}),e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:e.jsx("span",{className:"rounded-full bg-green-50 px-2.5 py-1 text-xs font-semibold text-green-700 dark:bg-green-950/40 dark:text-green-300",children:d(s.hours)})})]})]})}function ta({entries:s,onEdit:l,onDelete:t,onView:n,isLoading:i=!1,emptyMessage:c="No time entries found",showRecordedBy:x=!1}){const f=g.useMemo(()=>{const o=[];return[...s].sort((j,d)=>{const h=new Date(j.date).getTime();return new Date(d.date).getTime()-h}).forEach(j=>{let d="Unknown Date";try{d=Q(new Date(j.date),"EEE, MMM d")}catch{}const h=o[o.length-1];if(h&&h.date===d){h.items.push(j);return}o.push({date:d,items:[j]})}),o},[s]);return i?e.jsx("div",{className:"space-y-3 py-2",children:[1,2,3,4,5].map(o=>e.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-gray-100 bg-white p-4 shadow-sm dark:border-gray-800 dark:bg-gray-900",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{className:"h-4 w-32 rounded-md"}),e.jsx(ye,{className:"h-3 w-20 rounded-md"})]}),e.jsx(ye,{className:"h-4 w-16 rounded-md"})]},o))}):s.length===0?e.jsxs("div",{className:"rounded-2xl bg-white py-12 text-center shadow-sm dark:bg-gray-800",children:[e.jsx(de,{className:"mx-auto mb-4 h-12 w-12 text-gray-300 dark:text-gray-600"}),e.jsx("p",{className:"font-medium text-gray-500 dark:text-gray-400",children:c})]}):e.jsx("div",{className:"pb-4",children:e.jsx(qe,{children:f.map(o=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"px-1 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:o.date}),e.jsx("div",{className:"space-y-2",children:o.items.map(p=>e.jsx(aa,{entry:p,onEdit:l,onDelete:t,onView:n,showRecordedBy:x},p.id))})]},o.date))})})}function be({label:s,value:l}){return e.jsx(H,{className:"rounded-2xl border-gray-100 bg-white shadow-sm dark:border-gray-800 dark:bg-gray-800",children:e.jsxs(me,{className:"p-3",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:s}),e.jsx("p",{className:"mt-1 text-2xl font-bold tracking-tight text-gray-900 dark:text-white",children:l})]})})}function ra({activeTab:s,onTabChange:l}){const t=[{value:"own",label:"My Entries",icon:e.jsx(Oe,{className:"h-3.5 w-3.5"})},{value:"all",label:"All Entries",icon:e.jsx(Ye,{className:"h-3.5 w-3.5"})}];return e.jsx("div",{className:"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":"Entry scope",children:t.map(n=>{const i=s===n.value;return e.jsxs("button",{type:"button",role:"tab","aria-selected":i,onClick:()=>
6l(n.value),className:se("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",i?"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:[n.icon,n.label]},n.value)})})})}function ia({activeData:s,activeLoading:l,activeError:t,activeTab:n,canCreateEntries:i,canViewAll:c,thisMonthCount:x,thisWeekCount:f,onTabChange:o,onCreate:p,onView:j,onEdit:d,onDelete:h}){const y=(s==null?void 0:s.entries)??[];return e.jsxs(e.Fragment,{children:[e.jsx(Js,{title:"Time Entries",subtitle:"Team member portal",rightAction:i?e.jsx(w,{type:"button",size:"icon",onClick:p,className:"h-11 w-11 rounded-2xl shadow-sm active:scale-95","aria-label":"Add time entry",children:e.jsx(Be,{className:"h-5 w-5"})}):null}),!i&&e.jsx("div",{className:"rounded-2xl border border-blue-200 bg-blue-50 p-4 dark:border-blue-800 dark:bg-blue-950/30",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(we,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-blue-600 dark:text-blue-400"}),e.jsx("p",{className:"text-sm leading-relaxed text-blue-800 dark:text-blue-200",children:"You can view entries, but your account owner has not enabled time entry creation."})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(be,{label:"Total",value:(s==null?void 0:s.total)??0}),e.jsx(be,{label:"Month",value:x}),e.jsx(be,{label:"Week",value:f})]}),c&&e.jsx(ra,{activeTab:n,onTabChange:o}),t&&e.jsx("div",{className:"rounded-2xl border border-red-100 bg-red-50 p-4 text-red-700 dark:border-red-900 dark:bg-red-950/30 dark:text-red-300",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(ls,{className:"mt-0.5 h-5 w-5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:"Failed to load entries"}),e.jsx("p",{className:"mt-1 text-xs opacity-80",children:t.message})]})]})}),e.jsx(ta,{entries:y,isLoading:l,emptyMessage:n==="own"?"No time entries yet":"No workspace entries found",showRecordedBy:n==="all",onView:j,onEdit:i?d:void 0,onDelete:i?h:void 0})]})}function na(s){return Ke({queryKey:["member-time-entries","own",s],queryFn:()=>te.getTimeEntries({...s,scope:"own"})})}function la(s){return Ke({queryKey:["member-time-entries","all",s],queryFn:()=>te.getTimeEntries({...s,scope:"all"})})}function ca(){const s=ge(),{toast:l}=ae();return ke({mutationFn:t=>te.createTimeEntry(t),onMutate:async t=>{await s.cancelQueries({queryKey:["member-time-entries"]});const n=s.getQueriesData({queryKey:["member-time-entries"]}),i=Date.now(),c={id:i,...t};return s.setQueriesData({queryKey:["member-time-entries"]},x=>x&&{...x,entries:[c,...x.entries],total:x.total+1}),{previousData:n,tempId:i}},onSuccess:(t,n,i)=>{s.setQueriesData({queryKey:["member-time-entries"]},c=>c&&{...c,entries:c.entries.map(x=>x.id===i.tempId?t:x)}),s.invalidateQueries({queryKey:["member-stats"]}),l({title:"Time Entry Created",description:"Your time entry has been logged successfully."})},onError:(t,n,i)=>{i!=null&&i.previousData&&i.previousData.forEach(([c,x])=>{s.setQueryData(c,x)}),l({title:"Error",description:t.message||"Failed to create time entry",variant:"destructive"})}})}function da(){const s=ge(),{toast:l}=ae();return ke({mutationFn:({id:t,data:n})=>te.updateTimeEntry(t,n),onMutate:async({id:t,data:n})=>{await s.cancelQueries({queryKey:["member-time-entries"]});const i=s.getQueriesData({queryKey:["member-time-entries"]});return s.setQueriesData({queryKey:["member-time-entries"]},c=>c&&{...c,entries:c.entries.map(x=>x.id===t?{...x,...n}:x)}),{previousData:i}},onSuccess:t=>{s.setQueriesData({queryKey:["member-time-entries"]},n=>n&&{...n,entries:n.entries.map(i=>i.id===t.id?t:i)}),s.invalidateQueries({queryKey:["member-stats"]}),l({title:"Time Entry Updated",description:"Your changes have been saved."})},onError:(t,n,i)=>{i!=null&&i.previousData&&i.previousData.forEach(([c,x])=>{s.setQueryData(c,x)}),l({title:"Error",description:t.message||"Failed to update time entry",variant:"destructive"})}})}function as(){const s=ge(),{toast:l}=ae();return ke({mutationFn:te.deleteTimeEntry,onMutate:async t=>{await s.cancelQueries({queryKey:["member-time-entries"]});const n=s.getQueriesData({queryKey:["member-time-entries"]});return s.setQueriesData({queryKey:["member-time-entries"]},i=>i&&{...i,entries:i.entries.filter(c=>c.id!==t),total:i.total-1}),{previousData:n}},onSuccess:()=>{s.invalidateQueries({queryKey:["member-stats"]}),l({title:"Time Entry Deleted",description:"Your time entry has been removed."})},onError:(t,n,i)=>{i!=null&&i.previousData&&i.previousData.forEach(([c,x])=>{s.setQueryData(c,x)}),l({title:"Error",description:t.message||"Failed to delete time entry",variant:"destructive"})}})}const oa=({children:s,feature:l,description:t,className:n="",inline:i=!1,showUpgradeButton:c=!0,onUpgrade:x,fallback:f})=>{const[o,p]=g.useState(!1);cs();const{canAccessPremiumFeatures:j}=ds(),{isDemoMode:d,isDemoFeatureBlocked:h}=os();if(!(d?h(l):!j))return e.jsx(e.Fragment,{children:s});const N=()=>{x?x():p(!0)};return i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`relative ${n}`,children:[f||s,e.jsx("div",{className:"absolute inset-0 bg-background/80 backdrop-blur-sm flex items-center justify-center rounded-lg",children:e.jsxs(w,{onClick:N,size:"sm",className:"bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 text-xs px-3 py-1.5 h-7",children:[e.jsx(ce,{className:"w-3 h-3 mr-1"}),"Upgrade to Shield Advisor"]})})]}),e.jsx(De,{isOpen:o,onClose:()=>p(!1),feature:l,upgradeReason:t})]}):e.jsxs(e.Fragment,{children:[e.jsx(H,{className:`border-dashed border-2 border-muted-foreground
6/30 ${n}`,children:e.jsxs(me,{className:"flex flex-col items-center justify-center p-8 text-center space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ms,{className:"w-12 h-12 text-muted-foreground/50"}),e.jsx(ce,{className:"w-6 h-6 text-yellow-500 absolute -top-1 -right-1"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx("h3",{className:"font-semibold text-lg",children:l}),e.jsxs(T,{variant:"secondary",className:"bg-gradient-to-r from-blue-100 to-indigo-100 dark:from-blue-900 dark:to-indigo-900",children:[e.jsx(xs,{className:"w-3 h-3 mr-1"}),"Shield Advisor"]})]}),t&&e.jsx("p",{className:"text-muted-foreground text-sm max-w-md",children:t})]}),c&&e.jsxs(w,{onClick:N,className:"bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700",children:[e.jsx(ce,{className:"w-4 h-4 mr-2"}),"Upgrade to Shield Advisor"]})]})}),e.jsx(De,{isOpen:o,onClose:()=>p(!1),feature:l,upgradeReason:t})]})},ma=us,xa=hs,ua=gs;function Ce({file:s,isOpen:l,onClose:t,hasActiveSubscription:n=!1,onUpgradeClick:i,allFiles:c=[],currentFileIndex:x=0,onFileChange:f,downloadFile:o,onDelete:p}){const[j,d]=g.useState(!0),[h,y]=g.useState(null),[N,u]=g.useState(!1),[F,M]=g.useState(!1),[P,O]=g.useState(""),[A,C]=g.useState(null),[W,Y]=g.useState(!1),[D,q]=g.useState(null);g.useEffect(()=>{(async()=>{const b=c.length===1?s.numericId:s.id,a=s.storageType==="r2"||s.r2Key;if(C(null),q(null),!(!l||!a||!b||isNaN(b))){Y(!0);try{const m=await fetch(`/api/evidence-files/access/${b}`,{credentials:"include"});if(!m.ok){const _=await m.json().catch(()=>({}));throw new Error(_.message||`Failed to get file URL (${m.status})`)}const k=await m.json();C(k.url)}catch(m){console.error("Failed to fetch R2 presigned URL:",m),q(m instanceof Error?m.message:"Failed to get file URL")}finally{Y(!1)}}})()},[l,s.id,s.numericId,s.storageType,s.r2Key]),g.useEffect(()=>{l&&(y(null),O(""),d(!1))},[l,s.id,s.mimeType]);const{toast:B}=ae(),K=r=>r?r.startsWith("http://")||r.startsWith("https://"):!1,V=r=>r?r.includes("drive.google.com")?"google":r.includes("1drv.ms")||r.includes("sharepoint.com")?"microsoft":"other":"other",E=r=>r.startsWith("image/")?e.jsx(Le,{className:"h-4 w-4"}):r==="application/pdf"?e.jsx(le,{className:"h-4 w-4"}):r.includes("document")||r.includes("word")?e.jsx(ze,{className:"h-4 w-4"}):e.jsx(bs,{className:"h-4 w-4"}),v=r=>r.startsWith("image/")?"Image":r==="application/pdf"?"PDF Document":r.includes("document")||r.includes("word")?"Word Document":"File",I=async()=>{try{const r=A||(s.publicToken?`${window.location.origin}/api/public/evidence/${s.publicToken}`:U());if(!r||r==="#"||r==="#loading"){B({title:"Copy Failed",description:"File URL is not yet available. Please try again.",variant:"destructive"});return}await navigator.clipboard.writeText(r),B({title:"Link Copied",description:"Public file link copied to clipboard."})}catch(r){console.error("Failed to copy public link:",r),B({title:"Copy Failed",description:"Failed to copy link to clipboard.",variant:"destructive"})}},S=r=>r.startsWith("image/")||r==="application/pdf"||r.startsWith("text/")||r==="application/json"||r.includes("officedocument")||r.includes("msword")||r.includes("excel")||r.includes("powerpoint")||r.startsWith("video/")||r.startsWith("audio/")||s.originalName.endsWith(".txt")||s.originalName.endsWith(".csv")||s.originalName.endsWith(".log"),$=r=>{if(r===0)return"0 Bytes";const b=1024,a=["Bytes","KB","MB","GB"],m=Math.floor(Math.log(r)/Math.log(b));return parseFloat((r/Math.pow(b,m)).toFixed(2))+" "+a[m]},pe=r=>{switch(r){case"completed":return e.jsx(T,{variant:"default",className:"bg-green-100 text-green-800 text-xs",children:"Analysis Complete"});case"pending":return e.jsxs(T,{variant:"secondary",className:"bg-yellow-100 text-yellow-800 text-xs",children:[e.jsx(ee,{className:"h-3 w-3 mr-1 animate-spin"}),"Analyzing..."]});case"failed":return e.jsx(T,{variant:"destructive",className:"text-xs",children:"Analysis Failed"});default:return e.jsx(T,{variant:"outline",className:"text-xs",children:"Not Analyzed"})}},U=()=>A||(W&&(s.storageType==="r2"||s.r2Key)?"#loading":s.storageType==="r2"||s.r2Key?"":s.publicToken?`/api/public/evidence/${s.publicToken}`:s.filePath?K(s.filePath)?s.filePath:s.filePath.startsWith("/uploads/")?`/api${s.filePath}`:`/api/uploads/${encodeURIComponent(s.filePath)}`:s.fileUrl?s.fileUrl:s.fileName?`/api/uploads/${encodeURIComponent(s.fileName)}`:"#"),re=r=>{var b;return(b=r.mimeType)!=null&&b.startsWith("image/")?e.jsx("div",{className:"w-16 h-16 bg-gray-50 dark:bg-gray-900/20 rounded-md border flex items-center justify-center flex-shrink-0",children:e.jsx(Le,{className:"h-8 w-8 text-gray-600"})}):r.mimeType==="application/pdf"?e.jsx("div",{className:"w-16 h-16 bg-red-50 dark:bg-red-900/20 rounded-md border flex items-center justify-center flex-shrink-0",children:e.jsx(le,{className:"h-8 w-8 text-red-600"})}):e.jsx("div",{className:"w-16 h-16 bg-gray-100 dark:bg-gray-800 rounded-md border flex items-center justify-center flex-shrink-0",children:E(r.mimeType||"application/octet-stream")})},ie=async r=>{try{const b=await fetch(r);if(!b.ok)throw new Error("Failed to fetch file");const a=await b.text();O(a),d(!1)}catch(b){console.error("Error fetching text content:",b),y("Failed to load text content"),d(!1)}};g.useEffect(()=>{const r=U();(s.mimeType.startsWith("text/")||s.mimeType==="application/json"||s.originalName&&s.originalName.endsWith(".txt")||s.originalName&&s.originalName.endsWith(".csv")||s.originalName&&s.originalName.endsWith(".log"))&&!P&&!h&&ie(r)},[s.mimeType,s.originalName,P,h]);const ne=()=>{if(W&&(s.storageType==="r2"||s.r2Key))return e.jsxs("div",{className:"flex flex-col items-center justify-center p-12 text-center min-h-[400px]",children:[e.jsx(ee,{className:"h-8 w-8 animate-spin mb
6-4 text-primary"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Loading file from cloud storage..."})]});if(D&&(s.storageType==="r2"||s.r2Key))return e.jsxs("div",{className:"flex flex-col items-center justify-center p-12 text-center min-h-[400px]",children:[e.jsx(Ne,{className:"h-8 w-8 text-yellow-600 mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:D}),e.jsx(w,{variant:"outline",onClick:()=>{C(null),q(null)},children:"Retry"})]});if(!S(s.mimeType))return e.jsxs("div",{className:"flex flex-col items-center justify-center p-12 text-center min-h-[400px]",children:[e.jsx("div",{className:"h-16 w-16 bg-gray-100 dark:bg-gray-800 rounded-lg flex items-center justify-center mb-4",children:E(s.mimeType)}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:"Preview not available for this file type"})]});const r=U();if(K(s.filePath||"")){const b=V(s.filePath),a=b==="google"?"Google Drive":b==="microsoft"?"OneDrive":"External Storage";return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-8 space-y-4 min-h-[400px]",children:[b==="google"&&e.jsx("div",{className:"w-16 h-16 bg-blue-50 dark:bg-blue-900/20 rounded-lg flex items-center justify-center",children:e.jsx("svg",{className:"w-10 h-10 text-blue-500",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M12.545 10.239v3.821h5.445c-.712 2.315-2.647 3.972-5.445 3.972a6.033 6.033 0 110-12.064c1.498 0 2.866.549 3.921 1.453l2.814-2.814A9.969 9.969 0 0012.545 2C7.021 2 2.543 6.477 2.543 12s4.478 10 10.002 10c8.396 0 10.249-7.85 9.426-11.748l-9.426-.013z"})})}),b==="microsoft"&&e.jsx("div",{className:"w-16 h-16 bg-blue-50 dark:bg-blue-900/20 rounded-lg flex items-center justify-center",children:e.jsx("svg",{className:"w-10 h-10 text-blue-600",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M11.5 2H2v9.5h9.5V2zm0 10.5H2V22h9.5v-9.5zm10.5 0h-9.5V22h9.5v-9.5zm0-10.5h-9.5v9.5h9.5V2z"})})}),b==="other"&&e.jsx("div",{className:"w-16 h-16 bg-gray-50 dark:bg-gray-800 rounded-lg flex items-center justify-center",children:e.jsx(je,{className:"w-10 h-10 text-gray-400"})}),e.jsx("p",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:s.originalName||"Calendar Attachment"}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400",children:[e.jsx(je,{className:"w-4 h-4"}),e.jsxs("span",{children:["Stored in ",a]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(w,{onClick:()=>window.open(s.filePath,"_blank"),className:"flex items-center gap-2",children:[e.jsx(je,{className:"w-4 h-4"}),"Open in ",a]}),e.jsxs(w,{variant:"outline",onClick:()=>{navigator.clipboard.writeText(s.filePath||""),B({title:"Link Copied",description:"External link copied to clipboard."})},children:[e.jsx(Se,{className:"w-4 h-4 mr-2"}),"Copy Link"]})]}),e.jsxs("p",{className:"text-xs text-gray-400 dark:text-gray-500 max-w-md text-center",children:["This file is stored externally and opens in a new tab. You must have access to the original file in your ",a," account."]})]})}return s.mimeType.startsWith("image/")?e.jsx("div",{className:"flex flex-col items-center min-h-[400px] p-4",children:e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("img",{src:r,alt:s.originalName,className:"max-w-full max-h-[500px] object-contain rounded-lg",onLoad:()=>{d(!1)},onError:()=>{y("Failed to load image")}})})}):s.mimeType==="application/pdf"?e.jsx("div",{className:"w-full min-h-[500px] relative",children:e.jsx("div",{className:"flex-1 bg-white dark:bg-gray-900 rounded-lg border overflow-hidden h-full min-h-[500px]",children:e.jsx("iframe",{src:r,className:"w-full h-full min-h-[500px]",title:s.originalName||"PDF Preview"})})}):s.mimeType.startsWith("text/")||s.mimeType==="application/json"||s.originalName.endsWith(".txt")||s.originalName.endsWith(".csv")||s.originalName.endsWith(".log")?e.jsx("div",{className:"w-full min-h-[500px] relative",children:j?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-50 dark:bg-gray-800 rounded-lg z-10",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ee,{className:"h-8 w-8 animate-spin mx-auto mb-2"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Loading text content..."})]})}):h?e.jsxs("div",{className:"w-full h-full min-h-[400px] flex flex-col items-center justify-center bg-gray-50 dark:bg-gray-800 rounded-lg",children:[e.jsx(le,{className:"h-12 w-12 text-gray-400 mb-2"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4 text-center max-w-md",children:h})]}):e.jsx("div",{className:"w-full h-full min-h-[500px] bg-white dark:bg-gray-900 rounded-lg border",children:e.jsx("textarea",{readOnly:!0,value:P,className:"w-full h-full min-h-[500px] p-4 font-mono text-sm bg-transparent border-none outline-none resize-none",style:{fontFamily:'Monaco, Consolas, "Courier New", monospace'}})})}):s.mimeType.startsWith("video/")?e.jsx("div",{className:"w-full min-h-[400px] flex items-center justify-center p-4",children:e.jsxs("video",{controls:!0,className:"max-w-full max-h-[500px] rounded-lg",onLoadStart:()=>d(!1),onError:()=>y("Failed to load video"),children:[e.jsx("source",{src:r,type:s.mimeType}),"Your browser does not support the video tag."]})}):s.mimeType.startsWith("audio/")?e.jsxs("div",{className:"w-full min-h-[400px] flex flex-col items-center justify-center p-4",children:[e.jsx("div",{className:"mb-4",children:e.jsx(ze,{className:"h-16 w-16 text-gray-400"})}),e.jsxs("audio",{controls:!0,className:"w-full max-w-md",onLoadStart:()=>d(!1),onError:()=>y("Failed to load audio"),children:[e.jsx("source",{src:r,type:s.mimeType}),"Your browser does not support the audio tag."]})]}):s.mimeType.includes("officedocument")||s.mimeType.includes("msword")||s.mimeType.includes("excel")||s.mimeType.includes("powerpoint")?e.jsxs("div",{className:"w-full min-h-[500px] relative",children:[e.jsx("iframe",{src:`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(r)}`,className:"w-full h-full border rounded-lg",title:s.originalName,onLoad:()=>{d(!1)},onError:()=>{d(!1),y("Office document preview not available. Try downloading the file.")},style:{minHeight:"500px"}}),h&&e.jsxs("div",{className:"absolute inset-0 w-full h-full min-h-[400px] flex flex-col items-center justify-center bg-gray-50 dark:bg-gray-800 rounded-lg",children:[e.jsx(le,{className:"h-12 w-12 text-gray-400 mb-2"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4 text-center max-w-md",children:h})]})]}):null};return e.jsxs(xe,{open:l,onOpenChange:t,children:[e.jsxs(ue,{className:"max-w-6xl max-h-[95vh] overflow-hidden flex flex-col","aria-describedby":"file-preview-description",children:[e.jsxs(Te,{className:"flex-shrink-0",children:[e.jsxs(he,{id:"file-preview-title",className:"flex items-center gap-2",children:[E(s.mimeType),s.originalName]}),e.jsx($e,{id:"file-preview-description",className:"text-sm text-muted-foreground",children:"File preview and analysis details for uploaded evidence"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto space-y-4",children:[e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4",children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400 mb-1",children:"Type"}),e.jsx("span",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:v(s.mimeType)})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400 mb-1",children:"Size"}),e.jsx("span",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:s.fileSize?$(s.fileSize):"Unknown"})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400 mb-1",children:"Uploaded"}),e.jsx("span",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:new Date(s.uploadedAt).toLocaleDateString()})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400 mb-1",children:"Analysis"}),e.jsxs("div",{className:"flex items-center gap-1",children:[!n&&e.jsx(ce,{className:"h-3.5 w-3.5 text-yellow-500",title:"Shield Advisor Feature"}),pe(s.aiAnalysisStatus||"pending")]})]})]})}
6),n?e.jsxs(ma,{open:N,onOpenChange:u,children:[e.jsx(xa,{className:"w-full",children:e.jsxs("div",{className:"flex items-center justify-between p-3 bg-blue-50 dark:bg-blue-900/20 rounded-lg hover:bg-blue-100 dark:hover:bg-blue-900/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fe,{className:"h-4 w-4 text-blue-600"}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:"AI Analysis Summary"})]}),N?e.jsx(ps,{className:"h-4 w-4 text-gray-600"}):e.jsx(ys,{className:"h-4 w-4 text-gray-600"})]})}),e.jsx(ua,{children:e.jsx("div",{className:"mt-2 p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:e.jsx("p",{className:"text-sm text-gray-800 dark:text-gray-200 leading-relaxed whitespace-pre-wrap",children:s.aiSummary||"Analyzing, please wait..."})})})]}):e.jsx(oa,{variant:"inline",feature:"AI File Analysis",description:"Get intelligent analysis and summaries of your uploaded evidence files. Our AI reads PDFs, images, and documents to provide relevant insights for IRS compliance and audit readiness.",onUpgrade:i}),c.length>1&&e.jsxs("div",{className:"mt-8 space-y-3",children:[e.jsxs("h4",{className:"font-semibold text-sm text-gray-700 dark:text-gray-300 flex items-center gap-2",children:["All Files",e.jsx("span",{className:"px-2 py-0.5 text-xs font-medium rounded-full bg-yellow-300 text-gray-800",children:c.length})]}),e.jsx(js,{className:"w-full overflow-x-auto",children:e.jsx("div",{className:"flex items-start gap-4 px-1 pt-2 pb-3",children:c.map((r,b)=>e.jsx("div",{className:`flex-shrink-0 flex flex-col items-center justify-center text-center rounded-md transition-all duration-200 7 ${b===x?"ring-2 ring-green-500 ring-offset-2 ring-offset-white dark:ring-offset-gray-900":"hover:ring-1 hover:ring-gray-300 dark:hover:ring-gray-600"}`,onClick:()=>f&&f(b),children:e.jsx("div",{className:"w-16 h-16 overflow-hidden rounded-md",children:re(r)})},r.id))})})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border overflow-hidden",children:[e.jsx("div",{className:"border-b bg-gray-50 dark:bg-gray-900/50 p-4",children:e.jsx("div",{className:"flex items-center justify-end gap-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{size:"icon",variant:"outline",onClick:I,disabled:W,className:"h-9 w-9 flex items-center justify-center",title:"Copy public file link",children:e.jsx(Se,{className:"h-4 w-4 text-green-600"})}),S(s.mimeType)&&e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>M(!0),className:"flex items-center gap-2 text-[#44958C] hover:text-[#44958C] text-sm normal-case",children:[e.jsx(ea,{className:"h-4 w-4"}),"Full View"]}),e.jsx(w,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:U(),download:s.originalName,className:"flex items-center gap-2 text-green-600",children:[e.jsx(fs,{className:"h-4 w-4"}),"Download"]})}),p&&e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>{p(s),t()},className:"flex items-center gap-2 text-red-600 hover:bg-red-50 hover:border-red-300 dark:hover:bg-red-900/20",children:[e.jsx(ve,{className:"h-4 w-4"}),"Delete"]})]})})}),e.jsxs("div",{className:"min-h-[400px]",children:[j&&e.jsx("div",{className:"flex items-center justify-center p-8 min-h-[400px]",children:e.jsx(ee,{className:"h-8 w-8 animate-spin"})}),h&&e.jsx("div",{className:"flex items-center justify-center p-8 text-center min-h-[400px]",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ne,{className:"h-8 w-8 text-yellow-600 mx-auto"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:h})]})}),!j&&!h&&ne()]})]})]})]}),F&&S(s.mimeType)&&e.jsx(xe,{open:!0,onOpenChange:()=>M(!1),children:e.jsxs(ue,{className:"max-w-[95vw] max-h-[95vh] p-0 overflow-hidden",children:[e.jsxs(he,{className:"sr-only",children:[s.originalName," - Full View"]}),s.mimeType.startsWith("image/")?e.jsx("img",{src:U(),alt:s.originalName,className:"w-full h-auto object-contain max-h-[95vh]"}):s.mimeType==="application/pdf"?e.jsx("iframe",{src:U(),className:"w-full h-[95vh] border-none",title:s.originalName}):null]})})]})}function Re({entries:s,isLoading:l,error:t,canCreateEntries:n=!0,showRecordedBy:i=!1,onEdit:c}){const x=as(),[f,o]=g.useState(null),[p,j]=g.useState(!1),[d,h]=g.useState([]);if(l)return e.jsx("div",{className:"text-center py-12",children:e.jsx("p",{className:"text-muted-foreground",children:"Loading time entries..."})});if(t)return e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-destructive",children:"Failed to load time entries"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:t.message})]});if(s.length===0)return e.jsxs("div",{className:"text-center py-12",children:[e.jsx(de,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No time entries yet"}),e.jsx("p",{className:"text-muted-foreground",children:'Click "Add Time Entry" to log your first activity'})]});const y=u=>{x.mutate(u)},N=u=>{if(u.evidenceFiles&&u.evidenceFiles.length>0){const F=u.evidenceFiles.map(M=>({...M,numericId:M.id,originalName:M.originalName||M.fileName,mimeType:M.mimeType||"application/octet-stream"}));h(F),o(F[0]),j(!0)}};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-md border",children:e.jsxs(Ns,{children:[e.jsx(vs,{children:e.jsxs(Pe,{children:[e.jsx(L,{children:"Date"}),e.jsx(L,{children:"Hours"}),e.jsx(L,{children:"Activity Type"}),e.jsx(L,{children:"Description"}),e.jsx(L,{children:"Property"}),i&&e.jsx(L,{children:"Recorded By"}),e.jsx(L,{children:"Participation"}),e.jsx(L,{children:"Evidence"}),e.jsx(L,{className:"text-right",children:"Actions"})]})}),e.jsx(ws,{children:s.map(u=>e.jsxs(Pe,{children:[e.jsx(z,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{children:Q(new Date(u.date),"MMM d, yyyy")})]})}),e.jsx(z,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ks,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("span",{className:"font-medium",children:[u.hours,"h"]})]})}),e.jsx(z,{children:e.jsx("span",{className:"text-sm",children:u.activityType})}),e.jsx(z,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:u.description||"-"})}),e.jsx(z,{children:u.property?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ts,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:u.property.nickname})]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"No property"})}),i&&e.jsx(z,{children:e.jsx(T,{variant:"secondary",className:"bg-blue-50 text-blue-700",children:u.recordedBy||"Unknown"})}),e.jsx(z,{children:u.isMaterialParticipation?e.jsx(T,{variant:"default",children:"Material Participation"}):u.isQualifiedNonMaterial?e.jsx(T,{variant:"secondary",children:"Qualified Non-Material"}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(z,{children:u.evidenceFiles&&u.evidenceFiles.length>0?e.jsxs(w,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>N(u),children:[e.jsx(oe,{className:"h-4 w-4 text-blue-500"}),e.jsxs("span",{className:"sr-only",children:[u.evidenceFiles.length," files"]})]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"-"})}),e.jsx(z,{className:"text-right",children:n?e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(w,{variant:"ghost",size:"sm",onClick:()=>c==null?void 0:c(u),children:e.jsx(Fs,{className:"w-4 h-4"})}),e.jsxs(He,{children:[e.jsx(Ms,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"sm",children:e.jsx(ve,{className:"w-4 h-4 text-destructive"})})}),e.jsxs(Ve,{children:[e.jsxs(_e,{children:[e.jsx(Ge,{children:"Delete Time Entry?"}),e.jsxs(Xe,{children:["This action cannot be undone. This will permanently delete your time entry from ",Q(new Date(u.date),"MMM d, yyyy"),"."]})]}),e.jsxs(Ze,{children:[e.jsx(Je,{children:"Cancel"}),e.jsx(es,{onClick:()=>y(u.id),children:"Delete"})]})]})]})]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"No access"})})]},u.id))})]})}),f&&e.jsx(Ce,{isOpen:p,onClose:()=>j(!1),file:f,allFiles:d,currentFileIndex:d.findIndex(u=>
7u.numericId===f.numericId),onFileChange:u=>{const F=d[u];F&&o(F)}})]})}function ha({value:s,onChange:l}){const[t,n]=g.useState(!1),i=s?new Date(`${s}T00:00:00`):void 0;return e.jsxs(Bs,{open:t,onOpenChange:n,children:[e.jsx(Os,{asChild:!0,children:e.jsxs("button",{type:"button",className:se("flex h-12 w-full items-center rounded-xl border border-input bg-background px-3 py-2 text-left text-base font-normal shadow-sm transition-colors sm:h-10 sm:text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",!s&&"text-muted-foreground"),children:[e.jsx("span",{children:i?Q(i,"MMM d, yyyy"):"Pick a date"}),e.jsx(de,{className:"ml-auto h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ys,{className:"w-auto p-0",align:"start",children:e.jsx(Ks,{mode:"single",selected:i,onSelect:c=>{c&&l(Q(c,"yyyy-MM-dd")),n(!1)},initialFocus:!0})})]})}function Qe({open:s,onOpenChange:l,entryToEdit:t}){var ne,r,b;const n=ca(),i=da(),{data:c}=ss(),x=ge(),{toast:f}=ae(),o=Me(),p=g.useRef(null),j={date:Cs(),hours:"",activityType:"",description:"",propertyId:"none",isMaterialParticipation:!1,isQualifiedNonMaterial:!1},[d,h]=g.useState(j),[y,N]=g.useState([]),[u,F]=g.useState([]),[M,P]=g.useState(!1),[O,A]=g.useState(!1),[C,W]=g.useState(null),[Y,D]=g.useState(!1);g.useEffect(()=>{var a;s&&(t?(h({date:new Date(t.date).toISOString().split("T")[0],hours:t.hours.toString(),activityType:t.activityType,description:t.description||"",propertyId:(a=t.property)!=null&&a.id?String(t.property.id):"none",isMaterialParticipation:t.isMaterialParticipation,isQualifiedNonMaterial:t.isQualifiedNonMaterial||!1}),F(t.evidenceFiles||[])):(h(j),F([])),N([]))},[s,t]),g.useEffect(()=>{const a=new Date().getFullYear();if(d.date){const k=new Date(`${d.date}T00:00:00`).getFullYear();k<a?(A(!0),f({title:"Previous Tax Year Selected",description:`You are logging hours for ${k}. These will not count toward your current ${a} goals.`})):A(!1)}},[d.date,f]);const q=()=>{h(j),N([]),F([])},B=a=>{const m=Ws(a),k=qs[a];h(_=>({..._,activityType:a,hours:!t&&m.defaultHours?m.defaultHours.toString():_.hours,isMaterialParticipation:(k==null?void 0:k.autoEnable)||!1}))},K=a=>{if(a.target.files){const m=Array.from(a.target.files);N(k=>[...k,...m])}},V=a=>{N(m=>m.filter((k,_)=>_!==a))},E=async a=>{if(y.length!==0){P(!0);try{const m=new FormData;y.forEach(k=>{m.append("files",k)}),await $s("POST",`/api/evidence-files/${a}`,m),f({title:"Files Uploaded",description:"Evidence files attached successfully."}),x.invalidateQueries({queryKey:["member-time-entries"]})}catch(m){console.error("Upload error:",m),f({title:"Upload Failed",description:"Failed to upload some evidence files.",variant:"destructive"})}finally{P(!1)}}},v=a=>{const m={id:a.id,numericId:a.id,originalName:a.originalName||a.fileName,fileName:a.fileName,fileUrl:a.fileUrl,mimeType:a.mimeType||"application/octet-stream",uploadedAt:a.uploadedAt||a.createdAt,fileSize:a.fileSize,aiSummary:a.aiSummary,aiAnalysisStatus:a.aiAnalysisStatus||"pending",storageType:a.storageType,r2Key:a.r2Key};W(m),D(!0)},I=async a=>{a.preventDefault();const m={date:d.date,hours:Number(d.hours),activityType:d.activityType,description:d.description,propertyId:d.propertyId&&d.propertyId!=="none"?Number(d.propertyId):void 0,isMaterialParticipation:d.isMaterialParticipation,isQualifiedNonMaterial:d.isQualifiedNonMaterial||void 0};t?i.mutate({id:t.id,data:m},{onSuccess:async()=>{y.length>0&&await E(t.id),q(),l(!1)}}):n.mutate(m,{onSuccess:async k=>{y.length>0&&k.id&&await E(k.id),q(),l(!1)}})},S=n.isPending||i.isPending||M,$=t?"Edit Time Entry":"Add Time Entry",pe=S?"Saving...":t?"Save Changes":"Create Entry",U=e.jsxs("div",{className:se("grid gap-4",o?"px-4 pb-4 pt-2":"py-4"),children:[e.jsxs("div",{className:"form-mobile-stack",children:[e.jsxs("div",{className:"form-mobile-full",children:[e.jsxs(R,{htmlFor:"date",className:"text-sm font-normal",children:["Date ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(ha,{value:d.date,onChange:a=>h(m=>({...m,date:a}))})]}),e.jsxs("div",{className:"form-mobile-full",children:[e.jsxs(R,{htmlFor:"activityType",className:"text-sm font-normal",children:["Activity Type ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Ds,{value:d.activityType,onValueChange:B,placeholder:"Select or type activity type...",className:"touch-target text-xs text-gray-600"}),d.activityType&&!t&&e.jsxs("div",{className:"mt-1 text-sm text-gray-600",children:[e.jsx(we,{className:"h-4 w-4 inline mr-1"}),"Auto-filled with suggested hours. You can adjust as needed."]})]})]}),O&&e.jsxs("div",{className:"bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(Ne,{className:"h-5 w-5 text-amber-600 dar
7k:text-amber-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-amber-800 dark:text-amber-200 text-sm mb-1",children:"Previous Tax Year Selected"}),e.jsxs("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:["You are logging hours for a previous tax year. These hours will not count toward your current ",new Date().getFullYear()," goals. You can view previous year data using the Tax Year selector on the dashboard."]})]})]}),e.jsx("div",{children:e.jsx(Ss,{value:d.hours,onChange:a=>h(m=>({...m,hours:a})),label:"Hours",required:!0,suggestedHours:!t&&d.activityType?(r=(ne=Ps.find(a=>a.value===d.activityType))==null?void 0:ne.defaultHours)==null?void 0:r.toString():void 0,className:!t&&d.activityType&&!d.hours?"border-blue-300 bg-blue-50":""})}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(R,{htmlFor:"property",className:"text-sm font-normal",children:"Property (Optional)"}),e.jsxs(As,{value:d.propertyId,onValueChange:a=>h({...d,propertyId:a}),children:[e.jsx(Es,{children:e.jsx(Is,{placeholder:"Select property"})}),e.jsxs(Us,{children:[e.jsx(Ae,{value:"none",children:"No property"}),(b=c==null?void 0:c.assignedProperties)==null?void 0:b.map(a=>e.jsx(Ae,{value:String(a.id),children:a.nickname},a.id))]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ee,{id:"materialParticipation",checked:d.isMaterialParticipation,onCheckedChange:a=>h(m=>({...m,isMaterialParticipation:a,isQualifiedNonMaterial:a?!1:m.isQualifiedNonMaterial}))}),e.jsx(R,{htmlFor:"materialParticipation",className:"text-sm font-normal",children:"Material Participation Activity"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ee,{id:"qualifiedNonMaterial",checked:d.isQualifiedNonMaterial,onCheckedChange:a=>h(m=>({...m,isQualifiedNonMaterial:a,isMaterialParticipation:a?!1:m.isMaterialParticipation}))}),e.jsx(R,{htmlFor:"qualifiedNonMaterial",className:"text-sm font-normal",children:"Qualified Non-Material Activity"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(R,{htmlFor:"description",className:"text-sm font-normal",children:"Description (Optional)"}),e.jsx(Ls,{id:"description",placeholder:"Describe what you did...",value:d.description,onChange:a=>h({...d,description:a.target.value}),rows:3})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(R,{htmlFor:"evidence",className:"text-sm font-normal",children:"Evidence (Optional)"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Photos, documents, or receipts"})]}),e.jsxs("div",{className:"border rounded-md p-3 space-y-3 bg-gray-50 dark:bg-gray-900/20",children:[u.length>0&&e.jsxs("div",{className:"space-y-2 mb-3",children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:"Attached Files"}),u.map(a=>e.jsxs("div",{className:"flex items-center justify-between bg-white dark:bg-gray-800 p-2 rounded border text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 truncate",children:[e.jsx(oe,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"truncate max-w-[200px]",children:a.originalName||a.fileName})]}),e.jsx(w,{type:"button",variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-blue-600",onClick:()=>v(a),children:e.jsx(Fe,{className:"h-3.5 w-3.5"})})]},a.id))]}),y.length>0&&e.jsxs("div",{className:"space-y-2 mb-3",children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:"To Upload"}),y.map((a,m)=>e.jsxs("div",{className:"flex items-center justify-between bg-white dark:bg-gray-800 p-2 rounded border text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 truncate",children:[e.jsx("span",{className:"text-xs font-mono bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300 px-1 rounded",children:"NEW"}),e.jsx("span",{className:"truncate max-w-[200px]",children:a.name})]}),e.jsx(w,{type:"button",variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-red-500 hover:text-red-700",onClick:()=>V(m),children:e.jsx(zs,{className:"h-3.5 w-3.5"})})]},m))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(w,{type:"button",variant:"outline",size:"sm",className:"w-full",onClick:()=>{var a;return(a=p.current)==null?void 0:a.click()},children:[e.jsx(oe,{className:"h-4 w-4 mr-2"}),"Attach Files"]}),e.jsx("input",{ref:p,type:"file",multiple:!0,className:"hidden",onChange:K})]})]})]})]}),re=e.jsxs("div",{className:se("flex gap-2",o?"px-4 pb-4 pt-1":"justify-end"),children:[e.jsx(w,{type:"button",variant:"outline",className:o?"h-11 flex-1 rounded-xl":void 0,onClick:()=>l(!1),children:"Cancel"}),e.jsxs(w,{type:"submit",disabled:S,className:o?"h-11 flex-1 rounded-xl bg-emerald-600 hover:bg-emerald-700":void 0,children:[M&&e.jsx(ee,{className:"mr-2 h-4 w-4 animate-spin"}),pe]})]}),ie=C?e.jsx(Ce,{isOpen:Y,onClose:()=>D(!1),file:C,allFiles:u.length>0?u.map(a=>({...a,numericId:a.id,mimeType:a.mimeType||"application/octet-stream"}
7)):[C],currentFileIndex:u.findIndex(a=>a.id===C.numericId),onFileChange:a=>{const m=u[a];m&&v(m)}}):null;return o?e.jsxs(e.Fragment,{children:[e.jsx(Rs,{open:s,onOpenChange:l,title:$,className:"bg-gray-50 dark:bg-gray-950",children:e.jsxs("form",{onSubmit:I,className:"pb-2",children:[e.jsx("p",{className:"px-4 pt-3 text-sm text-muted-foreground",children:t?"Update your time entry details":"Log your work hours for REPS compliance tracking"}),U,re]})}),ie]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{open:s,onOpenChange:l,children:e.jsx(ue,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[650px]",children:e.jsxs("form",{onSubmit:I,children:[e.jsxs(Te,{children:[e.jsx(he,{children:$}),e.jsx($e,{children:t?"Update your time entry details":"Log your work hours for REPS compliance tracking"})]}),U,e.jsx(Qs,{children:re})]})})}),ie]})}function ga({open:s,onOpenChange:l,entry:t}){const n=Me();return t?n?e.jsx(qe,{children:s&&e.jsxs(J.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",damping:30,stiffness:300,mass:.8},className:"fixed inset-0 z-[60] bg-white dark:bg-gray-950 overflow-hidden flex flex-col",children:[e.jsx(Hs,{title:"Entry Details",showBack:!0,onBack:()=>l(!1),className:"bg-white/80 dark:bg-gray-950/80 backdrop-blur-md border-b border-gray-100 dark:border-gray-800"}),e.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-safe-bottom pt-[calc(env(safe-area-inset-top)+64px)]",children:e.jsx(We,{entry:t})})]})}):e.jsx(xe,{open:s,onOpenChange:l,children:e.jsxs(ue,{className:"max-w-2xl max-h-[80vh] overflow-y-auto rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 shadow-lg",children:[e.jsx(Te,{children:e.jsx(he,{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Time Entry Details"})}),e.jsx(We,{entry:t})]})}):null}function We({entry:s}){var f;const[l,t]=g.useState(null),[n,i]=g.useState(!1),c=((f=s.evidenceFiles)==null?void 0:f.map((o,p)=>{const j=Number(o.id??p);return{...o,id:j,numericId:j,originalName:o.originalName||o.fileName||`Evidence file ${p+1}`,mimeType:o.mimeType||"application/octet-stream",uploadedAt:o.uploadedAt||o.createdAt||s.createdAt}}))||[],x=o=>{t(o),i(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Date"}),e.jsx("p",{className:"mt-1 text-sm text-gray-900 dark:text-gray-100",children:Q(new Date(s.date),"MMMM d, yyyy")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Hours"}),e.jsxs("p",{className:"mt-1 text-sm font-semibold text-gray-900 dark:text-gray-100",children:[s.hours,"h"]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Activity Type"}),e.jsx("div",{className:"mt-2",children:e.jsx(T,{variant:"outline",className:"bg-green-50 text-green-700 border border-green-200 text-xs font-medium px-3 py-0.5 rounded-full",children:s.activityType})})]}),s.description&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Description"}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-gray-800 dark:text-gray-200 bg-gray-50 dark:bg-gray-800 p-3 rounded-lg border border-gray-200 dark:border-gray-700",children:s.description})]}),s.property&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Property"}),e.jsxs("div",{className:"mt-2 p-3 bg-gray-50 dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:s.property.nickname}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-1",children:s.property.address})]})]}),s.recordedBy&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Recorded By"}),e.jsx("div",{className:"mt-2",children:e.jsx(T,{variant:"secondary",className:"bg-blue-50 text-blue-700 text-xs px-2 py-0.5",children:s.recordedBy})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Material Participation"}),e.jsx("div",{className:"mt-2",children:e.jsx(T,{variant:s.isMaterialParticipation?"default":"secondary",className:"text-xs px-2 py-0.5",children:s.isMaterialParticipation?"Yes":"No"})})]}),s.isQualifiedNonMaterial&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Qualified Non-Material"}),e.jsx("div",{className:"mt-2",children:e.jsx(T,{variant:"secondary",className:"text-xs px-2 py-0.5",children:"Yes"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Evidence Files"}),e.jsx("div",{className:"mt-2 space-y-2",children:c.length>0?c.map((o,p)=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"min-w-0 pr-3",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:o.originalName||o.fileName}),o.uploadedAt&&e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Uploaded:"," ",Vs(new Date(o.uploadedAt))?Q(new Date(o.uploadedAt),"MMM d, yyyy HH:mm"):"Unknown date"]})]}),e.jsxs(w,{type:"button",variant:"ghost",size:"sm",className:"shrink-0 text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",onClick:()=>x(o),children:[e.jsx(Fe,{className:"mr-2 h-4 w-4"}),"View"]}
7)]},o.id||p)):e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 italic",children:"No evidence files attached"})})]}),e.jsx("div",{className:"pt-6 border-t border-gray-200 dark:border-gray-700",children:e.jsx("div",{className:"grid grid-cols-1 gap-4 text-xs text-gray-500 dark:text-gray-400",children:e.jsxs("div",{children:[e.jsx("label",{className:"block font-medium text-gray-600 dark:text-gray-300",children:"Created"}),e.jsx("p",{className:"mt-1",children:Q(new Date(s.createdAt),"MMM d, yyyy HH:mm")})]})})})]}),l&&e.jsx(Ce,{isOpen:n,onClose:()=>i(!1),file:l,allFiles:c,currentFileIndex:c.findIndex(o=>o.numericId===l.numericId),onFileChange:o=>{const p=c[o];p&&t(p)}})]})}function wa(){const[s,l]=g.useState(!1),[t,n]=g.useState(null),[i,c]=g.useState(null),[x,f]=g.useState(null),[o]=g.useState({}),[p,j]=g.useState("own"),d=Me(),h=as(),{data:y}=ss(),N=(y==null?void 0:y.permissions.canCreateTimeEntries)??!0,u=(y==null?void 0:y.permissions.canViewAllTimeEntries)??!1,F=v=>{n(v),l(!0)},M=v=>{l(v),v||n(null)},{data:P,isLoading:O,error:A}=na(o),{data:C,isLoading:W,error:Y}=la(o),D=p==="own"?P:C,q=p==="own"?O:W,B=p==="own"?A:Y,K=(D==null?void 0:D.entries)||[],V=K.filter(v=>{const I=new Date(v.date),S=new Date;return I.getMonth()===S.getMonth()&&I.getFullYear()===S.getFullYear()}).length,E=K.filter(v=>{const I=new Date(v.date),S=new Date,$=new Date(S);return $.setDate(S.getDate()-S.getDay()),I>=$}).length;return d?e.jsxs(e.Fragment,{children:[e.jsx(ia,{activeData:D,activeLoading:q,activeError:B,activeTab:p,canCreateEntries:N,canViewAll:u,thisMonthCount:V,thisWeekCount:E,onTabChange:j,onCreate:()=>l(!0),onView:c,onEdit:v=>{n(v),l(!0)},onDelete:f}),e.jsx(Qe,{open:s,onOpenChange:M,entryToEdit:t}),e.jsx(ga,{open:!!i,onOpenChange:v=>!v&&c(null),entry:i}),e.jsx(He,{open:!!x,onOpenChange:v=>!v&&f(null),children:e.jsxs(Ve,{children:[e.jsxs(_e,{children:[e.jsx(Ge,{children:"Delete Time Entry?"}),e.jsx(Xe,{children:x&&e.jsxs(e.Fragment,{children:["This action cannot be undone. This will permanently delete your time entry from"," ",Q(new Date(x.date),"MMM d, yyyy"),"."]})})]}),e.jsxs(Ze,{children:[e.jsx(Je,{children:"Cancel"}),e.jsx(es,{onClick:()=>{x&&(h.mutate(x.id),f(null))},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"My Time Entries"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Track and manage your work hours for REPS compliance"})]}),N?e.jsxs(w,{onClick:()=>l(!0),size:"lg",children:[e.jsx(Be,{className:"w-4 h-4 mr-2"}),"Add Time Entry"]}):e.jsxs(_s,{className:"max-w-sm",children:[e.jsx(we,{className:"h-4 w-4"}),e.jsx(Gs,{className:"text-sm",children:"You don't have permission to create time entries. Contact your account owner."})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(H,{children:e.jsxs(G,{className:"pb-2",children:[e.jsx(X,{children:"Total Entries"}),e.jsx(Z,{className:"text-3xl",children:(D==null?void 0:D.total)||0})]})}),e.jsx(H,{children:e.jsxs(G,{className:"pb-2",children:[e.jsx(X,{children:"This Month"}),e.jsx(Z,{className:"text-3xl",children:V})]})}),e.jsx(H,{children:e.jsxs(G,{className:"pb-2",children:[e.jsx(X,{children:"This Week"}),e.jsx(Z,{className:"text-3xl",children:E})]})})]}),e.jsxs(Xs,{value:p,onValueChange:v=>j(v),children:[e.jsxs(Zs,{children:[e.jsxs(Ie,{value:"own",children:[e.jsx(Oe,{className:"w-4 h-4 mr-2"}),"My Entries"]}),u&&e.jsxs(Ie,{value:"all",children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),"All Entries"]})]}),e.jsx(Ue,{value:"own",className:"space-y-4",children:e.jsxs(H,{children:[e.jsxs(G,{children:[e.jsx(Z,{children:"My Time Entries"}),e.jsx(X,{children:"Time entries you have personally created"})]}),e.jsx(me,{children:e.jsx(Re,{entries:(P==null?void 0:P.entries)||[],isLoading:O,error:A,canCreateEntries:N,showRecordedBy:!1,onEdit:F})})]})}),u&&e.jsx(Ue,{value:"all",className:"space-y-4",children:e.jsxs(H,{
7children:[e.jsxs(G,{children:[e.jsx(Z,{children:"All Workspace Entries"}),e.jsx(X,{children:"Time entries from all team members in your workspace"})]}),e.jsx(me,{children:e.jsx(Re,{entries:(C==null?void 0:C.entries)||[],isLoading:W,error:Y,canCreateEntries:N,showRecordedBy:!0,onEdit:F})})]})})]}),e.jsx(Qe,{open:s,onOpenChange:M,entryToEdit:t})]})}export{wa 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.