1import{u as F,a as q,j as e,L as G,E as O,f as J,r as T}from"./index-Dknl3VNf.js";import{e as K}from"./chartLoader-1ceMudca.js";const I=500,z=800,Q={claude:"#79c0ff",openai:"#56d364",gemini:"#f78166",mistral:"#d2a8ff",cohere:"#ffb86c",groq:"#50fa7b",together:"#8be9fd",perplexity:"#ff79c6",huggingface:"#f1fa8c",replicate:"#bd93f9",elevenlabs:"#6be5e2",xai:"#e0e0e0",deepseek:"#ff6b6b",openrouter:"#ffa657",stability:"#c9d1d9",assemblyai:"#79dfc1",deepgram:"#a5b4fc"};function U(r){return r<=I?"bg-[var(--green)]":r<=z?"bg-[var(--amber)]":"bg-[var(--red)]"}function X(r){return r<=I?"text-[var(--green)]":r<=z?"text-[var(--amber)]":"text-[var(--red)]"}function Y({services:r,t:d,hourlyData:s}){const i=T.useRef(null),o=T.useRef(null),S=s&&s.length>0;return T.useEffect(()=>{if(!i.current||!S)return;let v=!1;return K().then(M=>{var E;if(v||!i.current)return;o.current&&o.current.destroy();const g=s.length>0&&typeof Object.values(s[0].data??{})[0]=="object",w=g?Object.keys(((E=s[s.length-1])==null?void 0:E.data)??{}):null,x=window.innerWidth<768,f=g&&s.length>60;let h=s;if(f){const t=new Map;for(const n of s){const l=new Date(n.t),j=l.getHours(),C=l.getMinutes()<30?0:30,N=`${j}:${C}`;t.has(N)||t.set(N,{points:[],h:j,half:C}),t.get(N).points.push(n)}h=[...t.values()].map(({points:n,h:l,half:j})=>{const C=n[Math.floor(n.length/2)],N={},B=new Set(n.flatMap(L=>Object.keys(L.data??{})));for(const L of B){const R=n.map(k=>{var A;const b=(A=k.data)==null?void 0:A[L];return b&&typeof b=="object"?b.rtt>0?b.rtt:null:b}).filter(k=>k!=null);R.length>0&&(N[L]={rtt:Math.round(R.reduce((k,b)=>k+b,0)/R.length),status:"ok"})}const _=String(l).padStart(2,"0"),V=j===0?"30":"00",W=j===0?_:String((l+1)%24).padStart(2,"0");return{t:C.t,data:N,_rangeLabel:`${_}:${String(j).padStart(2,"0")}â${W}:${V}`}})}const p=h.map(t=>{const n=new Date(t.t);return`${String(n.getHours()).padStart(2,"0")}:${String(n.getMinutes()).padStart(2,"0")}`}),m=f?h.map(t=>t._rangeLabel):null;let c=w?r.filter(t=>w.includes(t.id)&&t.category!=="app"):r.filter(t=>t.category==="api"&&t.latency!=null);x&&(c=[...c].sort((t,n)=>(n.aiwatchScore??0)-(t.aiwatchScore??0)).slice(0,8));const $=getComputedStyle(document.documentElement),y=$.getPropertyValue("--text2").trim()||"#6b7280",a=$.getPropertyValue("--border").trim()||"rgba(107,114,128,0.1)",u=c.map(t=>({label:t.name,data:h.map(n=>{const l=n.data[t.id];return l==null?null:typeof l=="object"?l.rtt>0?l.rtt:null:l}),borderColor:Q[t.id]??"#8b949e",borderWidth:x?1:1.5,pointRadius:x?0:1.5,pointHoverRadius:3,tension:.3,fill:!1,spanGaps:!0}));o.current=new M(i.current,{type:"line",data:{labels:p,datasets:u},options:{responsive:!0,maintainAspectRatio:!1,interaction:{mode:"index",intersect:!1},plugins:{legend:{display:!x,position:"bottom",labels:{font:{size:9,family:"var(--font-mono)"},color:y,boxWidth:8,padding:8}},tooltip:{filter:t=>t.parsed.y!=null,itemSort:(t,n)=>n.parsed.y-t.parsed.y,callbacks:{title:t=>{if(!t.length)return"";const n=t[0].dataIndex;return m?`${m[n]} avg`:p[n]},label:t=>`${t.dataset.label}: ${t.parsed.y}ms`}}},scales:{x:{ticks:{font:{size:9,family:"var(--font-mono)"},color:y,maxTicksLimit:x?6:12,callback:(t,n)=>{const l=p[n];return l?l.slice(0,3)+"00":""}},grid:{display:!1}},y:{ticks:{font:{size:9,family:"var(--font-mono)"},color:y,callback:t=>`${t}ms`},grid:{color:a}}}}})}),()=>{v=!0,o.current&&(o.current.destroy(),o.current=null)}},[S,s]),e.jsxs("section",{className:"bg-[var(--bg1)] border border-[var(--border)] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"border-b border-[var(--border)] flex items-center justify-between",style:{padding:"12px 16px"},children:[e.jsxs("div",{className:"mono text-[10px] text-[var(--text1)] uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx("span",{className:"rounded-full shrink-0",style:{width:"5px",height:"5px",background:"var(--blue)"}}),d("latency.trend")]}),e.jsx("span",{className:"md:hidden mono text-[9px] text-[var(--text2)]",children:d("latency.top8")})]}),S?e.jsx("div",{className:"p-2 md:p-4",children:e.jsx("div",{className:"h-[240px] md:h-[320px]",children:e.jsx("canvas",{ref:i})})}):e.jsx("div",{className:"flex items-center justify-center",style:{padding:"40px 16px"},children:e.jsx("p",{className:"text-xs text-[var(--text2)] mono",children:d("uptime.collecting")})})]})}const Z={"text-[var(--green)]":"var(--green)","text-[var(--blue)]":"var(--blue)","text-[var(--red)]":"var(--red)"};function P({label:r,value:d,sub:s,colorClass:i}){const o=Z[i]??"var(--border)";return e.jsxs("div",{className:"relative bg-[var(--bg1)] border border-[var(--border)] rounded-lg overflow-hidden",style:{padding:"14px 16px"},children:[e.jsx("span",{className:"absolute top-0 left-0 right-0 h-px",style:{background:o}}),e.jsx("div",{className:"mono text-[9px] text-[var(--text2)] uppercase",style:{letterSpacing:"0.1em",marginBottom:"6px"},children:r}),e.jsxs("div",{className:`mono text-[26px] font-semibold leading-none ${i}`,style:{marginBottom:"4px"},children:[d,e.jsx("span",{style:{fontSize:"14px"},children:"ms"})]}),s&&e.jsx("div",{className:"mono text-[10px] text-[var(--text2)]",children:s})]})}function H({service:r,maxLatency:d,rank:s}){const i=d>0?Math.round(r.latency/d*100):0;return e.jsxs("div",{className:"flex items-center gap-1.5 md:gap-3 min-w-0",children:[e.jsx("span",{className:"w-4 shrink-0 text-right text-[10px] mono text-[var(--text2)]",children:s}),e.jsx("span",{className:"w-[72px] md:w-28 shrink-0 truncate text-xs text-[var(--text1)]",children:r.name}),e.jsx("div",{className:"flex-1 min-w-0 bg-[var(--bg3)] rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:`h-2 rounded-full ${U(r.latency)}`,style:{width:`${i}%`}})}),e.jsxs("span",{className:`w-[52px] md:w-16 shrink-0 text-right text-[10px] md:text-xs mono font-medium ${X(r.latency)}`,children:[r.latency," ms"]})]})}function te(){const{t:r}=F(),{services:d,loading:s,error:i,probe24h:o,latency24h:S,probeServiceIds:v,refresh:M}=q(),g=d??[];if(s&&g.length===0)return e.jsx(G,{});if(!s&&g.length===0&&i)return e.jsx(O,{type:"offline",onAction:M});if(i)return e.jsx(O,{type:"error",onAction:()=>window.location.reload()});const w=v.length>0,x=g.filter(a=>a.latency!=null),f=w?x.filter(a=>v.includes(a.id)&&a.category!=="app"):x,h=w?x.filter(a=>!v.includes(a.id)):[],p=[...f].sort((a,u)=>a.latency-u.latency),m=p[0],c=p[p.length-1],$=f.length?Math.round(f.reduce((a,u)=>a+u.latency,0)/f.length):0,y=(c==null?void 0:c.latency)??1;return e.jsxs("div",{className:"flex flex-col",style:{gap:"20px"},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"mono text-[10px] text-[var(--text2)] uppercase flex items-center gap-2",style:{letterSpacing:"0.1em"},children:[e.jsx("span",{className:"text-[var(--green)] font-semibold",children:"//"}),r("nav.latency")]}),e.jsx("span",{className:"mono text-[10px] text-[var(--text2)]",children:r("overview.panel.latency.sub")})]}),e.jsx("p",{className:"text-[11px] text-[var(--text2)]",style:{marginTop:"-12px"},children:r("latency.disclaimer")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3",style:{gap:"10px"},children:[e.jsx(P,{label:r("latency.fastest"),value:(m==null?void 0:m.latency)??"â",sub:(m==null?void 0:m.name)??"",colorClass:"text-[var(--green)]"}),e.jsx(P,{label:r("latency.average"),value:$,sub:`${f.length} ${r("latency.avg.services")}`,colorClass:"text-[var(--blue)]"}),e.jsx(P,{label:r("latency.slowest"),value:(c==null?void 0:c.latency)??"â",sub:(c==null?void 0:c.name)??"",colorClass:"text-[var(--red)]"})]}),e.jsxs("section",{className:"bg-[var(--bg1)] border border-[var(--border)] rounded-lg overflow-hidden",children:[e.jsx("div",{className:"flex items-center justify-between border-b border-[var(--border)]",style:{padding:"12px 16px"},children:e.jsxs("div",{className:"mono text-[10px] text-[var(--text1)] uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx("span",{className:"rounded-full shrink-0",style:{width:"5px",height:"5
1px",background:"var(--teal)"}}),r("latency.rankings")]})}),e.jsx("div",{style:{padding:"16px"},children:g.length===0?e.jsx(O,{type:"neutral"}):e.jsxs("div",{className:"flex flex-col gap-3",children:[p.map((a,u)=>e.jsx(H,{service:a,maxLatency:y,rank:u+1},a.id)),h.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mono text-[9px] text-[var(--text2)] uppercase",style:{marginTop:"8px",letterSpacing:"0.08em"},children:r("svc.latency.statusPage")}),[...h].sort((a,u)=>a.latency-u.latency).map(a=>e.jsx(H,{service:a,maxLatency:y,rank:"â"},a.id))]}),e.jsx("p",{className:"text-[10px] text-[var(--text2)] mono",style:{marginTop:"12px"},children:r("latency.excludeNote")})]})})]}),e.jsx(Y,{services:p,t:r,hourlyData:o.length>0?J(o):S})]})}export{te 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.