import { a7 as head, a4 as escape_html, a6 as attr, a5 as ensure_array_like, a9 as attr_style, a8 as stringify } from '../../../chunks/index.js-BVnekaYQ.js';
import '../../../chunks/exports.js-8HOoaa4e.js';
import '../../../chunks/utils2.js-BQzn9ikS.js';
import '../../../chunks/utils.js-mIi_c4Oz.js';
import '../../../chunks/root.js-l4cSj5gU.js';
import '../../../chunks/state.svelte.js-DC2zSH9Y.js';
import '../../../chunks/false.js-B2gHlHjM.js';

function _page($$renderer, $$props) {
  $$renderer.component(($$renderer2) => {
    let { data, form } = $$props;
    let logoPreview = data.settings.center_logo ?? "";
    let logoData = "";
    head("1i19ct2", $$renderer2, ($$renderer3) => {
      $$renderer3.title(($$renderer4) => {
        $$renderer4.push(`<title>Ajustes · Inventario EDUmind</title>`);
      });
    });
    $$renderer2.push(`<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> `);
    if (form?.success) {
      $$renderer2.push("<!--[0-->");
      $$renderer2.push(`<p class="mb-4 rounded-lg bg-emerald-50 px-4 py-3 text-sm font-medium text-emerald-700" role="status">${escape_html(form.success)}</p>`);
    } else {
      $$renderer2.push("<!--[-1-->");
    }
    $$renderer2.push(`<!--]--> <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"${attr("value", data.settings.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"${attr("value", data.settings.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"${attr("value", data.settings.loan_default_days)}/></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"${attr("value", data.settings.label_offset_x_mm)}/></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"${attr("value", data.settings.label_offset_y_mm)}/></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> `);
    if (form?.catError) {
      $$renderer2.push("<!--[0-->");
      $$renderer2.push(`<p class="mb-3 rounded-lg bg-red-50 px-3 py-2 text-sm font-medium text-red-700" role="alert">${escape_html(form.catError)}</p>`);
    } else {
      $$renderer2.push("<!--[-1-->");
    }
    $$renderer2.push(`<!--]--> <ul class="mb-4 divide-y divide-slate-100"><!--[-->`);
    const each_array = ensure_array_like(data.categories);
    for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
      let c = each_array[$$index];
      $$renderer2.push(`<li class="flex items-center gap-3 py-2"><span class="h-4 w-4 shrink-0 rounded-full"${attr_style(`background:${stringify(c.color)}`)}></span> <span class="font-mono text-sm font-semibold text-slate-700">${escape_html(c.code)}</span> <span class="text-slate-800">${escape_html(c.name)}</span> <span class="ml-auto text-xs text-slate-400">${escape_html(c.device_count)} equipo(s)</span> `);
      if (c.device_count === 0) {
        $$renderer2.push("<!--[0-->");
        $$renderer2.push(`<form method="POST" action="?/deleteCategory"><input type="hidden" name="id"${attr("value", c.id)}/> <button class="text-xs font-medium text-red-600 hover:underline" type="submit">Borrar</button></form>`);
      } else {
        $$renderer2.push("<!--[-1-->");
      }
      $$renderer2.push(`<!--]--></li>`);
    }
    $$renderer2.push(`<!--]--></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> `);
    if (form?.brandError) {
      $$renderer2.push("<!--[0-->");
      $$renderer2.push(`<p class="mb-3 rounded-lg bg-red-50 px-3 py-2 text-sm font-medium text-red-700" role="alert">${escape_html(form.brandError)}</p>`);
    } else {
      $$renderer2.push("<!--[-1-->");
    }
    $$renderer2.push(`<!--]--> <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">`);
    if (logoPreview) {
      $$renderer2.push("<!--[0-->");
      $$renderer2.push(`<img${attr("src", logoPreview)} alt="Logo del centro" class="max-h-24 max-w-full object-contain"/>`);
    } else {
      $$renderer2.push("<!--[-1-->");
      $$renderer2.push(`<span class="text-xs text-slate-400">Sin logo</span>`);
    }
    $$renderer2.push(`<!--]--></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> `);
    if (data.settings.center_logo) {
      $$renderer2.push("<!--[0-->");
      $$renderer2.push(`<button class="text-xs font-medium text-red-600 hover:underline" type="submit" formaction="?/removeLogo">Quitar</button>`);
    } else {
      $$renderer2.push("<!--[-1-->");
    }
    $$renderer2.push(`<!--]--></div> `);
    {
      $$renderer2.push("<!--[-1-->");
    }
    $$renderer2.push(`<!--]--> <p class="mt-1 text-xs text-slate-400">PNG o JPG, máx. 700 KB.</p> <input type="hidden" name="logo_data"${attr("value", logoData)}/></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">`);
    const $$body = escape_html(data.settings.lopd_text);
    if ($$body) {
      $$renderer2.push(`${$$body}`);
    }
    $$renderer2.push(`</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">${escape_html(data.version || "—")}</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"${attr("title", data.dataDir)}>${escape_html(data.dataDir)}</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>`);
  });
}

export { _page as default };
//# sourceMappingURL=_page.svelte.js-CXon_McF.js.map
