1import{r as i,j as r,M as j,T as y,C as k,f as b}from"./react-vendor-pafHdoJx.js";import"./map-vendor-Dr8zbd0c.js";import{b as N,d as C}from"./index-Db0fDLGN.js";import{C as B}from"./shared-DWiYwVXx.js";import{a8 as M,o as E}from"./ui-vendor-DLXJn6s3.js";import{L as S,E as w,S as P,f as h,R as l}from"./shared-DHvo53EK.js";import"./firebase-vendor-D3UzkAhn.js";function I(){var d;const t=N(()=>C.connectLive(),[]),[n,u]=i.useState("all"),[c,g]=i.useState("all");i.useEffect(()=>{const e=setInterval(()=>t.silentRefetch(),3e4);return()=>clearInterval(e)},[]);const a=((d=t.data)==null?void 0:d.trips)||[],f=i.useMemo(()=>[...new Set(a.map(e=>e.shipperName).filter(Boolean))],[a]),p=a.filter(e=>(n==="all"||e.shipperName===n)&&(c==="all"||e.riskBucket===c)),o=p.filter(e=>e.position),v=o.length?[o[0].position.lat,o[0].position.lng]:[-15.78,-47.93];return r.jsx(B,{icon:M,title:"Mapa vivo",subtitle:"A sua frota em tempo real â a mesma posição que o embarcador vê na torre dele",right:r.jsxs("div",{className:"flex items-center gap-1.5",children:[["all","ok","risk","late"].map(e=>r.jsx("button",{onClick:()=>g(e),className:"text-[11px] px-2 py-1 rounded-full font-medium",style:c===e?{background:e==="all"?"#10B981":l[e].color,color:"#fff"}:{background:"var(--surface-secondary)",color:"var(--page-text-secondary)",border:"1px solid var(--border-primary)"},children:e==="all"?`Todas (${a.length})`:`${l[e].label} (${a.filter(s=>s.riskBucket===e).length})`},e)),r.jsxs("select",{value:n,onChange:e=>u(e.target.value),className:"text-[11px] rounded-lg px-2 py-1 ml-1",style:{background:"var(--surface-secondary)",color:"var(--page-text)",border:"1px solid var(--border-primary)"},"aria-label":"Filtrar por embarcador",children:[r.jsx("option",{value:"all",children:"Todos embarcadores"}),f.map(e=>r.jsx("option",{value:e,children:e},e))]})]}),children:t.loading&&!t.data?r.jsx(S,{}):r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[340px_1fr] gap-4",children:[r.jsxs("div",{className:"space-y-2 max-h-[600px] overflow-y-auto pr-1",children:[p.length===0&&r.jsx(w,{text:"Nenhuma viagem em trânsito com esse filtro."}),p.map(e=>{var s;return r.jsxs("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--border-primary)",background:"var(--surface-secondary)"},children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("span",{className:"font-semibold truncate",style:{color:"var(--page-text)"},children:[e.origin," â ",e.destination]}),((s=e.position)==null?void 0:s.stale)&&r.jsx(E,{size:13,className:"shrink-0",style:{color:"#F59E0B"}})]}),r.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-[11px]",style:{color:"var(--page-text-secondary)"},children:[r.jsx(P,{kind:"risk",label:e.riskBucket}),r.jsx("span",{children:e.shipperName||"â"}),e.position?r.jsxs("span",{children:["· ",e.position.speedKmh," km/h · ETA ",h(e.etaMinutes)]}):r.jsx("span",{children:"· sem posição (app fechado?)"})]}),e.driverName&&r.jsxs("p",{className:"text-[11px] mt-0.5",style:{color:"var(--page-text-secondary)"},children:[e.driverName,e.vehiclePlate?` · ${e.vehiclePlate}`:""]})]},e.id)})]}),r.jsx("div",{className:"rounded-xl overflow-hidden border",style:{borderColor:"var(--border-primary)",minHeight:600},children:r.jsxs(j,{center:v,zoom:o.length?5:4,style:{height:600,width:"100%"},children:[r.jsx(y,{url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",attribution:"© OpenStreetMap"}),o.map(e=>{var m,x;const s=((m=l[e.riskBucket])==null?void 0:m.color)||"#10B981";return r.jsx(k,{center:[e.position.lat,e.position.lng],radius:9,pathOptions:{color:s,fillColor:s,fillOpacity:.85},children:r.jsxs(b,{children:[r.jsxs("strong",{children:[e.origin," â ",e.destination]}),r.jsx("br",{}),e.shipperName||""," · ",(x=l[e.riskBucket])==null?void 0:x.label,r.jsx("br",{}),e.driverName||""," · ",e.position.speedKmh," km/h",r.jsx("br",{}),"ETA ",h(e.etaMinutes),e.scheduledDate?` · janela ${new Date(e.scheduledDate).toLocaleDateString("pt-BR")}`:""]})},e.id)})]})})]})})}export{I 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.