import{j as r}from"./main.84523976.js";const a="reportes",h=async(s={})=>(await r.get(`${a}/salidas`,{params:s})).data,S=async(s={})=>(await r.get("dashboard/estadisticas",{params:s})).data,u=async(s={})=>(await r.get(`${a}/exportar-csv`,{params:s})).data,v=async s=>{await g(`${a}/salidas/ventas/${s}/pdf`,`salidas_venta_${s}.pdf`)},b=async(s={})=>{const t=new URLSearchParams;Object.entries(s).forEach(([o,e])=>{e!=null&&String(e).trim()!==""&&t.set(o,String(e))});const n=t.toString(),c=`${a}/salidas/exportar-pdf${n?`?${n}`:""}`;await g(c,`reporte_viajes_fotos_${new Date().toISOString().slice(0,10)}.pdf`)};async function g(s,t){var f,m;const n=window.localStorage.getItem("token"),c={}.VITE_API_URL||"/api",o=await fetch(`${c}/${s}`,{headers:{Authorization:n?`Bearer ${n}`:"",Accept:"application/pdf"}});if(!o.ok){const i=await o.json().catch(()=>({}));throw new Error((i==null?void 0:i.message)||((m=(f=i==null?void 0:i.errors)==null?void 0:f.sucursal)==null?void 0:m[0])||"No se pudo generar el PDF")}const e=await o.blob(),p=(o.headers.get("content-disposition")||"").match(/filename="?([^";]+)"?/i),l=(p==null?void 0:p[1])||t,d=document.createElement("a");d.href=URL.createObjectURL(e),d.download=l,d.click(),URL.revokeObjectURL(d.href)}const y=async(s={})=>(await r.get(`${a}/ventas/estadisticas`,{params:s})).data,_=async(s={})=>(await r.get(`${a}/ventas/exportar-excel`,{params:s})).data,x=async(s={})=>(await r.get(`${a}/ventas/movimientos-reporte`,{params:s})).data,R=async(s={})=>{const t=new URLSearchParams;Object.entries(s).forEach(([o,e])=>{e!=null&&String(e).trim()!==""&&t.set(o,String(e))});const n=t.toString(),c=`${a}/ventas/movimientos-reporte/pdf${n?`?${n}`:""}`;await g(c,`resumen_movimientos_ventas_${new Date().toISOString().slice(0,10)}.pdf`)},j=async(s={})=>(await r.get(`${a}/ventas/movimientos-reporte/csv`,{params:s})).data;export{h as a,v as b,y as c,b as d,u as e,x as f,S as g,_ as h,j as i,R as j};
