1import{r as d,p as N,q as w,j as e,v as y,L as k}from"./index-XuTraXL9.js";const x={reload:"Auto-reload triggered",capped:"Retry limit reached",recovered:"Recovered after reload","route-error":"Route error caught",revalidate:"Silent revalidation"},u={reload:"bg-primary/15 text-primary border-primary/30",capped:"bg-destructive/15 text-destructive border-destructive/30",recovered:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30","route-error":"bg-amber-500/15 text-amber-400 border-amber-500/30",revalidate:"bg-muted text-muted-foreground border-border"};function h(r){try{return new Date(r).toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"})}catch{return String(r)}}function p(r){const s=Math.max(0,Math.round((Date.now()-r)/1e3));return s<60?`${s}s ago`:s<3600?`${Math.round(s/60)}m ago`:s<86400?`${Math.round(s/3600)}h ago`:`${Math.round(s/86400)}d ago`}function E(){const[r,s]=d.useState([]),[o,g]=d.useState(null),[f,b]=d.useState(0),n=d.useCallback(()=>{s(N()),g(w()),b(t=>t+1)},[]);d.useEffect(()=>{n();const t=window.setTimeout(n,2e3),l=window.setInterval(n,5e3),c=m=>{(!m.key||m.key.startsWith("jukez.selfheal"))&&n()};return window.addEventListener("storage",c),()=>{window.clearTimeout(t),window.clearInterval(l),window.removeEventListener("storage",c)}},[n]);const a=r[0],v=r.filter(t=>t.kind==="reload").length,j=r.filter(t=>t.kind==="route-error").length;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[e.jsx(i,{label:"Auto-reloads",value:String(v)}),e.jsx(i,{label:"Route errors",value:String(j)}),e.jsx(i,{label:"Retries used",value:o?`${o.attempts}/${o.maxAttempts}`:"â",hint:o?`per ${Math.round(o.windowMs/1e3)}s window`:void 0}),e.jsx(i,{label:"Last event",value:a?p(a.at):"None"})]}),e.jsxs("div",{className:"rounded-xl border border-border bg-card/60 p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:"Last auto-heal reason"}),a?e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[e.jsx("span",{className:"text-foreground",children:x[a.kind]??a.kind})," â ",a.reason,e.jsxs("span",{className:"block text-xs",children:[h(a.at)," · ",a.path??"unknown path",a.attempt?` · attempt ${a.attempt}`:""]})]}):e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Nothing to report â no load failures have been recovered on this device."})]}),e.jsxs("div",{className:"rounded-xl border border-border bg-card/60",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:"Event history"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:n,className:"rounded-md border border-input px-3 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-accent",children:"Refresh"}),e.jsx("button",{onClick:()=>{y(),n()},className:"rounded-md border border-input px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent",children:"Clear"})]})]}),r.length===0?e.jsx("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:"No events recorded."}):e.jsx("ul",{className:"divide-y divide-border",children:r.map((t,l)=>e.jsxs("li",{className:"flex flex-col gap-1 px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:`inline-flex rounded-full border px-2 py-0.5 text-[11px] font-semibold ${u[t.kind]??u.revalidate}`,children:x[t.kind]??t.kind}),e.jsx("p",{className:"mt-1 truncate text-sm text-foreground",children:t.reason}),e.jsxs("p",{className:"truncate text-xs text-muted-foreground",children:[t.path??"unknown path",t.attempt?` · attempt ${t.attempt}`:""]})]}),e.jsxs("div",{className:"shrink-0 text-xs text-muted-foreground sm:text-right",children:[e.jsx("div",{children:h(t.at)}),e.jsx("div",{children:p(t.at)})]})]},`${t.at}-${l}`))})]})]},f)}function i({label:r,value:s,hint:o}){return e.jsxs("div",{className:"rounded-xl border border-border bg-card/60 p-4",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:r}),e.jsx("p",{className:"mt-1 text-2xl font-bold text-foreground",children:s}),o?e.jsx("p",{className:"text-[11px] text-muted-foreground",children:o}):null]})}
1function L(){const[r,s]=d.useState(!1);return d.useEffect(()=>s(!0),[]),e.jsx("main",{className:"min-h-screen bg-background px-4 py-10",children:e.jsxs("div",{className:"mx-auto max-w-3xl",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight text-foreground",children:"Load diagnostics"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Whenever a page fails to load, JUKEZ recovers itself and records what happened here â reason, retry count and timestamp. This log is stored on this device only."}),e.jsx("div",{className:"mt-8",children:r?e.jsx(E,{}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading diagnosticsâ¦"})}),e.jsx("div",{className:"mt-8",children:e.jsx(k,{to:"/",className:"text-sm font-medium text-primary hover:underline",children:"â Back to JUKEZ"})})]})})}export{L as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.