PageSourceSearch

https://sentinel-365-c9d4f.web.app/assets/ExtrattaPages-DFiYn7hQ.js

js sentinel-365-c9d4f.web.app collected 2026-10-03 12:38:36 UTC 42,025 bytes, 1 lines download raw bytes

1import{r as g,j as e}from"./react-vendor-pafHdoJx.js";import{u as A,d as N,j as q,b as T,C as _}from"./index-Db0fDLGN.js";import{t as V,r as F}from"./errors-SShhAJmM.js";import{E as R}from"./ErrorState-B9i6eo2M.js";import{X as B,al as M,L as y,I as z,cE as S,l as L,as as I,aS as U,aE as J,aa as $,bk as X,an as H,p as K,F as Q,aC as P}from"./ui-vendor-DLXJn6s3.js";import"./map-vendor-Dr8zbd0c.js";import"./firebase-vendor-D3UzkAhn.js";function G({ciot:t,onClose:l,onSuccess:a}){const{toast:s}=A(),[o,c]=g.useState(""),[x,d]=g.useState(""),[m,r]=g.useState(""),[u,n]=g.useState(!1),i=g.useMemo(()=>W(t),[t.tipoCiot,t.dataInicioViagem,t.dataFimViagem,t.emitidoEm]),p=async()=>{var j;if(i.bloqueado)return;const v={};if(o){const f=Number(o);if(!Number.isFinite(f)||f<=0){s({title:"Valor do frete inválido (deve ser > 0)",kind:"error"});return}v.ValorFrete=f}if(x&&(v.DataInicioViagem=new Date(x).toISOString()),m&&(v.DataFimViagem=new Date(m).toISOString()),Object.keys(v).length===0){s({title:"Informe ao menos um campo pra retificar",kind:"error"});return}n(!0);try{const f=await N.anttRetificarCiot({ciot:t.ciot,verificador:t.verificador,updates:v});f!=null&&f.sucesso?(s({title:"CIOT retificado na ANTT",kind:"success"}),a()):s({title:`Falha: ${((j=f==null?void 0:f.erro)==null?void 0:j.message)||"erro"}`,kind:"error"})}catch(f){s({title:(f==null?void 0:f.message)||"Erro ao retificar",kind:"error"})}finally{n(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-[1100] bg-black/50",onClick:l}),e.jsxs("div",{className:"fixed top-[5vh] left-1/2 -translate-x-1/2 max-h-[90vh] rounded-2xl shadow-2xl z-[1101] flex flex-col",style:{width:"min(560px, 94vw)",background:"var(--page-bg)",border:"1px solid var(--border-primary)"},children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",style:{borderColor:"var(--border-primary)"},children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--page-text)"},children:"Retificar CIOT"}),e.jsxs("p",{className:"text-xs font-mono mt-0.5",style:{color:"var(--page-text-muted)"},children:[t.ciot,"-",t.verificador]})]}),e.jsx("button",{onClick:l,className:"text-gray-400 hover:text-gray-600",children:e.jsx(B,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"p-5 space-y-4 overflow-y-auto",children:i.bloqueado?e.jsxs("div",{className:"rounded-lg p-3 flex items-start gap-2 text-sm",style:{background:"#fef2f2",color:"#dc2626",border:"1px solid #fecaca"},children:[e.jsx(M,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold mb-0.5",children:"Retificação bloqueada pela regulação"}),e.jsx("p",{className:"text-xs",children:i.motivo})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-lg p-2.5 text-xs",style:{background:"#fef3c7",color:"#92400e"},children:[e.jsx("p",{className:"font-medium",children:"⚠ Restrições R7 (MP 1.343/2026)"}),e.jsx("p",{className:"mt-0.5",children:"Placa, motorista, proprietário e composição veicular NÃO podem ser retificados após emissão. Para essas mudanças, cancele e re-emita."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",style:{color:"var(--page-text-secondary)"},children:"Novo valor do frete (R$)"}),e.jsx("input",{type:"number",className:"input",step:"0.01",min:"0",placeholder:"Ex: 5500.00",value:o,onChange:v=>c(v.target.value)}),e.jsx("p",{className:"text-[10px] mt-0.5",style:{color:"var(--page-text-muted)"},children:"Deixe vazio pra não alterar."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",style:{color:"var(--page-text-secondary)"},children:"Nova data de início"}),e.jsx("input",{type:"datetime-local",className:"input",value:x,onChange:v=>d(v.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",style:{color:"var(--page-text-secondary)"},children:"Nova data de término"}),e.jsx("input",{type:"datetime-local",className:"input",value:m,onChange:v=>r(v.target.value)})]})]}),i.aviso&&e.jsxs("div",{className:"rounded-lg p-2 text-[11px]",style:{background:"var(--surface-secondary)",color:"var(--page-text-secondary)"}
1,children:["ℹ ",i.aviso]})]})}),e.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t",style:{borderColor:"var(--border-primary)"},children:[e.jsx("button",{onClick:l,className:"btn-secondary text-sm",children:"Cancelar"}),!i.bloqueado&&e.jsxs("button",{onClick:p,disabled:u,className:"btn-primary text-sm flex items-center gap-2",children:[u&&e.jsx(y,{className:"w-4 h-4 animate-spin"}),"Retificar na ANTT"]})]})]})]})}function W(t){const l=t.tipoCiot;if(l==="lotacao")return{bloqueado:!0,motivo:"R6: operação Lotação não pode ser retificada após emissão do CIOT. Para alterar, cancele dentro da janela R1 (24h antes do início) e re-emita."};const a=Date.now(),s=864e5;if(l==="fracionada"){const o=t.emitidoEm?t.emitidoEm._seconds?t.emitidoEm._seconds*1e3:new Date(t.emitidoEm).getTime():NaN;if(!isNaN(o)){const c=(a-o)/s;return c>5?{bloqueado:!0,motivo:`R10: Fracionada só retifica até 5d pós-emissão. Decorridos: ${c.toFixed(1)}d.`}:{bloqueado:!1,aviso:`R10: faltam ${(5-c).toFixed(1)}d até o limite (5d pós-emissão).`}}}if(l==="tac_agregado"){const o=t.dataFimViagem?new Date(t.dataFimViagem).getTime():NaN;if(!isNaN(o)){const c=(a-o)/s;return c>30?{bloqueado:!0,motivo:`R5: TAC-Agregado só retifica até 30d pós-término. Decorridos: ${c.toFixed(1)}d.`}:{bloqueado:!1,aviso:`R5: ${c<0?"antes do término":`${c.toFixed(0)}d pós-término`} — limite 30d.`}}}return{bloqueado:!1}}const Y={lotacao:1,fracionada:2,tac_agregado:3};function Z({ciot:t,onChanged:l}){const{toast:a}=A(),{confirmar:s}=q(),[o,c]=g.useState(null),[x,d]=g.useState(!1),[m,r]=g.useState(null),u=t.status==="cancelado",n=t.status==="encerrado",i=g.useMemo(()=>ee(t),[t.dataInicioViagem,t.emitidoEm,t.tipoCiot]),p=async()=>{var b;if(!i.podeCancelar){a({title:`Fora da janela legal: ${i.motivoBloqueio||"cancelamento não permitido"}`,kind:"error"});return}const f=prompt("Motivo do cancelamento (mínimo 5 caracteres):");if(!(!f||f.trim().length<5)){c("cancelar");try{const C=await N.anttCancelarCiot({ciot:t.ciot,verificador:t.verificador,motivo:f.trim(),dataInicioViagem:t.dataInicioViagem||void 0,tipoOperacao:t.tipoCiot?Y[t.tipoCiot]:void 0});C!=null&&C.sucesso?(a({title:"CIOT cancelado com sucesso na ANTT",kind:"success"}),l==null||l()):a({title:`Falha: ${((b=C==null?void 0:C.erro)==null?void 0:b.message)||"erro desconhecido"}`,kind:"error"})}catch(C){a({title:(C==null?void 0:C.message)||"Erro ao cancelar",kind:"error"})}finally{c(null)}}},v=async()=>{var f;if(!i.podeEncerrar){a({title:`Fora da janela legal: ${i.motivoBloqueioEncerrar||"encerramento não permitido"}`,kind:"error"});return}if(await s({titulo:"Encerrar este CIOT na ANTT?",descricao:"Esta ação é definitiva.",confirmar:"Encerrar"})){c("encerrar");try{const b=await N.anttEncerrarCiot({ciot:t.ciot,verificador:t.verificador});b!=null&&b.sucesso?(a({title:"CIOT encerrado na ANTT",kind:"success"}),l==null||l()):a({title:`Falha: ${((f=b==null?void 0:b.erro)==null?void 0:f.message)||"erro"}`,kind:"error"})}catch(b){a({title:(b==null?void 0:b.message)||"Erro ao encerrar",kind:"error"})}finally{c(null)}}},j=async()=>{c("consultar");try{const f=await N.anttConsultarCiot(t.ciot,t.verificador);r(f)}catch(f){a({title:(f==null?void 0:f.message)||"Erro ao consultar",kind:"error"})}finally{c(null)}};return e.jsxs("div",{className:"space-y-3 pt-3 border-t",style:{borderColor:"var(--border-primary)"},children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"var(--page-text-muted)"},children:"Ações ANTT direta"}),(u||n)&&e.jsxs("div",{className:"rounded-lg p-2 text-xs flex items-center gap-2",style:{background:"var(--surface-secondary)",color:"var(--page-text-muted)"},children:[e.jsx(z,{className:"w-3.5 h-3.5"}),"CIOT ",u?"cancelado":"encerrado"," — só ações de leitura disponíveis."]}),!u&&!n&&e.jsxs("div",{className:"space-y-1.5 text-xs",children:[i.cancelarLabel&&e.jsxs("div",{className:"flex items-center gap-1.5",style:{color:i.podeCancelar?"#059669":"#dc2626"},children:[i.podeCancelar?e.jsx(S,{className:"w-3 h-3"}):e.jsx(L,{className:"w-3 h-3"}),i.cancelarLabel]}),i.encerrarLabel&&e.jsxs("div",{className:"flex items-center gap-1.5",style:{color:i.podeEncerrar?"#059669":"#dc2626"},children:[i.podeEncerrar?e.jsx(S,{className:"w-3 h-3"}):e.jsx(L,{className:"w-3 h-3"}),i.encerrarLabel]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs("button",{onClick:j,disabled:o!==null,className:"btn-secondary text-xs flex items-center gap-1.5",children:[o==="consultar"?e.jsx(y,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(I,{className:"w-3.5 h-3.5"}),"Consultar status ANTT"]}),!u&&!n&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>d(!0),disabled:o!==null,className:"btn-secondary text-xs flex items-center gap-1.5",title:i.retificarHint,children:[e.jsx(U,{className:"w-3.5 h-3.5"})," Retificar"]}),e.jsxs("button",{onClick:v,disabled:o!==null||!i.podeEncerrar,className:"btn-secondary text-xs flex items-center gap-1.5",style:i.podeEncerrar?void 0:{opacity:.5,cursor:"not-allowed"},children:[o==="encerrar"?e.jsx(y,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(S,{className:"w-3.5 h-3.5"}),"Encerrar"]}),e.jsxs("button",{onClick:p,disabled:o!==null||!i.podeCancelar,className:"btn-danger text-xs flex items-center gap-1.5",style:i.podeCancelar?void 0:{opacity:.5,cursor:"not-allowed"}
1,children:[o==="cancelar"?e.jsx(y,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(J,{className:"w-3.5 h-3.5"}),"Cancelar"]})]})]}),m&&e.jsxs("details",{className:"rounded-lg p-2 text-xs",style:{background:"var(--surface-secondary)"},children:[e.jsx("summary",{className:"cursor-pointer font-medium",style:{color:"var(--page-text)"},children:"Resposta da ANTT (raw)"}),e.jsx("pre",{className:"mt-2 overflow-auto max-h-60 text-[10px] font-mono",style:{color:"var(--page-text-muted)"},children:JSON.stringify(m,null,2)})]}),x&&e.jsx(G,{ciot:t,onClose:()=>d(!1),onSuccess:()=>{d(!1),l==null||l()}})]})}function ee(t){const l=t.tipoCiot,a=t.dataInicioViagem?new Date(t.dataInicioViagem).getTime():NaN,s=Date.now(),o=36e5,c=864e5;let x=!0,d,m;if(l==="tac_agregado")d="TAC-Agregado: cancelamento até 5d pós-emissão";else if(!isNaN(a)){const p=(a-s)/o;p>=24?d=`Cancelar permitido (faltam ${p.toFixed(0)}h pro início — janela 24h)`:(x=!1,m=`Início em ${p.toFixed(1)}h — R1 exige ≥24h de antecedência`,d=m)}let r=!0,u,n;if(l==="tac_agregado"&&!isNaN(a)){const p=(s-a)/c;p>=10?u=`Encerrar permitido (${p.toFixed(0)}d desde início)`:(r=!1,n=`Decorridos ${p.toFixed(1)}d — R11 exige ≥10d`,u=n)}return{podeCancelar:x,cancelarLabel:d,motivoBloqueio:m,podeEncerrar:r,encerrarLabel:u,motivoBloqueioEncerrar:n,retificarHint:l==="lotacao"?"R6: Lotação NÃO pode ser retificada após emissão":l==="fracionada"?"R10: Fracionada até 5d pós-emissão. R7: veículo não muda":"R5: TAC-Agregado até 30d pós-término. R7: veículo não muda"}}function E({feature:t}){return e.jsxs("div",{className:"rounded-xl p-8 text-center",style:{background:"var(--surface-secondary)",border:"1px dashed var(--border-primary)"},children:[e.jsx(M,{className:"w-10 h-10 mx-auto mb-3",style:{color:"var(--page-text-muted)"}}),e.jsx("h3",{className:"text-base font-semibold mb-1",style:{color:"var(--page-text)"},children:t}),e.jsx("p",{className:"text-sm mb-4",style:{color:"var(--page-text-muted)"},children:"Este módulo precisa ser habilitado pelo administrador da plataforma antes de você poder usá-lo."}),e.jsx("a",{href:"/configuracoes?tab=integracoes",className:"text-xs font-semibold",style:{color:"var(--accent-brand)"},children:"Abrir configurações do administrador →"})]})}function k(){return e.jsx("div",{className:"flex justify-center py-10",children:e.jsx(y,{className:"w-6 h-6 animate-spin",style:{color:"var(--page-text-muted)"}})})}function O(t){return Number(t||0).toLocaleString("pt-BR",{style:"currency",currency:"BRL"})}function w(){const{data:t,loading:l,error:a,refetch:s}=T(()=>N.extrattaConfig(),[]);return{configured:!!(t!=null&&t.configured),loading:l,error:a,refetch:s}}function pe(){var v,j,f,b,C,D;const{configured:t,loading:l,error:a,refetch:s}=w(),{data:o,loading:c,refetch:x}=T(()=>N.extrattaListarCiots(),[]),[d,m]=g.useState(null),[r,u]=g.useState("all");if(l)return e.jsx(k,{});if(a)return e.jsx(R,{error:a,onRetry:s,title:"Não foi possível verificar a integração Extratta"});if(!t)return e.jsx(E,{feature:"Pagamento de frete"});if(c)return e.jsx(k,{});const n=(o==null?void 0:o.ciots)||[],i=r==="all"?n:n.filter(h=>(h.channel||"extratta")===r),p=(o==null?void 0:o.stats)||{total:0,tacAgregado:0,contingencia:0,fiscalizados:0,porCanal:{antt_direct:0,extratta:0}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--page-text)"},children:"Pagamento de Frete"}),e.jsx("p",{className:"text-sm",style:{color:"var(--page-text-muted)"},children:"CIOTs emitidos — adiantamento, saldo, estadia, retenções"})]}),e.jsxs("button",{onClick:x,className:"btn-secondary text-xs flex items-center gap-1.5",children:[e.jsx(I,{className:"w-3.5 h-3.5"})," Atualizar"]})]}),p.total>0&&e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"card p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider",style:{color:"var(--page-text-muted)"},children:"Total CIOTs (últimos 50)"}),e.jsx("p",{className:"text-xl font-bold mt-1",style:{color:"var(--page-text)"},children:p.total}),(((v=p.porCanal)==null?void 0:v.antt_direct)>0||((j=p.porCanal)==null?void 0:j.extratta)>0)&&e.jsxs("p",{className:"text-[10px] mt-1",style:{color:"var(--page-text-muted)"},children:[e.jsxs("span",{style:{color:"#10B981"},children:["● ",((f=p.porCanal)==null?void 0:f.antt_direct)||0," ANTT"]})," · ",e.jsxs("span",{style:{color:"#3B82F6"},children:["● ",((b=p.porCanal)==null?void 0:b.extratta)||0," Extratta"]})]})]}),e.jsxs("div",{className:"card p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider",style:{color:"var(--page-text-muted)"},children:"TAC Agregado"}),e.jsx("p",{className:"text-xl font-bold mt-1",style:{color:"#7C3AED"},children:p.tacAgregado})]}),e.jsxs("div",{className:"card p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider",style:{color:"var(--page-text-muted)"},children:"Em contingência"}),e.jsx("p",{className:"text-xl font-bold mt-1",style:{color:p.contingencia>0?"#D97706":"var(--page-text)"},children:p.contingencia})]}),e.jsxs("div",{className:"card p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider",style:{color:"var(--page-text-muted)"},children:"Fiscalizados ANTT"}),e.jsx("p",{className:"text-xl font-bold mt-1",style:{color:"#0EA5E9"},children:p.fiscalizados})]})]}),p.total>0&&(((C=p.porCanal)==null?void 0:C.antt_direct)>0||((D=p.porCanal)==null?void 0:D.extratta)>0)&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{style:{color:"var(--page-text-muted)"},children:"Filtrar canal:"}),["all","antt_direct","extratta"].map(h=>e.jsx("button",{onClick:()=>u(h),className:"px-2.5 py-1 rounded-full transition-all",style:{background:r===h?"var(--accent-brand)":"var(--surface-secondary)",color:r===h?"#fff":"var(--page-text-secondary)",fontWeight:r===h?600:400},children:h==="all"?"Todos":h==="antt_direct"?"🟢 ANTT direta":"🔵 Extratta"},h))]}),i.length===0?e.jsx("div",{className:"card p-8 text-center text-sm",style:{color:"var(--page-text-muted)"},children:"Nenhum CIOT emitido pela sua organização ainda. Ao emitir um CIOT a partir de um despacho, ele aparece aqui automaticamente."}):e.jsx("div",{className:"card divide-y",style:{borderColor:"var(--border-primary)"},children:i.map(h=>e.jsxs("button",{onClick:()=>m(h),className:"w-full flex items-center justify-between p-4 hover-surface text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(X,{className:"w-5 h-5",style:{color:h.channel==="antt_direct"?"#10B981":"#3B82F6"}}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-mono font-semibold",style:{color:"var(--page-text)"},children:h.ciot}),e.jsx("span",{className:"text-[10px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:h.channel==="antt_direct"?"#ecfdf5":"#eff6ff",color:h.channel==="antt_direct"?"#059669":"#1d4ed8"},title:h.channel==="antt_direct"?"Emitido direto na ANTT (gratuito)":"Emitido via Extratta (IPEF)",children:h.channel==="antt_direct"?"ANTT":"EXTRATTA"}),h.status&&h.status!=="emitido"&&e.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:h.status==="cancelado"?"#fef2f2":"#f3f4f6",color:h.status==="cancelado"?"#dc2626":"#6b7280"},children:h.status})]}),e.jsxs("p",{className:"text-xs",style:{color:"var(--page-text-muted)"},children:[h.tipoCiot==="tac_agregado"?"TAC Agregado":h.tipoCiot==="fracionada"?"Fracionada":"Lotação",h.emContingencia&&" · contingência",h.consultadoPelaFiscalizacao&&" · fiscalizado"]})]})]}),e.jsx("span",{className:"text-xs",style:{color:"var(--page-text-muted)"},children:h.dataDeclaracao?new Date(h.dataDeclaracao).toLocaleDateString("pt-BR"):"—"})]}
1,h.id))}),d&&e.jsx(ae,{ciot:d,onClose:()=>m(null),onChanged:()=>{x(),m(null)}})]})}function ae({ciot:t,onClose:l,onChanged:a}){const[s,o]=g.useState(null),[c,x]=g.useState(!0),d=t.channel==="antt_direct";return g.useEffect(()=>{if(d){x(!1);return}(async()=>{try{const m=await N.extrattaConsultarViagem(t.idViagemExtratta);o((m==null?void 0:m.Objeto)??m)}catch{o(null)}finally{x(!1)}})()},[t.idViagemExtratta,d]),e.jsx("div",{className:"fixed inset-0 bg-black/60 z-50 flex justify-end",onClick:m=>m.target===m.currentTarget&&l(),children:e.jsxs("div",{className:"w-full max-w-xl h-full overflow-y-auto shadow-2xl",style:{background:"var(--page-bg)"},children:[e.jsxs("div",{className:"p-5 flex items-center justify-between",style:{borderBottom:"1px solid var(--border-primary)"},children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-mono font-bold",style:{color:"var(--page-text)"},children:t.ciot}),e.jsxs("p",{className:"text-xs",style:{color:"var(--page-text-muted)"},children:["Verificador ",t.verificador]})]}),e.jsx("button",{onClick:l,children:e.jsx(B,{className:"w-5 h-5",style:{color:"var(--page-text-muted)"}})})]}),c?e.jsx(k,{}):e.jsxs("div",{className:"p-5 space-y-4",children:[t.avisoTransportador&&e.jsxs("div",{className:"rounded-lg p-3 text-xs",style:{background:"#fef3c7",color:"#92400e"},children:[e.jsx("strong",{children:"Aviso ANTT:"})," ",t.avisoTransportador]}),d?e.jsx(Z,{ciot:t,onChanged:a}):e.jsxs(e.Fragment,{children:[e.jsx(te,{eventos:(s==null?void 0:s.Eventos)||[],idViagem:t.idViagemExtratta}),e.jsx(re,{ciot:t})]})]})]})})}function te({eventos:t,idViagem:l}){return t!=null&&t.length?e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"var(--page-text-muted)"},children:"Parcelas do frete"}),t.map(a=>e.jsx(se,{evento:a,idViagem:l},a.IdViagemEvento))]}):e.jsx("p",{className:"text-xs text-center py-4",style:{color:"var(--page-text-muted)"},children:"Sem parcelas registradas."})}function se({evento:t,idViagem:l}){const{toast:a}=A(),[s,o]=g.useState(!1),[c,x]=g.useState(null),d=["Adiantamento","Saldo","Estadia","RPA","Tarifa ANTT","Abastecimento","Abono"][t.TipoEventoViagem]||"Parcela",m=["Aberto","Bloqueado","Baixado","Cancelado"][t.Status]||"Aberto",r=()=>x("baixar"),u=()=>x("cancelar"),n=async()=>{if(c){o(!0);try{c==="baixar"?await N.extrattaBaixarEvento(l,t.IdViagemEvento):await N.extrattaCancelarEvento(l,t.IdViagemEvento),a({title:c==="baixar"?`Parcela ${d} marcada como paga`:`Parcela ${d} cancelada`,kind:"success"}),window.location.reload()}catch(i){F(i,(p,v)=>a({title:p,description:v,kind:"error"}))}finally{o(!1)}}};return e.jsxs("div",{className:"rounded-lg p-3 flex items-center justify-between",style:{background:"var(--surface-secondary)"},children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--page-text)"},children:d}),e.jsxs("p",{className:"text-xs",style:{color:"var(--page-text-muted)"},children:[O(t.ValorPagamento)," · ",m]})]}),t.Status===0&&e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("button",{onClick:r,disabled:s,className:"btn-primary text-xs px-3 py-1.5",children:"Marcar paga"}),e.jsx("button",{onClick:u,disabled:s,className:"btn-danger text-xs px-3 py-1.5",children:"Cancelar"})]}),e.jsx(_,{open:c!==null,onClose:()=>x(null),title:c==="cancelar"?`Cancelar parcela ${d}?`:`Marcar parcela ${d} como paga?`,description:`${O(t.ValorPagamento)} · a operação é enviada à Extratta e registrada no CIOT.`,confirmLabel:c==="cancelar"?"Cancelar parcela":"Marcar paga",onConfirm:n})]})}function re({ciot:t}){const l=t.urlsRecibos||{};return e.jsxs("div",{className:"pt-3 border-t",style:{borderColor:"var(--border-primary)"},children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"var(--page-text-muted)"},children:"Documentos"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs("a",{href:l.declaracao||`/api/extratta/ciot/${t.idViagemExtratta}`,target:"_blank",rel:"noreferrer",className:"btn-secondary text-xs flex items-center gap-1.5",children:[e.jsx(P,{className:"w-3.5 h-3.5"})," Declaração CIOT"]}),l.pef&&e.jsxs("a",{href:l.pef,target:"_blank",rel:"noreferrer",className:"btn-secondary text-xs flex items-center gap-1.5",title:"Comprovante de Pagamento 
1Eletrônico de Frete (Lei 13.703 art 5º-A §3)",children:[e.jsx(P,{className:"w-3.5 h-3.5"})," Recibo PEF"]}),l.vpo&&e.jsxs("a",{href:l.vpo,target:"_blank",rel:"noreferrer",className:"btn-secondary text-xs flex items-center gap-1.5",title:"Recibo Vale-Pedágio Obrigatório (Lei 10.209/2001)",children:[e.jsx(P,{className:"w-3.5 h-3.5"})," Recibo VPO"]})]})]})}const oe=[{id:"sem_parar",label:"Sem Parar"},{id:"move_mais",label:"Move Mais"},{id:"veloe",label:"Veloe"},{id:"tag_extratta",label:"Tag Extratta"},{id:"conectcar",label:"ConectCar"},{id:"taggy",label:"Taggy Edenred"}];function ge(){const{configured:t,loading:l,error:a,refetch:s}=w(),[o,c]=g.useState(""),[x,d]=g.useState("sem_parar"),[m,r]=g.useState(null),[u,n]=g.useState(!1),[i,p]=g.useState(null);if(l)return e.jsx(k,{});if(a)return e.jsx(R,{error:a,onRetry:s,title:"Não foi possível verificar a integração Extratta"});if(!t)return e.jsx(E,{feature:"Vale-pedágio"});const v=async()=>{if(o.trim()){n(!0),p(null),r(null);try{const j=await N.extrattaConsultarTag(o.trim().toUpperCase(),x);r(j)}catch(j){p(j.message||"Erro ao consultar")}finally{n(!1)}}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--page-text)"},children:"Vale-Pedágio"}),e.jsx("p",{className:"text-sm",style:{color:"var(--page-text-muted)"},children:"Status de tag por placa · 6 fornecedores suportados"})]}),e.jsxs("div",{className:"card p-5 space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--page-text)"},children:"Consultar tag"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label text-xs block mb-1",children:"Placa"}),e.jsx("input",{className:"input",placeholder:"ABC1D23",value:o,onChange:j=>c(j.target.value.toUpperCase()),style:{textTransform:"uppercase"}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label text-xs block mb-1",children:"Fornecedor"}),e.jsx("select",{className:"input",value:x,onChange:j=>d(j.target.value),children:oe.map(j=>e.jsx("option",{value:j.id,children:j.label},j.id))})]}),e.jsx("div",{className:"flex items-end",children:e.jsxs("button",{onClick:v,disabled:u||!o.trim(),className:"btn-primary w-full flex items-center justify-center gap-2",children:[u?e.jsx(y,{className:"w-4 h-4 animate-spin"}):e.jsx(H,{className:"w-4 h-4"})," ","Consultar"]})})]}),i&&e.jsx("div",{className:"rounded-lg p-3 text-sm",style:{background:"#fef2f2",color:"#dc2626"},children:i}),m&&e.jsx("pre",{className:"rounded-lg p-3 text-xs overflow-auto max-h-64 font-mono",style:{background:"var(--surface-tertiary)",color:"var(--page-text)"},children:JSON.stringify(m,null,2)})]}),e.jsxs("div",{className:"rounded-xl p-4 text-xs",style:{background:"#eff6ff",border:"1px solid #bfdbfe",color:"#1e40af"},children:[e.jsx("strong",{children:"Como usar:"})," a compra de vale-pedágio acontece automaticamente quando você emite um CIOT com fornecedor de pedágio selecionado no despacho. Esta tela serve pra verificar status de tag existente ou diagnosticar problemas."]})]})}function fe(){const{configured:t,loading:l}=w(),{data:a,loading:s,error:o,refetch:c}=T(()=>N.extrattaListarCiots(),[]),{toast:x}=A(),[d,m]=g.useState(null);if(l)return e.jsx(k,{});if(!t)return e.jsx(E,{feature:"Contratos TAC Agregado"});if(s)return e.jsx(k,{});if(o)return e.jsx(R,{error:o,onRetry:c,title:"Não foi possível carregar os contratos TAC Agregado"});const r=((a==null?void 0:a.ciots)||[]).filter(i=>i.tipoCiot==="tac_agregado"),u=i=>m(i),n=async()=>{if(d)try{await N.extrattaEncerrarAgregado(d),x({title:`Contrato ${d} encerrado`,kind:"success"}),c()}catch(i){F(i,(p,v)=>x({title:p,description:v,kind:"error"}))}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--page-text)"},children:"Contratos TAC Agregado"}),e.jsx("p",{className:"text-sm",style:{color:"var(--page-text-muted)"},children:"Contratos periódicos ativos com proprietários agregados"})]}),e.jsxs("button",{onClick:c,className:"btn-secondary text-xs flex items-center gap-1.5",children:[e.jsx(I,{className:"w-3.5 h-3.5"})," Atualizar"]})]}),r.length===0?e.jsx("div",{className:"card p-8 text-center text-sm",style:{color:"var(--page-text-muted)"},children:"Nenhum contrato TAC Agregado ativo."}):e.jsx("div",{className:"card divide-y",style:{borderColor:"var(--border-primary)"},children:r.map(i=>e.jsxs("div",{className:"p-4 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-mono font-semibold",style:{color:"var(--page-text)"},children:i.ciot}),e.jsxs("p",{className:"text-xs",style:{color:"var(--page-text-muted)"},children:["Iniciado em"," ",i.dataDeclaracao?new Date(i.dataDeclaracao).toLocaleDateString("pt-BR"):"—",i.cancelado&&" · encerrado"]})]}),!i.cancelado&&e.jsx("button",{onClick:()=>u(i.ciot),className:"btn-danger text-xs",children:"Encerrar"})]},i.id))}),e.jsx(_,{open:!!d,onClose:()=>m(null),title:`Encerrar o contrato TAC Agregado ${d||""}?`,description:"Essa ação é definitiva: o encerramento é enviado à Extratta/ANTT e o contrato não pode ser reaberto.",confirmLabel:"Encerrar contrato",onConfirm:n})]})}const le=[{id:"ticketlog",label:"TicketLog"},{id:"shell_expers",label:"Shell Expers"},{id:"truckpag",label:"Truckpag"}];function he(){const{configured:t,loading:l}=w(),{toast:a}=A(),[s,o]=g.useState({fornecedor:"ticketlog",idViagem:"",placa:"",valor:"",numeroControle:"",codigoProduto:"",numeroCartaoFornecedor:"",dataValidade:"",dataLiberacao:""}),[c,x]=g.useState(!1),[d,m]=g.useState(null);if(l)return e.jsx(k,{});if(!t)return e.jsx(E,{feature:"Abastecimento"});const r=s.fornecedor==="truckpag",u=async()=>
1{if(!s.placa||!s.valor||!s.numeroControle){a({title:"Preencha placa, valor e número de controle.",kind:"warning"});return}if(!r&&!s.codigoProduto){a({title:"Código do produto é obrigatório para TicketLog/Shell.",kind:"warning"});return}x(!0);try{const n=await N.extrattaSolicitarAbastecimento({fornecedor:s.fornecedor,idViagem:s.idViagem?Number(s.idViagem):void 0,placa:s.placa,valor:Number(s.valor),numeroControle:s.numeroControle,codigoProduto:r?void 0:s.codigoProduto,numeroCartaoFornecedor:r?void 0:s.numeroCartaoFornecedor||void 0,dataValidade:r?void 0:s.dataValidade||void 0,dataLiberacao:r?void 0:s.dataLiberacao||void 0});m(n)}catch(n){F(n,(i,p)=>a({title:i,description:p,kind:"error"}))}finally{x(!1)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--page-text)"},children:"Abastecimento"}),e.jsx("p",{className:"text-sm",style:{color:"var(--page-text-muted)"},children:"Solicitação de crédito de combustível atrelado à viagem (TicketLog · Shell Expers · TruckPag)."})]}),e.jsxs("div",{className:"card p-5 space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--page-text)"},children:"Solicitar crédito"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label text-xs block mb-1",children:"Fornecedor"}),e.jsx("select",{className:"input",value:s.fornecedor,onChange:n=>o({...s,fornecedor:n.target.value}),children:le.map(n=>e.jsx("option",{value:n.id,children:n.label},n.id))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label text-xs block mb-1",children:"Placa"}),e.jsx("input",{className:"input",placeholder:"ABC1D23",value:s.placa,onChange:n=>o({...s,placa:n.target.value.toUpperCase()})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label text-xs block mb-1",children:"Valor (R$)"}),e.jsx("input",{type:"number",step:"0.01",className:"input",value:s.valor,onChange:n=>o({...s,valor:n.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label text-xs block mb-1",children:"Nº Controle (TMS)"}),e.jsx("input",{className:"input",value:s.numeroControle,onChange:n=>o({...s,numeroControle:n.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label text-xs block mb-1",children:"IdViagem (opcional)"}),e.jsx("input",{className:"input",placeholder:"Vazio = nova viagem",value:s.idViagem,onChange:n=>o({...s,idViagem:n.target.value})})]}),!r&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"label text-xs block mb-1",children:"Código produto *"}),e.jsx("input",{className:"input",placeholder:"Ex: DIESEL_S10",value:s.codigoProduto,onChange:n=>o({...s,codigoProduto:n.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label text-xs block mb-1",children:"Cartão do fornecedor"}),e.jsx("input",{className:"input",value:s.numeroCartaoFornecedor,onChange:n=>o({...s,numeroCartaoFornecedor:n.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label text-xs block mb-1",children:"Validade"}),e.jsx("input",{type:"date",className:"input",value:s.dataValidade,onChange:n=>o({...s,dataValidade:n.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label text-xs block mb-1",children:"Liberação"}),e.jsx("input",{type:"date",className:"input",value:s.dataLiberacao,onChange:n=>o({...s,dataLiberacao:n.target.value})})]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs("button",{onClick:u,disabled:c,className:"btn-primary flex items-center gap-2",children:[c?e.jsx(y,{className:"w-4 h-4 animate-spin"}):e.jsx(Q,{className:"w-4 h-4"}),"Solicitar crédito"]})})]}),d&&e.jsxs("div",{className:"card p-5",children:[e.jsx("h3",{className:"text-sm font-semibold mb-3",style:{color:"var(--page-text)"},children:"Resposta da Extratta"}),e.jsx("pre",{className:"rounded-lg p-3 text-xs overflow-auto max-h-96 font-mono",style:{background:"var(--surface-tertiary)",color:"var(--page-text)"},children:JSON.stringify(d,null,2)})]}),e.jsxs("div",{className:"rounded-xl p-4 text-xs",style:{background:"#eff6ff",border:"1px solid #bfdbfe",color:"#1e40af"},children:[e.jsx("strong",{children:"Como funciona:"})," O crédito é incluído como evento ",e.jsx("code",{children:"TipoEvento=5"})," em uma viagem (existente ou nova). Para cancelar, use o IdViagemEvento retornado. TruckPag não usa código de produto nem cartão do fornecedor — usa o cartão PASS do motorista."]})]})}function ve(){const{configured:t,loading:l}=w(),[a,s]=g.useState({cpfCnpjProprietario:"",tipoChave:"cpf",chave:"",agencia:"",conta:"",codBanco:""}),[o,c]=g.useState(!1),[x,d]=g.useState("");
1if(l)return e.jsx(k,{});if(!t)return e.jsx(E,{feature:"Cadastro de chave PIX"});const m=a.tipoChave==="agencia_conta",r=async()=>{c(!0),d("");try{await N.extrattaCadastrarChavePix({cpfCnpjProprietario:a.cpfCnpjProprietario,tipoChave:a.tipoChave,chave:m?void 0:a.chave,agencia:m?a.agencia:void 0,conta:m?a.conta:void 0,codBanco:m?a.codBanco:void 0}),d("Chave PIX cadastrada com sucesso!"),s({cpfCnpjProprietario:"",tipoChave:"cpf",chave:"",agencia:"",conta:"",codBanco:""})}catch(u){const n=V(u);d(n.mensagem)}finally{c(!1)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--page-text)"},children:"Chave PIX do proprietário"}),e.jsx("p",{className:"text-sm",style:{color:"var(--page-text-muted)"},children:"Vincula uma chave PIX (ou conta bancária) a um proprietário para pagamento direto de frete. Tipos suportados: CPF, CNPJ, Telefone, Email, Aleatória, Agência+Conta."})]}),e.jsxs("div",{className:"card p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label text-sm block mb-1.5",children:"CPF/CNPJ do proprietário"}),e.jsx("input",{className:"input",placeholder:"Apenas dígitos",value:a.cpfCnpjProprietario,onChange:u=>s({...a,cpfCnpjProprietario:u.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label text-sm block mb-1.5",children:"Tipo de chave"}),e.jsxs("select",{className:"input",value:a.tipoChave,onChange:u=>s({...a,tipoChave:u.target.value}),children:[e.jsx("option",{value:"cpf",children:"CPF"}),e.jsx("option",{value:"cnpj",children:"CNPJ"}),e.jsx("option",{value:"telefone",children:"Telefone"}),e.jsx("option",{value:"email",children:"E-mail"}),e.jsx("option",{value:"aleatoria",children:"Aleatória (EVP)"}),e.jsx("option",{value:"agencia_conta",children:"Agência + Conta"})]})]}),!m&&e.jsxs("div",{children:[e.jsxs("label",{className:"label text-sm block mb-1.5",children:["Valor da chave ",a.tipoChave==="aleatoria"&&"(opcional — Extratta gera)"]}),e.jsx("input",{className:"input",placeholder:a.tipoChave==="email"?"[email protected]":a.tipoChave==="telefone"?"11987654321":a.tipoChave==="cpf"?"CPF (11 dígitos)":a.tipoChave==="cnpj"?"CNPJ (14 dígitos)":"Vazio = gerar automaticamente",value:a.chave,onChange:u=>s({...a,chave:u.target.value})})]}),m&&e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label text-sm block mb-1.5",children:"Agência"}),e.jsx("input",{className:"input",value:a.agencia,onChange:u=>s({...a,agencia:u.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label text-sm block mb-1.5",children:"Conta + dígito"}),e.jsx("input",{className:"input",placeholder:"Sem espaço/hífen",value:a.conta,onChange:u=>s({...a,conta:u.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label text-sm block mb-1.5",children:"Cód. Banco"}),e.jsx("input",{className:"input",placeholder:"001",value:a.codBanco,onChange:u=>s({...a,codBanco:u.target.value})})]})]}),x&&e.jsx("p",{className:"text-sm p-3 rounded-lg",style:{background:x.includes("sucesso")?"#ecfdf5":"#fef2f2",color:x.includes("sucesso")?"#059669":"#dc2626"},children:x}),e.jsxs("button",{onClick:r,disabled:o||!a.cpfCnpjProprietario||(m?!a.agencia||!a.conta||!a.codBanco:!1)||!m&&a.tipoChave!=="aleatoria"&&!a.chave,className:"btn-primary w-full flex items-center justify-center gap-2",children:[o?e.jsx(y,{className:"w-4 h-4 animate-spin"}):e.jsx($,{className:"w-4 h-4"})," ","Cadastrar chave"]})]})]})}function je(){const{configured:t,loading:l}=w(),[a,s]=g.useState({cpfUsuarioResponsavel:"",cpfCnpjPortador:"",nomeMotorista:"",valor:"",referencia:"",nroControle:""}),[o,c]=g.useState(!1),[x,d]=g.useState("");if(l)return e.jsx(k,{});if(!t)return e.jsx(E,{feature:"Diárias e despesas"});const m=async()=>{c(!0),d("");try{const r=await N.extrattaIntegrarDiaria({cpfUsuarioResponsavel:a.cpfUsuarioResponsavel,nroControleIntegracao:a.nroControle||`D-${Date.now()}`,cargas:[{cpfCnpjPortador:a.cpfCnpjPortador,nome:a.nomeMotorista,valor:Number(a.valor),observacao:a.referencia||void 0}]});d(r!=null&&r.Sucesso?"Diária carregada com sucesso no cartão PASS!":`Erro: ${(r==null?void 0:r.Mensagem)||"falha"}`),r!=null&&r.Sucesso&&s({cpfUsuarioResponsavel:a.cpfUsuarioResponsavel,cpfCnpjPortador:"",nomeMotorista:"",valor:"",referencia:"",nroControle:""})}catch(r){d(V(r).mensagem)}finally{c(!1)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--page-text)"},children:"Diárias e despesas de viagem"}),e.jsx("p",{className:"text-sm",style:{color:"var(--page-text-muted)"},children:"Carga avulsa no cartão PASS do motorista (recarga rápida sem viagem associada)."})]}),e.jsxs("div",{className:"card p-5 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label text-sm block mb-1.5",children:"CPF do usuário responsável"}),e.jsx("input",{className:"input",placeholder:"CPF cadastrado no portal Extratta",value:a.cpfUsuarioResponsavel,onChange:r=>s({...a,cpfUsuarioResponsavel:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label text-sm block mb-1.5",children:"Nº Controle (idempotência)"}),e.jsx("input",{className:"input",placeholder:"Auto-gerado se vazio",value:a.nroControle,onChange:r=>s({...a,nroControle:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label text-sm block mb-1.5",children:"CPF/CNPJ do portador"}),e.jsx("input",{className:"input",placeholder:"Apenas dígitos",value:a.cpfCnpjPortador,onChange:r=>s({...a,cpfCnpjPortador:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label text-sm block mb-1.5",children:"Nome do motorista"}),e.jsx("input",{className:"input",value:a.nomeMotorista,onChange:r=>s({...a,nomeMotorista:r.target.value})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label text-sm block mb-1.5",children:"Valor (R$)"}),e.jsx("input",{type:"number",step:"0.01",min:"0",className:"input",placeholder:"0,00",value:a.valor,onChange:r=>s({...a,valor:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label text-sm block mb-1.5",children:"Observação (opcional)"}),e.jsx("input",{className:"input",placeholder:"Ex: Diária Atibaia → SP · 25/04",value:a.referencia,onChange:r=>s({...a,referencia:r.target.value})})]}),x&&e.jsx("p",{className:"text-sm p-3 rounded-lg",style:{background:x.includes("sucesso")?"#ecfdf5":"#fef2f2",color:x.includes("sucesso")?"#059669":"#dc2626"},children:x}),e.jsxs("button",{onClick:m,disabled:o||!a.cpfUsuarioResponsavel||!a.cpfCnpjPortador||!a.nomeMotorista||!a.valor,className:"btn-primary w-full flex items-center justify-center gap-2",children:[o?e.jsx(y,{className:"w-4 h-4 animate-spin"}):e.jsx(K,{className:"w-4 h-4"})," ","Carregar diária"]})]})]})}function be(){const{configured:t,loading:l}=w(),[a,s]=g.useState({documento:"",numeroCartao:"",cartaoVirtual:!1}),[o,c]=g.useState(!1),[x,d]=g.useState("");
1if(l)return e.jsx(k,{});if(!t)return e.jsx(E,{feature:"Vínculo de cartão PASS"});const m=async()=>{c(!0),d("");try{const r=await N.extrattaVincularCartao({documento:a.documento,numeroCartao:a.cartaoVirtual?void 0:a.numeroCartao});d(r!=null&&r.Sucesso?r.Mensagem||"Cartão vinculado!":`Erro: ${(r==null?void 0:r.Mensagem)||"falha"}`),r!=null&&r.Sucesso&&s({documento:"",numeroCartao:"",cartaoVirtual:!1})}catch(r){d(V(r).mensagem)}finally{c(!1)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--page-text)"},children:"Vincular cartão PASS ao portador"}),e.jsx("p",{className:"text-sm",style:{color:"var(--page-text-muted)"},children:"Associa um cartão Visa Cargo PASS a um proprietário ou motorista já cadastrado na Extratta. Para proprietários, omitir o número do cartão cria automaticamente um cartão virtual."})]}),e.jsxs("div",{className:"card p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label text-sm block mb-1.5",children:"CPF/CNPJ do portador"}),e.jsx("input",{className:"input",placeholder:"Apenas dígitos",value:a.documento,onChange:r=>s({...a,documento:r.target.value})})]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",style:{color:"var(--page-text)"},children:[e.jsx("input",{type:"checkbox",checked:a.cartaoVirtual,onChange:r=>s({...a,cartaoVirtual:r.target.checked})}),"Criar cartão virtual (apenas proprietários)"]}),!a.cartaoVirtual&&e.jsxs("div",{children:[e.jsx("label",{className:"label text-sm block mb-1.5",children:"Número do cartão físico"}),e.jsx("input",{className:"input",placeholder:"Impresso no cartão entregue",value:a.numeroCartao,onChange:r=>s({...a,numeroCartao:r.target.value})})]}),x&&e.jsx("p",{className:"text-sm p-3 rounded-lg",style:{background:x.toLowerCase().includes("erro")?"#fef2f2":"#ecfdf5",color:x.toLowerCase().includes("erro")?"#dc2626":"#059669"},children:x}),e.jsxs("button",{onClick:m,disabled:o||!a.documento||!a.cartaoVirtual&&!a.numeroCartao,className:"btn-primary w-full flex items-center justify-center gap-2",children:[o?e.jsx(y,{className:"w-4 h-4 animate-spin"}):e.jsx($,{className:"w-4 h-4"}),"Vincular cartão"]})]})]})}export{he as AbastecimentoPage,fe as ContratosAgregadosPage,je as DiariasPage,pe as PagamentoFretePage,ve as P
1ixChavePage,ge as ValePedagioPage,be as VincularCartaoPage};

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.