1import{z as Yn,j as t,dv as Wr,q as gn,au as Xn,i as pn,b_ as Ft,b$ as Et,c0 as Mt,c1 as Pt,c2 as Dt,dQ as It,c3 as $t,c4 as _t,c5 as At,ae as ie,bo as rt,a as ve,aE as Vt,aG as pe,dR as Qr,b1 as Rr,b2 as Fr,b3 as Er,b4 as Mr,F as tt,B as L,$ as St,D as kt,_ as Ot,R as wt,V as jt,aL as te,A as nr,Y as hr,L as $e,a0 as Se,a1 as Ce,a2 as Ve,a3 as ke,a4 as Z,e as re,aT as mn,aU as fn,aV as _e,aW as Fe,aX as xn,aY as ge,N as je,bq as Jn,h as hn,ag as Zn,f as Pr,aN as Dr,aJ as yn,aK as Nt,cy as vn,dc as es,a7 as Te,a5 as Kr,C as Me,b as zt,d as Pe,dd as ts,cq as rs,ba as wn,ah as yr,bn as ns,X as jn,dS as vr,b0 as Yr,bM as ss,b5 as is,ad as Xr,dE as Ir,dF as $r,dT as Jr,dG as _r,dU as as,aI as wr,bX as ls,dH as et,dO as os,G as ds,I as cs,J as Zr,cU as us,d7 as gs,dV as ps,bL as ms,dW as Bt,dX as bn,bT as fs,bU as xs,bV as hs,d0 as ys,cX as vs,cs as en,aM as ws,d6 as js,dB as ye,bx as sr,c$ as bs,bO as Ns,x as Ss,dY as Cs,r as ks,p as Rs,dZ as Fs,W as Es,d_ as Ms,d$ as tn}from"./index-DGo-vssZ.js";import{r as y,c as Ar}from"./vendor-Qgthw7N1.js";import{C as Rt}from"./checkbox-i5ygXx_L.js";import{F as Ps}from"./file-spreadsheet-BLcWv5CC.js";import{A as rn}from"./archive-CR8M3D3c.js";import{F as jr}from"./filter-D8zDqrI6.js";import{S as Nn,t as Ze,A as Gt}from"./timeEntryService-DCnrU_uK.js";import{c as Ds,F as nn,D as Is}from"./useFileAccessUrl-DT-HA0mT.js";import{B as $s}from"./building-wUoLfZZJ.js";import{C as sn}from"./circle-x--5-vDMIU.js";import{u as _s,a as ir}from"./use-transform-CDjFxHsE.js";import"./file-image-DUgfxpHG.js";import"./hard-drive-CZLUTk6_.js";import"./share-2-8n29V9oi.js";import"./maximize-2-6AmOphWr.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 an=Yn("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);function Sn(e){switch((e==null?void 0:e.toLowerCase().trim())||""){case"manual":return"Manual Entry";case"stopwatch":return"Stopwatch";case"gmail":return"Gmail";case"calendar":case"calendar_rules":case"rules":return"Calendar";case"geofence":return"Location Visit";default:return e||"Unknown"}}function Cn(e){switch((e==null?void 0:e.toLowerCase().trim())||""){case"manual":return t.jsx(Wr,{className:"h-4 w-4 text-gray-400 dark:text-gray-400"});case"stopwatch":return t.jsx(pn,{className:"h-4 w-4 text-gray-400 dark:text-gray-400"});case"gmail":return t.jsx(Xn,{className:"h-4 w-4 text-gray-400 dark:text-gray-400"});case"calendar":case"calendar_rules":case"rules":return t.jsx(gn,{className:"h-4 w-4 text-gray-400 dark:text-gray-400"});case"geofence":return t.jsx("span",{className:"text-base leading-none",role:"img","aria-label":"Location Visit",children:"ð§ââï¸"});default:return t.jsx(Wr,{className:"h-4 w-4 text-gray-400 dark:text-gray-400"})}}function Kt(e){switch(e.toLowerCase().split(".").pop()){case"pdf":return"application/pdf";case"jpg":case"jpeg":return"image/jpeg";case"png":return"image/png";case"gif":return"image/gif";case"doc":return"application/msword";case"webp":return"image/webp";case"docx":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";default:return"application/octet-stream"}}const ln={select:{weight:3,minWidth:"44px",maxWidth:"48px"},date:{weight:7,minWidth:"110px"},hours:{weight:6,minWidth:"90px"},activityType:{weight:11,minWidth:"120px"},category:{weight:8,minWidth:"100px"},description:{weight:20,minWidth:"140px"},property:{weight:12,minWidth:"140px"},recordedBy:{weight:10,minWidth:"100px"},evidenceFiles:{weight:6,minWidth:"70px",maxWidth:"90px"},source:{weight:5,minWidth:"70px",maxWidth:"90px"},propertyType:{weight:11,minWidth:"120px"},approvalStatus:{weight:5,minWidth:"60px",maxWidth:"80px"},restore:{weight:5,minWidth:"70px",maxWidth:"90px"},actions:{weight:4,minWidth:"48px",maxWidth:"56px"}};function As(e,s){const r=ln[e];if(!r)return{};const n=s.reduce((a,l)=>{var o;return a+(((o=ln[l])==null?void 0:o.weight)||0)},0);return{width:`${(n>0?r.weight/n*100:0).toFixed(2)}%`,minWidth:r.minWidth,maxWidth:r.maxWidth}}const kn=["select","evidenceFiles","approvalStatus","restore","actions"],Vs=[...kn,"description","source"];function ar(e,s,r=""){const n=As(e,s),i=!Vs.includes(e),a=kn.includes(e),p=[r.replace(/\bpx-\d+\b/g,"").replace(/\bpy-\d+\b/g,"").replace(/\balign-(?:top|middle|bottom)\b/g,"").trim(),e==="select"?"px-1 py-4":"px-2 lg:px-3 py-4",a?"text-center":e==="source"?"text-left":"",i?"truncate":"",e==="description"?"overflow-hidden":"","min-w-0","align-top"].filter(
6Boolean).join(" ").trim(),u={width:n.width,minWidth:n.minWidth,maxWidth:n.maxWidth};return{className:p,style:u}}function Ts({open:e,onOpenChange:s,entry:r,onConfirm:n,isDeleting:i}){return t.jsx(Ft,{open:e,onOpenChange:s,children:t.jsxs(Et,{className:"rounded-xl shadow-lg border border-gray-200",children:[t.jsxs(Mt,{children:[t.jsx(Pt,{className:"text-lg font-semibold text-gray-900",children:"Delete Time Entry"}),t.jsxs(Dt,{className:"text-sm text-gray-600 leading-relaxed",children:["This action"," ",t.jsx("span",{className:"font-medium text-red-600",children:"cannot be undone"}),". Are you sure you want to delete this time entry?",r&&t.jsxs("div",{className:"mt-3 p-3 bg-gray-50 border border-gray-200 rounded-lg text-sm text-gray-700",children:[t.jsx("div",{className:"font-medium text-gray-900",children:r.activityType}),t.jsxs("div",{className:"text-xs text-gray-500",children:[r.hours,"h ⢠",It(r.date,"MMM d, yyyy")]})]}),t.jsx("p",{className:"mt-3 text-xs italic",children:'Note: Deleted entries can be restored from the "Show Deleted" view.'})]})]}),t.jsxs($t,{className:"flex justify-end space-x-2",children:[t.jsx(_t,{disabled:i,className:"px-4 py-2 rounded-lg border border-gray-300 text-gray-700 text-sm font-medium hover:bg-gray-100 transition",children:"Cancel"}),t.jsx(At,{onClick:n,disabled:i,className:"px-4 py-2 rounded-lg bg-red-600 text-white text-sm font-medium hover:bg-red-700 transition flex items-center",children:i?t.jsxs(t.Fragment,{children:[t.jsx(ie,{className:"mr-2 h-4 w-4 animate-spin"}),"Deleting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(rt,{className:"mr-2 h-4 w-4"}),"Delete Entry"]})})]})]})})}function Ls({open:e,onOpenChange:s,selectedCount:r,onConfirm:n,isDeleting:i}){return t.jsx(Ft,{open:e,onOpenChange:s,children:t.jsxs(Et,{className:"rounded-xl shadow-lg border border-gray-200",children:[t.jsxs(Mt,{children:[t.jsx(Pt,{className:"text-lg font-semibold text-gray-900",children:"Delete Multiple Entries"}),t.jsxs(Dt,{className:"text-sm text-gray-600 leading-relaxed",children:["Are you sure you want to delete"," ",t.jsx("span",{className:"font-medium text-gray-900",children:r})," ","selected time entries?",t.jsx("p",{className:"mt-3 text-xs italic",children:'Note: Deleted entries can be restored from the "Show Deleted" view.'})]})]}),t.jsxs($t,{className:"flex justify-end space-x-2",children:[t.jsx(_t,{disabled:i,className:"px-4 py-2 rounded-lg border border-gray-300 text-gray-700 text-sm font-medium hover:bg-gray-100 transition",children:"Cancel"}),t.jsx(At,{onClick:n,disabled:i,className:"px-4 py-2 rounded-lg bg-red-600 text-white text-sm font-medium hover:bg-red-700 transition flex items-center",children:i?t.jsxs(t.Fragment,{children:[t.jsx(ie,{className:"mr-2 h-4 w-4 animate-spin"}),"Deleting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(rt,{className:"mr-2 h-4 w-4"}),"Delete ",r," Entries"]})})]})]})})}function Hs({steps:e,currentIndex:s}){var r;return t.jsxs("div",{className:"mt-4",children:[t.jsx("div",{className:"flex items-center justify-center gap-1 sm:gap-2",children:e.map((n,i)=>{const a=i<s,l=i===s;return t.jsxs(Ar.Fragment,{children:[i>0&&t.jsx("div",{className:te("h-px flex-1 max-w-6 sm:max-w-12 transition-colors",a?"bg-green-500":"bg-muted-foreground/20")}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:te("w-6 h-6 rounded-full flex items-center justify-center text-xs font-medium shrink-0 transition-colors",a&&"bg-green-500 text-white",l&&"bg-primary text-primary-foreground ring-2 ring-primary/20",!a&&!l&&"bg-muted text-muted-foreground"),children:a?t.jsx(Pr,{className:"w-3 h-3"}):i+1}),t.jsx("span",{className:te("text-xs font-medium hidden sm:inline",l?"text-foreground":"text-muted-foreground"),children:n.label})]})]},n.key)})}),t.jsx("p",{className:"text-xs text-center text-muted-foreground mt-2 sm:hidden",children:(r=e[s])==null?void 0:r.label})]})}const lr=["date","hours","activityType","description","propertyName","isMaterialParticipation","approvalStatus"],or={date:{required:!0,alternatives:["date","entry_date","activity_date","timestamp","when"],validation:e=>{if(!(e!=null&&e.trim()))return{valid:!1,error:"Date is required"};const s=new Date(e);return{valid:!isNaN(s.getTime()),error:"Invalid date format"}}},hours:{required:!0,alternatives:["hours","time","duration","hours_worked","time_spent"],validation:e=>{const s=parseFloat(e);return isNaN(s)?{valid:!1,error:"Hours must be a number"}:s<.0167||s>24?{valid:!1,error:"Hours must be between 1 minute and 24 hours"}:{valid:!0}}},activityType:{required:!0,alternatives:["activityType","activity_type","activity","type","task_type"],validation:e=>e!=null&&e.trim()?{valid:!0}:{valid:!1,error:"Activity type is required"}},description:{required:!1,alternatives:["description","notes","details","comments","summary"],validation:()=>({valid:!0})},propertyName:{required:!1,alternatives:["propertyName","property_name","property","location","address"],validation:()=>({valid:!0})},isMaterialParticipation:{required:!1,alternatives:["isMaterialParticipation","material_participation","material","mp"],validation:e=>{if(!(e!=null&&e.trim()))return{valid:!0};const s=e.toLowerCase();return{valid:["true","false","yes","no","1","0"].includes(s)}}},approvalStatus:{required:!1,alternatives:["approvalStatus","approval_status","status","approved"],validation:e=>{if(!(e!=null&&e.trim()))return{valid:!0};const s=e.toLowerCase();return{valid:["pending","approved"].includes(s)}}}};function Os({open:e,onClose:s,onImportComplete:r,properties:n}){const[i,a]=y.useState("select"),[l,o]=y.useState("upload"),[c,g]=y.useState(null),[m,p]=y.useState([]),[u,d]=y.useState([]),[f,h]=y.useState({}),[C,v]=y.useState([]),[w,N]=y.useState([]),[x,b]=y.useState(0),[k,P]=y.useState(null),[I,M]=y.useState({success:0,errors:0,duplicates:0}),[$,G]=y.useState(!1),[U,K]=y.useState(null),[J,oe]=y.useState(!1),{toast:X}=ve(),He=y.useRef(null),nt=()=>{if(i==="select")return"sm:max-w-lg";switch(l){case"upload":return"sm:max-w-lg";case"mapping":return"sm:max-w-2xl";case"preview":return"sm:max-w-5xl";case"importing":return"sm:max-w-md";case"complete":return"sm:max-w-md";default:return"sm:max-w-lg"}},Oe=()=>i==="template"?[{key:"upload",label:"Upload"},{key:"preview",label:"Preview"},{key:"complete",label:"Import"}]:[{key:"upload",label:"Upload"},{key:"mapping",label:"Map"},{key:"preview",label:"Preview"},{key:"complete",label:"Import"}],st=()=>{const S=Oe(),R=l==="importing"?"complete":l;return Math.max(0,S.findIndex(D=>D.key===R))},it=Oe(),at=st(),lt=i!=="select"&&l!=="importing",ae=w.filter(S=>S.severity==="error"),Ne=w.filter(S=>S.severity==="warning"),qe=Vt({mutationFn:async S=>(await pe("POST","/api/ai/map-csv",S)).json(),onSuccess:S=>{S.success&&(K(S.result),v(S.result.mappedData),N([]),o("preview"),
6X({title:"AI Mapping Complete",description:`Mapped ${S.result.mappedData.length} rows with ${Math.round(S.result.overallConfidence*100)}% confidence`}))},onError:S=>{X({title:"AI Mapping Failed",description:S.message||"Failed to map CSV data with AI",variant:"destructive"});const R=de(u);h(R),o("mapping")},onSettled:()=>{G(!1)}}),ot=y.useCallback(()=>{const S=lr,R=["2024-01-15","2.5","property-management","Conducted property inspection and tenant screening",n.length>0?n[0].nickname||n[0].address:"","true","pending"],D=[S.join(","),R.map(F=>`"${F}"`).join(",")].join(` 7`),V=new Blob([D],{type:"text/csv;charset=utf-8;"}),O=document.createElement("a"),z=URL.createObjectURL(V);O.setAttribute("href",z),O.setAttribute("download","time-entries-template.csv"),O.style.visibility="hidden",document.body.appendChild(O),O.click(),document.body.removeChild(O),X({title:"Template Downloaded",description:"Fill out the template and upload it for guaranteed compatibility."})},[n,X]),de=y.useCallback(S=>{const R={};return Object.entries(or).forEach(([D,V])=>{const O=S.find(z=>{const F=z.toLowerCase().trim();return V.alternatives.some(B=>B.toLowerCase()===F||F.includes(B.toLowerCase())||B.toLowerCase().includes(F))});O&&(R[O]=D)}),R},[]),We=y.useCallback((S,R)=>{const D=[],V=[];return S.forEach((O,z)=>{const F={};if(Object.entries(R).forEach(([B,H])=>{var xe;const Y=((xe=O[B])==null?void 0:xe.trim())||"";F[H]=Y;const Re=or[H];if(Re){const Ke=Re.validation(Y);Ke.valid||D.push({row:z+1,field:H,value:Y,message:Ke.error||"Invalid value",severity:"error"})}}),F.propertyName&&F.propertyName.trim()){const B=F.propertyName.trim(),H=n.find(Y=>{var Re,xe;return((Re=Y.nickname)==null?void 0:Re.toLowerCase())===B.toLowerCase()||((xe=Y.address)==null?void 0:xe.toLowerCase())===B.toLowerCase()||`${Y.nickname} - ${Y.address}`.toLowerCase()===B.toLowerCase()});H?(F.propertyId=H.id,F.propertyDisplayName=H.nickname||H.address):n.length===0?F.propertyDisplayName=B:(F.propertyDisplayName=B,D.push({row:z+1,field:"propertyName",value:B,message:`Property '${B}' not found â select one from the dropdown or import without it.`,severity:"warning"}))}if(F.isMaterialParticipation){const B=F.isMaterialParticipation.toLowerCase();F.isMaterialParticipation=["true","yes","1"].includes(B)}F.approvalStatus&&!["pending","approved"].includes(F.approvalStatus)&&(F.approvalStatus="pending"),V.push(F)}),N(D),v(V),D.length===0},[n]),fe=y.useCallback(S=>{const R=[],D=S.map(F=>F.trim()),V=[...lr],O=V.filter(F=>!D.includes(F));O.length>0&&R.push(`Missing required columns: ${O.join(", ")}`);const z=D.filter(F=>!V.includes(F)&&F.trim()!=="");return z.length>0&&R.push(`Unexpected columns found: ${z.join(", ")}`),R.length===0&&(D.length!==V.length?R.push(`Expected ${V.length} columns, but found ${D.length}.`):D.every((B,H)=>B===V[H])||R.push("Column order does not match template. Please ensure columns are in the exact order: "+V.join(", "))),{isValid:R.length===0,errors:R}},[]),ze=y.useCallback(S=>{if(!S.name.toLowerCase().endsWith(".csv")){X({title:"Invalid File Type",description:"Please upload a CSV file (.csv)",variant:"destructive"});return}if(S.size>5*1024*1024){X({title:"File Too Large",description:"Please upload a file smaller than 5MB",variant:"destructive"});return}g(S),Qr.parse(S,{header:!0,skipEmptyLines:!0,complete:R=>{if(R.errors&&R.errors.length>0){console.error("Parse errors:",R.errors),X({title:"Parse Error",description:`Failed to parse CSV file: ${R.errors[0].message}`,variant:"destructive"});return}const D=R.meta.fields||[];if(D.length===0){console.error("No headers found"),X({title:"Parse Error",description:"No valid headers found in the CSV file",variant:"destructive"});return}if(d(D),p(R.data),i==="template"){const V=fe(D);if(!V.isValid){console.error("Template format validation failed:",V.errors),P(V.errors.join(` 8`));return}P(null);const O={};D.forEach(z=>{lr.includes(z)&&(O[z]=z)}),h(O),We(R.data,O),o("preview")}else{G(!0),o("mapping");const V=R.data.slice(0,10);qe.mutate({csvHeaders:D,csvRows:V})}},error:R=>{console.error("Papa.parse error:",R),X({title:"Upload Error",description:R.message,variant:"destructive"})}})},[i,de,We,fe,X]),dt=y.useCallback(async()=>
8{if(!C.length)return;o("importing"),b(0);const S={success:0,errors:0,duplicates:0};try{for(let R=0;R<C.length;R++){const D=C[R];b((R+1)/C.length*100);try{const V=new FormData;V.append("date",D.date||""),V.append("hours",D.hours||""),V.append("activityType",D.activityType||""),V.append("description",D.description||""),V.append("isMaterialParticipation",(D.isMaterialParticipation||!1).toString()),V.append("isQualifiedNonMaterial",(D.isQualifiedNonMaterial||!1).toString()),V.append("source","manual"),D.propertyId&&D.propertyId!==""&&V.append("propertyId",D.propertyId.toString()),(await pe("POST","/api/time-entries",V)).ok?S.success++:S.errors++,await new Promise(z=>setTimeout(z,50))}catch{S.errors++}}M(S),o("complete"),X({title:"Import Complete",description:`Successfully imported ${S.success} entries${S.errors>0?` (${S.errors} errors)`:""}.`}),r()}catch{X({title:"Import Failed",description:"An error occurred during import. Please try again.",variant:"destructive"}),o("preview")}},[C,r,X]),Be=y.useCallback(()=>{a("select"),o("upload"),g(null),p([]),d([]),h({}),v([]),N([]),b(0),M({success:0,errors:0,duplicates:0}),P(null),oe(!1),G(!1),K(null)},[]),Qe=y.useCallback(()=>{Be(),s()},[Be,s]),ct=y.useCallback(()=>{l==="upload"?(a("select"),g(null),P(null)):l==="mapping"?(o("upload"),g(null),p([]),d([]),K(null),G(!1),h({})):l==="preview"&&(i==="smart"?o("mapping"):(o("upload"),g(null),p([]),d([]),v([]),N([]),h({})))},[l,i]),ut=y.useCallback(S=>{S.preventDefault(),S.stopPropagation()},[]),gt=y.useCallback(S=>{S.preventDefault(),S.stopPropagation(),oe(!0)},[]),pt=y.useCallback(S=>{S.preventDefault(),S.stopPropagation(),oe(!1)},[]),mt=y.useCallback(S=>{var D;S.preventDefault(),S.stopPropagation(),oe(!1);const R=(D=S.dataTransfer.files)==null?void 0:D[0];R&&(P(null),ze(R))},[ze]),ne=y.useCallback((S,R,D)=>{const V=[...C];V[S]={...V[S],[R]:D},v(V)},[C]);return t.jsx(Rr,{open:e,onOpenChange:Qe,children:t.jsxs(Fr,{className:te("p-0 gap-0 flex flex-col overflow-hidden transition-[max-width] duration-300 ease-in-out",nt()),children:[t.jsxs("div",{className:"shrink-0 px-6 pt-6 pb-3 border-b",children:[t.jsx(Er,{children:t.jsx(Mr,{className:"text-base font-semibold",children:"Import Time Entries"})}),i!=="select"&&t.jsx(Hs,{steps:it,currentIndex:at})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-5","data-no-nav-clearance":"",children:t.jsxs("div",{className:"animate-in fade-in-0 duration-200",children:[i==="select"&&t.jsxs("div",{className:"space-y-5 py-2",children:[t.jsxs("div",{className:"text-center space-y-1.5",children:[t.jsx(tt,{className:"w-10 h-10 mx-auto text-muted-foreground"}),t.jsx("h3",{className:"font-semibold",children:"Upload CSV File"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Import time entries from a spreadsheet"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs(L,{onClick:()=>{a("template"),o("upload")},className:"w-full bg-green-600 hover:bg-green-700 text-white",size:"lg",children:[t.jsx(St,{className:"w-4 h-4 mr-2"}),"Upload Template CSV"]}),t.jsxs("button",{onClick:ot,className:"w-full text-sm text-muted-foreground hover:text-foreground underline underline-offset-4 transition-colors py-1",children:[t.jsx(kt,{className:"w-3.5 h-3.5 inline mr-1"}),"Download template first"]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute inset-0 flex items-center",children:t.jsx("div",{className:"w-full border-t"})}),t.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:t.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"or"})})]}),t.jsxs(L,{onClick:()=>{a("smart"),o("upload")},variant:"outline",className:"w-full",children:[t.jsx(Ot,{className:"w-4 h-4 mr-2"}),"Smart Import (AI Column Mapping)"]})]}),i!=="select"&&l==="upload"&&t.jsxs("div",{className:"space-y-4",children:[i==="template"&&k&&t.jsxs(wt,{variant:"destructive",children:[t.jsx(sn,{className:"h-4 w-4"}),t.jsxs(jt,{children:[t.jsx("div",{className:"font-medium mb-1",children:"Template Format Error"}),t.jsx("div",{className:"whitespace-pre-line text-sm",children:k}),t.jsxs(L,{variant:"outline",size:"sm",className:"mt-3 border-purple-300 text-purple-700 hover:bg-purple-50 dark:border-purple-600 dar
8k:text-purple-300 dark:hover:bg-purple-900/30",onClick:()=>{P(null),a("smart"),c&&(g(null),setTimeout(()=>{a("smart"),g(c),Qr.parse(c,{header:!0,skipEmptyLines:!0,complete:S=>{const R=S.meta.fields||[];d(R),p(S.data),G(!0),o("mapping");const D=S.data.slice(0,10);qe.mutate({csvHeaders:R,csvRows:D})}})},0))},children:[t.jsx(Ot,{className:"w-3.5 h-3.5 mr-1.5"}),"Try Smart Import instead"]})]})]}),c?t.jsxs("div",{className:"border rounded-lg p-6 text-center space-y-3",children:[t.jsx(tt,{className:"w-10 h-10 mx-auto text-green-600"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:c.name}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[(c.size/1024).toFixed(1)," KB"]})]}),t.jsx("button",{onClick:()=>{g(null),P(null),He.current&&(He.current.value="")},className:"text-sm text-muted-foreground hover:text-foreground underline underline-offset-4 transition-colors",children:"Choose a different file"})]}):t.jsxs("div",{onDragOver:ut,onDragEnter:gt,onDragLeave:pt,onDrop:mt,onClick:()=>{var S;P(null),(S=He.current)==null||S.click()},className:te("border-2 border-dashed rounded-lg p-8 text-center transition-colors cursor-pointer",J?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-muted-foreground/50"),children:[t.jsx(St,{className:te("w-10 h-10 mx-auto mb-3 transition-colors",J?"text-primary":"text-muted-foreground")}),t.jsx("p",{className:"font-medium",children:J?"Drop your file here":"Drag & drop your CSV file"}),t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:i==="template"?"or click to browse â use the template format":"or click to browse â any CSV format"})]}),t.jsx("input",{ref:He,type:"file",accept:".csv",onChange:S=>{var D;const R=(D=S.target.files)==null?void 0:D[0];R&&(P(null),ze(R))},className:"hidden"})]}),i==="smart"&&l==="mapping"&&t.jsx("div",{className:"space-y-4",children:$?t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ot,{className:"w-4 h-4 text-primary animate-pulse"}),t.jsx("p",{className:"text-sm font-medium",children:"AI is analyzing your columns..."})]}),t.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(S=>t.jsxs("div",{className:"flex items-center gap-3 animate-pulse",children:[t.jsx("div",{className:"w-1/3 h-9 bg-muted rounded"}),t.jsx(nr,{className:"w-4 h-4 text-muted-foreground/40 shrink-0"}),t.jsx("div",{className:"flex-1 h-9 bg-muted rounded"})]},S))})]}):t.jsxs("div",{className:"space-y-4",children:[U?t.jsxs(wt,{children:[t.jsx(Ot,{className:"h-4 w-4"}),t.jsxs(jt,{children:["AI mapped your columns with"," ",Math.round(U.overallConfidence*100),"% confidence. Review and adjust if needed."]})]}):t.jsxs(wt,{children:[t.jsx(hr,{className:"h-4 w-4"}),t.jsx(jt,{children:"AI mapping failed. We've generated basic mappings â please review."})]}),t.jsx("div",{className:"space-y-3",children:Object.entries(or).map(([S,R])=>{var V;const D=((V=Object.entries(f).find(([,O])=>O===S))==null?void 0:V[0])||"unmapped";return t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-1/3",children:t.jsxs($e,{className:"text-sm",children:[S,R.required&&t.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})}),t.jsx(nr,{className:"w-4 h-4 text-muted-foreground shrink-0"}),t.jsx("div",{className:"flex-1",children:t.jsxs(Se,{value:D,onValueChange:O=>{if(O==="unmapped"){const z={...f};Object.keys(z).forEach(F=>{z[F]===S&&delete z[F]}),h(z)}else{const z={...f};Object.keys(z).forEach(F=>{z[F]===S&&delete z[F]}),z[O]=S,h(z)}},children:[t.jsx(Ce,{className:"h-9",children:t.jsx(Ve,{placeholder:"Select column..."})}),t.jsxs(ke,{children:[t.jsx(Z,{value:"unmapped",children:"No mapping"}),u.map(O=>t.jsx(Z,{value:O,children:O},O))]})]})})]},S)})})]})}),l==="preview"&&t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:[C.length," ",C.length===1?"entry":"entries"," to import"]}
8),i==="smart"&&U&&t.jsxs(re,{variant:"outline",className:te("text-xs",U.overallConfidence>.8?"bg-green-50 text-green-700 border-green-200":U.overallConfidence>=.5?"bg-amber-50 text-amber-700 border-amber-200":"bg-red-50 text-red-700 border-red-200"),children:["AI ",Math.round(U.overallConfidence*100),"% confidence"]})]})}),ae.length>0&&t.jsxs(wt,{variant:"destructive",children:[t.jsx(sn,{className:"h-4 w-4"}),t.jsxs(jt,{children:[t.jsxs("p",{className:"font-medium",children:[ae.length," ",ae.length===1?"error":"errors"," must be fixed before importing"]}),t.jsxs("ul",{className:"mt-1.5 text-xs space-y-0.5 opacity-80",children:[ae.slice(0,3).map((S,R)=>t.jsxs("li",{children:["Row ",S.row,": ",S.field," â ",S.message]},R)),ae.length>3&&t.jsxs("li",{children:["...and ",ae.length-3," more"]})]})]})]}),Ne.length>0&&t.jsxs(wt,{children:[t.jsx(hr,{className:"h-4 w-4"}),t.jsxs(jt,{children:[t.jsxs("p",{className:"font-medium",children:[Ne.length," ",Ne.length===1?"warning":"warnings"," â you can still import"]}),t.jsxs("ul",{className:"mt-1.5 text-xs space-y-0.5 opacity-80",children:[Ne.slice(0,3).map((S,R)=>t.jsxs("li",{children:["Row ",S.row,": ",S.field," â ",S.message]},R)),Ne.length>3&&t.jsxs("li",{children:["...and ",Ne.length-3," more"]})]})]})]}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[t.jsxs("span",{children:[t.jsx("strong",{children:"MP"})," = Material Participation"]}),t.jsxs("span",{children:[t.jsx("strong",{children:"QNM"})," = Qualified Non-Material"]})]}),t.jsx("div",{className:"hidden sm:block border rounded-lg overflow-auto max-h-[50vh]",children:t.jsxs(mn,{children:[t.jsx(fn,{children:t.jsxs(_e,{className:"bg-muted/50",children:[t.jsx(Fe,{className:"w-10 text-center",children:"#"}),t.jsx(Fe,{className:"w-[120px]",children:"Date"}),t.jsx(Fe,{className:"w-[80px]",children:"Hours"}),t.jsx(Fe,{className:"w-[180px]",children:"Activity"}),t.jsx(Fe,{children:"Description"}),t.jsx(Fe,{className:"w-[140px]",children:"Property"}),t.jsx(Fe,{className:"w-[60px] text-center",children:"MP"}),t.jsx(Fe,{className:"w-[60px] text-center",children:"QNM"})]})}),t.jsx(xn,{children:C.map((S,R)=>{var z;const D=w.filter(F=>F.row===R+1),V=D.some(F=>F.severity==="error"),O=D.some(F=>F.severity==="warning");return t.jsxs(_e,{className:te(R%2===0?"bg-background":"bg-muted/30",V&&"border-l-2 border-l-red-500 bg-red-50/50",!V&&O&&"border-l-2 border-l-amber-400 bg-amber-50/40"),children:[t.jsx(ge,{className:"text-center text-xs text-muted-foreground",children:R+1}),t.jsx(ge,{children:t.jsx(je,{type:"date",value:S.date||"",onChange:F=>ne(R,"date",F.target.value),className:"h-8 text-sm"})}),t.jsx(ge,{children:t.jsx(je,{type:"number",step:"0.25",min:"0",max:"24",value:S.hours||"",onChange:F=>ne(R,"hours",F.target.value),className:"h-8 text-sm w-20"})}),t.jsx(ge,{children:t.jsx(je,{value:S.activityType||"",onChange:F=>ne(R,"activityType",F.target.value),className:"h-8 text-sm"})}),t.jsx(ge,{children:t.jsx(je,{value:S.description||"",onChange:F=>ne(R,"description",F.target.value),className:"h-8 text-sm",placeholder:"Description..."})}),t.jsx(ge,{children:t.jsxs(Se,{value:((z=S.propertyId)==null?void 0:z.toString())||"none",onValueChange:F=>{const B=[...C];if(F==="none")B[R]={...B[R],propertyId:null,propertyDisplayName:null,propertyName:null};else{const H=n.find(Y=>Y.id.toString()===F);B[R]={...B[R],propertyId:parseInt(F),propertyDisplayName:(H==null?void 0:H.nickname)||(H==null?void 0:H.address),propertyName:H==null?void 0:H.nickname}}v(B),N(H=>H.filter(Y=>!(Y.row===R+1&&Y.field==="propertyName")))},children:[t.jsx(Ce,{className:"h-8 text-sm",children:t.jsx(Ve,{placeholder:"None"})}),t.jsxs(ke,{children:[t.jsx(Z,{value:"none",children:"None"}),n.map(F=>t.jsx(Z,{value:F.id.toString(),children:F.nickname||F.address},F.id))]})]})}),t.jsx(ge,{className:"text-center",children:t.jsx("button",{onClick:()=>ne(R,"isMaterialParticipation",!S.isMaterialParticipation),className:te("w-7 h-7 rounded-full flex items-center justify-center text-xs font-medium transition-colors mx-auto",S.isMaterialParticipation?"bg-green-100 text-green-700 hover:bg-green-200":"bg-gray-100 text-gray-400 hover:bg-gray-200"),children:S.isMaterialParticipation?"Y":"N"})}),t.jsx(ge,{className:"text-center",children:t.jsx("button",{onClick:()=>ne(R,"isQualifiedNonMaterial",!S.isQualifiedNonMaterial),className:te("w-7 h-7 rounded-full flex items-center justify-center text-xs font-medium transition-colors mx-auto",S.isQualifiedNonMaterial?"bg-blue-100 text-blue-700 hover:bg-blue-200":"bg-gray-100 text-gray-400 hover:bg-gray-200"),children:S.isQualifiedNonMaterial?"Y":"N"})})]},R)})})]})}),t.jsx("div",{className:"sm:hidden space-y-3 max-h-[50vh] overflow-y-auto","data-no-nav-clearance":"",children:C.map((S,R)=>{var z;const D=w.filter(F=>F.row===R+1),V=D.some(F=>F.severity==="error"),O=D.some(F=>F.severity==="warning");return t.jsxs("div",{className:te("border rounded-lg p-4 space-y-3",V&&"border-red-300 bg-red-50/50",!V&&O&&"border-amber-300 bg-amber-50/40"),children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("span",{className:"text-xs font-medium text-muted-foreground",children:["Entry ",R+1]}),V&&t.jsx(re,{variant:"destructive",className:"text-xs h-5",children:"Error"}),!V&&O&&t.jsx(re,{variant:"outline",className:"text-xs h-5 bg-amber-50 text-amber-700 border-amber-300",children:"Warning"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx($e,{className:"text-xs text-muted-foreground",children:"Date"}),t.jsx(je,{type:"date",value:S.date||"",onChange:F=>ne(R,"date",F.target.value),className:"h-9 text-sm"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx($e,{className:"text-xs text-muted-foreground",children:"Hours"}),t.jsx(je,{type:"number",step:"0.25",min:"0",max:"24",value:S.hours||"",onChange:F=>ne(R,"hours",F.target.value),className:"h-9 text-sm"})]})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx($e,{className:"text-xs text-muted-foreground",children:"Activity Type"}),t.jsx(je,{value:S.activityType||"",onChange:F=>ne(R,"activityType",F.target.value),className:"h-9 text-sm"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx($e,{className:"text-xs text-muted-foreground",children:"Description"}),t.jsx(je,{value:S.description||"",onChange:F=>ne(R,"description",F.target.value),className:"h-9 text-sm",placeholder:"Description..."})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx($e,{className:"text-xs text-muted-foreground",children:"Property"}),t.jsxs(Se,{value:((z=S.propertyId)==null?void 0:z.toString())||"none",onValueChange:F=>{const B=[...C];if(F==="none")B[R]={...B[R],propertyId:null,propertyDisplayName:null,propertyName:null};else{const H=n.find(Y=>Y.id.toString()===F);B[R]={...B[R],propertyId:parseInt(F),propertyDisplayName:(H==null?void 0:H.nickname)||(H==null?void 0:H.address),propertyName:H==null?void 0:H.nickname}}v(B),N(H=>H.filter(Y=>!(Y.row===R+1&&Y.field==="propertyName")))},children:[t.jsx(Ce,{className:"h-9 text-sm",children:t.jsx(Ve,{placeholder:"None"})}),t.jsxs(ke,{children:[t.jsx(Z,{value:"none",children:"None"}),n.map(F=>t.jsx(Z,{value:F.id.toString(),children:F.nickname||F.address},F.id))]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx($e,{className:"text-xs text-muted-foreground",children:"Material Participation"}),t.jsx("button",{onClick:()=>ne(R,"isMaterialParticipation",!S.isMaterialParticipation),className:te("w-full h-9 rounded-md text-sm font-medium transition-colors border",S.isMaterialParticipation?"bg-green-50 text-green-700 border-green-200":"bg-gray-50 text-gray-500 border-gray-200"),children:S.isMaterialParticipation?"Yes":"No"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx($e,{className:"text-xs text-muted-foreground",children:"Qualified Non-Material"}),t.jsx("button",{onClick:()=>ne(R,"isQualifiedNonMaterial",!S.isQualifiedNonMaterial),className:te("w-full h-9 rounded-md text-sm font-medium transition-colors border",S.isQualifiedNonMaterial?"bg-blue-50 text-blue-700 border-blue-200":"bg-gray-50 text-gray-500 border-gray-200"),children:S.isQualifiedNonMaterial?"Yes":"No"})]})]}),D.length>0&&t.jsx("div",{className:te("text-xs space-y-0.5 pt-1 border-t",V?"text-red-600 border-red-200":"text-amber-600 border-amber-200"),children:D.map((F,B)=>t.jsxs("p",{children:[F.field,": ",F.message]},B))})]},R)})})]}),l==="importing"&&t.jsxs("div",{className:"py-8 text-center space-y-4",children:[t.jsx("div",{className:"w-14 h-14 mx-auto rounded-full bg-primary/10 flex items-center justify-center",children:t.jsx(St,{className:"w-7 h-7 text-primary animate-pulse"})}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("h3",{className:"font-semibold",children:"Importing entries..."}),t.jsx(Jn,{value:x,className:"w-full max-w-xs mx-auto"}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(x),"% complete"]})]})]}),l==="complete"&&t.jsxs("div",{className:"py-8 text-center space-y-6",children:[t.jsx("div",{className:"w-16 h-16 mx-auto rounded-full bg-green-100 flex items-center justify-center",children:t.jsx(hn,{className:"w-9 h-9 text-green-600"})}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("h3",{className:"text-lg font-semibold text-green-700",children:"Import Complete"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Your time entries have been imported."})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-3 max-w-sm mx-auto",children:[t.jsxs("div",{className:"p-4 bg-green-50 rounded-xl",children:[t.jsx("div",{className:"text-2xl font-bold text-green-600",children:I.success}),t.jsx("div",{className:"text-xs text-green-700 mt-0.5",children:"Imported"})]}),t.jsxs("div",{className:"p-4 bg-amber-50 rounded-xl",children:[t.jsx("div",{className:"text-2xl font-bold text-amber-600",children:I.duplicates}),t.jsx("div",{className:"text-xs text-amber-700 mt-0.5",children:"Duplicates"})]}),t.jsxs("div",{className:"p-4 bg-red-50 rounded-xl",children:[t.jsx("div",{className:"text-2xl font-bold text-red-600",children:I.errors}),t.jsx("div",{className:"text-xs text-red-700 mt-0.5",children:"Errors"})]})]})]})]},`${i}-${l}`)}),lt&&t.jsxs("div",{className:"shrink-0 px-6 py-3 border-t flex items-center justify-between bg-background",children:[t.jsx("div",{children:l!=="complete"&&t.jsxs(L,{variant:"ghost",size:"sm",onClick:ct,children:[t.jsx(Zn,{className:"w-4 h-4 mr-1.5"}),"Back"]})}),t.jsxs("div",{children:[l==="mapping"&&!$&&t.jsxs(L,{onClick:()=>{(U||We(m,f))&&o("preview")},disabled:!U&&Object.keys(f).length===0,children:["Continue",t.jsx(nr,{className:"w-4 h-4 ml-1.5"})]}),l==="preview"&&t.jsxs(L,{onClick:dt,disabled:ae.length>0,className:"bg-green-600 hover:bg-green-700 text-white",children:["Import ",C.length," Entries"]}),l==="complete"&&t.jsx(L,{onClick:Qe,children:"Done"})]})]})]})})}function zs({open:e,onOpenChange:s,entry:r}){const n=Dr();return r?n?t.jsx(yn,{children:e&&t.jsxs(Nt.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:[t.jsx(vn,{title:"Entry Details",showBack:!0,onBack:()=>s(!1),className:"bg-white/80 dark:bg-gray-950/80 backdrop-blur-md border-b border-gray-100 dark:border-gray-800"}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-safe-bottom pt-[calc(env(safe-area-inset-top)+64px)]","data-no-nav-clearance":"",children:t.jsx(on,{entry:r})})]})}):t.jsx(Rr,{open:e,onOpenChange:s,children:t.jsxs(Fr,{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:[t.jsx(Er,{children:t.jsx(Mr,{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Time Entry Details"})}),t.jsx(on,{entry:r})]})}):null}function on({entry:e}){return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Date"}),t.jsx("p",{className:"mt-1 text-sm text-gray-900 dark:text-gray-100",children:It(e.date,"MMMM d, yyyy")})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Hours"}),t.jsxs("p",{className:"mt-1 text-sm font-semibold text-gray-900 dark:text-gray-100",children:[e.hours,"h"]})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Activity Types"}),t.jsx("div",{className:"mt-2",children:t.jsx(re,{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:e.activityType})})]}),e.description&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Description"}),t.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:e.description})]}),e.property&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Property"}),t.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:[t.jsx("p",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:e.property.nickname}),t.jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-1",children:[e.property.address,", ",e.property.city,","," ",e.property.state," ",e.property.zipCode]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Material Participation"}),t.jsx("div",{className:"mt-2",children:t.jsx(re,{variant:e.isMaterialParticipation?"default":"secondary",className:"text-xs px-2 py-0.5",children:e.isMaterialParticipation?"Yes":"No"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Approval Status"}),t.jsx("div",{className:"mt-2",children:t.jsx(re,{variant:(e.approvalStatus||"pending")==="approved"?"default":"secondary",className:"text-xs px-2 py-0.5",children:e.approvalStatus||"Pending"})})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Entry Source"}),t.jsx("div",{className:"mt-2",children:t.jsx(re,{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:Sn(e.source||"")})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"Evidence Files"}),t.jsx("div",{className:"mt-2 space-y-2",children:e.evidenceFiles&&e.evidenceFiles.length>0?e.evidenceFiles.map((s,r)=>t.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:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:s.fileName}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Uploaded:"," ",s.uploadedAt&&es(new Date(s.uploadedAt))?Te(new Date(s.uploadedAt),"MMM d, yyyy HH:mm"):"Unknown date"]})]}),t.jsx(L,{variant:"ghost",size:"sm",className:"text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white",onClick:()=>window.open(s.fileUrl,"_blank"),children:t.jsx(Kr,{className:"h-4 w-4"})})]},r)):e.evidenceUrl?t.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:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:e.evidenceFileName||"Evid
8ence File"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Legacy evidence file"})]}),t.jsx(L,{variant:"ghost",size:"sm",className:"text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white",onClick:()=>window.open(e.evidenceUrl,"_blank"),children:t.jsx(Kr,{className:"h-4 w-4"})})]}):t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 italic",children:"No evidence files attached"})})]}),e.aiSummary&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"AI Summary"}),t.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:typeof e.aiSummary=="string"?e.aiSummary:JSON.stringify(e.aiSummary)})]}),e.aiTags&&e.aiTags.length>0&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:"AI Tags"}),t.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:e.aiTags.map((s,r)=>{const n=typeof s=="string"?s:(s==null?void 0:s.name)||(s==null?void 0:s.category)||JSON.stringify(s);return t.jsx(re,{variant:"outline",className:"text-xs px-2 py-0.5",children:n},r)})})]}),t.jsx("div",{className:"pt-6 border-t border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"grid grid-cols-2 gap-6 text-xs text-gray-500 dark:text-gray-400",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block font-medium text-gray-600 dark:text-gray-300",children:"Created"}),t.jsx("p",{className:"mt-1",children:Te(new Date(e.createdAt),"MMM d, yyyy HH:mm")})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block font-medium text-gray-600 dark:text-gray-300",children:"Last Updated"}),t.jsx("p",{className:"mt-1",children:Te(new Date(e.updatedAt),"MMM d, yyyy HH:mm")})]})]})})]})}function Bs({open:e,onOpenChange:s,selectedCount:r,confirmBulkApprove:n,isApprovingBulk:i,table:a}){return t.jsx(Ft,{open:e,onOpenChange:s,children:t.jsxs(Et,{className:"rounded-xl shadow-lg border border-gray-200",children:[t.jsxs(Mt,{children:[t.jsx(Pt,{className:"text-lg font-semibold text-gray-900",children:"Approve Multiple Entries"}),t.jsxs(Dt,{className:"text-sm text-gray-600 leading-relaxed",children:[". Are you sure you want to approve"," ",t.jsx("span",{className:"font-medium text-gray-900",children:a.getFilteredSelectedRowModel().rows.filter(l=>{const o=l.original;return!o.isNew&&o.approvalStatus!=="approved"}).length})," ","selected time entries?"]})]}),t.jsxs($t,{className:"flex justify-end space-x-2",children:[t.jsx(_t,{disabled:i,className:"px-4 py-2 rounded-lg border border-gray-300 text-gray-700 text-sm font-medium hover:bg-gray-100 transition",children:"Cancel"}),t.jsx(At,{onClick:n,disabled:i,className:"px-4 py-2 rounded-lg bg-red-600 text-white text-sm font-medium hover:bg-red-700 transition flex items-center",children:i?t.jsxs(t.Fragment,{children:[t.jsx(ie,{className:"mr-2 h-4 w-4 animate-spin"}),"Approving..."]}):t.jsxs(t.Fragment,{children:[t.jsx(rt,{className:"mr-2 h-4 w-4"}),"Approve"," ",a.getFilteredSelectedRowModel().rows.filter(l=>{const o=l.original;return!o.isNew&&o.approvalStatus!=="approved"}).length," ","Entries"]})})]})]})})}function Gs({open:e,onOpenChange:s,selectedCount:r,confirmBulkUnapprove:n,isUnapprovingBulk:i,table:a}){return t.jsx(Ft,{open:e,onOpenChange:s,children:t.jsxs(Et,{className:"rounded-xl shadow-lg border border-gray-200",children:[t.jsxs(Mt,{children:[t.jsx(Pt,{className:"text-lg font-semibold text-gray-900",children:"Unapprove Multiple Entries"}),t.jsxs(Dt,{className:"text-sm text-gray-600 leading-relaxed",children:[". Are you sure you want to unapprove"," ",t.jsx("span",{className:"font-medium text-gray-900",children:a.getFilteredSelectedRowModel().rows.filter(l=>{const o=l.original;return!o.isNew&&o.approvalStatus!=="pending"}).length})," ","selected time entries?"]})]}),t.jsxs($t,{className:"flex justify-end space-x-2",children:[t.jsx(_t,{disabled:i,className:"px-4 py-2 rounded-lg border border-gray-300 text-gray-700 text-sm font-medium hover:bg-gray-100 transition",children:"Cancel"}),t.jsx(At,{onClick:n,disabled:i,className:"px-4 py-2 rounded-lg bg-red-600 text-white text-sm font-medium hover:bg-red-700 transition flex items-center",children:i?t.jsxs(t.Fragment,{children:[t.jsx(ie,{className:"mr-2 h-4 w-4 animate-spin"}),"Unapproving..."]}):t.jsxs(t.Fragment,{children:[t.jsx(rt,{className:"mr-2 h-4 w-4"}),"Unapprove"," ",a.getFilteredSelectedRowModel().rows.filter(l=>{const o=l.original;return!o.isNew&&o.approvalStatus!=="pending"}).length," ","Entries"]})})]})]})})}/** 9 * table-core 10 * 11 * Copyright (c) TanStack 12 * 13 * This source code is licensed under the MIT license found in the 14 * LICENSE.md file in the root directory of this source tree. 15 * 16 * @license MIT 17 */function Ae(e,s){return typeof e=="function"?e(s):e}function me(e,s){return r=>{s.setState(n=>({...n,[e]:Ae(r,n[e])}))}}function Yt(e){return e instanceof Function}function Us(e){return Array.isArray(e)&&e.every(s=>typeof s=="number")}function qs(e,s){const r=[],n=i=>
vendor: 59,790 bytes, lines 17-29
17{i.forEach(a=>{r.push(a);const l=s(a);l!=null&&l.length&&n(l)})};return n(e),r}function _(e,s,r){let n=[],i;return a=>{let l;r.key&&r.debug&&(l=Date.now());const o=e(a);if(!(o.length!==n.length||o.some((m,p)=>n[p]!==m)))return i;n=o;let g;if(r.key&&r.debug&&(g=Date.now()),i=s(...o),r==null||r.onChange==null||r.onChange(i),r.key&&r.debug&&r!=null&&r.debug()){const m=Math.round((Date.now()-l)*100)/100,p=Math.round((Date.now()-g)*100)/100,u=p/16,d=(f,h)=>{for(f=String(f);f.length<h;)f=" "+f;return f};console.info(`%câ± ${d(p,5)} /${d(m,5)} ms`,` 18 font-size: .6rem; 19 font-weight: bold; 20 color: hsl(${Math.max(0,Math.min(120-120*u,120))}deg 100% 31%);`,r==null?void 0:r.key)}return i}}function A(e,s,r,n){return{debug:()=>{var i;return(i=e==null?void 0:e.debugAll)!=null?i:e[s]},key:!1,onChange:n}}function Ws(e,s,r,n){const i=()=>{var l;return(l=a.getValue())!=null?l:e.options.renderFallbackValue},a={id:`${s.id}_${r.id}`,row:s,column:r,getValue:()=>s.getValue(n),renderValue:i,getContext:_(()=>[e,r,s,a],(l,o,c,g)=>({table:l,column:o,row:c,cell:g,getValue:g.getValue,renderValue:g.renderValue}),A(e.options,"debugCells"))};return e._features.forEach(l=>{l.createCell==null||l.createCell(a,r,s,e)},{}),a}function Qs(e,s,r,n){var i,a;const o={...e._getDefaultColumnDef(),...s},c=o.accessorKey;let g=(i=(a=o.id)!=null?a:c?typeof String.prototype.replaceAll=="function"?c.replaceAll(".","_"):c.replace(/\./g,"_"):void 0)!=null?i:typeof o.header=="string"?o.header:void 0,m;if(o.accessorFn?m=o.accessorFn:c&&(c.includes(".")?m=u=>{let d=u;for(const h of c.split(".")){var f;d=(f=d)==null?void 0:f[h]}return d}:m=u=>u[o.accessorKey]),!g)throw new Error;let p={id:`${String(g)}`,accessorFn:m,parent:n,depth:r,columnDef:o,columns:[],getFlatColumns:_(()=>[!0],()=>{var u;return[p,...(u=p.columns)==null?void 0:u.flatMap(d=>d.getFlatColumns())]},A(e.options,"debugColumns")),getLeafColumns:_(()=>[e._getOrderColumnsFn()],u=>{var d;if((d=p.columns)!=null&&d.length){let f=p.columns.flatMap(h=>h.getLeafColumns());return u(f)}return[p]},A(e.options,"debugColumns"))};for(const u of e._features)u.createColumn==null||u.createColumn(p,e);return p}const le="debugHeaders";function dn(e,s,r){var n;let a={id:(n=r.id)!=null?n:s.id,column:s,index:r.index,isPlaceholder:!!r.isPlaceholder,placeholderId:r.placeholderId,depth:r.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const l=[],o=c=>{c.subHeaders&&c.subHeaders.length&&c.subHeaders.map(o),l.push(c)};return o(a),l},getContext:()=>({table:e,header:a,column:s})};return e._features.forEach(l=>{l.createHeader==null||l.createHeader(a,e)}),a}const Ks={createTable:e=>{e.getHeaderGroups=_(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(s,r,n,i)=>{var a,l;const o=(a=n==null?void 0:n.map(p=>r.find(u=>u.id===p)).filter(Boolean))!=null?a:[],c=(l=i==null?void 0:i.map(p=>r.find(u=>u.id===p)).filter(Boolean))!=null?l:[],g=r.filter(p=>!(n!=null&&n.includes(p.id))&&!(i!=null&&i.includes(p.id)));return Ut(s,[...o,...g,...c],e)},A(e.options,le)),e.getCenterHeaderGroups=_(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(s,r,n,i)=>(r=r.filter(a=>!(n!=null&&n.includes(a.id))&&!(i!=null&&i.includes(a.id))),Ut(s,r,e,"center")),A(e.options,le)),e.getLeftHeaderGroups=_(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(s,r,n)=>{var i;const a=(i=n==null?void 0:n.map(l=>r.find(o=>o.id===l)).filter(Boolean))!=null?i:[];return Ut(s,a,e,"left")},A(e.options,le)),e.getRightHeaderGroups=_(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(s,r,n)=>{var i;const a=(i=n==null?void 0:n.map(l=>r.find(o=>o.id===l)).filter(Boolean))!=null?i:[];return Ut(s,a,e,"right")},A(e.options,le)),e.getFooterGroups=_(()=>[e.getHeaderGroups()],s=>[...s].reverse(),A(e.options,le)),e.getLeftFooterGroups=_(()=>[e.getLeftHeaderGroups()],s=>[...s].reverse(),A(e.options,le)),e.getCenterFooterGroups=_(()=>[e.getCenterHeaderGroups()],s=>[...s].reverse(),A(e.options,le)),e.getRightFooterGroups=_(()=>[e.getRightHeaderGroups()],s=>[...s].reverse(),A(e.options,le)),e.getFlatHeaders=_(()=>[e.getHeaderGroups()],s=>s.map(r=>r.headers).flat(),A(e.options,le)),e.getLeftFlatHeaders=_(()=>[e.getLeftHeaderGroups()],s=>s.map(r=>r.headers).flat(),A(e.options,le)),e.getCenterFlatHeaders=_(()=>[e.getCenterHeaderGroups()],s=>s.map(r=>r.headers).flat(),A(e.options,le)),e.getRightFlatHeaders=_(()=>[e.getRightHeaderGroups()],s=>s.map(r=>r.headers).flat(),A(e.options,le)),e.getCenterLeafHeaders=_(()=>[e.getCenterFlatHeaders()],s=>s.filter(r=>{var n;return!((n=r.subHeaders)!=null&&n.length)}),A(e.options,le)),e.getLeftLeafHeaders=_(()=>[e.getLeftFlatHeaders()],s=>s.filter(r=>{var n;return!((n=r.subHeaders)!=null&&n.length)}),A(e.options,le)),e.getRightLeafHeaders=_(()=>[e.getRightFlatHeaders()],s=>s.filter(r=>{var n;return!((n=r.subHeaders)!=null&&n.length)}),A(e.options,le)),e.getLeafHeaders=_(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(s,r,n)=>{var i,a,l,o,c,g;return[...(i=(a=s[0])==null?void 0:a.headers)!=null?i:[],...(l=(o=r[0])==null?void 0:o.headers)!=null?l:[],...(c=(g=n[0])==null?void 0:g.headers)!=null?c:[]].map(m=>m.getLeafHeaders()).flat()},A(e.options,le))}};function Ut(e,s,r,n){var i,a;let l=0;const o=function(u,d){d===void 0&&(d=1),l=Math.max(l,d),u.filter(f=>f.getIsVisible()).forEach(f=>{var h;(h=f.columns)!=null&&h.length&&o(f.columns,d+1)},0)};o(e);let c=[];const g=(u,d)=>{const f={depth:d,id:[n,`${d}`].filter(Boolean).join("_"),headers:[]},h=[];u.forEach(C=>{const v=[...h].reverse()[0],w=C.column.depth===f.depth;let N,x=!1;if(w&&C.column.parent?N=C.column.parent:(N=C.column,x=!0),v&&(v==null?void 0:v.column)===N)v.subHeaders.push(C);else{const b=dn(r,N,{id:[n,d,N.id,C==null?void 0:C.id].filter(Boolean).join("_"),isPlaceholder:x,placeholderId:x?`${h.filter(k=>k.column===N).length}`:void 0,depth:d,index:h.length});b.subHeaders.push(C),h.push(b)}f.headers.push(C),C.headerGroup=f}),c.push(f),d>0&&g(h,d-1)},m=s.map((u,d)=>dn(r,u,{depth:l,index:d}));g(m,l-1),c.reverse();const p=u=>u.filter(f=>f.column.getIsVisible()).map(f=>{let h=0,C=0,v=[0];f.subHeaders&&f.subHeaders.length?(v=[],p(f.subHeaders).forEach(N=>{let{colSpan:x,rowSpan:b}=N;h+=x,v.push(b)})):h=1;const w=Math.min(...v);return C=C+w,f.colSpan=h,f.rowSpan=C,{colSpan:h,rowSpan:C}});return p((i=(a=c[0])==null?void 0:a.headers)!=null?i:[]),c}const Vr=(e,s,r,n,i,a,l)=>{let o={id:s,index:n,original:r,depth:i,parentId:l,_valuesCache:{},_uniqueValuesCache:{},getValue:c=>{if(o._valuesCache.hasOwnProperty(c))return o._valuesCache[c];const g=e.getColumn(c);if(g!=null&&g.accessorFn)return o._valuesCache[c]=g.accessorFn(o.original,n),o._valuesCache[c]},getUniqueValues:c=>{if(o._uniqueValuesCache.hasOwnProperty(c))return o._uniqueValuesCache[c];const g=e.getColumn(c);if(g!=null&&g.accessorFn)return g.columnDef.getUniqueValues?(o._uniqueValuesCache[c]=g.columnDef.getUniqueValues(o.original,n),o._uniqueValuesCache[c]):(o._uniqueValuesCache[c]=[o.getValue(c)],o._uniqueValuesCache[c])},renderValue:c=>{var g;return(g=o.getValue(c))!=null?g:e.options.renderFallbackValue},subRows:[],getLeafRows:()=>qs(o.subRows,c=>c.subRows),getParentRow:()=>o.parentId?e.getRow(o.parentId,!0):void 0,getParentRows:()=>{let c=[],g=o;for(;;){const m=g.getParentRow();if(!m)break;c.push(m),g=m}return c.reverse()},getAllCells:_(()=>[e.getAllLeafColumns()],c=>c.map(g=>Ws(e,o,g,g.id)),A(e.options,"debugRows")),_getAllCellsByColumnId:_(()=>[o.getAllCells()],c=>c.reduce((g,m)=>(g[m.column.id]=m,g),{}),A(e.options,"debugRows"))};for(let c=0;c<e._features.length;c++){const g=e._features[c];g==null||g.createRow==null||g.createRow(o,e)}return o},Ys={createColumn:(e,s)=>{e._getFacetedRowModel=s.options.getFacetedRowModel&&s.options.getFacetedRowModel(s,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():s.getPreFilteredRowModel(),e._getFacetedUniqueValues=s.options.getFacetedUniqueValues&&s.options.getFacetedUniqueValues(s,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=s.options.getFacetedMinMaxValues&&s.options.getFacetedMinMaxValues(s,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},Rn=(e,s,r)=>{var n,i;const a=r==null||(n=r.toString())==null?void 0:n.toLowerCase();return!!(!((i=e.getValue(s))==null||(i=i.toString())==null||(i=i.toLowerCase())==null)&&i.includes(a))};Rn.autoRemove=e=>be(e);const Fn=(e,s,r)=>{var n;return!!(!((n=e.getValue(s))==null||(n=n.toString())==null)&&n.includes(r))};Fn.autoRemove=e=>be(e);const En=(e,s,r)=>{var n;return((n=e.getValue(s))==null||(n=n.toString())==null?void 0:n.toLowerCase())===(r==null?void 0:r.toLowerCase())};En.autoRemove=e=>be(e);const Mn=(e,s,r)=>{var n;return(n=e.getValue(s))==null?void 0:n.includes(r)};Mn.autoRemove=e=>be(e);const Pn=(e,s,r)=>!r.some(n=>{var i;return!((i=e.getValue(s))!=null&&i.includes(n))});Pn.autoRemove=e=>be(e)||!(e!=null&&e.length);const Dn=(e,s,r)=>r.some(n=>{var i;return(i=e.getValue(s))==null?void 0:i.includes(n)});Dn.autoRemove=e=>be(e)||!(e!=null&&e.length);const In=(e,s,r)=>e.getValue(s)===r;In.autoRemove=e=>be(e);const $n=(e,s,r)=>e.getValue(s)==r;$n.autoRemove=e=>be(e);const Tr=(e,s,r)=>{let[n,i]=r;const a=e.getValue(s);return a>=n&&a<=i};Tr.resolveFilterValue=e=>{let[s,r]=e,n=typeof s!="number"?parseFloat(s):s,i=typeof r!="number"?parseFloat(r):r,a=s===null||Number.isNaN(n)?-1/0:n,l=r===null||Number.isNaN(i)?1/0:i;if(a>l){const o=a;a=l,l=o}return[a,l]};Tr.autoRemove=e=>be(e)||be(e[0])&&be(e[1]);const Ee={includesString:Rn,includesStringSensitive:Fn,equalsString:En,arrIncludes:Mn,arrIncludesAll:Pn,arrIncludesSome:Dn,equals:In,weakEquals:$n,inNumberRange:Tr};function be(e){return e==null||e===""}const Xs={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:me("columnFilters",e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,s)=>{e.getAutoFilterFn=()=>{const r=s.getCoreRowModel().flatRows[0],n=r==null?void 0:r.getValue(e.id);return typeof n=="string"?Ee.includesString:typeof n=="number"?Ee.inNumberRange:typeof n=="boolean"||n!==null&&typeof n=="object"?Ee.equals:Array.isArray(n)?Ee.arrIncludes:Ee.weakEquals},e.getFilterFn=()=>{var r,n;return Yt(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn==="auto"?e.getAutoFilterFn():(r=(n=s.options.filterFns)==null?void 0:n[e.columnDef.filterFn])!=null?r:Ee[e.columnDef.filterFn]},e.getCanFilter=()=>{var r,n,i;return((r=e.columnDef.enableColumnFilter)!=null?r:!0)&&((n=s.options.enableColumnFilters)!=null?n:!0)&&((i=s.options.enableFilters)!=null?i:!0)&&!!e.accessorFn},e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var r;return(r=s.getState().columnFilters)==null||(r=r.find(n=>n.id===e.id))==null?void 0:r.value},e.getFilterIndex=()=>{var r,n;return(r=(n=s.getState().columnFilters)==null?void 0:n.findIndex(i=>i.id===e.id))!=null?r:-1},e.setFilterValue=r=>{s.setColumnFilters(n=>{const i=e.getFilterFn(),a=n==null?void 0:n.find(m=>m.id===e.id),l=Ae(r,a?a.value:void 0);if(cn(i,l,e)){var o;return(o=n==null?void 0:n.filter(m=>m.id!==e.id))!=null?o:[]}const c={id:e.id,value:l};if(a){var g;return(g=n==null?void 0:n.map(m=>m.id===e.id?c:m))!=null?g:[]}return n!=null&&n.length?[...n,c]:[c]})}},createRow:(e,s)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=s=>{const r=e.getAllLeafColumns(),n=i=>{var a;return(a=Ae(s,i))==null?void 0:a.filter(l=>{const o=r.find(c=>c.id===l.id);if(o){const c=o.getFilterFn();if(cn(c,l.value,o))return!1}return!0})};e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(n)},e.resetColumnFilters=s=>{var r,n;e.setColumnFilters(s?[]:(r=(n=e.initialState)==null?void 0:n.columnFilters)!=null?r:[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function cn(e,s,r){return(e&&e.autoRemove?e.autoRemove(s,r):!1)||typeof s>"u"||typeof s=="string"&&!s}const Js=(e,s,r)=>r.reduce((n,i)=>{const a=i.getValue(e);return n+(typeof a=="number"?a:0)},0),Zs=(e,s,r)=>{let n;return r.forEach(i=>{const a=i.getValue(e);a!=null&&(n>a||n===void 0&&a>=a)&&(n=a)}),n},ei=(e,s,r)=>{let n;return r.forEach(i=>{const a=i.getValue(e);a!=null&&(n<a||n===void 0&&a>=a)&&(n=a)}),n},ti=(e,s,r)=>{let n,i;return r.forEach(a=>{const l=a.getValue(e);l!=null&&(n===void 0?l>=l&&(n=i=l):(n>l&&(n=l),i<l&&(i=l)))}),[n,i]},ri=(e,s)=>{let r=0,n=0;if(s.forEach(i=>{let a=i.getValue(e);a!=null&&(a=+a)>=a&&(++r,n+=a)}),r)return n/r},ni=(e,s)=>{if(!s.length)return;const r=s.map(a=>a.getValue(e));if(!Us(r))return;if(r.length===1)return r[0];const n=Math.floor(r.length/2),i=r.sort((a,l)=>a-l);return r.length%2!==0?i[n]:(i[n-1]+i[n])/2},si=(e,s)=>Array.from(new Set(s.map(r=>r.getValue(e))).values()),ii=(e,s)=>new Set(s.map(r=>r.getValue(e))).size,ai=(e,s)=>s.length,dr={sum:Js,min:Zs,max:ei,extent:ti,mean:ri,median:ni,unique:si,uniqueCount:ii,count:ai},li={getDefaultColumnDef:()=>({aggregatedCell:e=>{var s,r;return(s=(r=e.getValue())==null||r.toString==null?void 0:r.toString())!=null?s:null},aggregationFn:"auto"}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:me("grouping",e),groupedColumnMode:"reorder"}),createColumn:(e,s)=>{e.toggleGrouping=()=>{s.setGrouping(r=>r!=null&&r.includes(e.id)?r.filter(n=>n!==e.id):[...r??[],e.id])},e.getCanGroup=()=>{var r,n;return((r=e.columnDef.enableGrouping)!=null?r:!0)&&((n=s.options.enableGrouping)!=null?n:!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue)},e.getIsGrouped=()=>{var r;return(r=s.getState().grouping)==null?void 0:r.includes(e.id)},e.getGroupedIndex=()=>{var r;return(r=s.getState().grouping)==null?void 0:r.indexOf(e.id)},e.getToggleGroupingHandler=()=>{const r=e.getCanGroup();return()=>{r&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{const r=s.getCoreRowModel().flatRows[0],n=r==null?void 0:r.getValue(e.id);if(typeof n=="number")return dr.sum;if(Object.prototype.toString.call(n)==="[object Date]")return dr.extent},e.getAggregationFn=()=>{var r,n;if(!e)throw new Error;return Yt(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn==="auto"?e.getAutoAggregationFn():(r=(n=s.options.aggregationFns)==null?void 0:n[e.columnDef.aggregationFn])!=null?r:dr[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=s=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(s),e.resetGrouping=s=>{var r,n;e.setGrouping(s?[]:(r=(n=e.initialState)==null?void 0:n.grouping)!=null?r:[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,s)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=r=>{if(e._groupingValuesCache.hasOwnProperty(r))return e._groupingValuesCache[r];const n=s.getColumn(r);return n!=null&&n.columnDef.getGroupingValue?(e._groupingValuesCache[r]=n.columnDef.getGroupingValue(e.original),e._groupingValuesCache[r]):e.getValue(r)},e._groupingValuesCache={}},createCell:(e,s,r,n)=>{e.getIsGrouped=()=>s.getIsGrouped()&&s.id===r.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&s.getIsGrouped(),e.getIsAggregated=()=>{var i;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((i=r.subRows)!=null&&i.length)}}};function oi(e,s,r){if(!(s!=null&&s.length)||!r)return e;const n=e.filter(a=>!s.includes(a.id));return r==="remove"?n:[...s.map(a=>e.find(l=>l.id===a)).filter(Boolean),...n]}const di={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:me("columnOrder",e)}),createColumn:(e,s)=>{e.getIndex=_(r=>[Ct(s,r)],r=>r.findIndex(n=>n.id===e.id),A(s.options,"debugColumns")),e.getIsFirstColumn=r=>{var n;return((n=Ct(s,r)[0])==null?void 0:n.id)===e.id},e.getIsLastColumn=r=>{var n;const i=Ct(s,r);return((n=i[i.length-1])==null?void 0:n.id)===e.id}},createTable:e=>{e.setColumnOrder=s=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(s),e.resetColumnOrder=s=>{var r;e.setColumnOrder(s?[]:(r=e.initialState.columnOrder)!=null?r:[])},e._getOrderColumnsFn=_(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(s,r,n)=>i=>{let a=[];if(!(s!=null&&s.length))a=i;else{const l=[...s],o=[...i];for(;o.length&&l.length;){const c=l.shift(),g=o.findIndex(m=>m.id===c);g>-1&&a.push(o.splice(g,1)[0])}a=[...a,...o]}return oi(a,r,n)},A(e.options,"debugTable"))}},cr=()=>({left:[],right:[]}),ci={getInitialState:e=>({columnPinning:cr(),...e}),getDefaultOptions:e=>({onColumnPinningChange:me("columnPinning",e)}),createColumn:(e,s)=>{e.pin=r=>{const n=e.getLeafColumns().map(i=>i.id).filter(Boolean);s.setColumnPinning(i=>{var a,l;if(r==="right"){var o,c;return{left:((o=i==null?void 0:i.left)!=null?o:[]).filter(p=>!(n!=null&&n.includes(p))),right:[...((c=i==null?void 0:i.right)!=null?c:[]).filter(p=>!(n!=null&&n.includes(p))),...n]}}if(r==="left"){var g,m;return{left:[...((g=i==null?void 0:i.left)!=null?g:[]).filter(p=>!(n!=null&&n.includes(p))),...n],right:((m=i==null?void 0:i.right)!=null?m:[]).filter(p=>!(n!=null&&n.includes(p)))}}return{left:((a=i==null?void 0:i.left)!=null?a:[]).filter(p=>!(n!=null&&n.includes(p))),right:((l=i==null?void 0:i.right)!=null?l:[]).filter(p=>!(n!=null&&n.includes(p)))}})},e.getCanPin=()=>e.getLeafColumns().some(n=>{var i,a,l;return((i=n.columnDef.enablePinning)!=null?i:!0)&&((a=(l=s.options.enableColumnPinning)!=null?l:s.options.enablePinning)!=null?a:!0)}),e.getIsPinned=()=>{const r=e.getLeafColumns().map(o=>o.id),{left:n,right:i}=s.getState().columnPinning,a=r.some(o=>n==null?void 0:n.includes(o)),l=r.some(o=>i==null?void 0:i.includes(o));return a?"left":l?"right":!1},e.getPinnedIndex=()=>{var r,n;const i=e.getIsPinned();return i?(r=(n=s.getState().columnPinning)==null||(n=n[i])==null?void 0:n.indexOf(e.id))!=null?r:-1:0}},createRow:(e,s)=>{e.getCenterVisibleCells=_(()=>[e._getAllVisibleCells(),s.getState().columnPinning.left,s.getState().columnPinning.right],(r,n,i)=>{const a=[...n??[],...i??[]];return r.filter(l=>!a.includes(l.column.id))},A(s.options,"debugRows")),e.getLeftVisibleCells=_(()=>[e._getAllVisibleCells(),s.getState().columnPinning.left],(r,n)=>(n??[]).map(a=>r.find(l=>l.column.id===a)).filter(Boolean).map(a=>({...a,position:"left"})),A(s.options,"debugRows")),e.getRightVisibleCells=_(()=>[e._getAllVisibleCells(),s.getState().columnPinning.right],(r,n)=>(n??[]).map(a=>r.find(l=>l.column.id===a)).filter(Boolean).map(a=>({...a,position:"right"})),A(s.options,"debugRows"))},createTable:e=>{e.setColumnPinning=s=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(s),e.resetColumnPinning=s=>{var r,n;return e.setColumnPinning(s?cr():(r=(n=e.initialState)==null?void 0:n.columnPinning)!=null?r:cr())},e.getIsSomeColumnsPinned=s=>{var r;const n=e.getState().columnPinning;if(!s){var i,a;return!!((i=n.left)!=null&&i.length||(a=n.right)!=null&&a.length)}return!!((r=n[s])!=null&&r.length)},e.getLeftLeafColumns=_(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(s,r)=>(r??[]).map(n=>s.find(i=>i.id===n)).filter(Boolean),A(e.options,"debugColumns")),e.getRightLeafColumns=_(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(s,r)=>(r??[]).map(n=>s.find(i=>i.id===n)).filter(Boolean),A(e.options,"debugColumns")),e.getCenterLeafColumns=_(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(s,r,n)=>{const i=[...r??[],...n??[]];return s.filter(a=>!i.includes(a.id))},A(e.options,"debugColumns"))}};function ui(e){return e||(typeof document<"u"?document:null)}const qt={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},ur=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),gi={getDefaultColumnDef:()=>qt,getInitialState:e=>({columnSizing:{},columnSizingInfo:ur(),...e}),getDefaultOptions:e=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:me("columnSizing",e),onColumnSizingInfoChange:me("columnSizingInfo",e)}),createColumn:(e,s)=>{e.getSize=()=>{var r,n,i;const a=s.getState().columnSizing[e.id];return Math.min(Math.max((r=e.columnDef.minSize)!=null?r:qt.minSize,(n=a??e.columnDef.size)!=null?n:qt.size),(i=e.columnDef.maxSize)!=null?i:qt.maxSize)},e.getStart=_(r=>[r,Ct(s,r),s.getState().columnSizing],(r,n)=>n.slice(0,e.getIndex(r)).reduce((i,a)=>i+a.getSize(),0),A(s.options,"debugColumns")),e.getAfter=_(r=>[r,Ct(s,r),s.getState().columnSizing],(r,n)=>n.slice(e.getIndex(r)+1).reduce((i,a)=>i+a.getSize(),0),A(s.options,"debugColumns")),e.resetSize=()=>{s.setColumnSizing(r=>{let{[e.id]:n,...i}=r;return i})},e.getCanResize=()=>{var r,n;return((r=e.columnDef.enableResizing)!=null?r:!0)&&((n=s.options.enableColumnResizing)!=null?n:!0)},e.getIsResizing=()=>s.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,s)=>{e.getSize=()=>{let r=0;const n=i=>{if(i.subHeaders.length)i.subHeaders.forEach(n);else{var a;r+=(a=i.column.getSize())!=null?a:0}};return n(e),r},e.getStart=()=>{if(e.index>0){const r=e.headerGroup.headers[e.index-1];return r.getStart()+r.getSize()}return 0},e.getResizeHandler=r=>{const n=s.getColumn(e.column.id),i=n==null?void 0:n.getCanResize();return a=>{if(!n||!i||(a.persist==null||a.persist(),gr(a)&&a.touches&&a.touches.length>1))return;const l=e.getSize(),o=e?e.getLeafHeaders().map(v=>[v.column.id,v.column.getSize()]):[[n.id,n.getSize()]],c=gr(a)?Math.round(a.touches[0].clientX):a.clientX,g={},m=(v,w)=>{typeof w=="number"&&(s.setColumnSizingInfo(N=>{var x,b;const k=s.options.columnResizeDirection==="rtl"?-1:1,P=(w-((x=N==null?void 0:N.startOffset)!=null?x:0))*k,I=Math.max(P/((b=N==null?void 0:N.startSize)!=null?b:0),-.999999);return N.columnSizingStart.forEach(M=>{let[$,G]=M;g[$]=Math.round(Math.max(G+G*I,0)*100)/100}),{...N,deltaOffset:P,deltaPercentage:I}}),(s.options.columnResizeMode==="onChange"||v==="end")&&s.setColumnSizing(N=>({...N,...g})))},p=v=>m("move",v),u=v=>{m("end",v),s.setColumnSizingInfo(w=>({...w,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},d=ui(r),f={moveHandler:v=>p(v.clientX),upHandler:v=>{d==null||d.removeEventListener("mousemove",f.moveHandler),d==null||d.removeEventListener("mouseup",f.upHandler),u(v.clientX)}},h={moveHandler:v=>(v.cancelable&&(v.preventDefault(),v.stopPropagation()),p(v.touches[0].clientX),!1),upHandler:v=>{var w;d==null||d.removeEventListener("touchmove",h.moveHandler),d==null||d.removeEventListener("touchend",h.upHandler),v.cancelable&&(v.preventDefault(),v.stopPropagation()),u((w=v.touches[0])==null?void 0:w.clientX)}},C=pi()?{passive:!1}:!1;gr(a)?(d==null||d.addEventListener("touchmove",h.moveHandler,C),d==null||d.addEventListener("touchend",h.upHandler,C)):(d==null||d.addEventListener("mousemove",f.moveHandler,C),d==null||d.addEventListener("mouseup",f.upHandler,C)),s.setColumnSizingInfo(v=>({...v,startOffset:c,startSize:l,deltaOffset:0,deltaPercentage:0,columnSizingStart:o,isResizingColumn:n.id}))}}},createTable:e=>{e.setColumnSizing=s=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(s),e.setColumnSizingInfo=s=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(s),e.resetColumnSizing=s=>{var r;e.setColumnSizing(s?{}:(r=e.initialState.columnSizing)!=null?r:{})},e.resetHeaderSizeInfo=s=>{var r;e.setColumnSizingInfo(s?ur():(r=e.initialState.columnSizingInfo)!=null?r:ur())},e.getTotalSize=()=>{var s,r;return(s=(r=e.getHeaderGroups()[0])==null?void 0:r.headers.reduce((n,i)=>n+i.getSize(),0))!=null?s:0},e.getLeftTotalSize=()=>{var s,r;return(s=(r=e.getLeftHeaderGroups()[0])==null?void 0:r.headers.reduce((n,i)=>n+i.getSize(),0))!=null?s:0},e.getCenterTotalSize=()=>{var s,r;return(s=(r=e.getCenterHeaderGroups()[0])==null?void 0:r.headers.reduce((n,i)=>n+i.getSize(),0))!=null?s:0},e.getRightTotalSize=()=>{var s,r;return(s=(r=e.getRightHeaderGroups()[0])==null?void 0:r.headers.reduce((n,i)=>n+i.getSize(),0))!=null?s:0}}};let Wt=null;function pi(){if(typeof Wt=="boolean")return Wt;let e=!1;try{const s={get passive(){return e=!0,!1}},r=()=>{};window.addEventListener("test",r,s),window.removeEventListener("test",r)}catch{e=!1}return Wt=e,Wt}function gr(e){return e.type==="touchstart"}const mi={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:me("columnVisibility",e)}),createColumn:(e,s)=>{e.toggleVisibility=r=>{e.getCanHide()&&s.setColumnVisibility(n=>({...n,[e.id]:r??!e.getIsVisible()}))},e.getIsVisible=()=>{var r,n;const i=e.columns;return(r=i.length?i.some(a=>a.getIsVisible()):(n=s.getState().columnVisibility)==null?void 0:n[e.id])!=null?r:!0},e.getCanHide=()=>{var r,n;return((r=e.columnDef.enableHiding)!=null?r:!0)&&((n=s.options.enableHiding)!=null?n:!0)},e.getToggleVisibilityHandler=()=>r=>{e.toggleVisibility==null||e.toggleVisibility(r.target.checked)}},createRow:(e,s)=>{e._getAllVisibleCells=_(()=>[e.getAllCells(),s.getState().columnVisibility],r=>r.filter(n=>n.column.getIsVisible()),A(s.options,"debugRows")),e.getVisibleCells=_(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(r,n,i)=>[...r,...n,...i],A(s.options,"debugRows"))},createTable:e=>{const s=(r,n)=>_(()=>[n(),n().filter(i=>i.getIsVisible()).map(i=>i.id).join("_")],i=>i.filter(a=>a.getIsVisible==null?void 0:a.getIsVisible()),A(e.options,"debugColumns"));e.getVisibleFlatColumns=s("getVisibleFlatColumns",()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=s("getVisibleLeafColumns",()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=s("getLeftVisibleLeafColumns",()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=s("getRightVisibleLeafColumns",()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=s("getCenterVisibleLeafColumns",()=>e.getCenterLeafColumns()),e.setColumnVisibility=r=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(r),e.resetColumnVisibility=r=>{var n;e.setColumnVisibility(r?{}:(n=e.initialState.columnVisibility)!=null?n:{})},e.toggleAllColumnsVisible=r=>{var n;r=(n=r)!=null?n:!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((i,a)=>({...i,[a.id]:r||!(a.getCanHide!=null&&a.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(r=>!(r.getIsVisible!=null&&r.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(r=>r.getIsVisible==null?void 0:r.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>r=>{var n;e.toggleAllColumnsVisible((n=r.target)==null?void 0:n.checked)}}};function Ct(e,s){return s?s==="center"?e.getCenterVisibleLeafColumns():s==="left"?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}const fi={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,"__global__"),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,"__global__"),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,"__global__"),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},xi={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:me("globalFilter",e),globalFilterFn:"auto",getColumnCanGlobalFilter:s=>{var r;const n=(r=e.getCoreRowModel().flatRows[0])==null||(r=r._getAllCellsByColumnId()[s.id])==null?void 0:r.getValue();return typeof n=="string"||typeof n=="number"}}),createColumn:(e,s)=>{e.getCanGlobalFilter=()=>{var r,n,i,a;return((r=e.columnDef.enableGlobalFilter)!=null?r:!0)&&((n=s.options.enableGlobalFilter)!=null?n:!0)&&((i=s.options.enableFilters)!=null?i:!0)&&((a=s.options.getColumnCanGlobalFilter==null?void 0:s.options.getColumnCanGlobalFilter(e))!=null?a:!0)&&!!e.accessorFn}},createTable:e=>{e.getGlobalAutoFilterFn=()=>Ee.includesString,e.getGlobalFilterFn=()=>{var s,r;const{globalFilterFn:n}=e.options;return Yt(n)?n:n==="auto"?e.getGlobalAutoFilterFn():(s=(r=e.options.filterFns)==null?void 0:r[n])!=null?s:Ee[n]},e.setGlobalFilter=s=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(s)},e.resetGlobalFilter=s=>{e.setGlobalFilter(s?void 0:e.initialState.globalFilter)}}},hi={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:me("expanded",e),paginateExpandedRows:!0}),createTable:e=>{let s=!1,r=!1;e._autoResetExpanded=()=>{var n,i;if(!s){e._queue(()=>{s=!0});return}if((n=(i=e.options.autoResetAll)!=null?i:e.options.autoResetExpanded)!=null?n:!e.options.manualExpanding){if(r)return;r=!0,e._queue(()=>{e.resetExpanded(),r=!1})}},e.setExpanded=n=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(n),e.toggleAllRowsExpanded=n=>{n??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=n=>{var i,a;e.setExpanded(n?{}:(i=(a=e.initialState)==null?void 0:a.expanded)!=null?i:{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(n=>n.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>n=>{n.persist==null||n.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{const n=e.getState().expanded;return n===!0||Object.values(n).some(Boolean)},e.getIsAllRowsExpanded=()=>{const n=e.getState().expanded;return typeof n=="boolean"?n===!0:!(!Object.keys(n).length||e.getRowModel().flatRows.some(i=>!i.getIsExpanded()))},e.getExpandedDepth=()=>{let n=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(a=>{const l=a.split(".");n=Math.max(n,l.length)}),n},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,s)=>{e.toggleExpanded=r=>{s.setExpanded(n=>{var i;const a=n===!0?!0:!!(n!=null&&n[e.id]);let l={};if(n===!0?Object.keys(s.getRowModel().rowsById).forEach(o=>{l[o]=!0}):l=n,r=(i=r)!=null?i:!a,!a&&r)return{...l,[e.id]:!0};if(a&&!r){const{[e.id]:o,...c}=l;return c}return n})},e.getIsExpanded=()=>{var r;const n=s.getState().expanded;return!!((r=s.options.getIsRowExpanded==null?void 0:s.options.getIsRowExpanded(e))!=null?r:n===!0||n!=null&&n[e.id])},e.getCanExpand=()=>{var r,n,i;return(r=s.options.getRowCanExpand==null?void 0:s.options.getRowCanExpand(e))!=null?r:((n=s.options.enableExpanding)!=null?n:!0)&&!!((i=e.subRows)!=null&&i.length)},e.getIsAllParentsExpanded=()=>{let r=!0,n=e;for(;r&&n.parentId;)n=s.getRow(n.parentId,!0),r=n.getIsExpanded();return r},e.getToggleExpandedHandler=()=>{const r=e.getCanExpand();return()=>{r&&e.toggleExpanded()}}}},br=0,Nr=10,pr=()=>({pageIndex:br,pageSize:Nr}),yi={getInitialState:e=>({...e,pagination:{...pr(),...e==null?void 0:e.pagination}}),getDefaultOptions:e=>({onPaginationChange:me("pagination",e)}),createTable:e=>{let s=!1,r=!1;e._autoResetPageIndex=()=>{var n,i;if(!s){e._queue(()=>{s=!0});return}if((n=(i=e.options.autoResetAll)!=null?i:e.options.autoResetPageIndex)!=null?n:!e.options.manualPagination){if(r)return;r=!0,e._queue(()=>{e.resetPageIndex(),r=!1})}},e.setPagination=n=>{const i=a=>Ae(n,a);return e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(i)},e.resetPagination=n=>{var i;e.setPagination(n?pr():(i=e.initialState.pagination)!=null?i:pr())},e.setPageIndex=n=>{e.setPagination(i=>{let a=Ae(n,i.pageIndex);const l=typeof e.options.pageCount>"u"||e.options.pageCount===-1?Number.MAX_SAFE_INTEGER:e.options.pageCount-1;return a=Math.max(0,Math.min(a,l)),{...i,pageIndex:a}})},e.resetPageIndex=n=>{var i,a;e.setPageIndex(n?br:(i=(a=e.initialState)==null||(a=a.pagination)==null?void 0:a.pageIndex)!=null?i:br)},e.resetPageSize=n=>{var i,a;e.setPageSize(n?Nr:(i=(a=e.initialState)==null||(a=a.pagination)==null?void 0:a.pageSize)!=null?i:Nr)},e.setPageSize=n=>{e.setPagination(i=>{const a=Math.max(1,Ae(n,i.pageSize)),l=i.pageSize*i.pageIndex,o=Math.floor(l/a);return{...i,pageIndex:o,pageSize:a}})},e.setPageCount=n=>e.setPagination(i=>{var a;let l=Ae(n,(a=e.options.pageCount)!=null?a:-1);return typeof l=="number"&&(l=Math.max(-1,l)),{...i,pageCount:l}}),e.getPageOptions=_(()=>[e.getPageCount()],n=>{let i=[];return n&&n>0&&(i=[...new Array(n)].fill(null).map((a,l)=>l)),i},A(e.options,"debugTable")),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{const{pageIndex:n}=e.getState().pagination,i=e.getPageCount();return i===-1?!0:i===0?!1:n<i-1},e.previousPage=()=>e.setPageIndex(n=>n-1),e.nextPage=()=>e.setPageIndex(n=>n+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>{var n;return(n=e.options.pageCount)!=null?n:Math.ceil(e.getRowCount()/e.getState().pagination.pageSize)},e.getRowCount=()=>{var n;return(n=e.options.rowCount)!=null?n:e.getPrePaginationRowModel().rows.length}}},mr=()=>({top:[],bottom:[]}),vi={getInitialState:e=>({rowPinning:mr(),...e}),getDefaultOptions:e=>({onRowPinningChange:me("rowPinning",e)}),createRow:(e,s)=>{e.pin=(r,n,i)=>{const a=n?e.getLeafRows().map(c=>{let{id:g}=c;return g}):[],l=i?e.getParentRows().map(c=>{let{id:g}=c;return g}):[],o=new Set([...l,e.id,...a]);s.setRowPinning(c=>{var g,m;if(r==="bottom"){var p,u;return{top:((p=c==null?void 0:c.top)!=null?p:[]).filter(h=>!(o!=null&&o.has(h))),bottom:[...((u=c==null?void 0:c.bottom)!=null?u:[]).filter(h=>!(o!=null&&o.has(h))),...Array.from(o)]}}if(r==="top"){var d,f;return{top:[...((d=c==null?void 0:c.top)!=null?d:[]).filter(h=>!(o!=null&&o.has(h))),...Array.from(o)],bottom:((f=c==null?void 0:c.bottom)!=null?f:[]).filter(h=>!(o!=null&&o.has(h)))}}return{top:((g=c==null?void 0:c.top)!=null?g:[]).filter(h=>!(o!=null&&o.has(h))),bottom:((m=c==null?void 0:c.bottom)!=null?m:[]).filter(h=>!(o!=null&&o.has(h)))}})},e.getCanPin=()=>{var r;const{enableRowPinning:n,enablePinning:i}=s.options;return typeof n=="function"?n(e):(r=n??i)!=null?r:!0},e.getIsPinned=()=>{const r=[e.id],{top:n,bottom:i}=s.getState().rowPinning,a=r.some(o=>n==null?void 0:n.includes(o)),l=r.some(o=>i==null?void 0:i.includes(o));return a?"top":l?"bottom":!1},e.getPinnedIndex=()=>{var r,n;const i=e.getIsPinned();if(!i)return-1;const a=(r=i==="top"?s.getTopRows():s.getBottomRows())==null?void 0:r.map(l=>{let{id:o}=l;return o});return(n=a==null?void 0:a.indexOf(e.id))!=null?n:-1}},createTable:e=>{e.setRowPinning=s=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(s),e.resetRowPinning=s=>{var r,n;return e.setRowPinning(s?mr():(r=(n=e.initialState)==null?void 0:n.rowPinning)!=null?r:mr())},e.getIsSomeRowsPinned=s=>{var r;const n=e.getState().rowPinning;if(!s){var i,a;return!!((i=n.top)!=null&&i.length||(a=n.bottom)!=null&&a.length)}return!!((r=n[s])!=null&&r.length)},e._getPinnedRows=(s,r,n)=>{var i;return((i=e.options.keepPinnedRows)==null||i?(r??[]).map(l=>{const o=e.getRow(l,!0);return o.getIsAllParentsExpanded()?o:null}):(r??[]).map(l=>s.find(o=>o.id===l))).filter(Boolean).map(l=>({...l,position:n}))},e.getTopRows=_(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(s,r)=>e._getPinnedRows(s,r,"top"),A(e.options,"debugRows")),e.getBottomRows=_(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(s,r)=>e._getPinnedRows(s,r,"bottom"),A(e.options,"debugRows")),e.getCenterRows=_(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(s,r,n)=>{const i=new Set([...r??[],...n??[]]);return s.filter(a=>!i.has(a.id))},A(e.options,"debugRows"))}},wi={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:me("rowSelection",e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=s=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(s),e.resetRowSelection=s=>{var r;return e.setRowSelection(s?{}:(r=e.initialState.rowSelection)!=null?r:{})},e.toggleAllRowsSelected=s=>{e.setRowSelection(r=>{s=typeof s<"u"?s:!e.getIsAllRowsSelected();const n={...r},i=e.getPreGroupedRowModel().flatRows;return s?i.forEach(a=>{a.getCanSelect()&&(n[a.id]=!0)}):i.forEach(a=>{delete n[a.id]}),n})},e.toggleAllPageRowsSelected=s=>e.setRowSelection(r=>{const n=typeof s<"u"?s:!e.getIsAllPageRowsSelected(),i={...r};return e.getRowModel().rows.forEach(a=>{Sr(i,a.id,n,!0,e)}),i}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=_(()=>[e.getState().rowSelection,e.getCoreRowModel()],(s,r)=>Object.keys(s).length?fr(e,r):{rows:[],flatRows:[],rowsById:{}},A(e.options,"debugTable")),e.getFilteredSelectedRowModel=_(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(s,r)=>Object.keys(s).length?fr(e,r):{rows:[],flatRows:[],rowsById:{}},A(e.options,"debugTable")),e.getGroupedSelectedRowModel=_(()=>[e.getState().rowSelection,e.getSortedRowModel()],(s,r)=>Object.keys(s).length?fr(e,r):{rows:[],flatRows:[],rowsById:{}},A(e.options,"debugTable")),e.getIsAllRowsSelected=()=>{const s=e.getFilteredRowModel().flatRows,{rowSelection:r}=e.getState();let n=!!(s.length&&Object.keys(r).length);return n&&s.some(i=>i.getCanSelect()&&!r[i.id])&&(n=!1),n},e.getIsAllPageRowsSelected=()=>{const s=e.getPaginationRowModel().flatRows.filter(i=>i.getCanSelect()),{rowSelection:r}=e.getState();let n=!!s.length;return n&&s.some(i=>!r[i.id])&&(n=!1),n},e.getIsSomeRowsSelected=()=>{var s;const r=Object.keys((s=e.getState().rowSelection)!=null?s:{}).length;return r>0&&r<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{const s=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:s.filter(r=>r.getCanSelect()).some(r=>r.getIsSelected()||r.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>s=>{e.toggleAllRowsSelected(s.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>s=>{e.toggleAllPageRowsSelected(s.target.checked)}},createRow:(e,s)=>{e.toggleSelected=(r,n)=>{const i=e.getIsSelected();s.setRowSelection(a=>{var l;if(r=typeof r<"u"?r:!i,e.getCanSelect()&&i===r)return a;const o={...a};return Sr(o,e.id,r,(l=n==null?void 0:n.selectChildren)!=null?l:!0,s),o})},e.getIsSelected=()=>{const{rowSelection:r}=s.getState();return Lr(e,r)},e.getIsSomeSelected=()=>{const{rowSelection:r}=s.getState();return Cr(e,r)==="some"},e.getIsAllSubRowsSelected=()=>{const{rowSelection:r}=s.getState();return Cr(e,r)==="all"},e.getCanSelect=()=>{var r;return typeof s.options.enableRowSelection=="function"?s.options.enableRowSelection(e):(r=s.options.enableRowSelection)!=null?r:!0},e.getCanSelectSubRows=()=>{var r;return typeof s.options.enableSubRowSelection=="function"?s.options.enableSubRowSelection(e):(r=s.options.enableSubRowSelection)!=null?r:!0},e.getCanMultiSelect=()=>{var r;return typeof s.options.enableMultiRowSelection=="function"?s.options.enableMultiRowSelection(e):(r=s.options.enableMultiRowSelection)!=null?r:!0},e.getToggleSelectedHandler=()=>{const r=e.getCanSelect();return n=>{var i;r&&e.toggleSelected((i=n.target)==null?void 0:i.checked)}}}},Sr=(e,s,r,n,i)=>{var a;const l=i.getRow(s,!0);r?(l.getCanMultiSelect()||Object.keys(e).forEach(o=>delete e[o]),l.getCanSelect()&&(e[s]=!0)):delete e[s],n&&(a=l.subRows)!=null&&a.length&&l.getCanSelectSubRows()&&l.subRows.forEach(o=>Sr(e,o.id,r,n,i))};function fr(e,s){const r=e.getState().rowSelection,n=[],i={},a=function(l,o){return l.map(c=>{var g;const m=Lr(c,r);if(m&&(n.push(c),i[c.id]=c),(g=c.subRows)!=null&&g.length&&(c={...c,subRows:a(c.subRows)}),m)return c}).filter(Boolean)};return{rows:a(s.rows),flatRows:n,rowsById:i}}function Lr(e,s){var r;return(r=s[e.id])!=null?r:!1}function Cr(e,s,r){var n;if(!((n=e.subRows)!=null&&n.length))return!1;let i=!0,a=!1;return e.subRows.forEach(l=>{if(!(a&&!i)&&(l.getCanSelect()&&(Lr(l,s)?a=!0:i=!1),l.subRows&&l.subRows.length)){const o=Cr(l,s);o==="all"?a=!0:(o==="some"&&(a=!0),i=!1)}}),i?"all":a?"some":!1}const kr=/([0-9]+)/gm,ji=(e,s,r)=>_n(Le(e.getValue(r)).toLowerCase(),Le(s.getValue(r)).toLowerCase()),bi=(e,s,r)=>_n(Le(e.getValue(r)),Le(s.getValue(r))),Ni=(e,s,r)=>Hr(Le(e.getValue(r)).toLowerCase(),Le(s.getValue(r)).toLowerCase()),Si=(e,s,r)=>Hr(Le(e.getValue(r)),Le(s.getValue(r))),Ci=(e,s,r)=>{const n=e.getValue(r),i=s.getValue(r);return n>i?1:n<i?-1:0},ki=(e,s,r)=>Hr(e.getValue(r),s.getValue(r));function Hr(e,s){return e===s?0:e>s?1:-1}function Le(e){return typeof e=="number"?isNaN(e)||e===1/0||e===-1/0?"":String(e):typeof e=="string"?e:""}function _n(e,s){const r=e.split(kr).filter(Boolean),n=s.split(kr).filter(Boolean);for(;r.length&&n.length;){const i=r.shift(),a=n.shift(),l=parseInt(i,10),o=parseInt(a,10),c=[l,o].sort();if(isNaN(c[0])){if(i>a)return 1;if(a>i)return-1;continue}if(isNaN(c[1]))return isNaN(l)?-1:1;if(l>o)return 1;if(o>l)return-1}return r.length-n.length}const bt={alphanumeric:ji,alphanumericCaseSensitive:bi,text:Ni,textCaseSensitive:Si,datetime:Ci,basic:ki},Ri={getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:me("sorting",e),isMultiSortEvent:s=>s.shiftKey}),createColumn:(e,s)=>{e.getAutoSortingFn=()=>{const r=s.getFilteredRowModel().flatRows.slice(10);let n=!1;for(const i of r){const a=i==null?void 0:i.getValue(e.id);if(Object.prototype.toString.call(a)==="[object Date]")return bt.datetime;if(typeof a=="string"&&(n=!0,a.split(kr).length>1))return bt.alphanumeric}return n?bt.text:bt.basic},e.getAutoSortDir=()=>{const r=s.getFilteredRowModel().flatRows[0];return typeof(r==null?void 0:r.getValue(e.id))=="string"?"asc":"desc"},e.getSortingFn=()=>{var r,n;if(!e)throw new Error;return Yt(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn==="auto"?e.getAutoSortingFn():(r=(n=s.options.sortingFns)==null?void 0:n[e.columnDef.sortingFn])!=null?r:bt[e.columnDef.sortingFn]},e.toggleSorting=(r,n)=>{const i=e.getNextSortingOrder(),a=typeof r<"u"&&r!==null;s.setSorting(l=>{const o=l==null?void 0:l.find(d=>d.id===e.id),c=l==null?void 0:l.findIndex(d=>d.id===e.id);let g=[],m,p=a?r:i==="desc";if(l!=null&&l.length&&e.getCanMultiSort()&&n?o?m="toggle":m="add":l!=null&&l.length&&c!==l.length-1?m="replace":o?m="toggle":m="replace",m==="toggle"&&(a||i||(m="remove")),m==="add"){var u;g=[...l,{id:e.id,desc:p}],g.splice(0,g.length-((u=s.options.maxMultiSortColCount)!=null?u:Number.MAX_SAFE_INTEGER))}else m==="toggle"?g=l.map(d=>d.id===e.id?{...d,desc:p}:d):m==="remove"?g=l.filter(d=>d.id!==e.id):g=[{id:e.id,desc:p}];return g})},e.getFirstSortDir=()=>{var r,n;return((r=(n=e.columnDef.sortDescFirst)!=null?n:s.options.sortDescFirst)!=null?r:e.getAutoSortDir()==="desc")?"desc":"asc"},e.getNextSortingOrder=r=>{var n,i;const a=e.getFirstSortDir(),l=e.getIsSorted();return l?l!==a&&((n=s.options.enableSortingRemoval)==null||n)&&(!(r&&(i=s.options.enableMultiRemove)!=null)||i)?!1:l==="desc"?"asc":"desc":a},e.getCanSort=()=>{var r,n;return((r=e.columnDef.enableSorting)!=null?r:!0)&&((n=s.options.enableSorting)!=null?n:!0)&&!!e.accessorFn},e.getCanMultiSort=()=>{var r,n;return(r=(n=e.columnDef.enableMultiSort)!=null?n:s.options.enableMultiSort)!=null?r:!!e.accessorFn},e.getIsSorted=()=>{var r;const n=(r=s.getState().sorting)==null?void 0:r.find(i=>i.id===e.id);return n?n.desc?"desc":"asc":!1},e.getSortIndex=()=>{var r,n;return(r=(n=s.getState().sorting)==null?void 0:n.findIndex(i=>i.id===e.id))!=null?r:-1},e.clearSorting=()=>{s.setSorting(r=>r!=null&&r.length?r.filter(n=>n.id!==e.id):[])},e.getToggleSortingHandler=()=>{const r=e.getCanSort();return n=>{r&&(n.persist==null||n.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?s.options.isMultiSortEvent==null?void 0:s.options.isMultiSortEvent(n):!1))}}},createTable:e=>{e.setSorting=s=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(s),e.resetSorting=s=>{var r,n;e.setSorting(s?[]:(r=(n=e.initialState)==null?void 0:n.sorting)!=null?r:[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},Fi=[Ks,mi,di,ci,Ys,Xs,fi,xi,Ri,li,hi,yi,vi,wi,gi];function Ei(e){var s,r;const n=[...Fi,...(s=e._features)!=null?s:[]];let i={_features:n};const a=i._features.reduce((u,d)=>Object.assign(u,d.getDefaultOptions==null?void 0:d.getDefaultOptions(i)),{}),l=u=>i.options.mergeOptions?i.options.mergeOptions(a,u):{...a,...u};let c={...{},...(r=e.initialState)!=null?r:{}};i._features.forEach(u=>{var d;c=(d=u.getInitialState==null?void 0:u.getInitialState(c))!=null?d:c});const g=[];let m=!1;const p={_features:n,options:{...a,...e},initialState:c,_queue:u=>{g.push(u),m||(m=!0,Promise.resolve().then(()=>{for(;g.length;)g.shift()();m=!1}).catch(d=>setTimeout(()=>{throw d})))},reset:()=>{i.setState(i.initialState)},setOptions:u=>{const d=Ae(u,i.options);i.options=l(d)},getState:()=>i.options.state,setState:u=>{i.options.onStateChange==null||i.options.onStateChange(u)},_getRowId:(u,d,f)=>{var h;return(h=i.options.getRowId==null?void 0:i.options.getRowId(u,d,f))!=null?h:`${f?[f.id,d].join("."):d}`},getCoreRowModel:()=>(i._getCoreRowModel||(i._getCoreRowModel=i.options.getCoreRowModel(i)),i._getCoreRowModel()),getRowModel:()=>i.getPaginationRowModel(),getRow:(u,d)=>{let f=(d?i.getPrePaginationRowModel():i.getRowModel()).rowsById[u];if(!f&&(f=i.getCoreRowModel().rowsById[u],!f))throw new Error;return f},_getDefaultColumnDef:_(()=>[i.options.defaultColumn],u=>{var d;return u=(d=u)!=null?d:{},{header:f=>{const h=f.header.column.columnDef;return h.accessorKey?h.accessorKey:h.accessorFn?h.id:null},cell:f=>{var h,C;return(h=(C=f.renderValue())==null||C.toString==null?void 0:C.toString())!=null?h:null},...i._features.reduce((f,h)=>Object.assign(f,h.getDefaultColumnDef==null?void 0:h.getDefaultColumnDef()),{}),...u}},A(e,"debugColumns")),_getColumnDefs:()=>i.options.columns,getAllColumns:_(()=>[i._getColumnDefs()],u=>{const d=function(f,h,C){return C===void 0&&(C=0),f.map(v=>{const w=Qs(i,v,C,h),N=v;return w.columns=N.columns?d(N.columns,w,C+1):[],w})};return d(u)},A(e,"debugColumns")),getAllFlatColumns:_(()=>[i.getAllColumns()],u=>u.flatMap(d=>d.getFlatColumns()),A(e,"debugColumns")),_getAllFlatColumnsById:_(()=>[i.getAllFlatColumns()],u=>u.reduce((d,f)=>(d[f.id]=f,d),{}),A(e,"debugColumns")),getAllLeafColumns:_(()=>[i.getAllColumns(),i._getOrderColumnsFn()],(u,d)=>{let f=u.flatMap(h=>h.getLeafColumns());return d(f)},A(e,"debugColumns")),getColumn:u=>i._getAllFlatColumnsById()[u]};Object.assign(i,p);for(let u=0;u<i._features.length;u++){const d=i._features[u];d==null||d.createTable==null||d.createTable(i)}return i}function Mi(){return e=>_(()=>[e.options.data],s=>{const r={rows:[],flatRows:[],rowsById:{}},n=function(i,a,l){a===void 0&&(a=0);const o=[];for(let g=0;g<i.length;g++){const m=Vr(e,e._getRowId(i[g],g,l),i[g],g,a,void 0,l==null?void 0:l.id);if(r.flatRows.push(m),r.rowsById[m.id]=m,o.push(m),e.options.getSubRows){var c;m.originalSubRows=e.options.getSubRows(i[g],g),(c=m.originalSubRows)!=null&&c.length&&(m.subRows=n(m.originalSubRows,a+1,m))}}return o};return r.rows=n(s),r},A(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex()))}function Pi(e){const s=[],r=n=>{var i;s.push(n),(i=n.subRows)!=null&&i.length&&n.getIsExpanded()&&n.subRows.forEach(r)};return e.rows.forEach(r),{rows:s,flatRows:e.flatRows,rowsById:e.rowsById}}function Di(e,s,r){return r.options.filterFromLeafRows?Ii(e,s,r):$i(e,s,r)}function Ii(e,s,r){var n;const i=[],a={},l=(n=r.options.maxLeafRowFilterDepth)!=null?n:100,o=function(c,g){g===void 0&&(g=0);const m=[];for(let u=0;u<c.length;u++){var p;let d=c[u];const f=Vr(r,d.id,d.original,d.index,d.depth,void 0,d.parentId);if(f.columnFilters=d.columnFilters,(p=d.subRows)!=null&&p.length&&g<l){if(f.subRows=o(d.subRows,g+1),d=f,s(d)&&!f.subRows.length){m.push(d),a[d.id]=d,i.push(d);continue}if(s(d)||f.subRows.length){m.push(d),a[d.id]=d,i.push(d);continue}}else d=f,s(d)&&(m.push(d),a[d.id]=d,i.push(d))}return m};return{rows:o(e),flatRows:i,rowsById:a}}function $i(e,s,r){var n;const i=[],a={},l=(n=r.options.maxLeafRowFilterDepth)!=null?n:100,o=function(c,g){g===void 0&&(g=0);const m=[];for(let u=0;u<c.length;u++){let d=c[u];if(s(d)){var p;if((p=d.subRows)!=null&&p.length&&g<l){const h=Vr(r,d.id,d.original,d.index,d.depth,void 0,d.parentId);h.subRows=o(d.subRows,g+1),d=h}m.push(d),i.push(d),a[d.id]=d}}return m};return{rows:o(e),flatRows:i,rowsById:a}}function _i(){return(e,s)=>_(()=>{var r;return[(r=e.getColumn(s))==null?void 0:r.getFacetedRowModel()]},r=>{if(!r)return new Map;let n=new Map;for(let a=0;a<r.flatRows.length;a++){const l=r.flatRows[a].getUniqueValues(s);for(let o=0;o<l.length;o++){const c=l[o];if(n.has(c)){var i;n.set(c,((i=n.get(c))!=null?i:0)+1)}else n.set(c,1)}}return n},A(e.options,"debugTable"))}function Ai(){return e=>_(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter],(s,r,n)=>{if(!s.rows.length||!(r!=null&&r.length)&&!n){for(let u=0;u<s.flatRows.length;u++)s.flatRows[u].columnFilters={},s.flatRows[u].columnFiltersMeta={};return s}const i=[],a=[];(r??[]).forEach(u=>{var d;const f=e.getColumn(u.id);if(!f)return;const h=f.getFilterFn();h&&i.push({id:u.id,filterFn:h,resolvedValue:(d=h.resolveFilterValue==null?void 0:h.resolveFilterValue(u.value))!=null?d:u.value})});const l=(r??[]).map(u=>u.id),o=e.getGlobalFilterFn(),c=e.getAllLeafColumns().filter(u=>u.getCanGlobalFilter());n&&o&&c.length&&(l.push("__global__"),c.forEach(u=>{var d;a.push({id:u.id,filterFn:o,resolvedValue:(d=o.resolveFilterValue==null?void 0:o.resolveFilterValue(n))!=null?d:n})}));let g,m;for(let u=0;u<s.flatRows.length;u++){const d=s.flatRows[u];if(d.columnFilters={},i.length)for(let f=0;f<i.length;f++){g=i[f];const h=g.id;d.columnFilters[h]=g.filterFn(d,h,g.resolvedValue,C=>{d.columnFiltersMeta[h]=C})}if(a.length){for(let f=0;f<a.length;f++){m=a[f];const h=m.id;if(m.filterFn(d,h,m.resolvedValue,C=>{d.columnFiltersMeta[h]=C})){d.columnFilters.__global__=!0;break}}d.columnFilters.__global__!==!0&&(d.columnFilters.__global__=!1)}}const p=u=>{for(let d=0;d<l.length;d++)if(u.columnFilters[l[d]]===!1)return!1;return!0};return Di(s.rows,p,e)},A(e.options,"debugTable","getFilteredRowModel",()=>e._autoResetPageIndex()))}function Vi(e){return s=>_(()=>[s.getState().pagination,s.getPrePaginationRowModel(),s.options.paginateExpandedRows?void 0:s.getState().expanded],(r,n)=>{if(!n.rows.length)return n;const{pageSize:i,pageIndex:a}=r;let{rows:l,flatRows:o,rowsById:c}=n;const g=i*a,m=g+i;l=l.slice(g,m);let p;s.options.paginateExpandedRows?p={rows:l,flatRows:o,rowsById:c}:p=Pi({rows:l,flatRows:o,rowsById:c}),p.flatRows=[];const u=d=>{p.flatRows.push(d),d.subRows.length&&d.subRows.forEach(u)};return p.rows.forEach(u),p},A(s.options,"debugTable"))}function Ti(){return e=>_(()=>[e.getState().sorting,e.getPreSortedRowModel()],(s,r)=>{if(!r.rows.length||!(s!=null&&s.length))return r;const n=e.getState().sorting,i=[],a=n.filter(c=>{var g;return(g=e.getColumn(c.id))==null?void 0:g.getCanSort()}),l={};a.forEach(c=>{const g=e.getColumn(c.id);g&&(l[c.id]={sortUndefined:g.columnDef.sortUndefined,invertSorting:g.columnDef.invertSorting,sortingFn:g.getSortingFn()})});const o=c=>{const g=c.map(m=>({...m}));return g.sort((m,p)=>{for(let d=0;d<a.length;d+=1){var u;const f=a[d],h=l[f.id],C=h.sortUndefined,v=(u=f==null?void 0:f.desc)!=null?u:!1;let w=0;if(C){const N=m.getValue(f.id),x=p.getValue(f.id),b=N===void 0,k=x===void 0;if(b||k){if(C==="first")return b?-1:1;if(C==="last")return b?1:-1;w=b&&k?0:b?C:-C}}if(w===0&&(w=h.sortingFn(m,p,f.id)),w!==0)return v&&(w*=-1),h.invertSorting&&(w*=-1),w}return m.index-p.index}),g.forEach(m=>{var p;i.push(m),(p=m.subRows)!=null&&p.length&&(m.subRows=o(m.subRows))}),g};return{rows:o(r.rows),flatRows:i,rowsById:r.rowsById}},A(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex()))}/** 21 * react-table 22 * 23 * Copyright (c) TanStack 24 * 25 * This source code is licensed under the MIT license found in the 26 * LICENSE.md file in the root directory of this source tree. 27 * 28 * @license MIT 29 */function xr(e,s){return e?Li(e)?y.createElement(e,s):e:null}function Li(e){return Hi(e)||typeof e=="function"||Oi(e)}function Hi(e){return typeof e=="function"&&(()=>{const s=Object.getPrototypeOf(e);return s.prototype&&s.prototype.isReactComponent})()}function Oi(e){return typeof e=="object"&&typeof e.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}function zi(e){const s={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[r]=y.useState(()=>({current:Ei(s)})),[n,i]=y.useState(()=>r.current.initialState);return r.current.setOptions(a=>({...a,...e,state:{...n,...e.state},onStateChange:l=>{i(l),e.onStateChange==null||e.onStateChange(l)}})),r.current}function Bi({stats:e,selectedCount:s,onStatusFilterChange:r}){return t.jsxs("div",{className:"flex flex-nowrap overflow-x-auto pb-4 gap-3 -mx-4 px-4 snap-x snap-mandatory scrollbar-hide md:grid md:grid-cols-4 md:gap-4 md:mx-0 md:px-0 md:pb-0",children:[t.jsxs(Me,{className:"min-w-[160px] md:min-w-0 flex-shrink-0 snap-center border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm hover:border-green-500 transition-all duration-200 touch-manipulation active:scale-[0.98]",style:{cursor:"pointer"},onClick:()=>r("all"),children:[t.jsxs(zt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx("div",{className:"text-sm font-medium",children:"Total Entries"}),t.jsx(tt,{className:"h-4 w-4 text-green-600"})]}),t.jsxs(Pe,{className:"py-2",children:[t.jsx("div",{className:"text-2xl font-extrabold text-gray-900 dark:text-gray-100",children:e.totalEntries}),t.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[e.totalHours.toFixed(2),"h total logged"]})]})]}),t.jsxs(Me,{className:"min-w-[160px] md:min-w-0 flex-shrink-0 snap-center border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm hover:border-amber-500 transition-all duration-200 touch-manipulation active:scale-[0.98]",style:{cursor:"pointer"},onClick:()=>r("pending"),children:[t.jsxs(zt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx("div",{className:"text-sm font-medium",children:"Pending"}),t.jsx(pn,{className:"h-4 w-4 text-amber-600"})]}),t.jsxs(Pe,{className:"py-2",children:[t.jsx("div",{className:"text-2xl font-extrabold text-amber-600",children:e.pendingEntries}),t.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Awaiting approval"})]})]}),t.jsxs(Me,{className:"min-w-[160px] md:min-w-0 flex-shrink-0 snap-center border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm hover:border-green-500 transition-all duration-200 touch-manipulation active:scale-[0.98]",style:{cursor:"pointer"},onClick:()=>r("approved"),children:[t.jsxs(zt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx("div",{className:"text-sm font-medium",children:"Approved"}),t.jsx(Pr,{className:"h-4 w-4 text-green-600"})]}),t.jsxs(Pe,{className:"py-2",children:[t.jsx("div",{className:"text-2xl font-extrabold text-green-600",children:e.approvedEntries}),t.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Ready for reporting"})]})]}),t.jsxs(Me,{className:"min-w-[160px] md:min-w-0 flex-shrink-0 snap-center border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm hover:border-green-500 transition-all duration-200 touch-manipulation active:scale-[0.98]",children:[t.jsxs(zt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx("div",{className:"text-sm font-medium",children:"Selected"}),t.jsx(Rt,{className:"h-4 w-4"})]}),t.jsxs(Pe,{className:"py-2",children:[t.jsx("div",{className:"text-2xl font-extrabold text-gray-900 dark:text-gray-100",children:s}),t.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Rows selected"})]})]})]})}function An({selectedMonth:e,goToPreviousMonth:s,goToNextMonth:r,isAtCurrentMonth:n}){const i=ts(e),a=rs(e),l=`${Te(i,"MMM d").toUpperCase()} - ${Te(a,"d yyyy")}`;return t.jsxs("div",{className:"flex items-center gap-2 w-full","data-testid":"monthly-filter-container",children:[t.jsxs("div",{className:"flex-1 flex items-center bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg px-3 py-2 h-10 shadow-sm",children:[t.jsx(gn,{className:"w-4 h-4 text-gray-400 mr-2"}),t.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:l})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(L,{variant:"outline",size:"icon",onClick:s,className:"h-10 w-10 border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-500",title:"Previous month",children:t.jsx(wn,{className:"h-4 w-4"})}),t.jsx(L,{variant:"outline",size:"icon",onClick:r,disabled:n,className:"h-10 w-10 border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-500 disabled:opacity-50",title:"Next month",children:t.jsx(yr,{className:"h-4 w-4"})})]})]})}function Gi({table:e,handleAddNewEntry:s}){return e.getFilteredSelectedRowModel().rows.length>0?null:t.jsx("div",{className:"flex items-center gap-3",children:t.jsx(L,{onClick:s,title:"Add Entry",className:"h-11 flex items-center justify-center bg-green-600 hover:bg-green-700 text-white dark:bg-green-600 dark:hover:bg-green-700 px-6 py-2 text-sm font-medium rounded-full shadow-md hover:shadow-lg transition-all duration-200 active:scale-95",children:t.jsx(ns,{className:"w-5 h-5"})})})}function Ui({table:e,handleBulkEnhancement:s,handleBulkDelete:r,handleBulkApprove:n,handleBulkUnapprove:i,isApprovingBulk:a,isUnapprovingBulk:l,isBulkEnhancing:o,isDeletingBulk:c,showDeleted:g}){const m=e.getFilteredSelectedRowModel().rows.length;return m===0?null:t.jsxs("div",{className:"flex items-center gap-3 ml-auto flex-shrink-0",children:[t.jsxs("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 whitespace-nowrap",children:[m," selected"]}),t.jsxs(L,{variant:"ghost",size:"sm",onClick:()=>e.resetRowSelection(),title:"Clear selection",className:"h-8 px-2 text-xs text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:[t.jsx(jn,{className:"h-3.5 w-3.5 mr-1"}),"Clear selection"]}),t.jsx("div",{className:"h-6 w-px bg-gray-200 dark:bg-gray-700"}),t.jsx(L,{variant:"outline",size:"default",onClick:s,disabled:o,title:`AI Enhance (${m})`,className:"h-11 text-purple-700 border-purple-300 hover:bg-purple-50 dark:text-purple-400 dark:border-purple-600 dar
29k:hover:bg-purple-900/20 flex items-center justify-center px-4 text-sm font-medium rounded-full shadow-sm",children:o?t.jsx(ie,{className:"h-5 w-5 animate-spin"}):t.jsx(vr,{className:"h-5 w-5 text-purple-600"})}),!g&&t.jsx(L,{variant:"destructive",size:"default",onClick:r,disabled:c,title:`Delete (${m})`,className:"h-11 flex items-center justify-center px-4 text-sm font-medium rounded-full shadow-sm",children:c?t.jsx(ie,{className:"h-5 w-5 animate-spin"}):t.jsx(rt,{className:"h-5 w-5"})}),t.jsx(L,{variant:"default",size:"default",onClick:n,disabled:a,title:`Approve (${e.getFilteredSelectedRowModel().rows.filter(p=>{const u=p.original;return!u.isNew&&u.approvalStatus!=="approved"}).length})`,className:"h-11 bg-[#10B981] flex items-center justify-center px-4 text-sm font-medium rounded-full shadow-md hover:shadow-lg transition-shadow",children:a?t.jsx(ie,{className:"h-5 w-5 animate-spin"}):t.jsx(Yr,{className:"h-5 w-5"})}),t.jsx(L,{variant:"default",size:"default",onClick:i,disabled:l,title:`Unapprove (${e.getFilteredSelectedRowModel().rows.filter(p=>{const u=p.original;return!u.isNew&&u.approvalStatus!=="pending"}).length})`,className:"h-11 bg-[#6B7280] text-white flex items-center justify-center px-4 text-sm font-medium rounded-full shadow-md hover:shadow-lg transition-shadow",children:l?t.jsx(ie,{className:"h-5 w-5 animate-spin"}):t.jsx(Yr,{className:"h-5 w-5"})})]})}function qi(e,s){if(!e||e.length===0)throw new Error("No data to export");const n=[["Date","Hours","Activity Type","Category","Description","Property","Recorded By","Evidence File Name","Source","Approval Status","AI Summary","Created","Property Type"].map(o=>`"${o}"`).join(","),...e.map(o=>{var u,d;const c=((u=o.evidenceFiles)==null?void 0:u.map(f=>f.originalName||f.fileName).join("; "))||"None",g=((d=o.evidenceFiles)==null?void 0:d.filter(f=>f.aiSummary).map((f,h)=>`File ${h+1} (${f.originalName||f.fileName}): ${f.aiSummary}`).join(` 30 31`))||"No AI analysis available",m=o.recordedBy?o.recordedBy.firstName&&o.recordedBy.lastName?`${o.recordedBy.firstName} ${o.recordedBy.lastName}`:o.recordedBy.email:"";return[`"${Te(new Date(o.date),"yyyy-MM-dd")}"`,`"${o.hours}"`,`"${o.activityType||""}"`,`"${o.isMaterialParticipation?"Material Participation Activity":"Qualified Non-Material"}"`,`"${(o.description||"").replace(/"/g,'""')}"`,`"${o.property?[o.property.nickname,o.property.address,o.property.city,o.property.state,o.property.zipCode].filter(Boolean).join(", "):""}"`,`"${m}"`,`"${c.replace(/"/g,'""')}"`,`"${o.source||"manual"}"`,`"${o.approvalStatus||"pending"}"`,`"${g.replace(/"/g,'""')}"`,`"${Te(new Date(o.createdAt),"yyyy-MM-dd HH:mm:ss")}"`,`"${o.propertyType||"Long-term Rental"}"`].join(",")})].join(` 32`),i=new Blob([n],{type:"text/csv;charset=utf-8;"}),a=document.createElement("a"),l=URL.createObjectURL(i);a.setAttribute("href",l),a.setAttribute("download",s),a.style.visibility="hidden",document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(l)}function un({data:e,selectedRowsCount:s=0,trigger:r}){const[n,i]=y.useState(!1),[a,l]=y.useState(!1),{toast:o}=ve(),c=e.length,g=e.filter(x=>x.evidenceFiles&&x.evidenceFiles.length>0).length,m=e.reduce((x,b)=>{var k;return x+(((k=b.evidenceFiles)==null?void 0:k.length)||0)},0),p=e.reduce((x,b)=>{var k;return x+(((k=b.evidenceFiles)==null?void 0:k.filter(P=>P.aiSummary).length)||0)},0),u=e.filter(x=>{var b;return((b=x.source)==null?void 0:b.includes("gmail"))||x.emailThreadId}).length,d=e.filter(x=>x.emailSubject).length,f=e.reduce((x,b)=>x+(b.emailMessageCount||0),0),h=e.reduce((x,b)=>x+(b.emailWordCount||0),0),C=s>0?`${s} selected entries`:`${c} entries`,v=async()=>{l(!0);try{const x=`enhanced-entries-${Te(new Date,"yyyy-MM-dd-HHmm")}.csv`;qi(e,x),o({title:"Enhanced CSV Export Complete",description:`Exported ${c} entries with file names and AI summaries to ${x}`}),i(!1)}catch{o({title:"Export Failed",description:"Failed to export enhanced CSV. Please try again.",variant:"destructive"})}finally{l(!1)}},w=async()=>{l(!0);try{const x=await fetch("/api/export/evidence-files",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({timeEntryIds:e.map(k=>k.id)})});if(!x.ok){const k=await x.text();throw console.error("â Export error response:",k),new Error(`Export failed: ${x.status} ${x.statusText}`)}const b=await x.json();if(!b.success||!b.downloadUrl)throw new Error("Export failed: No download URL received");
32window.location.href=b.downloadUrl,o({title:"Evidence Files Export Complete",description:`Export ready: ${b.fileCount} files. Download will start automatically.`}),i(!1)}catch(x){console.error("ð¥ Export error:",x),o({title:"Export Failed",description:x instanceof Error?x.message:"Failed to export evidence files. Please try again.",variant:"destructive"})}finally{l(!1)}},N=async()=>{l(!0);try{const x=await fetch("/api/export/combined",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({timeEntryIds:e.map(k=>k.id)})});if(!x.ok){const k=await x.text();throw console.error("â Combined export error response:",k),new Error(`Combined export failed: ${x.status} ${x.statusText}`)}const b=await x.json();if(!b.success||!b.downloadUrl)throw new Error("Combined export failed: No download URL received");window.location.href=b.downloadUrl,o({title:"Combined Export Complete",description:`Export ready: ${b.entryCount} entries with ${b.fileCount} files. Download will start automatically.`}),i(!1)}catch{o({title:"Export Failed",description:"Failed to create combined export. Please try again.",variant:"destructive"})}finally{l(!1)}};return t.jsxs(Rr,{open:n,onOpenChange:i,children:[t.jsx(ss,{asChild:!0,children:r||t.jsxs(L,{variant:"outline",children:[t.jsx(kt,{className:"mr-2 h-4 w-4"}),"Export"]})}),t.jsxs(Fr,{className:"max-w-lg",children:[t.jsxs(Er,{children:[t.jsxs(Mr,{className:"flex items-center gap-2",children:[t.jsx(an,{className:"h-5 w-5"}),"Enhanced Export Options"]}),t.jsxs(is,{children:["Choose how you want to export your activity data and evidence files. Exporting ",C," from the current view."]})]}),t.jsxs("div",{className:"grid grid-cols-4 gap-2 mb-4",children:[t.jsxs("div",{className:"text-center p-1.5 bg-muted rounded",children:[t.jsx("div",{className:"text-sm font-semibold",children:c}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"Entries"})]}),t.jsxs("div",{className:"text-center p-1.5 bg-muted rounded",children:[t.jsx("div",{className:"text-sm font-semibold",children:g}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"With Files"})]}),t.jsxs("div",{className:"text-center p-1.5 bg-muted rounded",children:[t.jsx("div",{className:"text-sm font-semibold",children:m}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Files"})]}),t.jsxs("div",{className:"text-center p-1.5 bg-muted rounded",children:[t.jsx("div",{className:"text-sm font-semibold",children:p}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"AI Analyzed"})]})]}),u>0&&t.jsxs("div",{className:"mb-4",children:[t.jsxs("h4",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:["ð§ Gmail Metadata Included",t.jsxs(re,{variant:"secondary",className:"text-xs",children:[u," Gmail entries"]})]}),t.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[t.jsxs("div",{className:"text-center p-1.5 bg-blue-50 dark:bg-blue-950 rounded",children:[t.jsx("div",{className:"text-sm font-semibold",children:u}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"Gmail Entries"})]}),t.jsxs("div",{className:"text-center p-1.5 bg-blue-50 dark:bg-blue-950 rounded",children:[t.jsx("div",{className:"text-sm font-semibold",children:d}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"With Subjects"})]}),t.jsxs("div",{className:"text-center p-1.5 bg-blue-50 dark:bg-blue-950 rounded",children:[t.jsx("div",{className:"text-sm font-semibold",children:f}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Messages"})]}),t.jsxs("div",{className:"text-center p-1.5 bg-blue-50 dark:bg-blue-950 rounded",children:[t.jsx("div",{className:"text-sm font-semibold",children:h.toLocaleString()}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Words"})]})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(Me,{className:"hover:bg-muted/30 transition-colors",children:t.jsxs(Pe,{className:"p-4",children:[t.jsx("div",{className:"flex items-center justify-between mb-2",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ps,{className:"h-4 w-4 text-green-600"}),t.jsx("span",{className:"font-medium",children:"Enhanced CSV"}),t.jsx(re,{variant:"secondary",className:"text-xs",children:"Entries Only"})]})}),t.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Enhanced data with file names and AI summaries"}),t.jsx(L,{onClick:v,disabled:a,className:"w-full",variant:"outline",size:"sm",children:a?t.jsxs(t.Fragment,{children:[t.jsx(ie,{className:"mr-2 h-3 w-3 animate-spin"}),"Exporting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(tt,{className:"mr-2 h-3 w-3"}),"Export CSV"]})})]})}),t.jsx(Me,{className:"hover:bg-muted/30 transition-colors",children:t.jsxs(Pe,{className:"p-4",children:[t.jsx("div",{className:"flex items-center justify-between mb-2",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(rn,{className:"h-4 w-4 text-blue-600"}),t.jsx("span",{className:"font-medium",children:"Evidence Files"}),t.jsx(re,{variant:"secondary",className:"text-xs",children:"ZIP Archive"})]})}),t.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Organized folders with entry metadata"}),t.jsx(L,{onClick:w,disabled:a||m===0,className:"w-full",variant:"outline",size:"sm",children:a?t.jsxs(t.Fragment,{children:[t.jsx(ie,{className:"mr-2 h-3 w-3 animate-spin"}),"Preparing..."]}):t.jsxs(t.Fragment,{children:[t.jsx(rn,{className:"mr-2 h-3 w-3"}),"Download (",m," files)"]})})]})}),t.jsx(Me,{className:"hover:bg-muted/30 transition-colors border border-primary/40",children:t.jsxs(Pe,{className:"p-4",children:[t.jsx("div",{className:"flex items-center justify-between mb-2",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(an,{className:"h-4 w-4 text-purple-600"}),t.jsx("span",{className:"font-medium",children:"Complete Package"}),t.jsx(re,{variant:"default",className:"text-xs",children:"Recommended"})]})}),t.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Single ZIP with enhanced CSV + organized evidence files"}),t.jsx(L,{onClick:N,disabled:a,className:"w-full",size:"sm",children:a?t.jsxs(t.Fragment,{children:[t.jsx(ie,{className:"mr-2 h-3 w-3 animate-spin"}),"Creating Package..."]}):t.jsxs(t.Fragment,{children:[t.jsx(kt,{className:"mr-2 h-3 w-3"}),"Export Everything"]})})]})})]}),m===0&&t.jsx("div",{className:"text-center p-4 bg-muted/50 rounded-lg text-sm text-muted-foreground",children:"No evidence files found in the selected entries. File export options will download an empty archive."})]})]})}function Vn({globalFilter:e,setGlobalFilter:s,statusFilter:r,setStatusFilter:n,table:i,allData:a,onImportClick:l,onRefresh:o,isLoading:c,showDeleted:g,setShowDeleted:m,showMobileFilters:p,setShowMobileFilters:u,handleBulkEnhancement:d,handleBulkDelete:f,handleBulkApprove:h,handleBulkUnapprove:C,isBulkEnhancing:v,isDeletingBulk:w,isApprovingBulk:N,isUnapprovingBulk:x}){const b=Dr(),k=p!==void 0?p:!1,P=u||(()=>{}),I=t.jsxs("div",{className:"hidden sm:flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[t.jsxs("div",{className:"flex items-center space-x-3 w-72 flex-shrink-0",children:[t.jsx(Xr,{className:"h-5 w-5 text-green-600 dark:text-green-400 flex-shrink-0"}),t.jsx(je,{placeholder:"Search entries...",value:e??"",onChange:M=>s(M.target.value),className:`w-full h-10 text-base rounded-lg border border-gray-300 dark:border-gray-700 33 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 34 placeholder-gray-400 dark:placeholder-gray-500 35 focus:outline-none focus:ring-2 focus:ring-green-500 dark:focus:ring-green-400`})]}),t.jsxs("div",{className:"w-full sm:w-auto flex items-center gap-3 overflow-x-auto scrollbar-hide pb-2 -mx-4 px-4 sm:mx-0 sm:px-0 sm:pb-0 sm:overflow-visible sm:flex-wrap",children:[t.jsxs(Se,{value:r,onValueChange:n,children:[t.jsx(Ce,{className:"w-[50px] h-11 text-sm rounded-full border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-green-500 dark:focus:ring-green-400 shadow-sm flex-shrink-0",title:"Status",children:t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(jr,{className:"h-4 w-4 text-green-600 dark:text-green-400"})})}),t.jsxs(ke,{children:[t.jsx(Z,{value:"all",children:"All Status"}),t.jsx(Z,{value:"pending",children:"Pending"}),t.jsx(Z,{value:"approved",children:"Approved"})]})]}),m&&t.jsx("div",{className:"flex items-center space-x-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-700 rounded-full px-4 h-11 flex-shrink-0 shadow-sm cursor-pointer active:scale-95 transition-transform",onClick:()=>m(!g),title:"Show Deleted",children:t.jsx(Rt,{id:"show-deleted",checked:g,onCheckedChange:M=>m(!!M),className:"data-[state=checked]:bg-green-600 data-[state=checked]:border-green-600"})}),t.jsxs(Ir,{children:[t.jsx($r,{asChild:!0,children:t.jsx(L,{variant:"outline",title:"Columns",className:"h-11 text-sm flex items-center justify-center rounded-full border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900 text-gray-800 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800 px-4 flex-shrink-0 shadow-sm",children:t.jsx(Jr,{className:"h-4 w-4 text-green-600 dark:text-green-400"})})}),t.jsx(_r,{align:"end",className:"bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-700 shadow-lg rounded-md",children:i.getAllColumns().filter(M=>M.getCanHide()).map(M=>t.jsx(as,{className:"capitalize text-sm text-gray-700 dark:text-gray-300",checked:M.getIsVisible(),onCheckedChange:$=>M.toggleVisibility(!!$),children:M.id},M.id))})]}),t.jsx("div",{className:"hidden sm:block h-8 w-px bg-gray-300 dark:bg-gray-700 flex-shrink-0"}),t.jsxs(L,{variant:"outline",onClick:l,title:"Import CSV",className:"h-11 text-sm flex items-center justify-center gap-2 rounded-full border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900 text-gray-800 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800 px-4 flex-shrink-0 shadow-sm",children:[t.jsx(St,{className:"h-4 w-4 text-green-600 dark:text-green-400"}),"Import CSV"]}),t.jsx(un,{data:a,selectedRowsCount:a.length,trigger:t.jsx(L,{variant:"outline",title:"Export",className:"h-11 text-sm flex items-center justify-center rounded-full border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900 text-gray-800 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800 px-4 flex-shrink-0 shadow-sm",children:t.jsx(kt,{className:"h-4 w-4 text-green-600 dark:text-green-400"})})}),t.jsx(L,{onClick:o,variant:"outline",disabled:c,title:"Refresh",className:"h-11 text-sm flex items-center justify-center rounded-full border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900 text-gray-800 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-50 px-4 flex-shrink-0 shadow-sm",children:t.jsx(wr,{className:`h-4 w-4 text-green-600 dark:text-green-400 ${c?"animate-spin":""}`})}),d&&f&&h&&C&&t.jsx(Ui,{table:i,handleBulkEnhancement:d,handleBulkDelete:f,handleBulkApprove:h,handleBulkUnapprove:C,isBulkEnhancing:!!v,isDeletingBulk:!!w,isApprovingBulk:!!N,isUnapprovingBulk:!!x,showDeleted:g})]})]});return t.jsxs("div",{className:"pb-6 border-b border-gray-300 dark:border-gray-600 mb-6",children:[p===void 0&&t.jsxs("div",{className:"sm:hidden flex items-center gap-3 w-full mb-2",children:[t.jsxs("div",{className:"relative flex-[8.5] min-w-0",children:[t.jsx(Xr,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-5 w-5 text-green-600 dark:text-green-400"}),t.jsx(je,{placeholder:"Search entries...",value:e??"",onChange:M=>s(M.target.value),className:`w-full h-12 pl-10 text-base rounded-2xl border border-gray-300 dark:border-gray-700 36 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 37 placeholder-gray-400 dark:placeholder-gray-500 38 focus:outline-none focus:ring-2 focus:ring-green-500 dark:focus:ring-green-400 shadow-sm`})]}),t.jsx(L,{variant:"outline",onClick:()=>P(!0),className:"flex-[1.5] h-12 rounded-2xl border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900 shadow-sm flex items-center justify-center p-0",children:t.jsx(Nn,{className:"h-6 w-6 text-green-600 dark:text-green-400"})})]}),t.jsx(ls,{open:k,onOpenChange:P,title:"Table Actions & Filters",children:t.jsxs("div",{className:"p-4 space-y-6",children:[t.jsxs("div",{className:"space-y-4",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Filters"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium",children:"Approval Status"}),t.jsxs(Se,{value:r,onValueChange:n,children:[t.jsx(Ce,{className:"w-full h-12 rounded-xl",children:t.jsxs("div",{className:"flex items-center gap-2 text-base",children:[t.jsx(jr,{className:"h-4 w-4 text-green-600"}),t.jsx("span",{children:r==="all"?"All Statuses":r.charAt(0).toUpperCase()+r.slice(1)})]})}),t.jsxs(ke,{children:[t.jsx(Z,{value:"all",children:"All Status"}),t.jsx(Z,{value:"pending",children:"Pending"}),t.jsx(Z,{value:"approved",children:"Approved"})]})]})]}),m&&t.jsx("div",{className:"flex items-center justify-between bg-gray-50 dark:bg-gray-800/50 border border-gray-200 dark:border-gray-700 rounded-xl p-4 cursor-pointer",onClick:()=>m(!g),children:t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx(Rt,{id:"mobile-show-deleted",checked:g,onCheckedChange:M=>m(!!M),className:"h-5 w-5 data-[state=checked]:bg-green-600 data-[state=checked]:border-green-600"}),t.jsx("label",{htmlFor:"mobile-show-deleted",className:"text-base font-medium",children:"Show Deleted
38Entries"})]})})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Columns Visibility"}),t.jsx("div",{className:"grid grid-cols-2 gap-2",children:i.getAllColumns().filter(M=>M.getCanHide()).map(M=>t.jsxs(L,{variant:M.getIsVisible()?"default":"outline",className:te("justify-start text-sm h-10 rounded-lg capitalize truncate",M.getIsVisible()?"bg-green-600 hover:bg-green-700 text-white":"border-gray-200"),onClick:()=>M.toggleVisibility(!M.getIsVisible()),children:[t.jsx(Jr,{className:"h-3.5 w-3.5 mr-2 opacity-70"}),M.id]},M.id))})]}),t.jsxs("div",{className:"space-y-4 pt-4 border-t border-gray-100 dark:border-gray-800",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Actions"}),t.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[t.jsxs(L,{variant:"outline",onClick:()=>{P(!1),l()},className:"w-full h-12 justify-start text-base rounded-xl border-gray-200",children:[t.jsx(St,{className:"h-5 w-5 mr-3 text-green-600"}),"Import CSV"]}),t.jsx(un,{data:a,selectedRowsCount:a.length,trigger:t.jsxs(L,{variant:"outline",className:"w-full h-12 justify-start text-base rounded-xl border-gray-200 text-gray-900 dark:text-gray-100",children:[t.jsx(kt,{className:"h-5 w-5 mr-3 text-green-600"}),"Export to Excel/CSV"]})}),t.jsxs(L,{onClick:()=>{o(),P(!1)},variant:"outline",disabled:c,className:"w-full h-12 justify-start text-base rounded-xl border-gray-200",children:[t.jsx(wr,{className:`h-5 w-5 mr-3 text-green-600 ${c?"animate-spin":""}`}),"Refresh Data"]})]})]})]})}),!b&&I]})}function Qt({column:e}){const s=e.getFilterValue(),r=Array.from(e.getFacetedUniqueValues().keys()).filter(n=>typeof n=="string"&&n.length>0).sort((n,i)=>n.localeCompare(i));return r.length===0?null:t.jsxs(Ir,{children:[t.jsx($r,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"sm",onClick:n=>n.stopPropagation(),title:s?`Filtered: ${s}`:"Filter this column",className:`h-6 w-6 p-0 flex-shrink-0 ${s?"text-green-600 dark:text-green-400":"text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300"}`,children:t.jsx(jr,{className:"h-3.5 w-3.5",fill:s?"currentColor":"none"})})}),t.jsxs(_r,{align:"start",className:"max-h-64 overflow-y-auto bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-700 shadow-lg rounded-md",children:[s&&t.jsxs(t.Fragment,{children:[t.jsx(et,{onClick:()=>e.setFilterValue(void 0),className:"text-sm text-gray-500 dark:text-gray-400",children:"Clear filter"}),t.jsx(os,{})]}),r.map(n=>t.jsx(et,{onClick:()=>e.setFilterValue(n),className:`text-sm capitalize ${s===n?"font-semibold text-green-700 dark:text-green-400":"text-gray-700 dark:text-gray-300"}`,children:n},n))]})]})}function Wi({stats:e,table:s,rowSelection:r,selectedMonth:n,goToNextMonth:i,goToPreviousMonth:a,isAtCurrentMonth:l,viewMode:o,setViewMode:c,globalFilter:g,setGlobalFilter:m,statusFilter:p,setStatusFilter:u,groupedData:d,loading:f,entries:h,newEntries:C,fetchData:v,filteredData:w,properties:N,handleAddNewEntry:x,handleBulkEnhancement:b,handleBulkDelete:k,handleBulkApprove:P,handleBulkUnapprove:I,isBulkEnhancing:M,isDeletingBulk:$,isApprovingBulk:G,isUnapprovingBulk:U,showDeleted:K,setShowDeleted:J,showImportDialog:oe,setShowImportDialog:X,selectedEntry:He,setSelectedEntry:nt,showDetailsDialog:Oe,setShowDetailsDialog:st,entryToModify:it,setEntryToModify:at,showModifyEntryDialog:lt,setShowModifyEntryDialog:ae,showDuplicateDialog:Ne,setShowDuplicateDialog:qe,entryToDuplicate:ot,setEntryToDuplicate:de,showDeleteDialog:We,setShowDeleteDialog:fe,entryToDelete:ze,handleDeleteEntry:dt,confirmDeleteEntry:Be,isDeletingEntry:Qe,showNewEntryDialog:ct,setShowNewEntryDialog:ut,isCreating:gt,setIsCreating:pt,showFilePreview:mt,setShowFilePreview:ne,selectedFile:S,setSelectedFile:R,previewFile:D,setPreviewFile:V,isFilePreviewOpen:O,currentFileIndex:z,setCurrentFileIndex:F,handleOpenFilePreview:B,downloadFile:H,deleteFileDialogOpen:Y,setDeleteFileDialogOpen:Re,fileToDelete:xe,handleFileDeleteClick:Ke,confirmFileDelete:Ye,deleteFileMutation:Xt,sharedDialogs:Xe,onCreateEntry:he,glowingDescriptions:Tt,setGlowingDescriptions:Jt}){var ht;const[De,ft]=y.useState(()=>{try{const q=localStorage.getItem("activityLedger.collapsedGroups");return q?JSON.parse(q):{pending:!1,approved:!1}}catch{return{pending:!1,approved:!1}}});y.useEffect(()=>{try{localStorage.setItem("activityLedger.collapsedGroups",JSON.stringify(De))}catch{}},[De]);const xt=q=>{ft(we=>({...we,[q]:!we[q]}))};return t.jsx(t.Fragment,{children:t.jsxs("div",{className:"container-mobile py-12 space-y-12",children:[t.jsx("div",{className:"mb-6 sm:mb-8",children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("h1",{className:"text-3xl md:text-4xl font-extrabold tracking-tight text-gray-900 dark:text-gray-100",children:"Activity Ledger"}),t.jsxs("p",{className:"text-gray-500 dark:text-gray-400 mt-1 text-sm md:text-base",children:["Advanced table with sorting, filtering, and bulk operations â"," ",t.jsxs("span",{className:"text-green-600 font-semibold",children:[e.totalEntries," total entries"]})]})]})}),t.jsx(Bi,{stats:e,selectedCount:Object.keys(r).length,onStatusFilterChange:q=>{u(q),c("all-entries")}}),t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row items-center sm:items-center gap-3 w-full sm:w-auto",children:[t.jsx(ds,{value:o,onValueChange:q=>c(q),className:"w-full sm:w-[300px]",children:t.jsxs(cs,{className:"grid w-full grid-cols-2 h-11 bg-muted/50 p-1 rounded-xl",children:[t.jsx(Zr,{value:"monthly",className:"text-sm rounded-lg data-[state=active]:bg-white dark:data-[state=active]:bg-gray-700",children:"Monthly View"}),t.jsx(Zr,{value:"all-entries",className:"text-sm rounded-lg data-[state=active]:bg-white dark:data-[state=active]:bg-gray-700",children:"All Entries"})]})}),o==="monthly"&&t.jsx("div",{className:"w-full sm:w-auto flex justify-center py-1",children:t.jsx(An,{selectedMonth:n,goToPreviousMonth:a,goToNextMonth:i,isAtCurrentMonth:l})})]}),t.jsx("div",{className:"flex items-center justify-end flex-1 w-full sm:w-auto",children:t.jsx(Gi,{table:s,handleAddNewEntry:()=>x()})})]}),t.jsx(Me,{className:"border border-gray-300 dark:border-gray-600 rounded-xl bg-white dark:bg-gray-900",children:t.jsxs(Pe,{className:"pt-6 px-6",children:[t.jsx(Vn,{globalFilter:g,setGlobalFilter:m,statusFilter:p,setStatusFilter:u,table:s,allData:[...C,...h],onImportClick:()=>X(!0),onRefresh:v,isLoading:f,showDeleted:K,setShowDeleted:J,handleBulkEnhancement:b,handleBulkDelete:k,handleBulkApprove:P,handleBulkUnapprove:I,isBulkEnhancing:M,isDeletingBulk:$,isApprovingBulk:G,isUnapprovingBulk:U}),t.jsx("div",{"data-tour":"activity-ledger-datatable",className:"rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-900",children:t.jsxs(mn,{className:"w-full border-separate border-spacing-0 divide-y divide-gray-200 dark:divide-gray-700",children:[t.jsx(fn,{className:"bg-gray-100 dark:bg-gray-800",children:s.getHeaderGroups().map(q=>{const we=s.getVisibleLeafColumns().map(ce=>ce.id);return t.jsx(_e,{children:q.headers.map(ce=>{const ue=ar(ce.id,we);return t.jsx(Fe,{className:`${ue.className} align-middle sticky top-0 md:-top-4 z-10 bg-gray-100 dark:bg-gray-800 h-auto`,style:ue.style,children:ce.isPlaceholder?null:t.jsx("div",{className:ce.id==="select"?"flex justify-center items-center w-full":"text-left font-semibold text-sm text-gray-800 dark:text-gray-200 tracking-wide select-none whitespace-nowrap",style:{lineHeight:"1.5rem"},children:xr(ce.column.columnDef.header,ce.getContext())})},ce.id)})},q.id)})}),t.jsx(xn,{className:"divide-y divide-gray-200 dark:divide-gray-700",children:f?t.jsx(_e,{children:t.jsx(ge,{colSpan:s.getVisibleLeafColumns().length,className:"h-28 text-center text-gray-600 dark:text-gray-400",children:t.jsxs("div",{className:"flex items-center justify-center space-x-3 text-sm",children:[t.jsx(ie,{className:"h-5 w-5 animate-spin text-green-600 dark:text-green-400"}
38),t.jsx("span",{children:"Loading entries..."})]})})}):(ht=s.getRowModel().rows)!=null&&ht.length?t.jsx(t.Fragment,{children:p==="all"&&(d.pending.length>0||d.approved.length>0)?(()=>{const q=s.getVisibleLeafColumns().length,we=s.getPrePaginationRowModel().rows,ce=we.filter(ee=>{const se=ee.original;return se.isNew||(se.approvalStatus||"pending")==="pending"}),ue=we.filter(ee=>{const se=ee.original;return!se.isNew&&se.approvalStatus==="approved"}),Ge=(ee,se,Zt,Lt,yt,er,tr)=>yt.length===0?null:t.jsxs(Ar.Fragment,{children:[t.jsx(_e,{className:"bg-gray-50 dark:bg-gray-800/70",children:t.jsx(ge,{colSpan:q,className:"px-6 py-3 text-sm select-none",children:t.jsxs("button",{type:"button",onClick:()=>xt(ee),className:`flex items-center gap-2 font-semibold ${Lt}`,"aria-expanded":!De[ee],children:[De[ee]?t.jsx(yr,{className:"h-4 w-4"}):t.jsx(us,{className:"h-4 w-4"}),se," ",Zt," (",yt.length,")"]})})}),!De[ee]&&yt.map(Je=>{const Ht=Je.original,rr=s.getVisibleLeafColumns().map(Ie=>Ie.id);return t.jsx(_e,{"data-state":Je.getIsSelected()&&"selected",className:`text-sm transition-colors ${tr(Ht)} data-[state=selected]:bg-blue-100 dark:data-[state=selected]:bg-blue-900`,style:{contentVisibility:"auto",containIntrinsicSize:"auto 56px"},children:Je.getVisibleCells().map(Ie=>{const vt=ar(Ie.column.id,rr,er);return t.jsx(ge,{className:vt.className,style:vt.style,children:xr(Ie.column.columnDef.cell,Ie.getContext())},Ie.id)})},Je.id)})]},ee);return t.jsxs(t.Fragment,{children:[Ge("pending","ð","Pending Entries","text-amber-700 dark:text-amber-400 hover:text-amber-800 dark:hover:text-amber-300",ce,"px-3 py-4 text-gray-900 dark:text-gray-200",ee=>ee.deletedAt?"bg-gray-100 dark:bg-gray-800 opacity-60 line-through":ee.isNew?"bg-blue-50 dark:bg-blue-900 hover:bg-blue-100 dark:hover:bg-blue-800 border-l-4 border-blue-400 dark:border-blue-600":"hover:bg-gray-50 dark:hover:bg-gray-800/60"),Ge("approved","â
","Approved Entries","text-green-700 dark:text-green-400 hover:text-green-800 dark:hover:text-green-300",ue,"px-6 py-3 text-gray-900 dark:text-gray-200",ee=>ee.deletedAt?"bg-gray-100 dark:bg-gray-800 opacity-60 line-through":"hover:bg-gray-50 dark:hover:bg-gray-800/60")]})})():s.getRowModel().rows.map(q=>{const we=q.original,ce=we.isNew;return t.jsx(_e,{"data-state":q.getIsSelected()&&"selected",className:`text-sm transition-colors ${we.deletedAt?"bg-gray-100 dark:bg-gray-800 opacity-60 line-through":ce?"bg-blue-50 dark:bg-blue-900 hover:bg-blue-100 dark:hover:bg-blue-800 border-l-4 border-blue-400 dark:border-blue-600":"hover:bg-gray-50 dark:hover:bg-gray-800/60"} data-[state=selected]:bg-blue-100 dark:data-[state=selected]:bg-blue-900`,style:{contentVisibility:"auto",containIntrinsicSize:"auto 56px"},children:q.getVisibleCells().map(ue=>{const Ge=ar(ue.column.id,s.getVisibleLeafColumns().map(ee=>ee.id),"px-6 py-3 text-gray-900 dark:text-gray-200");return t.jsx(ge,{className:Ge.className,style:Ge.style,children:xr(ue.column.columnDef.cell,ue.getContext())},ue.id)})},q.id)})}):t.jsx(_e,{children:t.jsx(ge,{colSpan:s.getVisibleLeafColumns().length,className:"h-28 text-center text-gray-600 dark:text-gray-400",children:"No entries found"})})})]})}),t.jsxs("div",{className:"flex flex-col lg:flex-row items-center justify-between gap-4 py-4 px-2",children:[t.jsx("div",{className:"flex-1 flex flex-col lg:flex-row items-center space-y-2 lg:space-y-0 lg:space-x-5 text-sm text-gray-600 dark:text-gray-400 select-none",children:t.jsxs("span",{children:[s.getFilteredSelectedRowModel().rows.length," of"," ",s.getFilteredRowModel().rows.length," row(s) selected."]})}),t.jsxs("div",{className:"flex items-center space-x-6",children:[t.jsxs("div",{className:"flex items-center space-x-3 text-sm font-light text-gray-700 dark:text-gray-300 select-none",children:[t.jsx("span",{children:"Rows per page"}),t.jsxs(Se,{value:`${s.getState().pagination.pageSize}`,onValueChange:q=>s.setPageSize(Number(q)),children:[t.jsx(Ce,{className:"h-9 w-[75px] text-sm font-light rounded-md border border-gray-300 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-green-500 dark:focus:ring-green-400",children:t.jsx(Ve,{placeholder:s.getState().pagination.pageSize})}),t.jsx(ke,{side:"top",className:"bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-700 rounded-md shadow-lg",children:[25,50,100,250].map(q=>t.jsx(Z,{value:`${q}`,className:"font-light text-gray-900 dark:text-gray-100",children:q},q))})]})]}),t.jsxs("div",{className:"flex w-[110px] justify-center text-sm font-light text-gray-700 dark:text-gray-300 select-none",children:["Page ",s.getState().pagination.pageIndex+1," of"," ",s.getPageCount()]}),t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx(L,{variant:"outline",className:"h-9 w-9 p-0 rounded-md border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900 text-gray-800 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-50",onClick:()=>s.previousPage(),disabled:!s.getCanPreviousPage(),"aria-label":"Previous Page",children:t.jsx(wn,{className:"h-5 w-5 text-green-600 dark:text-green-400"})}),t.jsx(L,{variant:"outline",className:"h-9 w-9 p-0 rounded-md border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900 text-gray-800 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-50",onClick:()=>s.nextPage(),disabled:!s.getCanNextPage(),"aria-label":"Next Page",children:t.jsx(yr,{className:"h-5 w-5 text-green-600 dark:text-green-400"})})]})]})]})]})}),Xe]})})}function Qi({entry:e,onUpdate:s,isEditing:r,onStartEdit:n,onCancelEdit:i}){var C;const[a,l]=y.useState(((C=e.date)==null?void 0:C.substring(0,10))||""),[o,c]=y.useState(!1),[g,m]=y.useState(!1),{toast:p}=ve(),u=new Date().getFullYear();y.useEffect(()=>{r&&a&&(new Date(a).getFullYear()<u?m(!0):m(!1))},[a,r,u]);const d=async()=>{var v;if(a===((v=e.date)==null?void 0:v.split("T")[0])){i();return}c(!0);try{await s(e.id,"date",a),i()}catch(w){console.error("Error updating date:",w)}finally{c(!1)}},f=()=>{d()},h=v=>{var w;v.key==="Enter"?d():v.key==="Escape"&&(l(((w=e.date)==null?void 0:w.split("T")[0])||""),i())};return r?t.jsxs("div",{className:"flex flex-col gap-2 w-full",children:[g&&t.jsxs("div",{className:"flex items-start gap-2 p-2 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-md",children:[t.jsx(hr,{className:"h-4 w-4 text-amber-600 dar
38k:text-amber-400 flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 text-xs text-amber-800 dark:text-amber-200",children:[t.jsx("span",{className:"font-semibold",children:"Previous Tax Year:"})," You are logging hours for a previous tax year. These will not count toward your current goals."]})]}),t.jsx(je,{type:"date",value:a,onChange:v=>{l(v.target.value),new Date(v.target.value).getFullYear()<u&&p({title:"Previous Tax Year Selected",description:"You are logging hours for a previous tax year. These will not count toward your current goals.",variant:"default"})},onBlur:f,onKeyDown:h,className:"w-full",autoFocus:!0})]}):t.jsx("div",{className:"cursor-pointer hover:bg-muted/50 p-1 rounded",onClick:n,children:e.date?It(e.date):"Click to set date"})}function Ki({entry:e,onUpdate:s,isEditing:r,onStartEdit:n,onCancelEdit:i}){var u;const[a,l]=y.useState(((u=e.hours)==null?void 0:u.toString())||""),[o,c]=y.useState(!1),g=async()=>{var d;if(a===((d=e.hours)==null?void 0:d.toString())){i();return}c(!0);try{await s(e.id,"hours",a),i()}catch(f){console.error("Error updating hours:",f),i()}finally{c(!1)}},m=()=>{setTimeout(()=>{g()},250)},p=d=>{var f;d.key==="Enter"?g():d.key==="Escape"&&(l(((f=e.hours)==null?void 0:f.toString())||""),i())};return r?t.jsx("div",{className:"flex items-center gap-1 w-full",children:t.jsx("div",{className:"flex-1",children:t.jsx(gs,{value:a,onChange:l,onBlur:m,onKeyDown:p,showQuickButtons:!1,showConversion:!1,className:"w-full",autoFocus:!0})})}):t.jsx("div",{className:"cursor-pointer hover:bg-muted/50 p-1 rounded",onClick:n,children:e.hours?ps(Number(e.hours)):"Click to set hours"})}function Yi({entry:e,onUpdate:s,isEditing:r,onStartEdit:n,onCancelEdit:i}){const[a,l]=y.useState(e.activityType||""),[o,c]=y.useState(!1),g=async m=>{l(m);try{await s(e.id,"activityType",m),i()}catch(p){console.error("Error updating activity type:",p)}};return r?t.jsx("div",{className:"flex items-center gap-2 w-full",children:t.jsx(ms,{value:a,onValueChange:g,className:"flex-1"})}):t.jsx("div",{className:"cursor-pointer hover:bg-muted/50 p-1 rounded",onClick:n,title:e.activityType||void 0,children:e.activityType?t.jsx(re,{variant:"secondary",className:"whitespace-nowrap",children:e.activityType}):"Click to set activity"})}function Xi({entry:e,onUpdate:s,isEditing:r,onStartEdit:n,onCancelEdit:i,glowingDescriptions:a,setGlowingDescriptions:l}){const[o,c]=y.useState(Bt(e.description||"")),[g,m]=y.useState(!1),[p,u]=y.useState(!1),{toast:d}=ve(),f=Vt({mutationFn:async x=>(await pe("POST","/api/ai/enhance-description",x)).json(),onSuccess:async x=>{if(x.success){const b=x.result.enhancedDescription||o;if(c(b),l&&a){const k=new Set(a);k.add(e.id),l(k),setTimeout(()=>{const P=new Set(a);P.delete(e.id),l(P)},2e3)}try{await s(e.id,"description",b),d({title:"Description Enhanced & Saved",description:`AI improvements applied with ${Math.round(x.result.confidence*100)}% confidence`})}catch{d({title:"Enhancement Applied",description:"Enhanced description applied. Please save manually.",variant:"default"})}}u(!1)},onError:x=>{u(!1),d({title:"Enhancement Failed",description:"Failed to enhance description. Please try again.",variant:"destructive"})}}),h=async()=>{var x;if(!(o!=null&&o.trim())){d({title:"No Description",description:"Please enter a description first",variant:"destructive"});return}u(!0),f.mutate({originalDescription:o,timeEntryId:e.id,activityType:e.activityType||"",propertyNickname:(x=e.property)==null?void 0:x.nickname})},C=async()=>{if(o===Bt(e.description||"")){i();return}m(!0);try{await s(e.id,"description",o),i()}catch(x){console.error("Error updating description:",x)}finally{m(!1)}},v=x=>{if(p)return;const b=x==null?void 0:x.relatedTarget;b!=null&&b.closest('button[title="Enhance with AI"]')||C()},w=x=>
38{x.key==="Enter"&&!x.shiftKey?(x.preventDefault(),C()):x.key==="Escape"&&(c(Bt(e.description||"")),i())};if(r){const b=o.split(` 39`).length,k=Math.ceil(o.length/45),P=Math.max(b,k),I=Math.max(2,Math.min(8,P)),M=I*1.5+1;return t.jsxs("div",{className:"flex items-start gap-2 w-full p-1",style:{minHeight:`${M}rem`},children:[t.jsx("textarea",{value:o,onChange:$=>c($.target.value),onBlur:$=>v($),onKeyDown:w,className:`flex-1 break-words bg-transparent border border-gray-300 dark:border-gray-600 rounded outline-none resize-none overflow-y-auto text-current transition-all duration-300 !text-[13px] !leading-[1.5] font-normal focus:border-blue-500 dark:focus:border-blue-400 ${a!=null&&a.has(e.id)?"shadow-[0_0_15px_rgba(168,85,247,0.6)] animate-pulse bg-purple-50 dark:bg-purple-900/20":"bg-white dark:bg-gray-800"}`,style:{minHeight:`${I*1.5}rem`,height:`${I*1.5}rem`,lineHeight:"1.5",fontSize:"13px",fontFamily:"inherit",fontWeight:"normal",padding:"4px 8px",margin:"0"},placeholder:"Enter description...",autoFocus:!0,rows:I}),t.jsx("div",{className:"flex flex-col gap-1 flex-shrink-0 mt-1",children:t.jsx(L,{size:"sm",variant:"ghost",onClick:h,onMouseDown:$=>{$.preventDefault()},disabled:g||p||!(o!=null&&o.trim()),title:"Enhance with AI",className:"text-purple-600 hover:text-purple-700 hover:bg-purple-50 h-7 w-7 p-1",children:p?t.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border border-purple-600 border-t-transparent"}):t.jsx(vr,{className:"h-3 w-3"})})})]})}const N=e.description?Bt(e.description):"";return t.jsx("div",{className:"cursor-pointer hover:bg-muted/50 p-1 rounded transition-all duration-200",onClick:n,title:N||void 0,children:t.jsxs("div",{className:"flex items-start space-x-1",children:[t.jsx("div",{className:"flex-1 line-clamp-1 !text-[13px] !leading-[1.5] font-normal",style:{fontSize:"13px",lineHeight:"1.5",fontWeight:"normal"},children:N||t.jsx("span",{className:"text-muted-foreground italic",children:"Click to add description"})}),t.jsxs("div",{className:"relative group flex-shrink-0 mt-0.5",children:[t.jsx(vr,{className:"h-3 w-3 text-purple-600"}),t.jsx("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-1 px-2 py-1 bg-black text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity duration-200 whitespace-nowrap z-10",children:"Click to edit · AI enhancement available"})]})]})})}function Ji({entry:e,onUpdate:s,isEditing:r,onStartEdit:n,onCancelEdit:i,properties:a=[]}){var u;const[l,o]=y.useState(((u=e.propertyId)==null?void 0:u.toString())||"none"),[c,g]=y.useState(!1),m=async d=>{o(d);try{await s(e.id,"propertyId",d==="none"?null:d),i()}catch(f){console.error("Error updating property:",f)}};if(r)return t.jsx("div",{className:"flex items-center gap-2 w-full",children:t.jsxs(Se,{value:l,onValueChange:m,children:[t.jsx(Ce,{className:"flex-1",children:t.jsx(Ve,{placeholder:"Select property"})}),t.jsxs(ke,{children:[t.jsx(Z,{value:"none",children:"No Property"}),a.map(d=>t.jsx(Z,{value:d.id.toString(),children:d.nickname||d.address},d.id))]})]})});const p=e.property||a.find(d=>d.id===e.propertyId);return t.jsx("div",{className:"cursor-pointer hover:bg-muted/50 p-1 rounded",onClick:n,children:p?t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx($s,{className:"h-4 w-4 text-muted-foreground"}),t.jsx("div",{className:"max-w-[150px] truncate",title:`${p.nickname} - ${p.address}`,children:p.nickname})]}):t.jsx("span",{className:"text-muted-foreground italic",children:"Click to select property"})})}function Zi({entry:e,onUpdate:s,onUpdateMultiple:r,isEditing:n,onStartEdit:i,onCancelEdit:a,categories:l=[]}){const[o,c]=y.useState(e.isMaterialParticipation===void 0||e.isMaterialParticipation===null?"":String(e.isMaterialParticipation)),[g,m]=y.useState(!1),p=async d=>{c(d);try{const f=d==="true",h=d==="false";await r(e.id,{isMaterialParticipation:f,isQualifiedNonMaterial:h}),a()}catch(f){console.error("Error updating category:",f)}};if(n)return t.jsx("div",{className:"flex items-center gap-2 w-full",children:t.jsxs(Se,{value:o,onValueChange:p,children:[t.jsx(Ce,{className:"flex-1",children:t.jsx(Ve,{placeholder:"Select Category"})}),t.jsx(ke,{children:bn.map(d=>t.jsx(Z,{value:d.state.toString(),children:d.name},d.id))})]})});const u=l.find(d=>d.state===String(e.isMaterialParticipation));return t.jsx("div",{className:"cursor-pointer hover:bg-muted/50 p-1 rounded",onClick:i,children:u?t.jsx("div",{className:"flex items-center space-x-2",children:t.jsx("div",{title:`${u.name}`,children:u.name})}):t.jsx("span",{className:"text-muted-foreground italic",children:"Click to select category"})})}function ea({entry:e}){const s=e.source||"manual",r=Sn(s),n=Cn(s);return s.toLowerCase()==="geofence"&&e.approvalStatus==="pending"?t.jsxs(fs,{children:[t.jsx(xs,{asChild:!0,children:t.jsx("div",{className:"flex items-center justify-center cursor-default",children:n})}),t.jsx(hs,{side:"top",className:"max-w-[220px] text-center text-xs",children:"Detected visit via location â awaiting your review"})]}):t.jsx("div",{className:"flex items-center justify-center",title:r,children:n})}function ta({entry:e,onUpdate:s,isEditing:r,onStartEdit:n,onCancelEdit:i}){const[a,l]=y.useState(e.propertyType||""),[o,c]=y.useState(!1),g=[{value:"Long-term Rental",label:"Long-term Rental"},{value:"Short-term Rental",label:"Short-term Rental"}],m=async p=>{l(p);try{await s(e.id,"propertyType",p),i()}catch(u){console.error("Error updating REP status type:",u)}};return r?t.jsxs("div",{className:"flex items-center gap-2 w-full",children:[t.jsxs(Se,{value:a,onValueChange:m,disabled:o,children:[t.jsx(Ce,{className:"h-8 text-xs",children:t.jsx(Ve,{})}),t.jsx(ke,{children:g.map(p=>t.jsx(Z,{value:p.value,className:"text-xs",children:p.label},p.value))})]}),o&&t.jsx(ie,{className:"h-4 w-4 animate-spin"})]}):t.jsx("div",{className:"cursor-pointer hover:bg-muted/50 p-1 rounded",onClick:n,"data-testid":"text-rep-status-type",children:t.jsx(re,{variant:"outline",className:`text-xs ${e.propertyType?(e.propertyType||"L
39ong-term Rental")==="Long-term Rental"?"bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-950 dark:text-blue-300 dark:border-blue-800":"bg-green-50 text-green-700 border-green-200 dark:bg-green-950 dark:text-green-300 dark:border-green-800":"text-muted-foreground border-dashed"}`,children:e.propertyType||"Select Type"})})}function ra({entry:e,onUpdate:s,onOpenFilePreview:r}){var f,h,C;const[n,i]=y.useState(0),{toast:a}=ve(),l=Ar.useRef(null),o=((f=e.evidenceFiles)==null?void 0:f.filter(v=>!v.isDeleted))&&((h=e.evidenceFiles)==null?void 0:h.filter(v=>!v.isDeleted).length)>0||e.evidenceUrl,c=(((C=e.evidenceFiles)==null?void 0:C.filter(v=>!v.isDeleted).length)||0)+(e.evidenceUrl?1:0),g=Vt({mutationFn:async v=>{const w=new FormData;return w.append("files",v),(await pe("POST",`/api/evidence-files/${e.id}`,w)).json()},onSuccess:async()=>{i(100),a({title:"File Uploaded",description:"Evidence file uploaded successfully. AI analysis in progress..."}),await s()},onError:v=>{a({title:"Upload Failed",description:"Failed to upload evidence file. Please try again.",variant:"destructive"})}}),m=async v=>{var b;if(!v)return;const w=[".pdf",".doc",".docx",".jpg",".jpeg",".png",".gif"],N="."+((b=v.name.split(".").pop())==null?void 0:b.toLowerCase());if(!w.includes(N)){a({title:"Invalid file type",description:"Please upload PDF, DOC, DOCX, JPG, PNG, or GIF files.",variant:"destructive"});return}if(v.size>5*1024*1024){a({title:"File too large",description:"Please upload files smaller than 5MB.",variant:"destructive"});return}i(0);const x=setInterval(()=>{i(k=>Math.min(k+10,90))},200);try{await g.mutateAsync(v),clearInterval(x)}catch(k){clearInterval(x),console.error("Error uploading file:",k)}finally{i(0),l.current&&(l.current.value="")}},p=v=>{var N;const w=(N=v.target.files)==null?void 0:N[0];w&&m(w)},u=g.isPending,d=o?`${c} evidence file${c>1?"s":""} attached - click to upload more`:"No evidence files - click to upload";return t.jsxs("div",{className:"flex items-center justify-center gap-1","data-testid":"evidence-icon-only",children:[t.jsx(L,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",onClick:()=>{var v;return!e.deletedAt&&((v=l.current)==null?void 0:v.click())},disabled:u||!!e.deletedAt,title:d,children:u?t.jsx(ie,{className:"h-4 w-4 animate-spin text-blue-500"}):t.jsx(ys,{className:`h-4 w-4 ${o?"text-green-600 dark:text-green-400":"text-gray-400 dark:text-gray-500"}`})}),o&&t.jsx(L,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-blue-100 dark:hover:bg-blue-800 transition-colors",onClick:()=>r==null?void 0:r(e),title:"View evidence files","data-testid":`button-file-vault-${e.id}`,children:t.jsx(tt,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"})}),t.jsx("input",{ref:l,type:"file",accept:".pdf,.doc,.docx,.jpg,.jpeg,.png",onChange:p,className:"hidden"})]})}function Tn({entry:e,onUpdate:s}){const{toast:r}=ve(),n=Vt({mutationFn:async c=>{const g=c?`/api/time-entries/${e.id}/approve`:`/api/time-entries/${e.id}/unapprove`;return(await pe("PATCH",g,{})).json()},onSuccess:(c,g)=>{r({title:g?"Entry approved":"Entry unapproved",description:`Time entry ${g?"approved":"unapproved"} successfully`}),s()},onError:c=>{r({title:"Error",description:"Failed to update approval status",variant:"destructive"})}}),i=y.useCallback(c=>{n.isPending||n.mutate(c)},[n]),a=e.approvalStatus==="approved",l=n.isPending,o=a?"Approved - click to unapprove":"Pending approval - click to approve";return t.jsx("div",{className:"flex items-center justify-center",children:t.jsx("button",{className:` 40 h-4 w-4 rounded-full border-2 transition-all duration-200 flex items-center justify-center 41 ${a?"bg-green-500 border-green-500 hover:bg-green-600 hover:border-green-600":"bg-amber-500 border-amber-500 hover:bg-amber-600 hover:border-amber-600"} 42 ${l||e.deletedAt?"cursor-not-allowed opacity-50":"cursor-pointer"} 43 `,onClick:()=>!e.deletedAt&&i(!a),disabled:l||!!e.deletedAt,title:o,children:l?t.jsx(ie,{className:"h-2.5 w-2.5 animate-spin text-gray-400"}):a?t.jsx(Pr,{className:"h-2.5 w-2.5 text-white stroke-[2.5]"}):null})})}function na({entry:e,onUpdate:s}){const[r,n]=y.useState(!1),[i,a]=y.useState(!1),{toast:l}=ve(),o=y.useCallback(async()=>
43{if(!r){n(!0);try{await Ze.restoreTimeEntry(e.id),l({title:"Entry restored",description:"Time entry restored successfully"}),s(),a(!1)}catch(c){console.error("Error restoring entry:",c),l({title:"Error",description:"Failed to restore entry",variant:"destructive"})}finally{n(!1)}}},[e.id,r,l,s]);return e.deletedAt?t.jsx("div",{className:"flex items-center justify-center",children:t.jsxs(Ft,{open:i,onOpenChange:a,children:[t.jsx(vs,{asChild:!0,children:t.jsx("button",{className:` 44 h-6 w-6 rounded-full border transition-all duration-200 flex items-center justify-center 45 `,disabled:r,title:"Restore deleted entry",children:r?t.jsx(ie,{className:"h-4 w-4 animate-spin text-blue-600 dark:text-blue-400"}):t.jsx(en,{className:"h-4 w-4 text-green-600"})})}),t.jsxs(Et,{className:"rounded-xl shadow-lg border border-gray-200",children:[t.jsxs(Mt,{children:[t.jsx(Pt,{className:"text-lg font-semibold text-gray-900",children:"Restore Time Entry"}),t.jsxs(Dt,{className:"text-sm text-gray-600 leading-relaxed",children:["Are you sure you want to restore this time entry? It will be moved back to your active ledger.",t.jsxs("div",{className:"mt-3 p-3 bg-blue-50 border border-blue-100 rounded-lg text-sm text-gray-700",children:[t.jsx("div",{className:"font-medium text-gray-900",children:e.description}),t.jsxs("div",{className:"text-xs text-gray-500",children:[e.hours,"h â¢"," ",It(e.date,"MMM d, yyyy")]})]})]})]}),t.jsxs($t,{className:"flex justify-end space-x-2",children:[t.jsx(_t,{disabled:r,className:"px-4 py-2 rounded-lg border border-gray-300 text-gray-700 text-sm font-medium hover:bg-gray-100 transition",children:"Cancel"}),t.jsx(At,{onClick:c=>{c.preventDefault(),o()},disabled:r,className:"px-4 py-2 rounded-lg bg-blue-600 text-white text-sm font-medium hover:bg-blue-700 transition flex items-center",children:r?t.jsxs(t.Fragment,{children:[t.jsx(ie,{className:"mr-2 h-4 w-4 animate-spin"}),"Restoring..."]}):t.jsxs(t.Fragment,{children:[t.jsx(en,{className:"mr-2 h-4 w-4"}),"Restore Entry"]})})]})]})]})}):null}function sa(){const[e,s]=y.useState(()=>{const a=new Date;return new Date(a.getFullYear(),a.getMonth(),1)}),r=y.useCallback(()=>{s(a=>{const l=new Date(a);return l.setMonth(l.getMonth()-1),l})},[]),n=y.useCallback(()=>{s(a=>{const l=new Date(a);return l.setMonth(l.getMonth()+1),l})},[]),i=y.useMemo(()=>{const a=new Date,l=new Date(a.getFullYear(),a.getMonth(),1);return e.getTime()===l.getTime()},[e]);return{selectedMonth:e,setSelectedMonth:s,goToPreviousMonth:r,goToNextMonth:n,isAtCurrentMonth:i}}function ia(){const[e,s]=y.useState({}),r=y.useCallback((a,l)=>{const o=`${a}-${l}`;s(c=>({...c,[o]:{isEditing:!0,field:l,originalValue:null}}))},[]),n=y.useCallback((a,l)=>{const o=`${a}-${l}`;s(c=>{const g={...c};return delete g[o],g})},[]),i=y.useCallback((a,l)=>{var c;const o=`${a}-${l}`;return((c=e[o])==null?void 0:c.isEditing)||!1},[e]);return{editingState:e,startEdit:r,cancelEdit:n,isEditing:i}}function aa(e=!1){const[s,r]=y.useState(!0),[n,i]=y.useState([]),[a,l]=y.useState([]),[o,c]=y.useState(null),g=y.useCallback(async()=>{try{r(!0);const p=await fetch(`/api/time-entries?includeDeleted=${e}&limit=1000`,{cache:"no-cache",headers:{"Cache-Control":"no-cache"}});if(!p.ok)throw new Error("Failed to fetch time entries");const u=await p.json();i(u||[]),c(null)}catch(p){console.error("Error fetching entries:",p),c(p instanceof Error?p.message:"Failed to fetch data")}finally{r(!1)}},[e]);y.useEffect(()=>{g()},[g]),y.useEffect(()=>{const p=()=>g();return window.addEventListener("ledger:refresh",p),()=>window.removeEventListener("ledger:refresh",p)},[g]);const m=y.useMemo(()=>{const p=n.length,u=n.filter(h=>(h.approvalStatus||"pending")==="pending").length,d=n.filter(h=>h.approvalStatus==="approved").length,f=n.reduce((h,C)=>h+(Number(C.hours)||0),0);return{totalEntries:p,pendingEntries:u,approvedEntries:d,totalHours:f}},[n]);return{loading:s,entries:n,setEntries:i,newEntries:a,setNewEntries:l,error:o,fetchData:g,stats:m}}function la(e){const{toast:s}=ve(),r=ws(),[n,i]=y.useState(null),[a,l]=y.useState(!1),[o,c]=y.useState(0),[g,m]=y.useState(!1),[p,u]=y.useState(null),d=async(w,N)=>{try{let x=w;const b=w.includes(".r2.cloudflarestorage.com")||w.includes(".cloudflare")||w.startsWith("https://"),k=w.includes("/api/public/evidence/");if(!b&&!k)throw new Error("Invalid file URL - Legacy downloads not supported");const P=await fetch(x,{credentials:k?"include":"omit"});if(!P.ok)throw new Error("Download failed");const I=await P.blob(),M=window.URL.createObjectURL(I),$=document.createElement("a");$.href=M,$.download=N,document.body.appendChild($),$.click(),document.body.removeChild($),window.URL.revokeObjectURL(M)}catch{s({title:"Download Error",description:"Failed to download file. Please try again.",variant:"destructive"})}},f=w=>{if(w.evidenceFiles&&w.evidenceFiles.length>0){const N=w.evidenceFiles.filter(k=>!k.isDeleted),x=N[0],b=N.map(k=>({id:`evidence-${w.id}-${k.fileName}`,numericId:k.id,originalName:k.originalName,fileName:k.fileName,fileUrl:k.fileUrl,mimeType:k.mimeType||Kt(k.fileName),uploadedAt:k.uploadedAt||k.createdAt,fileSize:k.fileSize,aiSummary:k.aiSummary||w.aiSummary,aiAnalysisStatus:k.aiAnalysisStatus||w.evidenceAiAnalysisStatus||"pending",timeEntryId:w.id,isLegacy:!1,r2Key:k.r2Key,storageType:k.storageType,publicToken:k.publicToken}));i({id:x.id,numericId:x.id,originalName:x.originalName,fileName:x.fileName,fileUrl:x.fileUrl,mimeType:x.mimeType||Kt(x.fileName),uploadedAt:x.uploadedAt||x.createdAt,fileSize:x.fileSize,aiSummary:x.aiSummary||w.aiSummary,aiAnalysisStatus:x.aiAnalysisStatus||w.evidenceAiAnalysisStatus||"pending",timeEntryId:w.id,allFiles:b,r2Key:x.r2Key,storageType:x.storageType,publicToken:x.publicToken}),c(0),l(!0)}},h=Vt({mutationFn:async w=>{const N=await fetch(`/api/evidence-files/${w}`,{method:"DELETE",credentials:"include"});if(!N.ok){const x=await N.json().catch(()=>({}));throw new Error(x.message||"Failed to delete file")}return N.json()},onSuccess:async w=>{if(await r.invalidateQueries({queryKey:["/api/evidence-files"]}),await r.invalidateQueries({queryKey:["/api/time-entries"]}
45),Ds(p==null?void 0:p.numericId),s({title:"File Deleted",description:`"${(p==null?void 0:p.originalName)||(p==null?void 0:p.fileName)}" has been moved to deleted files.`}),m(!1),a&&n&&n.allFiles){const N=n.allFiles.filter(x=>x.numericId!==(p==null?void 0:p.numericId));if(N.length===0)l(!1),i(null);else if(n.numericId===(p==null?void 0:p.numericId)){const x=N[0];i({...x,allFiles:N}),c(0)}else{i(b=>({...b,allFiles:N}));const x=N.findIndex(b=>b.numericId===n.numericId);x!==-1&&c(x)}}u(null),await e()},onError:w=>{s({title:"Delete Failed",description:w.message,variant:"destructive"})}});return{previewFile:n,setPreviewFile:i,isFilePreviewOpen:a,setIsFilePreviewOpen:l,currentFileIndex:o,setCurrentFileIndex:c,handleOpenFilePreview:f,downloadFile:d,deleteFileDialogOpen:g,setDeleteFileDialogOpen:m,fileToDelete:p,handleFileDeleteClick:w=>{u(w),m(!0)},confirmFileDelete:()=>{p!=null&&p.numericId&&h.mutate(p.numericId)},deleteFileMutation:h}}function oa({entries:e,newEntries:s,selectedMonth:r}){const n=typeof window<"u"?new URLSearchParams(window.location.search):null,i=n==null?void 0:n.get("status"),[a,l]=y.useState(""),[o,c]=y.useState(i==="pending"?"pending":"all"),[g,m]=y.useState(i==="pending"?"all-entries":"monthly"),p=y.useMemo(()=>{const d=[...s,...e];let f=d;return o==="pending"?f=d.filter(h=>h.isNew||(h.approvalStatus||"pending")==="pending"):o==="approved"&&(f=d.filter(h=>!h.isNew&&h.approvalStatus==="approved")),g==="monthly"&&(f=f.filter(h=>{if(!h.date)return!1;const C=new Date(h.date),v=C.getFullYear(),w=C.getMonth(),N=r.getFullYear(),x=r.getMonth();return v===N&&w===x})),f.sort((h,C)=>{const v=h.isNew,w=C.isNew;if(v&&!w)return-1;if(!v&&w)return 1;if(v&&w)return 0;const N=h.approvalStatus||"pending",x=C.approvalStatus||"pending";return N==="pending"&&x!=="pending"?-1:N!=="pending"&&x==="pending"?1:C.id-h.id})},[e,s,o,r,g]),u=y.useMemo(()=>{const d=p.filter(h=>h.isNew||(h.approvalStatus||"pending")==="pending"),f=p.filter(h=>!h.isNew&&h.approvalStatus==="approved");return{pending:d,approved:f}},[p]);return{globalFilter:a,setGlobalFilter:l,statusFilter:o,setStatusFilter:c,viewMode:g,setViewMode:m,filteredData:p,groupedData:u}}function da({entries:e,setEntries:s,newEntries:r,setNewEntries:n,startEdit:i,properties:a=[]}){const{toast:l}=ve(),[o,c]=y.useState(null),[g,m]=y.useState(!1),[p,u]=y.useState(!1),d=y.useCallback(()=>{const x=`new-${Date.now()}`,b={id:x,date:js(),hours:"0.25",activityType:"",description:"",isMaterialParticipation:null,isQualifiedNonMaterial:!1,source:"manual",propertyType:null,isNew:!0};n(k=>[b,...k]),setTimeout(()=>{i(x,"activityType")},100),l({title:"New Entry Added",description:"Fill in the details in the blue highlighted row. Entry will save automatically when date, hours, and activity type are complete."})},[n,i,l]),f=y.useCallback(async(x,b,k,P)=>{try{if(typeof x=="string"&&x.startsWith("new-")){let I=null;n(M=>M.map($=>{if($.id===x){const G={...$,[b]:k};return G.date&&G.hours&&G.activityType&&(I=G),G}return $})),I&&setTimeout(()=>{C(x,I)},100)}else{const I=P||e.find(G=>G.id===x);if(!I)throw new Error("Entry not found");const M={...I,[b]:k},$={date:M.date||"",hours:(M.hours||0).toString(),activityType:M.activityType||"",description:M.description||"",isMaterialParticipation:M.isMaterialParticipation,isQualifiedNonMaterial:M.isQualifiedNonMaterial,source:M.source||"manual",propertyType:M.propertyType,propertyId:M.propertyId?M.propertyId.toString():void 0};await Ze.updateTimeEntry(x,$),s(G=>G.map(U=>{if(U.id===x){let K={...U,[b]:k};if(b==="propertyId")if(k===null||k==="none")K.property=void 0,K.propertyId=void 0;else{const J=typeof k=="string"?parseInt(k,10):k,oe=a.find(X=>X.id===J);oe&&(K.property=oe,K.propertyId=J)}return U.isNew&&K.activityType&&K.hours&&K.description&&delete K.isNew,K}return U})),l({title:"Entry updated",description:"Time entry has been successfully updated."})}}catch(I){throw console.error("Error updating entry:",I),l({title:"Error",description:I instanceof Error?I.message:"Failed to update entry. Please try again.",variant:"destructive"}),I}},[e,r,s,n,l,a]),h=y.useCallback(async(x,b,k)=>
45{try{if(typeof x=="string"&&x.startsWith("new-")){let P=null;n(I=>I.map(M=>{if(M.id===x){const $={...M,...b};return $.date&&$.hours&&$.activityType&&(P=$),$}return M})),P&&setTimeout(()=>{C(x,P)},100)}else{const P=k||e.find($=>$.id===x);if(!P)throw new Error("Entry not found");const I={...P,...b},M={date:I.date||"",hours:(I.hours||0).toString(),activityType:I.activityType||"",description:I.description||"",isMaterialParticipation:I.isMaterialParticipation,isQualifiedNonMaterial:I.isQualifiedNonMaterial,source:I.source||"manual",propertyType:I.propertyType,propertyId:I.propertyId?I.propertyId.toString():void 0};await Ze.updateTimeEntry(x,M),s($=>$.map(G=>{if(G.id===x){let U={...G,...b};if("propertyId"in b){const K=b.propertyId;if(K===null||K==="none")U.property=void 0,U.propertyId=void 0;else{const J=typeof K=="string"?parseInt(K,10):K,oe=a.find(X=>X.id===J);oe&&(U.property=oe,U.propertyId=J)}}return G.isNew&&U.activityType&&U.hours&&U.description&&delete U.isNew,U}return G})),l({title:"Entry updated",description:"Time entry has been successfully updated."})}}catch(P){throw console.error("Error updating entry:",P),l({title:"Error",description:P instanceof Error?P.message:"Failed to update entry. Please try again.",variant:"destructive"}),P}},[e,r,s,n,l,a]),C=y.useCallback(async(x,b)=>{if(!b){console.error("â saveNewEntry: No entry data provided");return}try{const k={date:b.date,hours:b.hours,activityType:b.activityType,description:b.description||"",isMaterialParticipation:b.isMaterialParticipation??null,isQualifiedNonMaterial:b.isQualifiedNonMaterial??!1,source:b.source,propertyType:b.propertyType,propertyId:b.propertyId&&b.propertyId!=="none"?b.propertyId:void 0},P=await Ze.createTimeEntry(k,[]);l({title:"Entry created",description:"Time entry has been successfully created."}),n(I=>I.filter(M=>M.id!==x)),s(I=>[P,...I])}catch(k){console.error("Error saving new entry:",k),l({title:"Error",description:"Failed to save entry. Please try again.",variant:"destructive"})}},[n,s,l]),v=y.useCallback(async x=>{if(typeof x=="string"&&x.startsWith("new-")){n(b=>b.filter(k=>k.id!==x));return}try{await Ze.deleteTimeEntry(x),s(b=>b.filter(k=>k.id!==x)),l({title:"Entry deleted",description:"New entry has been successfully deleted."})}catch(b){console.error("Error deleting new entry:",b),l({title:"Error",description:"Failed to delete entry. Please try again.",variant:"destructive"})}},[n,s,l]),w=y.useCallback(async x=>{if(typeof x.id=="string"&&x.id.startsWith("new-")){v(x.id);return}c(x),m(!0)},[v]),N=y.useCallback(async()=>{if(o)try{u(!0),await Ze.deleteTimeEntry(o.id),l({title:"Entry deleted",description:"Time entry has been successfully deleted."}),m(!1),s(x=>x.filter(b=>b.id!==o.id)),c(null)}catch{l({title:"Error",description:"Failed to delete entry. Please try again.",variant:"destructive"})}finally{u(!1)}},[o,s,l]);return{handleAddNewEntry:d,handleUpdateEntry:f,handleUpdateMultipleFields:h,deleteNewEntry:v,handleDeleteEntry:w,confirmDeleteEntry:N,entryToDelete:o,setEntryToDelete:c,showDeleteDialog:g,setShowDeleteDialog:m,isDeletingEntry:p}}function ca({table:e,entries:s,setEntries:r,setRowSelection:n,fetchData:i}){const{toast:a}=ve(),[l,o]=y.useState(!1),[c,g]=y.useState(!1),[m,p]=y.useState(!1),u=y.useCallback(()=>{if(e.getFilteredSelectedRowModel().rows.length===0){a({title:"No entries selected",description:"Please select entries to delete.",variant:"destructive"});return}o(!0)},[e,a]),d=y.useCallback(async()=>{const v=e.getFilteredSelectedRowModel().rows.map(w=>w.original).filter(w=>!w.deletedAt);if(v.length===0){o(!1);return}try{g(!0);const w=v.map(k=>pe("DELETE",`/api/time-entries/${k.id}`)),N=await Promise.allSettled(w),x=N.filter(k=>k.status==="rejected"),b=N.filter(k=>k.status==="fulfilled"&&k.value.ok);x.length>0?a({title:"Partial deletion",description:`${b.length} entries deleted, ${x.length} failed.`,variant:"destructive"}):a({title:"Entries deleted",description:`${b.length} entries have been successfully deleted.`}),o(!1),n({}),i()}catch{a({title:"Error",description:"Failed to delete entries. Please try again.",variant:"destructive"})}finally{g(!1)}},[e,n,i,a]),f=y.useCallback(async()=>{const C=e.getFilteredSelectedRowModel().rows.map(w=>w.original);if(C.length===0){a({title:"No entries selected",description:"Please select entries to enhance.",variant:"destructive"});return}const v=C.filter(w=>typeof w.id=="number");if(v.length===0){a({title:"No valid entries",description:"Please save new entries first before enhancing.",variant:"destructive"});return}if(v.length>50){a({title:"Too many entries",description:"Maximum 50 entries allowed for bulk enhancement.",variant:"destructive"});return}p(!0);try{const w=v.map(b=>b.id),N=await pe("POST","/api/ai/enhance-descriptions-bulk",{timeEntryIds:w});if(!N.ok)throw new Error("Failed to enhance descriptions");const x=await N.json();if(x.success&&x.results){let b=0,k=0;const P=x.results.map(async M=>{if(M.enhancement.enhancedDescription!==M.originalDescription)try{const $=v.find(G=>
45G.id===M.timeEntryId);return $?(await pe("PATCH",`/api/time-entries/${M.timeEntryId}`,{date:$.date,hours:$.hours,activityType:$.activityType,description:M.enhancement.enhancedDescription,isMaterialParticipation:$.isMaterialParticipation}),b++,{id:M.timeEntryId,description:M.enhancement.enhancedDescription}):(k++,null)}catch($){return console.error(`Failed to save enhanced description for entry ${M.timeEntryId}:`,$),k++,null}return null}),I=await Promise.all(P);r(M=>M.map($=>{const G=I.find(U=>(U==null?void 0:U.id)===$.id);return G?{...$,description:G.description}:$})),n({}),a({title:"Bulk Enhancement Complete",description:`Enhanced ${b} entries${k>0?`, ${k} failed`:""}`})}}catch(w){console.error("Bulk enhancement error:",w),a({title:"Enhancement Failed",description:"Failed to enhance descriptions. Please try again.",variant:"destructive"})}finally{p(!1)}},[e,s,r,n,a]);return{handleBulkDelete:u,confirmBulkDelete:d,showBulkDeleteDialog:l,setShowBulkDeleteDialog:o,isDeletingBulk:c,handleBulkEnhancement:f,isBulkEnhancing:m}}function ua({data:e,columns:s,globalFilter:r,setGlobalFilter:n}){const[i,a]=y.useState([]),[l,o]=y.useState([]),[c,g]=y.useState({propertyType:!1,category:!1}),[m,p]=y.useState({}),[u,d]=y.useState({pageIndex:0,pageSize:100});return{table:zi({data:e,columns:s,onSortingChange:a,onColumnFiltersChange:o,getCoreRowModel:Mi(),getPaginationRowModel:Vi(),getSortedRowModel:Ti(),getFilteredRowModel:Ai(),getFacetedUniqueValues:_i(),onColumnVisibilityChange:g,onRowSelectionChange:p,onPaginationChange:d,onGlobalFilterChange:n,globalFilterFn:"includesString",state:{sorting:i,columnFilters:l,columnVisibility:c,rowSelection:m,globalFilter:r,pagination:u}}),sorting:i,setSorting:a,columnFilters:l,setColumnFilters:o,columnVisibility:c,setColumnVisibility:g,rowSelection:m,setRowSelection:p,pagination:u,setPagination:d}}function ga({entries:e,setEntries:s,setShowNewEntryDialog:r,setShowModifyEntryDialog:n,setEntryToModify:i}){const{toast:a}=ve(),[l,o]=y.useState(!1);return{handleNewEntrySubmit:async m=>{var p;o(!0);try{const u=new FormData;u.append("date",m.date),u.append("hours",m.hours),u.append("activityType",m.activityType),u.append("description",m.description||""),u.append("propertyId",m.propertyId==="none"||!m.propertyId?"":m.propertyId),u.append("isMaterialParticipation",m.isMaterialParticipation.toString()),u.append("isQualifiedNonMaterial",((p=m.isQualifiedNonMaterial)==null?void 0:p.toString())||"false"),u.append("source","manual");const f=await(await pe("POST","/api/time-entries",u)).json();s(h=>[f,...h]),a({title:"Success",description:"Time entry created successfully"}),r==null||r(!1)}catch(u){throw a({title:"Error",description:u.message||"Failed to create entry",variant:"destructive"}),u}finally{o(!1)}},handleModifyEntrySubmit:async(m,p,u)=>{var d;o(!0);try{const f=new FormData;f.append("date",p.date),f.append("hours",p.hours),f.append("activityType",p.activityType),f.append("description",p.description||""),f.append("propertyId",p.propertyId==="none"||!p.propertyId?"":p.propertyId),f.append("isMaterialParticipation",p.isMaterialParticipation.toString()),f.append("isQualifiedNonMaterial",((d=p.isQualifiedNonMaterial)==null?void 0:d.toString())||"false");const C=await(await pe("PATCH",`/api/time-entries/${m}`,f)).json();if(u&&u.length>0)try{const v=new FormData;u.forEach(w=>{v.append("files",w)}),await pe("POST",`/api/evidence-files/${m}`,v),a({title:"Evidence Attached",description:`${u.length} file(s) uploaded successfully`})}catch(v){console.error("File upload failed",v),a({title:"Evidence Upload Failed",description:(v==null?void 0:v.message)||"Entry updated but files failed to upload",variant:"destructive"})}s(v=>v.map(w=>w.id===m?C:w)),a({title:"Success",description:"Time entry updated successfully"}),n(!1),i(null)}catch(f){throw a({title:"Error",description:f.message||"Failed to update entry",variant:"destructive"}),f}finally{o(!1)}},isSubmitting:l}}function pa({children:e,headerTitle:s,showBack:r,rightAction:n,className:i,fullWidth:a=!1}){return t.jsxs("div",{className:"bg-background md:pb-0",children:[s&&t.jsx(vn,{title:s,showBack:r,rightAction:n}),t.jsx("main",{className:te("w-full container-mobile mx-auto",s?"pt-[60px]":"pt-4",!a&&"","safe-area-left safe-area-right",i),children:e})]})}function ma({table:e,entries:s,setEntries:r,setRowSelection:n,fetchData:i}){const[a,l]=y.useState(!1),[o,c]=y.useState(!1),[g,m]=y.useState(!1),[p,u]=y.useState(!1),d=y.useCallback(async()=>
45{if(e.getFilteredSelectedRowModel().rows.filter(w=>{const N=w.original;return!N.isNew&&N.approvalStatus!=="approved"}).length===0){ye({title:"No entries selected",description:"Please select entries to approve.",variant:"destructive"});return}m(!0)},[e,n,i,ye]),f=y.useCallback(async()=>{if(e.getFilteredSelectedRowModel().rows.filter(w=>{const N=w.original;return!N.isNew&&N.approvalStatus!=="pending"}).length===0){ye({title:"No entries selected",description:"Please select entries to unapprove.",variant:"destructive"});return}u(!0)},[e,n,i,ye]),h=y.useCallback(async()=>{const w=e.getFilteredSelectedRowModel().rows.filter(N=>{const x=N.original;return!x.isNew&&x.approvalStatus!=="approved"}).map(N=>N.original);try{l(!0);const N=w.map(P=>fetch(`/api/time-entries/${P.id}/approve`,{method:"PATCH"})),x=await Promise.allSettled(N),b=x.filter(P=>P.status==="rejected"),k=x.filter(P=>P.status==="fulfilled"&&P.value.ok);b.length>0?ye({title:"Partial approval",description:`${k.length} entries approved, ${b.length} failed.`,variant:"destructive"}):ye({title:"Entries approved",description:`${k.length} entries have been successfully approved.`}),m(!1),n({}),i()}catch{ye({title:"Error",description:"Failed to approve entries. Please try again.",variant:"destructive"})}finally{l(!1)}},[e,ye,n,i]),C=y.useCallback(async()=>{const w=e.getFilteredSelectedRowModel().rows.filter(N=>{const x=N.original;return!x.isNew&&x.approvalStatus!=="pending"}).map(N=>N.original);try{c(!0);const N=w.map(P=>fetch(`/api/time-entries/${P.id}/unapprove`,{method:"PATCH"})),x=await Promise.allSettled(N),b=x.filter(P=>P.status==="rejected"),k=x.filter(P=>P.status==="fulfilled"&&P.value.ok);b.length>0?ye({title:"Partial unapproval",description:`${k.length} entries unapproved, ${b.length} failed.`,variant:"destructive"}):ye({title:"Entries unapproved",description:`${k.length} entries have been successfully unapproved.`}),u(!1),n({}),i()}catch{ye({title:"Error",description:"Failed to unapprove entries. Please try again.",variant:"destructive"})}finally{c(!1)}},[e,ye,n,i]);return{isApprovingBulk:a,isUnapprovingBulk:o,showBulkApproveDialog:g,showBulkUnapproveDialog:p,handleBulkApprove:d,handleBulkUnapprove:f,confirmBulkApprove:h,confirmBulkUnapprove:C,setShowBulkApproveDialog:m,setShowBulkUnapproveDialog:u}}function fa({entry:e,onEdit:s,onDelete:r,onView:n,onUpdate:i,properties:a=[]}){const{impactMedium:l}=bs(),o=_s(0),c=ir(o,[-100,0,100],["#ef4444","#ffffff","#22c55e"]),g=ir(o,[-100,-50,0],[1,.5,0]),m=ir(o,[0,50,100],[0,.5,1]),p=(h,C)=>{C.offset.x<-100&&r?(l(),r(e)):C.offset.x>100&&s&&(l(),s(e))},u=(h,C)=>{const v=Math.floor(h),w=C||Math.round((h-v)*60);return v===0?`${w}m`:w===0?`${v}h`:`${v}h ${w}m`},d=()=>{if(e.property&&typeof e.property=="object"&&"nickname"in e.property)return e.property.nickname;if(e.property&&typeof e.property=="object"&&"name"in e.property)return e.property.name;if(typeof e.property=="string")return e.property;if(e.propertyId&&a.length>0){const h=a.find(C=>C.id===e.propertyId);if(h)return h.nickname||h.address}return"Unknown Property"},f=e.approvalStatus==="approved";return t.jsxs("div",{className:"relative overflow-hidden bg-white dark:bg-gray-900 rounded-xl border border-gray-100 dark:border-gray-800 shadow-sm mb-2.5",children:[t.jsxs(Nt.div,{className:"absolute inset-0 flex items-center justify-between px-6",style:{background:c},children:[t.jsx(Nt.div,{className:"flex items-center text-white",style:{opacity:g},children:t.jsx(rt,{className:"w-4 h-4 mr-2"})}),t.jsx(Nt.div,{className:"flex items-center text-white",style:{opacity:m},children:t.jsx(Ns,{className:"w-4 h-4 ml-2"})})]}),t.jsxs(Nt.div,{drag:"x",dragConstraints:{left:0,right:0},dragElastic:.1,onDragEnd:p,style:{x:o},className:te("relative bg-white dark:bg-gray-900 px-4 py-3.5 cursor-pointer active:bg-gray-50 dark:active:bg-gray-800 flex items-start gap-3 z-10",e.deletedAt&&"opacity-50"),whileTap:{scale:.995},onClick:h=>{h.target.closest("button")||s==null||s(e)},children:[t.jsx("div",{className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-full bg-gray-100 dark:bg-gray-800",children:t.jsx(Ss,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}),t.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[t.jsx("span",{className:"font-semibold text-gray-900 dark:text-gray-100 text-[13px] truncate",children:d()}),t.jsx("span",{className:"text-[11px] text-gray-500 dark:text-gray-400 truncate lowercase",children:e.category||e.activityType}),e.description&&t.jsx("span",{className:"text-[10px] text-gray-400 dark:text-gray-500 line-clamp-2",children:e.description}),e.source==="geofence"&&e.approvalStatus==="pending"&&t.jsxs("span",{className:"flex items-center gap-1 mt-0.5",children:[Cn("geofence"),t.jsx("span",{className:"text-[10px] text-blue-500 dark:text-blue-400 font-medium",children:"Detected visit â awaiting review"})]})]}),t.jsxs("div",{className:"flex flex-col items-end gap-1.5 shrink-0",children:[t.jsx("span",{className:"font-semibold text-gray-900 dark:text-gray-100 text-[13px] whitespace-nowrap",children:u(e.hours,e.minutes)}),t.jsx("div",{onClick:h=>h.stopPropagation(),children:i?t.jsx(Tn,{entry:e,onUpdate:i}):t.jsx(hn,{className:te("w-4 h-4",f?"text-green-500 fill-green-50":"text-gray-300 dark:text-gray-600")})})]})]})]})}function xa({entries:e,onEdit:s,onDelete:r,onView:n,isLoading:i=!1,emptyMessage:a="No activity entries found",properties:l=[],onUpdate:o}){if(i)return t.jsx("div",{className:"space-y-4 px-4 py-4",children:[1,2,3,4,5].map(g=>t.jsxs("div",{className:"flex justify-between items-center py-4 border-b border-gray-100",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(sr,{className:"h-4 w-32 rounded-md"}),t.jsx(sr,{className:"h-3 w-20 rounded-md"})]}),t.jsx(sr,{className:"h-4 w-16 rounded-md"})]},g))});if(e.length===0)return t.jsxs("div",{className:"text-center py-12",children:[t.jsx(tt,{className:"w-12 h-12 text-gray-300 dark:text-gray-600 mx-auto mb-4"}),t.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:a})]});const c=y.useMemo(()=>{const g=[];return[...e].sort((p,u)=>{const d=new Date(p.date).getTime();return new Date(u.date).getTime()-d}
45).forEach(p=>{let u="Unknown Date";try{u=It(p.date,"EEE, MMM d")}catch{}const d=g[g.length-1];d&&d.date===u?d.items.push(p):g.push({date:u,items:[p]})}),g},[e]);return t.jsx("div",{children:t.jsx(yn,{children:c.map(g=>t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"bg-gray-200 dark:bg-gray-800 px-4 pt-2 pb-3 text-xs font-semibold text-gray-600 dark:text-gray-400 uppercase tracking-wide sticky top-0 z-10 w-full",children:g.date}),t.jsx("div",{className:"bg-transparent pt-2",children:g.items.map(m=>t.jsx(fa,{entry:m,onEdit:s,onDelete:r,onView:n,onUpdate:o,properties:l},m.id))})]},g.date))})})}function Da(){var Br,Gr;const[e,s]=y.useState(!1),r=Dr(),[n,i]=y.useState(!1);y.useEffect(()=>{i(!0)},[]);const{toast:a}=ve(),{selectedMonth:l,goToPreviousMonth:o,goToNextMonth:c,isAtCurrentMonth:g}=sa(),{startEdit:m,cancelEdit:p,isEditing:u}=ia(),{loading:d,entries:f,setEntries:h,newEntries:C,setNewEntries:v,error:w,fetchData:N,stats:x}=aa(e),{registerRefreshCallback:b}=Cs();y.useEffect(()=>{b(N)},[N,b]);const{globalFilter:k,setGlobalFilter:P,statusFilter:I,setStatusFilter:M,filteredData:$,groupedData:G,viewMode:U,setViewMode:K}=oa({entries:f,newEntries:C,selectedMonth:l}),{previewFile:J,setPreviewFile:oe,isFilePreviewOpen:X,setIsFilePreviewOpen:He,currentFileIndex:nt,setCurrentFileIndex:Oe,handleOpenFilePreview:st,downloadFile:it,deleteFileDialogOpen:at,setDeleteFileDialogOpen:lt,fileToDelete:ae,handleFileDeleteClick:Ne,confirmFileDelete:qe,deleteFileMutation:ot}=la(N),{data:de=[]}=ks({queryKey:["/api/properties"],retry:!1}),{handleAddNewEntry:We,handleUpdateEntry:fe,handleUpdateMultipleFields:ze,deleteNewEntry:dt,handleDeleteEntry:Be,confirmDeleteEntry:Qe,entryToDelete:ct,showDeleteDialog:ut,setShowDeleteDialog:gt,isDeletingEntry:pt}=da({entries:f,setEntries:h,newEntries:C,setNewEntries:v,startEdit:m,properties:de}),[mt,ne]=y.useState(!1),[S,R]=y.useState(null),[D,V]=y.useState(!1),[O,z]=y.useState(null),[F,B]=y.useState(!1),[H,Y]=y.useState(!1),[Re,xe]=y.useState(!1),[Ke,Ye]=y.useState(null),[Xt,Xe]=y.useState(!1),[he,Tt]=y.useState(null),[Jt,De]=y.useState(new Set),[ft,xt]=y.useState(!1),[ht,q]=y.useState(!1),[we,ce]=y.useState(!1),ue=async(E,j)=>{xt(!0);try{const T=new FormData;
45Object.keys(E).forEach(W=>{E[W]!==null&&E[W]!==void 0&&T.append(W,String(E[W]))}),T.has("source")||T.append("source","manual");const Q=await pe("POST","/api/time-entries",T);if(Q.ok){const W=await Q.json();if(j&&j.length>0&&W.id)try{const Ue=new FormData;j.forEach(Ur=>{Ue.append("files",Ur)}),await pe("POST",`/api/evidence-files/${W.id}`,Ue),a({title:"Evidence Attached",description:`${j.length} file(s) uploaded successfully`})}catch(Ue){console.error("File upload failed",Ue),a({title:"Evidence Upload Failed",description:"Entry created but files failed to upload",variant:"destructive"})}a({title:"Entry Created",description:"Time entry has been successfully created"}),Y(!1),Xe(!1),N()}else throw new Error("Failed to create entry")}catch(T){throw a({title:"Error",description:"Failed to create time entry",variant:"destructive"}),T}finally{xt(!1)}},Ge=E=>{Tt(E),Xe(!0)},ee=y.useMemo(()=>[{id:"select",header:({table:E})=>t.jsx("div",{className:"flex items-center justify-center w-full h-full",children:t.jsx(Rt,{checked:E.getIsAllPageRowsSelected(),onCheckedChange:j=>E.toggleAllPageRowsSelected(!!j),"aria-label":"Select all"})}),cell:({row:E})=>{const j=E.original,T=j.isNew;return t.jsxs("div",{className:"flex items-center justify-center gap-1 w-full h-full",children:[t.jsx(Rt,{checked:E.getIsSelected(),onCheckedChange:Q=>E.toggleSelected(!!Q),"aria-label":"Select row",disabled:T}),T&&t.jsx(L,{size:"sm",variant:"ghost",onClick:()=>dt(j.id),className:"h-5 w-5 p-0 text-red-500 hover:text-red-700 flex items-center justify-center",title:"Delete new entry",children:t.jsx(jn,{className:"h-3 w-3"})})]})},enableSorting:!1,enableHiding:!1},{accessorKey:"date",header:({column:E})=>t.jsxs(L,{variant:"ghost",onClick:()=>E.toggleSorting(E.getIsSorted()==="asc"),className:"h-8 p-0 hover:bg-transparent text-left justify-start w-full font-semibold",children:["DATE",t.jsx(Gt,{className:"ml-2 h-4 w-4"})]}),cell:({row:E})=>{const j=E.original;return t.jsx(Qi,{entry:j,onUpdate:(T,Q,W)=>fe(T,Q,W,j),isEditing:u(j.id,"date"),onStartEdit:()=>!j.deletedAt&&m(j.id,"date"),onCancelEdit:()=>p(j.id,"date")})}},{accessorKey:"hours",header:({column:E})=>t.jsxs(L,{variant:"ghost",onClick:()=>E.toggleSorting(E.getIsSorted()==="asc"),className:"h-8 p-0 hover:bg-transparent text-left justify-start w-full font-semibold",children:["DURATION",t.jsx(Gt,{className:"ml-2 h-4 w-4"})]}),cell:({row:E})=>{const j=E.original;return t.jsx(Ki,{entry:j,onUpdate:(T,Q,W)=>fe(T,Q,W,j),isEditing:u(j.id,"hours"),onStartEdit:()=>!j.deletedAt&&m(j.id,"hours"),onCancelEdit:()=>p(j.id,"hours")})}},{accessorKey:"activityType",filterFn:"equalsString",header:({column:E})=>t.jsxs("div",{className:"flex items-center w-full",children:[t.jsxs(L,{variant:"ghost",onClick:()=>E.toggleSorting(E.getIsSorted()==="asc"),className:"h-8 p-0 hover:bg-transparent text-left justify-start flex-1 font-semibold",children:["Activity Type",t.jsx(Gt,{className:"ml-2 h-4 w-4"})]}),t.jsx(Qt,{column:E})]}),cell:({row:E})=>{const j=E.original;return t.jsx(Yi,{entry:j,onUpdate:(T,Q,W)=>fe(T,Q,W,j),isEditing:u(j.id,"activityType"),onStartEdit:()=>!j.deletedAt&&m(j.id,"activityType"),onCancelEdit:()=>p(j.id,"activityType")})}},{accessorKey:"category",header:()=>t.jsx("div",{className:"flex items-center justify-start w-full h-full",children:t.jsx("span",{className:"text-sm font-semibold tracking-wide text-left",children:"Category"})}),cell:({row:E})=>{const j=E.original;return t.jsx(Zi,{entry:j,onUpdate:(T,Q,W)=>fe(T,Q,W,j),onUpdateMultiple:(T,Q)=>ze(T,Q,j),isEditing:u(j.id,"isMaterialParticipation"),onStartEdit:()=>!j.deletedAt&&m(j.id,"isMaterialParticipation"),onCancelEdit:()=>p(j.id,"isMaterialParticipation"),categories:bn})},enableHiding:!0,enableSorting:!0},{accessorKey:"description",header:()=>t.jsx("div",{className:"flex items-center justify-start w-full h-full",children:t.jsx("span",{className:"text-sm font-semibold tracking-wide text-left",children:"Description"})}),cell:({row:E})=>{const j=E.original;return t.jsx(Xi,{entry:j,onUpdate:(T,Q,W)=>fe(T,Q,W,j),isEditing:u(j.id,"description"),onStartEdit:()=>!j.deletedAt&&m(j.id,"description"),onCancelEdit:()=>p(j.id,"description"),glowingDescriptions:Jt,setGlowingDescriptions:De})}},{accessorKey:"property",filterFn:"equalsString",header:({column:E})=>t.jsxs("div",{className:"flex items-center justify-start w-full h-full",children:[t.jsx("span",{className:"text-sm font-semibold tracking-wide text-left flex-1",children:"Property"}),t.jsx(Qt,{column:E})]}),cell:({row:E})=>{const j=E.original;return t.jsx(Ji,{entry:j,onUpdate:(T,Q,W)=>fe(T,Q,W,j),isEditing:u(j.id,"property"),onStartEdit:()=>!j.deletedAt&&m(j.id,"property"),onCancelEdit:()=>p(j.id,"property"),properties:de})}},{accessorKey:"recordedBy",filterFn:"equalsString",header:({column:E})=>t.jsxs("div",{className:"flex items-center w-full",children:[t.jsxs(L,{variant:"ghost",onClick:()=>
45E.toggleSorting(E.getIsSorted()==="asc"),className:"h-8 p-0 hover:bg-transparent text-left justify-start flex-1 font-semibold",children:["Recorded By",t.jsx(Gt,{className:"ml-2 h-4 w-4"})]}),t.jsx(Qt,{column:E})]}),cell:({row:E})=>{const j=E.original;if(j.isNew)return t.jsx("span",{className:"text-xs text-muted-foreground",children:"You"});const{user:Q}=Rs(),W=j.recordedBy,Ue=j.recordedByUserId;if(!W&&!Ue)return t.jsx("span",{className:"text-xs text-muted-foreground",children:"â"});if((Q==null?void 0:Q.id)===Ue)return t.jsx(re,{variant:"secondary",className:"text-xs bg-blue-100 text-blue-800",children:"You"});const qr=W?W&&W?`${W}`:W:"Team Member";return t.jsx(re,{variant:"outline",className:"text-xs",title:qr,children:qr})},enableSorting:!0,enableHiding:!0},{accessorKey:"evidenceFiles",header:()=>t.jsx("div",{className:"flex items-center justify-center w-full h-full",children:t.jsx("span",{className:"text-sm font-semibold tracking-wide text-center",children:"Evidence"})}),cell:({row:E})=>{const j=E.original;return j.isNew?t.jsx("span",{className:"text-muted-foreground italic text-xs",children:"Save entry first"}):t.jsx(ra,{entry:j,onUpdate:N,onOpenFilePreview:st})}},{accessorKey:"source",header:()=>t.jsx("div",{className:"flex items-center justify-start w-full h-full",children:t.jsx("span",{className:"text-sm font-semibold tracking-wide text-left",children:"Source"})}),cell:({row:E})=>{const j=E.original;return t.jsx(ea,{entry:j})}},{accessorKey:"propertyType",header:()=>t.jsx("div",{className:"flex items-center justify-start w-full h-full",children:t.jsx("span",{className:"text-sm font-semibold tracking-wide text-left",children:"Property Type"})}),cell:({row:E})=>{const j=E.original;return t.jsx(ta,{entry:j,onUpdate:(T,Q,W)=>fe(T,Q,W,j),isEditing:u(j.id,"propertyType"),onStartEdit:()=>!j.deletedAt&&m(j.id,"propertyType"),onCancelEdit:()=>p(j.id,"propertyType")})},enableSorting:!0,enableHiding:!0},{accessorKey:"approvalStatus",filterFn:"equalsString",header:({column:E})=>t.jsxs("div",{className:"flex items-center justify-center w-full h-full",children:[t.jsx("span",{className:"text-sm font-semibold tracking-wide text-center",children:"Approval"}),t.jsx(Qt,{column:E})]}),cell:({row:E})=>{const j=E.original;return j.isNew?t.jsx(re,{variant:"secondary",className:"text-xs",children:"New"}):t.jsx("div",{className:"flex items-center justify-center w-full h-full",children:t.jsx(Tn,{entry:j,onUpdate:N})})}},...e?[{accessorKey:"restore",header:()=>t.jsx("div",{className:"flex items-center justify-center w-full h-full",children:t.jsx("span",{className:"text-sm font-semibold tracking-wide text-center",children:"Restore"})}),cell:({row:E})=>{const j=E.original;return j.isNew?t.jsx(re,{variant:"secondary",className:"text-xs",children:"New"}):t.jsx("div",{className:"flex items-center justify-center w-full h-full",children:t.jsx(na,{entry:j,onUpdate:N})})},enableHiding:!0}]:[],{id:"actions",header:()=>t.jsx("div",{className:"flex items-center justify-center w-full h-full",children:t.jsx("span",{className:"text-sm font-semibold tracking-wide text-center",children:"Actions"})}),cell:({row:E})=>{const j=E.original,T="isNew"in j&&j.isNew===!0;return t.jsx("div",{className:"flex items-center justify-center gap-2",children:t.jsxs(Ir,{children:[t.jsx($r,{asChild:!0,children:t.jsxs(L,{variant:"ghost",className:"h-8 w-8 p-0",children:[t.jsx("span",{className:"sr-only",children:"Open menu"}),t.jsx(Fs,{className:"h-4 w-4"})]})}),t.jsxs(_r,{align:"end",children:[t.jsxs(et,{onClick:()=>{T||Ge(j)},disabled:T,children:[t.jsx(Es,{className:"mr-2 h-4 w-4"}),"Duplicate Entry"]}),t.jsx(et,{onClick:()=>{T||(Ye(j),xe(!0))},disabled:T,children:"Edit Entry"}),t.jsx(et,{onClick:()=>{T||(z(j),B(!0))},disabled:T,children:"View Details"}),!j.deletedAt&&t.jsx(et,{onClick:()=>{T||Be(j)},className:"text-red-600",disabled:T,children:"Delete Entry"})]})]})})}}],[N,fe,ze,dt,u,m,p,de]),{table:se,rowSelection:Zt,setRowSelection:Lt}=ua({data:$,columns:ee,globalFilter:k,setGlobalFilter:P}),{handleBulkDelete:yt,confirmBulkDelete:er,showBulkDeleteDialog:tr,setShowBulkDeleteDialog:Je,isDeletingBulk:Ht,handleBulkEnhancement:rr,isBulkEnhancing:Ie}=ca({table:se,entries:f,setEntries:h,setRowSelection:Lt,fetchData:N}),{isApprovingBulk:vt,isUnapprovingBulk:Or,showBulkApproveDialog:Ln,showBulkUnapproveDialog:Hn,handleBulkApprove:On,handleBulkUnapprove:zn,confirmBulkApprove:Bn,confirmBulkUnapprove:Gn,setShowBulkApproveDialog:Un,setShowBulkUnapproveDialog:qn}=ma({table:se,entries:f,setEntries:h,setRowSelection:Lt,fetchData:N}),{handleModifyEntrySubmit:Wn,isSubmitting:Qn}=ga({entries:f,setEntries:h,setShowModifyEntryDialog:xe,setEntryToModify:Ye}),zr=t.jsxs(t.Fragment,{children:[S&&t.jsx(nn,{file:S,isOpen:D,onClose:()=>{V(!1),R(null)},hasActiveSubscription:!0}
45),t.jsx(zs,{open:F,onOpenChange:B,entry:O}),t.jsx(Ts,{open:ut,onOpenChange:gt,entry:ct,onConfirm:Qe,isDeleting:pt}),t.jsx(Ls,{open:tr,onOpenChange:Je,selectedCount:se.getFilteredSelectedRowModel().rows.length,onConfirm:er,isDeleting:Ht}),t.jsx(Bs,{open:Ln,onOpenChange:Un,selectedCount:se.getFilteredSelectedRowModel().rows.length,confirmBulkApprove:Bn,isApprovingBulk:vt,table:se}),t.jsx(Gs,{open:Hn,onOpenChange:qn,selectedCount:se.getFilteredSelectedRowModel().rows.length,confirmBulkUnapprove:Gn,isUnapprovingBulk:Or,table:se}),t.jsx(Os,{open:mt,onClose:()=>ne(!1),onImportComplete:N,properties:de}),t.jsx(Ms,{open:Re,onClose:()=>{xe(!1),Ye(null)},onSubmit:Wn,properties:de,entry:Ke,isSubmitting:Qn}),J&&t.jsx(nn,{file:J,isOpen:X,onClose:()=>{He(!1),oe(null),Oe(0)},hasActiveSubscription:!0,allFiles:J.allFiles||[],currentFileIndex:nt,onFileChange:E=>{if(J.allFiles&&J.allFiles[E]){const j=J.allFiles[E];Oe(E),oe({...J,id:j.numericId||j.id,numericId:j.numericId||j.id,originalName:j.originalName||j.fileName,fileName:j.fileName,fileUrl:j.fileUrl,mimeType:j.mimeType||Kt(j.fileName),uploadedAt:j.uploadedAt||j.createdAt,fileSize:j.fileSize,aiSummary:j.aiSummary,aiAnalysisStatus:j.aiAnalysisStatus,r2Key:j.r2Key,storageType:j.storageType,publicToken:j.publicToken})}},downloadFile:it,getMimeTypeFromFileName:Kt,onDelete:Ne}),t.jsx(Is,{open:at,onOpenChange:lt,fileName:(ae==null?void 0:ae.originalName)||(ae==null?void 0:ae.fileName)||"",onConfirm:qe,isDeleting:ot.isPending}),t.jsx(tn,{open:H,onClose:()=>Y(!1),onSubmit:ue,properties:de,isSubmitting:ft}),t.jsx(tn,{open:Xt,onClose:()=>{Xe(!1),Tt(null)},onSubmit:ue,properties:de,isSubmitting:ft,initialValues:he?{date:((Br=he.date)==null?void 0:Br.substring(0,10))||new Date().toISOString().substring(0,10),hours:he.hours.toString(),activityType:he.activityType,description:he.description,propertyId:((Gr=he.propertyId)==null?void 0:Gr.toString())||"none",isMaterialParticipation:he.isMaterialParticipation??!1,isQualifiedNonMaterial:he.isQualifiedNonMaterial??!1,category:he.isMaterialParticipation?"material":he.isQualifiedNonMaterial?"qualified":"passive"}:void 0,isDuplicate:!0})]}),Kn=x;return w?t.jsx("div",{className:"container mx-auto p-6",children:t.jsx(Me,{children:t.jsx(Pe,{className:"pt-6",children:t.jsxs("div",{className:"text-center text-red-600",children:[t.jsxs("p",{children:["Error loading activity ledger: ",w]}),t.jsxs(L,{onClick:N,variant:"outline",className:"mt-4",children:[t.jsx(wr,{className:"mr-2 h-4 w-4"}),"Retry"]})]})})})}):r?t.jsxs(pa,{fullWidth:!0,children:[t.jsxs("div",{className:"space-y-3 pt-3 pb-2",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100 tracking-tight",children:"Activity Ledger"}),t.jsx(L,{variant:"ghost",size:"icon",className:"h-9 w-9",onClick:()=>q(!ht),children:t.jsx(Nn,{className:"h-5 w-5 stroke-[2.5]"})})]}),t.jsx("div",{className:"w-full",children:t.jsx(An,{selectedMonth:l,goToPreviousMonth:o,goToNextMonth:c,isAtCurrentMonth:g})}),t.jsx("div",{className:"flex items-center gap-2",children:t.jsxs(Se,{value:I,onValueChange:M,children:[t.jsx(Ce,{className:"h-10 text-sm font-semibold flex-1 rounded-xl",children:t.jsx(Ve,{placeholder:"ALL STATUS"})}),t.jsxs(ke,{children:[t.jsx(Z,{value:"all",children:"ALL STATUS"}),t.jsx(Z,{value:"pending",children:"PENDING"}),t.jsx(Z,{value:"approved",children:"APPROVED"})]})]})}),t.jsx(Vn,{globalFilter:k,setGlobalFilter:P,statusFilter:I,setStatusFilter:M,table:se,allData:[...C,...f],onImportClick:()=>ne(!0),onRefresh:N,isLoading:d,showDeleted:e,setShowDeleted:s,showMobileFilters:ht,setShowMobileFilters:q})]}),t.jsx(xa,{entries:$.map(E=>({id:E.id,date:E.date,hours:typeof E.hours=="string"?parseFloat(E.hours):E.hours,minutes:E.minutes,activityType:E.activityType,description:E.description,property:E.property,propertyId:E.propertyId,approvalStatus:E.approvalStatus,category:E.category,source:E.source,isNew:E.isNew,deletedAt:E.deletedAt})),properties:de,onUpdate:N,isLoading:d,onView:E=>{const j=[...C,...f].find(T=>T.id===E.id);j&&!("isNew"in j&&j.isNew)&&(z(j),B(!0))},onEdit:E=>{const j=[...C,...f].find(T=>T.id===E.id);j&&!("isNew"in j&&j.isNew)&&(Ye(j),xe(!0))},onDelete:E=>{const j=[...C,...f].find(T=>T.id===E.id);j&&!("isNew"in j&&j.isNew)&&Be(j)},emptyMessage:"No entries for this period"}),zr]}):n?t.jsx(t.Fragment,{children:t.jsx(Wi,{stats:Kn,table:se,rowSelection:Zt,selectedMonth:l,goToNextMonth:c,goToPreviousMonth:o,isAtCurrentMonth:g,viewMode:U,setViewMode:K,globalFilter:k,setGlobalFilter:P,statusFilter:I,setStatusFilter:M,groupedData:G,loading:d,entries:f,newEntries:C,fetchData:N,filteredData:$,properties:de,handleAddNewEntry:We,handleBulkEnhancement:rr,handleBulkDelete:yt,handleBulkApprove:On,handleBulkUnapprove:zn,isBulkEnhancing:Ie,isDeletingBulk:Ht,isApprovingBulk:vt,isUnapprovingBulk:Or,showDeleted:e,setShowDeleted:s,showImportDialog:mt,setShowImportDialog:ne,selectedEntry:O,setSelectedEntry:z,showDetail
45sDialog:F,setShowDetailsDialog:B,entryToModify:Ke,setEntryToModify:Ye,showModifyEntryDialog:Re,setShowModifyEntryDialog:xe,showDuplicateDialog:Xt,setShowDuplicateDialog:Xe,entryToDuplicate:he,setEntryToDuplicate:Tt,showDeleteDialog:ut,setShowDeleteDialog:gt,entryToDelete:ct,handleDeleteEntry:Be,confirmDeleteEntry:Qe,isDeletingEntry:pt,showNewEntryDialog:H,setShowNewEntryDialog:Y,isCreating:ft,setIsCreating:xt,showFilePreview:D,setShowFilePreview:V,selectedFile:S,setSelectedFile:R,previewFile:J,setPreviewFile:oe,isFilePreviewOpen:X,currentFileIndex:nt,setCurrentFileIndex:Oe,handleOpenFilePreview:st,downloadFile:it,deleteFileDialogOpen:at,setDeleteFileDialogOpen:lt,fileToDelete:ae,handleFileDeleteClick:Ne,confirmFileDelete:qe,deleteFileMutation:ot,sharedDialogs:zr,onCreateEntry:ue,glowingDescriptions:Jt,setGlowingDescriptions:De})}):t.jsx("div",{className:"skeleton-loader"})}export{Da 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.