import"./Bzak7iHL.js";import{p as te,t as C,a as L,b as se,s as l,d as t,e as n,l as R,c as N,v as k,r as a,n as c}from"./CiQWViEs.js";import{i as re}from"./CEkQpEF5.js";import{e as le}from"./EUGRfuDz.js";import{a as ie,e as oe}from"./BblGoPVU.js";import{s as q,b as H,r as d,c as ne}from"./zaEOnEon.js";import{p as u}from"./Du-gvTYZ.js";import{R as ce}from"./S2plRkmd.js";var de=N('<p class="rounded-lg bg-red-50 px-3 py-2 text-sm font-medium text-red-700" role="alert"> </p>'),ve=N("<option> </option>"),pe=N('<form method="POST" class="card space-y-5 p-6"><!> <div class="grid gap-5 sm:grid-cols-2"><div><label class="label" for="name">Nombre completo *</label> <input class="input" id="name" name="name" required=""/></div> <div><label class="label" for="identifier">Identificador (DNI, nº empleado…)</label> <input class="input" id="identifier" name="identifier"/></div></div> <div><label class="label" for="email">Correo (usuario de acceso)</label> <input class="input" id="email" name="email" type="email"/> <p class="mt-1 text-xs text-slate-500">Necesario solo si el usuario va a iniciar sesión en la app.</p></div> <div class="grid gap-5 sm:grid-cols-2"><div><label class="label" for="role">Rol</label> <select class="input" id="role" name="role"></select> <p class="mt-1 text-xs text-slate-500">Consulta: solo ver · Gestor: préstamos y etiquetas · Admin: todo.</p></div> <div><label class="label" for="password"> </label> <input class="input" id="password" name="password" type="password" minlength="8" autocomplete="new-password"/> <p class="mt-1 text-xs text-slate-500"> </p></div></div> <div class="flex flex-wrap gap-6"><label class="flex items-center gap-2 text-sm text-slate-700"><input type="checkbox" name="can_borrow" class="h-4 w-4 rounded border-slate-300 text-brand-700"/> Puede recibir equipos en préstamo</label> <label class="flex items-center gap-2 text-sm text-slate-700"><input type="checkbox" name="active" class="h-4 w-4 rounded border-slate-300 text-brand-700"/> Cuenta activa</label></div> <div class="flex gap-2"><button class="btn-primary" type="submit"> </button> <a class="btn-secondary" href="/users">Cancelar</a></div></form>');function we(J,o){te(o,!0);let i=u(o,"user",3,null),K=u(o,"values",3,null),A=u(o,"error",3,null),M=u(o,"submitLabel",3,"Guardar");const Q=["consulta","gestor","admin"],v=(e,s="")=>{var r;return((r=K())==null?void 0:r[e])??s},W=k(()=>{var e;return((e=i())==null?void 0:e.role)??v("role","consulta")}),X=k(()=>i()?i().can_borrow===1:!0),Y=k(()=>i()?i().active===1:!0);var p=pe(),B=t(p);{var Z=e=>{var s=de(),r=t(s,!0);a(s),C(()=>n(r,A())),L(e,s)};re(B,e=>{A()&&e(Z)})}var b=l(B,2),_=t(b),D=l(t(_),2);d(D),a(_);var E=l(_,2),G=l(t(E),2);d(G),a(E),a(b);var f=l(b,2),I=l(t(f),2);d(I),c(2),a(f);var x=l(f,2),g=t(x),O=l(t(g),2);le(O,20,()=>Q,e=>e,(e,s)=>{var r=ve(),m=t(r,!0);a(r);var z={};C(()=>{ne(r,R(W)===s),n(m,ce[s]),z!==(z=s)&&(r.value=(r.__value=s)??"")}),L(e,r)}),a(O),c(2),a(g);var P=l(g,2),h=t(P),$=t(h,!0);a(h);var U=l(h,4),ee=t(U,!0);a(U),a(P),a(x);var w=l(x,2),y=t(w),j=t(y);d(j),c(),a(y);var F=l(y,2),S=t(F);d(S),c(),a(F),a(w);var T=l(w,2),V=t(T),ae=t(V,!0);a(V),c(2),a(T),a(p),ie(p,e=>{var s;return(s=oe)==null?void 0:s(e)}),C((e,s,r)=>{var m;q(D,e),q(G,s),q(I,r),n($,(m=i())!=null&&m.has_login?"Restablecer contraseña":"Contraseña de acceso"),n(ee,i()?"Déjalo vacío para no cambiarla.":"Vacío = usuario sin acceso (solo préstamos)."),H(j,R(X)),H(S,R(Y)),n(ae,M())},[()=>{var e;return((e=i())==null?void 0:e.name)??v("name")},()=>{var e;return((e=i())==null?void 0:e.identifier)??v("identifier")},()=>{var e;return((e=i())==null?void 0:e.email)??v("email")}]),L(J,p),se()}export{we as U};
