import"../chunks/Bzak7iHL.js";import{p as oa,s as i,f as da,a as c,b as la,k as ia,c as m,$ as va,d as e,r as t,t as b,l as a,e as p,v as N}from"../chunks/CiQWViEs.js";import{i as k}from"../chunks/CEkQpEF5.js";import{e as L}from"../chunks/EUGRfuDz.js";import{h as na}from"../chunks/DG4rvltU.js";import{a as u}from"../chunks/zaEOnEon.js";import{s as M}from"../chunks/Bbah6i2R.js";import{p as ca}from"../chunks/Iv4M5qa3.js";import{a as ma,f as O,i as pa}from"../chunks/C-TorKLD.js";import{r as xa}from"../chunks/S2plRkmd.js";var _a=m('<a role="tab"> <span> </span></a>'),fa=m('<p class="px-5 py-16 text-center text-slate-500"> </p>'),ba=m('<th class="px-4 py-3 font-semibold">Actas</th>'),ua=m('<span class="badge bg-emerald-100 text-emerald-800"> </span>'),ha=m('<span class="badge bg-red-100 text-red-700">Vencido</span>'),ga=m('<span class="badge bg-amber-100 text-amber-800">En préstamo</span>'),ya=m('<td class="px-4 py-3"><div class="flex gap-2 text-xs"><a class="font-medium text-brand-700 hover:underline" target="_blank">Entrega</a> <a class="font-medium text-brand-700 hover:underline" target="_blank">Recogida</a></div></td>'),ka=m('<tr class="hover:bg-slate-50"><td class="px-4 py-3"><a class="font-mono font-semibold text-brand-700 hover:underline"> </a> <span class="block text-xs text-slate-400"> </span></td><td class="px-4 py-3 font-medium text-slate-900"> </td><td class="px-4 py-3 text-slate-600"> </td><td class="px-4 py-3 text-slate-600"> </td><td class="px-4 py-3"><!></td><!></tr>'),wa=m('<div class="overflow-x-auto"><table class="w-full text-left text-sm"><thead class="border-b border-slate-200 bg-slate-50 text-xs uppercase text-slate-500"><tr><th class="px-4 py-3 font-semibold">Equipo</th><th class="px-4 py-3 font-semibold">Usuario</th><th class="px-4 py-3 font-semibold">Salida</th><th class="px-4 py-3 font-semibold">Prevista</th><th class="px-4 py-3 font-semibold">Estado</th><!></tr></thead><tbody class="divide-y divide-slate-100"></tbody></table></div>'),Ea=m('<div class="mb-6"><h1 class="text-2xl font-bold text-slate-900">Préstamos</h1> <p class="text-slate-600">Trazabilidad de entradas y salidas de equipos.</p></div> <div class="mb-4 flex flex-wrap gap-2" role="tablist"></div> <div class="card overflow-hidden"><!></div>',1);function Ha(R,v){oa(v,!0);const U=N(()=>{var d;return xa((d=ca.data.user)==null?void 0:d.role,"gestor")}),S=N(()=>[{key:"active",label:"Activos",count:v.data.counts.active??0},{key:"overdue",label:"Vencidos",count:v.data.counts.overdue??0},{key:"all",label:"Historial",count:v.data.counts.all_count??0}]);var V=Ea();na("1jj77xg",d=>{ia(()=>{va.title="Préstamos · Inventario EDUmind"})});var w=i(da(V),2);L(w,21,()=>a(S),d=>d.key,(d,r)=>{var n=_a(),_=e(n),f=i(_),E=e(f,!0);t(f),t(n),b(()=>{u(n,"href",`/loans?filter=${a(r).key??""}`),u(n,"aria-selected",v.data.filter===a(r).key),M(n,1,`rounded-lg px-4 py-2 text-sm font-semibold transition-colors ${v.data.filter===a(r).key?"bg-brand-700 text-white":"bg-white text-slate-700 ring-1 ring-slate-200 hover:bg-slate-50"}`),p(_,`${a(r).label??""} `),M(f,1,`ml-1 rounded-full px-1.5 text-xs ${v.data.filter===a(r).key?"bg-white/20":a(r).key==="overdue"&&a(r).count>0?"bg-red-100 text-red-700":"bg-slate-100 text-slate-600"}`),p(E,a(r).count)}),c(d,n)}),t(w);var z=i(w,2),B=e(z);{var C=d=>{var r=fa(),n=e(r,!0);t(r),b(()=>p(n,v.data.filter==="overdue"?"No hay préstamos vencidos. 👍":v.data.filter==="active"?"No hay préstamos activos.":"Todavía no hay movimientos.")),c(d,r)},F=d=>{var r=wa(),n=e(r),_=e(n),f=e(_),E=i(e(f),5);{var G=x=>{var s=ba();c(x,s)};k(E,x=>{a(U)&&x(G)})}t(f),t(_);var H=i(_);L(H,21,()=>v.data.loans,x=>x.id,(x,s)=>{var D=ka(),A=e(D),h=e(A),J=e(h,!0);t(h);var I=i(h,2),K=e(I,!0);t(I),t(A);var P=i(A),Q=e(P,!0);t(P);var T=i(P),W=e(T,!0);t(T);var j=i(T),X=e(j,!0);t(j);var q=i(j),Y=e(q);{var Z=o=>{var l=ua(),g=e(l);t(l),b(y=>p(g,`Devuelto ${y??""}`),[()=>O(a(s).returned_at)]),c(o,l)},$=o=>{var l=ha();c(o,l)},aa=N(()=>pa(a(s).due_at,a(s).returned_at)),ta=o=>{var l=ga();c(o,l)};k(Y,o=>{a(s).returned_at?o(Z):a(aa)?o($,1):o(ta,-1)})}t(q);var ea=i(q);{var ra=o=>{var l=ya(),g=e(l),y=e(g),sa=i(y,2);t(g),t(l),b(()=>{u(y,"href",`/loans/${a(s).id??""}/document?type=entrega`),u(sa,"href",`/loans/${a(s).id??""}/document?type=recogida`)}),c(o,l)};k(ea,o=>{a(U)&&o(ra)})}t(D),b((o,l)=>{u(h,"href",`/devices/${a(s).device_id??""}`),p(J,a(s).device_code),p(K,a(s).device_name||a(s).category_name||""),p(Q,a(s).borrower_name||"—"),p(W,o),p(X,l)},[()=>ma(a(s).checkout_at),()=>a(s).due_at?O(a(s).due_at):"—"]),c(x,D)}),t(H),t(n),t(r),c(d,r)};k(B,d=>{v.data.loans.length===0?d(C):d(F,-1)})}t(z),c(R,V),la()}export{Ha as component};
