import{_ as N,n as S,E 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,s as E,t as i}from"./index-3TWHIczS.js";import{B as w}from"./BarberLayout-DV6e9h8s.js";import{L as A}from"./LoadingSpinner-COK2j8hC.js";import{E as B}from"./ErrorMessage-BHF5LlOC.js";import"./LogoutButton-UlpRNmzs.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"},H={class:"exp-modal card"},I={class:"exp-modal-head"},j={class:"exp-modal-title"},G={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),v=o(""),g=o(""),m=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",m.value=[],_.value=[],v.value="",y.value=!0,h.value=!0;try{const{data:t}=await C.getClientExpediente(s);m.value=Array.isArray(t.photos)?t.photos:[],_.value=Array.isArray(t.appointments)?t.appointments:[]}catch(t){v.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",H,[e("div",I,[e("h3",j,"Expediente: "+i(g.value),1),e("button",{type:"button",class:"exp-close","aria-label":"Cerrar",onClick:k},"✕")]),e("div",G,[h.value?(a(),p(A,{key:0})):v.value?(a(),p(B,{key:1,message:v.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)),m.value.length?(a(),l("div",O,[(a(!0),l(f,null,E(m.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};
