1import{_ as D}from"./BsqTxom4.js";import{a9 as z,u as I,s as L,r as N,q as S,c as i,b as e,a as y,h,e as _,F as w,x as v,j as V,_ as q,o as l,t as n,p as H,i as p}from"#entry";const T={class:"mb-8"},U={class:"flex justify-between items-center"},$={class:"space-y-6"},F={class:"flex justify-between items-start mb-4"},R={class:"text-lg font-semibold text-gray-900"},O={class:"text-sm text-gray-500"},G={key:0,class:"text-xs text-gray-400 font-mono mt-1"},J={class:"text-right"},K={class:"text-lg font-bold text-gray-900 mt-2"},Q={class:"mb-4"},W={class:"space-y-2"},X={class:"flex-1"},Y={class:"font-medium text-gray-900"},Z={class:"text-xs text-gray-600"},ee={class:"font-medium text-gray-900"},te={class:"flex items-center justify-between pt-4 border-t"},se={class:"flex items-center space-x-2"},oe={key:0,class:"flex items-center text-green-600 text-sm font-medium"},re={key:1,class:"flex items-center text-orange-600 text-sm font-medium"},ne={key:0,class:"text-center py-12 bg-white rounded-xl shadow-lg"},de=z({__name:"compras",setup(ae){I({title:"Mis Compras - AutoPiezas360",meta:[{name:"robots",content:"noindex, nofollow"}]});const d=L(),x=N([]),k=r=>r?new Intl.DateTimeFormat("es-CL",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(r)):"No disponible",C=r=>({approved:"bg-green-100 text-green-800",pending:"bg-yellow-100 text-yellow-800",in_process:"bg-blue-100 text-blue-800",rejected:"bg-red-100 text-red-800",refunded:"bg-purple-100 text-purple-800",cancelled:"bg-gray-100 text-gray-800"})[r]||"bg-gray-100 text-gray-800",M=r=>({approved:"Aprobado",pending:"Pendiente",in_process:"En Proceso",rejected:"Rechazado",refunded:"Reembolsado",cancelled:"Cancelado"})[r]||r,P=async()=>{try{const{$firestore:r}=V(),{collection:t,query:u,where:o,getDocs:a,orderBy:m}=await D(async()=>{const{collection:s,query:f,where:c,getDocs:j,orderBy:A}=await import("#entry").then(B=>B.aC);return{collection:s,query:f,where:c,getDocs:j,orderBy:A}},[],import.meta.url);if(!d.user?.uid&&!d.user?.email)return;const g=[];if(d.user?.uid){const s=u(t(r,"ventas"),o("userId","==",d.user.uid),m("createdAt","desc"));(await a(s)).forEach(c=>g.push({id:c.id,...c.data()}))}if(d.user?.email){const s=u(t(r,"ventas"),o("email","==",d.user.email),m("createdAt","desc"));(await a(s)).forEach(c=>g.push({id:c.id,...c.data()}))}const b=new Map;g.forEach(s=>b.set(s.id,s));const E=Array.from(b.values());x.value=E.map(s=>({id:s.id,numero:(s.id||"").substring(0,8).toUpperCase(),estado:s.estado||"pending",createdAt:s.createdAt?.toDate()||new Date,isPaid:s.isPaid||!1,total:s.total||0,paymentId:s.mercadopagoPaymentId,items:s.items||[]}))}catch(r){console.error("Error cargando compras:",r)}};return S(async()=>{await d.checkAuthState(),await P()}),(r,t)=>{const u=q;return l(),i("div",null,[e("div",T,[e("div",U,[t[1]||(t[1]=e("div",null,[e("h1",{class:"text-3xl font-bold text-gray-900"},"Mis Compras"),e("p",{class:"text-gray-600 mt-2"},"Historial de compras realizadas con MercadoPago")],-1)),y(u,{to:"/carrito",class:"px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors font-medium flex items-center space-x-2"},{default:h(()=>[...t[0]||(t[0]=[e("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z"})],-1),e("span",null,"Ir al Carrito",-1)])]),_:1})])]),e("div",$,[(l(!0),i(w,null,v(x.value,o=>(l(),i("div",{key:o.id,class:"bg-white rounded-xl shadow-lg p-6 border border-gray-100"},[e("div",F,[e("div",null,[e("h3",R,"Compra #"+n(o.numero),1),e("p",O,n(k(o.createdAt)),1),o.paymentId?(l(),i("p",G," ID Pago: "+n(o.paymentId),1)):_("",!0)]),e("div",J,[e("span",{class:H(["inline-flex px-3 py-1 text-sm font-medium rounded-full",C(o.estado)])},n(M(o.estado)),3),e("p",K,"$"+n(o.total.toLocaleString()),1)])]),e("div",Q,[t[2]||(t[2]=e("h4",{class:"text-sm font-medium text-gray-700 mb-2"},"Productos:",-1)),e("div",W,[(l(!0),i(w,null,v(o.items,(a,m)=>(l(),i("div",{key:m,class:"flex justify-between items-center text-sm bg-gray-50 p-3 rounded-lg"},[e("div",X,[e("p",Y,n(a.nombre),1),e("p",Z,n(a.marca)+" "+n(a.modelo)+" "+n(a.anio)+" - Cantidad: "+n(a.cantidad),1)]),e("p",ee,"$"+n(a.subtotal.toLocaleStr
1ing()),1)]))),128))])]),e("div",te,[e("div",se,[o.isPaid?(l(),i("span",oe,[...t[3]||(t[3]=[e("svg",{class:"w-5 h-5 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 13l4 4L19 7"})],-1),p(" Pagado ",-1)])])):(l(),i("span",re,[...t[4]||(t[4]=[e("svg",{class:"w-5 h-5 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})],-1),p(" Pendiente de Pago ",-1)])]))]),y(u,{to:`/compra/${o.id}`,class:"px-4 py-2 bg-blue-600 text-white text-sm rounded-lg hover:bg-blue-700 transition-colors"},{default:h(()=>[...t[5]||(t[5]=[p(" Ver Detalles ",-1)])]),_:1},8,["to"])])]))),128)),x.value.length===0?(l(),i("div",ne,[t[7]||(t[7]=e("svg",{class:"w-16 h-16 text-gray-400 mx-auto mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z"})],-1)),t[8]||(t[8]=e("h3",{class:"text-lg font-medium text-gray-900 mb-2"},"No tienes compras aún",-1)),t[9]||(t[9]=e("p",{class:"text-gray-500 mb-4"},"Explora nuestro catálogo y realiza tu primera compra",-1)),y(u,{to:"/",class:"inline-flex items-center px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors font-medium"},{default:h(()=>[...t[6]||(t[6]=[e("svg",{class:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})],-1),p(" Explorar Productos ",-1)])]),_:1})])):_("",!0)])])}}});export{de 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.