import{_ as N,m as S,G as C,f as p,i as $,r as o,o as a,b as e,g as r,c as l,F as f,x as E,t as i}from"./index-CWMS7dAC.js";import{B as w}from"./BarberLayout-CvW4_RQY.js";import{L as A}from"./LoadingSpinner-C87W1wg0.js";import{E as B}from"./ErrorMessage-Bb6Uk6jv.js";import"./LogoutButton-D6TM46MH.js";const F={key:2,class:"card empty-card"},M={key:3,class:"card table-wrap"},P={class:"data-table"},T={class:"td-actions-col"},q=["onClick"],z={key:4,class:"exp-overlay"},G={class:"exp-modal card"},H={class:"exp-modal-head"},I={class:"exp-modal-title"},j={class:"exp-modal-body"},J={key:0,class:"exp-summary"},K={key:1,class:"exp-empty"},O={key:2,class:"exp-photo-grid"},Q={class:"exp-photo-wrap"},R=["src","alt"],U={class:"exp-photo-meta"},W={key:0},X={key:1},Y={__name:"ClientesView",setup(Z){const d=o(!1),c=o(""),u=o([]),y=o(!1),h=o(!1),m=o(""),g=o(""),v=o([]),_=o([]);function L(n){if(!n)return"—";const s=String(n).slice(0,10),[t,x,b]=s.split("-");return b&&x&&t?`${b}/${x}/${t}`:s}function V(n){return n?new Date(n).toLocaleDateString("es-ES",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):""}async function D(n){const s=n.client?.id;if(s){g.value=n.client?.name||"Cliente",v.value=[],_.value=[],m.value="",y.value=!0,h.value=!0;try{const{data:t}=await C.getClientExpediente(s);v.value=Array.isArray(t.photos)?t.photos:[],_.value=Array.isArray(t.appointments)?t.appointments:[]}catch(t){m.value=t.response?.data?.message||"No se pudo cargar el expediente"}finally{h.value=!1}}}function k(){y.value=!1}return S(async()=>{d.value=!0,c.value="";try{const n=await C.getClientHistory();u.value=Array.isArray(n.data)?n.data:[]}catch(n){c.value=n.response?.data?.message||"No se pudo cargar el historial",u.value=[]}finally{d.value=!1}}),(n,s)=>(a(),p(w,null,{default:$(()=>[s[3]||(s[3]=e("h2",{style:{margin:"0 0 8px 0","font-size":"20px"}},"Clientes",-1)),s[4]||(s[4]=e("p",{class:"intro"}," Clientes con al menos una cita contigo (activas o históricas, sin canceladas). Podés abrir el expediente para ver todas las fotos del cliente, aunque otro profesional haya tomado la cita. ",-1)),d.value?(a(),p(A,{key:0})):r("",!0),c.value?(a(),p(B,{key:1,message:c.value},null,8,["message"])):r("",!0),!d.value&&!c.value&&u.value.length===0?(a(),l("div",F,[...s[0]||(s[0]=[e("p",null,"Todavía no hay movimiento registrado.",-1)])])):!d.value&&u.value.length?(a(),l("div",M,[e("table",P,[s[1]||(s[1]=e("thead",null,[e("tr",null,[e("th",null,"Cliente"),e("th",null,"Teléfono"),e("th",null,"Visitas"),e("th",null,"Última cita"),e("th",{class:"th-actions-col"},"Expediente")])],-1)),e("tbody",null,[(a(!0),l(f,null,E(u.value,t=>(a(),l("tr",{key:t.client?.id},[e("td",null,i(t.client?.name||"—"),1),e("td",null,i(t.client?.phone||"—"),1),e("td",null,i(t.visit_count),1),e("td",null,i(L(t.last_appointment_date)),1),e("td",T,[e("button",{type:"button",class:"btn btn-outline btn-sm",onClick:x=>D(t)},"Ver",8,q)])]))),128))])])])):r("",!0),y.value?(a(),l("div",z,[e("div",{class:"exp-backdrop",onClick:k}),e("div",G,[e("div",H,[e("h3",I,"Expediente: "+i(g.value),1),e("button",{type:"button",class:"exp-close","aria-label":"Cerrar",onClick:k},"✕")]),e("div",j,[h.value?(a(),p(A,{key:0})):m.value?(a(),p(B,{key:1,message:m.value},null,8,["message"])):(a(),l(f,{key:2},[_.value.length?(a(),l("p",J,i(_.value.length)+" cita(s) en historial (todos los profesionales). ",1)):r("",!0),s[2]||(s[2]=e("h4",{class:"exp-section-title"},"Fotos",-1)),v.value.length?(a(),l("div",O,[(a(!0),l(f,null,E(v.value,t=>(a(),l("div",{key:t.id,class:"exp-photo-cell"},[e("div",Q,[e("img",{src:t.url,alt:`Foto ${t.id}`},null,8,R)]),e("div",U,[e("span",null,i(V(t.taken_at)),1),t.appointment?.barber?.user?(a(),l("span",W,i(t.appointment.barber.user.name),1)):r("",!0),t.appointment?.service?(a(),l("span",X,i(t.appointment.service.name),1)):r("",!0)])]))),128))])):(a(),l("div",K,"Sin fotos en el expediente."))],64))])])])):r("",!0)]),_:1}))}},le=N(Y,[["__scopeId","data-v-5d25d66c"]]);export{le as default};
