import{r as n,j as e}from"./0-vendor-react-DWOJpYrt.js";import{u as k,L as I}from"./page-herramientas-BzovIToK.js";import{B as h}from"./page-ajustes-DgawOEJM.js";import{C as x,c as f,d as g,e as j,I as A}from"./page-comunicacion-DmHQUHoW.js";import{f as m,C as E,g as D,a as T}from"./timers-DtW-cs9v.js";import"./1-vendor-utils-Delnuc0l.js";import"./2-vendor-markdown-BQlHAcA7.js";const _=[{id:"access",title:"Acceso vascular de gran calibre",description:"Canalizar vía periférica (o alternativa) y preparar perfusión."},{id:"fluids",title:"Fluidoterapia 30 ml/kg",description:"Administrar cristaloides en bolo según peso.",hasFluidCalculator:!0},{id:"cultures",title:"Hemocultivos antes de antibióticos",description:"Tomar cultivos según protocolo local."},{id:"antibiotics",title:"Antibiótico en < 1 hora",description:"Iniciar antibiótico de amplio espectro.",hasAntibioticDeadline:!0},{id:"vasopressors",title:"Evaluar vasopresores",description:"Si MAP < 65 tras fluidos, considerar noradrenalina."},{id:"source",title:"Buscar foco infeccioso",description:"Exploración dirigida y reevaluación clínica."}],b="sepsis_checklist_v1",K=30,M=3600,o={startedAt:null,completed:{},manualWeightKg:void 0},R=()=>{if(typeof window>"u")return o;try{const r=window.localStorage.getItem(b);if(!r)return o;const i=JSON.parse(r);return{...o,...i}}catch{return o}},B=r=>{if(!(typeof window>"u"))try{window.localStorage.setItem(b,JSON.stringify(r))}catch{}},H=()=>{const{state:r}=k(),[i,c]=n.useState(o),[F,v]=n.useState(Date.now());n.useEffect(()=>{c(R())},[]),n.useEffect(()=>{B(i)},[i]),n.useEffect(()=>{const t=window.setInterval(()=>v(Date.now()),1e3);return()=>window.clearInterval(t)},[]);const a=i.startedAt,w=D(a),u=T(a,M),l=r.patient.weight??i.manualWeightKg,p=n.useMemo(()=>l?Math.round(l*K):null,[l]),N=(t,s)=>{c(d=>({...d,completed:{...d.completed,[t]:s}}))},S=()=>{a||c(t=>({...t,startedAt:Date.now()}))},C=()=>{c(o)},y=t=>{const s=Number(t);c(d=>({...d,manualWeightKg:Number.isFinite(s)?s:void 0}))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("header",{className:"space-y-2",children:[e.jsx("h1",{className:"text-xl font-semibold text-foreground",children:"Checklist Código Sepsis"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checklist interactiva con temporizador y cálculo de fluidos."})]}),e.jsxs(x,{children:[e.jsxs(f,{className:"flex flex-row items-center justify-between space-y-0",children:[e.jsx(g,{className:"text-base",children:"Temporizador"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:a?`Tiempo: ${m(w)}`:"Sin iniciar"})]}),e.jsxs(j,{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[e.jsx("div",{className:"text-sm",children:a?`Antibiótico < 1h: ${m(u)}`:"Inicia para contar el tiempo crítico."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{onClick:S,disabled:!!a,children:"Iniciar"}),e.jsx(h,{variant:"outline",onClick:C,children:"Reiniciar"})]})]})]}),_.map(t=>e.jsxs(x,{children:[e.jsx(f,{className:"flex flex-row items-center justify-between space-y-0",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(E,{checked:!!i.completed[t.id],onCheckedChange:s=>N(t.id,!!s)}),e.jsx(g,{className:"text-base",children:t.title})]})}),e.jsxs(j,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:t.description}),t.hasFluidCalculator&&e.jsxs("div",{className:"rounded-md border border-border/60 bg-muted/30 p-3 space-y-2",children:[e.jsx(I,{children:"Peso (kg)"}),e.jsx(A,{type:"number",inputMode:"numeric",value:l??"",onChange:s=>y(s.target.value),placeholder:"Ej: 70"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:p?`Volumen recomendado: ${p} ml`:"Introduce el peso para calcular 30 ml/kg."})]}),t.hasAntibioticDeadline&&e.jsx("div",{className:"rounded-md border border-border/60 bg-muted/30 p-3 text-sm text-muted-foreground",children:a?`Tiempo restante: ${m(u)}`:"Inicia el temporizador para activar la cuenta atrás."})]})]},t.id))]})};export{H as default};