import"./Bzak7iHL.js";import{p as ia,t as b,a as _,b as ra,s as t,d as r,e as f,c as E,r as l,l as m,n as q,m as sa}from"./CiQWViEs.js";import{i as oa}from"./CEkQpEF5.js";import{e as W}from"./EUGRfuDz.js";import{a as da,e as na}from"./BblGoPVU.js";import{s as n,c as X,r as c}from"./zaEOnEon.js";import{p as g}from"./Du-gvTYZ.js";var va=E('<p class="rounded-lg bg-red-50 px-3 py-2 text-sm font-medium text-red-700" role="alert"> </p>'),Y=E("<option> </option>"),ca=E('<form method="POST" class="card space-y-5 p-6"><!> <div class="grid gap-5 sm:grid-cols-2"><div><label class="label" for="category_id">Categoría / tipología *</label> <select class="input" id="category_id" name="category_id" required=""><option>Selecciona…</option><!></select></div> <div><label class="label" for="code">Código del equipo</label> <input class="input font-mono" id="code" name="code" placeholder="Se genera automáticamente (ej. POR-0001)"/> <p class="mt-1 text-xs text-slate-500">Déjalo vacío para autogenerar según la categoría.</p></div></div> <div><label class="label" for="name">Nombre / descripción</label> <input class="input" id="name" name="name" placeholder="Portátil aula 3B"/></div> <div class="grid gap-5 sm:grid-cols-3"><div><label class="label" for="brand">Marca</label> <input class="input" id="brand" name="brand"/></div> <div><label class="label" for="model">Modelo</label> <input class="input" id="model" name="model"/></div> <div><label class="label" for="serial">Nº de serie</label> <input class="input" id="serial" name="serial"/></div></div> <div class="grid gap-5 sm:grid-cols-2"><div><label class="label" for="location">Ubicación habitual</label> <input class="input" id="location" name="location" placeholder="Aula TIC"/></div> <div><label class="label" for="status">Estado</label> <select class="input" id="status" name="status"></select> <p class="mt-1 text-xs text-slate-500">El estado «Prestado» se gestiona desde préstamos.</p></div></div> <div><label class="label" for="notes">Notas</label> <textarea class="input" id="notes" name="notes" rows="3"></textarea></div> <div class="flex gap-2"><button class="btn-primary" type="submit"> </button> <a class="btn-secondary" href="/devices">Cancelar</a></div></form>');function xa(Z,v){ia(v,!0);let L=g(v,"device",3,null),k=g(v,"values",3,null),O=g(v,"error",3,null),$=g(v,"submitLabel",3,"Guardar");const s=(i,a="")=>{var e,o;return((e=k())==null?void 0:e[i])??(((o=L())==null?void 0:o[i])!=null?String(L()[i]):a)};var u=ca(),T=r(u);{var aa=i=>{var a=va(),e=r(a,!0);l(a),b(()=>f(e,O())),_(i,a)};oa(T,i=>{O()&&i(aa)})}var x=t(T,2),h=r(x),w=t(r(h),2),y=r(w);y.value=y.__value="";var ea=t(y);W(ea,17,()=>v.categories,i=>i.id,(i,a)=>{var e=Y(),o=r(e);l(e);var d={};b(p=>{X(e,p),f(o,`${m(a).name??""} (${m(a).code??""})`),d!==(d=m(a).id)&&(e.value=(e.__value=m(a).id)??"")},[()=>String(m(a).id)===s("category_id")]),_(i,e)}),l(w),l(h);var A=t(h,2),B=t(r(A),2);c(B),q(2),l(A),l(x);var D=t(x,2),F=t(r(D),2);c(F),l(D);var S=t(D,2),j=r(S),G=t(r(j),2);c(G),l(j);var C=t(j,2),I=t(r(C),2);c(I),l(C);var R=t(C,2),U=t(r(R),2);c(U),l(R),l(S);var P=t(S,2),M=r(P),z=t(r(M),2);c(z),l(M);var H=t(M,2),J=t(r(H),2);W(J,20,()=>["disponible","mantenimiento","baja"],i=>i,(i,a)=>{var e=Y(),o=r(e,!0);l(e);var d={};b(p=>{X(e,p),f(o,a==="disponible"?"Disponible":a==="mantenimiento"?"Mantenimiento":"De baja"),d!==(d=a)&&(e.value=(e.__value=a)??"")},[()=>s("status","disponible")===a]),_(i,e)}),l(J),q(2),l(H),l(P);var N=t(P,2),K=t(r(N),2);sa(K),l(N);var Q=t(N,2),V=r(Q),ta=r(V,!0);l(V),q(2),l(Q),l(u),da(u,i=>{var a;return(a=na)==null?void 0:a(i)}),b((i,a,e,o,d,p,la)=>{n(B,i),n(F,a),n(G,e),n(I,o),n(U,d),n(z,p),n(K,la),f(ta,$())},[()=>s("code"),()=>s("name"),()=>s("brand"),()=>s("model"),()=>s("serial"),()=>s("location"),()=>s("notes")]),_(Z,u),ra()}export{xa as D};
