1import{r as l,j as e}from"./react-vendor-pafHdoJx.js";import{b as N,u as C,d as g}from"./index-Db0fDLGN.js";import{C as k}from"./shared-DWiYwVXx.js";import{ak as w,bk as P,an as $}from"./ui-vendor-DLXJn6s3.js";import{L as u,E as h,b as v}from"./shared-DHvo53EK.js";import"./map-vendor-Dr8zbd0c.js";import"./firebase-vendor-D3UzkAhn.js";function F(){const n=N(()=>g.connectDispatches({status:"delivered",limit:100}),[]),{toast:y}=C(),[i,f]=l.useState(""),[c,p]=l.useState(null),[s,m]=l.useState(null),[b,x]=l.useState(!1),d=l.useMemo(()=>{var o;const r=((o=n.data)==null?void 0:o.dispatches)||[],a=i.trim().toLowerCase();return a?r.filter(t=>`${t.origin} ${t.destination} ${t.nfeNumber||""} ${t.shipperName||""}`.toLowerCase().includes(a)):r},[n.data,i]),j=async r=>{p(r),x(!0),m(null);try{m(await g.connectPod(r))}catch(a){y({title:(a==null?void 0:a.message)||"POD indisponÃvel para esta viagem",kind:"error"}),p(null)}finally{x(!1)}};return e.jsx(k,{icon:w,title:"Comprovantes de entrega",subtitle:"O canhoto digital que você entregou ao embarcador â buscável, com leitura por IA",right:e.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-2.5 py-1.5",style:{background:"var(--surface-secondary)",border:"1px solid var(--border-primary)"},children:[e.jsx($,{size:14,style:{color:"var(--page-text-secondary)"}}),e.jsx("input",{value:i,onChange:r=>f(r.target.value),placeholder:"Buscar por rota, NF, embarcador",className:"text-sm bg-transparent outline-none w-56",style:{color:"var(--page-text)"}})]}),children:n.loading&&!n.data?e.jsx(u,{}):e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[400px_1fr] gap-4",children:[e.jsxs("div",{className:"space-y-2 max-h-[580px] overflow-y-auto pr-1",children:[e.jsxs("p",{className:"text-xs font-semibold uppercase tracking-wide",style:{color:"var(--page-text-secondary)"},children:["Entregas (",d.length,")"]}),d.length===0&&e.jsx(h,{text:"Nenhuma entrega encontrada."}),d.map(r=>e.jsxs("button",{onClick:()=>j(r.id),className:`w-full text-left rounded-lg border p-3 text-sm transition-colors ${c===r.id?"shadow-sm":"hover-surface"}`,style:{borderColor:c===r.id?"#10B98140":"var(--border-primary)",background:c===r.id?"#10B98110":"var(--surface-secondary)"},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("span",{className:"font-semibold truncate",style:{color:"var(--page-text)"},children:[r.origin," â ",r.destination]}),r.hasPod?e.jsx(P,{size:14,className:"shrink-0",style:{color:"#10B981"}}):e.jsx("span",{className:"text-[10px] font-bold shrink-0",style:{color:"#F59E0B"},children:"SEM POD"})]}),e.jsxs("p",{className:"text-xs mt-0.5",style:{color:"var(--page-text-secondary)"},children:[r.shipperName||"â",r.nfeNumber?` · NF ${r.nfeNumber}`:""," · ",v(r.arrivedAt)]})]},r.id))]}),e.jsxs("div",{className:"rounded-xl border p-4 min-h-[320px]",style:{borderColor:"var(--border-primary)",background:"var(--surface-secondary)"},children:[!c&&e.jsx(h,{text:"Selecione uma entrega para ver o comprovante."}),b&&e.jsx(u,{}),s&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-semibold",style:{color:"var(--page-text)"},children:["Recebido por ",s.receiverName||"â",s.receiverRelation?` (${s.receiverRelation})`:""]}),e.jsxs("p",{className:"text-xs",style:{color:"var(--page-text-secondary)"},children:[s.shipperName||""," · ",v(s.deliveredAt),s.driverName?` · ${s.driverName}`:""]})]}),[["Canhoto",s.photosCanhoto],["Carga",s.photosCargo],["Extras",s.photosExtra]].filter(([,r])=>r==null?void 0:r.length).map(([r,a])=>e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide mb-1.5",style:{color:"var(--page-text-secondary)"},children:r}),e.jsx("div",{className:"flex flex-wrap gap-2",children:a.map((o,t)=>e.jsx("a",{href:o,target:"_blank",rel:"noreferrer",children:e.jsx("img",{src:o,alt:`${r} ${t+1}`,loading:"lazy",className:"w-24 h-24 object-cover rounded-lg border",style:{borderColor:"var(--border-primary)"}})},t))})]},r)),s.ocr&&e.jsxs("div",{className:"rounded-lg p-3 text-xs",style:{background:"#10B98112",color:"var(--page-text-secondary)"},children:[e.jsx("strong",{style:{color:"#10B981"},children:"Leitura automática (IA): "}),typeof s.ocr=="string"?s.ocr:JSON.stringify(s.ocr)]}),s.notes&&e.jsxs("p",{className:"text-xs",style:{color:"var(--page-text-secondary)"},children:["Obs.: ",s.notes]})]})]})]})})}export{F 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.