import{u as b}from"./useQuery-DB4moXtm.js";import{i as a,x as T}from"./index-CXwCk-SR.js";function C(o){if(!o)return;const t=/^([+-])(\d{2})(\d{2})$/.exec(o);return t?(t[1]==="-"?-1:1)*(Number(t[2])*60+Number(t[3])):void 0}function z(){const o=b({queryKey:["oap-info"],queryFn:()=>T.menu.oapInfo(),staleTime:2e4,refetchInterval:3e4,refetchOnWindowFocus:!0}),t=a(()=>o.data.value??null),c=a(()=>{var e;return((e=t.value)==null?void 0:e.reachable)??!1}),m=a(()=>{var e;return(e=t.value)==null?void 0:e.version}),s=a(()=>{var e;return(e=t.value)==null?void 0:e.healthScore}),l=a(()=>{var e;return C((e=t.value)==null?void 0:e.timezone)}),v=a(()=>{const e=l.value;if(e==null)return"";const n=e>=0?"+":"-",u=Math.abs(e),r=Math.floor(u/60),i=u%60;return i===0?`UTC${n}${r}`:`UTC${n}${r}:${String(i).padStart(2,"0")}`});function $(e,n="minute"){const u=l.value;if(u==null)return"";const r=new Date(e+u*6e4),i=r.getUTCFullYear(),f=String(r.getUTCMonth()+1).padStart(2,"0"),d=String(r.getUTCDate()).padStart(2,"0");if(n==="day")return`${i}-${f}-${d}`;const h=String(r.getUTCHours()).padStart(2,"0");if(n==="hour")return`${i}-${f}-${d} ${h}`;const S=String(r.getUTCMinutes()).padStart(2,"0");return`${i}-${f}-${d} ${h}${S}`}const p=a(()=>{var e,n;return{queryAlarms:((n=(e=t.value)==null?void 0:e.capabilities)==null?void 0:n.queryAlarms)??!1}}),g=a(()=>c.value?s.value===void 0?"unknown":s.value<0?"err":s.value>0?"warn":"ok":"err");return{isLoading:o.isLoading,info:t,reachable:c,version:m,timezone:l,tzOffsetLabel:v,healthScore:s,healthState:g,capabilities:p,toServerTzString:$,refetch:o.refetch}}export{z as u};
