1import{u as oe,j as e,P as te,T as Re,U as K,S as Be}from"./index--siChAZm.js";import{u as de,r}from"./react-vendor-B-clOVnp.js";import{C as X}from"./CopyId-DheAb2bs.js";import{A as Te}from"./AuthImage-ZP-tkq6M.js";import{l as Ee,a as We}from"./planosFreelancer-DfTphmA0.js";import{N as re,_ as ne,m as ce,r as pe,O as fe,aF as me,J as xe,am as Q,b0 as ge,R as _e,U as $e,T as ee,n as qe,b1 as De,aM as Oe,c as Fe,t as Le,a as Me,b2 as Xe}from"./icons-BCLA8W0j.js";const ae=n=>Number(n||0).toLocaleString("pt-BR",{style:"currency",currency:"BRL"}),L=50;function Ue({forma:n}){return n==="cartao"?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:12,fontWeight:600,padding:"3px 10px",borderRadius:20,background:"#ede9fe",color:"#5b21b6"},children:[e.jsx(fe,{size:13})," Cartão"]}):e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:12,fontWeight:600,padding:"3px 10px",borderRadius:20,background:"#cffafe",color:"#0e7490"},children:[e.jsx(me,{size:13})," PIX"]})}const _={padding:"12px 14px",fontSize:14,verticalAlign:"middle"},$={padding:"10px 14px",fontSize:11,color:"#6b7280",textTransform:"uppercase",letterSpacing:"0.04em",textAlign:"left",fontWeight:700,whiteSpace:"nowrap"};function Ve(){const{token:n}=oe(),p=de(),[l,u]=r.useState([]),[f,b]=r.useState(0),[d,y]=r.useState(!0),[x,m]=r.useState(""),[k,W]=r.useState(""),[w,N]=r.useState(""),[j,s]=r.useState(""),[g,C]=r.useState(0),P=r.useCallback(async()=>{y(!0),m("");try{const t={limit:L,skip:g};k&&(t.forma=k),j&&(t.busca=j);const B=await Ee(n,t);u(B.docs||[]),b(B.total||0)}catch(t){m(t.message)}finally{y(!1)}},[n,g,k,j]);r.useEffect(()=>{P()},[P]);function I(t){t.preventDefault(),C(0),s(w.trim())}const A={padding:"8px 12px",border:"1.5px solid #e5e7eb",borderRadius:8,fontSize:14},R=l.reduce((t,B)=>t+Number(B.valorFinal||0),0),o=Math.floor(g/L)+1,S=Math.max(1,Math.ceil(f/L));return e.jsxs("div",{children:[e.jsxs("form",{onSubmit:I,style:{display:"flex",gap:8,marginBottom:14,flexWrap:"wrap"},children:[e.jsxs("select",{value:k,onChange:t=>{W(t.target.value),C(0)},style:A,children:[e.jsx("option",{value:"",children:"Todas as formas"}),e.jsx("option",{value:"pix",children:"PIX"}),e.jsx("option",{value:"cartao",children:"Cartão"})]}),e.jsx("input",{value:w,onChange:t=>N(t.target.value),placeholder:"Buscar por nome, e-mail ou IDâ¦",style:{...A,flex:1,minWidth:200}}),e.jsx("button",{type:"submit",className:"btn btn-primary btn-sm",children:"Buscar"})]}),!d&&!x&&e.jsxs("div",{style:{fontSize:13,color:"#6b7280",marginBottom:10},children:[f," pagamento",f===1?"":"s"," recebido",f===1?"":"s",l.length>0&&e.jsxs(e.Fragment,{children:[" · soma nesta página: ",e.jsx("strong",{style:{color:"#059669"},children:ae(R)})]})]}),d&&e.jsx(te,{variant:"tabela",colunas:["30%","20%","20%","15%","15%"],linhas:8}),!d&&x&&e.jsx("div",{className:"alert alert-warning",children:x}),!d&&!x&&l.length===0&&e.jsxs("div",{className:"empty-state",children:[e.jsx(re,{size:36,color:"var(--accent)"}),e.jsx("p",{children:"Nenhum pagamento recebido encontrado."})]}),!d&&!x&&l.length>0&&e.jsx("div",{style:{overflowX:"auto",border:"1px solid #f3f4f6",borderRadius:10},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",background:"#fff"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f9fafb"},children:[e.jsx("th",{style:$,children:"Freelancer"}),e.jsx("th",{style:$,children:"Plano"}),e.jsx("th",{style:$,children:"Forma"}),e.jsx("th",{style:{...$,textAlign:"right"},children:"Valor"}),e.jsx("th",{style:$,children:"Pago em"}),e.jsx("th",{style:$,children:"Vigência"})]})}),e.jsx("tbody",{children:l.map(t=>e.jsxs("tr",{style:{borderTop:"1px solid #f3f4f6"},children:[e.jsx("td",{style:_,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(Re,{foto:t.imagemPerfil,nome:t.nome||t.email,pro:!0}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{fontWeight:600},children:t.nome||t.email||"â"}),e.jsx("div",{style:{fontSize:12,color:"#6b7280"},children:t.email||"â"}),e.jsxs("div",{style:{fontSize:11,color:"#9ca3af",display:"flex",alignItems:"center",gap:4},children:[t.bubbleUserId," ",e.jsx(X,{id:t.bubbleUserId})]}),t.freelancerBubbleId&&e.jsxs("button",{onClick:()=>p(`/admin/freelancers/${t.freelancerBubbleId}`),style:{marginTop:6,display:"inline-flex",alignItems:"center",gap:5,fontSize:12,fontWeight:600,color:"var(--primary)",background:"#eef2ff",border:"1px solid #c7d2fe",borderRadius:8,padding:"4px 10px",cursor:"pointer"},children:[e.jsx(ne,{size:13})," Ver mais informações"]})]})]})}),e.jsxs("td",{style:_,children:[e.jsx("div",{style:{fontWeight:600,color:"var(--primary)"},children:"Profissional"}),e.jsxs("div",{style:{fontSize:12,color:"#6b7280"},children:[t.cadencia,t.meses?` · ${t.meses} ${t.meses===1?"mês":"meses"}`:""]})]}),e.jsx("td",{style:_,children:e.jsx(Ue,{forma:t.formaPagamento})}),e.jsxs("td",{style:{..._,textAlign:"right"},children:[e.jsx("div",{style:{fontWeight:700,color:"#059669",fontSize:16},children:ae(t.valorFinal)}),Number(t.descontoPix)>0&&e.jsxs("div",{style:{fontSize:11,color:"#9ca3af"},children:["bruto ",ae(t.precoBruto)]})]}),e.jsx("td",{style:_,children:K(t.pagoEm||t.ativadoEm||t.updatedAt)}),e.jsxs("td",{style:_,children:[e.jsx("div",{style:{fontSize:12,color:"#6b7280"}
1,children:t.vigenciaInicio?K(t.vigenciaInicio):"â"}),e.jsxs("div",{style:{fontSize:12,color:"#6b7280"},children:["até ",t.vigenciaFim?K(t.vigenciaFim):"â"]})]})]},t._id))})]})}),!d&&!x&&S>1&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:12,marginTop:16},children:[e.jsxs("button",{className:"btn btn-ghost btn-sm",disabled:g===0,onClick:()=>C(Math.max(0,g-L)),children:[e.jsx(ce,{size:15})," Anterior"]}),e.jsxs("span",{style:{fontSize:13,color:"#6b7280"},children:["Página ",o," de ",S]}),e.jsxs("button",{className:"btn btn-ghost btn-sm",disabled:o>=S,onClick:()=>C(g+L),children:["Próxima ",e.jsx(pe,{size:15})]})]})]})}const V=n=>Number(n||0).toLocaleString("pt-BR",{style:"currency",currency:"BRL"}),M=50,H={padding:"12px 14px",fontSize:14,verticalAlign:"middle"},G={padding:"10px 14px",fontSize:11,color:"#6b7280",textTransform:"uppercase",letterSpacing:"0.04em",textAlign:"left",fontWeight:700,whiteSpace:"nowrap"};function He({src:n,nome:p}){const[l,u]=r.useState(!1);return!n||l?e.jsx("div",{style:{width:40,height:40,borderRadius:8,background:"#f3f4f6",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(xe,{size:20,color:"#9ca3af"})}):e.jsx("img",{src:n,alt:p||"Empresa",onError:()=>u(!0),style:{width:40,height:40,borderRadius:8,objectFit:"cover",flexShrink:0}})}function Ge({formaPagamento:n="pix",parcelas:p=1,tipoAjuste:l}){const u=n?.startsWith("cartao"),f=n==="boleto";if(n==="ajuste"){const d=l==="debito";return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:12,fontWeight:600,padding:"3px 10px",borderRadius:20,background:d?"#fee2e2":"#dcfce7",color:d?"#b91c1c":"#166534"},children:[d?e.jsx(Q,{size:13}):e.jsx(ge,{size:13}),d?"DÃBITO ADM":"CRÃDITO ADM"]})}if(u){const d=p>1?` ${p}x`:"";return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:12,fontWeight:600,padding:"3px 10px",borderRadius:20,background:"#ede9fe",color:"#6d28d9"},children:[e.jsx(fe,{size:13})," CARTÃO",d]})}return f?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:12,fontWeight:600,padding:"3px 10px",borderRadius:20,background:"#fef3c7",color:"#92400e"},children:[e.jsx(re,{size:13})," BOLETO"]}):e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:12,fontWeight:600,padding:"3px 10px",borderRadius:20,background:"#cffafe",color:"#0e7490"},children:[e.jsx(me,{size:13})," PIX"]})}function Je(){const{token:n}=oe(),p=de(),[l,u]=r.useState([]),[f,b]=r.useState(0),[d,y]=r.useState(!0),[x,m]=r.useState(""),[k,W]=r.useState(""),[w,N]=r.useState(""),[j,s]=r.useState(0),g=r.useCallback(async()=>{y(!0),m("");try{const o={limit:M,skip:j};w&&(o.busca=w);const S=await We(n,o);u(S.docs||[]),b(S.total||0)}catch(o){m(o.message)}finally{y(!1)}},[n,j,w]);r.useEffect(()=>{g()},[g]);function C(o){o.preventDefault(),s(0),N(k.trim())}const P={padding:"8px 12px",border:"1.5px solid #e5e7eb",borderRadius:8,fontSize:14},I=l.reduce((o,S)=>o+Number(S.valor||0),0),A=Math.floor(j/M)+1,R=Math.max(1,Math.ceil(f/M));return e.jsxs("div",{children:[e.jsxs("form",{onSubmit:C,style:{display:"flex",gap:8,marginBottom:14,flexWrap:"wrap"},children:[e.jsx("input",{value:k,onChange:o=>W(o.target.value),placeholder:"Buscar por nome da empresa, e-mail ou IDâ¦",style:{...P,flex:1,minWidth:200}}),e.jsx("button",{type:"submit",className:"btn btn-primary btn-sm",children:"Buscar"})]}),!d&&!x&&e.jsxs("div",{style:{fontSize:13,color:"#6b7280",marginBottom:10},children:[f," pagamento",f===1?"":"s"," recebido",f===1?"":"s",l.length>0&&e.jsxs(e.Fragment,{children:[" · soma nesta página: ",e.jsx("strong",{style:{color:"#059669"},children:V(I)})]})]}),d&&e.jsx(te,{variant:"tabela",colunas:["35%","20%","20%","25%"],linhas:8}),!d&&x&&e.jsx("div",{className:"alert alert-warning",children:x}),!d&&!x&&l.length===0&&e.jsxs("div",{className:"empty-state",children:[e.jsx(xe,{size:36,color:"var(--accent)"}),e.jsx("p",{children:"Nenhum pagamento de empresa encontrado."})]}),!d&&!x&&l.length>0&&e.jsx("div",{style:{overflowX:"auto",border:"1px solid #f3f4f6",borderRadius:10},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",background:"#fff"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f9fafb"},children:[e.jsx("th",{style:G,children:"Empresa"}),e.jsx("th",{style:G,children:"Forma"}),e.jsx("th",{style:{...G,textAlign:"right"},children:"Valor"}),e.jsx("th",{style:G,children:"Pago em"})]})}),e.jsx("tbody",{children:l.map(o=>e.jsxs("tr",{style:{borderTop:"1px solid #f3f4f6"},children:[e.jsx("td",{style:H,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(He,{src:o.logotipo,nome:o.nomeDaEmpresa}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{fontWeight:600},children:o.nomeDaEmpresa||o.razaoSocial||"â"}),o.razaoSocial&&o.razaoSocial!==o.nomeDaEmpresa&&e.jsx("div",{style:{fontSize:12,color:"#6b7280"},children:o.razaoSocial}),e.jsx("div",{style:{fontSize:12,color:"#6b7280"},children:o.email||"â"}),o.descricao&&e.jsx("div",{style:{fontSize:11,color:"#7c3aed",fontWeight:600,marginTop:2},children:o.descricao}),o.empresaId&&e.jsxs("div",{style:{fontSize:11,color:"#9ca3af",display:"flex",alignItems:"center",gap:4},children:[o.empresaId," ",e.jsx(X,{id:o.empresaId})]}),o.empresaId&&e.jsxs("button",{onClick:()=>p(`/admin/empresas/${o.empresaId}`),style:{marginTop:6,display:"inline-flex",alignItems:"center",gap:5,fontSize:12,fontWeight:600,color:"var(--primary)",background:"#eef2ff",border:"1px solid #c7d2fe",borderRadius:8,padding:"4px 10px",cursor:"pointer"},children:[e.jsx(ne,{size:13})," Ver mais informações"]})]})]})}),e.jsxs("td",{style:H,children:[e.jsx(Ge,{formaPagamento:o.formaPagamento,parcelas:o.parcelas,tipoAjuste:o.tipoAjuste}),o.simulada&&e.jsx("div",{style:{fontSize:11,color:"#f59e0b",marginTop:3,fontWeight:600},children:"SIMULADO"})]}),e.jsxs("td",{style:{...H,textAlign:"right"},children:[e.jsx("div",{style:{fontWeight:700,fontSize:16,color:o.tipoAjuste==="debito"?"#dc2626":"#059669"},children:o.tipoAjuste==="debito"?`â${V(o.valor)}`:V(o.valor)}),o.saldoApos!=null&&e.jsxs("div",{style:{fontSize:11,color:"#9ca3af",marginTop:1},children:["saldo após: ",V(o.saldoApos)]})]}),e.jsx("td",{style:H,children:K(o.paidAt)})]},o._id))})]})}),!d&&!x&&R>1&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:12,marginTop:16},children:[e.jsxs("button",{className:"btn btn-ghost btn-sm",disabled:j===0,onClick:()=>s(Math.max(0,j-M)),children:[e.jsx(ce,{size:15})," Anterior"]}),e.jsxs("span",{style:{fontSize:13,color:"#6b7280"},children:["Página ",A," de ",R]}),e.jsxs("button",{className:"btn btn-ghost btn-sm",disabled:A>=R,onClick:()=>s(j+M),children:["Próxima ",e.jsx(pe,{size:15})]})]})]})}const le={cpf:"CPF",cnpj:"CNPJ",email:"E-mail",telefone:"Telefone",aleatoria:"Chave Aleatória"},q=n=>
1Number(n||0).toLocaleString("pt-BR",{style:"currency",currency:"BRL"});function J(n){return n?new Date(n).toLocaleString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):"â"}function Ke(n){if(!n)return"â";const p=String(n).match(/^(\d{4})-(\d{2})-(\d{2})/);if(p)return`${p[3]}/${p[2]}/${p[1]}`;const l=new Date(n);return Number.isNaN(l.getTime())?"â":l.toLocaleDateString("pt-BR")}const Qe=new Set(["processado","cancelado","chave_invalida"]);function he(n,p){if(!n||Qe.has(p))return"normal";const l=new Date(n)-Date.now();return l<0?"vencido":l<24*3600*1e3?"urgente":"normal"}function Ye({prazoEm:n,status:p}){const l=he(n,p);return l==="vencido"?e.jsx("span",{style:{fontSize:11,fontWeight:700,padding:"2px 8px",borderRadius:20,background:"#fee2e2",color:"#991b1b"},children:"VENCIDO"}):l==="urgente"?e.jsx("span",{style:{fontSize:11,fontWeight:700,padding:"2px 8px",borderRadius:20,background:"#fef3c7",color:"#92400e"},children:"Urgente"}):null}function na(){const{token:n,usuario:p,bubbleVersion:l}=oe(),u=r.useRef(null);function f(a={}){return{Authorization:`Bearer ${n}`,"x-bubble-version":l||"live","x-test-perfil":p?.perfil||"",...a}}const[b,d]=r.useState("saques"),[y,x]=r.useState("freelancers"),[m,k]=r.useState("pendente"),[W,w]=r.useState([]),[N,j]=r.useState(!0),[s,g]=r.useState(null),[C,P]=r.useState({adminNota:""}),[I,A]=r.useState(null),[R,o]=r.useState(null),[S,t]=r.useState(!1),[B,se]=r.useState(""),[Y,ue]=r.useState(null),[be,je]=r.useState({});async function U(a=m){j(!0),se("");try{const c=await fetch(`/api/admin/pagamentos?status=${a}`,{headers:f()}),z=await c.json();if(!c.ok)throw new Error(z.error||"Erro ao carregar");w(z)}catch(c){se(c.message)}finally{j(!1)}}r.useEffect(()=>{b==="saques"&&U(m)},[m,b]);function T(a,c){g({saque:a,acao:c}),P({adminNota:""}),A(null),o(null),u.current&&(u.current.value="")}function ve(a){const c=a.target.files?.[0];if(!c)return;A(c);const z=URL.createObjectURL(c);o(z)}const ye={agendado:"agendar",liberado:"liberar",processado:"processar",cancelado:"cancelar",chave_invalida:"marcar-invalida"};async function Se(a,c){t(!0);try{if(c==="chave_invalida"){const v=await fetch(`/api/admin/pagamentos/${a}/marcar-invalida`,{method:"PATCH",headers:f({"Content-Type":"application/json"}),body:JSON.stringify({motivoInvalido:C.adminNota||""})}),E=await v.json();if(!v.ok)throw new Error(E.error||"Erro");g(null),P({adminNota:""}),U(m);return}if(c==="processado"){if(!I&&!s.saque.comprovanteId)throw new Error("Anexe o comprovante bancário antes de marcar como pago.");if(I){const v=new FormData;v.append("comprovante",I);const E=await fetch(`/api/admin/pagamentos/${a}/comprovante`,{method:"POST",headers:f(),body:v}),O=await E.json();if(!E.ok)throw new Error(O.error||"Erro ao enviar comprovante")}}const z=ye[c];if(!z)throw new Error("Ação inválida: "+c);const h=await fetch(`/api/admin/pagamentos/${a}/${z}`,{method:"PATCH",headers:f({"Content-Type":"application/json"}),body:JSON.stringify({observacao:(C.adminNota||"").trim()})}),D=await h.json();if(!h.ok)throw new Error(D.error||"Erro");g(null),U(m)}catch(z){alert(z.message)}finally{t(!1)}}const ze=[{id:"pendente",label:"Pendentes"},{id:"agendado",label:"Agendados"},{id:"processando",label:"Processando"},{id:"processado",label:"Processados"},{id:"cancelado",label:"Cancelados"},{id:"chave_invalida",label:"Chave Inválida"},{id:"todos",label:"Todos"}],Ce={pendente:{bg:"#fef3c7",cor:"#92400e",label:"Pendente"},agendado:{bg:"#dbeafe",cor:"#1e40af",label:"Agendado"},processando:{bg:"#fed7aa",cor:"#9a3412",label:"Processando"},processado:{bg:"#d1fae5",cor:"#065f46",label:"Processado"},cancelado:{bg:"#fee2e2",cor:"#991b1b",label:"Cancelado"},chave_invalida:{bg:"#fce7f3",cor:"#9d174d",label:"Chave inválida"}},ke={agendado:"Agendar PIX (Operador 1 â Financeiro)",liberado:"Liberar PIX no banco (Operador 2)",processado:"Confirmar Pagamento (anexar comprovante)",cancelado:"Cancelar Saque",chave_invalida:"Marcar Chave PIX como Inválida"},Ie={agendado:"Agendar PIX",liberado:"Liberar no banco",processado:"Confirmar Pagamento",cancelado:"Cancelar Saque",chave_invalida:"Marcar como Inválida"},Ae={cancelado:{color:"#ef4444",borderColor:"#ef4444"},chave_invalida:{color:"#9d174d",borderColor:"#f9a8d4",background:"#fce7f3"}},we=new Set(["cancelado","chave_invalida"]);return e.jsxs("div",{className:"page",children:[e.jsxs("div",{className:"page-header",children:[e.jsx("h2",{children:"Gerenciar Pagamentos"}),b==="saques"&&e.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>U(m),style:{marginLeft:"auto"},children:e.jsx(_e,{size:15})})]}),e.jsx("div",{style:{display:"flex",gap:8,marginBottom:16,borderBottom:"1.5px solid #e5e7eb"},children:[{id:"saques",label:"Saques de freelancers"},{id:"recebidos",label:"Pagamentos recebidos"}].map(a=>e.jsx("button",{onClick:()=>d(a.id),style:{padding:"8px 16px",border:"none",borderBottom:"2.5px solid",borderColor:b===a.id?"var(--primary)":"transparent",background:"none",cursor:"pointer",fontSize:14,fontWeight:b===a.id?700:500,color:b===a.id?"var(--primary)":"#6b7280",marginBottom:-1.5},children:a.label},a.id))}),b==="recebidos"&&e.jsxs("div",{children:[e.jsx("div",{style:{display:"flex",gap:4,marginBottom:16,borderBottom:"1.5px solid #f3f4f6"},children:[{id:"freelancers",label:"Freelancers"},{id:"empresas",label:"Empresas"}].map(a=>e.jsx("button",{onClick:()=>x(a.id),style:{padding:"7px 18px",border:"none",borderBottom:"2.5px solid",borderColor:y===a.id?"var(--primary)":"transparent",background:"none",cursor:"pointer",fontSize:13,fontWeight:y===a.id?700:500,color:y===a.id?"var(--primary)":"#6b7280",marginBottom:-1.5},children:a.label},a.id))}),y==="freelancers"&&e.jsx(Ve,{}),y==="empresas"&&e.jsx(Je,{})]}),b==="saques"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"flex",gap:4,marginBottom:14},children:ze.map(a=>e.jsx("button",{onClick:()=>k(a.id),style:{padding:"6px 14px",borderRadius:20,border:"1.5px solid",fontSize:13,fontWeight:600,cursor:"pointer",background:m===a.id?"var(--primary)":"#fff",color:m===a.id?"#fff":"var(--primary)",borderColor:"var(--primary)"},children:a.label},a.id))}),N&&e.jsx(te,{variant:"tabela",colunas:["25%","25%","25%","25%"],linhas:8}),!N&&B&&e.jsx("div",{className:"alert alert-warning",children:B}),!N&&W.length===0&&e.jsxs("div",{className:"empty-state",children:[e.jsx(re,{size:36,color:"var(--accent)"}),e.jsxs("p",{children:["Nenhum saque ",m!=="todos"?m:""," encontrado."]})]}),!N&&W.map(a=>{const c=he(a.prazoEm,a.status),z=c==="vencido"?"#fca5a5":c==="urgente"?"#fcd34d":"#e5e7eb";return e.jsxs("div",{style:{background:"#fff",border:`1.5px solid ${z}`,borderRadius:10,padding:"14px 16px",marginBottom:10},children:[e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap",marginBottom:8},children:[e.jsx(Ye,{prazoEm:a.prazoEm,status:a.status}),(()=>{const h=Ce[a.status]||{bg:"#f3f4f6",cor:"#6b7280",label:a.status};return e.jsx("span",{style:{fontSize:11,fontWeight:600,padding:"2px 8px",borderRadius:20,background:h.bg,color:h.cor},children:h.label})})(),e.jsxs("span",{style:{marginLeft:"auto",fontSize:12,color:"#9ca3af"},children:["Prazo: ",J(a.prazoEm)]})]}),e.jsxs("div",{style:{display:"flex",gap:16,flexWrap:"wrap",marginBottom:8},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:11,color:"#9ca3af",textTransform:"uppercase",letterSpacing:"0.04em"},children:"Freelancer"}),e.jsxs("div",{style:{fontWeight:600,color:"var(--primary)",display:"flex",alignItems:"center",gap:4},children:[e.jsx($e,{size:13})," ",a.freelancerNome||a.freelancerId,e.jsx(X,{id:a.freelancerId})]}),a.freelancerEmail&&e.jsx("div",{style:{fontSize:12,color:"#6b7280"},children:a.freelancerEmail})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:11,color:"#9ca3af",textTransform:"uppercase",letterSpacing:"0.04em"},children:"Chave PIX"}),e.jsxs("div",{style:{fontWeight:500,fontSize:14,display:"inline-flex",alignItems:"center",gap:3,maxWidth:"100%"},children:[e.jsxs("span",{children:[le[a.pixTipo]||a.pixTipo,": ",e.jsx("strong",{children:a.pixChave})]}),e.jsx(X,{id:a.pixChave})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:11,color:"#9ca3af",textTransform:"uppercase",letterSpacing:"0.04em"},children:"Valor"}),e.jsx("div",{style:{fontWeight:700,color:"#059669",fontSize:18},children:q(a.valor)})]})]}),a.motivoInvalido&&e.jsxs("div",{style:{background:"#fce7f3",border:"1px solid #f9a8d4",borderRadius:8,padding:"8px 12px",marginBottom:8,fontSize:12,color:"#9d174d",display:"flex",gap:6,alignItems:"flex-start"},children:[e.jsx(ee,{size:13,style:{flexShrink:0,marginTop:1}}),e.jsxs("span",{children:[e.jsx("strong",{children:"Chave PIX inválida:"})," ",a.motivoInvalido]})]}),(a.adminNota||(a.composicao?.itens?.length||0)>0)&&(()=>{const h=!!be[a._id],D=(a.adminNota||"").split(` 2`).filter(i=>i.trim().length>0),v=a.composicao?.itens||[],E=a.composicao?.soma||0,O=a.composicao?.bate,Ne=D.length+v.length;return e.jsxs("div",{style:{marginBottom:8},children:[e.jsxs("button",{type:"button",onClick:()=>je(i=>({...i,[a._id]:!h})),style:{background:h?"#eef2ff":"#f9fafb",border:"1px solid "+(h?"#c7d2fe":"#e5e7eb"),borderRadius:8,padding:"6px 10px",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:6,fontSize:12,fontWeight:600,color:h?"#3730a3":"#475569"},children:[e.jsx(qe,{size:13}),h?"Ocultar histórico e composição":`Ver histórico e composição (${Ne})`,h?e.jsx(De,{size:13}):e.jsx(Oe,{size:13})]}),h&&e.jsxs("div",{style:{marginTop:6,display:"flex",flexDirection:"column",gap:8},children:[v.length>0&&e.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:"10px 12px"},children:[e.jsxs("div",{style:{fontSize:11,fontWeight:700,color:"#166534",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:8,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,flexWrap:"wrap"},children:[e.jsxs("span",{children:["Composição do valor sacado (",v.length," ",v.length===1?"lançamento":"lançamentos",")"]}),e.jsx("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:12,fontWeight:700,background:O?"#dcfce7":"#fee2e2",color:O?"#166534":"#991b1b"},children:O?`Σ ${q(E)} OK`:`Σ ${q(E)} â ${q(a.valor)}`})]}),v.map((i,F)=>{const Pe=i.criadoPorAdmin?`crédito admin (${i.criadoPorAdmin}
2)`:i.liberadoPorAvaliacao?"avaliação positiva":i.checkoutEm?"check-out concluÃdo":"contratação",ie=Ke(i.dataEvento||i.createdAt),Z=i.eventoId?`referente ao trabalho de ${i.eventoFuncao||"â"} no dia ${ie} - ${i.eventoId}`:"";return e.jsxs("div",{style:{padding:"6px 0",borderTop:F>0?"1px dashed #bbf7d0":"none",display:"flex",justifyContent:"space-between",gap:12,alignItems:"flex-start",flexWrap:"wrap"},children:[e.jsxs("div",{style:{flex:1,minWidth:0,fontSize:12,color:"#14532d",lineHeight:1.5},children:[e.jsxs("div",{style:{fontWeight:600},children:[ie," · ",i.eventoFuncao||"â"]}),Z&&e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:3,color:"#166534",wordBreak:"break-word"},children:[e.jsx("span",{children:Z}),e.jsx(X,{id:Z,style:{flexShrink:0}})]}),e.jsxs("div",{style:{color:"#15803d"},children:[i.empresaNome||"â",i.horarioInicio||i.horarioFim?` · ${i.horarioInicio||"?"}â${i.horarioFim||"?"}`:""]}),e.jsxs("div",{style:{fontSize:11,color:"#65a30d",marginTop:2},children:["Origem: ",Pe,i.eventoId?` · evento ${String(i.eventoId).slice(-6)}`:""]}),i.eventoId&&e.jsxs("button",{type:"button",onClick:()=>window.open(`/admin/contratacoes-avulsas/${encodeURIComponent(String(i.eventoId))}`,"_blank","noopener,noreferrer"),title:"Abrir página do evento em uma nova aba",style:{display:"inline-flex",alignItems:"center",gap:5,marginTop:6,padding:"4px 9px",borderRadius:6,border:"1px solid #86efac",background:"#f0fdf4",color:"#166534",fontSize:11,fontWeight:700,cursor:"pointer"},children:[e.jsx(ne,{size:12})," Abrir evento"]})]}),e.jsx("div",{style:{fontWeight:700,color:"#166534",fontSize:13,whiteSpace:"nowrap"},children:q(i.valor)})]},i._id||F)})]}),v.length===0&&a.adminNota&&e.jsx("div",{style:{background:"#fef3c7",border:"1px solid #fde68a",borderRadius:8,padding:"8px 12px",fontSize:12,color:"#92400e"},children:"â ï¸ Nenhum lançamento de saldo está vinculado a este saque (saque legado ou saldo cancelado/devolvido). Verifique a origem antes de processar."}),D.length>0&&e.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:"10px 12px"},children:[e.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#475569",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:6},children:"Histórico de ações"}),D.map((i,F)=>e.jsx("div",{style:{fontSize:12,color:"#374151",lineHeight:1.55,padding:"4px 0",borderTop:F>0?"1px dashed #e2e8f0":"none",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:i},F))]})]})]})})(),a.comprovanteId&&e.jsxs("div",{style:{marginBottom:8},children:[e.jsxs("button",{onClick:()=>ue(Y===a._id?null:a._id),style:{background:"none",border:"none",cursor:"pointer",fontSize:12,color:"var(--primary)",display:"flex",alignItems:"center",gap:4,fontWeight:600},children:[e.jsx(Fe,{size:13})," ",Y===a._id?"Ocultar comprovante":"Ver comprovante"]}),Y===a._id&&e.jsx("div",{style:{marginTop:8},children:e.jsx(Te,{src:`/api/comprovante/${a.comprovanteId}`,alt:"Comprovante",style:{maxWidth:"100%",maxHeight:320,borderRadius:8,border:"1px solid #e5e7eb",display:"block"}})})]}),(a.agendadoEm||a.processandoEm||a.processadoEm)&&e.jsxs("div",{style:{fontSize:12,color:"#6b7280",marginTop:4,display:"flex",flexDirection:"column",gap:2},children:[a.agendadoEm&&e.jsxs("div",{children:["ð
Agendado em: ",J(a.agendadoEm),a.agendadoPorNome?` · ${a.agendadoPorNome}`:""]}),a.processandoEm&&e.jsxs("div",{children:["ð¦ Liberado no banco em: ",J(a.processandoEm),a.processandoPorNome?` · ${a.processandoPorNome}`:""]}),a.processadoEm&&e.jsxs("div",{children:["â
Pago em: ",J(a.processadoEm)]})]}),a.status==="pendente"&&e.jsxs("div",{style:{display:"flex",gap:8,marginTop:10,flexWrap:"wrap"},children:[e.jsxs("button",{className:"btn btn-sm",style:{background:"#1e40af",color:"#fff",border:"none"},onClick:()=>T(a,"agendado"),children:[e.jsx(Le,{size:14})," PIX agendado (Op. 1)"]}),e.jsxs("button",{className:"btn btn-ghost btn-sm",style:{color:"#9d174d",borderColor:"#f9a8d4"},onClick:()=>T(a,"chave_invalida"),children:[e.jsx(ee,{size:14})," Chave PIX inválida"]}),e.jsxs("button",{className:"btn btn-ghost btn-sm",style:{color:"#ef4444"},onClick:()=>T(a,"cancelado"),children:[e.jsx(Q,{size:14})," Cancelar"]})]}),a.status==="agendado"&&e.jsxs("div",{style:{display:"flex",gap:8,marginTop:10,flexWrap:"wrap"},children:[e.jsxs("button",{className:"btn btn-sm",style:{background:"#9a3412",color:"#fff",border:"none"},onClick:()=>T(a,"liberado"),children:[e.jsx(ge,{size:14})," Liberar PIX no banco (Op. 2)"]}),e.jsxs("button",{className:"btn btn-ghost btn-sm",style:{color:"#ef4444"},onClick:()=>T(a,"cancelado"),children:[e.jsx(Q,{size:14})," Cancelar"]})]}),a.status==="processando"&&e.jsxs("div",{style:{display:"flex",gap:8,marginTop:10,flexWrap:"wrap"},children:[e.jsxs("button",{className:"btn btn-primary btn-sm",onClick:()=>T(a,"processado"),children:[e.jsx(Me,{size:14})," Marcar como pago (anexar comprovante)"]}),e.jsxs("button",{className:"btn btn-ghost btn-sm",style:{color:"#ef4444"},onClick:()=>T(a,"cancelado"),children:[e.jsx(Q,{size:14})," Cancelar"]})]})]},a._id)}),s&&e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",zIndex:2e3,display:"flex",alignItems:"center",justifyContent:"center",padding:16},onClick:a=>a.target===a.currentTarget&&g(null),children:e.jsxs("div",{style:{background:"#fff",borderRadius:12,padding:24,width:"100%",maxWidth:440,boxShadow:"0 8px 32px rgba(0,0,0,0.18)"},children:[e.jsx("h3",{style:{marginBottom:16,color:s.acao==="chave_invalida"?"#9d174d":"var(--primary)"},children:ke[s.acao]||"Atualizar Saque"}),e.jsxs("div",{style:{background:"#f9fafb",borderRadius:8,padding:12,marginBottom:14},children:[e.jsx("strong",{children:s.saque.freelancerNome}),e.jsx("div",{style:{fontSize:13,color:"#6b7280"},children:s.saque.freelancerEmail}),e.jsxs("div",{style:{fontSize:13},children:[le[s.saque.pixTipo]||s.saque.pixTipo,": ",s.saque.pixChave]}),s.saque.banco&&e.jsxs("div",{style:{fontSize:13,color:"#374151"},children:["Banco: ",e.jsx("strong",{children:s.saque.banco})]}),e.jsx("div",{style:{color:"#059669",fontWeight:700,fontSize:18,marginTop:4},children:q(s.saque.valor)})]}),s.acao==="chave_invalida"&&e.jsxs("div",{style:{background:"#fce7f3",border:"1px solid #f9a8d4",borderRadius:8,padding:"10px 14px",marginBottom:14,fontSize:13,color:"#9d174d"},children:[e.jsx(ee,{size:14,style:{verticalAlign:"middle",marginRight:6}}
2),"O freelancer será notificado por push e precisará corrigir a chave PIX para que o saque seja reprocessado."]}),s.acao==="processado"&&e.jsxs("div",{className:"form-group",style:{marginBottom:14},children:[e.jsx("label",{style:{fontWeight:600,fontSize:13,display:"block",marginBottom:6},children:"Comprovante de pagamento (opcional)"}),R?e.jsxs("div",{style:{marginBottom:10,position:"relative"},children:[e.jsx("img",{src:R,alt:"Preview",style:{maxWidth:"100%",maxHeight:180,borderRadius:8,border:"1px solid #e5e7eb",display:"block"}}),e.jsx("button",{type:"button",onClick:()=>{A(null),o(null),u.current&&(u.current.value="")},style:{position:"absolute",top:4,right:4,background:"rgba(0,0,0,0.55)",color:"#fff",border:"none",borderRadius:"50%",width:24,height:24,cursor:"pointer",fontSize:14,lineHeight:"24px",textAlign:"center"},children:"Ã"}),e.jsxs("div",{style:{fontSize:11,color:"#6b7280",marginTop:4},children:[I?.name," · ",(I?.size/1024).toFixed(0)," KB"]})]}):e.jsxs("label",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,padding:"20px 16px",borderRadius:8,border:"2px dashed #d1d5db",cursor:"pointer",color:"#9ca3af",fontSize:13,background:"#fafafa"},children:[e.jsx(Xe,{size:24,color:"#9ca3af"}),e.jsx("span",{children:"Clique para selecionar imagem"}),e.jsx("span",{style:{fontSize:11},children:"JPG, PNG, WEBP · máx. 10 MB"}),e.jsx("input",{ref:u,type:"file",accept:"image/*",style:{display:"none"},onChange:ve})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{style:{fontWeight:600,fontSize:13,display:"block",marginBottom:6},children:s.acao==="chave_invalida"?"Motivo / instrução para o freelancer (opcional)":"Nota interna (opcional)"}),e.jsx("textarea",{className:"form-control",style:{resize:"vertical",minHeight:70,width:"100%",boxSizing:"border-box",padding:8,fontSize:13},value:C.adminNota,onChange:a=>P(c=>({...c,adminNota:a.target.value})),placeholder:s.acao==="chave_invalida"?"Ex: Chave não encontrada, verifique se está no seu nome...":"Observações sobre este pagamento..."})]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:16},children:[e.jsx("button",{className:"btn btn-ghost",onClick:()=>g(null),children:"Voltar"}),e.jsx("button",{className:`btn ${we.has(s.acao)?"btn-ghost":"btn-primary"}`,style:{display:"inline-flex",alignItems:"center",gap:6,...Ae[s.acao]||{}},disabled:S,onClick:()=>Se(s.saque._id,s.acao),children:S?e.jsxs(e.Fragment,{children:[e.jsx(Be,{size:14})," Salvandoâ¦"]}):Ie[s.acao]||"Confirmar"})]})]})})]})]})}export{na 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.