PageSourceSearch

https://bizvanguard.ai/assets/BillsPage-xqGFFnbK.js

js bizvanguard.ai collected 2026-10-05 13:48:27 UTC 34,158 bytes, 1 lines download raw bytes

1import{r as o,u as He,j as e,t as z}from"./vendor-react-zwv87yMD.js";import{u as Xe,a as he,b as U}from"./vendor-query-DYq8g7OI.js";import{p as cs}from"./api-client-wl3SCNAO.js";import{B as h}from"./button-DlBDuKbo.js";import{B as f}from"./badge-QivbhJml.js";import{I as ds}from"./input-C9cRIRX4.js";import{S as pe}from"./select-D2pLZtG9.js";import{A as ge,a as fe,b as je,c as Ne,d as ve,e as ye,f as we,g as Ce}from"./alert-dialog-P2RRIvov.js";import{b as M,f as L,g as be,a as Ee,c as ms,d as us}from"./bills-BzfdgZgx.js";import{R as Fe,c as Le}from"./receipts-DCJTRWD5.js";import{u as xs}from"./authStore-Bv6p2Ne2.js";import{u as hs}from"./useOrgTimezone-C1UagyKl.js";import{e as ps,a as gs}from"./timezoneFormatters-Lg56xFv0.js";import{g as fs,D as js}from"./DateFilterDropdown-CWvO1sMa.js";import{B as Ns,a as vs,R as ys}from"./BillDetailDialog-BCu1VgSf.js";import{v as P,O as ws,z as Re,w as Cs,C as Q,aq as bs,X as qe,bb as ks,bE as Ps,F as Ss,h as Ke,g as ke,az as Pe,s as Qe,x as Oe,p as $e,b as Ds,ap as Ue,bH as As,y as Ms,Q as zs}from"./vendor-icons-bLSWzydc.js";import{S as V}from"./SortIcon-DyP3bkCL.js";import{L as Ts}from"./ListSortMenu-CCmrkLSN.js";import{c as Bs}from"./vendor-router-DimZLiZb.js";import{f as Se}from"./vendor-date-DQe75t6Q.js";import"./vendor-charts-CtrTLS4K.js";import"./vendor-i18n-BdYkS11p.js";import"./vendor-ui-CfDMlrKu.js";import"./vendor-pdf-DQuePnfN.js";import"./vendor-state-ByI9XJey.js";import"./vendor-editor-C_dhmuey.js";import"./utils-BXSzAfFa.js";import"./i18n-CwjSIy0a.js";import"./employeeAuthStore-lYSKMuhw.js";import"./dropdown-menu-DJoX9NOt.js";import"./label-CSUA9GMO.js";import"./textarea-CfTUtQow.js";import"./tabs-Dd8Qm6LV.js";import"./phoneUtils-CLDOdnrv.js";import"./dialog-CCoQRIQ_.js";import"./pdfWorker-El_8qpqi.js";const Is=["image/jpeg","image/png","image/gif","image/webp","image/heic","image/heif","application/pdf"].join(","),Ve=10*1024*1024,Ge=3;function _e({onBillCreated:A}){const d=o.useRef(null),w=Xe(),[j,N]=o.useState(null),[t,m]=o.useState(null),{t:c}=He("bills"),r=t!==null,u=()=>{var I;(I=d.current)==null||I.click()},C=async I=>{const R=Array.from(I.target.files??[]);if(d.current&&(d.current.value=""),R.length===0)return;const q=R.filter(v=>v.size>Ve),S=R.filter(v=>v.size<=Ve);if(q.length>0?N(q.length===1?c("upload.fileTooLargeNamed",{name:q[0].name}):c("upload.fileTooLargeCount",{count:q.length})):N(null),S.length===0)return;m({done:0,total:S.length});let T=0,p=0;try{for(let v=0;v<S.length;v+=Ge){const G=S.slice(v,v+Ge),E=await Promise.allSettled(G.map(F=>M.upload(F)));for(const F of E)F.status==="fulfilled"?T+=1:p+=1;m({done:v+G.length,total:S.length})}}finally{m(null)}T>0&&(w.invalidateQueries({queryKey:["bills"]}),w.invalidateQueries({queryKey:["bills-dashboard"]}),A==null||A()),p===0&&T>0?z.success(c("upload.successToast",{count:T})):T>0?z.success(c("upload.partialToast",{ok:T,total:S.length,fail:p})):N(c("upload.errorFallback"))},k=r&&t.total>1?c("upload.uploadingProgress",{done:t.done,total:t.total}):c("upload.uploading");return e.jsxs("div",{children:[e.jsx("input",{ref:d,type:"file",accept:Is,multiple:!0,onChange:C,className:"hidden"}),e.jsxs(h,{onClick:u,disabled:r,children:[r?e.jsx(P,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(ws,{className:"h-4 w-4 mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:r?k:c("upload.buttonLabel")}),e.jsx("span",{className:"sm:hidden",children:c(r?"upload.uploading":"upload.buttonLabelShort")})]}),j&&e.jsx("p",{className:"text-xs text-red-600 mt-1",children:j})]})}function Es(A,d="uploaded",w="desc"){const j=new Map,N=c=>d==="document"?c.invoiceDate??c.createdAt:c.createdAt,t=w==="asc"?1:-1,m=[...A].sort((c,r)=>t*(new Date(N(c)).getTime()-new Date(N(r)).getTime()));for(const c of m){const r=new Date(N(c)),u=Se(r,"yyyy-MM"),C=Se(r,"MMMM yyyy");j.has(u)||j.set(u,{key:u,label:C,bills:[],total:0});const k=j.get(u);k.bills.push(c),k.total+=c.totalAmount||0}return Array.from(j.values()).sort((c,r)=>w==="asc"?c.key.localeCompare(r.key):r.key.localeCompare(c.key))}function Fs(A){var N;const d=new Set,w=new Map,j=new Map;for(const t of A){const m=t.vendorName.toLowerCase().trim(),c=t.totalAmount.toString(),r=((N=t.dueDate??t.invoiceDate)==null?void 0:N.split("T")[0])??"",u=`${m}|${c}|${r}`;if(w.has(u)||w.set(u,[]),w.get(u).push(t.id),t.invoiceNumber){const C=`${m}|${t.invoiceNumber.toLowerCase().trim()}`;j.has(C)||j.set(C,[]),j.get(C).push(t.id)}}for(const t of w.values())t.length>1&&t.forEach(m=>d.add(m));for(const t of j.values())t.length>1&&t.forEach(m=>d.add(m));return d}function Ls(){var Ie;const A=Bs(),d=Xe(),{permissions:w,currentOrganizationId:j}=xs(),N=hs(),{t}=He("bills"),m=w.includes("MANAGE_BILLS"),c=w.includes("VIEW_BILLS"),[r,u]=o.useState(1),C=20,[k,I]=o.use
1State(""),[R,q]=o.useState(""),[S,T]=o.useState("all"),[p,v]=o.useState("all"),[G,E]=o.useState(null),[F,_]=o.useState(null),[De,We]=o.useState(new Set),[Ye,se]=o.useState(null),[H,Je]=o.useState(()=>localStorage.getItem("bills-view-mode")||"list"),[y,Ae]=o.useState("uploaded"),[b,te]=o.useState("desc"),[X,Ze]=o.useState("all"),[ae,es]=o.useState({}),[g,W]=o.useState(new Set),[ss,ie]=o.useState(!1),[ts,ne]=o.useState(!1);o.useEffect(()=>{const s=setTimeout(()=>{q(k),u(1)},300);return()=>clearTimeout(s)},[k]);const le=o.useCallback(s=>{W(a=>{const i=new Set(a);return i.has(s)?i.delete(s):i.add(s),i})},[]),as=o.useCallback(s=>{W(a=>s.every(l=>a.has(l.id))?new Set:new Set(s.map(l=>l.id)))},[]),re=o.useCallback(()=>W(new Set),[]),O=s=>{y===s?te(a=>a==="asc"?"desc":"asc"):(Ae(s),te(s==="amount"?"desc":"asc")),u(1)},Me=s=>{Je(s),localStorage.setItem("bills-view-mode",s)},Y=o.useMemo(()=>y==="invoiceDate"?{sortBy:"invoiceDate",sortOrder:b}:y==="uploaded"?{sortBy:"uploaded",sortOrder:b}:{sortBy:"uploaded",sortOrder:"desc"},[y,b]),ze=y==="invoiceDate"?"document":"uploaded",{data:oe}=he({queryKey:["expense-categories",j],queryFn:M.getCategories,enabled:c,staleTime:300*1e3}),J=o.useMemo(()=>fs(X,ae,N),[X,ae,N]),{data:x,isLoading:is}=he({queryKey:["bills",j,p,S,r,R,J.from,J.to,Y.sortBy,Y.sortOrder],queryFn:()=>M.getAll({status:p==="needs-review"?"DRAFT":p==="pending"?"PENDING":p==="awaiting-approval"?"AWAITING_APPROVAL":p==="paid"?"PAID":void 0,expenseCategory:S!=="all"?S:void 0,uploadedFrom:J.from??void 0,uploadedTo:J.to??void 0,sortBy:Y.sortBy,sortOrder:Y.sortOrder,search:R||void 0,page:r,limit:C}),enabled:c,refetchInterval:s=>{var l;const a=s.state.data;return((l=a==null?void 0:a.bills)==null?void 0:l.some(D=>D.vendorName==="Processing..."&&D.totalAmount===0))?5e3:3e4}}),{data:n}=he({queryKey:["bills-dashboard",j],queryFn:M.getDashboardStats,enabled:c}),ce=o.useMemo(()=>(x==null?void 0:x.bills)||[],[x==null?void 0:x.bills]),K=s=>s.vendorName==="Processing..."&&s.totalAmount===0,de=s=>K(s)?"processing":s.processingErrorType||s.source!=="MANUAL"&&(s.vendorName==="Unknown Vendor"||s.vendorName==="Unknown")&&s.totalAmount===0?"error":s.aiConfidence!=null&&s.aiConfidence>0&&s.aiConfidence<.7?"low":s.aiConfidence!=null&&s.aiConfidence>=.7?"processed":null,$=ce,Z=o.useMemo(()=>[...$].sort((s,a)=>{const i=b==="asc"?1:-1;switch(y){case"vendor":return i*s.vendorName.localeCompare(a.vendorName);case"uploaded":return i*(new Date(s.createdAt).getTime()-new Date(a.createdAt).getTime());case"invoiceDate":return!s.invoiceDate&&!a.invoiceDate?0:s.invoiceDate?a.invoiceDate?i*(new Date(s.invoiceDate).getTime()-new Date(a.invoiceDate).getTime()):-1:1;case"amount":return i*(s.totalAmount-a.totalAmount);case"status":return i*s.status.localeCompare(a.status);case"aiConfidence":return i*((s.aiConfidence??0)-(a.aiConfidence??0));default:return 0}}),[$,y,b]),ns=o.useMemo(()=>Es($,ze,b),[$,ze,b]),me=o.useMemo(()=>Fs(ce),[ce]),ue=U({mutationFn:s=>M.markPaid(s),onSuccess:()=>{d.invalidateQueries({queryKey:["bills"]}),d.invalidateQueries({queryKey:["bills-dashboard"]}),d.invalidateQueries({queryKey:["bills-kpi-summary"]}),d.invalidateQueries({queryKey:["bills-ai-summary"]}),_(null)}}),Te=U({mutationFn:({id:s,category:a})=>M.update(s,{expenseCategory:a}),onSuccess:()=>{d.invalidateQueries({queryKey:["bills"]})}}),xe=U({mutationFn:()=>M.backfillCategories(),onSuccess:s=>{d.invalidateQueries({queryKey:["bills"]}),d.invalidateQueries({queryKey:["bills-dashboard"]}),z.success(s.updated>0?t("list.autoCategorizeSuccess",{count:s.updated}):t("list.autoCategorizeNone"))},onError:()=>z.error(t("list.autoCategorizeError"))}),B=U({mutationFn:({billIds:s,status:a})=>M.bulkUpdateStatus(s,a),onSuccess:(s,a)=>{d.invalidateQueries({queryKey:["bills"]}),d.invalidateQueries({queryKey:["bills-dashboard"]}),d.invalidateQueries({queryKey:["bills-kpi-summary"]}),d.invalidateQueries({queryKey:["bills-ai-summary"]}),re(),ne(!1),a.status==="PAID"?z.success(t("list.bulkMarkPaidSuccess",{count:s.updated})):a.status==="CANCELLED"&&z.success(t("list.bulkCancelSuccess",{count:s.updated}))},onError:()=>z.error(t("list.bulkActionFailed"))}),ee=U({mutationFn:s=>M.bulkDelete(s),onSuccess:s=>{d.invalidateQueries({queryKey:["bills"]}),d.invalidateQueries({queryKey:["bills-dashboard"]}),d.invalidateQueries({queryKey:["bills-kpi-summary"]}),d.invalidateQueries({queryKey:["bills-ai-summary"]}
1),re(),ie(!1),z.success(t("list.bulkDeleteSuccess",{count:s.deleted}))},onError:()=>z.error(t("list.bulkActionFailed"))}),ls=o.useCallback(s=>{W(a=>{const i=s.length>0&&s.every(D=>a.has(D.id)),l=new Set(a);return i?s.forEach(D=>l.delete(D.id)):s.forEach(D=>l.add(D.id)),l})},[]),rs=s=>{We(a=>{const i=new Set(a);return i.has(s)?i.delete(s):i.add(s),i})},os=()=>{F&&ue.mutate(F)},Be=()=>{};return e.jsxs("div",{className:"space-y-4 pb-24 sm:pb-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h1",{className:"text-lg sm:text-2xl font-semibold sm:font-bold leading-tight",children:t("list.pageTitle")}),e.jsx("p",{className:"hidden sm:block text-sm text-muted-foreground mt-1",children:t("list.pageSubtitle")}),e.jsxs("p",{className:"sm:hidden text-xs text-muted-foreground mt-0.5",children:[e.jsx("span",{className:"font-medium text-foreground",children:(n==null?void 0:n.totalBills)??0})," ",t("list.mobileStored"),((n==null?void 0:n.needsReview)??0)>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"font-medium text-yellow-700",children:[n==null?void 0:n.needsReview," ",t("list.mobileToReview")]})]})]})]}),m&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("div",{className:"hidden sm:flex",children:e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>xe.mutate(),disabled:xe.isPending,className:"h-8 whitespace-nowrap",title:t("list.autoCategorizeTitle"),children:[e.jsx(Re,{className:"h-3.5 w-3.5 mr-1.5"}),xe.isPending?t("list.categorizing"):t("list.autoCategorize")]})}),e.jsx(_e,{onBillCreated:Be})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 lg:flex-row lg:flex-wrap lg:items-center lg:gap-x-4 lg:gap-y-2",children:[e.jsxs("div",{className:"flex flex-col gap-2 min-w-0 lg:flex-1 lg:flex-row lg:items-center",children:[e.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-1 scrollbar-hide min-w-0 w-full lg:w-auto touch-pan-x",children:[e.jsxs(h,{variant:p==="all"?"default":"outline",size:"sm",onClick:()=>{v("all"),u(1)},className:"h-8 whitespace-nowrap flex-shrink-0",children:[e.jsx("span",{className:"hidden sm:inline",children:t("list.filterAll")}),e.jsx("span",{className:"sm:hidden",children:t("list.filterAllShort")}),e.jsx(f,{variant:"secondary",className:"ml-2 h-5 px-1.5",children:(n==null?void 0:n.totalBills)??((Ie=x==null?void 0:x.pagination)==null?void 0:Ie.total)??0})]}),e.jsxs(h,{variant:p==="needs-review"?"default":"outline",size:"sm",onClick:()=>{v("needs-review"),u(1)},className:`h-8 whitespace-nowrap flex-shrink-0 ${p!=="needs-review"&&((n==null?void 0:n.needsReview)??0)>0?"border-orange-300 text-orange-700 hover:bg-orange-50":""}`,children:[e.jsx(Cs,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx("span",{className:"hidden sm:inline",children:t("list.filterNeedsReview")}),e.jsx("span",{className:"sm:hidden",children:t("list.filterNeedsReviewShort")}),((n==null?void 0:n.needsReview)??0)>0&&e.jsx(f,{variant:p==="needs-review"?"secondary":"outline",className:"ml-2 h-5 px-1.5 bg-orange-100 text-orange-700 border-orange-300",children:n==null?void 0:n.needsReview})]}),((n==null?void 0:n.awaitingApproval)??0)>0&&e.jsxs(h,{variant:p==="awaiting-approval"?"default":"outline",size:"sm",onClick:()=>{v("awaiting-approval"),u(1)},className:"h-8 whitespace-nowrap flex-shrink-0 border-red-300 text-red-700 hover:bg-red-50",children:[e.jsx("span",{className:"hidden sm:inline",children:t("list.filterAwaitingApproval")}),e.jsx("span",{className:"sm:hidden",children:t("list.filterAwaitingApprovalShort")}),e.jsx(f,{variant:p==="awaiting-approval"?"secondary":"outline",className:"ml-2 h-5 px-1.5 bg-red-100 text-red-700 border-red-300",children:n==null?void 0:n.awaitingApproval})]}),((n==null?void 0:n.pending)??0)>0&&e.jsxs(h,{variant:p==="pending"?"default":"outline",size:"sm",onClick:()=>{v("pending"),u(1)},className:"h-8 whitespace-nowrap flex-shrink-0",children:[t("list.filterPending"),e.jsx(f,{variant:p==="pending"?"secondary":"outline",className:"ml-2 h-5 px-1.5",children:n==null?void 0:n.pending})]}),e.jsxs(h,{variant:p==="paid"?"default":"outline",size:"sm",onClick:()=>{v("paid"),u(1)},className:"h-8 whitespace-nowrap flex-shrink-0",children:[e.jsx(Q,{className:"h-3.5 w-3.5 mr-1.5"}),t("list.filterPaid"),((n==null?void 0:n.paid)??0)>0&&e.jsx(f,{variant:p==="paid"?"secondary":"outline",className:"ml-2 h-5 px-1.5 bg-green-100 text-green-700 border-green-300",children:n==null?void 0:n.paid})]})]}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(js,{value:X,customRange:ae,onChange:(s,a)=>{Ze(s),es(a),u(1)},className:"h-8 flex-1 min-w-0 lg:flex-none"}),e.jsx(Ts,{basis:y==="invoiceDate"?"document":"uploaded",direction:y==="invoiceDate"||y==="uploaded"?b:"desc",documentLabel:t("list.sortDocumentLabel"),onChange:(s,a)=>{Ae(s==="document"?"invoiceDate":"uploaded"),te(a),u(1)},className:"flex-1 lg:flex-initial"})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 sm:items-center lg:flex-shrink-0",children:[e.jsxs("div",{className:"relative flex-1 sm:flex-initial sm:w-64",children:[e.jsx(bs,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground z-10 pointer-events-none"}),e.jsx(ds,{type:"search",placeholder:t("list.searchPlaceholder"),value:k,onChange:s=>{I(s.target.value),u(1)},className:"pl-9 w-full"}),k&&e.jsx(h,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 -translate-y-1/2 h-6 w-6 p-0 z-10",onClick:()=>I(""),children:e.jsx(qe,{className:"h-3 w-3"})})]}),e.jsxs(pe,{value:S,onChange:s=>{T(s.target.value),u(1)},className:"w-full sm:w-40 flex-shrink-0",children:[e.jsx("option",{value:"all",children:t("list.allCategories")}),oe==null?void 0:oe.map(s=>e.jsx("option",{value:s.name,children:s.name},s.id))]}),e.jsxs("div",{className:"hidden sm:flex items-center border rounded-lg overflow-hidden flex-shrink-0",children:[e.jsx("button",{onClick:()=>Me("list"),className:`p-2 ${H==="list"?"bg-primary text-primary-foreground":"hover:bg-muted"}`,title:t("list.viewList"),children:e.jsx(ks,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>Me("table"),className:`p-2 ${H==="table"?"bg-primary text-primary-foreground":"hover:bg-muted"}`,title:t("list.viewTable"),children:e.jsx(Ps,{className:"h-4 w-4"})})]})]})]}),e.jsx("div",{children:is?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(P,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):$.length===0?e.jsxs("div",{className:"text-center py-12 bg-white rounded-lg border",children:[e.jsx(Ss,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium",children:t(k?"list.emptySearch":p!=="all"||X!=="all"?"list.emptyFilter":"list.emptyDefault")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t(k?"list.emptySearchHint":"list.emptyDefaultHint")}),m&&!k&&p==="all"&&e.jsx("div",{className:"flex gap-2 justify-center mt-4",children:e.jsx(_e,{onBillCreated:Be})})]}):e.jsxs("div",{className:"space-y-4",children:[(x==null?void 0:x.pagination)&&x.pagination.totalPages>1&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-2 px-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:t("list.paginationShowing",{from:(r-1)*C+1,to:Math.min(r*C,x.pagination.total),total:x.pagination.total})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(h,{variant:"outline",size:"sm",disabled:r===1,onClick:()=>u(r-1),children:[e.jsx(Ke,{className:"h-4 w-4 mr-1"}),t("list.paginationPrevious")]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t("list.paginationPage",{page:r,totalPages:x.pagination.totalPages})}),e.jsxs(h,{variant:"outline",size:"sm",disabled:r>=x.pagination.totalPages,onClick:()=>u(r+1),children:[t("list.paginationNext"),e.jsx(ke,{className:"h-4 w-4 ml-1"})]})]})]}),H==="table"&&e.jsx("div",{className:"hidden sm:block bg-white rounded-lg border overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm min-w-[900px]",children:[e.jsx("thead",{className:"bg-muted/50 border-b",children:e.jsxs("tr",{children:[m&&e.jsx("th",{className:"w-10 px-3 py-2",children:e.jsx("input",{type:"checkbox",className:"h-4 w-4 roun
1ded border-gray-300 cursor-pointer",checked:Z.length>0&&Z.every(s=>g.has(s.id)),onChange:()=>as(Z)})}),e.jsx("th",{className:"px-3 py-2 text-left font-medium cursor-pointer hover:bg-muted/80 select-none",onClick:()=>O("vendor"),children:e.jsxs("span",{className:"flex items-center gap-1",children:[t("list.colVendor"),e.jsx(V,{field:"vendor",sortField:y,sortDirection:b})]})}),e.jsx("th",{className:"px-3 py-2 text-left font-medium",children:t("list.colInvoiceDate")}),e.jsx("th",{className:"px-3 py-2 text-left font-medium cursor-pointer hover:bg-muted/80 select-none",onClick:()=>O("uploaded"),children:e.jsxs("span",{className:"flex items-center gap-1",children:[t("list.colUploaded"),e.jsx(V,{field:"uploaded",sortField:y,sortDirection:b})]})}),e.jsx("th",{className:"px-3 py-2 text-left font-medium",children:t("list.colCategory")}),e.jsx("th",{className:"px-3 py-2 text-right font-medium cursor-pointer hover:bg-muted/80 select-none",onClick:()=>O("amount"),children:e.jsxs("span",{className:"flex items-center justify-end gap-1",children:[t("list.colAmount"),e.jsx(V,{field:"amount",sortField:y,sortDirection:b})]})}),e.jsx("th",{className:"px-3 py-2 text-left font-medium cursor-pointer hover:bg-muted/80 select-none",onClick:()=>O("status"),children:e.jsxs("span",{className:"flex items-center gap-1",children:[t("list.colStatus"),e.jsx(V,{field:"status",sortField:y,sortDirection:b})]})}),e.jsx("th",{className:"px-3 py-2 text-left font-medium cursor-pointer hover:bg-muted/80 select-none",onClick:()=>O("aiConfidence"),children:e.jsxs("span",{className:"flex items-center gap-1",children:[t("list.colAI"),e.jsx(V,{field:"aiConfidence",sortField:y,sortDirection:b})]})}),e.jsx("th",{className:"px-3 py-2 text-right font-medium",children:t("list.colActions")})]})}),e.jsx("tbody",{className:"divide-y",children:Z.map(s=>{const a=de(s);return e.jsxs("tr",{className:`hover:bg-muted/50 cursor-pointer ${g.has(s.id)?"bg-primary/5":""}`,onClick:()=>E(s),children:[m&&e.jsx("td",{className:"px-3 py-2",children:e.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-gray-300 cursor-pointer",checked:g.has(s.id),onChange:()=>le(s.id),onClick:i=>i.stopPropagation()})}),e.jsx("td",{className:"px-3 py-2 font-medium max-w-[200px]",children:K(s)?e.jsxs("span",{className:"flex items-center gap-1.5 text-blue-600",children:[e.jsx(P,{className:"h-3 w-3 animate-spin"}),t("list.aiProcessing")]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"truncate",children:s.vendorName}),me.has(s.id)&&e.jsx("span",{title:t("list.possibleDuplicate"),children:e.jsx(Pe,{className:"h-3 w-3 text-yellow-600 flex-shrink-0","aria-label":t("list.possibleDuplicate")})})]})}),e.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:s.invoiceDate?Se(cs(s.invoiceDate),"MMM d, yyyy"):"—"}),e.jsx("td",{className:"px-3 py-2 text-muted-foreground whitespace-nowrap",children:ps(s.createdAt,N)}),e.jsx("td",{className:"px-3 py-2",children:m?e.jsxs(pe,{value:s.expenseCategory||"",onChange:i=>{i.stopPropagation(),Te.mutate({id:s.id,category:i.target.value})},onClick:i=>i.stopPropagation(),className:"h-8 text-xs py-1 px-2 w-full min-w-[130px]",children:[e.jsx("option",{value:"",children:t("list.noCategory")}),Fe.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))]}):e.jsx("span",{className:"text-muted-foreground truncate",children:s.expenseCategory?Le(s.expenseCategory):"—"})}),e.jsx("td",{className:"px-3 py-2 text-right font-semibold",children:L(s.totalAmount)}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(f,{className:`text-xs ${Ee(s.status)}`,children:be(s.status)})}),e.jsxs("td",{className:"px-3 py-2",children:[a==="processing"&&e.jsxs(f,{className:"text-xs bg-blue-100 text-blue-800",children:[e.jsx(P,{className:"h-2.5 w-2.5 mr-0.5 animate-spin"}),t("list.aiStatusProcessing")]}),a==="error"&&e.jsx("span",{title:s.processingError??t("list.aiProcessingFailed"),children:e.jsxs(f,{className:"text-xs bg-red-100 text-red-800",children:[e.jsx(Qe,{className:"h-2.5 w-2.5 mr-0.5"}),t("list.aiStatusFailed")]})}),a==="low"&&e.jsx(f,{className:"text-xs bg-yellow-100 text-yellow-800",children:t("list.aiStatusLow")}),a==="processed"&&e.jsx(f,{className:"text-xs bg-green-100 text-green-800",children:s.aiConfidence?`${Math.round(s.aiConfidence*100)}%`:"OK"})]}),e.jsx("td",{className:"px-3 py-2 text-right",children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[m&&s.status!=="PAID"&&e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:i=>{i.stopPropagation(),se(s)},title:t("list.actionRecordPayment"),children:e.jsx(Oe,{className:"h-3.5 w-3.5"})}),e.jsx(h,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-green-600 hover:text-green-700 hover:bg-green-50",onClick:i=>{i.stopPropagation(),_(s.id)},title:t("list.actionMarkPaid"),children:e.jsx(Q,{className:"h-3.5 w-3.5"})})]}),e.jsx(h,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:i=>{i.stopPropagation(),E(s)},title:t("list.actionViewDetails"),children:e.jsx($e,{className:"h-3.5 w-3.5"})})]})})]},s.id)})})]})}),e.jsx("div",{className:`space-y-4 ${H==="table"?"sm:hidden":""} ${g.size>0?"pb-24":""}`,children:ns.map(s=>e.jsxs("div",{className:"bg-white rounded-lg border overflow-hidden",children:[e.jsxs("button",{onClick:()=>rs(s.key),className:"w-full px-3 sm:px-4 py-2.5 sm:py-3 flex items-center justify-between bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[m&&e.jsx("input",{type:"checkbox",className:"h-4 w-4 roun
1ded border-gray-300 cursor-pointer",checked:s.bills.length>0&&s.bills.every(a=>g.has(a.id)),onChange:()=>ls(s.bills),onClick:a=>a.stopPropagation(),"aria-label":t("list.bulkSelectGroup")}),De.has(s.key)?e.jsx(ke,{className:"h-4 w-4 sm:h-5 sm:w-5 text-muted-foreground"}):e.jsx(Ds,{className:"h-4 w-4 sm:h-5 sm:w-5 text-muted-foreground"}),e.jsx("span",{className:"font-semibold text-base sm:text-lg",children:s.label}),e.jsx(f,{variant:"secondary",className:"ml-1 text-xs",children:s.bills.length})]}),e.jsx("div",{className:"text-right",children:e.jsx("span",{className:"font-semibold text-base sm:text-lg",children:L(s.total)})})]}),!De.has(s.key)&&e.jsx("div",{className:"divide-y",children:s.bills.map(a=>{const i=a.amountPaid>0&&a.status!=="PAID";return e.jsxs("div",{className:`p-3 sm:p-4 hover:bg-muted/50 cursor-pointer ${g.has(a.id)?"bg-primary/5":""}`,onClick:()=>E(a),children:[e.jsx("div",{className:"sm:hidden",children:e.jsxs("div",{className:"flex items-center gap-3",children:[m&&e.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-gray-300 cursor-pointer flex-shrink-0",checked:g.has(a.id),onChange:()=>le(a.id),onClick:l=>l.stopPropagation(),"aria-label":t("list.bulkSelectBill")}),(()=>{const l=de(a),D=K(a)?"bg-blue-500 animate-pulse":l==="error"?"bg-red-500":l==="low"?"bg-yellow-500":a.status==="PAID"?"bg-green-500":"bg-gray-400";return e.jsx("span",{className:`flex-shrink-0 w-2 h-2 rounded-full ${D}`,title:be(a.status)})})(),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:K(a)?e.jsx("span",{className:"text-blue-600",children:t("list.aiProcessingEllipsis")}):a.vendorName}),me.has(a.id)&&e.jsx(Pe,{className:"h-3 w-3 text-yellow-600 flex-shrink-0","aria-label":t("list.possibleDuplicate")})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground mt-0.5",children:[e.jsx("span",{className:"flex-shrink-0",children:gs(a.invoiceDate??a.createdAt,N)}),a.invoiceNumber&&e.jsx("span",{className:"truncate",children:t("list.invPrefix",{number:a.invoiceNumber})}),i&&e.jsx("span",{className:"text-blue-600 flex-shrink-0",children:t("list.partialPaidMobile",{amount:L(a.amountPaid)})})]})]}),e.jsx("p",{className:"font-semibold text-sm flex-shrink-0 tabular-nums",children:L(a.totalAmount)})]})}),e.jsxs("div",{className:"hidden sm:flex items-center gap-4",children:[m&&e.jsx("div",{className:"flex-shrink-0",children:e.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-gray-300 cursor-pointer",checked:g.has(a.id),onChange:()=>le(a.id),onClick:l=>l.stopPropagation()})}),e.jsx("div",{className:"w-16 h-16 rounded-lg overflow-hidden flex-shrink-0",children:K(a)?e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-blue-50",children:e.jsx(P,{className:"h-6 w-6 animate-spin text-blue-500"})}):e.jsx(Ns,{billId:a.id,hasImage:!!a.storageKey,className:"w-full h-full object-cover",fallbackClassName:"w-16 h-16 rounded-lg",updatedAt:a.updatedAt})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"font-medium truncate",children:K(a)?e.jsxs("span",{className:"flex items-center gap-1.5 text-blue-600",children:[e.jsx(P,{className:"h-3.5 w-3.5 animate-spin"}),t("list.aiProcessing")]}):a.vendorName}),e.jsx(f,{className:Ee(a.status),children:be(a.status)}),e.jsx(f,{variant:"outline",className:us(a.source),children:ms(a.source)}),(()=>{const l=de(a);return l==="processing"?e.jsxs(f,{className:"bg-blue-100 text-blue-800",children:[e.jsx(P,{className:"h-3 w-3 mr-1 animate-spin"}),t("list.aiStatusProcessing")]}):l==="error"?e.jsx("span",{title:a.processingError??t("list.aiProcessingFailed"),children:e.jsxs(f,{className:"bg-red-100 text-red-800",children:[e.jsx(Qe,{className:"h-3 w-3 mr-1"}),t("list.aiStatusFailed")]})}):l==="low"?e.jsx(f,{className:"bg-yellow-100 text-yellow-800",children:t("list.aiStatusLowConfidence")}):l==="processed"?e.jsx(f,{className:"bg-green-100 text-green-800",children:t("list.aiStatusProcessed")}):null})(),me.has(a.id)&&e.jsxs(f,{variant:"outline",className:"bg-yellow-50 text-yellow-700 border-yellow-300",children:[e.jsx(Pe,{className:"h-3 w-3 mr-1"}),t("list.possibleDuplicate")]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mt-1",children:[e.jsxs("span",{children:["#",a.billNumber]}),a.invoiceNumber&&e.jsx("span",{children:t("list.invPrefixDesktop",{number:a.invoiceNumber})}),m?e.jsxs(pe,{value:a.expenseCategory||"",onChange:l=>
1{l.stopPropagation(),Te.mutate({id:a.id,category:l.target.value})},onClick:l=>l.stopPropagation(),className:"h-8 text-xs py-1 px-2 w-auto min-w-[140px] max-w-[180px]",children:[e.jsx("option",{value:"",children:t("list.noCategory")}),Fe.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value))]}):a.expenseCategory&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Re,{className:"h-3 w-3"}),Le(a.expenseCategory)]}),i&&e.jsx("span",{className:"text-blue-600",children:t("list.partialPaid",{amount:L(a.amountPaid)})})]})]}),e.jsxs("div",{className:"text-right flex-shrink-0",children:[e.jsx("p",{className:"text-lg font-semibold",children:L(a.totalAmount)}),a.amountPaid>0&&a.status!=="PAID"&&e.jsx("p",{className:"text-xs text-orange-600",children:t("list.amountDue",{amount:L(a.amountDue)})}),a.aiConfidence!=null&&e.jsx("p",{className:"text-xs text-muted-foreground",children:t("list.aiConfidence",{pct:Math.round(a.aiConfidence*100)})})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[m&&a.status!=="PAID"&&e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"ghost",size:"sm",className:"text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:l=>{l.stopPropagation(),se(a)},title:t("list.actionRecordPayment"),children:e.jsx(Oe,{className:"h-4 w-4"})}),e.jsx(h,{variant:"ghost",size:"sm",className:"text-green-600 hover:text-green-700 hover:bg-green-50",onClick:l=>{l.stopPropagation(),_(a.id)},title:t("list.actionMarkPaid"),children:e.jsx(Q,{className:"h-4 w-4"})})]}),e.jsx(h,{variant:"ghost",size:"sm",onClick:l=>{l.stopPropagation(),E(a)},title:t("list.actionViewDetails"),children:e.jsx($e,{className:"h-4 w-4"})})]})]})]},a.id)})})]},s.key))}),(x==null?void 0:x.pagination)&&x.pagination.totalPages>1&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-2 px-1",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",(r-1)*C+1," to"," ",Math.min(r*C,x.pagination.total)," of"," ",x.pagination.total," bills"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(h,{variant:"outline",size:"sm",disabled:r===1,onClick:()=>u(r-1),children:[e.jsx(Ke,{className:"h-4 w-4 mr-1"}),"Previous"]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",r," of ",x.pagination.totalPages]}),e.jsxs(h,{variant:"outline",size:"sm",disabled:r>=x.pagination.totalPages,onClick:()=>u(r+1),children:["Next",e.jsx(ke,{className:"h-4 w-4 ml-1"})]})]})]})]})}),e.jsx(vs,{bill:G,onClose:()=>E(null)}),e.jsx(ys,{bill:Ye,onClose:()=>se(null)}),e.jsx(ge,{open:!!F,onOpenChange:()=>_(null),children:e.jsxs(fe,{children:[e.jsxs(je,{children:[e.jsx(Ne,{children:t("list.markPaidTitle")}),e.jsx(ve,{children:t("list.markPaidDescription")})]}),e.jsxs(ye,{children:[e.jsx(we,{children:t("list.cancel")}),e.jsxs(Ce,{onClick:os,className:"bg-green-600 text-white hover:bg-green-700",disabled:ue.isPending,children:[ue.isPending?e.jsx(P,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Q,{className:"h-4 w-4 mr-2"}),t("list.markPaidConfirm")]})]})]})}),e.jsx(ge,{open:ts,onOpenChange:ne,children:e.jsxs(fe,{children:[e.jsxs(je,{children:[e.jsx(Ne,{children:t("list.bulkMarkPaidTitle",{count:g.size})}),e.jsx(ve,{children:t("list.bulkMarkPaidDescription")})]}),e.jsxs(ye,{children:[e.jsx(we,{children:t("list.cancel")}),e.jsxs(Ce,{onClick:()=>B.mutate({billIds:Array.from(g),status:"PAID"}),className:"bg-green-600 text-white hover:bg-green-700",disabled:B.isPending,children:[B.isPending?e.jsx(P,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Q,{className:"h-4 w-4 mr-2"}),t("list.bulkMarkPaidConfirm",{count:g.size})]})]})]})}),e.jsx(ge,{open:ss,onOpenChange:ie,children:e.jsxs(fe,{children:[e.jsxs(je,{children:[e.jsx(Ne,{children:t("list.bulkDeleteTitle",{count:g.size})}),e.jsx(ve,{children:t("list.bulkDeleteDescription")})]}),e.jsxs(ye,{children:[e.jsx(we,{children:t("list.cancel")}),e.jsxs(Ce,{onClick:()=>ee.mutate(Array.from(g)),className:"bg-red-600 text-white hover:bg-red-700",disabled:ee.isPending,children:[ee.isPending?e.jsx(P,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Ue,{className:"h-4 w-4 mr-2"}),t("list.bulkDeleteConfirm",{count:g.size})]})]})]})}),g.size>0&&m&&e.jsxs("div",{className:"fixed bottom-0 left-0 right-0 z-50 bg-white border-t shadow-lg px-3 py-3 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-3 sm:px-6 pb-[max(0.75rem,env(safe-area-inset-bottom))]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(As,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:t("list.bulkSelected",{count:g.size})}),e.jsx(h,{variant:"ghost",size:"sm",onClick:re,className:"h-7 px-2",children:e.jsx(qe,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(h,{variant:"outline",size:"sm",disabled:B.isPending,onClick:()=>B.mutate({billIds:Array.from(g),status:"CANCELLED"}),children:[B.isPending?e.jsx(P,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}):e.jsx(Ms,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx("span",{className:"hidden sm:inline",children:t("list.bulkCancelSelected")}),e.jsx("span",{className:"sm:hidden",children:t("list.bulkCancelShort")})]}),e.jsxs(h,{variant:"outline",size:"sm",className:"text-green-700 border-green-300 hover:bg-green-50",disabled:B.isPending,onClick:()=>ne(!0),children:[B.isPending?e.jsx(P,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}):e.jsx(Q,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx("span",{className:"hidden sm:inline",children:t("list.bulkMarkPaid")}),e.jsx("span",{className:"sm:hidden",children:t("list.bulkMarkPaidShort")})]}),e.jsxs(h,{variant:"outline",size:"sm",className:"text-red-700 border-red-300 hover:bg-red-50",disabled:ee.isPending,onClick:()=>ie(!0),children:[e.jsx(Ue,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx("span",{className:"hidden sm:inline",children:t("list.bulkDeleteSelected")}),e.jsx("span",{className:"sm:hidden",children:t("list.bulkDeleteShort")})]})]})]}),m&&g.size===0&&e.jsx("button",{onClick:()=>A("/dashboard/scan-bill"),className:"fixed bottom-6 right-6 z-40 sm:hidden w-14 h-14 roun
1ded-full bg-primary text-primary-foreground shadow-lg hover:shadow-xl active:scale-95 transition-all flex items-center justify-center mb-[env(safe-area-inset-bottom)]",children:e.jsx(zs,{className:"h-6 w-6"})})]})}function vt(){return e.jsx("div",{className:"px-3 py-2 sm:p-6 space-y-2 sm:space-y-6",children:e.jsx(Ls,{})})}export{vt 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.