import{j as e,cM as i,U as u,am as x,I as n}from"./v_7_4_2_12_5cc5c70e-17b9-46d5-a61c-750829962ec510.js";import{u as h}from"./v_7_4_2_12_5cc5c70e-17b9-46d5-a61c-750829962ec519.js";import{q as f}from"./v_7_4_2_12_5cc5c70e-17b9-46d5-a61c-750829962ec523.js";import{d as g}from"./v_7_4_2_12_5cc5c70e-17b9-46d5-a61c-750829962ec5156.js";import{V as w}from"./v_7_4_2_12_5cc5c70e-17b9-46d5-a61c-750829962ec518.js";import"./v_7_4_2_12_5cc5c70e-17b9-46d5-a61c-750829962ec58.js";import"./v_7_4_2_12_5cc5c70e-17b9-46d5-a61c-750829962ec54.js";import"./v_7_4_2_12_5cc5c70e-17b9-46d5-a61c-750829962ec5.js";import"./v_7_4_2_12_5cc5c70e-17b9-46d5-a61c-750829962ec55.js";import"./v_7_4_2_12_5cc5c70e-17b9-46d5-a61c-750829962ec57.js";import"./v_7_4_2_12_5cc5c70e-17b9-46d5-a61c-750829962ec56.js";import"./v_7_4_2_12_5cc5c70e-17b9-46d5-a61c-750829962ec59.js";import"./v_7_4_2_12_5cc5c70e-17b9-46d5-a61c-750829962ec52.js";import"./v_7_4_2_12_5cc5c70e-17b9-46d5-a61c-750829962ec53.js";function L({rel:r}){const{label:m}=f(),{language:t}=h(),l=[{ico:e.jsx(i,{className:"w-5 h-5 text-[var(--secundaria)]"}),name:`${t.baixar_todos}`,type:"all"},{ico:e.jsx(i,{className:"w-5 h-5 text-[var(--primaria)]"}),name:`${t.baixar_com_falha}`,type:"error"},{ico:e.jsx(i,{className:"w-5 h-5 text-[var(--terciaria)]"}),name:`${t.baixar_com_sucesso}`,type:"success"}],p=async o=>{let s=[];if(o==="all"?s=r.send.map(a=>({id:a.phone,name:a.nome,status:a.status})):o==="success"?s=r.send.filter(a=>a.status==="Enviado").map(a=>({id:a.phone,name:a.nome,status:a.status})):s=r.send.filter(a=>a.status==="Erro").map(a=>({id:a.phone,name:a.nome,status:a.status})),s.length===0){n({type:"Error",message:`${t.relatorio_vazio}`,position:"top-right"});return}const c={contacts:s,labelName:m.nameID,type:o};try{const a=await fetch(`${w.backend_utils}api/XLSX/exportrelatorio`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!a.ok)throw new Error("Erro ao enviar dados para o servidor");const d=await a.json();g(d.XLSXbase64,`${m.nameID}_relatorio_${o}.xlsx`),n({type:"Success",message:`${t.contatos_exportados}`,position:"top-right"})}catch(a){console.error("Erro ao exportar relatório:",a),n({type:"Error",message:t.erroEnvio,position:"top-right"})}};return e.jsxs("div",{className:"bugiwsl0 fooq7fky",children:[e.jsx("h2",{className:"px-2",children:u.MillisToFormattedDate(parseInt(r.id))}),l.map((o,s)=>e.jsx("span",{children:e.jsx(x,{content:o.name,icon:o.ico,setFunction:()=>p(o.type),stroke:"1"})},s))]})}export{L as default};
