import"../chunks/Bzak7iHL.js";import{g as Be,p as Ie,h as K,i as Ne,s as t,f as Te,t as m,j as Fe,a as i,b as Ue,k as Je,c,$ as Ke,d as r,r as s,n as g,l as d,e as n,m as Qe,o as b}from"../chunks/CiQWViEs.js";import{i as v}from"../chunks/CEkQpEF5.js";import{e as Ve}from"../chunks/EUGRfuDz.js";import{h as Xe}from"../chunks/DG4rvltU.js";import{a as y,e as h}from"../chunks/BblGoPVU.js";import{r as u,s as p,a as ue}from"../chunks/zaEOnEon.js";import{s as Ye}from"../chunks/bfdffNJu.js";var He=c('<p class="mb-4 rounded-lg bg-emerald-50 px-4 py-3 text-sm font-medium text-emerald-700" role="status"> </p>'),_e=c('<p class="mb-3 rounded-lg bg-red-50 px-3 py-2 text-sm font-medium text-red-700" role="alert"> </p>'),Me=c('<form method="POST" action="?/deleteCategory"><input type="hidden" name="id"/> <button class="text-xs font-medium text-red-600 hover:underline" type="submit">Borrar</button></form>'),We=c('<li class="flex items-center gap-3 py-2"><span class="h-4 w-4 shrink-0 rounded-full"></span> <span class="font-mono text-sm font-semibold text-slate-700"> </span> <span class="text-slate-800"> </span> <span class="ml-auto text-xs text-slate-400"> </span> <!></li>'),Ze=c('<img alt="Logo del centro" class="max-h-24 max-w-full object-contain"/>'),$e=c('<span class="text-xs text-slate-400">Sin logo</span>'),ea=c('<button class="text-xs font-medium text-red-600 hover:underline" type="submit" formaction="?/removeLogo">Quitar</button>'),aa=c('<p class="mt-1 text-xs text-red-600"> </p>'),ta=c(`<div class="mb-6"><h1 class="text-2xl font-bold text-slate-900">Ajustes</h1> <p class="text-slate-600">Configuración del centro, préstamos, etiquetas y categorías.</p></div> <!> <div class="grid gap-6 lg:grid-cols-2"><section class="card p-6"><h2 class="mb-4 font-semibold text-slate-900">Centro y préstamos</h2> <form method="POST" action="?/saveGeneral" class="space-y-4"><div><label class="label" for="center_name">Nombre del centro</label> <input class="input" id="center_name" name="center_name"/></div> <div><label class="label" for="center_code">Código de centro (opcional)</label> <input class="input" id="center_code" name="center_code"/></div> <div><label class="label" for="loan_default_days">Días de préstamo por defecto</label> <input class="input" id="loan_default_days" name="loan_default_days" type="number" min="1"/></div> <fieldset><legend class="label">Calibración de etiquetas por defecto (mm)</legend> <div class="grid grid-cols-2 gap-3"><div><label class="text-xs text-slate-500" for="label_offset_x_mm">Desplaz. X</label> <input class="input" id="label_offset_x_mm" name="label_offset_x_mm" type="number" step="0.5"/></div> <div><label class="text-xs text-slate-500" for="label_offset_y_mm">Desplaz. Y</label> <input class="input" id="label_offset_y_mm" name="label_offset_y_mm" type="number" step="0.5"/></div></div></fieldset> <button class="btn-primary" type="submit">Guardar ajustes</button></form></section> <section class="card p-6"><h2 class="mb-1 font-semibold text-slate-900">Categorías / tipologías</h2> <p class="mb-4 text-sm text-slate-500">El código (2–5 letras) genera los IDs de equipo: <span class="font-mono">POR-0001</span>.</p> <!> <ul class="mb-4 divide-y divide-slate-100"></ul> <form method="POST" action="?/addCategory" class="flex flex-wrap items-end gap-2 border-t border-slate-200 pt-4"><div class="w-20"><label class="label" for="cat_code">Código</label> <input class="input font-mono uppercase" id="cat_code" name="code" placeholder="POR" maxlength="5" required=""/></div> <div class="min-w-[120px] flex-1"><label class="label" for="cat_name">Nombre</label> <input class="input" id="cat_name" name="name" placeholder="Portátil" required=""/></div> <div><label class="label" for="cat_color">Color</label> <input class="input h-[42px] w-14 p-1" id="cat_color" name="color" type="color" value="#0f766e"/></div> <button class="btn-primary" type="submit">Añadir</button></form></section></div> <section class="card mt-6 p-6"><h2 class="mb-1 font-semibold text-slate-900">Identidad del centro y protección de datos</h2> <p class="mb-4 text-sm text-slate-500">El logo aparece en la cabecera de las actas de entrega/recogida y el texto de protección de
		datos, al pie.</p> <!> <form method="POST" action="?/saveBranding" class="grid gap-6 lg:grid-cols-[220px_1fr]"><div><span class="label">Logo del centro</span> <div class="flex h-28 w-full items-center justify-center rounded-lg border border-dashed border-slate-300 bg-slate-50 p-2"><!></div> <div class="mt-2 flex items-center gap-2"><label class="btn-secondary cursor-pointer text-xs">Elegir imagen… <input type="file" accept="image/png,image/jpeg" class="hidden"/></label> <!></div> <!> <p class="mt-1 text-xs text-slate-400">PNG o JPG, máx. 700 KB.</p> <input type="hidden" name="logo_data"/></div> <div><label class="label" for="lopd_text">Cláusula de protección de datos (LOPD/RGPD)</label> <textarea class="input text-sm" id="lopd_text" name="lopd_text" rows="7"></textarea> <div class="mt-3"><button class="btn-primary" type="submit">Guardar identidad</button></div></div></form></section> <section class="card mt-6 p-6"><h2 class="mb-1 font-semibold text-slate-900">Copia de seguridad y datos</h2> <p class="mb-4 text-sm text-slate-500">Descarga una copia de toda la base de datos (equipos, préstamos, usuarios y ajustes).
		Guárdala en lugar seguro; sirve para restaurar o migrar de equipo.</p> <a class="btn-primary" href="/settings/backup" download="">Descargar copia de seguridad</a> <dl class="mt-5 grid gap-x-6 gap-y-2 text-sm sm:grid-cols-2"><div class="flex justify-between border-t border-slate-100 pt-2"><dt class="text-slate-500">Versión de la app</dt> <dd class="font-medium text-slate-800"> </dd></div> <div class="flex justify-between border-t border-slate-100 pt-2"><dt class="text-slate-500">Carpeta de datos</dt> <dd class="max-w-[60%] truncate font-mono text-xs text-slate-600"> </dd></div></dl> <p class="mt-3 rounded-lg bg-slate-50 px-3 py-2 text-xs text-slate-500">Los datos se guardan <strong>fuera</strong> de la carpeta de la aplicación, así que al
		instalar una versión nueva <strong>no se pierden</strong>. Para restaurar una copia,
		reemplaza el archivo <span class="font-mono">inventario.db</span> de esa carpeta (con la app
		cerrada).</p></section>`,1);function ma(fe,l){Ie(l,!0);let P=K(Ne(l.data.settings.center_logo??"")),w=K(""),_=K(null);function be(a){var f;b(_,null);const e=(f=a.target.files)==null?void 0:f[0];if(!e)return;if(!/image\/(png|jpeg|jpg)/.test(e.type)){b(_,"Formato no válido. Usa PNG o JPG.");return}if(e.size>700*1024){b(_,"Imagen demasiado grande (máx. 700 KB).");return}const o=new FileReader;o.onload=()=>{b(w,String(o.result??""),!0),b(P,d(w),!0)},o.readAsDataURL(e)}var Q=ta();Xe("1i19ct2",a=>{Je(()=>{Ke.title="Ajustes · Inventario EDUmind"})});var V=t(Te(Q),2);{var xe=a=>{var e=He(),o=r(e,!0);s(e),m(()=>n(o,l.form.success)),i(a,e)};v(V,a=>{var e;(e=l.form)!=null&&e.success&&a(xe)})}var D=t(V,2),j=r(D),C=t(r(j),2),q=r(C),X=t(r(q),2);u(X),s(q);var E=t(q,2),Y=t(r(E),2);u(Y),s(E);var G=t(E,2),H=t(r(G),2);u(H),s(G);var M=t(G,2),W=t(r(M),2),L=r(W),Z=t(r(L),2);u(Z),s(L);var $=t(L,2),ee=t(r($),2);u(ee),s($),s(W),s(M),g(2),s(C),y(C,a=>{var e;return(e=h)==null?void 0:e(a)}),s(j);var ae=t(j,2),te=t(r(ae),4);{var ge=a=>{var e=_e(),o=r(e,!0);s(e),m(()=>n(o,l.form.catError)),i(a,e)};v(te,a=>{var e;(e=l.form)!=null&&e.catError&&a(ge)})}var O=t(te,2);Ve(O,21,()=>l.data.categories,a=>a.id,(a,e)=>{var o=We(),f=r(o),T=t(f,2),Oe=r(T,!0);s(T);var F=t(T,2),Se=r(F,!0);s(F);var U=t(F,2),ke=r(U);s(U);var Re=t(U,2);{var ze=J=>{var x=Me(),pe=r(x);u(pe),g(2),s(x),y(x,Ae=>{var ve;return(ve=h)==null?void 0:ve(Ae)}),m(()=>p(pe,d(e).id)),i(J,x)};v(Re,J=>{d(e).device_count===0&&J(ze)})}s(o),m(()=>{Ye(f,`background:${d(e).color??""}`),n(Oe,d(e).code),n(Se,d(e).name),n(ke,`${d(e).device_count??""} equipo(s)`)}),i(a,o)}),s(O);var ye=t(O,2);y(ye,a=>{var e;return(e=h)==null?void 0:e(a)}),s(ae),s(D);var S=t(D,2),se=t(r(S),4);{var he=a=>{var e=_e(),o=r(e,!0);s(e),m(()=>n(o,l.form.brandError)),i(a,e)};v(se,a=>{var e;(e=l.form)!=null&&e.brandError&&a(he)})}var k=t(se,2),R=r(k),z=t(r(R),2),Pe=r(z);{var we=a=>{var e=Ze();m(()=>ue(e,"src",d(P))),i(a,e)},De=a=>{var e=$e();i(a,e)};v(Pe,a=>{d(P)?a(we):a(De,-1)})}s(z);var A=t(z,2),B=r(A),je=t(r(B));s(B);var Ce=t(B,2);{var qe=a=>{var e=ea();i(a,e)};v(Ce,a=>{l.data.settings.center_logo&&a(qe)})}s(A);var re=t(A,2);{var Ee=a=>{var e=aa(),o=r(e,!0);s(e),m(()=>n(o,d(_))),i(a,e)};v(re,a=>{d(_)&&a(Ee)})}var le=t(re,4);u(le),s(R);var oe=t(R,2),de=t(r(oe),2);Qe(de),g(2),s(oe),s(k),y(k,a=>{var e;return(e=h)==null?void 0:e(a)}),s(S);var ie=t(S,2),ne=t(r(ie),6),I=r(ne),ce=t(r(I),2),Ge=r(ce,!0);s(ce),s(I);var me=t(I,2),N=t(r(me),2),Le=r(N,!0);s(N),s(me),s(ne),g(2),s(ie),m(()=>{p(X,l.data.settings.center_name),p(Y,l.data.settings.center_code),p(H,l.data.settings.loan_default_days),p(Z,l.data.settings.label_offset_x_mm),p(ee,l.data.settings.label_offset_y_mm),p(le,d(w)),p(de,l.data.settings.lopd_text),n(Ge,l.data.version||"—"),ue(N,"title",l.data.dataDir),n(Le,l.data.dataDir)}),Fe("change",je,be),i(fe,Q),Ue()}Be(["change"]);export{ma as component};
