1import{_ as q}from"./De6l2Vv1.js";import{_ as H}from"./D9LKWYn9.js";import{c as G}from"./CxlASv4b.js";import{d as K,i as O,j as X,H as J,u as Q,a1 as W,h as k,r as Y,s as Z,c as r,b as e,a as x,w as A,f as t,t as a,G as g,g as d,e as w,I as ee,F as y,y as f,z as C,o as i,K as te,L as se,_ as oe}from"./C-pd9DEJ.js";import{u as re}from"./Duz9RtaY.js";import{u as ie}from"./DNik6tLO.js";const ne={class:"account-page"},ae={class:"account-container"},de={class:"account-main"},le={class:"account-header"},ce={key:0,class:"order-detail__loading"},ue={key:1,class:"order-detail__error"},_e={key:2,class:"order-detail"},pe={class:"order-detail__status-info"},ve={class:"order-detail__id"},he={class:"order-detail__header-meta"},ge={class:"order-detail__date"},me={key:0,class:"order-detail__tracking"},ke={class:"order-detail__tracking-info"},we={key:0,class:"order-detail__tracking-row"},ye={key:1,class:"order-detail__tracking-row"},fe={key:2,class:"order-detail__tracking-row"},be=["href"],xe={key:1,class:"order-detail__invoice"},Ce={class:"order-detail__invoice-info"},Se={key:0,class:"order-detail__tracking-row"},$e={key:1,class:"order-detail__tracking-row"},De={key:2,class:"order-detail__invoice-actions"},Ie=["href"],Ae=["href"],Ve={class:"order-detail__section"},je={class:"order-items"},Pe={class:"order-item__image"},Te=["src","alt"],Be={key:1,class:"order-item__placeholder"},Ee={class:"order-item__details"},Le={class:"order-item__name"},Ne={key:0,class:"order-item__variant"},Ue={key:1,class:"order-item__sku"},Re={key:2,class:"order-item__original-price"},Me={class:"order-item__qty"},ze={class:"order-item__price"},Fe={class:"order-detail__section"},qe={class:"order-totals"},He={key:0,class:"order-totals__row"},Ge={key:1,class:"order-totals__row"},Ke={key:2,class:"order-totals__row order-totals__row--discount"},Oe={class:"order-totals__row order-totals__row--total"},Xe={key:2,class:"order-detail__section"},Je={class:"order-address"},Qe={key:0,class:"order-address__name"},We={key:1},Ye={key:2},Ze={key:3,class:"order-detail__section"},et={class:"order-detail__payment"},tt={key:4,class:"order-detail__section"},st={class:"order-detail__notes"},ot={key:5,class:"order-detail__section"},rt={class:"order-reviews"},it={class:"review-item__product"},nt={class:"review-item__name"},at={key:0,class:"review-item__existing"},dt={class:"review-item__stars"},lt=["fill"],ct={key:0,class:"review-item__comment"},ut={key:1,class:"review-item__form"},_t={class:"review-item__stars review-item__stars--interactive"},pt=["onClick"],vt=["fill"],ht=["onUpdate:modelValue"],gt=["disabled","onClick"],mt={key:6,class:"order-detail__actions"},kt=K({__name:"[orderId]",setup(wt){const V=O(),j=X(),P=J(),m=re(),{storeName:T,formatPrice:v,requiresConfiguration:B}=Q(),S=k(()=>V.params.orderId),{data:o,error:$,status:E}=W(()=>`/api/auth/orders/${S.value}`,{server:!1,headers:k(()=>({}))},"$SU-S7dS5qS"),L=k(()=>E.value==="pending"),D=k(()=>$.value?$.value?.data?.error||"Error al cargar el pedido":null);function N(l){return new Date(l).toLocaleDateString("es-PE",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"})}function I(l){return new Date(l).toLocaleDateString("es-PE",{year:"numeric",month:"short",day:"numeric"})}const{addItem:U}=ie();function R(){if(!o.value)return;let l=0;const s=[];for(const c of o.value.items){if(c.productId&&B(c.productId)){s.push(c.name);continue}c.productId&&(U({productId:String(c.productId),variantId:c.variantId?String(c.variantId):void 0,name:c.name,price:c.price,image:c.image,sku:c.sku},c.quantity),l++)}s.length&&m.info(`Arma de nuevo en su ficha: ${s.join(", ")}.`,8e3),l>0&&(m.success(`${l} producto${l>1?"s":""} agregado${l>1?"s":""} al carrito`),j.push("/cart"))}const p=C([]),b=C(!1),u=C({});Y(o,async l=>{if(!(!l?.orderId||!P.isAuthenticated||b.value||l.paymentStatus!=="paid")){try{const s=await $fetch(`/api/auth/orders/${l.orderId}/reviews`,{});p.value=s.data??[];for(const c of p.value)c.has_review||(u.value[c.product_id]={rating:0,comment:"",submitting:!1})}catch{}b.value=!0}});function M(l,s){u.value[l]&&(u.value[l].rating=s)}async function z(l){const s=u.value[l];if(!(!s||s.rating===0||s.submitting)){s.submitting=!0;try{await $fetch("/api/auth/reviews",{method:"POST",headers:{},body:{product_id:l,order_id:o.value?.orderId,rating:s.rating,comment:s.comment||void 0}});const c=p.value.findIndex(h=>h.product_id===l);c>=0&&(p.value[c].has_review=!0,p.value[c].review={id:0,rating:s.rating,status:"pending",comment:s.comment}),delete u.value[l],m.success("Gracias por tu opinión. Será visible una vez aprobada.")}catch(c){const h=c?.data?.message||c?.data?.error||"Error al enviar la opinión";m.error(h)}finally{s.submitting=!1}}}const F={pending:"Pendiente de aprobacion",approved:"Publicada",rejected:"Rechazada"};return Z({title:()=>`Pedido ${S.value} | ${T.value}`}),(l,s)=>{const c=q,h=H;
1return i(),r("div",ne,[e("div",ae,[x(c),e("main",de,[e("div",le,[x(h,{to:"/mis-compras",class:"order-detail__back"},{default:A(()=>[...s[0]||(s[0]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("polyline",{points:"15 18 9 12 15 6"})],-1),w(" Volver a mis compras ",-1)])]),_:1}),s[1]||(s[1]=e("h1",{class:"account-title"},"Detalle del pedido",-1))]),t(L)?(i(),r("div",ce,[...s[2]||(s[2]=[e("div",{class:"spinner"},null,-1),e("p",null,"Cargando pedido...",-1)])])):t(D)?(i(),r("div",ue,[e("p",null,a(t(D)),1),x(h,{to:"/mis-compras",class:"btn btn--primary btn--sm"},{default:A(()=>[...s[3]||(s[3]=[w("Volver",-1)])]),_:1})])):t(o)?(i(),r("div",_e,[e("div",{class:g(["order-detail__status-card",`order-detail__status-card--${t(o).status}`])},[e("div",pe,[e("span",{class:g(["order-status",`order-status--${t(o).status}`])},a(t(o).statusText),3),e("span",ve,a(t(o).id),1)]),e("div",he,[e("span",ge,a(N(t(o).date)),1),t(o).paymentStatusText?(i(),r("span",{key:0,class:g(["order-detail__payment-badge",`order-detail__payment-badge--${t(o).paymentStatus}`])},a(t(o).paymentStatusText),3)):d("",!0)])],2),t(o).shipping_info?.trackingCode||t(o).shipping_info?.courier?(i(),r("div",me,[s[8]||(s[8]=e("h3",null,"Seguimiento del envÃo",-1)),e("div",ke,[t(o).shipping_info.courier?(i(),r("div",we,[s[4]||(s[4]=e("span",{class:"order-detail__tracking-label"},"Courier:",-1)),e("strong",null,a(t(o).shipping_info.courier.name),1)])):d("",!0),t(o).shipping_info.trackingCode?(i(),r("div",ye,[s[5]||(s[5]=e("span",{class:"order-detail__tracking-label"},"N. de tracking:",-1)),e("strong",null,a(t(o).shipping_info.trackingCode),1)])):d("",!0),t(o).shipping_info.shippedDate?(i(),r("div",fe,[s[6]||(s[6]=e("span",{class:"order-detail__tracking-label"},"Fecha de envÃo:",-1)),e("span",null,a(I(t(o).shipping_info.shippedDate)),1)])):d("",!0),t(o).shipping_info.trackingUrl?(i(),r("a",{key:3,href:t(o).shipping_info.trackingUrl,target:"_blank",rel:"noopener",class:"btn btn--secondary btn--sm"},[...s[7]||(s[7]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e("polyline",{points:"15 3 21 3 21 9"}),e("line",{x1:"10",y1:"14",x2:"21",y2:"3"})],-1),w(" Rastrear envÃo ",-1)])],8,be)):d("",!0)])])):d("",!0),t(o).billing?(i(),r("div",xe,[s[12]||(s[12]=e("h3",null,"Comprobante electrónico",-1)),e("div",Ce,[t(o).billing.documentCode?(i(),r("div",Se,[s[9]||(s[9]=e("span",{class:"order-detail__tracking-label"},"Documento:",-1)),e("strong",null,a(t(o).billing.documentCode),1)])):d("",!0),t(o).billing.date?(i(),r("div",$e,[s[10]||(s[10]=e("span",{class:"order-detail__tracking-label"},"Fecha:",-1)),e("span",null,a(I(t(o).billing.date)),1)])):d("",!0),t(o).billing.pdfUrl?(i(),r("div",De,[e("a",{href:t(o).billing.pdfUrl,target:"_blank",rel:"noopener",class:"btn btn--secondary btn--sm"},[...s[11]||(s[11]=[ee('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-5ee4212e><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" data-v-5ee4212e></path><polyline points="14 2 14 8 20 8" data-v-5ee4212e></polyline><line x1="16" y1="13" x2="8" y2="13" data-v-5ee4212e></line><line x1="16" y1="17" x2="8" y2="17" data-v-5ee4212e></line><polyline points="10 9 9 9 8 9" data-v-5ee4212e></polyline></svg> Ver PDF ',2)])],8,Ie),t(o).billing.xmlUrl?(i(),r("a",{key:0,href:t(o).billing.xmlUrl,target:"_blank",rel:"noopener",class:"btn btn--outline btn--sm"}," Descargar XML ",8,Ae)):d("",!0)])):d("",!0)])])):d("",!0),e("div",Ve,[e("h3",null,"Productos ("+a(t(o).items.length)+")",1),e("div",je,[(i(!0),r(y,null,f(t(o).items,n=>(i(),r("div",{key:n.id||n.name,class:"order-item"},[e("div",Pe,[n.image?(i(),r("img",{key:0,src:("cdnThumb"in l?l.cdnThumb:t(G))(n.image,160),alt:n.name,loading:"lazy"},null,8,Te)):(i(),r("div",Be,[...s[13]||(s[13]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1","stroke-linecap":"round","stroke-linejoin":"round"},[e("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),e("polyline",{points:"21 15 16 10 5 21"})],-1)])]))]),e("div",Ee,[e("span",Le,a(n.name),1),n.variant?(i(),r("span",Ne,a(n.variant),
11)):d("",!0),n.sku?(i(),r("span",Ue,"SKU: "+a(n.sku),1)):d("",!0),n.originalPrice&&n.originalPrice>n.price?(i(),r("span",Re,a(t(v)(n.originalPrice)),1)):d("",!0)]),e("div",Me,"x"+a(n.quantity),1),e("div",ze,a(t(v)((n.subtotal??n.price*n.quantity)||0)),1)]))),128))])]),e("div",Fe,[s[17]||(s[17]=e("h3",null,"Resumen",-1)),e("div",qe,[t(o).subtotal?(i(),r("div",He,[s[14]||(s[14]=e("span",null,"Subtotal",-1)),e("span",null,a(t(v)(t(o).subtotal)),1)])):d("",!0),(t(o).shipping??0)>0?(i(),r("div",Ge,[s[15]||(s[15]=e("span",null,"EnvÃo",-1)),e("span",null,a(t(v)(t(o).shipping)),1)])):d("",!0),(t(o).discount??0)>0?(i(),r("div",Ke,[e("span",null,"Descuento"+a(t(o).couponCode?` (${t(o).couponCode})`:""),1),e("span",null,"-"+a(t(v)(t(o).discount)),1)])):d("",!0),e("div",Oe,[s[16]||(s[16]=e("span",null,"Total",-1)),e("span",null,a(t(v)(t(o).total??0)),1)])])]),t(o).shippingAddress?(i(),r("div",Xe,[e("h3",null,a(t(o).deliveryMethod==="pickup"?"Recojo en tienda":"Dirección de envÃo"),1),e("div",Je,[t(o).shippingAddress.recipientName?(i(),r("p",Qe,a(t(o).shippingAddress.recipientName),1)):d("",!0),e("p",null,a(t(o).shippingAddress.address),1),t(o).shippingAddress.reference?(i(),r("p",We,"Ref: "+a(t(o).shippingAddress.reference),1)):d("",!0),e("p",null,a([t(o).shippingAddress.district,t(o).shippingAddress.province,t(o).shippingAddress.department].filter(
1Boolean).join(", ")),1),t(o).shippingAddress.phone?(i(),r("p",Ye,"Tel: "+a(t(o).shippingAddress.phone),1)):d("",!0)])])):d("",!0),t(o).paymentMethod?(i(),r("div",Ze,[s[18]||(s[18]=e("h3",null,"Método de pago",-1)),e("p",et,a(t(o).paymentMethod),1)])):d("",!0),t(o).notes?(i(),r("div",tt,[s[19]||(s[19]=e("h3",null,"Notas",-1)),e("p",st,a(t(o).notes),1)])):d("",!0),t(b)&&t(p).length>0&&t(o).paymentStatus==="paid"?(i(),r("div",ot,[s[22]||(s[22]=e("h3",null,"Califica tus productos",-1)),e("div",rt,[(i(!0),r(y,null,f(t(p),n=>(i(),r("div",{key:n.product_id,class:"review-item"},[e("div",it,[e("span",nt,a(n.product_name),1)]),n.has_review&&n.review?(i(),r("div",at,[e("div",dt,[(i(),r(y,null,f(5,_=>e("svg",{key:_,xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:_<=n.review.rating?"currentColor":"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:g(_<=n.review.rating?"star--filled":"star--empty")},[...s[20]||(s[20]=[e("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"},null,-1)])],10,lt)),64))]),n.review.comment?(i(),r("p",ct,a(n.review.comment),1)):d("",!0),e("span",{class:g(["review-item__status",`review-item__status--${n.review.status}`])},a(F[n.review.status]||n.review.status),3)])):t(u)[n.product_id]?(i(),r("div",ut,[e("div",_t,[(i(),r(y,null,f(5,_=>e("button",{key:_,type:"button",onClick:yt=>M(n.product_id,_),class:g(["star-btn",{"star-btn--active":_<=t(u)[n.product_id].rating}])},[(i(),r("svg",{xmlns:"http://www.w3.org/2000/svg",width:"22",height:"22",viewBox:"0 0 24 24",fill:_<=t(u)[n.product_id].rating?"currentColor":"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[...s[21]||(s[21]=[e("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"},null,-1)])],8,vt))],10,pt)),64))]),te(e("textarea",{"onUpdate:modelValue":_=>t(u)[n.product_id].comment=_,class:"review-item__textarea",placeholder:"Escribe tu opinión (opcional)",rows:"2"},null,8,ht),[[se,t(u)[n.product_id].comment]]),e("button",{class:"btn btn--primary btn--sm",disabled:t(u)[n.product_id].rating===0||t(u)[n.product_id].submitting,onClick:_=>z(n.product_id)},a(t(u)[n.product_id].submitting?"Enviando...":"Enviar opinión"),9,gt)])):d("",!0)]))),128))])])):d("",!0),t(o).status!=="cancelled"?(i(),r("div",mt,[e("button",{class:"btn btn--primary",onClick:R},[...s[23]||(s[23]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("polyline",{points:"23 4 23 10 17 10"}),e("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})],-1),w(" Volver a pedir ",-1)])])])):d("",!0)])):d("",!0)])])])}}}),Dt=oe(kt,[["__scopeId","data-v-5ee4212e"]]);export{Dt 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.