1import{b as L,j as a,M as T,dM as M,$,bu as _,c4 as I,r as R}from"./index.C_jEAofg.js";import{d as P,r}from"./reactRouter.C6cvQAHO.js";import{u as A,i as C}from"./i18n.BxWiIRpk.js";import{C as O}from"./Select.BO5et_f4.js";import{R as D,L as K,C as H,X as W,Y as F,T as U,m as Y,c as y}from"./recharts.DzmhKP_O.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"aec9389561908f1f1b5366362ca3b629220ab900"},e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(u){for(var n=1;n<arguments.length;n++){var i=arguments[n];if(i!=null)for(var h in i)i.hasOwnProperty(h)&&(u[h]=i[h])}return u}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:tuf-website":!0});var s=new e.Error().stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="7b101df9-6d28-4f27-a944-6b5bc5a1f73b",e._sentryDebugIdIdentifier="sentry-dbid-7b101df9-6d28-4f27-a944-6b5bc5a1f73b")}catch{}})();const B=["cdn","nginx"],z={cdn:"cdnService",nginx:"nginxService"},X=["1h","3h","6h","12h","24h","3d","7d","14d"];function G(e,s){return e?e.skipped===!0?{className:"skipped",label:s("healthCheck.serviceChecks.skipped")}:e.ok===!0?{className:"online",label:s("healthCheck.serviceState.ok")}:{className:"offline",label:s("healthCheck.serviceState.down")}:{className:"offline",label:s("healthCheck.serviceState.down")}}function w(e,s){return e?{className:"online",label:s("healthCheck.serviceState.ok")}:{className:"offline",label:s("healthCheck.serviceState.down")}}function j(e,s){return e?e.skipped===!0?s("healthCheck.responseTime.skipped"):typeof e.durationMs!="number"||Number.isNaN(e.durationMs)?s("healthCheck.responseTime.unavailable"):s("healthCheck.responseTime.ms",{ms:Math.round(e.durationMs)}):s("healthCheck.responseTime.unavailable")}function q({healthData:e,t:s,getStatusColor:u,getStatusIcon:n}){var t,o,b;const i=((t=e.details)==null?void 0:t.probes)??{},h=i.database,k=i.mainServer,m=w(((o=e.checks)==null?void 0:o.database)===!0,s),p=w(((b=e.checks)==null?void 0:b.mainServer)===!0,s),d=j(h,s),x=j(k,s),c=s("healthCheck.responseTime.ariaLabel");return a.jsxs("div",{className:"health-dashboard",children:[a.jsx("div",{className:"health-summary",children:a.jsxs("div",{className:"status-badge",style:{backgroundColor:u(e.status)},children:[a.jsx("span",{className:"status-icon",children:n(e.status)}),a.jsx("span",{children:s(`healthCheck.overall.${e.status}`)})]})}),a.jsxs("div",{className:"health-grid",children:[a.jsxs("div",{className:"health-card",children:[a.jsxs("div",{className:"health-card-header",children:[a.jsx("h3",{children:s("healthCheck.serviceChecks.database")}),a.jsx("span",{className:"health-card-response-time",title:c,"aria-label":`${s("healthCheck.serviceChecks.database")}, ${c}: ${d}`,children:d})]}),a.jsx("div",{className:`status-indicator ${m.className}`,children:m.label})]}),a.jsxs("div",{className:"health-card",children:[a.jsxs("div",{className:"health-card-header",children:[a.jsx("h3",{children:s("healthCheck.serviceChecks.mainServer")}),a.jsx("span",{className:"health-card-response-time",title:c,"aria-label":`${s("healthCheck.serviceChecks.mainServer")}, ${c}: ${x}`,children:x})]}),a.jsx("div",{className:`status-indicator ${p.className}`,children:p.label})]}),B.map(f=>{const l=i[f];if(!l)return null;const g=z[f],v=s(`healthCheck.serviceChecks.${g}`),N=j(l,s),{className:S,label:E}=G(l,s);return a.jsxs("div",{className:"health-card",children:[a.jsxs("div",{className:"health-card-header",children:[a.jsx("h3",{children:v}),a.jsx("span",{className:"health-card-response-time",title:c,"aria-label":`${v}, ${c}: ${N}`,children:N})]}),a.jsx("div",{className:`status-indicator ${S}`,children:E})]},f)})]})]})}function J({t:e}){const[s,u]=r.useState("24h"),[n,i]=r.useState(null),[h,k]=r.useState(!1),[m,p]=r.useState(null),d=r.useMemo(()=>X.map(t=>({value:t,label:e(`healthCheck.latency.windows.${t}`)})),[e]),x=r.useMemo(()=>d.find(t=>t.value===s)??d[4],[d,s]);r.useEffect(()=>{let t=!1;async function o(){k(!0),p(null);try{const b=`${I(R.health.latency())}?window=${encodeURIComponent(s)}`,f=await fetch(b);
1if(!f.ok)throw new Error(`HTTP ${f.status}`);const l=await f.json();t||i(l)}catch(b){console.error("Latency history fetch failed:",b),t||(p(e("healthCheck.latency.loadError")),i(null))}finally{t||k(!1)}}return o(),()=>{t=!0}},[s,e]);const c=r.useMemo(()=>{const t=n==null?void 0:n.points;return Array.isArray(t)?t.map(o=>({t:Date.parse(o.at),database:o.database,mainServer:o.main_server,cdn:o.cdn})):[]},[n]);return _?a.jsxs("div",{className:"health-latency-section",children:[a.jsx("h2",{className:"health-latency-title",children:e("healthCheck.latency.title")}),a.jsxs("div",{className:"health-latency-toolbar",children:[a.jsx("span",{className:"health-latency-window-label",children:e("healthCheck.latency.windowLabel")}),a.jsx(O,{options:d,value:x,onChange:t=>t&&u(t.value),"aria-label":e("healthCheck.latency.windowLabel")})]}),m&&a.jsx("div",{className:"error-message health-latency-error",children:m}),h&&a.jsx("div",{className:"health-latency-chart-loading",children:a.jsx("div",{className:"spinner spinner-large"})}),!h&&!m&&c.length===0&&a.jsx("p",{className:"health-latency-empty",children:e("healthCheck.latency.empty")}),!h&&c.length>0&&a.jsx("div",{className:"health-latency-chart-wrap",children:a.jsx(D,{width:"100%",height:320,children:a.jsxs(K,{data:c,margin:{top:8,right:12,left:4,bottom:8},children:[a.jsx(H,{strokeDasharray:"3 3",stroke:"rgba(255, 255, 255, 0.08)"}),a.jsx(W,{dataKey:"t",type:"number",domain:["dataMin","dataMax"],tickFormatter:t=>new Date(t).toLocaleString(C.language||void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),stroke:"#aaa",tick:{fill:"#aaa",fontSize:11,fontWeight:500}}),a.jsx(F,{stroke:"#aaa",tick:{fill:"#aaa",fontSize:11},label:{value:e("healthCheck.latency.yAxisLabel"),angle:-90,position:"insideLeft",fill:"#aaa",style:{textAnchor:"middle"}}}),a.jsx(U,{formatter:t=>t==null?"â":`${t} ms`,labelFormatter:t=>new Date(t).toLocaleString(C.language||void 0),contentStyle:{backgroundColor:"rgba(25, 25, 25, 0.97)",border:"1px solid rgba(255, 255, 255, 0.12)",borderRadius:6,fontWeight:500},labelStyle:{color:"#eee"}}),a.jsx(Y,{wrapperStyle:{color:"#ddd"}}),a.jsx(y,{type:"linear",dataKey:"database",name:e("healthCheck.latency.series.database"),stroke:"var(--btn-success)",strokeWidth:2,dot:!1}),a.jsx(y,{type:"linear",dataKey:"mainServer",name:e("healthCheck.latency.series.mainServer"),stroke:"var(--danger-color)",strokeWidth:2,dot:!1}),a.jsx(y,{type:"linear",dataKey:"cdn",name:e("healthCheck.latency.series.cdn"),stroke:"var(--warning-color)",strokeWidth:2,dot:!1})]})})})]}):null}const se=()=>{const{t:e}=A("pages"),s=P(),u=r.useMemo(()=>L({title:e("healthCheck.title"),description:e("healthCheck.metaDescription"),pathname:s.pathname,image:"/og-image.jpg",type:"website",noindex:!0}),[e,s.pathname]),[n,i]=r.useState(null),[h,k]=r.useState(!0),[m,p]=r.useState(null),[d,x]=r.useState(null),[c,t]=r.useState(!1),o=async()=>{var l;t(!0),p(null);try{const g=await fetch(M("/health/api"));if(!g.ok)throw new Error(`HTTP error! Status: ${g.status}`);const v=await g.json();i(v),x($(new Date,(l=C)==null?void 0:l.language))}catch(g){p(e("healthCheck.loadError")),console.error("Error fetching health data:",g)}finally{k(!1),t(!1)}};r.useEffect(()=>{o();const l=setInterval(o,3e4);return()=>clearInterval(l)},[]);const b=l=>{switch(l){case"online":return"#4CAF50";case"degraded":return"#FF9800";case"offline":return"#F44336";default:return"#9E9E9E"}},f=l=>{switch(l){case"online":return"â";case"degraded":return"â ";case"offline":return"â";default:return"?"}};return a.jsxs("div",{className:"health-check-page",children:[a.jsx(T,{...u}),a.jsxs("div",{className:"health-check-container page-content",children:[a.jsx("h1",{children:e("healthCheck.title")}),d&&a.jsx("div",{className:"last-updated",children:e("healthCheck.lastUpdated",{time:d})}),m&&a.jsx("div",{className:"error-message",children:m}),h&&!n&&a.jsxs("div",{className:"loading-container",children:[a.jsx("div",{className:"spinner spinner-xlarge"}),a.jsx("p",{className:"loading-label",children:e("loading.generic",{ns:"common"})})]}),n&&a.jsx(q,{healthData:n,t:e,getStatusColor:b,getStatusIcon:f}),a.jsx(J,{t:e})]}),a.jsx("button",{className:"fixed-refresh-button",onClick:o,disabled:c,"aria-label":e("healthCheck.refresh.ariaLabel"),children:c?a.jsx("div",{className:"spinner refresh-spinner"}):a.jsx("span",{className:"refresh-icon",children:"â»"})})]})};export{se as default};
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.