import{j as e}from"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a71.js";import{u}from"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a7120.js";import{s as x}from"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a7124.js";import{d as h}from"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a71156.js";import{dd as i,U as f,ao as g,I as n}from"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a7111.js";import{V as w}from"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a7119.js";import"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a718.js";import"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a717.js";import"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a719.js";import"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a716.js";import"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a714.js";import"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a713.js";import"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a712.js";import"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a7110.js";function L({rel:r}){const{label:m}=x(),{language:t}=u(),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 a=>{let s=[];if(a==="all"?s=r.send.map(o=>({id:o.phone,name:o.nome,status:o.status})):a==="success"?s=r.send.filter(o=>o.status==="Enviado").map(o=>({id:o.phone,name:o.nome,status:o.status})):s=r.send.filter(o=>o.status==="Erro").map(o=>({id:o.phone,name:o.nome,status:o.status})),s.length===0){n({type:"Error",message:`${t.relatorio_vazio}`,position:"top-right"});return}const c={contacts:s,labelName:m.nameID,type:a};try{const o=await fetch(`${w.backend_utils}api/XLSX/exportrelatorio`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!o.ok)throw new Error("Erro ao enviar dados para o servidor");const d=await o.json();h(d.XLSXbase64,`${m.nameID}_relatorio_${a}.xlsx`),n({type:"Success",message:`${t.contatos_exportados}`,position:"top-right"})}catch(o){console.error("Erro ao exportar relatório:",o),n({type:"Error",message:t.erroEnvio,position:"top-right"})}};return e.jsxs("div",{className:"bugiwsl0 fooq7fky",children:[e.jsx("h2",{className:"px-2",children:f.MillisToFormattedDate(parseInt(r.id))}),l.map((a,s)=>e.jsx("span",{children:e.jsx(g,{content:a.name,icon:a.ico,setFunction:()=>p(a.type),stroke:"1"})},s))]})}export{L as default};
