ot-gateway 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/VERSION +1 -1
- package/apps/gateway/src/main.mjs +452 -145
- package/apps/web/out/404/index.html +1 -1
- package/apps/web/out/404.html +1 -1
- package/apps/web/out/__next.__PAGE__.txt +6 -6
- package/apps/web/out/__next._full.txt +6 -6
- package/apps/web/out/__next._tree.txt +2 -2
- package/apps/web/out/_next/static/chunks/0-tykl1ek9eef.js +1 -0
- package/apps/web/out/_next/static/chunks/0_9hphsk8elkz.js +1 -0
- package/apps/web/out/_next/static/chunks/2-12vm-gmodvi.css +1 -0
- package/apps/web/out/_next/static/chunks/2hhp92plmhxim.js +1 -0
- package/apps/web/out/_next/static/chunks/2t90haogl_st8.js +1 -0
- package/apps/web/out/_next/static/chunks/2vp-i92uyys5d.js +1 -0
- package/apps/web/out/_next/static/chunks/3k0dufyi1j19w.js +12 -0
- package/apps/web/out/_not-found/__next._full.txt +4 -4
- package/apps/web/out/_not-found/__next._not-found.__PAGE__.txt +4 -4
- package/apps/web/out/_not-found/__next._tree.txt +2 -2
- package/apps/web/out/_not-found/index.html +1 -1
- package/apps/web/out/_not-found/index.txt +4 -4
- package/apps/web/out/index.html +1 -1
- package/apps/web/out/index.txt +6 -6
- package/apps/web/out/messages/__next._full.txt +6 -6
- package/apps/web/out/messages/__next._tree.txt +2 -2
- package/apps/web/out/messages/__next.messages.__PAGE__.txt +6 -6
- package/apps/web/out/messages/index.html +1 -1
- package/apps/web/out/messages/index.txt +6 -6
- package/apps/web/out/points/__next._full.txt +6 -6
- package/apps/web/out/points/__next._tree.txt +2 -2
- package/apps/web/out/points/__next.points.__PAGE__.txt +6 -6
- package/apps/web/out/points/index.html +1 -1
- package/apps/web/out/points/index.txt +6 -6
- package/apps/web/out/settings/__next._full.txt +6 -6
- package/apps/web/out/settings/__next._tree.txt +2 -2
- package/apps/web/out/settings/__next.settings.__PAGE__.txt +6 -6
- package/apps/web/out/settings/index.html +1 -1
- package/apps/web/out/settings/index.txt +6 -6
- package/package.json +1 -1
- package/packaging/compose.yaml +1 -1
- package/apps/web/out/_next/static/chunks/03_syxbyimnor.js +0 -1
- package/apps/web/out/_next/static/chunks/1-_c1aqhwim5t.css +0 -1
- package/apps/web/out/_next/static/chunks/1bh2-eknm9t8k.js +0 -1
- package/apps/web/out/_next/static/chunks/259s9pubapqip.js +0 -1
- package/apps/web/out/_next/static/chunks/25dqruymh00rk.js +0 -1
- package/apps/web/out/_next/static/chunks/3b0ql-jh_xg_k.js +0 -12
- package/apps/web/out/_next/static/chunks/3o5cr1y-sws-u.js +0 -1
- /package/apps/web/out/_next/static/{r5hL3CDxDJkHMarR92YKm → XiBzAo3f0YeQ4E_ciqAE_}/_buildManifest.js +0 -0
- /package/apps/web/out/_next/static/{r5hL3CDxDJkHMarR92YKm → XiBzAo3f0YeQ4E_ciqAE_}/_clientMiddlewareManifest.js +0 -0
- /package/apps/web/out/_next/static/{r5hL3CDxDJkHMarR92YKm → XiBzAo3f0YeQ4E_ciqAE_}/_ssgManifest.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,61981,e=>{"use strict";var t=e.i(94115),a=e.i(20367),s=e.i(80136),r=e.i(71513),l=e.i(7347),n=e.i(64036),i=e.i(44946),o=e.i(29164),d=e.i(89486),c=e.i(86224);let u={value:"default",metadata:"secondary",health:"outline","command result":"warning",other:"outline"},m=[["value","Values"],["metadata","Metadata"],["health","Health"],["command result","Command results"],["other","Other"]],h=e=>`${e.toLocaleString()} ${1===e?"topic":"topics"}`;e.s(["default",0,()=>{let e=(0,r.Z)((0,s.useGateway)()),{messages:x,failed:p}=(()=>{let[e,t]=(0,a.useState)(void 0),[s,l]=(0,a.useState)(void 0);return(0,a.useEffect)(()=>{let e,a=!1,s=()=>(0,d.I)(d.x).then(n=>{a||("Success"===n._tag?(t(n.success),l(void 0)):l(n.failure.message),e=setTimeout(()=>void s(),r.z))});return s(),()=>{a=!0,void 0!==e&&clearTimeout(e)}},[]),{messages:e,failed:s}})(),[g,f]=(0,a.useState)({query:"",kind:"all"}),v=""!==g.query||"all"!==g.kind,b=x?.messages??[],w=(0,a.useMemo)(()=>b.filter(e=>((e,t)=>{if("all"!==t.kind&&(0,d.D)(e.topic)!==t.kind)return!1;let a=t.query.toLowerCase().split(/\s+/).filter(e=>""!==e);if(0===a.length)return!0;let s=`${e.topic} ${e.payload}`.toLowerCase();return a.every(e=>s.includes(e))})(e,g)),[b,g]);(0,s.useListCount)(x?.messages.length,v?w.length:void 0,"topic");let{body:j,range:N,rowHeight:y}=(0,c.f)(w.length,57),k=(0,a.useMemo)(()=>{let e=(e=>{let t=new Map;for(let a of e){let e=(0,d.D)(a.topic);t.set(e,(t.get(e)??0)+1)}return t})(b);return[{value:"all",label:"All kinds",detail:h(b.length)},...m.filter(([t])=>e.has(t)||t===g.kind).map(([t,a])=>({value:t,label:a,detail:h(e.get(t)??0)}))]},[b,g.kind]),M=void 0===e?"":`${e.site}/${e.building}/`,C=e?.now??Date.now();return void 0===x?(0,t.jsx)("p",{className:"text-muted-foreground",children:void 0===p?"Loading…":`The gateway does not answer: ${p}`}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("p",{className:"max-w-3xl text-sm text-muted-foreground",children:["The latest message on each topic the gateway publishes: what a client subscribed to"," ",(0,t.jsxs)("code",{className:"font-mono",children:[M,"#"]})," receives. A value goes to"," ",(0,t.jsx)("code",{className:"font-mono",children:"site/building/device/point"})," as its publish mode says, its metadata to"," ",(0,t.jsx)("code",{className:"font-mono",children:"…/$meta"}),", and the gateway's health to"," ",(0,t.jsxs)("code",{className:"font-mono",children:["…/$gateway/",e?.id??"id","/health"]}),"."]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,t.jsxs)("div",{className:"relative min-w-0 flex-1 basis-64",children:[(0,t.jsx)("input",{"aria-label":"Search messages",className:`h-9 w-full rounded-md border bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-search-cancel-button]:appearance-none ${""===g.query?"":"pr-20"}`,onChange:e=>f({...g,query:e.target.value}),placeholder:"Search topics and payloads…",type:"search",value:g.query}),""===g.query?null:(0,t.jsxs)("button",{className:"absolute top-1/2 right-1.5 flex -translate-y-1/2 items-center gap-1 rounded px-1.5 py-0.5 text-xs hover:bg-muted",onClick:()=>f({...g,query:""}),type:"button",children:[(0,t.jsx)("span",{"aria-hidden":"true",children:"✕"}),"Reset"]})]}),(0,t.jsx)(i.f,{className:"w-full sm:w-56",emptyText:"No kind found.",label:"Kind",onChange:e=>{let t;return f({...g,kind:(t=e,m.find(([e])=>e===t)?.[0]??"all")})},options:k,searchPlaceholder:"Search kinds…",value:g.kind})]}),(0,t.jsx)(n.N,{className:"py-0",children:(0,t.jsx)(n.O,{className:"px-0",children:0===w.length?(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 p-6 text-sm text-muted-foreground",children:[(0,t.jsx)("p",{children:0===b.length?"Nothing published yet.":"No message matches."}),v?(0,t.jsx)("button",{className:"font-medium text-foreground underline-offset-4 hover:underline",onClick:()=>f({query:"",kind:"all"}),type:"button",children:"Clear filters"}):null]}):(0,t.jsxs)(o.s,{"aria-rowcount":w.length+1,containerClassName:"overflow-clip rounded-xl",children:[(0,t.jsx)(o.E,{className:"sticky top-0 z-10 [&_th]:bg-card [&_th]:shadow-[inset_0_-1px_0_var(--border)] [&_tr]:border-0",children:(0,t.jsxs)(o.N,{"aria-rowindex":1,className:"hover:bg-transparent",children:[(0,t.jsx)(o.U,{className:"pl-4",children:"Topic"}),(0,t.jsx)(o.U,{children:"Latest payload"}),(0,t.jsx)(o.U,{className:"hidden text-right sm:table-cell",children:"Messages"}),(0,t.jsx)(o.U,{className:"pr-4 text-right",children:"Sent at"})]})}),(0,t.jsxs)(o.z,{ref:j,children:[0===N.start?null:(0,t.jsx)("tr",{"aria-hidden":"true",style:{height:N.start*y}}),w.slice(N.start,N.end).map((e,a)=>{let s=N.start+a,r=(0,d.D)(e.topic),n=e.topic.startsWith(M)?e.topic.slice(M.length):e.topic;return(0,t.jsxs)(o.N,{"aria-rowindex":s+2,className:"h-14","data-row":s,children:[(0,t.jsxs)(o.d,{className:"max-w-56 pl-4 sm:max-w-96",children:[(0,t.jsxs)("p",{className:"truncate font-mono text-xs",title:e.topic,children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:M}),n]}),(0,t.jsxs)("div",{className:"mt-1 flex gap-1",children:[(0,t.jsx)(l.f,{variant:u[r],children:r}),e.retained?(0,t.jsx)(l.f,{title:"The broker keeps it and gives it to every subscriber that connects later",variant:"outline",children:"retained"}):null]})]}),(0,t.jsx)(o.d,{className:"max-w-40 sm:max-w-md",children:(0,t.jsxs)("code",{className:"block truncate font-mono text-xs",title:e.payload,children:[e.payload,e.truncated?"…":""]})}),(0,t.jsx)(o.d,{className:"hidden text-right tabular-nums sm:table-cell",children:e.count.toLocaleString()}),(0,t.jsx)(o.d,{className:"pr-4 text-right text-muted-foreground tabular-nums",children:(0,d.w)(e.at,C)})]},e.topic)}),N.end===w.length?null:(0,t.jsx)("tr",{"aria-hidden":"true",style:{height:(w.length-N.end)*y}})]})]})})}),x.droppedTopics>0?(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:[x.droppedTopics.toLocaleString()," more topics are not shown, and search does not find them: the gateway keeps the latest message of at most ",x.messages.length.toLocaleString()," topics."]}):null]})}],61981)},64036,e=>{"use strict";var t=e.i(94115),a=e.i(52088);e.s(["N",0,({className:e,...s})=>(0,t.jsx)("div",{"data-slot":"card",className:(0,a.f)("flex flex-col gap-4 rounded-xl border bg-card py-5 text-card-foreground shadow-sm",e),...s}),"O",0,({className:e,...s})=>(0,t.jsx)("div",{"data-slot":"card-content",className:(0,a.f)("px-5",e),...s}),"u",0,({className:e,...s})=>(0,t.jsx)("div",{"data-slot":"card-description",className:(0,a.f)("text-sm text-muted-foreground",e),...s}),"Y",0,({className:e,...s})=>(0,t.jsx)("div",{"data-slot":"card-header",className:(0,a.f)("grid auto-rows-min items-start gap-1.5 px-5",e),...s}),"v",0,({className:e,...s})=>(0,t.jsx)("div",{"data-slot":"card-title",className:(0,a.f)("leading-none font-semibold",e),...s})])},44946,86224,e=>{"use strict";var t=e.i(94115),a=e.i(20367),s=e.i(81081),r=e.i(52088);let l={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};e.s(["f",0,({options:e,value:n,onChange:i,label:o,searchPlaceholder:d,emptyText:c,className:u})=>{let m=(0,a.useId)(),h=`${m}-list`,x=e=>`${m}-option-${e}`,p=(0,a.useRef)(null),g=(0,a.useRef)(null),f=(0,a.useRef)(null),v=(0,a.useRef)(null),[b,w]=(0,a.useState)(!1),[j,N]=(0,a.useState)(""),[y,k]=(0,a.useState)(0),M=e.find(e=>e.value===n),C=(0,a.useMemo)(()=>e.filter(e=>(0,s.w)(`${e.label} ${e.detail??""} ${e.keywords??""}`,j)),[e,j]),L=C.slice(0,100),S=()=>{N("");let t=void 0===M?-1:e.indexOf(M);k(t>=0&&t<100?t:0),w(!0)},$=e=>{w(!1),e&&g.current?.focus()},E=e=>{void 0!==e&&(i(e.value),$(!0))};return(0,a.useLayoutEffect)(()=>{b&&f.current?.focus()},[b]),(0,a.useLayoutEffect)(()=>{b&&v.current?.querySelector(`[data-index="${y}"]`)?.scrollIntoView({block:"nearest"})},[b,y]),(0,a.useEffect)(()=>{if(!b)return;let e=e=>{e.target instanceof Node&&!p.current?.contains(e.target)&&$(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[b]),(0,t.jsxs)("div",{className:(0,r.f)("relative",u),ref:p,children:[(0,t.jsxs)("button",{"aria-expanded":b,"aria-haspopup":"listbox","aria-label":`${o}: ${M?.label??""}`,className:"flex h-9 w-full items-center gap-2 rounded-md border bg-background px-3 text-sm hover:bg-muted/50 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",onClick:()=>b?$(!1):S(),onKeyDown:e=>{"ArrowDown"!==e.key||b||(e.preventDefault(),S())},ref:g,type:"button",children:[M?.leading,(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate text-left",children:M?.label}),(0,t.jsx)("svg",{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground",...l,children:(0,t.jsx)("path",{d:"m7 15 5 5 5-5M7 9l5-5 5 5"})})]}),b?(0,t.jsxs)("div",{className:"absolute top-[calc(100%+4px)] right-0 z-50 flex w-[min(20rem,calc(100vw-2rem))] flex-col overflow-hidden rounded-lg border bg-card text-card-foreground shadow-lg motion-safe:animate-[popover-in_120ms_ease-out]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 border-b px-3",children:[(0,t.jsxs)("svg",{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground",...l,children:[(0,t.jsx)("circle",{cx:"11",cy:"11",r:"7"}),(0,t.jsx)("path",{d:"m20 20-3.5-3.5"})]}),(0,t.jsx)("input",{"aria-activedescendant":void 0===L[y]?void 0:x(y),"aria-autocomplete":"list","aria-controls":h,"aria-expanded":"true","aria-label":d,className:"h-10 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground",onChange:e=>{N(e.target.value),k(0)},onKeyDown:e=>{let t=L.length-1,a=a=>{e.preventDefault(),k(Math.min(Math.max(a,0),Math.max(t,0)))};switch(e.key){case"ArrowDown":return a(y+1);case"ArrowUp":return a(y-1);case"Home":return a(0);case"End":return a(t);case"PageDown":return a(y+8);case"PageUp":return a(y-8);case"Enter":return e.preventDefault(),E(L[y]);case"Escape":return e.preventDefault(),e.stopPropagation(),$(!0);case"Tab":return $(!1)}},placeholder:d,ref:f,role:"combobox",value:j})]}),(0,t.jsxs)("ul",{"aria-label":o,className:"max-h-[min(18rem,50dvh)] overflow-y-auto overscroll-contain p-1",id:h,ref:v,role:"listbox",children:[0===L.length?(0,t.jsx)("li",{className:"px-2 py-6 text-center text-sm text-muted-foreground",children:c}):L.map((e,a)=>(0,t.jsxs)("li",{"aria-selected":e.value===n,className:(0,r.f)("flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm select-none",a===y&&"bg-muted"),"data-index":a,id:x(a),onMouseDown:e=>e.preventDefault(),onClick:()=>E(e),onPointerMove:()=>k(a),role:"option",children:[e.leading,(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.label}),void 0===e.detail?null:(0,t.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:e.detail}),(0,t.jsx)("svg",{"aria-hidden":"true",className:(0,r.f)("size-4 shrink-0",e.value!==n&&"invisible"),...l,children:(0,t.jsx)("path",{d:"M20 6 9 17l-5-5"})})]},e.value)),C.length>L.length?(0,t.jsxs)("li",{className:"px-2 py-2 text-center text-xs text-muted-foreground",role:"presentation",children:[(C.length-L.length).toLocaleString()," more: type to narrow"]}):null]})]}):null]})}],44946),e.s(["f",0,(e,t)=>{let s=(0,a.useRef)(null),r=(0,a.useRef)(t),[l,n]=(0,a.useState)(()=>({start:0,end:Math.min(e,30)})),[i,o]=(0,a.useState)(t),d=(0,a.useCallback)(()=>{var t;let a,l=s.current;if(null===l)return;let i=l.querySelector("[data-row]")?.getBoundingClientRect().height;void 0!==i&&i>0&&Math.abs(i-r.current)>.5&&(r.current=i,o(i));let d={start:a=Math.min((t={top:-l.getBoundingClientRect().top,height:window.innerHeight,rowHeight:r.current,count:e,overscan:8}).count,Math.max(0,Math.floor(t.top/t.rowHeight)-t.overscan)),end:Math.max(a,Math.min(t.count,Math.max(0,Math.ceil((t.top+t.height)/t.rowHeight)+t.overscan)))};n(e=>e.start===d.start&&e.end===d.end?e:d)},[e]);(0,a.useLayoutEffect)(d,[d]),(0,a.useEffect)(()=>{let e=0,t=()=>{0===e&&(e=requestAnimationFrame(()=>{e=0,d()}))};return window.addEventListener("scroll",t,{passive:!0}),window.addEventListener("resize",t),()=>{cancelAnimationFrame(e),window.removeEventListener("scroll",t),window.removeEventListener("resize",t)}},[d]);let c=(0,a.useCallback)(e=>{let t=s.current;if(null===t)return;let a=t.getBoundingClientRect().top+e*r.current;(a<0||a+r.current>window.innerHeight)&&window.scrollBy({top:a-window.innerHeight/2+r.current/2}),d()},[d]);return{body:s,range:l,rowHeight:i,reveal:c}}],86224)},29164,e=>{"use strict";var t=e.i(94115),a=e.i(52088);e.s(["s",0,({className:e,containerClassName:s="overflow-x-auto",...r})=>(0,t.jsx)("div",{"data-slot":"table-container",className:(0,a.f)("relative w-full",s),children:(0,t.jsx)("table",{"data-slot":"table",className:(0,a.f)("w-full caption-bottom text-sm",e),...r})}),"z",0,({className:e,...s})=>(0,t.jsx)("tbody",{"data-slot":"table-body",className:(0,a.f)("[&_tr:last-child]:border-0",e),...s}),"d",0,({className:e,...s})=>(0,t.jsx)("td",{"data-slot":"table-cell",className:(0,a.f)("p-2 align-middle whitespace-nowrap",e),...s}),"U",0,({className:e,...s})=>(0,t.jsx)("th",{"data-slot":"table-head",className:(0,a.f)("h-9 px-2 text-left align-middle font-medium whitespace-nowrap text-muted-foreground",e),...s}),"E",0,({className:e,...s})=>(0,t.jsx)("thead",{"data-slot":"table-header",className:(0,a.f)("[&_tr]:border-b",e),...s}),"N",0,({className:e,...s})=>(0,t.jsx)("tr",{"data-slot":"table-row",className:(0,a.f)("border-b transition-colors hover:bg-muted/50",e),...s})])}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,72469,e=>{"use strict";let t;var a=e.i(94115),s=e.i(30302),r=e.i(20367),n=e.i(80136),i=e.i(71513);e.i(66563);var l=e.i(71658),o=e.i(83453),d=e.i(92387),c=e.i(4270),c=c,u=c,m=e.i(87486),x=e.i(97490),h=e.i(12379),f=e.i(50492),g=e.i(27195),p=e.i(84279),v=e.i(89486);let b=[{id:"15m",label:"15 min",ms:9e5},{id:"1h",label:"1 h",ms:36e5},{id:"24h",label:"24 h",ms:864e5},{id:"7d",label:"7 days",ms:6048e5}],j=p.f.make(l.K,{baseUrl:window.location.origin}),w=(e,t,a=4)=>{if(!Number.isFinite(e)||!Number.isFinite(t)||e>t)return[0,1];if(e===t){let s=.05*Math.abs(e)||1;return w(e-s,t+s,a)}let s=(t-e)/a,r=10**Math.floor(Math.log10(s)),n=([1,2,5,10].find(e=>e*r>=s)??10)*r,i=Math.floor(e/n)*n,l=[];for(let e=0;;e++){let a=Number((i+e*n).toPrecision(12));if(l.push(a),a>=t)return l}},N=[6e4,3e5,9e5,18e5,36e5,108e5,216e5,864e5],y=(e,t)=>t?`${Math.round(100*e)} % on`:Number(e.toPrecision(4)).toLocaleString(),k=({series:e,unit:t,boolean:s,label:n})=>{let[i,l]=(()=>{let e=(0,r.useRef)(null),[t,a]=(0,r.useState)(0);return(0,r.useEffect)(()=>{let t=e.current;if(null===t)return;let s=new ResizeObserver(([e])=>a(e?.contentRect.width??0));return s.observe(t),()=>s.disconnect()},[]),[e,t]})(),[o,d]=(0,r.useState)(void 0),{buckets:c,stepMs:u,from:m,to:x}=e,h=c.map(e=>e.min),f=c.map(e=>e.max),g=s?[0,1]:w(Math.min(...h),Math.max(...f)),p=g[0]??0,b=g.at(-1)??1,j=Math.max(0,l-48-12),k=e=>48+(e+u/2-m)/(x-m)*j,$=e=>8+(b-e)/(b-p||1)*120,M=((e,t,a=5)=>{let s=N.find(s=>(t-e)/s<=a)??864e5,r=6e4*new Date(e).getTimezoneOffset(),n=[];for(let a=Math.ceil((e-r)/s)*s+r;a<=t;a+=s)n.push(a);return{ticks:n,step:s}})(m,x),S=((e,t)=>{let a=[],s=[];for(let r of e){let e=s.at(-1);void 0!==e&&r.t-e.t>2*t&&(a.push(s),s=[]),s.push(r)}return s.length>0&&a.push(s),a})(c,u),E=void 0===o?void 0:((e,t)=>{let a;for(let s of e)(void 0===a||Math.abs(s.t-t)<Math.abs(a.t-t))&&(a=s);return a})(c,o),_=(0,v.E)(t);return(0,a.jsxs)("div",{ref:i,className:"relative",children:[0===c.length?(0,a.jsx)("p",{className:"flex h-[150px] items-center justify-center text-sm text-muted-foreground",children:"No reads in this range yet."}):0===l?(0,a.jsx)("div",{className:"h-[150px]"}):(0,a.jsxs)("svg",{"aria-label":`${n}: ${c.length} buckets, ${y(p,s)} to ${y(b,s)}`,className:"block touch-none select-none",height:150,onPointerLeave:()=>d(void 0),onPointerMove:e=>{let t=e.currentTarget.getBoundingClientRect(),a=(e.clientX-t.left-48)/j;d(a<0||a>1?void 0:m+a*(x-m)-u/2)},role:"img",width:l,children:[g.map(e=>(0,a.jsxs)("g",{children:[(0,a.jsx)("line",{stroke:"var(--border)",x1:48,x2:l-12,y1:$(e),y2:$(e)}),(0,a.jsx)("text",{className:"fill-muted-foreground text-[11px] tabular-nums",textAnchor:"end",x:42,y:$(e)+4,children:s?1===e?"on":"off":e.toLocaleString()})]},e)),M.ticks.map(e=>(0,a.jsx)("text",{className:"fill-muted-foreground text-[11px] tabular-nums",textAnchor:"middle",x:48+(e-m)/(x-m)*j,y:144,children:M.step>=864e5?new Date(e).toLocaleDateString([],{weekday:"short",day:"numeric"}):new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},e)),S.map(e=>{let t=e.map(e=>`${k(e.t)},${$(e.max)}`),r=e.toReversed().map(e=>`${k(e.t)},${$(e.min)}`),n=e.map((e,t)=>0===t?`M${k(e.t)},${$(e.avg)}`:s?`H${k(e.t)}V${$(e.avg)}`:`L${k(e.t)},${$(e.avg)}`);return(0,a.jsxs)("g",{children:[s?null:(0,a.jsx)("polygon",{fill:"var(--series-1)",fillOpacity:.14,points:[...t,...r].join(" ")}),(0,a.jsx)("path",{d:n.join(" "),fill:"none",stroke:"var(--series-1)",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2}),1===e.length?(0,a.jsx)("circle",{cx:k(e[0]?.t??0),cy:$(e[0]?.avg??0),fill:"var(--series-1)",r:3}):null]},e[0]?.t)}),void 0===E?null:(0,a.jsxs)("g",{pointerEvents:"none",children:[(0,a.jsx)("line",{stroke:"var(--muted-foreground)",strokeDasharray:"3 3",x1:k(E.t),x2:k(E.t),y1:8,y2:128}),(0,a.jsx)("circle",{cx:k(E.t),cy:$(E.avg),fill:"var(--series-1)",r:4,stroke:"var(--card)",strokeWidth:2})]})]}),void 0===E?null:(0,a.jsxs)("div",{className:"pointer-events-none absolute top-0 z-10 rounded-md border bg-card text-card-foreground px-2.5 py-1.5 text-xs shadow-md",style:{left:Math.min(Math.max(k(E.t)+10,0),Math.max(0,l-170)),minWidth:150},children:[(0,a.jsx)("div",{className:"text-muted-foreground tabular-nums",children:new Date(E.t).toLocaleString([],{weekday:"short",hour:"2-digit",minute:"2-digit",second:u<6e4?"2-digit":void 0})}),(0,a.jsxs)("div",{className:"font-mono tabular-nums",children:[y(E.avg,s)," ",s?"":_]}),s||1===E.count?null:(0,a.jsxs)("div",{className:"text-muted-foreground tabular-nums",children:[(0,v.z)(Number(E.min.toPrecision(4)))," – ",(0,v.z)(Number(E.max.toPrecision(4)))," ",_]}),(0,a.jsxs)("div",{className:"text-muted-foreground tabular-nums",children:[E.count.toLocaleString()," ",1===E.count?"read":"reads"]})]})]})},$=({value:e,unit:t,now:s,className:n=""})=>{let[i]=(0,r.useState)(e?.ts),l=e?.ts!==void 0&&e.ts!==i;return(0,a.jsxs)("span",{className:`rounded px-1 ${l?"motion-safe:animate-[value-changed_1.2s_ease-out]":""} ${n}`,title:e?.ts===void 0?"nothing read yet":`read ${(0,v.w)(e.ts,s)}`,children:[(0,v.z)(e?.value)," ",(0,a.jsx)("span",{className:"text-muted-foreground",children:(0,v.E)(t)})]},e?.ts)};var M=e.i(7347);let S=({label:e,children:t})=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("dt",{className:"text-muted-foreground",children:e}),(0,a.jsx)("dd",{className:"min-w-0 font-mono break-words",children:t})]}),E=({topic:e})=>{let[t,s]=(0,r.useState)(!1);return(0,a.jsxs)("span",{className:"inline-flex flex-wrap items-center gap-2",children:[(0,a.jsx)("span",{className:"break-all",children:e}),(0,a.jsx)("button",{className:"rounded border px-1.5 py-0.5 font-sans text-xs text-muted-foreground hover:text-foreground",onClick:()=>{navigator.clipboard?.writeText(e).then(()=>{s(!0),setTimeout(()=>s(!1),1500)})},type:"button",children:t?"Copied":"Copy"})]})},_="rounded-md px-2 py-1 text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-40",C=({point:e,live:t,now:s,position:n,morph:i,unreachable:l,onStep:p,onClose:w})=>{let N,y=(0,r.useRef)(null),[C,D]=(0,r.useState)(b[1]),L=((e,t,a)=>{let s=`${e}/${t}@${a.id}`,[n,i]=(0,r.useState)({});return(0,r.useEffect)(()=>{let r,n=!1,l=()=>{let p;return(0,v.I)((p=Date.now(),j.pipe(o.f.flatMap(s=>s.status.history({query:{device:e,point:t,from:p-a.ms,to:p,buckets:240}})),d.f.map(e=>({_tag:"series",series:e})),c.catchTags({HistoryUnavailable:e=>u.succeed({_tag:"off",message:e.message}),HistoryQueryInvalid:e=>u.succeed({_tag:"off",message:e.message})}),m.f.mapError(e=>new v.i({message:e.message})),x.f.provide(g.f.layer),h.f.timeoutOrElse({duration:"5 seconds",orElse:()=>f.f.fail(new v.i({message:"no answer within 5 s"}))})))).then(e=>{n||(i(t=>"Success"===e._tag?{of:s,series:e.success}:{...t,unreachable:e.failure.message}),r=setTimeout(()=>void l(),a.ms<=36e5?5e3:6e4))})};return l(),()=>{n=!0,void 0!==r&&clearTimeout(r)}},[e,t,a,s]),{...n,stale:n.of!==s}})(e.device,e.id,C),T=t?.value,R=t?.device,P=void 0===R?void 0:(0,v.g)(R,s);return(0,r.useLayoutEffect)(()=>{let e=y.current;if(null!==e)return e.open||e.showModal(),e.focus(),()=>e.close()},[]),(0,a.jsx)("dialog",{"aria-label":`${e.device}/${e.id}`,className:`point-sheet ${i?"morphing":""} ms-auto me-0 my-0 h-dvh max-h-dvh w-[min(36rem,100vw)] max-w-full overflow-y-auto border-l bg-card p-0 outline-none text-card-foreground shadow-2xl`,onCancel:e=>{e.preventDefault(),w()},onClick:e=>{e.target===e.currentTarget&&w()},onKeyDown:e=>{if(e.target instanceof HTMLInputElement)return;let t="ArrowDown"===e.key||"j"===e.key?1:"ArrowUp"===e.key||"k"===e.key?-1:0;0!==t&&(e.preventDefault(),p(t))},ref:y,style:{viewTransitionName:"point-sheet"},tabIndex:-1,children:(0,a.jsxs)("div",{className:"flex flex-col gap-6 p-6",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"font-mono text-sm text-muted-foreground",children:e.device}),(0,a.jsx)("h2",{className:"w-fit font-mono text-lg font-semibold break-all",children:e.id}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:e.name})]}),(0,a.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[void 0===n?null:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{className:"mr-1 text-xs text-muted-foreground tabular-nums",children:[n.index," of ",n.total]}),(0,a.jsx)("button",{"aria-label":"Previous point (↑ or k)",className:_,disabled:n.index<=1,onClick:()=>p(-1),title:"Previous point (↑ or k)",type:"button",children:"↑"}),(0,a.jsx)("button",{"aria-label":"Next point (↓ or j)",className:_,disabled:n.index>=n.total,onClick:()=>p(1),title:"Next point (↓ or j)",type:"button",children:"↓"})]}),(0,a.jsx)("button",{"aria-label":"Close (Esc)",className:_,onClick:w,title:"Close (Esc)",type:"button",children:"✕"})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("p",{className:`font-mono text-3xl font-semibold tabular-nums ${l?"opacity-50":""}`,children:(0,a.jsx)($,{className:"-mx-1",now:s,unit:e.unit,value:T},`${e.device}/${e.id}`)}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[l?(0,a.jsx)(M.f,{variant:"destructive",children:"gateway unreachable: last known value"}):null,P?._tag==="failing"?(0,a.jsxs)(M.f,{variant:"destructive",children:["device failing: ",(0,v.F)(P.reason)]}):null,P?._tag==="late"?(0,a.jsx)(M.f,{variant:"warning",children:"device late"}):null,e.writable?(0,a.jsx)(M.f,{variant:"outline",children:"writable"}):null,(0,a.jsx)("span",{children:T?.ts===void 0?"nothing read yet":`read ${(0,v.w)(T.ts,s)}`})]})]}),(0,a.jsxs)("section",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,a.jsx)("h3",{className:"text-sm font-medium",children:"History"}),(0,a.jsx)("div",{className:"inline-flex rounded-md border p-0.5",role:"group","aria-label":"Range",children:b.map(e=>(0,a.jsx)("button",{"aria-pressed":e.id===C.id,className:`rounded px-2.5 py-1 text-xs ${e.id===C.id?"bg-muted font-medium":"text-muted-foreground hover:text-foreground"}`,onClick:()=>D(e),type:"button",children:e.label},e.id))})]}),(0,a.jsx)("div",{className:`transition-opacity duration-200 ${L.stale?"opacity-40":""}`,children:void 0===L.series?(0,a.jsx)("div",{className:"h-[150px] animate-pulse rounded-md bg-muted"}):"off"===L.series._tag?(0,a.jsx)("p",{className:"flex h-[150px] items-center justify-center text-sm text-muted-foreground",children:L.series.message}):(0,a.jsx)(k,{boolean:"boolean"==typeof T?.value,label:e.id,series:L.series.series,unit:e.unit})}),void 0===L.unreachable?null:(0,a.jsx)("p",{className:"text-xs text-destructive",title:L.unreachable,children:"History is not updating: the gateway does not answer."})]}),(0,a.jsxs)("section",{className:"flex flex-col gap-2",children:[(0,a.jsx)("h3",{className:"text-sm font-medium",children:"Configuration"}),(0,a.jsxs)("dl",{className:"grid grid-cols-[max-content_1fr] gap-x-6 gap-y-2 text-sm",children:[(0,a.jsx)(S,{label:"Topic",children:(0,a.jsx)(E,{topic:e.topic})}),(0,a.jsx)(S,{label:"Source",children:e.source}),(0,a.jsx)(S,{label:"Publishes",children:e.publish}),void 0===e.unit?null:(0,a.jsxs)(S,{label:"Unit",children:[(0,v.E)(e.unit)," ",(0,a.jsxs)("span",{className:"text-muted-foreground",children:["(",e.unit,")"]})]}),void 0===e.scaling?null:(0,a.jsx)(S,{label:"Scaling",children:(N=e.scaling,`raw \xd7 ${N.factor}${0===N.offset?"":` ${N.offset<0?"−":"+"} ${Math.abs(N.offset)}`}`)}),void 0===e.limits?null:(0,a.jsxs)(S,{label:"Write limits",children:[e.limits.min," to ",e.limits.max]}),void 0===e.brick?null:(0,a.jsx)(S,{label:"Brick",children:e.brick}),void 0===e.haystack||0===e.haystack.length?null:(0,a.jsx)(S,{label:"Haystack",children:(0,a.jsx)("span",{className:"flex flex-wrap gap-1",children:e.haystack.map(e=>(0,a.jsx)(M.f,{variant:"secondary",children:e},e))})})]})]})]})})};var D=e.i(64036),L=e.i(44946),T=e.i(29164),R=e.i(81081),P=e.i(16634),z=e.i(86224);let H={live:"bg-success",starting:"bg-muted-foreground/40",late:"bg-warning",failing:"bg-destructive"},U=e=>"live"===e._tag?"device answering":"starting"===e._tag?"device starting":"late"===e._tag?"device late: no answer for a few intervals":`device failing: ${(0,v.F)(e.reason)}`,A=({device:e,now:t})=>{if(void 0===e)return(0,a.jsx)("span",{"aria-hidden":"true",className:"size-2 shrink-0 rounded-full bg-muted"});let s=(0,v.g)(e,t);return(0,a.jsx)("span",{"aria-label":U(s),className:`size-2 shrink-0 rounded-full ${H[s._tag]}`,role:"img",title:U(s)})},q=e=>`${e.toLocaleString()} ${1===e?"point":"points"}`,B=()=>{let e=(0,n.useGateway)(),l=(e=>{let a=void 0!==e&&t?.since===e?t.catalog:void 0,[s,n]=(0,r.useState)(()=>void 0===a?{_tag:"loading"}:{_tag:"ok",catalog:a});return(0,r.useEffect)(()=>{let a;if(void 0===e)return;if(t?.since===e)return n({_tag:"ok",catalog:t.catalog});let s=!1,r=()=>(0,v.I)(v.n).then(i=>{if(!s){if("Success"===i._tag)return t={since:e,catalog:i.success},n({_tag:"ok",catalog:i.success});n({_tag:"failed",message:i.failure.message}),a=setTimeout(()=>void r(),5e3)}});return r(),()=>{s=!0,void 0!==a&&clearTimeout(a)}},[e]),s})((0,i.Z)(e)?.since),[{filter:o,open:d},c]=(()=>{let e=(0,s.useSearchParams)().toString(),[t,a]=(0,r.useState)(()=>(0,R.l)(e));return(0,r.useEffect)(()=>{a(t=>(0,R.r)(t.filter,t.open).slice(1)===e?t:(0,R.l)(e))},[e]),[t,e=>{a(e),window.history.replaceState(null,"",`${window.location.pathname}${(0,R.r)(e.filter,e.open)}`)}]})(),[u,m]=(0,r.useState)(!1),x=(0,i.Z)(e),h="unreachable"===e._tag,f=(0,r.useMemo)(()=>(0,R.d)(x),[x]),g="ok"===l._tag?l.catalog:void 0,p=x?.now??Date.now(),b=(0,r.useMemo)(()=>void 0===g?[]:(0,R.M)(g),[g]),j=(0,r.useMemo)(()=>""===o.device||b.some(e=>e.id===o.device)?o:{...o,device:""},[o,b]),w=""!==j.query||""!==j.device,N=(0,r.useMemo)(()=>[{value:"",label:"All devices",detail:q(b.reduce((e,t)=>e+t.points,0))},...b.map(e=>{let t=f.get(e.id);return{value:e.id,label:e.id,detail:q(e.points),leading:(0,a.jsx)(A,{device:t,now:p}),...void 0===t?{}:{keywords:v.T[t.protocol]}}})],[b,f,p]),y=(0,r.useMemo)(()=>void 0===g?[]:g.points.filter(e=>(0,R.u)(e,j)),[g,j]);(0,n.useListCount)(g?.points.length,w?y.length:void 0,"point");let k=void 0===d?void 0:g?.points.find(e=>(0,R.Z)(e)===d),S=void 0===k?-1:y.indexOf(k),{body:E,range:_,rowHeight:H,reveal:U}=(0,z.f)(y.length,57),B=y.slice(_.start,_.end),O=(0,i.P)((0,r.useMemo)(()=>[...B.map(R.Z),...void 0===d?[]:[d]],[B,d])),Z=e=>({value:O.get((0,R.Z)(e)),device:f.get(e.device)}),F=(0,r.useRef)(void 0),K=()=>{if(void 0===F.current)return;let e=E.current?.querySelector(`[data-row="${F.current}"]`);null!=e&&(e.focus({preventScroll:!0}),F.current=void 0)};(0,r.useEffect)(K);let I=e=>{F.current=e,U(e),K()},V=e=>{c({filter:{...j,...e},...void 0===d?{}:{open:d}})},W=e=>c({filter:j,...void 0===e?{}:{open:e}}),J=e=>{m((0,P.J)()),(0,P.Z)(()=>W(e))};return void 0===g?(0,a.jsx)("p",{className:"text-muted-foreground",children:"failed"===l._tag?`The gateway does not answer: ${l.message}`:"Loading…"}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("div",{className:"relative min-w-0 flex-1 basis-64",children:[(0,a.jsx)("input",{"aria-label":"Search points",className:`h-9 w-full rounded-md border bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-search-cancel-button]:appearance-none ${""===j.query?"":"pr-20"}`,onChange:e=>V({query:e.target.value}),placeholder:"Search by id, name, topic, register, Brick class…",type:"search",value:j.query}),""===j.query?null:(0,a.jsxs)("button",{className:"absolute top-1/2 right-1.5 flex -translate-y-1/2 items-center gap-1 rounded px-1.5 py-0.5 text-xs hover:bg-muted",onClick:()=>V({query:""}),type:"button",children:[(0,a.jsx)("span",{"aria-hidden":"true",children:"✕"}),"Reset"]})]}),(0,a.jsx)(L.f,{className:"w-full sm:w-56",emptyText:"No device found.",label:"Device",onChange:e=>V({device:e}),options:N,searchPlaceholder:"Search devices…",value:j.device})]}),(0,a.jsx)(D.N,{className:"py-0",children:(0,a.jsx)(D.O,{className:"px-0",children:0===y.length?(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 p-6 text-sm text-muted-foreground",children:[(0,a.jsx)("p",{children:0===g.points.length?"The config has no points.":"No point matches."}),w?(0,a.jsx)("button",{className:"font-medium text-foreground underline-offset-4 hover:underline",onClick:()=>V({query:"",device:""}),type:"button",children:"Clear filters"}):null]}):(0,a.jsxs)(T.s,{"aria-rowcount":y.length+1,containerClassName:"overflow-clip rounded-xl",children:[(0,a.jsx)(T.E,{className:"sticky top-0 z-10 [&_th]:bg-card [&_th]:shadow-[inset_0_-1px_0_var(--border)] [&_tr]:border-0",children:(0,a.jsxs)(T.N,{"aria-rowindex":1,className:"hover:bg-transparent",children:[(0,a.jsx)(T.U,{className:"pl-4",children:"Point"}),(0,a.jsx)(T.U,{className:"hidden md:table-cell",children:"Device"}),(0,a.jsx)(T.U,{className:"text-right",children:"Value"}),(0,a.jsx)(T.U,{className:"hidden text-right sm:table-cell",children:"Read"}),(0,a.jsx)(T.U,{className:"hidden md:table-cell",children:"Source"}),(0,a.jsx)(T.U,{className:"hidden pr-4 lg:table-cell",children:"Publishes"})]})}),(0,a.jsxs)(T.z,{ref:E,children:[0===_.start?null:(0,a.jsx)("tr",{"aria-hidden":"true",style:{height:_.start*H}}),B.map((e,t)=>{let s=_.start+t,r=(0,R.Z)(e),n=Z(e),i=n.device?.status==="failing";return(0,a.jsxs)(T.N,{"aria-rowindex":s+2,"aria-selected":r===d,className:"h-14 cursor-pointer aria-selected:bg-muted","data-row":s,tabIndex:0,...{onClick:e=>{e.metaKey||e.ctrlKey||J(r)},onKeyDown:e=>{let t="ArrowDown"===e.key?s+1:"ArrowUp"===e.key?s-1:"Home"===e.key?0:"End"===e.key?y.length-1:void 0;if(void 0!==t){e.preventDefault(),I(Math.min(Math.max(t,0),y.length-1));return}("Enter"===e.key||" "===e.key)&&(e.preventDefault(),J(r))}},children:[(0,a.jsxs)(T.d,{className:"max-w-52 pl-4 sm:max-w-72",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(A,{device:n?.device,now:p}),(0,a.jsx)("span",{className:"truncate font-mono",children:e.id}),e.writable?(0,a.jsx)(M.f,{variant:"outline",children:"writable"}):null]}),(0,a.jsxs)("p",{className:"truncate pl-4 text-xs text-muted-foreground",title:e.name,children:[(0,a.jsxs)("span",{className:"font-mono md:hidden",children:[e.device," · "]}),e.name,void 0===e.brick?"":` \xb7 ${e.brick}`]})]}),(0,a.jsx)(T.d,{className:"hidden max-w-48 truncate font-mono text-muted-foreground md:table-cell",children:(0,a.jsx)("span",{title:e.device,children:e.device})}),(0,a.jsx)(T.d,{className:`text-right font-mono tabular-nums ${i||h?"opacity-50":""}`,children:(0,a.jsx)($,{now:p,unit:e.unit,value:n?.value})}),(0,a.jsx)(T.d,{className:"hidden text-right text-muted-foreground tabular-nums sm:table-cell",children:n?.value?.ts===void 0?"–":(0,v.w)(n.value.ts,p)}),(0,a.jsx)(T.d,{className:"hidden font-mono text-xs text-muted-foreground md:table-cell",children:e.source}),(0,a.jsx)(T.d,{className:"hidden pr-4 text-xs text-muted-foreground lg:table-cell",children:e.publish})]},r)}),_.end===y.length?null:(0,a.jsx)("tr",{"aria-hidden":"true",style:{height:(y.length-_.end)*H}})]})]})})}),void 0===k?null:(0,a.jsx)(C,{live:Z(k),morph:u,now:p,onClose:()=>{(0,P.Z)(()=>W(void 0),{updated:()=>{S>=0&&I(S)}})},onStep:e=>{let t=y[S+e];void 0!==t&&(W((0,R.Z)(t)),U(S+e))},point:k,unreachable:h,position:S<0?void 0:{index:S+1,total:y.length}})]})};e.s(["default",0,()=>(0,a.jsx)(r.Suspense,{fallback:(0,a.jsx)("p",{className:"text-muted-foreground",children:"Loading…"}),children:(0,a.jsx)(B,{})})],72469)},64036,e=>{"use strict";var t=e.i(94115),a=e.i(52088);e.s(["N",0,({className:e,...s})=>(0,t.jsx)("div",{"data-slot":"card",className:(0,a.f)("flex flex-col gap-4 rounded-xl border bg-card py-5 text-card-foreground shadow-sm",e),...s}),"O",0,({className:e,...s})=>(0,t.jsx)("div",{"data-slot":"card-content",className:(0,a.f)("px-5",e),...s}),"u",0,({className:e,...s})=>(0,t.jsx)("div",{"data-slot":"card-description",className:(0,a.f)("text-sm text-muted-foreground",e),...s}),"Y",0,({className:e,...s})=>(0,t.jsx)("div",{"data-slot":"card-header",className:(0,a.f)("grid auto-rows-min items-start gap-1.5 px-5",e),...s}),"v",0,({className:e,...s})=>(0,t.jsx)("div",{"data-slot":"card-title",className:(0,a.f)("leading-none font-semibold",e),...s})])},44946,86224,e=>{"use strict";var t=e.i(94115),a=e.i(20367),s=e.i(81081),r=e.i(52088);let n={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};e.s(["f",0,({options:e,value:i,onChange:l,label:o,searchPlaceholder:d,emptyText:c,className:u})=>{let m=(0,a.useId)(),x=`${m}-list`,h=e=>`${m}-option-${e}`,f=(0,a.useRef)(null),g=(0,a.useRef)(null),p=(0,a.useRef)(null),v=(0,a.useRef)(null),[b,j]=(0,a.useState)(!1),[w,N]=(0,a.useState)(""),[y,k]=(0,a.useState)(0),$=e.find(e=>e.value===i),M=(0,a.useMemo)(()=>e.filter(e=>(0,s.w)(`${e.label} ${e.detail??""} ${e.keywords??""}`,w)),[e,w]),S=M.slice(0,100),E=()=>{N("");let t=void 0===$?-1:e.indexOf($);k(t>=0&&t<100?t:0),j(!0)},_=e=>{j(!1),e&&g.current?.focus()},C=e=>{void 0!==e&&(l(e.value),_(!0))};return(0,a.useLayoutEffect)(()=>{b&&p.current?.focus()},[b]),(0,a.useLayoutEffect)(()=>{b&&v.current?.querySelector(`[data-index="${y}"]`)?.scrollIntoView({block:"nearest"})},[b,y]),(0,a.useEffect)(()=>{if(!b)return;let e=e=>{e.target instanceof Node&&!f.current?.contains(e.target)&&_(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[b]),(0,t.jsxs)("div",{className:(0,r.f)("relative",u),ref:f,children:[(0,t.jsxs)("button",{"aria-expanded":b,"aria-haspopup":"listbox","aria-label":`${o}: ${$?.label??""}`,className:"flex h-9 w-full items-center gap-2 rounded-md border bg-background px-3 text-sm hover:bg-muted/50 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",onClick:()=>b?_(!1):E(),onKeyDown:e=>{"ArrowDown"!==e.key||b||(e.preventDefault(),E())},ref:g,type:"button",children:[$?.leading,(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate text-left",children:$?.label}),(0,t.jsx)("svg",{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground",...n,children:(0,t.jsx)("path",{d:"m7 15 5 5 5-5M7 9l5-5 5 5"})})]}),b?(0,t.jsxs)("div",{className:"absolute top-[calc(100%+4px)] right-0 z-50 flex w-[min(20rem,calc(100vw-2rem))] flex-col overflow-hidden rounded-lg border bg-card text-card-foreground shadow-lg motion-safe:animate-[popover-in_120ms_ease-out]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 border-b px-3",children:[(0,t.jsxs)("svg",{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground",...n,children:[(0,t.jsx)("circle",{cx:"11",cy:"11",r:"7"}),(0,t.jsx)("path",{d:"m20 20-3.5-3.5"})]}),(0,t.jsx)("input",{"aria-activedescendant":void 0===S[y]?void 0:h(y),"aria-autocomplete":"list","aria-controls":x,"aria-expanded":"true","aria-label":d,className:"h-10 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground",onChange:e=>{N(e.target.value),k(0)},onKeyDown:e=>{let t=S.length-1,a=a=>{e.preventDefault(),k(Math.min(Math.max(a,0),Math.max(t,0)))};switch(e.key){case"ArrowDown":return a(y+1);case"ArrowUp":return a(y-1);case"Home":return a(0);case"End":return a(t);case"PageDown":return a(y+8);case"PageUp":return a(y-8);case"Enter":return e.preventDefault(),C(S[y]);case"Escape":return e.preventDefault(),e.stopPropagation(),_(!0);case"Tab":return _(!1)}},placeholder:d,ref:p,role:"combobox",value:w})]}),(0,t.jsxs)("ul",{"aria-label":o,className:"max-h-[min(18rem,50dvh)] overflow-y-auto overscroll-contain p-1",id:x,ref:v,role:"listbox",children:[0===S.length?(0,t.jsx)("li",{className:"px-2 py-6 text-center text-sm text-muted-foreground",children:c}):S.map((e,a)=>(0,t.jsxs)("li",{"aria-selected":e.value===i,className:(0,r.f)("flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm select-none",a===y&&"bg-muted"),"data-index":a,id:h(a),onMouseDown:e=>e.preventDefault(),onClick:()=>C(e),onPointerMove:()=>k(a),role:"option",children:[e.leading,(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.label}),void 0===e.detail?null:(0,t.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:e.detail}),(0,t.jsx)("svg",{"aria-hidden":"true",className:(0,r.f)("size-4 shrink-0",e.value!==i&&"invisible"),...n,children:(0,t.jsx)("path",{d:"M20 6 9 17l-5-5"})})]},e.value)),M.length>S.length?(0,t.jsxs)("li",{className:"px-2 py-2 text-center text-xs text-muted-foreground",role:"presentation",children:[(M.length-S.length).toLocaleString()," more: type to narrow"]}):null]})]}):null]})}],44946),e.s(["f",0,(e,t)=>{let s=(0,a.useRef)(null),r=(0,a.useRef)(t),[n,i]=(0,a.useState)(()=>({start:0,end:Math.min(e,30)})),[l,o]=(0,a.useState)(t),d=(0,a.useCallback)(()=>{var t;let a,n=s.current;if(null===n)return;let l=n.querySelector("[data-row]")?.getBoundingClientRect().height;void 0!==l&&l>0&&Math.abs(l-r.current)>.5&&(r.current=l,o(l));let d={start:a=Math.min((t={top:-n.getBoundingClientRect().top,height:window.innerHeight,rowHeight:r.current,count:e,overscan:8}).count,Math.max(0,Math.floor(t.top/t.rowHeight)-t.overscan)),end:Math.max(a,Math.min(t.count,Math.max(0,Math.ceil((t.top+t.height)/t.rowHeight)+t.overscan)))};i(e=>e.start===d.start&&e.end===d.end?e:d)},[e]);(0,a.useLayoutEffect)(d,[d]),(0,a.useEffect)(()=>{let e=0,t=()=>{0===e&&(e=requestAnimationFrame(()=>{e=0,d()}))};return window.addEventListener("scroll",t,{passive:!0}),window.addEventListener("resize",t),()=>{cancelAnimationFrame(e),window.removeEventListener("scroll",t),window.removeEventListener("resize",t)}},[d]);let c=(0,a.useCallback)(e=>{let t=s.current;if(null===t)return;let a=t.getBoundingClientRect().top+e*r.current;(a<0||a+r.current>window.innerHeight)&&window.scrollBy({top:a-window.innerHeight/2+r.current/2}),d()},[d]);return{body:s,range:n,rowHeight:l,reveal:c}}],86224)},29164,e=>{"use strict";var t=e.i(94115),a=e.i(52088);e.s(["s",0,({className:e,containerClassName:s="overflow-x-auto",...r})=>(0,t.jsx)("div",{"data-slot":"table-container",className:(0,a.f)("relative w-full",s),children:(0,t.jsx)("table",{"data-slot":"table",className:(0,a.f)("w-full caption-bottom text-sm",e),...r})}),"z",0,({className:e,...s})=>(0,t.jsx)("tbody",{"data-slot":"table-body",className:(0,a.f)("[&_tr:last-child]:border-0",e),...s}),"d",0,({className:e,...s})=>(0,t.jsx)("td",{"data-slot":"table-cell",className:(0,a.f)("p-2 align-middle whitespace-nowrap",e),...s}),"U",0,({className:e,...s})=>(0,t.jsx)("th",{"data-slot":"table-head",className:(0,a.f)("h-9 px-2 text-left align-middle font-medium whitespace-nowrap text-muted-foreground",e),...s}),"E",0,({className:e,...s})=>(0,t.jsx)("thead",{"data-slot":"table-header",className:(0,a.f)("[&_tr]:border-b",e),...s}),"N",0,({className:e,...s})=>(0,t.jsx)("tr",{"data-slot":"table-row",className:(0,a.f)("border-b transition-colors hover:bg-muted/50",e),...s})])},16634,e=>{"use strict";var t=e.i(6655);let a=()=>"function"==typeof document.startViewTransition&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches;e.s(["J",0,a,"Z",0,(e,s={})=>{if(!a()){(0,t.flushSync)(e),s.updated?.(),s.after?.();return}s.before?.(),document.startViewTransition(()=>{(0,t.flushSync)(e),s.updated?.()}).finished.finally(()=>s.after?.())}])}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,39798,e=>{"use strict";var t=e.i(94115),s=e.i(84974),r=e.i(20367),a=e.i(80136),n=e.i(16634);let o="detail",i=({title:e,morph:s,onClose:a,children:n})=>{let i=(0,r.useRef)(null);return(0,r.useLayoutEffect)(()=>{let e=i.current;if(null!==e)return e.open||e.showModal(),e.focus(),()=>e.close()},[]),(0,t.jsx)("dialog",{"aria-label":e,className:`detail-dialog ${s?"morphing":""} m-auto max-h-[85dvh] w-[min(34rem,calc(100vw-2rem))] overflow-y-auto rounded-xl border bg-card p-0 text-card-foreground shadow-2xl outline-none`,onCancel:e=>{e.preventDefault(),a()},onClick:e=>{e.target===e.currentTarget&&a()},ref:i,style:{viewTransitionName:o},tabIndex:-1,children:(0,t.jsxs)("div",{className:"flex flex-col gap-5 p-6",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:e}),(0,t.jsx)("button",{"aria-label":"Close (Esc)",className:"rounded-md px-2 py-1 text-muted-foreground hover:bg-muted hover:text-foreground",onClick:a,title:"Close (Esc)",type:"button",children:"✕"})]}),n]})})},l=e=>({morph:(0,n.J)(),open:t=>(0,n.Z)(t,{before:()=>e?.style.setProperty("view-transition-name",o),updated:()=>e?.style.removeProperty("view-transition-name")}),close:t=>(0,n.Z)(t,{updated:()=>{e?.style.setProperty("view-transition-name",o),(e?.querySelector("button")??e)?.focus({preventScroll:!0})},after:()=>e?.style.removeProperty("view-transition-name")})}),d=({rows:e})=>(0,t.jsx)("dl",{className:"grid grid-cols-[auto_minmax(0,1fr)] gap-x-6 gap-y-2 text-sm",children:e.map(e=>!1===e?null:(0,t.jsxs)("div",{className:"contents",children:[(0,t.jsx)("dt",{className:"text-muted-foreground",children:e[0]}),(0,t.jsx)("dd",{className:"min-w-0 text-right tabular-nums break-words",children:e[1]})]},e[0]))});var c=e.i(71513),u=e.i(89486);let h={overflow:"the buffer was full, so the oldest were dropped",rejected:"the broker refused them",unreadable:"they could no longer be read from disk",undeliverable:"they broke the connection three times in a row",lost:"the buffer file was replaced or damaged"},m=e=>{let t=e/6e4;if(t<1)return"under a minute";if(t<60)return`about ${Math.round(t)} min`;let s=t/60;return s<48?`about ${Math.round(s)} h`:`about ${Math.round(s/24)} days`};var x=e.i(7347),f=e.i(64036);let p=e=>{switch(e._tag){case"live":return(0,t.jsx)(x.f,{variant:"success",children:"ok"});case"starting":return(0,t.jsx)(x.f,{variant:"secondary",children:"starting"});case"late":return(0,t.jsx)(x.f,{variant:"warning",children:"late"});case"failing":return(0,t.jsx)(x.f,{variant:"destructive",children:(0,u.F)(e.reason)})}},g=(e,t,s)=>{let r=`read ${(0,u.M)(e.pollIntervalMs)}`;switch(t._tag){case"live":case"starting":return r;case"late":case"failing":return void 0===t.lastSuccess?`${r} \xb7 no answer yet`:`${r} \xb7 no answer for ${(0,u.K)(t.lastSuccess,s)}`}},v=({status:e})=>{let[a,n]=(0,r.useState)(!1),o=(0,u.f)(e.devices,e.now),i=o.filter(t=>"live"!==(0,u.g)(t,e.now)._tag).length,l=a?o:o.slice(0,Math.max(10,i));return(0,t.jsxs)(f.N,{className:"gap-0 py-0",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 border-b px-5 py-4",children:[(0,t.jsx)("h2",{className:"leading-none font-semibold",children:"Devices"}),(0,t.jsx)(s.default,{className:"text-sm text-muted-foreground underline-offset-4 hover:text-foreground hover:underline",href:"/points/",children:"All points →"})]}),(0,t.jsx)("ul",{className:"divide-y",children:l.map(r=>{let a=(0,u.g)(r,e.now);return(0,t.jsx)("li",{children:(0,t.jsxs)(s.default,{className:"grid grid-cols-[1fr_auto] items-center gap-x-4 gap-y-1 px-5 py-3 hover:bg-muted/50 focus-visible:bg-muted/50 focus-visible:outline-none sm:grid-cols-[minmax(0,1fr)_auto_auto_auto]",href:`/points/?device=${encodeURIComponent(r.id)}`,children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"truncate font-mono text-sm font-medium",children:r.id}),(0,t.jsxs)("p",{className:"truncate text-xs text-muted-foreground",children:[u.T[r.protocol]," · ",g(r,a,e.now)]})]}),(0,t.jsxs)("span",{className:"hidden text-sm text-muted-foreground tabular-nums sm:block",children:[r.pointCount.toLocaleString()," ",1===r.pointCount?"point":"points"]}),(0,t.jsx)("span",{className:"justify-self-end",children:p(a)}),(0,t.jsx)("span",{"aria-hidden":"true",className:"hidden text-muted-foreground sm:block",children:"→"})]})},r.id)})}),l.length<o.length?(0,t.jsx)("div",{className:"border-t p-3 text-center",children:(0,t.jsxs)("button",{className:"text-sm text-muted-foreground underline-offset-4 hover:text-foreground hover:underline",onClick:()=>n(!0),type:"button",children:["Show all ",o.length.toLocaleString()," devices"]})}):null]})},b={broker:"Broker",devices:"Devices",buffer:"Buffer"},j=({label:e,title:s,note:r,extra:a,bad:n,onOpen:o,cardRef:i})=>(0,t.jsx)(f.N,{className:"group relative transition-colors has-[button:hover]:bg-muted/40",ref:i,children:(0,t.jsxs)(f.Y,{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)(f.u,{children:(0,t.jsx)("button",{"aria-haspopup":"dialog",className:"outline-none after:absolute after:inset-0 after:rounded-xl focus-visible:after:ring-2 focus-visible:after:ring-ring",onClick:o,type:"button",children:e})}),(0,t.jsx)("span",{"aria-hidden":"true",className:"text-sm text-muted-foreground opacity-0 transition-opacity group-has-[button:hover]:opacity-100 group-has-[button:focus-visible]:opacity-100",children:"Details →"})]}),(0,t.jsx)(f.v,{className:`text-2xl tabular-nums ${n?"text-destructive":""}`,children:s}),(0,t.jsx)(f.u,{className:"truncate",title:r,children:r}),a]})}),w=({status:e})=>{let{broker:r,buffer:a}=e,n=r.connection;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("p",{className:`text-xl font-semibold ${r.connected?"":"text-destructive"}`,children:r.connected?void 0===r.connectedAt?"Connected":`Connected since ${(0,u.w)(r.connectedAt,e.now)}`:void 0===r.connectedAt?"Not connected yet":`Disconnected, last connected at ${(0,u.w)(r.connectedAt,e.now)}`}),r.connected?null:(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:void 0===a?"Values are lost until it is back: there is no buffer to keep them.":"Values wait in the buffer and go out once it is back."})]}),(0,t.jsx)(d,{rows:[["Broker",(0,t.jsx)("span",{className:"font-mono",children:r.url})],["Values published",r.published.toLocaleString()],["Could not publish",(0,t.jsx)("span",{className:r.publishFailures>0?"text-destructive":"",children:r.publishFailures.toLocaleString()})],["Reconnects",Math.max(0,r.connects-1).toLocaleString()],["Failed connection attempts",r.failedConnects.toLocaleString()],void 0!==n&&["MQTT version",n.protocolVersion],void 0!==n&&["Keep-alive",`${n.keepAliveSeconds} s`],void 0!==n&&["Retained messages",n.retainAvailable?"supported":"not supported"],void 0!==n&&["Largest message",void 0===n.maximumPacketSize?"no limit":(0,u.L)(n.maximumPacketSize)]]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Counts since the gateway started."}),(0,t.jsx)(s.default,{className:"text-sm underline-offset-4 hover:underline",href:"/messages/",children:"What it publishes →"})]})},N=({status:e})=>{let r=((e,t)=>{let s={live:0,starting:0,late:0,failing:0};for(let r of e)s[(0,u.g)(r,t)._tag]++;return s})(e.devices,e.now),a=(0,u.f)(e.devices,e.now).filter(t=>{let s=(0,u.g)(t,e.now)._tag;return"failing"===s||"late"===s}),n=[["Answering",r.live,""],["Starting",r.starting,""],["Late",r.late,r.late>0?"text-amber-600 dark:text-amber-400":""],["Failing",r.failing,r.failing>0?"text-destructive":""]];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"grid grid-cols-4 gap-3",children:n.map(([e,s,r])=>(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)("span",{className:`text-2xl font-semibold tabular-nums ${r}`,children:s.toLocaleString()}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:e})]},e))}),(0,t.jsx)(d,{rows:(e=>{let t=new Map;for(let s of e){let e=t.get(s.protocol)??{devices:0,points:0};e.devices++,e.points+=s.pointCount,t.set(s.protocol,e)}return[...t].toSorted(([,e],[,t])=>t.devices-e.devices).map(([e,t])=>({protocol:e,name:u.T[e]??e,...t}))})(e.devices).map(({name:e,devices:t,points:s})=>[e,`${t.toLocaleString()} ${1===t?"device":"devices"} \xb7 ${s.toLocaleString()} ${1===s?"point":"points"}`])}),0===a.length?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Every device answers."}):(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:"Need a look"}),(0,t.jsx)("ul",{className:"divide-y rounded-lg border",children:a.map(r=>{let a=(0,u.g)(r,e.now);return(0,t.jsx)("li",{children:(0,t.jsxs)(s.default,{className:"flex items-center justify-between gap-3 px-3 py-2 text-sm hover:bg-muted/50",href:`/points/?device=${encodeURIComponent(r.id)}`,children:[(0,t.jsxs)("span",{className:"min-w-0",children:[(0,t.jsx)("span",{className:"block truncate font-mono",children:r.id}),(0,t.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:g(r,a,e.now)})]}),p(a)]})},r.id)})})]}),(0,t.jsx)(s.default,{className:"text-sm underline-offset-4 hover:underline",href:"/points/",children:"All points →"})]})},y=({status:e,view:r})=>{let{buffer:a}=e;if(void 0===a)return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"text-sm",children:"There is no buffer, so values read while the broker is away are lost. A buffer keeps them on the gateway's disk and sends them once the broker is back."}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["To add one, put a ",(0,t.jsx)("code",{className:"font-mono",children:"buffer"})," block in the config and restart the gateway."]}),(0,t.jsx)(s.default,{className:"text-sm underline-offset-4 hover:underline",href:"/settings/",children:"Settings →"})]});let n=Object.entries(a.droppedBy).filter(([,e])=>e>0).toSorted(([,e],[,t])=>t-e).map(([e,t])=>({reason:e,count:t,words:h[e]??e}));return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("p",{className:`text-xl font-semibold tabular-nums ${r.bad?"text-destructive":""}`,children:r.title}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:[r.note.charAt(0).toUpperCase()+r.note.slice(1),0===a.rows||a.rows>=a.maxRows?".":` (${(0,u.r)(a.rows,a.maxRows)} full).`]}),a.disabled?(0,t.jsx)("p",{className:"text-sm text-destructive",children:"The buffer could not be used, so values go straight to the broker and are lost while it is away. The gateway log says why."}):null]}),(0,t.jsx)(d,{rows:[["Holds up to",`${a.maxRows.toLocaleString()} messages`],["Stored",a.written.toLocaleString()],["Sent on later",a.delivered.toLocaleString()],["Dropped",(0,t.jsx)("span",{className:a.dropped>0?"text-destructive":"",children:a.dropped.toLocaleString()})],["Disk errors",a.failures.toLocaleString()],e.host?.diskFreeBytes!==void 0&&["Disk free",(0,u.L)(e.host.diskFreeBytes)],["File",(0,t.jsx)("span",{className:"font-mono",children:a.path})]]}),0===n.length?null:(0,t.jsx)("ul",{className:"flex flex-col gap-1 text-sm text-destructive",children:n.map(({reason:e,count:s,words:r})=>(0,t.jsxs)("li",{children:[s.toLocaleString()," dropped because ",r]},e))}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Counts since the gateway started."})]})},k=({status:e,stale:s})=>{let[a,n]=(0,r.useState)(void 0),[o,d]=(0,r.useState)(!1),c=(0,r.useRef)({}),u=e.devices.filter(e=>"failing"===e.status).length,h=e.devices.filter(e=>"ok"===e.status).length,x=((e,t,s)=>{if(void 0===e)return{title:"Off",note:t?"values are lost while the broker is down":"values are lost until the broker is back",bad:!t,dropped:0};let{rows:r,maxRows:a,dropped:n}=e;if(e.disabled)return{title:"Failed",note:"values are lost while the broker is down",bad:!0,dropped:n};if(r>=a)return{title:"Full",note:"the oldest values are being dropped",bad:!0,dropped:n};if(0===r)return{title:"Nothing waiting",note:t?"values go straight to the broker":"values wait here until the broker is back",bad:!1,dropped:n};let o=`${r.toLocaleString()} waiting`;return t?{title:o,note:void 0!==s&&s<0?`sending, ${m(-(r/s*1e3))} left`:"sending to the broker",bad:!1,dropped:n}:{title:o,note:void 0!==s&&s>0?`full in ${m((a-r)/s*1e3)} at this rate`:"for the broker to be back",bad:!1,dropped:n}})(e.buffer,e.broker.connected,(e=>{let t=(0,r.useRef)([]),[s,a]=(0,r.useState)(void 0),n=e.buffer?.rows;return(0,r.useEffect)(()=>{if(void 0!==n){var s,r;let o;s=t.current,r={at:e.now,since:e.since,rows:n},t.current=void 0!==(o=s.at(-1))&&(o.since!==r.since||r.at<o.at)?[r]:void 0!==o&&o.at===r.at?s:[...s.filter(e=>r.at-e.at<=6e4),r],a((e=>{let t=e[0],s=e.at(-1);if(void 0===t||void 0===s||e.length<3)return;let r=s.at-t.at;return r<1e4?void 0:(s.rows-t.rows)/r*1e3})(t.current))}},[n,e.now,e.since]),s})(e)),p=e=>s?"page is not reaching the gateway":e,g=e=>({onOpen:()=>{let t;d((t=l(c.current[e]??null)).morph),t.open(()=>n(e))},cardRef:t=>{c.current[e]=t}});return(0,t.jsxs)("div",{className:"grid gap-4 sm:grid-cols-3",children:[(0,t.jsx)(j,{...g("broker"),bad:!e.broker.connected,extra:e.broker.connected?null:(0,t.jsx)(f.u,{className:void 0===e.buffer?"text-destructive":"",children:void 0===e.buffer?"values are lost until it is back":"values wait in the buffer"}),label:"Broker",note:p(`${e.broker.connected?"to ":""}${e.broker.url}`),title:e.broker.connected?"connected":"disconnected"}),(0,t.jsx)(j,{...g("devices"),bad:u>0,label:"Devices",note:p(u>0?`devices answering, ${u} failing`:h===e.devices.length?"devices answering":`devices answering, ${e.devices.length-h} starting`),title:`${h}/${e.devices.length}`}),(0,t.jsx)(j,{...g("buffer"),bad:x.bad&&!s,extra:0===x.dropped?null:(0,t.jsxs)(f.u,{className:"text-destructive",children:[x.dropped.toLocaleString()," dropped since start"]}),label:"Buffer",note:p(x.note),title:x.title}),void 0===a?null:(0,t.jsx)(i,{morph:o,onClose:()=>{void 0!==a&&l(c.current[a]??null).close(()=>n(void 0))},title:b[a],children:"broker"===a?(0,t.jsx)(w,{status:e}):"devices"===a?(0,t.jsx)(N,{status:e}):(0,t.jsx)(y,{status:e,view:x})})]})},S=({host:e,upMs:s})=>{let r=((e,t)=>{let s=[],r=e.throttled?.now??[];if(r.includes("under_voltage")?s.push("The power supply is too weak: the Raspberry Pi gets too little voltage. Use a stronger supply."):r.length>0&&s.push("The Raspberry Pi slows itself down to protect itself from heat or weak power."),void 0!==e.temperatureC&&e.temperatureC>=80&&s.push(`The machine is too hot (${Math.round(e.temperatureC)} \xb0C): give it air or a heat sink.`),void 0!==e.diskFreeBytes&&e.diskFreeBytes<0x4000000&&s.push(`The disk is almost full (${(0,u.L)(e.diskFreeBytes)} left): values cannot be kept while the broker is away.`),t<6e4)return s;if(e.eventLoopLagMs.max>=1e3){let t;s.push(`The gateway stalled for up to ${(t=e.eventLoopLagMs.max,`${Number((t/1e3).toFixed(1))} s`)} in the last minute: reads and messages waited.`)}else e.cpuPercent>=90&&s.push(`The gateway is busy (${Math.round(e.cpuPercent)} % of a processor core): little room is left.`);return s})(e,s);return 0===r.length?null:(0,t.jsx)("div",{className:"flex flex-col gap-1 rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-700 dark:text-amber-300",role:"status",children:r.map(e=>(0,t.jsx)("p",{children:e},e))})};e.s(["default",0,()=>{let e=(0,a.useGateway)(),s=(0,c.Z)(e);return(0,t.jsx)(t.Fragment,{children:void 0===s?(0,t.jsx)("p",{className:"text-muted-foreground",children:"loading"===e._tag?"Loading…":"The gateway does not answer."}):(0,t.jsxs)(t.Fragment,{children:[void 0===s.host?null:(0,t.jsx)(S,{host:s.host,upMs:s.now-s.since}),(0,t.jsx)(k,{status:s,stale:"ok"!==e._tag}),(0,t.jsx)(v,{status:s})]})})}],39798)},64036,e=>{"use strict";var t=e.i(94115),s=e.i(52088);e.s(["N",0,({className:e,...r})=>(0,t.jsx)("div",{"data-slot":"card",className:(0,s.f)("flex flex-col gap-4 rounded-xl border bg-card py-5 text-card-foreground shadow-sm",e),...r}),"O",0,({className:e,...r})=>(0,t.jsx)("div",{"data-slot":"card-content",className:(0,s.f)("px-5",e),...r}),"u",0,({className:e,...r})=>(0,t.jsx)("div",{"data-slot":"card-description",className:(0,s.f)("text-sm text-muted-foreground",e),...r}),"Y",0,({className:e,...r})=>(0,t.jsx)("div",{"data-slot":"card-header",className:(0,s.f)("grid auto-rows-min items-start gap-1.5 px-5",e),...r}),"v",0,({className:e,...r})=>(0,t.jsx)("div",{"data-slot":"card-title",className:(0,s.f)("leading-none font-semibold",e),...r})])},16634,e=>{"use strict";var t=e.i(6655);let s=()=>"function"==typeof document.startViewTransition&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches;e.s(["J",0,s,"Z",0,(e,r={})=>{if(!s()){(0,t.flushSync)(e),r.updated?.(),r.after?.();return}r.before?.(),document.startViewTransition(()=>{(0,t.flushSync)(e),r.updated?.()}).finished.finally(()=>r.after?.())}])}]);
|