rigscope 0.1.4 → 0.1.5

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.
Files changed (94) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +3 -3
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/prerender-manifest.json +6 -6
  5. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  6. package/.next/server/app/_global-error.html +1 -1
  7. package/.next/server/app/_global-error.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  12. package/.next/server/app/_not-found.html +1 -1
  13. package/.next/server/app/_not-found.rsc +2 -2
  14. package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  15. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  16. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  17. package/.next/server/app/administration/page_client-reference-manifest.js +1 -1
  18. package/.next/server/app/administration.html +1 -1
  19. package/.next/server/app/administration.rsc +3 -3
  20. package/.next/server/app/administration.segments/_full.segment.rsc +3 -3
  21. package/.next/server/app/administration.segments/_tree.segment.rsc +2 -2
  22. package/.next/server/app/administration.segments/administration/__PAGE__.segment.rsc +3 -3
  23. package/.next/server/app/alerts/page.js +1 -1
  24. package/.next/server/app/alerts/page_client-reference-manifest.js +1 -1
  25. package/.next/server/app/alerts.html +1 -1
  26. package/.next/server/app/alerts.rsc +4 -4
  27. package/.next/server/app/alerts.segments/_full.segment.rsc +4 -4
  28. package/.next/server/app/alerts.segments/_tree.segment.rsc +2 -2
  29. package/.next/server/app/alerts.segments/alerts/__PAGE__.segment.rsc +4 -4
  30. package/.next/server/app/connections/page.js +1 -1
  31. package/.next/server/app/connections/page.js.nft.json +1 -1
  32. package/.next/server/app/connections/page_client-reference-manifest.js +1 -1
  33. package/.next/server/app/connections.html +1 -1
  34. package/.next/server/app/connections.rsc +6 -6
  35. package/.next/server/app/connections.segments/_full.segment.rsc +6 -6
  36. package/.next/server/app/connections.segments/_tree.segment.rsc +2 -2
  37. package/.next/server/app/connections.segments/connections/__PAGE__.segment.rsc +6 -6
  38. package/.next/server/app/history/page_client-reference-manifest.js +1 -1
  39. package/.next/server/app/history.html +1 -1
  40. package/.next/server/app/history.rsc +3 -3
  41. package/.next/server/app/history.segments/_full.segment.rsc +3 -3
  42. package/.next/server/app/history.segments/_tree.segment.rsc +2 -2
  43. package/.next/server/app/history.segments/history/__PAGE__.segment.rsc +3 -3
  44. package/.next/server/app/index.html +1 -1
  45. package/.next/server/app/index.rsc +6 -6
  46. package/.next/server/app/index.segments/__PAGE__.segment.rsc +6 -6
  47. package/.next/server/app/index.segments/_full.segment.rsc +6 -6
  48. package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  49. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  50. package/.next/server/app/login.html +1 -1
  51. package/.next/server/app/login.rsc +2 -2
  52. package/.next/server/app/login.segments/_full.segment.rsc +2 -2
  53. package/.next/server/app/login.segments/_tree.segment.rsc +2 -2
  54. package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  55. package/.next/server/app/machines/[machineId]/page.js +1 -1
  56. package/.next/server/app/machines/[machineId]/page.js.nft.json +1 -1
  57. package/.next/server/app/machines/[machineId]/page_client-reference-manifest.js +1 -1
  58. package/.next/server/app/page.js +1 -1
  59. package/.next/server/app/page.js.nft.json +1 -1
  60. package/.next/server/app/page_client-reference-manifest.js +1 -1
  61. package/.next/server/app/processes/page.js +1 -1
  62. package/.next/server/app/processes/page_client-reference-manifest.js +1 -1
  63. package/.next/server/app/processes.html +1 -1
  64. package/.next/server/app/processes.rsc +4 -4
  65. package/.next/server/app/processes.segments/_full.segment.rsc +4 -4
  66. package/.next/server/app/processes.segments/_tree.segment.rsc +2 -2
  67. package/.next/server/app/processes.segments/processes/__PAGE__.segment.rsc +4 -4
  68. package/.next/server/app-paths-manifest.json +3 -3
  69. package/.next/server/chunks/364.js +1 -0
  70. package/.next/server/chunks/751.js +1 -1
  71. package/.next/server/middleware-build-manifest.js +1 -1
  72. package/.next/server/pages/404.html +1 -1
  73. package/.next/server/pages/500.html +1 -1
  74. package/.next/static/chunks/103-13ec30dcc059b9d3.js +1 -0
  75. package/.next/static/chunks/{227-417939c480f50747.js → 130-e940915010276f88.js} +1 -1
  76. package/.next/static/chunks/app/alerts/{page-fe0e877778c60af8.js → page-2548b2ab0c057953.js} +1 -1
  77. package/.next/static/chunks/app/connections/{page-99cd54d6929b3f1f.js → page-07113bf16cb352e7.js} +1 -1
  78. package/.next/static/chunks/app/machines/[machineId]/{page-1a25a267563c18c0.js → page-0b89e4393a137c4d.js} +1 -1
  79. package/.next/static/chunks/app/{page-1ae9fc94c897785b.js → page-c68554c93016dd13.js} +1 -1
  80. package/.next/static/chunks/app/processes/{page-0e98a4a64e829c5f.js → page-b6d97d119f10e2a1.js} +3 -3
  81. package/.next/static/css/fb3ad9534f4681e6.css +1 -0
  82. package/CHANGELOG.md +14 -0
  83. package/DESIGN.md +27 -16
  84. package/dist/cli.cjs +1 -0
  85. package/dist/collector.cjs +1 -1
  86. package/dist/hub.cjs +1 -1
  87. package/docs/installation.md +6 -3
  88. package/docs/releasing.md +12 -12
  89. package/package.json +1 -1
  90. package/.next/server/chunks/877.js +0 -1
  91. package/.next/static/chunks/103-c47318242b24e9ac.js +0 -1
  92. package/.next/static/css/3fbf75e4c471c6a8.css +0 -1
  93. /package/.next/static/{-mNveXe-cHv8irQe97wI_ → oxwySrJXqXq8O6_7AzZGe}/_buildManifest.js +0 -0
  94. /package/.next/static/{-mNveXe-cHv8irQe97wI_ → oxwySrJXqXq8O6_7AzZGe}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- <!DOCTYPE html><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-9ca43f4ce1bb8938.js"/><script src="/_next/static/chunks/4bd1b696-c7408084347438ae.js" async=""></script><script src="/_next/static/chunks/794-ceeb732a1a81bc27.js" async=""></script><script src="/_next/static/chunks/main-app-f92328c8950d2e53.js" async=""></script><title>500: This page couldn’t load</title><style>:root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }</style><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;display:flex;align-items:center;justify-content:center"><div style="margin-top:-32px;max-width:325px;padding:32px 28px;text-align:left"><svg width="32" height="32" viewBox="-0.2 -1.5 32 32" fill="none" style="margin-bottom:24px"><path d="M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z" fill="var(--next-error-title)"></path></svg><h1 style="font-size:24px;font-weight:500;letter-spacing:-0.02em;line-height:32px;margin:0 0 12px 0;color:var(--next-error-title)">This page couldn’t load</h1><p style="font-size:14px;font-weight:400;line-height:21px;margin:0 0 20px 0;color:var(--next-error-message)">A server error occurred. Reload to try again.</p><form style="margin:0"><button type="submit" style="display:inline-flex;align-items:center;justify-content:center;height:32px;padding:0 12px;font-size:14px;font-weight:500;line-height:20px;border-radius:6px;cursor:pointer;color:var(--next-error-btn-text);background:var(--next-error-btn-bg);border:var(--next-error-btn-border)">Reload</button></form></div></div><!--$--><!--/$--><script src="/_next/static/chunks/webpack-9ca43f4ce1bb8938.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[7121,[],\"\"]\n3:I[4581,[],\"\"]\n7:I[484,[],\"OutletBoundary\"]\n8:\"$Sreact.suspense\"\na:\"ViewportBoundary\"\nb:I[484,[],\"$a\"]\nd:\"MetadataBoundary\"\ne:I[484,[],\"$d\"]\n10:I[7123,[],\"default\",1]\n4:X\n"])</script><script>self.__next_f.push([1,"6:[[\"children\",{\"s\":\"__PAGE__\",\"h\":528,\"d\":{\"r\":[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[[\"$\",\"title\",null,{\"children\":\"500: This page couldn’t load\"}],[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\":root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }\"}}]]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"display\":\"flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"marginTop\":\"-32px\",\"maxWidth\":\"325px\",\"padding\":\"32px 28px\",\"textAlign\":\"left\"},\"children\":[[\"$\",\"svg\",null,{\"width\":\"32\",\"height\":\"32\",\"viewBox\":\"-0.2 -1.5 32 32\",\"fill\":\"none\",\"style\":{\"marginBottom\":\"24px\"},\"children\":[\"$\",\"path\",null,{\"d\":\"M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z\",\"fill\":\"var(--next-error-title)\"}]}],[\"$\",\"h1\",null,{\"style\":{\"fontSize\":\"24px\",\"fontWeight\":500,\"letterSpacing\":\"-0.02em\",\"lineHeight\":\"32px\",\"margin\":\"0 0 12px 0\",\"color\":\"var(--next-error-title)\"},\"children\":\"This page couldn’t load\"}],[\"$\",\"p\",null,{\"style\":{\"fontSize\":\"14px\",\"fontWeight\":400,\"lineHeight\":\"21px\",\"margin\":\"0 0 20px 0\",\"color\":\"var(--next-error-message)\"},\"children\":\"A server error occurred. Reload to try again.\"}],[\"$\",\"form\",null,{\"style\":{\"margin\":0},\"children\":[\"$\",\"button\",null,{\"type\":\"submit\",\"style\":{\"display\":\"inline-flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\",\"height\":\"32px\",\"padding\":\"0 12px\",\"fontSize\":\"14px\",\"fontWeight\":500,\"lineHeight\":\"20px\",\"borderRadius\":\"6px\",\"cursor\":\"pointer\",\"color\":\"var(--next-error-btn-text)\",\"background\":\"var(--next-error-btn-bg)\",\"border\":\"var(--next-error-btn-border)\"},\"children\":\"Reload\"}]}]]}]}]}]]}],null,[\"$\",\"$L7\",null,{\"children\":[\"$\",\"$8\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@9\"}]}]]}],\"p\":false,\"v\":null}}]]\n"])</script><script>self.__next_f.push([1,"5:[[\"children\",{\"s\":\"_global-error\",\"h\":528,\"d\":{\"r\":[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],\"p\":false,\"v\":\"$4\"},\"c\":\"$Q6\"}]]\n0:{\"P\":null,\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"t\":{\"t\":{\"s\":\"\",\"h\":528,\"d\":{\"r\":[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],\"p\":false,\"v\":\"$4\"},\"c\":\"$Q5\"},\"h\":{\"r\":[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$Lb\",null,{\"children\":\"$Lc\"}],[\"$\",\"$Le\",null,{\"children\":[[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$8\",null,{\"name\":\"Next.Metadata\",\"children\":\"$Lf\"}]}],null]}],null]}],\"p\":false,\"v\":null}},\"m\":\"$undefined\",\"G\":[\"$10\",[]],\"S\":true,\"r\":\"$undefined\",\"s\":\"$undefined\",\"a\":\"$undefined\",\"l\":\"$undefined\",\"p\":\"$undefined\",\"d\":\"$undefined\",\"b\":\"-mNveXe-cHv8irQe97wI_\"}\n"])</script><script>self.__next_f.push([1,"4:C\nc:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"9:null\nf:[]\n"])</script></body></html>
1
+ <!DOCTYPE html><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-9ca43f4ce1bb8938.js"/><script src="/_next/static/chunks/4bd1b696-c7408084347438ae.js" async=""></script><script src="/_next/static/chunks/794-ceeb732a1a81bc27.js" async=""></script><script src="/_next/static/chunks/main-app-f92328c8950d2e53.js" async=""></script><title>500: This page couldn’t load</title><style>:root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }</style><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;display:flex;align-items:center;justify-content:center"><div style="margin-top:-32px;max-width:325px;padding:32px 28px;text-align:left"><svg width="32" height="32" viewBox="-0.2 -1.5 32 32" fill="none" style="margin-bottom:24px"><path d="M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z" fill="var(--next-error-title)"></path></svg><h1 style="font-size:24px;font-weight:500;letter-spacing:-0.02em;line-height:32px;margin:0 0 12px 0;color:var(--next-error-title)">This page couldn’t load</h1><p style="font-size:14px;font-weight:400;line-height:21px;margin:0 0 20px 0;color:var(--next-error-message)">A server error occurred. Reload to try again.</p><form style="margin:0"><button type="submit" style="display:inline-flex;align-items:center;justify-content:center;height:32px;padding:0 12px;font-size:14px;font-weight:500;line-height:20px;border-radius:6px;cursor:pointer;color:var(--next-error-btn-text);background:var(--next-error-btn-bg);border:var(--next-error-btn-border)">Reload</button></form></div></div><!--$--><!--/$--><script src="/_next/static/chunks/webpack-9ca43f4ce1bb8938.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[7121,[],\"\"]\n3:I[4581,[],\"\"]\n7:I[484,[],\"OutletBoundary\"]\n8:\"$Sreact.suspense\"\na:\"ViewportBoundary\"\nb:I[484,[],\"$a\"]\nd:\"MetadataBoundary\"\ne:I[484,[],\"$d\"]\n10:I[7123,[],\"default\",1]\n4:X\n"])</script><script>self.__next_f.push([1,"6:[[\"children\",{\"s\":\"__PAGE__\",\"h\":528,\"d\":{\"r\":[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[[\"$\",\"title\",null,{\"children\":\"500: This page couldn’t load\"}],[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\":root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }\"}}]]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"display\":\"flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"marginTop\":\"-32px\",\"maxWidth\":\"325px\",\"padding\":\"32px 28px\",\"textAlign\":\"left\"},\"children\":[[\"$\",\"svg\",null,{\"width\":\"32\",\"height\":\"32\",\"viewBox\":\"-0.2 -1.5 32 32\",\"fill\":\"none\",\"style\":{\"marginBottom\":\"24px\"},\"children\":[\"$\",\"path\",null,{\"d\":\"M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z\",\"fill\":\"var(--next-error-title)\"}]}],[\"$\",\"h1\",null,{\"style\":{\"fontSize\":\"24px\",\"fontWeight\":500,\"letterSpacing\":\"-0.02em\",\"lineHeight\":\"32px\",\"margin\":\"0 0 12px 0\",\"color\":\"var(--next-error-title)\"},\"children\":\"This page couldn’t load\"}],[\"$\",\"p\",null,{\"style\":{\"fontSize\":\"14px\",\"fontWeight\":400,\"lineHeight\":\"21px\",\"margin\":\"0 0 20px 0\",\"color\":\"var(--next-error-message)\"},\"children\":\"A server error occurred. Reload to try again.\"}],[\"$\",\"form\",null,{\"style\":{\"margin\":0},\"children\":[\"$\",\"button\",null,{\"type\":\"submit\",\"style\":{\"display\":\"inline-flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\",\"height\":\"32px\",\"padding\":\"0 12px\",\"fontSize\":\"14px\",\"fontWeight\":500,\"lineHeight\":\"20px\",\"borderRadius\":\"6px\",\"cursor\":\"pointer\",\"color\":\"var(--next-error-btn-text)\",\"background\":\"var(--next-error-btn-bg)\",\"border\":\"var(--next-error-btn-border)\"},\"children\":\"Reload\"}]}]]}]}]}]]}],null,[\"$\",\"$L7\",null,{\"children\":[\"$\",\"$8\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@9\"}]}]]}],\"p\":false,\"v\":null}}]]\n"])</script><script>self.__next_f.push([1,"5:[[\"children\",{\"s\":\"_global-error\",\"h\":528,\"d\":{\"r\":[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],\"p\":false,\"v\":\"$4\"},\"c\":\"$Q6\"}]]\n0:{\"P\":null,\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"t\":{\"t\":{\"s\":\"\",\"h\":528,\"d\":{\"r\":[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],\"p\":false,\"v\":\"$4\"},\"c\":\"$Q5\"},\"h\":{\"r\":[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$Lb\",null,{\"children\":\"$Lc\"}],[\"$\",\"$Le\",null,{\"children\":[[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$8\",null,{\"name\":\"Next.Metadata\",\"children\":\"$Lf\"}]}],null]}],null]}],\"p\":false,\"v\":null}},\"m\":\"$undefined\",\"G\":[\"$10\",[]],\"S\":true,\"r\":\"$undefined\",\"s\":\"$undefined\",\"a\":\"$undefined\",\"l\":\"$undefined\",\"p\":\"$undefined\",\"d\":\"$undefined\",\"b\":\"oxwySrJXqXq8O6_7AzZGe\"}\n"])</script><script>self.__next_f.push([1,"4:C\nc:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"9:null\nf:[]\n"])</script></body></html>
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[103],{802:(e,n,t)=>{t.d(n,{B:()=>l});var r=t(5155),a=t(8500),i=t.n(a),s=t(9939);function l(){let{session:e,phase:n,signOut:t}=(0,s.M)();return"signed-in"===e.kind?(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"hidden max-w-[12rem] truncate text-xs text-muted-foreground sm:inline",children:e.user.username}),(0,r.jsx)("button",{type:"button",onClick:()=>void t(),className:"rounded-md px-2.5 py-1.5 text-xs text-muted-foreground transition-colors hover:bg-card-strong hover:text-foreground",children:"Sign out"})]}):"restoring"===e.kind||"auth-unavailable"===e.kind?null:(0,r.jsx)("div",{className:"flex items-center gap-1",children:(0,r.jsx)(i(),{href:"/login",className:"rounded-md border border-border px-2.5 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:"Sign in"})})}},940:(e,n,t)=>{t.d(n,{$E:()=>d,TK:()=>o});var r=t(5155),a=t(9939);let i={ok:"bg-ok",warn:"bg-warn",crit:"bg-crit",muted:"bg-muted-foreground/50"};function s(e,n){switch(e.kind){case"restoring":return{label:"Checking session…",tone:"muted"};case"restore-failed":return{label:"Hub unreachable",tone:"crit"};case"signed-out":return{label:"Signed out",tone:"muted"};case"auth-unavailable":return{label:"Sign-in unavailable",tone:"warn"}}switch(n){case"idle":return{label:"Not connected",tone:"muted"};case"connecting":return{label:"Connecting…",tone:"warn"};case"live":return{label:"Live",tone:"ok"};case"reconnecting":return{label:"Reconnecting…",tone:"warn"};case"disconnected":return{label:"Disconnected",tone:"crit"};case"expired":return{label:"Session ended",tone:"crit"};case"no-permission":return{label:"No permission",tone:"warn"}}}function l({tone:e}){return(0,r.jsx)("span",{className:`inline-block h-2 w-2 shrink-0 rounded-full ${i[e]}`,"aria-hidden":!0})}function d(){let{session:e,phase:n,lastEventKind:t,notice:i,dismissNotice:d}=(0,a.M)(),o=s(e,n),c="reset"===t&&"live"===n?"Stream resynchronized with a fresh snapshot.":null;return(0,r.jsxs)("div",{role:"status","aria-label":`Live feed status: ${o.label}`,className:"flex min-w-0 items-center gap-2",children:[(0,r.jsx)(l,{tone:o.tone}),(0,r.jsx)("span",{className:"tnum truncate text-xs text-muted-foreground",children:o.label}),c?(0,r.jsxs)("span",{className:"tnum hidden truncate text-xs text-muted-foreground lg:inline",title:c,children:["\xb7 ",c]}):null,i?(0,r.jsxs)("button",{type:"button",onClick:d,className:"max-w-[16rem] truncate rounded-md border border-border px-2 py-0.5 text-xs text-foreground transition-colors hover:bg-card-strong",title:`${i} Click to dismiss.`,children:[i,(0,r.jsx)("span",{"aria-hidden":!0,children:" ✕"})]}):null]})}function o(){let{session:e,phase:n}=(0,a.M)(),t=s(e,n);return(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 text-xs",children:[(0,r.jsx)(l,{tone:t.tone}),(0,r.jsx)("span",{className:"truncate",role:"status","aria-label":`Live feed status: ${t.label}`,children:t.label})]})}},1721:(e,n,t)=>{t.d(n,{MachineBreadcrumb:()=>d});var r=t(5155),a=t(8500),i=t.n(a),s=t(9939),l=t(8664);function d({machineId:e,title:n,view:t}){let{machines:a}=(0,s.M)(),o=(0,l.FM)(),c=a.find(n=>n.machineId===e),m=c?.displayName||c?.hostname||"Machine";return(0,r.jsxs)("nav",{"aria-label":"Breadcrumb",className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,r.jsx)(i(),{href:"/",className:"hidden text-muted-foreground hover:text-foreground sm:inline",children:"Fleet"}),(0,r.jsx)("span",{"aria-hidden":!0,className:"hidden text-muted-foreground sm:inline",children:"/"}),(0,r.jsx)(i(),{href:(0,l.Y2)(e,"overview"),className:"hidden max-w-48 truncate text-muted-foreground hover:text-foreground md:inline",children:m}),(0,r.jsx)("select",{"aria-label":"Machine",value:e,onChange:e=>o(e.target.value,t),className:"h-8 min-w-0 max-w-32 rounded-md border border-border bg-card px-1.5 text-sm md:hidden",children:a.map(e=>(0,r.jsx)("option",{value:e.machineId,children:e.displayName||e.hostname||e.machineId},e.machineId))}),(0,r.jsx)("span",{"aria-hidden":!0,className:"text-muted-foreground",children:"/"}),(0,r.jsx)("h1",{className:"truncate text-lg font-semibold tracking-tight",children:n})]})}},2394:(e,n,t)=>{t.d(n,{ThemeToggle:()=>l});var r=t(5155),a=t(1134),i=t(9145),s=t(460);function l(){let{resolvedTheme:e,setTheme:n}=(0,s.D)();return(0,r.jsxs)("button",{type:"button",onClick:()=>n("dark"===e?"light":"dark"),"aria-label":"Toggle theme",className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-selected hover:text-foreground",children:[(0,r.jsx)(a.A,{className:"h-4.5 w-4.5 dark:hidden"}),(0,r.jsx)(i.A,{className:"hidden h-4.5 w-4.5 dark:block"})]})}},2701:(e,n,t)=>{t.d(n,{Sidebar:()=>k});var r=t(5155),a=t(8500),i=t.n(a),s=t(3321),l=t(257),d=t(7233),o=t(2955),c=t(3896),m=t(9764),u=t(4201),h=t(8731),x=t(8664),f=t(8773),b=t(940),g=t(9939),p=t(7586),v=t(7348);let w=[{href:"/alerts",label:"Alerts",icon:l.A},{href:"/connections",label:"Connections",icon:d.A}],j=[{view:"overview",label:"Overview",icon:o.A},{view:"history",label:"History",icon:c.A},{view:"processes",label:"Processes",icon:m.A}],N=e=>["flex min-h-9 min-w-0 items-center gap-3 rounded-md border px-2 text-sm transition-colors md:px-3",e?"border-accent/60 bg-selected font-medium text-foreground":"border-transparent text-muted-foreground hover:bg-card-strong hover:text-foreground"].join(" ");function k({machineId:e,machineView:n}){let t=(0,s.usePathname)(),{session:a,machines:l,phase:d}=(0,g.M)(),o=(0,v.c)(),{machine:c,view:m,selectMachine:y}=(0,x.PY)(e,n),I="signed-in"===a.kind&&!0===a.user.admin?[...w,{href:"/administration",label:"Administration",icon:u.A}]:w;return(0,r.jsxs)("aside",{className:"flex w-14 shrink-0 flex-col border-r border-border bg-background md:w-56",children:[(0,r.jsxs)(i(),{href:"/","aria-label":"Rigscope",className:"flex h-14 shrink-0 items-center gap-2.5 border-b border-border px-3 md:px-5",children:[(0,r.jsx)(f.R,{className:"h-5 w-5 shrink-0 text-accent","aria-hidden":!0}),(0,r.jsx)("span",{className:"hidden text-sm font-semibold tracking-tight text-foreground md:inline",children:"Rigscope"})]}),(0,r.jsxs)("nav",{"aria-label":"Primary",className:"flex min-h-0 flex-1 flex-col overflow-y-auto p-2 md:p-3",children:[(0,r.jsxs)(i(),{href:"/","aria-current":"/"===t?"page":void 0,title:"Fleet","aria-label":"Fleet",className:N("/"===t),children:[(0,r.jsx)(h.A,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),(0,r.jsx)("span",{className:"hidden md:inline",children:"Fleet"})]}),l.length>0?(0,r.jsx)("div",{role:"group","aria-label":"Select a machine",className:"my-3 flex max-h-[min(30dvh,20rem)] shrink-0 flex-col gap-1 overflow-y-auto",children:l.map(e=>{let n=e.displayName||e.hostname||e.machineId,t=e.tags?.join(", "),a=c?.machineId===e.machineId,i=(0,p.vj)(e,o),s=e.connected?"live"!==d?"Feed unavailable":"stale"===i?"Stale":"unknown"===i?"No sample yet":"Live":"Disconnected",l="Live"===s?"bg-ok":"Disconnected"===s?"bg-crit":"No sample yet"===s?"bg-muted-foreground":"bg-warn",m=e.inventory?.cpu.model||t;return(0,r.jsxs)("button",{type:"button","aria-pressed":a,"aria-label":`${n}: ${s}${m?`, ${m}`:""}`,title:[n,s,m,t].filter(Boolean).join(" \xb7 "),onClick:()=>y(e.machineId),className:`${N(a)} w-full shrink-0 py-2 text-left focus-visible:outline-offset-[-2px] max-md:justify-center max-md:px-0`,children:[(0,r.jsxs)("span",{"aria-hidden":!0,className:"relative flex h-5 w-6 shrink-0 items-center justify-center md:w-4",children:[(0,r.jsx)("span",{className:"text-xs font-medium md:hidden",children:n.slice(0,2).toUpperCase()}),(0,r.jsx)("span",{className:`h-2 w-2 shrink-0 rounded-full max-md:absolute max-md:-right-1 max-md:-bottom-0.5 ${l}`})]}),(0,r.jsxs)("span",{className:"hidden min-w-0 flex-1 md:block",children:[(0,r.jsx)("span",{className:"block break-words font-medium leading-5",children:n}),m?(0,r.jsx)("span",{className:`mt-0.5 block break-words text-xs leading-4 ${a?"text-foreground/80":"text-muted-foreground"}`,children:m}):null]})]},e.machineId)})}):null,c?(0,r.jsx)("div",{role:"group","aria-label":"Selected machine views",className:"mb-3 flex shrink-0 flex-col gap-1 border-t border-border pt-3",children:j.map(({view:e,label:n,icon:t})=>(0,r.jsxs)(i(),{href:(0,x.Y2)(c.machineId,e),"aria-current":m===e?"page":void 0,"aria-label":`${c.displayName||c.hostname||c.machineId}: ${n}`,title:`${c.displayName||c.hostname||c.machineId}: ${n}`,className:N(m===e),children:[(0,r.jsx)(t,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),(0,r.jsx)("span",{className:"hidden md:inline",children:n})]},e))}):null,(0,r.jsx)("div",{className:"flex shrink-0 flex-col gap-1 border-t border-border pt-3",children:I.map(({href:e,label:n,icon:a})=>(0,r.jsxs)(i(),{href:e,"aria-current":t===e?"page":void 0,title:n,"aria-label":n,className:N(t===e),children:[(0,r.jsx)(a,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),(0,r.jsx)("span",{className:"hidden md:inline",children:n})]},e))})]}),(0,r.jsx)("footer",{className:"hidden shrink-0 border-t border-border p-3 md:block",children:(0,r.jsx)(b.TK,{})})]})}},3440:(e,n,t)=>{t.d(n,{Z:()=>a,p:()=>i});var r=t(5155);function a({title:e,action:n,className:t,children:i}){return(0,r.jsxs)("section",{className:["flex min-w-0 flex-col rounded-xl border border-border bg-card p-5",t].filter(Boolean).join(" "),children:[(0,r.jsxs)("div",{className:"flex shrink-0 items-center justify-between gap-4",children:[(0,r.jsx)("h2",{className:"text-sm font-medium tracking-tight",children:e}),n?(0,r.jsx)("div",{className:"text-xs tabular-nums",children:n}):null]}),(0,r.jsx)("div",{className:"mt-4 flex min-h-0 flex-1 flex-col",children:i})]})}function i({icon:e,note:n,className:t}){return(0,r.jsxs)("div",{className:["flex flex-1 flex-col items-center justify-center gap-2.5 rounded-lg border border-dashed border-border px-6 py-10 text-center",t].filter(Boolean).join(" "),children:[(0,r.jsx)(e,{className:"h-5 w-5 text-muted-foreground","aria-hidden":!0}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:n})]})}},4173:(e,n,t)=>{t.d(n,{G:()=>l});var r=t(5155),a=t(1721),i=t(2701),s=t(2394);function l({title:e,headerRight:n,children:t,workspace:d=!1,machineId:o,machineView:c}){return(0,r.jsxs)("div",{className:"relative flex h-dvh overflow-hidden bg-background text-foreground",children:[(0,r.jsx)("a",{href:"#main-content",className:"sr-only z-50 rounded-md bg-card px-4 py-2 text-foreground focus:not-sr-only focus:absolute focus:start-2 focus:top-2 focus:outline-2 focus:outline-accent",children:"Skip to content"}),(0,r.jsx)(i.Sidebar,{machineId:o,machineView:c}),(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[(0,r.jsxs)("header",{className:"flex min-h-14 shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-2 md:px-6",children:[o&&c?(0,r.jsx)(a.MachineBreadcrumb,{machineId:o,title:e,view:c}):(0,r.jsx)("h1",{className:"truncate text-lg font-semibold tracking-tight",children:e}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[n?(0,r.jsx)("div",{className:"flex min-w-0 items-center gap-3",children:n}):null,(0,r.jsx)(s.ThemeToggle,{})]})]}),(0,r.jsx)("main",{id:"main-content",tabIndex:-1,className:`relative min-h-0 min-w-0 flex-1 overflow-x-hidden overscroll-contain p-4 outline-offset-[-2px] md:p-6 ${d?"flex flex-col overflow-y-hidden":"overflow-y-auto"}`,children:(0,r.jsx)("div",{className:d?"mx-auto flex h-full w-full min-h-0 min-w-0 max-w-[1500px] flex-1 flex-col":"mx-auto flex w-full min-w-0 max-w-[1500px] flex-col",children:t})})]})]})}},6114:(e,n,t)=>{t.d(n,{u:()=>u});var r=t(2115);let a="rigscope:",i=new Map,s=new Map,l=new Map,d=!1;function o(e){try{return"local"===e?window.localStorage:window.sessionStorage}catch{return null}}function c(e,n){return`${e}:${n}`}function m(e,n,t,r){let s=c(e,n);if(i.has(s))return i.get(s);let l=t,d=o(e);if(null!==d)try{let e=d.getItem(a+n);if(null!==e){let n=r(JSON.parse(e));null!==n&&(l=n)}}catch{}return i.set(s,l),l}function u(e,n,t,h="local"){let x=c(h,e);return[(0,r.useSyncExternalStore)((0,r.useCallback)(e=>{let n;return void 0===(n=s.get(x))&&(n=new Set,s.set(x,n)),n.add(e),()=>{n.delete(e)}},[x]),()=>m(h,e,n,t),()=>n),(0,r.useCallback)(r=>{let u=m(h,e,n,t),f="function"==typeof r?r(u):r;if(!Object.is(f,u)){i.set(x,f);let n=c(h,e),t=l.get(n);void 0!==t&&clearTimeout(t.timer);let r=()=>{let t=l.get(n);t&&clearTimeout(t.timer),l.delete(n);let r=o(h);if(null!==r)try{r.setItem(a+e,JSON.stringify(i.get(n)))}catch{}};if(l.set(n,{timer:setTimeout(r,250),flush:r}),!d){d=!0;let e=()=>l.forEach(e=>e.flush());window.addEventListener("pagehide",e),document.addEventListener("visibilitychange",()=>{document.hidden&&e()})}s.get(x)?.forEach(e=>e())}},[n,x,e,h,t])]}},7348:(e,n,t)=>{t.d(n,{c:()=>a});var r=t(2115);function a(e=1e3){let[n,t]=(0,r.useState)(()=>Date.now());return(0,r.useEffect)(()=>{t(Date.now());let n=setInterval(()=>t(Date.now()),e);return()=>clearInterval(n)},[e]),n}},8664:(e,n,t)=>{t.d(n,{FM:()=>f,JG:()=>x,PY:()=>b,Y2:()=>l});var r=t(2115),a=t(3321),i=t(6114),s=t(9939);function l(e,n){let t=encodeURIComponent(e);return"overview"===n?`/machines/${t}`:`/${n}?machineId=${t}`}function d(e){let n=e.inventory?.capabilities?.processes;return void 0===n||"supported"===n.status}let o={overview:e=>e[0],history:e=>e[0],processes:e=>e.find(d)??e[0]};function c({view:e,requestedMachineId:n,rememberedMachineId:t,machines:r}){if(0===r.length)return{kind:"fleet-empty"};if(n){let e=r.find(e=>e.machineId===n);return e?{kind:"resolved",machine:e,via:"requested"}:{kind:"missing",requestedMachineId:n}}if(t){let e=r.find(e=>e.machineId===t);if(e)return{kind:"resolved",machine:e,via:"remembered"}}let a=o[e](r);return a?{kind:"resolved",machine:a,via:"fallback"}:{kind:"fleet-empty"}}let m=e=>"string"==typeof e?e:null;function u(){return(0,i.u)("machine.selected","",m,"session")}let h=new Set(["history"]);function x(e,n){let{session:t,machines:i}=(0,s.M)(),l=(0,a.useRouter)(),d=(0,a.usePathname)()||`/${e}`,o=(0,a.useSearchParams)(),[m,x]=u(),f="overview"===e?n??"":o.get("machineId")||null,b=(0,r.useMemo)(()=>c({view:e,requestedMachineId:f,rememberedMachineId:m,machines:i}),[e,f,m,i]),g="resolved"===b.kind?b.machine:void 0,p=g?.machineId??"",v="overview"===e?f??"":"processes"===e?g?.machineId??f??"":p;(0,r.useEffect)(()=>{p&&x(p)},[p,x]);let w=h.has(e);return(0,r.useEffect)(()=>{if(!w||"signed-in"!==t.kind||0===i.length||null!==f||""===p)return;let e=function(e,n,t){if(n.get("machineId"))return null;let r=new URLSearchParams(n.toString());return r.set("machineId",t),`${e}?${r.toString()}`}(d,o,p);e&&l.replace(e,{scroll:!1})},[w,t.kind,i,f,p,o,l,d]),{resolution:b,machine:g,machineId:p,navMachineId:v,requestedMachineId:f}}function f(){let e=(0,a.useRouter)(),[,n]=u();return(0,r.useCallback)((t,r)=>{n(t),e.push(l(t,r))},[n,e])}function b(e,n){let t=(0,a.usePathname)()||"/",{machines:r}=(0,s.M)(),[i]=u(),l=f(),d=n??(t.startsWith("/machines/")?"overview":"/history"===t?"history":"/processes"===t?"processes":null),o=c({view:d??"overview",requestedMachineId:r.some(n=>n.machineId===e)?e:null,rememberedMachineId:i,machines:r});return{view:d,machine:"resolved"===o.kind?o.machine:void 0,selectMachine:e=>l(e,d??"overview")}}},8773:(e,n,t)=>{t.d(n,{R:()=>a});var r=t(5155);function a(e){return(0,r.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",...e,children:[(0,r.jsx)("path",{d:"M8 3H4v18h4M16 3h4v18h-4"}),(0,r.jsx)("path",{d:"m8 15 4-6 4 3M8 8h.01M16 17h.01"})]})}}}]);
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[227],{438:(e,t,s)=>{s.d(t,{A:()=>n});let n=(0,s(8698).A)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},2241:(e,t,s)=>{s.d(t,{B4:()=>p,CE:()=>d,V5:()=>i,YL:()=>y,Zf:()=>f,cH:()=>c,cy:()=>C,d5:()=>m,fp:()=>B,hL:()=>N,rn:()=>u,v4:()=>o});var n=s(7586);function r(e,t){return{state:"value",value:e,stale:t}}function a(e){return{state:"unavailable",reason:e}}function l(e){return{state:"absent",reason:e}}function o(e){let t=e.displayName?.trim();if(t)return t;let s=e.hostname?.trim();return s||e.machineId}function i(e){let t=new Set,s=[];for(let n of e.tags??[]){if("string"!=typeof n)continue;let e=n.trim();if(!(""===e||t.has(e.toLowerCase()))&&(t.add(e.toLowerCase()),s.push(e),s.length>=32))break}return s}function u(e,t){let s=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return 0===s.length?[...e]:e.filter(e=>{let t=[o(e),e.hostname,e.machineId,e.collectorId,...i(e)].filter(e=>"string"==typeof e&&""!==e.trim()).join(" ").toLowerCase();return s.every(e=>t.includes(e))})}function d(e){return null!=e&&Number.isFinite(e)?`${(0,n.z3)(e)}/s`:"—"}function c(e){return null!=e&&Number.isFinite(e)?`${Math.round(e)} \xb0C`:"—"}function m(e){return null!=e&&Number.isFinite(e)?`${Math.round(e)} W`:"—"}function y(e){return null==e||!Number.isFinite(e)||e<0?"—":`${e<10?e.toFixed(2):e.toFixed(1)} ms`}function p(e){return null!=e&&Number.isFinite(e)?Math.round(e).toLocaleString():"—"}function f(e){return null!=e&&Number.isFinite(e)?`${Math.round(e)} Mb/s`:"—"}function x(e){let t=e.filter(e=>"supported"===e.telemetry);return t.some(e=>"ok"===e.state)&&t.some(e=>"ok"!==e.state)}let h="The collector has not reported this metric family to this hub.";function g(e){return e.metrics?.payload??null}function v(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function b(e){let t=v(e);return null!==t&&t>=0?t:null}function k(e,t,s,n,o=!0){if(null===e||"object"!=typeof e)return l(n);if("unavailable"===e.status)return a(("string"==typeof e.reason?e.reason.trim():"")||"This metric family is unavailable.");if("ok"!==e.status)return l(n);let i=(o?b:v)(e[t]);return null===i?a("Not reported for this sample."):r(i,s)}function w(e){let t=g(e);return null!==t?"ok"===t.disks.status?{state:"available"}:{state:"unavailable",reason:t.disks.reason}:{state:"absent",reason:h}}function N(e,t){var s;let u,d,c,m,y,p,f,v,N,j=(0,n.vj)(e,t),B="stale"===j,P=function(e,t){let s=e.inventory?.gpus??[],n=g(e),r=n?.gpus.status==="ok"?n.gpus.devices:[],a=n?.gpus.status==="unavailable"?n.gpus.reason:null,l=new Map(r.map(e=>[e.id,e])),o=new Map(s.map(e=>[e.id,e])),i=[];for(let e of s)i.push(e.id);for(let e of r)o.has(e.id)||i.push(e.id);let u=[];for(let e of i){let s=o.get(e),n=l.get(e),r={id:e,name:s?.name??e.replace(/^gpu:/,""),vendor:s?.vendor??"other",pciBusId:s?.pciBusId??null,telemetry:s?.telemetry??"supported",stale:t};if(n?.status==="ok"){u.push({...r,state:"ok",reason:null,utilizationPercent:n.utilizationPercent,memoryUsedBytes:n.memoryUsedBytes,memoryTotalBytes:n.memoryTotalBytes??s?.memoryTotalBytes??null,temperatureC:n.temperatureC,powerWatts:n.powerWatts});continue}if(n?.status==="unavailable"){u.push({...r,state:"unavailable",reason:n.reason,utilizationPercent:null,memoryUsedBytes:null,memoryTotalBytes:s?.memoryTotalBytes??null,temperatureC:null,powerWatts:null});continue}if(s?.telemetry==="unsupported"){u.push({...r,state:"unsupported",reason:s.reason??"No supported telemetry for this adapter.",utilizationPercent:null,memoryUsedBytes:null,memoryTotalBytes:null,temperatureC:null,powerWatts:null});continue}u.push({...r,state:"unavailable",reason:a??"No current reading for this device.",utilizationPercent:null,memoryUsedBytes:null,memoryTotalBytes:s?.memoryTotalBytes??null,temperatureC:null,powerWatts:null})}return u}(e,B);return{displayName:o(e),tags:i(e),freshness:j,thresholdMs:(0,n.Cj)(e.expectedIntervalMs),stale:B,cpu:{total:void 0===(c=e.metrics?.payload.cpu)?l("No CPU reading has been received yet."):"ok"===c.status?r(c.usagePercent,B):a(c.reason),perCore:void 0===(m=e.metrics?.payload.cpu)?l("No CPU reading has been received yet; per-core values are unknown."):"ok"===m.status?r([...m.perCore],B):a(m.reason)},memory:void 0===(y=e.metrics?.payload.memory)?l("No memory reading has been received yet."):"ok"===y.status?r({usedBytes:y.usedBytes,totalBytes:y.totalBytes},B):a(y.reason),swap:void 0===(p=e.metrics?.payload.swap)?l("No swap reading has been received yet."):"ok"===p.status?r({usedBytes:p.usedBytes,totalBytes:p.totalBytes},B):a(p.reason),bottlenecks:(f=e.metrics?.payload.cpu,v=e.metrics?.payload.memory,N=e.metrics?.payload.disks,{cpuTemperature:k(f,"temperatureC",B,"No CPU reading has been received yet.",!1),cpuPower:k(f,"powerWatts",B,"No CPU reading has been received yet."),cpuIowait:k(f,"iowaitPercent",B,"No CPU reading has been received yet."),cpuPressure:k(f,"pressureSomePercent",B,"No CPU reading has been received yet."),memoryPressureSome:k(v,"pressureSomePercent",B,"No memory reading has been received yet."),memoryPressureFull:k(v,"pressureFullPercent",B,"No memory reading has been received yet."),ioPressureSome:k(N,"pressureSomePercent",B,"No disk reading has been received yet."),ioPressureFull:k(N,"pressureFullPercent",B,"No disk reading has been received yet.")}),gpus:{family:null!==(u=g(s=e))?"ok"===u.gpus.status?{state:"available"}:{state:"unavailable",reason:u.gpus.reason}:(s.inventory?.gpus.length??0)>0?{state:"absent",reason:"No GPU readings have been received yet."}:{state:"absent",reason:h+" GPU telemetry is unknown until inventory or a reading arrives."},cards:P,partial:x(P)},filesystems:{family:w(e),items:function(e,t){let s=e.inventory?.filesystems??[],n=g(e),r=n?.disks.status==="ok"?n.disks.filesystems:[],a=n?.disks.status==="unavailable"?n.disks.reason:null,l=new Map(r.map(e=>[e.id,e])),o=new Map(s.map(e=>[e.id,e])),i=[];for(let e of s)i.push(e.id);for(let e of r)o.has(e.id)||i.push(e.id);return i.map(e=>{let s=o.get(e),r=l.get(e),i={id:e,mountPoint:s?.mountPoint??e.replace(/^fs:/,""),device:s?.device??"",fsType:s?.fsType??"unknown",totalBytes:s?.totalBytes??null,inodesUsed:null,inodesTotal:null,stale:t};return r?.status==="ok"?{...i,usedBytes:r.usedBytes,totalBytes:r.totalBytes,inodesUsed:b(r.inodesUsed),inodesTotal:b(r.inodesTotal),state:"ok",reason:null}:r?.status==="unavailable"?{...i,usedBytes:null,state:"unavailable",reason:r.reason}:null!==a?{...i,usedBytes:null,state:"unavailable",reason:a}:{...i,usedBytes:null,state:"inventory",reason:null===n?h:"No current usage reading for this filesystem."}})}(e,B)},disks:{family:w(e),items:function(e,t){let s=e.inventory?.disks??[],n=g(e),r=n?.disks.status==="ok"?n.disks.devices:[],a=n?.disks.status==="unavailable"?n.disks.reason:null,l=new Map(r.map(e=>[e.id,e])),o=new Map(s.map(e=>[e.id,e])),i=[];for(let e of s)i.push(e.id);for(let e of r)o.has(e.id)||i.push(e.id);return i.map(e=>{let s=o.get(e),r=l.get(e),i={id:e,name:s?.name??e.replace(/^disk:/,""),model:s?.model??null,rotational:s?.rotational??null,sizeBytes:s?.sizeBytes??null,readLatencyMs:null,writeLatencyMs:null,ioUtilizationPercent:null,stale:t};return r?.status==="ok"?{...i,state:"ok",reason:null,readBytesPerSec:r.readBytesPerSec,writeBytesPerSec:r.writeBytesPerSec,readLatencyMs:b(r.readLatencyMs),writeLatencyMs:b(r.writeLatencyMs),ioUtilizationPercent:b(r.ioUtilizationPercent)}:r?.status==="unavailable"?{...i,state:"unavailable",reason:r.reason,readBytesPerSec:null,writeBytesPerSec:null}:null!==a?{...i,state:"unavailable",reason:a,readBytesPerSec:null,writeBytesPerSec:null}:{...i,state:"inventory",reason:null===n?h:"No current I/O reading for this device.",readBytesPerSec:null,writeBytesPerSec:null}})}(e,B)},network:{family:null!==(d=g(e))?"ok"===d.network.status?{state:"available"}:{state:"unavailable",reason:d.network.reason}:{state:"absent",reason:h},items:function(e,t){let s=e.inventory?.network??[],n=g(e),r=n?.network.status==="ok"?n.network.interfaces:[],a=n?.network.status==="unavailable"?n.network.reason:null,l=new Map(r.map(e=>[e.id,e])),o=new Map(s.map(e=>[e.id,e])),i=[];for(let e of s)i.push(e.id);for(let e of r)o.has(e.id)||i.push(e.id);return i.map(e=>{let s=o.get(e),r=l.get(e),i={id:e,name:s?.name??e.replace(/^net:/,""),mac:s?.mac??null,addresses:s?.addresses??[],virtual:s?.virtual??!1,linkState:s?.state??"unknown",speedMbps:s?.speedMbps??null,stale:t};return r?.status==="ok"?{...i,state:"ok",reason:null,rxBytesPerSec:r.rxBytesPerSec,txBytesPerSec:r.txBytesPerSec}:r?.status==="unavailable"?{...i,state:"unavailable",reason:r.reason,rxBytesPerSec:null,txBytesPerSec:null}:null!==a?{...i,state:"unavailable",reason:a,rxBytesPerSec:null,txBytesPerSec:null}:{...i,state:"inventory",reason:null===n?h:"No current rate reading for this interface.",rxBytesPerSec:null,txBytesPerSec:null}})}(e,B)}}}function j(e){if(0===e.length||e.some(e=>null===e))return null;let t=0;for(let s of e)t+=s;return t}function B(e,t){let s,n,r,a,l,o,i=N(e,t),u=i.gpus.cards,d=0===u.length?null:(r=(n=(s=u.filter(e=>"supported"===e.telemetry)).filter(e=>"ok"===e.state)).map(e=>e.utilizationPercent).filter(e=>null!==e),a=j(s.map(e=>e.memoryUsedBytes)),l=j(s.map(e=>e.memoryTotalBytes)),o=0===n.length?"unavailable"===i.gpus.family.state||"absent"===i.gpus.family.state?i.gpus.family.reason:0===s.length?"No telemetry-supported GPU was reported.":"No current GPU reading.":null,{count:u.length,supportedCount:s.length,okCount:n.length,partial:x(u),maxUtilizationPercent:0===r.length?null:Math.max(...r),memoryUsedBytes:a,memoryTotalBytes:l,stale:i.stale,reason:o}),c=i.filesystems.items.filter(e=>"ok"===e.state&&null!==e.usedBytes&&null!==e.totalBytes&&e.totalBytes>0).map(e=>e.usedBytes/e.totalBytes*100),m=0===i.filesystems.items.length?null:{maxUsedPercent:0===c.length?null:Math.max(...c),stale:i.stale,reason:0===c.length?"available"===i.filesystems.family.state?"No current filesystem usage reading.":i.filesystems.family.reason:null},y=i.network.items.filter(e=>"ok"===e.state&&null!==e.rxBytesPerSec&&null!==e.txBytesPerSec),p=0===i.network.items.length?null:{rxBytesPerSec:y.reduce((e,t)=>e+t.rxBytesPerSec,0),txBytesPerSec:y.reduce((e,t)=>e+t.txBytesPerSec,0),stale:i.stale,reason:0===y.length?"available"===i.network.family.state?"No current interface rate reading.":i.network.family.reason:null};return{cpu:i.cpu.total,memory:i.memory,gpu:d,disk:m,network:p}}let P=["cpu","memory","swap","gpus","disks","network","processes"],S={cpu:"CPU",memory:"Memory",swap:"Swap",gpus:"GPUs",disks:"Disks",network:"Network",processes:"Processes"};function C(e,t){return e.map(e=>{var s;return{machineId:e.machineId,name:o(e),collectorId:e.collectorId,connected:e.connected,cadenceMs:e.expectedIntervalMs??null,thresholdMs:(0,n.Cj)(e.expectedIntervalMs),lastReceivedAt:e.lastReceivedAt,freshness:(0,n.vj)(e,t),delivery:e.delivery?.delivery??null,deliveryCapturedAt:e.delivery?.capturedAt??null,failures:e.delivery?.failures??[],capabilities:void 0===(s=e.inventory)?null:P.map(e=>{let t=s.capabilities[e];return{key:e,label:S[e],status:t.status,reason:t.reason??null}})}})}},6576:(e,t,s)=>{s.d(t,{iL:()=>d,jB:()=>m,vw:()=>y});var n=s(5155),r=s(7586),a=s(5887);let l=2*Math.PI*70;function o(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}function i(e){let{reason:t,ageLabel:s,center:r}=e;return(0,n.jsxs)("p",{className:r?"max-w-[16rem] text-center text-xs text-warn":"text-xs text-warn",children:["Unavailable — ",t,s?(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" (last update ",s,")"]}):null]})}function u(e){let{reason:t,ageLabel:s}=e;return(0,n.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,n.jsx)("div",{role:"img","aria-label":`Unavailable — ${t}`,className:"flex h-40 w-40 shrink-0 items-center justify-center rounded-full border-[5px] border-dashed border-border",children:(0,n.jsx)("span",{className:"tnum text-xl font-semibold text-muted-foreground",children:"—"})}),(0,n.jsx)(i,{reason:t,ageLabel:s,center:!0})]})}function d(e){let{metricName:t,field:s,ageLabel:i,isHeld:d,thresholdMs:c}=e;if("unavailable"===s.out)return(0,n.jsx)(u,{reason:s.reason,ageLabel:i??null});if("absent"===s.out)return(0,n.jsx)(u,{reason:"No sample has arrived yet.",ageLabel:i??null});let m="stale"===s.out,y=o(s.value),p=l*(1-y/100),f=m?`${t} last known ${(0,r.l9)(y)}, stale`:`${t} ${(0,r.l9)(y)}`;return(0,n.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,n.jsxs)("svg",{role:"img","aria-label":f,viewBox:"0 0 160 160",className:"h-40 w-40 shrink-0",children:[(0,n.jsx)("circle",{cx:80,cy:80,r:70,fill:"none",stroke:"var(--border)",strokeWidth:8}),(0,n.jsx)("circle",{cx:80,cy:80,r:70,fill:"none",stroke:m?"var(--warn)":"var(--cpu)",strokeWidth:8,strokeLinecap:"round",strokeDasharray:l,strokeDashoffset:p,transform:"rotate(-90 80 80)"}),(0,n.jsx)("text",{x:"50%",y:m||d?"45%":"50%",dominantBaseline:"central",textAnchor:"middle",className:"fill-foreground text-xl font-semibold tnum",children:(0,r.l9)(y)}),m?(0,n.jsx)("text",{x:"50%",y:102,textAnchor:"middle",className:"fill-warn text-xs tnum",children:"last known"}):d?(0,n.jsx)("text",{x:"50%",y:102,textAnchor:"middle",className:"fill-muted-foreground text-xs tnum",children:"held"}):null]}),(0,n.jsx)("p",{className:"text-center text-xs text-muted-foreground",children:m?`Last known value — no update for over ${(0,r.$)(c??a.vz)}${i?` (${i})`:""}`:i??""})]})}function c(e){let{reason:t,ageLabel:s}=e;return(0,n.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,n.jsx)("div",{role:"img","aria-label":`Memory unavailable — ${t}`,className:"h-3 w-full max-w-64 rounded-full border border-dashed border-border"}),(0,n.jsx)(i,{reason:t,ageLabel:s})]})}function m(e){let{field:t,ageLabel:s,isHeld:l,thresholdMs:i}=e;if("unavailable"===t.out)return(0,n.jsx)(c,{reason:t.reason,ageLabel:s??null});if("absent"===t.out)return(0,n.jsx)(c,{reason:"No sample has arrived yet.",ageLabel:s??null});let u="stale"===t.out,d=t.totalBytes,m=t.usedBytes,p=d>0?o(m/d*100)/100:0,f=u?`Memory last known ${(0,r.z3)(m)} of ${(0,r.z3)(d)}, stale`:`Memory ${(0,r.z3)(m)} of ${(0,r.z3)(d)}`;return(0,n.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,n.jsx)("div",{role:"img","aria-label":f,className:"flex h-3 w-full max-w-64 items-stretch overflow-hidden rounded-full bg-card-strong",children:(0,n.jsx)("div",{className:"h-full rounded-full",style:{width:`${100*p}%`,backgroundColor:u?"var(--warn)":"var(--mem)",minWidth:d>0?void 0:0}})}),(0,n.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,n.jsx)("p",{className:"tnum text-sm",children:d>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"font-semibold",children:(0,r.z3)(m)}),(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" of ",(0,r.z3)(d)]}),(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" ","\xb7 ",(0,r.l9)(d>0?m/d*100:null)]})]}):(0,n.jsxs)("span",{className:"text-muted-foreground",children:[(0,r.z3)(m)," used — total size unavailable"]})}),u?(0,n.jsx)(y,{text:"last known",title:`No update for over ${(0,r.$)(i??a.vz)}`}):null,l&&!u?(0,n.jsx)(y,{text:"held",title:"Value kept while the connection is down"}):null]}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:u?`Retained from the last accepted sample${s?` (${s})`:""}.`:s??""})]})}function y(e){let{text:t,title:s}=e;return(0,n.jsx)("span",{title:s,className:"tnum shrink-0 rounded-full border border-border px-2 py-0.5 text-xs text-muted-foreground",children:t})}},6582:(e,t,s)=>{s.d(t,{E:()=>h,x:()=>x});var n=s(5155),r=s(8500),a=s.n(r),l=s(828),o=s(6914),i=s(7029),u=s(438),d=s(7422),c=s(1735),m=s(3440),y=s(9939);function p(e){return(0,n.jsxs)("button",{type:"button",onClick:e.onClick,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,n.jsx)(l.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.children]})}function f(e){return(0,n.jsx)(a(),{href:e.href,className:e.primary?"inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90":"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:e.children})}function x(){let{session:e,phase:t,retryConnection:s}=(0,y.M)();switch(e.kind){case"restoring":return(0,n.jsx)(m.Z,{title:"Checking session",className:"mx-auto my-12 max-w-md",children:(0,n.jsx)(m.p,{icon:o.A,note:"Checking your session…"})});case"restore-failed":return(0,n.jsxs)(m.Z,{title:"Hub unreachable",className:"mx-auto my-12 max-w-md",children:[(0,n.jsx)(m.p,{icon:i.A,note:"The hub is unreachable right now."}),(0,n.jsx)("div",{className:"flex justify-center",children:(0,n.jsx)(p,{onClick:s,children:"Check again"})})]});case"signed-out":if("expired"===t)return(0,n.jsxs)(m.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,n.jsx)(m.p,{icon:u.A,note:"Your session ended."}),(0,n.jsx)("div",{className:"flex justify-center",children:(0,n.jsx)(f,{href:"/login",primary:!0,children:"Sign in"})})]});return(0,n.jsxs)(m.Z,{title:"Sign in required",className:"mx-auto my-12 max-w-md",children:[(0,n.jsx)(m.p,{icon:o.A,note:"Sign in required."}),(0,n.jsx)("div",{className:"flex justify-center",children:(0,n.jsx)(f,{href:"/login",primary:!0,children:"Sign in"})})]});case"auth-unavailable":return(0,n.jsx)(m.Z,{title:"Sign-in unavailable",className:"mx-auto my-12 max-w-md",children:(0,n.jsx)(m.p,{icon:d.A,note:"Browser sign-in is not configured on this hub."})})}return"expired"===t?(0,n.jsxs)(m.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,n.jsx)(m.p,{icon:u.A,note:"Your session ended."}),(0,n.jsx)("div",{className:"flex justify-center",children:(0,n.jsx)(f,{href:"/login",primary:!0,children:"Sign in"})})]}):"no-permission"===t?(0,n.jsxs)(m.Z,{title:"No permission",className:"mx-auto my-12 max-w-md",children:[(0,n.jsx)(m.p,{icon:d.A,note:`You are signed in as ${e.user.username}, but this hub grants no machine view to this account.`}),(0,n.jsx)("div",{className:"flex justify-center",children:(0,n.jsx)(p,{onClick:s,children:"Check again"})})]}):null}function h(){let{phase:e,retryConnection:t}=(0,y.M)();return"reconnecting"!==e&&"disconnected"!==e&&"connecting"!==e?null:"connecting"===e?(0,n.jsxs)("div",{role:"status",className:"mb-5 flex items-center gap-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,n.jsx)(l.A,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),"Connecting to the live feed — waiting for the first snapshot."]}):(0,n.jsxs)("div",{role:"status",className:"mb-5 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,n.jsx)(c.A,{className:"h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,n.jsxs)("span",{children:["Connection lost — values below are ",(0,n.jsx)("strong",{className:"font-medium text-foreground",children:"last known"}),", not live measurements","reconnecting"===e?" — retrying with backoff…":" — retries stopped."]}),"disconnected"===e?(0,n.jsx)(p,{onClick:t,children:"Retry now"}):null]})}},7348:(e,t,s)=>{s.d(t,{c:()=>r});var n=s(2115);function r(e=1e3){let[t,s]=(0,n.useState)(()=>Date.now());return(0,n.useEffect)(()=>{s(Date.now());let t=setInterval(()=>s(Date.now()),e);return()=>clearInterval(t)},[e]),t}}}]);
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[130],{438:(e,t,s)=>{s.d(t,{A:()=>n});let n=(0,s(8698).A)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},2241:(e,t,s)=>{s.d(t,{B4:()=>p,CE:()=>d,V5:()=>o,YL:()=>y,Zf:()=>f,cH:()=>c,cy:()=>C,d5:()=>m,fp:()=>B,hL:()=>N,rn:()=>u,v4:()=>i});var n=s(7586);function r(e,t){return{state:"value",value:e,stale:t}}function a(e){return{state:"unavailable",reason:e}}function l(e){return{state:"absent",reason:e}}function i(e){let t=e.displayName?.trim();if(t)return t;let s=e.hostname?.trim();return s||e.machineId}function o(e){let t=new Set,s=[];for(let n of e.tags??[]){if("string"!=typeof n)continue;let e=n.trim();if(!(""===e||t.has(e.toLowerCase()))&&(t.add(e.toLowerCase()),s.push(e),s.length>=32))break}return s}function u(e,t){let s=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return 0===s.length?[...e]:e.filter(e=>{let t=[i(e),e.hostname,e.machineId,e.collectorId,...o(e)].filter(e=>"string"==typeof e&&""!==e.trim()).join(" ").toLowerCase();return s.every(e=>t.includes(e))})}function d(e){return null!=e&&Number.isFinite(e)?`${(0,n.z3)(e)}/s`:"—"}function c(e){return null!=e&&Number.isFinite(e)?`${Math.round(e)} \xb0C`:"—"}function m(e){return null!=e&&Number.isFinite(e)?`${Math.round(e)} W`:"—"}function y(e){return null==e||!Number.isFinite(e)||e<0?"—":`${e<10?e.toFixed(2):e.toFixed(1)} ms`}function p(e){return null!=e&&Number.isFinite(e)?Math.round(e).toLocaleString():"—"}function f(e){return null!=e&&Number.isFinite(e)?`${Math.round(e)} Mb/s`:"—"}function x(e){let t=e.filter(e=>"supported"===e.telemetry);return t.some(e=>"ok"===e.state)&&t.some(e=>"ok"!==e.state)}let h="The collector has not reported this metric family to this hub.";function g(e){return e.metrics?.payload??null}function v(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function b(e){let t=v(e);return null!==t&&t>=0?t:null}function k(e,t,s,n,i=!0){if(null===e||"object"!=typeof e)return l(n);if("unavailable"===e.status)return a(("string"==typeof e.reason?e.reason.trim():"")||"This metric family is unavailable.");if("ok"!==e.status)return l(n);let o=(i?b:v)(e[t]);return null===o?a("Not reported for this sample."):r(o,s)}function w(e){let t=g(e);return null!==t?"ok"===t.disks.status?{state:"available"}:{state:"unavailable",reason:t.disks.reason}:{state:"absent",reason:h}}function N(e,t){var s;let u,d,c,m,y,p,f,v,N,j=(0,n.vj)(e,t),B="stale"===j,P=function(e,t){let s=e.inventory?.gpus??[],n=g(e),r=n?.gpus.status==="ok"?n.gpus.devices:[],a=n?.gpus.status==="unavailable"?n.gpus.reason:null,l=new Map(r.map(e=>[e.id,e])),i=new Map(s.map(e=>[e.id,e])),o=[];for(let e of s)o.push(e.id);for(let e of r)i.has(e.id)||o.push(e.id);let u=[];for(let e of o){let s=i.get(e),n=l.get(e),r={id:e,name:s?.name??e.replace(/^gpu:/,""),vendor:s?.vendor??"other",pciBusId:s?.pciBusId??null,telemetry:s?.telemetry??"supported",stale:t};if(n?.status==="ok"){u.push({...r,state:"ok",reason:null,utilizationPercent:n.utilizationPercent,memoryUsedBytes:n.memoryUsedBytes,memoryTotalBytes:n.memoryTotalBytes??s?.memoryTotalBytes??null,temperatureC:n.temperatureC,powerWatts:n.powerWatts});continue}if(n?.status==="unavailable"){u.push({...r,state:"unavailable",reason:n.reason,utilizationPercent:null,memoryUsedBytes:null,memoryTotalBytes:s?.memoryTotalBytes??null,temperatureC:null,powerWatts:null});continue}if(s?.telemetry==="unsupported"){u.push({...r,state:"unsupported",reason:s.reason??"No supported telemetry for this adapter.",utilizationPercent:null,memoryUsedBytes:null,memoryTotalBytes:null,temperatureC:null,powerWatts:null});continue}u.push({...r,state:"unavailable",reason:a??"No current reading for this device.",utilizationPercent:null,memoryUsedBytes:null,memoryTotalBytes:s?.memoryTotalBytes??null,temperatureC:null,powerWatts:null})}return u}(e,B);return{displayName:i(e),tags:o(e),freshness:j,thresholdMs:(0,n.Cj)(e.expectedIntervalMs),stale:B,cpu:{total:void 0===(c=e.metrics?.payload.cpu)?l("No CPU reading has been received yet."):"ok"===c.status?r(c.usagePercent,B):a(c.reason),perCore:void 0===(m=e.metrics?.payload.cpu)?l("No CPU reading has been received yet; per-core values are unknown."):"ok"===m.status?r([...m.perCore],B):a(m.reason)},memory:void 0===(y=e.metrics?.payload.memory)?l("No memory reading has been received yet."):"ok"===y.status?r({usedBytes:y.usedBytes,totalBytes:y.totalBytes},B):a(y.reason),swap:void 0===(p=e.metrics?.payload.swap)?l("No swap reading has been received yet."):"ok"===p.status?r({usedBytes:p.usedBytes,totalBytes:p.totalBytes},B):a(p.reason),bottlenecks:(f=e.metrics?.payload.cpu,v=e.metrics?.payload.memory,N=e.metrics?.payload.disks,{cpuTemperature:k(f,"temperatureC",B,"No CPU reading has been received yet.",!1),cpuPower:k(f,"powerWatts",B,"No CPU reading has been received yet."),cpuIowait:k(f,"iowaitPercent",B,"No CPU reading has been received yet."),cpuPressure:k(f,"pressureSomePercent",B,"No CPU reading has been received yet."),memoryPressureSome:k(v,"pressureSomePercent",B,"No memory reading has been received yet."),memoryPressureFull:k(v,"pressureFullPercent",B,"No memory reading has been received yet."),ioPressureSome:k(N,"pressureSomePercent",B,"No disk reading has been received yet."),ioPressureFull:k(N,"pressureFullPercent",B,"No disk reading has been received yet.")}),gpus:{family:null!==(u=g(s=e))?"ok"===u.gpus.status?{state:"available"}:{state:"unavailable",reason:u.gpus.reason}:(s.inventory?.gpus.length??0)>0?{state:"absent",reason:"No GPU readings have been received yet."}:{state:"absent",reason:h+" GPU telemetry is unknown until inventory or a reading arrives."},cards:P,partial:x(P)},filesystems:{family:w(e),items:function(e,t){let s=e.inventory?.filesystems??[],n=g(e),r=n?.disks.status==="ok"?n.disks.filesystems:[],a=n?.disks.status==="unavailable"?n.disks.reason:null,l=new Map(r.map(e=>[e.id,e])),i=new Map(s.map(e=>[e.id,e])),o=[];for(let e of s)o.push(e.id);for(let e of r)i.has(e.id)||o.push(e.id);return o.map(e=>{let s=i.get(e),r=l.get(e),o={id:e,mountPoint:s?.mountPoint??e.replace(/^fs:/,""),device:s?.device??"",fsType:s?.fsType??"unknown",totalBytes:s?.totalBytes??null,inodesUsed:null,inodesTotal:null,stale:t};return r?.status==="ok"?{...o,usedBytes:r.usedBytes,totalBytes:r.totalBytes,inodesUsed:b(r.inodesUsed),inodesTotal:b(r.inodesTotal),state:"ok",reason:null}:r?.status==="unavailable"?{...o,usedBytes:null,state:"unavailable",reason:r.reason}:null!==a?{...o,usedBytes:null,state:"unavailable",reason:a}:{...o,usedBytes:null,state:"inventory",reason:null===n?h:"No current usage reading for this filesystem."}})}(e,B)},disks:{family:w(e),items:function(e,t){let s=e.inventory?.disks??[],n=g(e),r=n?.disks.status==="ok"?n.disks.devices:[],a=n?.disks.status==="unavailable"?n.disks.reason:null,l=new Map(r.map(e=>[e.id,e])),i=new Map(s.map(e=>[e.id,e])),o=[];for(let e of s)o.push(e.id);for(let e of r)i.has(e.id)||o.push(e.id);return o.map(e=>{let s=i.get(e),r=l.get(e),o={id:e,name:s?.name??e.replace(/^disk:/,""),model:s?.model??null,rotational:s?.rotational??null,sizeBytes:s?.sizeBytes??null,readLatencyMs:null,writeLatencyMs:null,ioUtilizationPercent:null,stale:t};return r?.status==="ok"?{...o,state:"ok",reason:null,readBytesPerSec:r.readBytesPerSec,writeBytesPerSec:r.writeBytesPerSec,readLatencyMs:b(r.readLatencyMs),writeLatencyMs:b(r.writeLatencyMs),ioUtilizationPercent:b(r.ioUtilizationPercent)}:r?.status==="unavailable"?{...o,state:"unavailable",reason:r.reason,readBytesPerSec:null,writeBytesPerSec:null}:null!==a?{...o,state:"unavailable",reason:a,readBytesPerSec:null,writeBytesPerSec:null}:{...o,state:"inventory",reason:null===n?h:"No current I/O reading for this device.",readBytesPerSec:null,writeBytesPerSec:null}})}(e,B)},network:{family:null!==(d=g(e))?"ok"===d.network.status?{state:"available"}:{state:"unavailable",reason:d.network.reason}:{state:"absent",reason:h},items:function(e,t){let s=e.inventory?.network??[],n=g(e),r=n?.network.status==="ok"?n.network.interfaces:[],a=n?.network.status==="unavailable"?n.network.reason:null,l=new Map(r.map(e=>[e.id,e])),i=new Map(s.map(e=>[e.id,e])),o=[];for(let e of s)o.push(e.id);for(let e of r)i.has(e.id)||o.push(e.id);return o.map(e=>{let s=i.get(e),r=l.get(e),o={id:e,name:s?.name??e.replace(/^net:/,""),mac:s?.mac??null,addresses:s?.addresses??[],virtual:s?.virtual??!1,linkState:s?.state??"unknown",speedMbps:s?.speedMbps??null,stale:t};return r?.status==="ok"?{...o,state:"ok",reason:null,rxBytesPerSec:r.rxBytesPerSec,txBytesPerSec:r.txBytesPerSec}:r?.status==="unavailable"?{...o,state:"unavailable",reason:r.reason,rxBytesPerSec:null,txBytesPerSec:null}:null!==a?{...o,state:"unavailable",reason:a,rxBytesPerSec:null,txBytesPerSec:null}:{...o,state:"inventory",reason:null===n?h:"No current rate reading for this interface.",rxBytesPerSec:null,txBytesPerSec:null}})}(e,B)}}}function j(e){if(0===e.length||e.some(e=>null===e))return null;let t=0;for(let s of e)t+=s;return t}function B(e,t){let s,n,r,a,l,i,o=N(e,t),u=o.gpus.cards,d=0===u.length?null:(r=(n=(s=u.filter(e=>"supported"===e.telemetry)).filter(e=>"ok"===e.state)).map(e=>e.utilizationPercent).filter(e=>null!==e),a=j(s.map(e=>e.memoryUsedBytes)),l=j(s.map(e=>e.memoryTotalBytes)),i=0===n.length?"unavailable"===o.gpus.family.state||"absent"===o.gpus.family.state?o.gpus.family.reason:0===s.length?"No telemetry-supported GPU was reported.":"No current GPU reading.":null,{count:u.length,supportedCount:s.length,okCount:n.length,partial:x(u),maxUtilizationPercent:0===r.length?null:Math.max(...r),memoryUsedBytes:a,memoryTotalBytes:l,stale:o.stale,reason:i}),c=o.filesystems.items.filter(e=>"ok"===e.state&&null!==e.usedBytes&&null!==e.totalBytes&&e.totalBytes>0).map(e=>e.usedBytes/e.totalBytes*100),m=0===o.filesystems.items.length?null:{maxUsedPercent:0===c.length?null:Math.max(...c),stale:o.stale,reason:0===c.length?"available"===o.filesystems.family.state?"No current filesystem usage reading.":o.filesystems.family.reason:null},y=o.network.items.filter(e=>"ok"===e.state&&null!==e.rxBytesPerSec&&null!==e.txBytesPerSec),p=0===o.network.items.length?null:{rxBytesPerSec:y.reduce((e,t)=>e+t.rxBytesPerSec,0),txBytesPerSec:y.reduce((e,t)=>e+t.txBytesPerSec,0),stale:o.stale,reason:0===y.length?"available"===o.network.family.state?"No current interface rate reading.":o.network.family.reason:null};return{cpu:o.cpu.total,memory:o.memory,gpu:d,disk:m,network:p}}let P=["cpu","memory","swap","gpus","disks","network","processes"],S={cpu:"CPU",memory:"Memory",swap:"Swap",gpus:"GPUs",disks:"Disks",network:"Network",processes:"Processes"};function C(e,t){return e.map(e=>{var s;return{machineId:e.machineId,name:i(e),collectorId:e.collectorId,connected:e.connected,cadenceMs:e.expectedIntervalMs??null,thresholdMs:(0,n.Cj)(e.expectedIntervalMs),lastReceivedAt:e.lastReceivedAt,freshness:(0,n.vj)(e,t),delivery:e.delivery?.delivery??null,deliveryCapturedAt:e.delivery?.capturedAt??null,failures:e.delivery?.failures??[],capabilities:void 0===(s=e.inventory)?null:P.map(e=>{let t=s.capabilities[e];return{key:e,label:S[e],status:t.status,reason:t.reason??null}})}})}},6576:(e,t,s)=>{s.d(t,{iL:()=>d,jB:()=>m,vw:()=>y});var n=s(5155),r=s(7586),a=s(5887);let l=2*Math.PI*70;function i(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}function o(e){let{reason:t,ageLabel:s,center:r}=e;return(0,n.jsxs)("p",{className:r?"max-w-[16rem] text-center text-xs text-warn":"text-xs text-warn",children:["Unavailable — ",t,s?(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" (last update ",s,")"]}):null]})}function u(e){let{reason:t,ageLabel:s}=e;return(0,n.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,n.jsx)("div",{role:"img","aria-label":`Unavailable — ${t}`,className:"flex h-40 w-40 shrink-0 items-center justify-center rounded-full border-[5px] border-dashed border-border",children:(0,n.jsx)("span",{className:"tnum text-xl font-semibold text-muted-foreground",children:"—"})}),(0,n.jsx)(o,{reason:t,ageLabel:s,center:!0})]})}function d(e){let{metricName:t,field:s,ageLabel:o,isHeld:d,thresholdMs:c}=e;if("unavailable"===s.out)return(0,n.jsx)(u,{reason:s.reason,ageLabel:o??null});if("absent"===s.out)return(0,n.jsx)(u,{reason:"No sample has arrived yet.",ageLabel:o??null});let m="stale"===s.out,y=i(s.value),p=l*(1-y/100),f=m?`${t} last known ${(0,r.l9)(y)}, stale`:`${t} ${(0,r.l9)(y)}`;return(0,n.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,n.jsxs)("svg",{role:"img","aria-label":f,viewBox:"0 0 160 160",className:"h-40 w-40 shrink-0",children:[(0,n.jsx)("circle",{cx:80,cy:80,r:70,fill:"none",stroke:"var(--border)",strokeWidth:8}),(0,n.jsx)("circle",{cx:80,cy:80,r:70,fill:"none",stroke:m?"var(--warn)":"var(--cpu)",strokeWidth:8,strokeLinecap:"round",strokeDasharray:l,strokeDashoffset:p,transform:"rotate(-90 80 80)"}),(0,n.jsx)("text",{x:"50%",y:m||d?"45%":"50%",dominantBaseline:"central",textAnchor:"middle",className:"fill-foreground text-xl font-semibold tnum",children:(0,r.l9)(y)}),m?(0,n.jsx)("text",{x:"50%",y:102,textAnchor:"middle",className:"fill-warn text-xs tnum",children:"last known"}):d?(0,n.jsx)("text",{x:"50%",y:102,textAnchor:"middle",className:"fill-muted-foreground text-xs tnum",children:"held"}):null]}),(0,n.jsx)("p",{className:"text-center text-xs text-muted-foreground",children:m?`Last known value — no update for over ${(0,r.$)(c??a.vz)}${o?` (${o})`:""}`:o??""})]})}function c(e){let{reason:t,ageLabel:s}=e;return(0,n.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,n.jsx)("div",{role:"img","aria-label":`Memory unavailable — ${t}`,className:"h-3 w-full max-w-64 rounded-full border border-dashed border-border"}),(0,n.jsx)(o,{reason:t,ageLabel:s})]})}function m(e){let{field:t,ageLabel:s,isHeld:l,thresholdMs:o}=e;if("unavailable"===t.out)return(0,n.jsx)(c,{reason:t.reason,ageLabel:s??null});if("absent"===t.out)return(0,n.jsx)(c,{reason:"No sample has arrived yet.",ageLabel:s??null});let u="stale"===t.out,d=t.totalBytes,m=t.usedBytes,p=d>0?i(m/d*100)/100:0,f=u?`Memory last known ${(0,r.z3)(m)} of ${(0,r.z3)(d)}, stale`:`Memory ${(0,r.z3)(m)} of ${(0,r.z3)(d)}`;return(0,n.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,n.jsx)("div",{role:"img","aria-label":f,className:"flex h-3 w-full max-w-64 items-stretch overflow-hidden rounded-full bg-card-strong",children:(0,n.jsx)("div",{className:"h-full rounded-full",style:{width:`${100*p}%`,backgroundColor:u?"var(--warn)":"var(--mem)",minWidth:d>0?void 0:0}})}),(0,n.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,n.jsx)("p",{className:"tnum text-sm",children:d>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"font-semibold",children:(0,r.z3)(m)}),(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" of ",(0,r.z3)(d)]}),(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" ","\xb7 ",(0,r.l9)(d>0?m/d*100:null)]})]}):(0,n.jsxs)("span",{className:"text-muted-foreground",children:[(0,r.z3)(m)," used — total size unavailable"]})}),u?(0,n.jsx)(y,{text:"last known",title:`No update for over ${(0,r.$)(o??a.vz)}`}):null,l&&!u?(0,n.jsx)(y,{text:"held",title:"Value kept while the connection is down"}):null]}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:u?`Retained from the last accepted sample${s?` (${s})`:""}.`:s??""})]})}function y(e){let{text:t,title:s}=e;return(0,n.jsx)("span",{title:s,className:"tnum shrink-0 rounded-full border border-border px-2 py-0.5 text-xs text-muted-foreground",children:t})}},6582:(e,t,s)=>{s.d(t,{E:()=>h,x:()=>x});var n=s(5155),r=s(8500),a=s.n(r),l=s(828),i=s(6914),o=s(7029),u=s(438),d=s(7422),c=s(1735),m=s(3440),y=s(9939);function p(e){return(0,n.jsxs)("button",{type:"button",onClick:e.onClick,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,n.jsx)(l.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.children]})}function f(e){return(0,n.jsx)(a(),{href:e.href,className:e.primary?"inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90":"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:e.children})}function x(){let{session:e,phase:t,retryConnection:s}=(0,y.M)();switch(e.kind){case"restoring":return(0,n.jsx)(m.Z,{title:"Checking session",className:"mx-auto my-12 max-w-md",children:(0,n.jsx)(m.p,{icon:i.A,note:"Checking your session…"})});case"restore-failed":return(0,n.jsxs)(m.Z,{title:"Hub unreachable",className:"mx-auto my-12 max-w-md",children:[(0,n.jsx)(m.p,{icon:o.A,note:"The hub is unreachable right now."}),(0,n.jsx)("div",{className:"flex justify-center",children:(0,n.jsx)(p,{onClick:s,children:"Check again"})})]});case"signed-out":if("expired"===t)return(0,n.jsxs)(m.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,n.jsx)(m.p,{icon:u.A,note:"Your session ended."}),(0,n.jsx)("div",{className:"flex justify-center",children:(0,n.jsx)(f,{href:"/login",primary:!0,children:"Sign in"})})]});return(0,n.jsxs)(m.Z,{title:"Sign in required",className:"mx-auto my-12 max-w-md",children:[(0,n.jsx)(m.p,{icon:i.A,note:"Sign in required."}),(0,n.jsx)("div",{className:"flex justify-center",children:(0,n.jsx)(f,{href:"/login",primary:!0,children:"Sign in"})})]});case"auth-unavailable":return(0,n.jsx)(m.Z,{title:"Sign-in unavailable",className:"mx-auto my-12 max-w-md",children:(0,n.jsx)(m.p,{icon:d.A,note:"Browser sign-in is not configured on this hub."})})}return"expired"===t?(0,n.jsxs)(m.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,n.jsx)(m.p,{icon:u.A,note:"Your session ended."}),(0,n.jsx)("div",{className:"flex justify-center",children:(0,n.jsx)(f,{href:"/login",primary:!0,children:"Sign in"})})]}):"no-permission"===t?(0,n.jsxs)(m.Z,{title:"No permission",className:"mx-auto my-12 max-w-md",children:[(0,n.jsx)(m.p,{icon:d.A,note:`You are signed in as ${e.user.username}, but this hub grants no machine view to this account.`}),(0,n.jsx)("div",{className:"flex justify-center",children:(0,n.jsx)(p,{onClick:s,children:"Check again"})})]}):null}function h(){let{phase:e,retryConnection:t}=(0,y.M)();return"reconnecting"!==e&&"disconnected"!==e&&"connecting"!==e?null:"connecting"===e?(0,n.jsxs)("div",{role:"status",className:"mb-5 flex items-center gap-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,n.jsx)(l.A,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),"Connecting to the live feed — waiting for the first snapshot."]}):(0,n.jsxs)("div",{role:"status",className:"mb-5 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,n.jsx)(c.A,{className:"h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,n.jsxs)("span",{children:["Connection lost — values below are ",(0,n.jsx)("strong",{className:"font-medium text-foreground",children:"last known"}),", not live measurements","reconnecting"===e?" — retrying with backoff…":" — retries stopped."]}),"disconnected"===e?(0,n.jsx)(p,{onClick:t,children:"Retry now"}):null]})}}}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[484],{438:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},1461:(e,t,r)=>{"use strict";r.d(t,{AlertsView:()=>L});var s=r(5155),n=r(2115),l=r(5798),a=r(7241),i=r(828),o=r(7422);let d=(0,r(8698).A)("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);var u=r(257),c=r(4173),m=r(3440),x=r(940),h=r(802),p=r(6582),b=r(7586),f=r(9939),g=r(7348);let y=[{value:"above",label:"At or above threshold",needsThreshold:!0},{value:"below",label:"At or below threshold",needsThreshold:!0},{value:"stale",label:"No receipt within cadence threshold",needsThreshold:!1},{value:"unavailable",label:"Reading unavailable",needsThreshold:!1}],v={"cpu.usage":{label:"CPU usage",unit:"percent",resource:"none"},"cpu.core":{label:"CPU core usage",unit:"percent",resource:"required"},"cpu.temperature":{label:"CPU temperature",unit:"celsius",resource:"none"},"cpu.power":{label:"CPU package power",unit:"watts",resource:"none"},"cpu.iowait":{label:"CPU I/O wait",unit:"percent",resource:"none"},"cpu.pressure":{label:"CPU pressure",unit:"percent",resource:"none"},"memory.used":{label:"Memory used",unit:"bytes",resource:"none"},"memory.total":{label:"Memory total",unit:"bytes",resource:"none"},"memory.usage":{label:"Memory usage",unit:"percent",resource:"none"},"memory.pressure.some":{label:"Memory pressure (some)",unit:"percent",resource:"none"},"memory.pressure.full":{label:"Memory pressure (full)",unit:"percent",resource:"none"},"swap.used":{label:"Swap used",unit:"bytes",resource:"none"},"swap.total":{label:"Swap total",unit:"bytes",resource:"none"},"gpu.utilization":{label:"GPU utilization",unit:"percent",resource:"required"},"gpu.memory.used":{label:"GPU memory used",unit:"bytes",resource:"required"},"gpu.memory.total":{label:"GPU memory total",unit:"bytes",resource:"required"},"gpu.temperature":{label:"GPU temperature",unit:"celsius",resource:"required"},"gpu.power":{label:"GPU power",unit:"watts",resource:"required"},"io.pressure.some":{label:"I/O pressure (some)",unit:"percent",resource:"none"},"io.pressure.full":{label:"I/O pressure (full)",unit:"percent",resource:"none"},"fs.used":{label:"Filesystem used",unit:"bytes",resource:"required"},"fs.total":{label:"Filesystem total",unit:"bytes",resource:"required"},"fs.usage":{label:"Filesystem usage",unit:"percent",resource:"required"},"fs.inodes.usage":{label:"Filesystem inode usage",unit:"percent",resource:"required"},"disk.read":{label:"Disk read",unit:"bytes_per_second",resource:"required"},"disk.write":{label:"Disk write",unit:"bytes_per_second",resource:"required"},"disk.read.latency":{label:"Disk read latency",unit:"milliseconds",resource:"required"},"disk.write.latency":{label:"Disk write latency",unit:"milliseconds",resource:"required"},"disk.utilization":{label:"Disk utilization",unit:"percent",resource:"required"},"net.rx":{label:"Network receive",unit:"bytes_per_second",resource:"required"},"net.tx":{label:"Network transmit",unit:"bytes_per_second",resource:"required"}};function j(e){return"required"===v[e].resource}function w(e){let t=["B","KiB","MiB","GiB","TiB"],r=Math.max(0,e),s=0;for(;r>=1024&&s<t.length-1;)r/=1024,s+=1;return 0===s?`${Math.round(r)} ${t[s]}`:`${r.toFixed(1)} ${t[s]}`}function N(e,t){if(null===t||!Number.isFinite(t))return"—";switch(v[e].unit){case"percent":return`${Math.round(100*t)/100}%`;case"bytes":return w(t);case"bytes_per_second":return`${w(t)}/s`;case"celsius":return`${Math.round(t)} \xb0C`;case"watts":return`${Math.round(t)} W`;case"milliseconds":return`${Math.round(10*t)/10} ms`}}function k(e){return y.find(t=>t.value===e)?.label??e}function C(e,t){return`${v[e].label}${t?` (${t})`:""}`}let S=[{id:"sustained-high-cpu",label:"Sustained high CPU",ruleName:"Sustained high CPU",metric:"cpu.usage",condition:"above",threshold:90,durationMs:3e5,resourceKind:"none",description:"Suggests CPU at or above 90% for 5 minutes."},{id:"memory-nearly-full",label:"Memory nearly full",ruleName:"Memory nearly full",metric:"memory.usage",condition:"above",threshold:90,durationMs:3e5,resourceKind:"none",description:"Suggests memory usage at or above 90% for 5 minutes."},{id:"disk-nearly-full",label:"Disk nearly full",ruleName:"Disk nearly full",metric:"fs.usage",condition:"above",threshold:90,durationMs:3e5,resourceKind:"filesystem",description:"Suggests filesystem usage at or above 90% for 5 minutes."},{id:"inode-capacity-low",label:"Inode capacity low",ruleName:"Inode capacity low",metric:"fs.inodes.usage",condition:"above",threshold:90,durationMs:3e5,resourceKind:"filesystem",description:"Suggests inode usage at or above 90% for 5 minutes."},{id:"gpu-hot",label:"GPU hot",ruleName:"GPU hot",metric:"gpu.temperature",condition:"above",threshold:85,durationMs:6e4,resourceKind:"gpu",description:"Suggests GPU temperature at or above 85 \xb0C for 1 minute."},{id:"cpu-hot",label:"CPU hot",ruleName:"CPU hot",metric:"cpu.temperature",condition:"above",threshold:90,durationMs:6e4,resourceKind:"none",description:"Suggests CPU temperature at or above 90 \xb0C for 1 minute."},{id:"collector-offline",label:"Collector offline",ruleName:"Collector offline",metric:"cpu.usage",condition:"stale",threshold:null,durationMs:0,resourceKind:"none",description:"Uses the existing stale condition and the collector's advertised cadence."},{id:"memory-pressure",label:"Memory pressure",ruleName:"Memory pressure",metric:"memory.pressure.some",condition:"above",threshold:10,durationMs:6e4,resourceKind:"none",description:"Suggests memory pressure at or above 10% for 1 minute."},{id:"io-pressure",label:"I/O pressure",ruleName:"I/O pressure",metric:"io.pressure.some",condition:"above",threshold:10,durationMs:6e4,resourceKind:"none",description:"Suggests I/O pressure at or above 10% for 1 minute."},{id:"cpu-pressure",label:"CPU pressure",ruleName:"CPU pressure",metric:"cpu.pressure",condition:"above",threshold:10,durationMs:6e4,resourceKind:"none",description:"Suggests CPU pressure at or above 10% for 1 minute."},{id:"high-io-wait",label:"High I/O wait",ruleName:"High I/O wait",metric:"cpu.iowait",condition:"above",threshold:20,durationMs:3e5,resourceKind:"none",description:"Suggests CPU I/O wait at or above 20% for 5 minutes."},{id:"disk-busy",label:"Disk busy",ruleName:"Disk busy",metric:"disk.utilization",condition:"above",threshold:90,durationMs:3e5,resourceKind:"disk",description:"Suggests disk utilization at or above 90% for 5 minutes."},{id:"slow-disk-reads",label:"Slow disk reads",ruleName:"Slow disk reads",metric:"disk.read.latency",condition:"above",threshold:100,durationMs:3e5,resourceKind:"disk",description:"Suggests read latency at or above 100 ms for 5 minutes."}],M={cpu:"CPU",memory:"Memory",swap:"Swap",gpus:"GPU",disks:"Disk",network:"Network"};function P(e){return{kind:"unavailable",reason:e}}function T(){return{kind:"waiting",reason:"Waiting for the first metrics sample."}}function U(e,t){if(null===e||"object"!=typeof e)return null;let r=e[t];return"number"==typeof r&&Number.isFinite(r)?r:null}function $(e,t){return"ok"===e.disks.status?e.disks.filesystems.find(e=>e.id===t):void 0}function I(e,t){return"ok"===e.disks.status?e.disks.devices.find(e=>e.id===t):void 0}function A(e,t,r){return null===U(e,t)?P(`${r} is not reported by this collector.`):{kind:"ready"}}function E(e,t,r,s,n){let l="ready"===r.kind&&void 0!==t?{name:e.ruleName,machineId:t.machineId,metric:e.metric,resourceId:n,condition:e.condition,threshold:e.threshold,durationMs:e.durationMs,enabled:!0}:null;return{preset:e,status:r,resourceId:n,resources:s,input:l}}function F(e,t){if(!t||!j(e))return[];let r=t.inventory;return void 0===r?[]:"cpu.core"===e?Array.from({length:Math.min(r.cpu.logicalCores,256)},(e,t)=>({value:`core:${t}`,label:`Core ${t}`})):e.startsWith("gpu.")?r.gpus.filter(e=>"supported"===e.telemetry).map(e=>({value:e.id,label:e.name})):e.startsWith("fs.")?r.filesystems.map(e=>({value:e.id,label:`${e.mountPoint} (${e.fsType})`})):e.startsWith("disk.")?r.disks.map(e=>({value:e.id,label:e.name})):e.startsWith("net.")?r.network.map(e=>({value:e.id,label:e.name})):[]}function D({machines:e,rule:t,busy:r,onSave:l,onCancel:a}){let i=e[0]?.machineId??"",[o,d]=(0,n.useState)(""),[u,c]=(0,n.useState)(i),[m,x]=(0,n.useState)("cpu.usage"),[h,p]=(0,n.useState)(""),[b,f]=(0,n.useState)("above"),[g,w]=(0,n.useState)("80"),[N,k]=(0,n.useState)("0"),[C,O]=(0,n.useState)(!0),[R,W]=(0,n.useState)(""),[q,_]=(0,n.useState)(""),[K,L]=(0,n.useState)(null),[G,Z]=(0,n.useState)(!1);(0,n.useEffect)(()=>{if(null===t){d(""),c(e[0]?.machineId??""),x("cpu.usage"),p(""),f("above"),w("80"),k("0"),O(!0),W(""),_(""),L(null);return}d(t.name),c(t.machineId),x(t.metric),p(t.resourceId),f(t.condition),w(null===t.threshold?"":String(t.threshold)),k(String(t.durationMs/1e3)),O(t.enabled),W(function(e){if(null===e)return"";let t=new Date(e);if(!Number.isFinite(t.getTime()))return"";let r=e=>String(e).padStart(2,"0");return`${t.getFullYear()}-${r(t.getMonth()+1)}-${r(t.getDate())}T${r(t.getHours())}:${r(t.getMinutes())}`}(t.maintenanceUntil)),_(""),L(null)},[t]),(0,n.useEffect)(()=>{null===t&&""===u&&void 0!==e[0]&&c(e[0].machineId)},[e,t,u]);let z=e.find(e=>e.machineId===u),H=void 0!==z&&void 0===z.metrics,B=null===t?S.map(e=>(function(e,t){let{resources:r,resourceId:s}=function(e,t){if("none"===e||void 0===t)return{resources:[],resourceId:""};if("filesystem"===e){let e=t.filesystems.map(e=>({value:e.id,label:`${e.mountPoint} (${e.fsType})`})),r=t.filesystems.find(e=>"/"===e.mountPoint)??t.filesystems[0];return{resources:e,resourceId:r?.id??""}}if("gpu"===e){let e=t.gpus.filter(e=>"supported"===e.telemetry);return{resources:e.map(e=>({value:e.id,label:e.name})),resourceId:e[0]?.id??""}}return{resources:t.disks.map(e=>({value:e.id,label:e.name})),resourceId:t.disks[0]?.id??""}}(e.resourceKind,t?.inventory);return void 0===t?E(e,t,P("Choose a machine."),r,s):"none"!==e.resourceKind&&""===s?E(e,t,P(function(e){switch(e){case"filesystem":return"No filesystems are reported by this machine.";case"gpu":return"No telemetry-capable GPU is reported by this machine.";case"disk":return"No disks are reported by this machine.";case"none":return"No resource is available."}}(e.resourceKind)),r,s):E(e,t,function(e,t,r){var s;if("stale"===e.condition)return{kind:"ready"};let n=function(e,t){let r=e.inventory?.capabilities[t];if(r?.status==="unsupported"||r?.status==="withheld")return P(`${M[t]} metrics are not shared with this hub.`);let s=e.metrics?.payload;return void 0===s?T():"unavailable"===function(e,t){switch(t){case"cpu":return e.cpu;case"memory":return e.memory;case"swap":return e.swap;case"gpus":return e.gpus;case"disks":return e.disks;case"network":return e.network}}(s,t).status?P(`${M[t]} readings are unavailable on this machine.`):null}(t,(s=e.metric).startsWith("cpu.")?"cpu":s.startsWith("memory.")?"memory":s.startsWith("swap.")?"swap":s.startsWith("gpu.")?"gpus":s.startsWith("io.")||s.startsWith("fs.")||s.startsWith("disk.")?"disks":"network");if(null!==n)return n;let l=t.metrics?.payload;if(void 0===l)return T();switch(e.metric){case"cpu.usage":default:return{kind:"ready"};case"cpu.temperature":return A(l.cpu,"temperatureC","CPU temperature");case"cpu.power":return A(l.cpu,"powerWatts","CPU package power");case"cpu.iowait":return A(l.cpu,"iowaitPercent","CPU I/O wait");case"cpu.pressure":return A(l.cpu,"pressureSomePercent","CPU pressure");case"memory.usage":{let e=l.memory;if("ok"!==e.status||!(e.totalBytes>0))return P("Memory total is not reported by this machine.");return{kind:"ready"}}case"memory.pressure.some":return A(l.memory,"pressureSomePercent","Memory pressure");case"memory.pressure.full":return A(l.memory,"pressureFullPercent","Memory full pressure");case"io.pressure.some":return A(l.disks,"pressureSomePercent","I/O pressure");case"io.pressure.full":return A(l.disks,"pressureFullPercent","I/O full pressure");case"fs.usage":{let e=$(l,r);if(void 0===e)return P("The latest sample does not include this filesystem.");if("ok"!==e.status||!(e.totalBytes>0))return P("Filesystem size is not reported for this filesystem.");return{kind:"ready"}}case"fs.inodes.usage":{let e=$(l,r);if(void 0===e)return P("The latest sample does not include this filesystem.");if("ok"!==e.status)return P("This filesystem is unavailable in the latest sample.");let t=U(e,"inodesUsed"),s=U(e,"inodesTotal");if(null===t||null===s||s<=0)return P("Inode usage is not reported for this filesystem.");return{kind:"ready"}}case"gpu.temperature":{let e="ok"===l.gpus.status?l.gpus.devices.find(e=>e.id===r):void 0;if(void 0===e)return P("The latest sample does not include this GPU.");if("ok"!==e.status)return P("This GPU is unavailable in the latest sample.");return A(e,"temperatureC","GPU temperature")}case"disk.utilization":{let e=I(l,r);if(void 0===e)return P("The latest sample does not include this disk.");if("ok"!==e.status)return P("This disk is unavailable in the latest sample.");return A(e,"ioUtilizationPercent","Disk utilization")}case"disk.read.latency":{let e=I(l,r);if(void 0===e)return P("The latest sample does not include this disk.");if("ok"!==e.status)return P("This disk is unavailable in the latest sample.");return A(e,"readLatencyMs","Disk read latency")}case"disk.write.latency":{let e=I(l,r);if(void 0===e)return P("The latest sample does not include this disk.");if("ok"!==e.status)return P("This disk is unavailable in the latest sample.");return A(e,"writeLatencyMs","Disk write latency")}}}(e,t,s),r,s)})(e,z)):[],J=""===q?null:B.find(e=>e.preset.id===q)??null;(0,n.useEffect)(()=>{H&&null===t&&"stale"!==b&&f("stale")},[H,t,b]);let V=F(m,z),Y="above"===b||"below"===b,Q=j(m),X=r||G||0===e.length,ee=async e=>{if(e.preventDefault(),L(null),""===o.trim())return void L("Give the rule a name.");if(""===u)return void L("Choose a machine.");if(H&&"stale"!==b)return void L("No metrics have been received from this machine yet, so value and unavailable rules cannot be evaluated against it. Use a stale rule, or wait until the machine reports metrics.");if(Q&&""===h.trim())return void L("Choose or enter the metric's resource.");let r=Number(N);if(""===N.trim()||!Number.isInteger(r)||r<0||1e3*r>864e5)return void L("Duration must be a whole number of seconds from 0 to 86400.");let s=null;if(Y&&(""===g.trim()||!Number.isFinite(s=Number(g))))return void L("Enter a numeric threshold.");let n=function(e){if(""===e.trim())return null;let t=new Date(e);return Number.isFinite(t.getTime())?t.toISOString():null}(R);Z(!0);try{await l({...null===t?{}:{id:t.id},name:o.trim(),machineId:u,metric:m,resourceId:Q?h.trim():"",condition:b,threshold:Y?s:null,durationMs:1e3*r,enabled:C,maintenanceUntil:n})}catch(e){L(e instanceof Error?e.message:"Could not save the rule.")}finally{Z(!1)}};return(0,s.jsxs)("form",{onSubmit:e=>void ee(e),"aria-busy":G,className:"flex flex-col gap-4",children:[0===e.length?(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"No machines available."}):null,null===t?(0,s.jsxs)("div",{className:"border-b border-border pb-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("label",{htmlFor:"alert-rule-preset",className:"text-xs text-muted-foreground",children:"Warning preset"}),(0,s.jsxs)("select",{id:"alert-rule-preset",value:q,onChange:e=>_(e.target.value),disabled:X,"aria-describedby":"alert-rule-preset-note",className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground",children:[(0,s.jsx)("option",{value:"",children:"Choose a preset…"}),B.map(e=>(0,s.jsxs)("option",{value:e.preset.id,children:[e.preset.label,"ready"===e.status.kind?"":"waiting"===e.status.kind?" — waiting for metrics":" — unavailable"]},e.preset.id))]})]}),(0,s.jsx)("button",{type:"button",onClick:()=>{if(null===J||null===J.input)return;let e=J.input;d(e.name),c(e.machineId),x(e.metric),p(e.resourceId??""),f(e.condition),w(null===e.threshold||void 0===e.threshold?"":String(e.threshold)),k(String(e.durationMs/1e3)),L(null)},disabled:X||J?.status.kind!=="ready",className:"rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Use preset"})]}),(0,s.jsx)("p",{id:"alert-rule-preset-note","aria-live":"polite",className:"mt-1.5 text-xs text-muted-foreground",children:null!==J&&"ready"!==J.status.kind?J.status.reason:""})]}):null,(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsxs)("div",{className:"sm:col-span-2",children:[(0,s.jsx)("label",{htmlFor:"alert-rule-name",className:"text-xs text-muted-foreground",children:"Rule name"}),(0,s.jsx)("input",{id:"alert-rule-name",value:o,onChange:e=>d(e.target.value),maxLength:128,disabled:X,placeholder:"CPU sustained high",className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground placeholder:text-muted-foreground"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-rule-machine",className:"text-xs text-muted-foreground",children:"Machine"}),(0,s.jsxs)("select",{id:"alert-rule-machine",value:u,onChange:r=>{var s;let n,l;return s=r.target.value,_(""),c(s),void 0!==(n=e.find(e=>e.machineId===s))&&void 0===n.metrics&&null===t&&f("stale"),l=F(m,n),void(j(m)&&p(l[0]?.value??""))},disabled:X,className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground",children:[""===u||e.some(e=>e.machineId===u)?null:(0,s.jsxs)("option",{value:u,children:[u," (current)"]}),e.map(e=>(0,s.jsx)("option",{value:e.machineId,children:e.displayName?.trim()||e.hostname||e.machineId},e.machineId))]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-rule-metric",className:"text-xs text-muted-foreground",children:"Metric"}),(0,s.jsx)("select",{id:"alert-rule-metric",value:m,onChange:e=>{var t;let r;return x(t=e.target.value),r=F(t,z),void p(j(t)?r[0]?.value??"":"")},disabled:X,className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground",children:Object.keys(v).map(e=>({value:e,label:v[e].label})).map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))})]}),Q?(0,s.jsxs)("div",{className:"sm:col-span-2",children:[(0,s.jsx)("label",{htmlFor:"alert-rule-resource",className:"text-xs text-muted-foreground",children:"Resource"}),V.length>0?(0,s.jsxs)("select",{id:"alert-rule-resource",value:h,onChange:e=>p(e.target.value),disabled:X,className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground",children:[""===h||V.some(e=>e.value===h)?null:(0,s.jsxs)("option",{value:h,children:[h," (current)"]}),V.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))]}):(0,s.jsx)("input",{id:"alert-rule-resource",value:h,onChange:e=>p(e.target.value),maxLength:256,disabled:X,placeholder:"cpu.core"===m?"core:0":m.startsWith("gpu.")?"gpu:GPU-…":m.startsWith("fs.")?"fs:/":m.startsWith("disk.")?"disk:sda":m.startsWith("net.")?"net:eno1":"Resource id",className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground placeholder:text-muted-foreground"})]}):null,(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-rule-condition",className:"text-xs text-muted-foreground",children:"Condition"}),(0,s.jsx)("select",{id:"alert-rule-condition",value:b,onChange:e=>f(e.target.value),disabled:X,className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground",children:y.map(e=>(0,s.jsx)("option",{value:e.value,disabled:H&&"stale"!==e.value,children:e.label},e.value))}),H?(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Waiting for metrics."}):null]}),Y?(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{htmlFor:"alert-rule-threshold",className:"text-xs text-muted-foreground",children:["Threshold (",function(e){switch(v[e].unit){case"percent":return"percent (0–100)";case"bytes":return"bytes";case"bytes_per_second":return"bytes per second";case"celsius":return"degrees Celsius";case"watts":return"watts";case"milliseconds":return"milliseconds"}}(m),")"]}),(0,s.jsx)("input",{id:"alert-rule-threshold",type:"number",step:"any",value:g,onChange:e=>w(e.target.value),disabled:X,className:"tnum mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground"})]}):null,(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-rule-duration",className:"text-xs text-muted-foreground",children:"Must hold for (seconds)"}),(0,s.jsx)("input",{id:"alert-rule-duration",type:"number",min:0,max:86400,step:1,value:N,onChange:e=>k(e.target.value),disabled:X,className:"tnum mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-rule-maintenance",className:"text-xs text-muted-foreground",children:"Maintenance until (optional)"}),(0,s.jsx)("input",{id:"alert-rule-maintenance",type:"datetime-local",value:R,onChange:e=>W(e.target.value),disabled:X,className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground"})]}),(0,s.jsxs)("label",{className:"flex items-center gap-2 text-xs text-foreground sm:col-span-2",children:[(0,s.jsx)("input",{type:"checkbox",checked:C,onChange:e=>O(e.target.checked),disabled:X,className:"h-4 w-4 rounded border-border accent-[var(--accent)]"}),"Rule enabled"]})]}),K?(0,s.jsx)("p",{role:"alert",className:"rounded-md bg-crit-soft px-3 py-2 text-xs text-foreground",children:K}):null,(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("button",{type:"submit",disabled:X,className:"rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90 disabled:opacity-50",children:G?"Saving…":null===t?"Create rule":"Save rule"}),null!==t?(0,s.jsx)("button",{type:"button",onClick:a,disabled:G,className:"rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Cancel"}):null]})]})}function O({status:e,busy:t,onConfigure:r,onClear:l,onTest:a}){let[i,o]=(0,n.useState)(""),[d,u]=(0,n.useState)(""),[c,m]=(0,n.useState)(""),[x,h]=(0,n.useState)(!0),[p,b]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[y,v]=(0,n.useState)(!1),[j,w]=(0,n.useState)(null),[N,k]=(0,n.useState)(null),C=(0,n.useRef)(null),S=(0,n.useRef)(null),M=(0,n.useRef)(null);(0,n.useEffect)(()=>{null!==j&&C.current?.focus()},[j]),(0,n.useEffect)(()=>{e.configured||(w(null),k(null))},[e.configured]);let P=async e=>{v(!0),b(null),w(null),k(null);try{await r(e),o(""),u(""),m(""),h(!0)}catch(e){b(e instanceof Error?e.message:"Could not configure the webhook.")}finally{v(!1)}},T=async t=>{t.preventDefault();let r=(()=>{let e;b(null),g(null);let t=i.trim();if(""===t)return b("Enter the webhook URL."),null;if(""!==d.trim())try{let t=JSON.parse(d);if(null===t||"object"!=typeof t||Array.isArray(t))throw Error("not an object");for(let[r,s]of(e={},Object.entries(t))){if("string"!=typeof s)throw Error("header values must be strings");e[r]=s}}catch{return b("Headers must be a JSON object with string values."),null}return{url:t,...void 0===e?{}:{headers:e},secret:""===c.trim()?null:c,enabled:x}})();if(null!==r){if(e.configured){k(r),w("replace");return}await P(r)}},U=async()=>{v(!0),b(null),g(null),w(null);try{await l(),o(""),u(""),m("")}catch(e){b(e instanceof Error?e.message:"Could not clear the webhook.")}finally{v(!1)}},$=async()=>{"clear"===j?await U():"replace"===j&&null!==N&&await P(N)},I=async()=>{b(null),v(!0);try{g(await a())}catch(e){b(e instanceof Error?e.message:"Could not test the webhook.")}finally{v(!1)}},A=t||y||null!==j,E=e.configured&&"loopback-http"===e.transport;return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-xs",children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Configured"}),(0,s.jsx)("dd",{className:"text-foreground",children:e.configured?e.enabled?"Enabled":"Disabled":"Not configured"}),(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Transport"}),(0,s.jsx)("dd",{className:"text-foreground",children:"https"===e.transport?"HTTPS":"loopback-http"===e.transport?"Loopback HTTP test sink":"—"}),(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Last test"}),(0,s.jsx)("dd",{className:"text-foreground",children:null===e.lastTestAt?"Never":`${!0===e.lastTestOk?"Passed":"Failed"} \xb7 ${new Date(e.lastTestAt).toLocaleString()}`}),e.lastError?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Last error"}),(0,s.jsx)("dd",{className:"text-warn",children:e.lastError})]}):null]}),(0,s.jsxs)("form",{onSubmit:e=>void T(e),className:"flex flex-col gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-webhook-url",className:"text-xs text-muted-foreground",children:e.configured?"Replace webhook URL":"Webhook URL"}),(0,s.jsx)("input",{id:"alert-webhook-url",type:"url",required:!0,value:i,onChange:e=>o(e.target.value),maxLength:2048,disabled:A,placeholder:"https://receiver.example/alerts",className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground placeholder:text-muted-foreground"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-webhook-headers",className:"text-xs text-muted-foreground",children:"Headers (JSON, optional)"}),(0,s.jsx)("textarea",{id:"alert-webhook-headers",value:d,onChange:e=>u(e.target.value),rows:2,disabled:A,placeholder:'{"x-channel": "monitoring"}',className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 font-mono text-xs text-foreground placeholder:text-muted-foreground"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-webhook-secret",className:"text-xs text-muted-foreground",children:"Signing secret (optional)"}),(0,s.jsx)("input",{id:"alert-webhook-secret",type:"password",value:c,onChange:e=>m(e.target.value),maxLength:256,disabled:A,placeholder:"Blank clears the signature",autoComplete:"new-password",className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground"})]}),(0,s.jsxs)("label",{className:"flex items-center gap-2 text-xs text-foreground",children:[(0,s.jsx)("input",{type:"checkbox",checked:x,onChange:e=>h(e.target.checked),disabled:A,className:"h-4 w-4 rounded border-border accent-[var(--accent)]"}),"Webhook enabled"]}),p?(0,s.jsx)("p",{role:"alert",className:"rounded-md bg-crit-soft px-3 py-2 text-xs text-foreground",children:p}):null,(0,s.jsx)("p",{role:"status",className:f?`rounded-md px-3 py-2 text-xs ${f.ok?"bg-ok-soft text-foreground":"bg-warn-soft text-foreground"}`:"sr-only",children:f?`Test ${f.ok?"delivered":"failed"}${null!==f.status?` (HTTP ${f.status})`:""}${f.error?` — ${f.error}`:""}.`:""}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("button",{ref:S,type:"submit",disabled:A||""===i.trim(),className:"rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90 disabled:opacity-50",children:e.configured?"Replace webhook":"Configure webhook"}),(0,s.jsx)("button",{ref:M,type:"button",onClick:()=>{b(null),w("clear")},disabled:A||!e.configured,className:"rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Clear webhook"}),(0,s.jsx)("button",{type:"button",onClick:()=>void I(),disabled:A||!E,title:E?"Send one explicit test message to the configured loopback sink":"Test delivery is available only for a configured loopback HTTP sink",className:"rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Send test"})]}),null!==j?(0,s.jsxs)("div",{role:"group","aria-label":"Confirm webhook change",className:"rounded-md bg-warn-soft px-3 py-3",children:[(0,s.jsx)("p",{className:"text-xs text-foreground",children:"clear"===j?"Clear the configured webhook? Future incidents will not be delivered until a webhook is configured again.":"Replace the configured webhook? The stored URL, headers and secret will be overwritten."}),(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,s.jsx)("button",{ref:C,type:"button",onClick:()=>void $(),disabled:y,className:`rounded-md px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors disabled:opacity-50 ${"clear"===j?"bg-crit":"bg-accent hover:bg-accent/90"}`,children:"clear"===j?"Confirm clear":"Confirm replace"}),(0,s.jsx)("button",{type:"button",onClick:()=>{let e="clear"===j?M.current:S.current;w(null),k(null),e?.focus()},disabled:y,className:"rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Cancel"})]})]}):null]})]})}function R(e){if(null===e)return"—";let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString():e}function W({tone:e,children:t}){return(0,s.jsx)("span",{className:`tnum inline-flex items-center rounded-full px-2 py-0.5 text-xs ${"ok"===e?"bg-ok-soft text-ok":"warn"===e?"bg-warn-soft text-warn":"crit"===e?"bg-crit-soft text-crit":"border border-border text-muted-foreground"}`,children:t})}function q({incident:e,now:t}){let r="open"===e.status;return(0,s.jsx)("li",{className:"border-b border-border py-3 last:border-b-0",children:(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-x-4 gap-y-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(W,{tone:r?"crit":"ok",children:r?"Open":"Recovered"}),(0,s.jsx)("span",{className:"truncate text-sm font-medium",children:e.ruleName}),(0,s.jsx)("span",{className:"tnum text-xs text-muted-foreground",children:e.machineId})]}),(0,s.jsx)("p",{className:"mt-1 max-w-2xl text-sm",children:e.message}),(0,s.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:[C(e.metric,e.resourceId)," \xb7 started"," ",(0,b.nV)((0,b.A4)(e.startedAt,t)),null!==e.resolvedAt?` \xb7 recovered ${(0,b.nV)((0,b.A4)(e.resolvedAt,t))}`:""]})]}),(0,s.jsxs)("dl",{className:"tnum grid shrink-0 grid-cols-2 gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[(0,s.jsx)("dt",{children:"Started value"}),(0,s.jsx)("dd",{className:"text-right text-foreground",children:N(e.metric,e.startedValue)}),(0,s.jsx)("dt",{children:"Recovered value"}),(0,s.jsx)("dd",{className:"text-right text-foreground",children:N(e.metric,e.resolvedValue)})]})]})})}function _({rule:e,admin:t,busy:r,confirmingDelete:n,onEdit:i,onRequestDelete:o,onCancelDelete:d,onConfirmDelete:u}){var c,m;let x=(c=e.condition,y.find(e=>e.value===c)?.needsThreshold)?`${k(e.condition)} ${N(e.metric,e.threshold)}`:k(e.condition),h=e.enabled?"firing"===e.state?"crit":"pending"===e.state?"warn":"ok":"muted",p=e.enabled?"firing"===e.state?"Firing":"pending"===e.state?"Pending":"OK":"Disabled";return(0,s.jsxs)("li",{className:"border-b border-border py-3 last:border-b-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-x-4 gap-y-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"truncate text-sm font-medium",children:e.name}),(0,s.jsx)(W,{tone:h,children:p})]}),(0,s.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:[e.machineId," \xb7 ",C(e.metric,e.resourceId)]}),(0,s.jsxs)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[x," \xb7 holds ",!Number.isFinite(m=e.durationMs)||m<=0?"Immediately":m<6e4?`${Math.round(m/1e3)} s`:m<36e5?`${Math.round(m/6e4)} min`:`${Math.round(m/36e5)} h`,e.pendingSince?` \xb7 pending since ${R(e.pendingSince)}`:""]}),e.maintenanceUntil?(0,s.jsxs)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["Maintenance until ",R(e.maintenanceUntil)]}):null]}),t?(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[(0,s.jsxs)("button",{type:"button",onClick:i,disabled:r||n,className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:[(0,s.jsx)(l.A,{className:"h-3 w-3","aria-hidden":!0}),"Edit"]}),(0,s.jsxs)("button",{type:"button",onClick:o,disabled:r||n,className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs text-crit transition-colors hover:bg-crit-soft disabled:opacity-50",children:[(0,s.jsx)(a.A,{className:"h-3 w-3","aria-hidden":!0}),"Delete"]})]}):null]}),n?(0,s.jsxs)("div",{role:"group","aria-label":"Confirm rule deletion",className:"mt-3 rounded-md bg-warn-soft px-3 py-2.5",children:[(0,s.jsxs)("p",{className:"text-xs text-foreground",children:["Delete “",e.name,"”? Its incident history stays, but the rule stops evaluating."]}),(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap gap-2",children:[(0,s.jsx)("button",{type:"button",autoFocus:!0,onClick:()=>void u(),disabled:r,className:"rounded-md bg-crit px-2.5 py-1 text-xs font-medium text-accent-foreground transition-colors disabled:opacity-50",children:"Confirm delete"}),(0,s.jsx)("button",{type:"button",onClick:d,disabled:r,className:"rounded-md border border-border px-2.5 py-1 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Cancel"})]})]}):null]})}function K({notification:e}){let t="failed"===e.status?"crit":"delivered"===e.status?"ok":"warn";return(0,s.jsxs)("li",{className:"border-b border-border py-2 last:border-b-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1 text-xs",children:[(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)(W,{tone:t,children:e.status}),(0,s.jsx)("span",{className:"text-foreground",children:e.event}),(0,s.jsxs)("span",{className:"tnum text-muted-foreground",children:["attempt ",e.attempts,"/",e.maxAttempts]})]}),(0,s.jsx)("span",{className:"tnum text-muted-foreground",children:R(e.createdAt)})]}),e.lastError?(0,s.jsx)("p",{className:"mt-1 text-xs text-warn",children:e.lastError}):null,(0,s.jsx)("p",{className:"tnum mt-0.5 truncate font-mono text-xs text-muted-foreground",children:e.id})]})}function L(){let{session:e,machines:t}=(0,f.M)(),r=(0,p.x)(),l=(0,g.c)(),a="signed-in"===e.kind?e.user.csrfToken:null,b="signed-in"===e.kind&&!0===e.user.admin,[y,v]=(0,n.useState)(null),[j,w]=(0,n.useState)(!0),[N,k]=(0,n.useState)(null),[C,S]=(0,n.useState)(null),[M,P]=(0,n.useState)(null),[T,U]=(0,n.useState)(null),[$,I]=(0,n.useState)(!1),A=b&&(null===y||y.canAdmin),E=(0,n.useCallback)(async()=>{if(null!==a){w(!0),k(null);try{let e=await fetch("/api/alerts",{headers:{Accept:"application/json"},cache:"no-store",credentials:"same-origin"}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error??`Could not load alerts (${e.status}).`);v(t)}catch(e){k(e instanceof Error?e.message:"Could not load alerts.")}finally{w(!1)}}},[a]);(0,n.useEffect)(()=>{null!==a&&E()},[a,E]);let F=(0,n.useCallback)(async(e,t)=>{if(null===a)throw Error("Sign in required.");I(!0),k(null);try{let r=await fetch(e,{...t,cache:"no-store",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json","x-csrf-token":a,...t.headers??{}}}),s=await r.json().catch(()=>({}));if(!r.ok)throw Error(s.error??`Request failed (${r.status}).`);return s}finally{I(!1)}},[a]),R=async e=>{await F("/api/alerts/rules",{method:"POST",body:JSON.stringify(e)}),P(null),S(e.id?"Rule saved.":"Rule created."),await E()},W=async e=>{try{await F(`/api/alerts/rules?id=${encodeURIComponent(e.id)}`,{method:"DELETE"}),M?.id===e.id&&P(null),U(null),S("Rule deleted."),await E()}catch(e){k(e instanceof Error?e.message:"Could not delete the rule.")}},L=async e=>{await F("/api/alerts/webhook",{method:"POST",body:JSON.stringify({action:"configure",...e})}),S("Webhook configured."),await E()},G=async()=>{await F("/api/alerts/webhook",{method:"POST",body:JSON.stringify({action:"clear"})}),S("Webhook cleared."),await E()},Z=async()=>{let e=await F("/api/alerts/webhook",{method:"POST",body:JSON.stringify({action:"test"})});return v(t=>null===t?t:{...t,webhook:e.status}),S(e.result.ok?"Webhook test delivered.":"Webhook test failed."),e.result},z=y?.incidents??[],H=z.filter(e=>"open"===e.status).length,B=y?.rules??[],J=y?.notifications,V=j&&null===y;return(0,s.jsx)(c.G,{title:"Alerts",headerRight:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(x.$E,{}),(0,s.jsx)(h.B,{})]}),children:r||(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(p.E,{}),(0,s.jsx)("div",{className:"mb-4 flex flex-wrap items-center justify-end gap-3",children:(0,s.jsxs)("button",{type:"button",onClick:()=>void E(),disabled:j,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:[(0,s.jsx)(i.A,{className:`h-3.5 w-3.5 ${j?"animate-spin":""}`,"aria-hidden":!0}),"Refresh"]})}),(0,s.jsx)("p",{role:"status",className:C?"mb-4 text-xs text-muted-foreground":"sr-only",children:C??""}),N?(0,s.jsx)("p",{role:"alert",className:"mb-4 rounded-lg bg-crit-soft px-4 py-2.5 text-xs text-foreground",children:N}):null,V?(0,s.jsx)(m.Z,{title:"Alerts",className:"mt-8",children:(0,s.jsx)(m.p,{icon:i.A,note:"Loading alert rules and incidents…"})}):null===y?(0,s.jsx)(m.Z,{title:"Alerts unavailable",className:"mt-8",children:(0,s.jsx)(m.p,{icon:o.A,note:"Alert state could not be loaded."})}):(0,s.jsxs)("div",{className:A?"grid gap-5 xl:grid-cols-[minmax(0,1fr)_24rem]":"flex flex-col gap-5",children:[(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-5",children:[(0,s.jsx)(m.Z,{title:"Incidents and recoveries",action:(0,s.jsxs)("span",{children:[H," open \xb7 ",z.length," recent"]}),children:0===z.length?(0,s.jsx)(m.p,{icon:d,note:"No incidents."}):(0,s.jsx)("ul",{className:"flex flex-col",children:z.map(e=>(0,s.jsx)(q,{incident:e,now:l},e.id))})}),(0,s.jsx)(m.Z,{title:"Rules",action:(0,s.jsxs)("span",{children:[B.length," configured"]}),children:0===B.length?(0,s.jsx)(m.p,{icon:u.A,note:"No rules."}):(0,s.jsx)("ul",{className:"flex flex-col",children:B.map(e=>(0,s.jsx)(_,{rule:e,admin:A,busy:$,confirmingDelete:T===e.id,onEdit:()=>{U(null),P(e)},onRequestDelete:()=>U(e.id),onCancelDelete:()=>U(null),onConfirmDelete:()=>W(e)},e.id))})}),(0,s.jsx)(m.Z,{title:"Notifications",action:(0,s.jsxs)("span",{children:[J?.pending??0," pending \xb7 ",J?.failed??0," failed"]}),children:void 0===J||0===J.recent.length?(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"No notifications."}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("dl",{className:"grid grid-cols-3 gap-3 border-b border-border pb-3 text-xs",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Pending"}),(0,s.jsx)("dd",{className:"tnum text-foreground",children:J.pending})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Delivered"}),(0,s.jsx)("dd",{className:"tnum text-foreground",children:J.delivered})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Failed"}),(0,s.jsx)("dd",{className:"tnum text-foreground",children:J.failed})]})]}),(0,s.jsx)("ul",{className:"mt-1 flex flex-col",children:J.recent.slice(0,10).map(e=>(0,s.jsx)(K,{notification:e},e.id))})]})})]}),A?(0,s.jsxs)("aside",{className:"flex min-w-0 flex-col gap-5",children:[(0,s.jsx)(m.Z,{title:null===M?"New rule":"Edit rule",action:null===M?null:(0,s.jsx)("button",{type:"button",onClick:()=>P(null),className:"text-xs text-muted-foreground hover:text-foreground",children:"New instead"}),children:(0,s.jsx)(D,{machines:t,rule:M,busy:$,onSave:R,onCancel:()=>P(null)})}),(0,s.jsx)(m.Z,{title:"Webhook",children:(0,s.jsx)(O,{status:y.webhook,busy:$,onConfigure:L,onClear:G,onTest:Z})})]}):null]})]})})}},2865:(e,t,r)=>{Promise.resolve().then(r.bind(r,1461))},5798:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]])},6582:(e,t,r)=>{"use strict";r.d(t,{E:()=>f,x:()=>b});var s=r(5155),n=r(8500),l=r.n(n),a=r(828),i=r(6914),o=r(7029),d=r(438),u=r(7422),c=r(1735),m=r(3440),x=r(9939);function h(e){return(0,s.jsxs)("button",{type:"button",onClick:e.onClick,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,s.jsx)(a.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.children]})}function p(e){return(0,s.jsx)(l(),{href:e.href,className:e.primary?"inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90":"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:e.children})}function b(){let{session:e,phase:t,retryConnection:r}=(0,x.M)();switch(e.kind){case"restoring":return(0,s.jsx)(m.Z,{title:"Checking session",className:"mx-auto my-12 max-w-md",children:(0,s.jsx)(m.p,{icon:i.A,note:"Checking your session…"})});case"restore-failed":return(0,s.jsxs)(m.Z,{title:"Hub unreachable",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(m.p,{icon:o.A,note:"The hub is unreachable right now."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(h,{onClick:r,children:"Check again"})})]});case"signed-out":if("expired"===t)return(0,s.jsxs)(m.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(m.p,{icon:d.A,note:"Your session ended."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(p,{href:"/login",primary:!0,children:"Sign in"})})]});return(0,s.jsxs)(m.Z,{title:"Sign in required",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(m.p,{icon:i.A,note:"Sign in required."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(p,{href:"/login",primary:!0,children:"Sign in"})})]});case"auth-unavailable":return(0,s.jsx)(m.Z,{title:"Sign-in unavailable",className:"mx-auto my-12 max-w-md",children:(0,s.jsx)(m.p,{icon:u.A,note:"Browser sign-in is not configured on this hub."})})}return"expired"===t?(0,s.jsxs)(m.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(m.p,{icon:d.A,note:"Your session ended."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(p,{href:"/login",primary:!0,children:"Sign in"})})]}):"no-permission"===t?(0,s.jsxs)(m.Z,{title:"No permission",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(m.p,{icon:u.A,note:`You are signed in as ${e.user.username}, but this hub grants no machine view to this account.`}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(h,{onClick:r,children:"Check again"})})]}):null}function f(){let{phase:e,retryConnection:t}=(0,x.M)();return"reconnecting"!==e&&"disconnected"!==e&&"connecting"!==e?null:"connecting"===e?(0,s.jsxs)("div",{role:"status",className:"mb-5 flex items-center gap-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,s.jsx)(a.A,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),"Connecting to the live feed — waiting for the first snapshot."]}):(0,s.jsxs)("div",{role:"status",className:"mb-5 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,s.jsx)(c.A,{className:"h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,s.jsxs)("span",{children:["Connection lost — values below are ",(0,s.jsx)("strong",{className:"font-medium text-foreground",children:"last known"}),", not live measurements","reconnecting"===e?" — retrying with backoff…":" — retries stopped."]}),"disconnected"===e?(0,s.jsx)(h,{onClick:t,children:"Retry now"}):null]})}},7241:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},7348:(e,t,r)=>{"use strict";r.d(t,{c:()=>n});var s=r(2115);function n(e=1e3){let[t,r]=(0,s.useState)(()=>Date.now());return(0,s.useEffect)(()=>{r(Date.now());let t=setInterval(()=>r(Date.now()),e);return()=>clearInterval(t)},[e]),t}}},e=>{e.O(0,[157,939,103,441,794,358],()=>e(e.s=2865)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[484],{438:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},1461:(e,t,r)=>{"use strict";r.d(t,{AlertsView:()=>L});var s=r(5155),n=r(2115),l=r(5798),a=r(7241),i=r(828),o=r(7422);let d=(0,r(8698).A)("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);var u=r(257),c=r(4173),m=r(3440),x=r(940),h=r(802),p=r(6582),b=r(7586),f=r(9939),g=r(7348);let y=[{value:"above",label:"At or above threshold",needsThreshold:!0},{value:"below",label:"At or below threshold",needsThreshold:!0},{value:"stale",label:"No receipt within cadence threshold",needsThreshold:!1},{value:"unavailable",label:"Reading unavailable",needsThreshold:!1}],v={"cpu.usage":{label:"CPU usage",unit:"percent",resource:"none"},"cpu.core":{label:"CPU core usage",unit:"percent",resource:"required"},"cpu.temperature":{label:"CPU temperature",unit:"celsius",resource:"none"},"cpu.power":{label:"CPU package power",unit:"watts",resource:"none"},"cpu.iowait":{label:"CPU I/O wait",unit:"percent",resource:"none"},"cpu.pressure":{label:"CPU pressure",unit:"percent",resource:"none"},"memory.used":{label:"Memory used",unit:"bytes",resource:"none"},"memory.total":{label:"Memory total",unit:"bytes",resource:"none"},"memory.usage":{label:"Memory usage",unit:"percent",resource:"none"},"memory.pressure.some":{label:"Memory pressure (some)",unit:"percent",resource:"none"},"memory.pressure.full":{label:"Memory pressure (full)",unit:"percent",resource:"none"},"swap.used":{label:"Swap used",unit:"bytes",resource:"none"},"swap.total":{label:"Swap total",unit:"bytes",resource:"none"},"gpu.utilization":{label:"GPU utilization",unit:"percent",resource:"required"},"gpu.memory.used":{label:"GPU memory used",unit:"bytes",resource:"required"},"gpu.memory.total":{label:"GPU memory total",unit:"bytes",resource:"required"},"gpu.temperature":{label:"GPU temperature",unit:"celsius",resource:"required"},"gpu.power":{label:"GPU power",unit:"watts",resource:"required"},"io.pressure.some":{label:"I/O pressure (some)",unit:"percent",resource:"none"},"io.pressure.full":{label:"I/O pressure (full)",unit:"percent",resource:"none"},"fs.used":{label:"Filesystem used",unit:"bytes",resource:"required"},"fs.total":{label:"Filesystem total",unit:"bytes",resource:"required"},"fs.usage":{label:"Filesystem usage",unit:"percent",resource:"required"},"fs.inodes.usage":{label:"Filesystem inode usage",unit:"percent",resource:"required"},"disk.read":{label:"Disk read",unit:"bytes_per_second",resource:"required"},"disk.write":{label:"Disk write",unit:"bytes_per_second",resource:"required"},"disk.read.latency":{label:"Disk read latency",unit:"milliseconds",resource:"required"},"disk.write.latency":{label:"Disk write latency",unit:"milliseconds",resource:"required"},"disk.utilization":{label:"Disk utilization",unit:"percent",resource:"required"},"net.rx":{label:"Network receive",unit:"bytes_per_second",resource:"required"},"net.tx":{label:"Network transmit",unit:"bytes_per_second",resource:"required"}};function j(e){return"required"===v[e].resource}function w(e){let t=["B","KiB","MiB","GiB","TiB"],r=Math.max(0,e),s=0;for(;r>=1024&&s<t.length-1;)r/=1024,s+=1;return 0===s?`${Math.round(r)} ${t[s]}`:`${r.toFixed(1)} ${t[s]}`}function N(e,t){if(null===t||!Number.isFinite(t))return"—";switch(v[e].unit){case"percent":return`${Math.round(100*t)/100}%`;case"bytes":return w(t);case"bytes_per_second":return`${w(t)}/s`;case"celsius":return`${Math.round(t)} \xb0C`;case"watts":return`${Math.round(t)} W`;case"milliseconds":return`${Math.round(10*t)/10} ms`}}function k(e){return y.find(t=>t.value===e)?.label??e}function C(e,t){return`${v[e].label}${t?` (${t})`:""}`}let S=[{id:"sustained-high-cpu",label:"Sustained high CPU",ruleName:"Sustained high CPU",metric:"cpu.usage",condition:"above",threshold:90,durationMs:3e5,resourceKind:"none",description:"Suggests CPU at or above 90% for 5 minutes."},{id:"memory-nearly-full",label:"Memory nearly full",ruleName:"Memory nearly full",metric:"memory.usage",condition:"above",threshold:90,durationMs:3e5,resourceKind:"none",description:"Suggests memory usage at or above 90% for 5 minutes."},{id:"disk-nearly-full",label:"Disk nearly full",ruleName:"Disk nearly full",metric:"fs.usage",condition:"above",threshold:90,durationMs:3e5,resourceKind:"filesystem",description:"Suggests filesystem usage at or above 90% for 5 minutes."},{id:"inode-capacity-low",label:"Inode capacity low",ruleName:"Inode capacity low",metric:"fs.inodes.usage",condition:"above",threshold:90,durationMs:3e5,resourceKind:"filesystem",description:"Suggests inode usage at or above 90% for 5 minutes."},{id:"gpu-hot",label:"GPU hot",ruleName:"GPU hot",metric:"gpu.temperature",condition:"above",threshold:85,durationMs:6e4,resourceKind:"gpu",description:"Suggests GPU temperature at or above 85 \xb0C for 1 minute."},{id:"cpu-hot",label:"CPU hot",ruleName:"CPU hot",metric:"cpu.temperature",condition:"above",threshold:90,durationMs:6e4,resourceKind:"none",description:"Suggests CPU temperature at or above 90 \xb0C for 1 minute."},{id:"collector-offline",label:"Collector offline",ruleName:"Collector offline",metric:"cpu.usage",condition:"stale",threshold:null,durationMs:0,resourceKind:"none",description:"Uses the existing stale condition and the collector's advertised cadence."},{id:"memory-pressure",label:"Memory pressure",ruleName:"Memory pressure",metric:"memory.pressure.some",condition:"above",threshold:10,durationMs:6e4,resourceKind:"none",description:"Suggests memory pressure at or above 10% for 1 minute."},{id:"io-pressure",label:"I/O pressure",ruleName:"I/O pressure",metric:"io.pressure.some",condition:"above",threshold:10,durationMs:6e4,resourceKind:"none",description:"Suggests I/O pressure at or above 10% for 1 minute."},{id:"cpu-pressure",label:"CPU pressure",ruleName:"CPU pressure",metric:"cpu.pressure",condition:"above",threshold:10,durationMs:6e4,resourceKind:"none",description:"Suggests CPU pressure at or above 10% for 1 minute."},{id:"high-io-wait",label:"High I/O wait",ruleName:"High I/O wait",metric:"cpu.iowait",condition:"above",threshold:20,durationMs:3e5,resourceKind:"none",description:"Suggests CPU I/O wait at or above 20% for 5 minutes."},{id:"disk-busy",label:"Disk busy",ruleName:"Disk busy",metric:"disk.utilization",condition:"above",threshold:90,durationMs:3e5,resourceKind:"disk",description:"Suggests disk utilization at or above 90% for 5 minutes."},{id:"slow-disk-reads",label:"Slow disk reads",ruleName:"Slow disk reads",metric:"disk.read.latency",condition:"above",threshold:100,durationMs:3e5,resourceKind:"disk",description:"Suggests read latency at or above 100 ms for 5 minutes."}],M={cpu:"CPU",memory:"Memory",swap:"Swap",gpus:"GPU",disks:"Disk",network:"Network"};function P(e){return{kind:"unavailable",reason:e}}function T(){return{kind:"waiting",reason:"Waiting for the first metrics sample."}}function U(e,t){if(null===e||"object"!=typeof e)return null;let r=e[t];return"number"==typeof r&&Number.isFinite(r)?r:null}function $(e,t){return"ok"===e.disks.status?e.disks.filesystems.find(e=>e.id===t):void 0}function A(e,t){return"ok"===e.disks.status?e.disks.devices.find(e=>e.id===t):void 0}function I(e,t,r){return null===U(e,t)?P(`${r} is not reported by this collector.`):{kind:"ready"}}function E(e,t,r,s,n){let l="ready"===r.kind&&void 0!==t?{name:e.ruleName,machineId:t.machineId,metric:e.metric,resourceId:n,condition:e.condition,threshold:e.threshold,durationMs:e.durationMs,enabled:!0}:null;return{preset:e,status:r,resourceId:n,resources:s,input:l}}function F(e,t){if(!t||!j(e))return[];let r=t.inventory;return void 0===r?[]:"cpu.core"===e?Array.from({length:Math.min(r.cpu.logicalCores,256)},(e,t)=>({value:`core:${t}`,label:`Core ${t}`})):e.startsWith("gpu.")?r.gpus.filter(e=>"supported"===e.telemetry).map(e=>({value:e.id,label:e.name})):e.startsWith("fs.")?r.filesystems.map(e=>({value:e.id,label:`${e.mountPoint} (${e.fsType})`})):e.startsWith("disk.")?r.disks.map(e=>({value:e.id,label:e.name})):e.startsWith("net.")?r.network.map(e=>({value:e.id,label:e.name})):[]}function D({machines:e,rule:t,busy:r,onSave:l,onCancel:a}){let i=e[0]?.machineId??"",[o,d]=(0,n.useState)(""),[u,c]=(0,n.useState)(i),[m,x]=(0,n.useState)("cpu.usage"),[h,p]=(0,n.useState)(""),[b,f]=(0,n.useState)("above"),[g,w]=(0,n.useState)("80"),[N,k]=(0,n.useState)("0"),[C,O]=(0,n.useState)(!0),[R,W]=(0,n.useState)(""),[q,_]=(0,n.useState)(""),[K,L]=(0,n.useState)(null),[G,Z]=(0,n.useState)(!1);(0,n.useEffect)(()=>{if(null===t){d(""),c(e[0]?.machineId??""),x("cpu.usage"),p(""),f("above"),w("80"),k("0"),O(!0),W(""),_(""),L(null);return}d(t.name),c(t.machineId),x(t.metric),p(t.resourceId),f(t.condition),w(null===t.threshold?"":String(t.threshold)),k(String(t.durationMs/1e3)),O(t.enabled),W(function(e){if(null===e)return"";let t=new Date(e);if(!Number.isFinite(t.getTime()))return"";let r=e=>String(e).padStart(2,"0");return`${t.getFullYear()}-${r(t.getMonth()+1)}-${r(t.getDate())}T${r(t.getHours())}:${r(t.getMinutes())}`}(t.maintenanceUntil)),_(""),L(null)},[t]),(0,n.useEffect)(()=>{null===t&&""===u&&void 0!==e[0]&&c(e[0].machineId)},[e,t,u]);let z=e.find(e=>e.machineId===u),H=void 0!==z&&void 0===z.metrics,B=null===t?S.map(e=>(function(e,t){let{resources:r,resourceId:s}=function(e,t){if("none"===e||void 0===t)return{resources:[],resourceId:""};if("filesystem"===e){let e=t.filesystems.map(e=>({value:e.id,label:`${e.mountPoint} (${e.fsType})`})),r=t.filesystems.find(e=>"/"===e.mountPoint)??t.filesystems[0];return{resources:e,resourceId:r?.id??""}}if("gpu"===e){let e=t.gpus.filter(e=>"supported"===e.telemetry);return{resources:e.map(e=>({value:e.id,label:e.name})),resourceId:e[0]?.id??""}}return{resources:t.disks.map(e=>({value:e.id,label:e.name})),resourceId:t.disks[0]?.id??""}}(e.resourceKind,t?.inventory);return void 0===t?E(e,t,P("Choose a machine."),r,s):"none"!==e.resourceKind&&""===s?E(e,t,P(function(e){switch(e){case"filesystem":return"No filesystems are reported by this machine.";case"gpu":return"No telemetry-capable GPU is reported by this machine.";case"disk":return"No disks are reported by this machine.";case"none":return"No resource is available."}}(e.resourceKind)),r,s):E(e,t,function(e,t,r){var s;if("stale"===e.condition)return{kind:"ready"};let n=function(e,t){let r=e.inventory?.capabilities[t];if(r?.status==="unsupported"||r?.status==="withheld")return P(`${M[t]} metrics are not shared with this hub.`);let s=e.metrics?.payload;return void 0===s?T():"unavailable"===function(e,t){switch(t){case"cpu":return e.cpu;case"memory":return e.memory;case"swap":return e.swap;case"gpus":return e.gpus;case"disks":return e.disks;case"network":return e.network}}(s,t).status?P(`${M[t]} readings are unavailable on this machine.`):null}(t,(s=e.metric).startsWith("cpu.")?"cpu":s.startsWith("memory.")?"memory":s.startsWith("swap.")?"swap":s.startsWith("gpu.")?"gpus":s.startsWith("io.")||s.startsWith("fs.")||s.startsWith("disk.")?"disks":"network");if(null!==n)return n;let l=t.metrics?.payload;if(void 0===l)return T();switch(e.metric){case"cpu.usage":default:return{kind:"ready"};case"cpu.temperature":return I(l.cpu,"temperatureC","CPU temperature");case"cpu.power":return I(l.cpu,"powerWatts","CPU package power");case"cpu.iowait":return I(l.cpu,"iowaitPercent","CPU I/O wait");case"cpu.pressure":return I(l.cpu,"pressureSomePercent","CPU pressure");case"memory.usage":{let e=l.memory;if("ok"!==e.status||!(e.totalBytes>0))return P("Memory total is not reported by this machine.");return{kind:"ready"}}case"memory.pressure.some":return I(l.memory,"pressureSomePercent","Memory pressure");case"memory.pressure.full":return I(l.memory,"pressureFullPercent","Memory full pressure");case"io.pressure.some":return I(l.disks,"pressureSomePercent","I/O pressure");case"io.pressure.full":return I(l.disks,"pressureFullPercent","I/O full pressure");case"fs.usage":{let e=$(l,r);if(void 0===e)return P("The latest sample does not include this filesystem.");if("ok"!==e.status||!(e.totalBytes>0))return P("Filesystem size is not reported for this filesystem.");return{kind:"ready"}}case"fs.inodes.usage":{let e=$(l,r);if(void 0===e)return P("The latest sample does not include this filesystem.");if("ok"!==e.status)return P("This filesystem is unavailable in the latest sample.");let t=U(e,"inodesUsed"),s=U(e,"inodesTotal");if(null===t||null===s||s<=0)return P("Inode usage is not reported for this filesystem.");return{kind:"ready"}}case"gpu.temperature":{let e="ok"===l.gpus.status?l.gpus.devices.find(e=>e.id===r):void 0;if(void 0===e)return P("The latest sample does not include this GPU.");if("ok"!==e.status)return P("This GPU is unavailable in the latest sample.");return I(e,"temperatureC","GPU temperature")}case"disk.utilization":{let e=A(l,r);if(void 0===e)return P("The latest sample does not include this disk.");if("ok"!==e.status)return P("This disk is unavailable in the latest sample.");return I(e,"ioUtilizationPercent","Disk utilization")}case"disk.read.latency":{let e=A(l,r);if(void 0===e)return P("The latest sample does not include this disk.");if("ok"!==e.status)return P("This disk is unavailable in the latest sample.");return I(e,"readLatencyMs","Disk read latency")}case"disk.write.latency":{let e=A(l,r);if(void 0===e)return P("The latest sample does not include this disk.");if("ok"!==e.status)return P("This disk is unavailable in the latest sample.");return I(e,"writeLatencyMs","Disk write latency")}}}(e,t,s),r,s)})(e,z)):[],J=""===q?null:B.find(e=>e.preset.id===q)??null;(0,n.useEffect)(()=>{H&&null===t&&"stale"!==b&&f("stale")},[H,t,b]);let V=F(m,z),Y="above"===b||"below"===b,Q=j(m),X=r||G||0===e.length,ee=async e=>{if(e.preventDefault(),L(null),""===o.trim())return void L("Give the rule a name.");if(""===u)return void L("Choose a machine.");if(H&&"stale"!==b)return void L("No metrics have been received from this machine yet, so value and unavailable rules cannot be evaluated against it. Use a stale rule, or wait until the machine reports metrics.");if(Q&&""===h.trim())return void L("Choose or enter the metric's resource.");let r=Number(N);if(""===N.trim()||!Number.isInteger(r)||r<0||1e3*r>864e5)return void L("Duration must be a whole number of seconds from 0 to 86400.");let s=null;if(Y&&(""===g.trim()||!Number.isFinite(s=Number(g))))return void L("Enter a numeric threshold.");let n=function(e){if(""===e.trim())return null;let t=new Date(e);return Number.isFinite(t.getTime())?t.toISOString():null}(R);Z(!0);try{await l({...null===t?{}:{id:t.id},name:o.trim(),machineId:u,metric:m,resourceId:Q?h.trim():"",condition:b,threshold:Y?s:null,durationMs:1e3*r,enabled:C,maintenanceUntil:n})}catch(e){L(e instanceof Error?e.message:"Could not save the rule.")}finally{Z(!1)}};return(0,s.jsxs)("form",{onSubmit:e=>void ee(e),"aria-busy":G,className:"flex flex-col gap-4",children:[0===e.length?(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"No machines available."}):null,null===t?(0,s.jsxs)("div",{className:"border-b border-border pb-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("label",{htmlFor:"alert-rule-preset",className:"text-xs text-muted-foreground",children:"Warning preset"}),(0,s.jsxs)("select",{id:"alert-rule-preset",value:q,onChange:e=>_(e.target.value),disabled:X,"aria-describedby":"alert-rule-preset-note",className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground",children:[(0,s.jsx)("option",{value:"",children:"Choose a preset…"}),B.map(e=>(0,s.jsxs)("option",{value:e.preset.id,children:[e.preset.label,"ready"===e.status.kind?"":"waiting"===e.status.kind?" — waiting for metrics":" — unavailable"]},e.preset.id))]})]}),(0,s.jsx)("button",{type:"button",onClick:()=>{if(null===J||null===J.input)return;let e=J.input;d(e.name),c(e.machineId),x(e.metric),p(e.resourceId??""),f(e.condition),w(null===e.threshold||void 0===e.threshold?"":String(e.threshold)),k(String(e.durationMs/1e3)),L(null)},disabled:X||J?.status.kind!=="ready",className:"rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Use preset"})]}),(0,s.jsx)("p",{id:"alert-rule-preset-note","aria-live":"polite",className:"mt-1.5 text-xs text-muted-foreground",children:null!==J&&"ready"!==J.status.kind?J.status.reason:""})]}):null,(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsxs)("div",{className:"sm:col-span-2",children:[(0,s.jsx)("label",{htmlFor:"alert-rule-name",className:"text-xs text-muted-foreground",children:"Rule name"}),(0,s.jsx)("input",{id:"alert-rule-name",value:o,onChange:e=>d(e.target.value),maxLength:128,disabled:X,placeholder:"CPU sustained high",className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground placeholder:text-muted-foreground"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-rule-machine",className:"text-xs text-muted-foreground",children:"Machine"}),(0,s.jsxs)("select",{id:"alert-rule-machine",value:u,onChange:r=>{var s;let n,l;return s=r.target.value,_(""),c(s),void 0!==(n=e.find(e=>e.machineId===s))&&void 0===n.metrics&&null===t&&f("stale"),l=F(m,n),void(j(m)&&p(l[0]?.value??""))},disabled:X,className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground",children:[""===u||e.some(e=>e.machineId===u)?null:(0,s.jsxs)("option",{value:u,children:[u," (current)"]}),e.map(e=>(0,s.jsx)("option",{value:e.machineId,children:e.displayName?.trim()||e.hostname||e.machineId},e.machineId))]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-rule-metric",className:"text-xs text-muted-foreground",children:"Metric"}),(0,s.jsx)("select",{id:"alert-rule-metric",value:m,onChange:e=>{var t;let r;return x(t=e.target.value),r=F(t,z),void p(j(t)?r[0]?.value??"":"")},disabled:X,className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground",children:Object.keys(v).map(e=>({value:e,label:v[e].label})).map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))})]}),Q?(0,s.jsxs)("div",{className:"sm:col-span-2",children:[(0,s.jsx)("label",{htmlFor:"alert-rule-resource",className:"text-xs text-muted-foreground",children:"Resource"}),V.length>0?(0,s.jsxs)("select",{id:"alert-rule-resource",value:h,onChange:e=>p(e.target.value),disabled:X,className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground",children:[""===h||V.some(e=>e.value===h)?null:(0,s.jsxs)("option",{value:h,children:[h," (current)"]}),V.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))]}):(0,s.jsx)("input",{id:"alert-rule-resource",value:h,onChange:e=>p(e.target.value),maxLength:256,disabled:X,placeholder:"cpu.core"===m?"core:0":m.startsWith("gpu.")?"gpu:GPU-…":m.startsWith("fs.")?"fs:/":m.startsWith("disk.")?"disk:sda":m.startsWith("net.")?"net:eno1":"Resource id",className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground placeholder:text-muted-foreground"})]}):null,(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-rule-condition",className:"text-xs text-muted-foreground",children:"Condition"}),(0,s.jsx)("select",{id:"alert-rule-condition",value:b,onChange:e=>f(e.target.value),disabled:X,className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground",children:y.map(e=>(0,s.jsx)("option",{value:e.value,disabled:H&&"stale"!==e.value,children:e.label},e.value))}),H?(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Waiting for metrics."}):null]}),Y?(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{htmlFor:"alert-rule-threshold",className:"text-xs text-muted-foreground",children:["Threshold (",function(e){switch(v[e].unit){case"percent":return"percent (0–100)";case"bytes":return"bytes";case"bytes_per_second":return"bytes per second";case"celsius":return"degrees Celsius";case"watts":return"watts";case"milliseconds":return"milliseconds"}}(m),")"]}),(0,s.jsx)("input",{id:"alert-rule-threshold",type:"number",step:"any",value:g,onChange:e=>w(e.target.value),disabled:X,className:"tnum mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground"})]}):null,(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-rule-duration",className:"text-xs text-muted-foreground",children:"Must hold for (seconds)"}),(0,s.jsx)("input",{id:"alert-rule-duration",type:"number",min:0,max:86400,step:1,value:N,onChange:e=>k(e.target.value),disabled:X,className:"tnum mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-rule-maintenance",className:"text-xs text-muted-foreground",children:"Maintenance until (optional)"}),(0,s.jsx)("input",{id:"alert-rule-maintenance",type:"datetime-local",value:R,onChange:e=>W(e.target.value),disabled:X,className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground"})]}),(0,s.jsxs)("label",{className:"flex items-center gap-2 text-xs text-foreground sm:col-span-2",children:[(0,s.jsx)("input",{type:"checkbox",checked:C,onChange:e=>O(e.target.checked),disabled:X,className:"h-4 w-4 rounded border-border accent-[var(--accent)]"}),"Rule enabled"]})]}),K?(0,s.jsx)("p",{role:"alert",className:"rounded-md bg-crit-soft px-3 py-2 text-xs text-foreground",children:K}):null,(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("button",{type:"submit",disabled:X,className:"rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90 disabled:opacity-50",children:G?"Saving…":null===t?"Create rule":"Save rule"}),null!==t?(0,s.jsx)("button",{type:"button",onClick:a,disabled:G,className:"rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Cancel"}):null]})]})}function O({status:e,busy:t,onConfigure:r,onClear:l,onTest:a}){let[i,o]=(0,n.useState)(""),[d,u]=(0,n.useState)(""),[c,m]=(0,n.useState)(""),[x,h]=(0,n.useState)(!0),[p,b]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[y,v]=(0,n.useState)(!1),[j,w]=(0,n.useState)(null),[N,k]=(0,n.useState)(null),C=(0,n.useRef)(null),S=(0,n.useRef)(null),M=(0,n.useRef)(null);(0,n.useEffect)(()=>{null!==j&&C.current?.focus()},[j]),(0,n.useEffect)(()=>{e.configured||(w(null),k(null))},[e.configured]);let P=async e=>{v(!0),b(null),w(null),k(null);try{await r(e),o(""),u(""),m(""),h(!0)}catch(e){b(e instanceof Error?e.message:"Could not configure the webhook.")}finally{v(!1)}},T=async t=>{t.preventDefault();let r=(()=>{let e;b(null),g(null);let t=i.trim();if(""===t)return b("Enter the webhook URL."),null;if(""!==d.trim())try{let t=JSON.parse(d);if(null===t||"object"!=typeof t||Array.isArray(t))throw Error("not an object");for(let[r,s]of(e={},Object.entries(t))){if("string"!=typeof s)throw Error("header values must be strings");e[r]=s}}catch{return b("Headers must be a JSON object with string values."),null}return{url:t,...void 0===e?{}:{headers:e},secret:""===c.trim()?null:c,enabled:x}})();if(null!==r){if(e.configured){k(r),w("replace");return}await P(r)}},U=async()=>{v(!0),b(null),g(null),w(null);try{await l(),o(""),u(""),m("")}catch(e){b(e instanceof Error?e.message:"Could not clear the webhook.")}finally{v(!1)}},$=async()=>{"clear"===j?await U():"replace"===j&&null!==N&&await P(N)},A=async()=>{b(null),v(!0);try{g(await a())}catch(e){b(e instanceof Error?e.message:"Could not test the webhook.")}finally{v(!1)}},I=t||y||null!==j,E=e.configured&&"loopback-http"===e.transport;return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-xs",children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Configured"}),(0,s.jsx)("dd",{className:"text-foreground",children:e.configured?e.enabled?"Enabled":"Disabled":"Not configured"}),(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Transport"}),(0,s.jsx)("dd",{className:"text-foreground",children:"https"===e.transport?"HTTPS":"loopback-http"===e.transport?"Loopback HTTP test sink":"—"}),(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Last test"}),(0,s.jsx)("dd",{className:"text-foreground",children:null===e.lastTestAt?"Never":`${!0===e.lastTestOk?"Passed":"Failed"} \xb7 ${new Date(e.lastTestAt).toLocaleString()}`}),e.lastError?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Last error"}),(0,s.jsx)("dd",{className:"text-warn",children:e.lastError})]}):null]}),(0,s.jsxs)("form",{onSubmit:e=>void T(e),className:"flex flex-col gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-webhook-url",className:"text-xs text-muted-foreground",children:e.configured?"Replace webhook URL":"Webhook URL"}),(0,s.jsx)("input",{id:"alert-webhook-url",type:"url",required:!0,value:i,onChange:e=>o(e.target.value),maxLength:2048,disabled:I,placeholder:"https://receiver.example/alerts",className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground placeholder:text-muted-foreground"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-webhook-headers",className:"text-xs text-muted-foreground",children:"Headers (JSON, optional)"}),(0,s.jsx)("textarea",{id:"alert-webhook-headers",value:d,onChange:e=>u(e.target.value),rows:2,disabled:I,placeholder:'{"x-channel": "monitoring"}',className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 font-mono text-xs text-foreground placeholder:text-muted-foreground"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-webhook-secret",className:"text-xs text-muted-foreground",children:"Signing secret (optional)"}),(0,s.jsx)("input",{id:"alert-webhook-secret",type:"password",value:c,onChange:e=>m(e.target.value),maxLength:256,disabled:I,placeholder:"Blank clears the signature",autoComplete:"new-password",className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground"})]}),(0,s.jsxs)("label",{className:"flex items-center gap-2 text-xs text-foreground",children:[(0,s.jsx)("input",{type:"checkbox",checked:x,onChange:e=>h(e.target.checked),disabled:I,className:"h-4 w-4 rounded border-border accent-[var(--accent)]"}),"Webhook enabled"]}),p?(0,s.jsx)("p",{role:"alert",className:"rounded-md bg-crit-soft px-3 py-2 text-xs text-foreground",children:p}):null,(0,s.jsx)("p",{role:"status",className:f?`rounded-md px-3 py-2 text-xs ${f.ok?"bg-ok-soft text-foreground":"bg-warn-soft text-foreground"}`:"sr-only",children:f?`Test ${f.ok?"delivered":"failed"}${null!==f.status?` (HTTP ${f.status})`:""}${f.error?` — ${f.error}`:""}.`:""}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("button",{ref:S,type:"submit",disabled:I||""===i.trim(),className:"rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90 disabled:opacity-50",children:e.configured?"Replace webhook":"Configure webhook"}),(0,s.jsx)("button",{ref:M,type:"button",onClick:()=>{b(null),w("clear")},disabled:I||!e.configured,className:"rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Clear webhook"}),(0,s.jsx)("button",{type:"button",onClick:()=>void A(),disabled:I||!E,title:E?"Send one explicit test message to the configured loopback sink":"Test delivery is available only for a configured loopback HTTP sink",className:"rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Send test"})]}),null!==j?(0,s.jsxs)("div",{role:"group","aria-label":"Confirm webhook change",className:"rounded-md bg-warn-soft px-3 py-3",children:[(0,s.jsx)("p",{className:"text-xs text-foreground",children:"clear"===j?"Clear the configured webhook? Future incidents will not be delivered until a webhook is configured again.":"Replace the configured webhook? The stored URL, headers and secret will be overwritten."}),(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,s.jsx)("button",{ref:C,type:"button",onClick:()=>void $(),disabled:y,className:`rounded-md px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors disabled:opacity-50 ${"clear"===j?"bg-crit":"bg-accent hover:bg-accent/90"}`,children:"clear"===j?"Confirm clear":"Confirm replace"}),(0,s.jsx)("button",{type:"button",onClick:()=>{let e="clear"===j?M.current:S.current;w(null),k(null),e?.focus()},disabled:y,className:"rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Cancel"})]})]}):null]})]})}function R(e){if(null===e)return"—";let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString():e}function W({tone:e,children:t}){return(0,s.jsx)("span",{className:`tnum inline-flex items-center rounded-full px-2 py-0.5 text-xs ${"ok"===e?"bg-ok-soft text-ok":"warn"===e?"bg-warn-soft text-warn":"crit"===e?"bg-crit-soft text-crit":"border border-border text-muted-foreground"}`,children:t})}function q({incident:e,now:t}){let r="open"===e.status;return(0,s.jsx)("li",{className:"border-b border-border py-3 last:border-b-0",children:(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-x-4 gap-y-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(W,{tone:r?"crit":"ok",children:r?"Open":"Recovered"}),(0,s.jsx)("span",{className:"truncate text-sm font-medium",children:e.ruleName}),(0,s.jsx)("span",{className:"tnum text-xs text-muted-foreground",children:e.machineId})]}),(0,s.jsx)("p",{className:"mt-1 max-w-2xl text-sm",children:e.message}),(0,s.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:[C(e.metric,e.resourceId)," \xb7 started"," ",(0,b.nV)((0,b.A4)(e.startedAt,t)),null!==e.resolvedAt?` \xb7 recovered ${(0,b.nV)((0,b.A4)(e.resolvedAt,t))}`:""]})]}),(0,s.jsxs)("dl",{className:"tnum grid shrink-0 grid-cols-2 gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[(0,s.jsx)("dt",{children:"Started value"}),(0,s.jsx)("dd",{className:"text-right text-foreground",children:N(e.metric,e.startedValue)}),(0,s.jsx)("dt",{children:"Recovered value"}),(0,s.jsx)("dd",{className:"text-right text-foreground",children:N(e.metric,e.resolvedValue)})]})]})})}function _({rule:e,admin:t,busy:r,confirmingDelete:n,onEdit:i,onRequestDelete:o,onCancelDelete:d,onConfirmDelete:u}){var c,m;let x=(c=e.condition,y.find(e=>e.value===c)?.needsThreshold)?`${k(e.condition)} ${N(e.metric,e.threshold)}`:k(e.condition),h=e.enabled?"firing"===e.state?"crit":"pending"===e.state?"warn":"ok":"muted",p=e.enabled?"firing"===e.state?"Firing":"pending"===e.state?"Pending":"OK":"Disabled";return(0,s.jsxs)("li",{className:"border-b border-border py-3 last:border-b-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-x-4 gap-y-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"truncate text-sm font-medium",children:e.name}),(0,s.jsx)(W,{tone:h,children:p})]}),(0,s.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:[e.machineId," \xb7 ",C(e.metric,e.resourceId)]}),(0,s.jsxs)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[x," \xb7 holds ",!Number.isFinite(m=e.durationMs)||m<=0?"Immediately":m<6e4?`${Math.round(m/1e3)} s`:m<36e5?`${Math.round(m/6e4)} min`:`${Math.round(m/36e5)} h`,e.pendingSince?` \xb7 pending since ${R(e.pendingSince)}`:""]}),e.maintenanceUntil?(0,s.jsxs)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["Maintenance until ",R(e.maintenanceUntil)]}):null]}),t?(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[(0,s.jsxs)("button",{type:"button",onClick:i,disabled:r||n,className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:[(0,s.jsx)(l.A,{className:"h-3 w-3","aria-hidden":!0}),"Edit"]}),(0,s.jsxs)("button",{type:"button",onClick:o,disabled:r||n,className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs text-crit transition-colors hover:bg-crit-soft disabled:opacity-50",children:[(0,s.jsx)(a.A,{className:"h-3 w-3","aria-hidden":!0}),"Delete"]})]}):null]}),n?(0,s.jsxs)("div",{role:"group","aria-label":"Confirm rule deletion",className:"mt-3 rounded-md bg-warn-soft px-3 py-2.5",children:[(0,s.jsxs)("p",{className:"text-xs text-foreground",children:["Delete “",e.name,"”? Its incident history stays, but the rule stops evaluating."]}),(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap gap-2",children:[(0,s.jsx)("button",{type:"button",autoFocus:!0,onClick:()=>void u(),disabled:r,className:"rounded-md bg-crit px-2.5 py-1 text-xs font-medium text-accent-foreground transition-colors disabled:opacity-50",children:"Confirm delete"}),(0,s.jsx)("button",{type:"button",onClick:d,disabled:r,className:"rounded-md border border-border px-2.5 py-1 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Cancel"})]})]}):null]})}function K({notification:e}){let t="failed"===e.status?"crit":"delivered"===e.status?"ok":"warn";return(0,s.jsxs)("li",{className:"border-b border-border py-2 last:border-b-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1 text-xs",children:[(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)(W,{tone:t,children:e.status}),(0,s.jsx)("span",{className:"text-foreground",children:e.event}),(0,s.jsxs)("span",{className:"tnum text-muted-foreground",children:["attempt ",e.attempts,"/",e.maxAttempts]})]}),(0,s.jsx)("span",{className:"tnum text-muted-foreground",children:R(e.createdAt)})]}),e.lastError?(0,s.jsx)("p",{className:"mt-1 text-xs text-warn",children:e.lastError}):null,(0,s.jsx)("p",{className:"tnum mt-0.5 truncate font-mono text-xs text-muted-foreground",children:e.id})]})}function L(){let{session:e,machines:t}=(0,f.M)(),r=(0,p.x)(),l=(0,g.c)(),a="signed-in"===e.kind?e.user.csrfToken:null,b="signed-in"===e.kind&&!0===e.user.admin,[y,v]=(0,n.useState)(null),[j,w]=(0,n.useState)(!0),[N,k]=(0,n.useState)(null),[C,S]=(0,n.useState)(null),[M,P]=(0,n.useState)(null),[T,U]=(0,n.useState)(null),[$,A]=(0,n.useState)(!1),I=b&&(null===y||y.canAdmin),E=(0,n.useCallback)(async()=>{if(null!==a){w(!0),k(null);try{let e=await fetch("/api/alerts",{headers:{Accept:"application/json"},cache:"no-store",credentials:"same-origin"}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error??`Could not load alerts (${e.status}).`);v(t)}catch(e){k(e instanceof Error?e.message:"Could not load alerts.")}finally{w(!1)}}},[a]);(0,n.useEffect)(()=>{null!==a&&E()},[a,E]);let F=(0,n.useCallback)(async(e,t)=>{if(null===a)throw Error("Sign in required.");A(!0),k(null);try{let r=await fetch(e,{...t,cache:"no-store",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json","x-csrf-token":a,...t.headers??{}}}),s=await r.json().catch(()=>({}));if(!r.ok)throw Error(s.error??`Request failed (${r.status}).`);return s}finally{A(!1)}},[a]),R=async e=>{await F("/api/alerts/rules",{method:"POST",body:JSON.stringify(e)}),P(null),S(e.id?"Rule saved.":"Rule created."),await E()},W=async e=>{try{await F(`/api/alerts/rules?id=${encodeURIComponent(e.id)}`,{method:"DELETE"}),M?.id===e.id&&P(null),U(null),S("Rule deleted."),await E()}catch(e){k(e instanceof Error?e.message:"Could not delete the rule.")}},L=async e=>{await F("/api/alerts/webhook",{method:"POST",body:JSON.stringify({action:"configure",...e})}),S("Webhook configured."),await E()},G=async()=>{await F("/api/alerts/webhook",{method:"POST",body:JSON.stringify({action:"clear"})}),S("Webhook cleared."),await E()},Z=async()=>{let e=await F("/api/alerts/webhook",{method:"POST",body:JSON.stringify({action:"test"})});return v(t=>null===t?t:{...t,webhook:e.status}),S(e.result.ok?"Webhook test delivered.":"Webhook test failed."),e.result},z=y?.incidents??[],H=z.filter(e=>"open"===e.status).length,B=y?.rules??[],J=y?.notifications,V=j&&null===y;return(0,s.jsx)(c.G,{title:"Alerts",headerRight:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(x.$E,{}),(0,s.jsx)(h.B,{})]}),children:r||(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(p.E,{}),(0,s.jsx)("div",{className:"mb-4 flex flex-wrap items-center justify-end gap-3",children:(0,s.jsxs)("button",{type:"button",onClick:()=>void E(),disabled:j,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:[(0,s.jsx)(i.A,{className:`h-3.5 w-3.5 ${j?"animate-spin":""}`,"aria-hidden":!0}),"Refresh"]})}),(0,s.jsx)("p",{role:"status",className:C?"mb-4 text-xs text-muted-foreground":"sr-only",children:C??""}),N?(0,s.jsx)("p",{role:"alert",className:"mb-4 rounded-lg bg-crit-soft px-4 py-2.5 text-xs text-foreground",children:N}):null,V?(0,s.jsx)(m.Z,{title:"Alerts",className:"mt-8",children:(0,s.jsx)(m.p,{icon:i.A,note:"Loading alert rules and incidents…"})}):null===y?(0,s.jsx)(m.Z,{title:"Alerts unavailable",className:"mt-8",children:(0,s.jsx)(m.p,{icon:o.A,note:"Alert state could not be loaded."})}):(0,s.jsxs)("div",{className:I?"grid gap-5 xl:grid-cols-[minmax(0,1fr)_24rem]":"flex flex-col gap-5",children:[(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-5",children:[(0,s.jsx)(m.Z,{title:"Incidents and recoveries",action:(0,s.jsxs)("span",{children:[H," open \xb7 ",z.length," recent"]}),children:0===z.length?(0,s.jsx)(m.p,{icon:d,note:"No incidents."}):(0,s.jsx)("ul",{className:"flex flex-col",children:z.map(e=>(0,s.jsx)(q,{incident:e,now:l},e.id))})}),(0,s.jsx)(m.Z,{title:"Rules",action:(0,s.jsxs)("span",{children:[B.length," configured"]}),children:0===B.length?(0,s.jsx)(m.p,{icon:u.A,note:"No rules."}):(0,s.jsx)("ul",{className:"flex flex-col",children:B.map(e=>(0,s.jsx)(_,{rule:e,admin:I,busy:$,confirmingDelete:T===e.id,onEdit:()=>{U(null),P(e)},onRequestDelete:()=>U(e.id),onCancelDelete:()=>U(null),onConfirmDelete:()=>W(e)},e.id))})}),(0,s.jsx)(m.Z,{title:"Notifications",action:(0,s.jsxs)("span",{children:[J?.pending??0," pending \xb7 ",J?.failed??0," failed"]}),children:void 0===J||0===J.recent.length?(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"No notifications."}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("dl",{className:"grid grid-cols-3 gap-3 border-b border-border pb-3 text-xs",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Pending"}),(0,s.jsx)("dd",{className:"tnum text-foreground",children:J.pending})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Delivered"}),(0,s.jsx)("dd",{className:"tnum text-foreground",children:J.delivered})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Failed"}),(0,s.jsx)("dd",{className:"tnum text-foreground",children:J.failed})]})]}),(0,s.jsx)("ul",{className:"mt-1 flex flex-col",children:J.recent.slice(0,10).map(e=>(0,s.jsx)(K,{notification:e},e.id))})]})})]}),I?(0,s.jsxs)("aside",{className:"flex min-w-0 flex-col gap-5",children:[(0,s.jsx)(m.Z,{title:null===M?"New rule":"Edit rule",action:null===M?null:(0,s.jsx)("button",{type:"button",onClick:()=>P(null),className:"text-xs text-muted-foreground hover:text-foreground",children:"New instead"}),children:(0,s.jsx)(D,{machines:t,rule:M,busy:$,onSave:R,onCancel:()=>P(null)})}),(0,s.jsx)(m.Z,{title:"Webhook",children:(0,s.jsx)(O,{status:y.webhook,busy:$,onConfigure:L,onClear:G,onTest:Z})})]}):null]})]})})}},2865:(e,t,r)=>{Promise.resolve().then(r.bind(r,1461))},5798:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]])},6582:(e,t,r)=>{"use strict";r.d(t,{E:()=>f,x:()=>b});var s=r(5155),n=r(8500),l=r.n(n),a=r(828),i=r(6914),o=r(7029),d=r(438),u=r(7422),c=r(1735),m=r(3440),x=r(9939);function h(e){return(0,s.jsxs)("button",{type:"button",onClick:e.onClick,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,s.jsx)(a.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.children]})}function p(e){return(0,s.jsx)(l(),{href:e.href,className:e.primary?"inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90":"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:e.children})}function b(){let{session:e,phase:t,retryConnection:r}=(0,x.M)();switch(e.kind){case"restoring":return(0,s.jsx)(m.Z,{title:"Checking session",className:"mx-auto my-12 max-w-md",children:(0,s.jsx)(m.p,{icon:i.A,note:"Checking your session…"})});case"restore-failed":return(0,s.jsxs)(m.Z,{title:"Hub unreachable",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(m.p,{icon:o.A,note:"The hub is unreachable right now."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(h,{onClick:r,children:"Check again"})})]});case"signed-out":if("expired"===t)return(0,s.jsxs)(m.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(m.p,{icon:d.A,note:"Your session ended."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(p,{href:"/login",primary:!0,children:"Sign in"})})]});return(0,s.jsxs)(m.Z,{title:"Sign in required",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(m.p,{icon:i.A,note:"Sign in required."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(p,{href:"/login",primary:!0,children:"Sign in"})})]});case"auth-unavailable":return(0,s.jsx)(m.Z,{title:"Sign-in unavailable",className:"mx-auto my-12 max-w-md",children:(0,s.jsx)(m.p,{icon:u.A,note:"Browser sign-in is not configured on this hub."})})}return"expired"===t?(0,s.jsxs)(m.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(m.p,{icon:d.A,note:"Your session ended."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(p,{href:"/login",primary:!0,children:"Sign in"})})]}):"no-permission"===t?(0,s.jsxs)(m.Z,{title:"No permission",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(m.p,{icon:u.A,note:`You are signed in as ${e.user.username}, but this hub grants no machine view to this account.`}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(h,{onClick:r,children:"Check again"})})]}):null}function f(){let{phase:e,retryConnection:t}=(0,x.M)();return"reconnecting"!==e&&"disconnected"!==e&&"connecting"!==e?null:"connecting"===e?(0,s.jsxs)("div",{role:"status",className:"mb-5 flex items-center gap-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,s.jsx)(a.A,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),"Connecting to the live feed — waiting for the first snapshot."]}):(0,s.jsxs)("div",{role:"status",className:"mb-5 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,s.jsx)(c.A,{className:"h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,s.jsxs)("span",{children:["Connection lost — values below are ",(0,s.jsx)("strong",{className:"font-medium text-foreground",children:"last known"}),", not live measurements","reconnecting"===e?" — retrying with backoff…":" — retries stopped."]}),"disconnected"===e?(0,s.jsx)(h,{onClick:t,children:"Retry now"}):null]})}},7241:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])}},e=>{e.O(0,[157,939,103,441,794,358],()=>e(e.s=2865)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[572],{3092:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});let n=(0,t(8698).A)("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},3612:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});let n=(0,t(8698).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},5773:(e,s,t)=>{"use strict";t.d(s,{ConnectionsView:()=>A});var n=t(5155),a=t(8500),l=t.n(a),r=t(438),d=t(3092),i=t(3612),c=t(7233),x=t(4173),o=t(3440),m=t(940),u=t(802),h=t(6576),g=t(6582),f=t(7586),p=t(9939),j=t(7348),N=t(2241);function b(e){if(null===e)return"—";let s=new Date(e);return Number.isFinite(s.getTime())?s.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"}):e}function v({capability:e}){var s;return(0,n.jsxs)("li",{className:"rounded-md border border-border bg-card-strong/30 px-2 py-1.5",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,n.jsx)("span",{className:"text-xs text-foreground",children:e.label}),(0,n.jsx)("span",{className:`tnum rounded-full px-1.5 py-0.5 text-xs ${"supported"===(s=e.status)?"bg-ok-soft text-ok":"unsupported"===s?"bg-warn-soft text-warn":"border border-border text-muted-foreground"}`,children:e.status})]}),e.reason?(0,n.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:e.reason}):null]})}function y({view:e,now:s}){return(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[(0,n.jsxs)("span",{className:"tnum inline-flex items-center gap-1.5 text-sm",children:[(0,n.jsx)("span",{"aria-hidden":!0,className:`inline-block h-2 w-2 shrink-0 rounded-full ${e.connected?"bg-ok":"bg-crit"}`}),e.connected?"Connected":"Disconnected"]}),(0,n.jsxs)("span",{className:"tnum text-xs text-muted-foreground",children:["Interval ",null===e.cadenceMs?"unknown":(0,f.$)(e.cadenceMs)]}),(0,n.jsxs)("span",{className:"tnum text-xs text-muted-foreground",children:["Updated ",(0,f.nV)((0,f.A4)(e.lastReceivedAt,s))]}),"stale"===e.freshness?(0,n.jsx)(h.vw,{text:"stale",title:`No update for over ${(0,f.$)(e.thresholdMs)}`}):"unknown"===e.freshness?(0,n.jsx)(h.vw,{text:"no sample",title:"No receipt timestamp is available yet"}):null]})}function w({view:e}){if(null===e.delivery)return(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Delivery status unavailable."});let s=e.delivery;return(0,n.jsxs)("dl",{className:"grid gap-x-6 gap-y-2 sm:grid-cols-2",children:[(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Backlog records"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:s.pendingRecords})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Backlog bytes"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:(0,f.z3)(s.pendingBytes)})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"In-flight records"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:s.inFlightRecords})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Oldest pending"}),(0,n.jsx)("dd",{className:"tnum text-right text-xs text-foreground",children:b(s.oldestPendingCapturedAt)})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Last acknowledgment"}),(0,n.jsx)("dd",{className:"tnum text-right text-xs text-foreground",children:null===s.lastAckAt?"No acknowledgment yet":b(s.lastAckAt)})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Dropped / gap records"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:s.droppedRecords})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Replaying"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:s.replaying?"Yes":"No"})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Status captured"}),(0,n.jsx)("dd",{className:"tnum text-right text-xs text-foreground",children:b(e.deliveryCapturedAt)})]})]})}function k({view:e,now:s}){return(0,n.jsx)(o.Z,{title:e.name,action:(0,n.jsx)(l(),{href:`/machines/${encodeURIComponent(e.machineId)}`,className:"text-xs text-accent hover:underline",children:"Open machine"}),children:(0,n.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,n.jsx)(y,{view:e,now:s}),(0,n.jsxs)("section",{"aria-label":`${e.name} delivery`,children:[(0,n.jsxs)("h3",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[(0,n.jsx)(r.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Delivery"]}),(0,n.jsx)("div",{className:"mt-2",children:(0,n.jsx)(w,{view:e})})]}),(0,n.jsxs)("section",{"aria-label":`${e.name} collection failures`,className:"border-t border-border pt-4",children:[(0,n.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:"Collection failures"}),null===e.delivery?(0,n.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Failure status unavailable."}):0===e.failures.length?(0,n.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"None"}):(0,n.jsx)("ul",{className:"mt-2 flex flex-col gap-1.5",children:e.failures.map((e,s)=>(0,n.jsxs)("li",{className:"text-xs",children:[(0,n.jsx)("span",{className:"text-foreground",children:e.metric}),e.resourceId?(0,n.jsxs)("span",{className:"tnum font-mono text-xs text-muted-foreground",children:[" \xb7 ",e.resourceId]}):null,(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" — ",e.reason]})]},`${e.metric}\0${e.resourceId??""}\0${e.reason}\0${s}`))})]}),(0,n.jsxs)("section",{"aria-label":`${e.name} capabilities`,className:"border-t border-border pt-4",children:[(0,n.jsxs)("h3",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[(0,n.jsx)(d.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Capabilities"]}),null===e.capabilities?(0,n.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Capabilities unavailable."}):(0,n.jsx)("ul",{className:"mt-2 grid gap-1.5 sm:grid-cols-2 xl:grid-cols-3",children:e.capabilities.map(e=>(0,n.jsx)(v,{capability:e},e.key))})]})]})})}function A(){let{phase:e,machines:s,session:t}=(0,p.M)(),a=(0,g.x)(),r=(0,j.c)(),d=(0,N.cy)(s,r);return(0,n.jsx)(x.G,{title:"Connections",headerRight:(0,n.jsxs)(n.Fragment,{children:["signed-in"===t.kind&&t.user.admin?(0,n.jsxs)(l(),{href:"/administration#collectors",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs hover:bg-card-strong",children:[(0,n.jsx)(i.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Add machine"]}):null,(0,n.jsx)(m.$E,{}),(0,n.jsx)(u.B,{})]}),children:a||(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(g.E,{}),("live"===e||"reconnecting"===e||"disconnected"===e)&&0===s.length?(0,n.jsx)(o.Z,{title:"No collectors",className:"mt-8",children:(0,n.jsx)(o.p,{icon:c.A,note:"No collectors are connected to this hub in your authorized scope."})}):null,0===d.length&&"connecting"===e?(0,n.jsx)(o.Z,{title:"Waiting for collector status",className:"mt-8",children:(0,n.jsx)(o.p,{icon:c.A,note:"Waiting for the first snapshot…"})}):null,d.length>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("h2",{className:"mb-4 text-sm font-medium tracking-tight",children:"Collectors"}),(0,n.jsx)("div",{className:"grid gap-5 xl:grid-cols-[repeat(auto-fit,minmax(30rem,1fr))]",children:d.map(e=>(0,n.jsx)(k,{view:e,now:r},e.machineId))})]}):null]})})}},6351:(e,s,t)=>{Promise.resolve().then(t.bind(t,5773))}},e=>{e.O(0,[157,939,103,227,441,794,358],()=>e(e.s=6351)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[572],{3092:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});let n=(0,t(8698).A)("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},3612:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});let n=(0,t(8698).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},5773:(e,s,t)=>{"use strict";t.d(s,{ConnectionsView:()=>A});var n=t(5155),a=t(8500),l=t.n(a),r=t(438),d=t(3092),i=t(3612),c=t(7233),x=t(4173),o=t(3440),m=t(940),u=t(802),h=t(6576),g=t(6582),f=t(7586),p=t(9939),j=t(7348),N=t(2241);function b(e){if(null===e)return"—";let s=new Date(e);return Number.isFinite(s.getTime())?s.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"}):e}function v({capability:e}){var s;return(0,n.jsxs)("li",{className:"rounded-md border border-border bg-card-strong/30 px-2 py-1.5",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,n.jsx)("span",{className:"text-xs text-foreground",children:e.label}),(0,n.jsx)("span",{className:`tnum rounded-full px-1.5 py-0.5 text-xs ${"supported"===(s=e.status)?"bg-ok-soft text-ok":"unsupported"===s?"bg-warn-soft text-warn":"border border-border text-muted-foreground"}`,children:e.status})]}),e.reason?(0,n.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:e.reason}):null]})}function y({view:e,now:s}){return(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[(0,n.jsxs)("span",{className:"tnum inline-flex items-center gap-1.5 text-sm",children:[(0,n.jsx)("span",{"aria-hidden":!0,className:`inline-block h-2 w-2 shrink-0 rounded-full ${e.connected?"bg-ok":"bg-crit"}`}),e.connected?"Connected":"Disconnected"]}),(0,n.jsxs)("span",{className:"tnum text-xs text-muted-foreground",children:["Interval ",null===e.cadenceMs?"unknown":(0,f.$)(e.cadenceMs)]}),(0,n.jsxs)("span",{className:"tnum text-xs text-muted-foreground",children:["Updated ",(0,f.nV)((0,f.A4)(e.lastReceivedAt,s))]}),"stale"===e.freshness?(0,n.jsx)(h.vw,{text:"stale",title:`No update for over ${(0,f.$)(e.thresholdMs)}`}):"unknown"===e.freshness?(0,n.jsx)(h.vw,{text:"no sample",title:"No receipt timestamp is available yet"}):null]})}function w({view:e}){if(null===e.delivery)return(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Delivery status unavailable."});let s=e.delivery;return(0,n.jsxs)("dl",{className:"grid gap-x-6 gap-y-2 sm:grid-cols-2",children:[(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Backlog records"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:s.pendingRecords})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Backlog bytes"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:(0,f.z3)(s.pendingBytes)})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"In-flight records"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:s.inFlightRecords})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Oldest pending"}),(0,n.jsx)("dd",{className:"tnum text-right text-xs text-foreground",children:b(s.oldestPendingCapturedAt)})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Last acknowledgment"}),(0,n.jsx)("dd",{className:"tnum text-right text-xs text-foreground",children:null===s.lastAckAt?"No acknowledgment yet":b(s.lastAckAt)})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Dropped / gap records"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:s.droppedRecords})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Replaying"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:s.replaying?"Yes":"No"})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Status captured"}),(0,n.jsx)("dd",{className:"tnum text-right text-xs text-foreground",children:b(e.deliveryCapturedAt)})]})]})}function k({view:e,now:s}){return(0,n.jsx)(o.Z,{title:e.name,action:(0,n.jsx)(l(),{href:`/machines/${encodeURIComponent(e.machineId)}`,className:"text-xs text-accent hover:underline",children:"Open machine"}),children:(0,n.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,n.jsx)(y,{view:e,now:s}),(0,n.jsxs)("section",{"aria-label":`${e.name} delivery`,children:[(0,n.jsxs)("h3",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[(0,n.jsx)(r.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Delivery"]}),(0,n.jsx)("div",{className:"mt-2",children:(0,n.jsx)(w,{view:e})})]}),(0,n.jsxs)("section",{"aria-label":`${e.name} collection failures`,className:"border-t border-border pt-4",children:[(0,n.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:"Collection failures"}),null===e.delivery?(0,n.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Failure status unavailable."}):0===e.failures.length?(0,n.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"None"}):(0,n.jsx)("ul",{className:"mt-2 flex flex-col gap-1.5",children:e.failures.map((e,s)=>(0,n.jsxs)("li",{className:"text-xs",children:[(0,n.jsx)("span",{className:"text-foreground",children:e.metric}),e.resourceId?(0,n.jsxs)("span",{className:"tnum font-mono text-xs text-muted-foreground",children:[" \xb7 ",e.resourceId]}):null,(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" — ",e.reason]})]},`${e.metric}\0${e.resourceId??""}\0${e.reason}\0${s}`))})]}),(0,n.jsxs)("section",{"aria-label":`${e.name} capabilities`,className:"border-t border-border pt-4",children:[(0,n.jsxs)("h3",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[(0,n.jsx)(d.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Capabilities"]}),null===e.capabilities?(0,n.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Capabilities unavailable."}):(0,n.jsx)("ul",{className:"mt-2 grid gap-1.5 sm:grid-cols-2 xl:grid-cols-3",children:e.capabilities.map(e=>(0,n.jsx)(v,{capability:e},e.key))})]})]})})}function A(){let{phase:e,machines:s,session:t}=(0,p.M)(),a=(0,g.x)(),r=(0,j.c)(),d=(0,N.cy)(s,r);return(0,n.jsx)(x.G,{title:"Connections",headerRight:(0,n.jsxs)(n.Fragment,{children:["signed-in"===t.kind&&t.user.admin?(0,n.jsxs)(l(),{href:"/administration#collectors",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs hover:bg-card-strong",children:[(0,n.jsx)(i.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Add machine"]}):null,(0,n.jsx)(m.$E,{}),(0,n.jsx)(u.B,{})]}),children:a||(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(g.E,{}),("live"===e||"reconnecting"===e||"disconnected"===e)&&0===s.length?(0,n.jsx)(o.Z,{title:"No collectors",className:"mt-8",children:(0,n.jsx)(o.p,{icon:c.A,note:"No collectors are connected to this hub in your authorized scope."})}):null,0===d.length&&"connecting"===e?(0,n.jsx)(o.Z,{title:"Waiting for collector status",className:"mt-8",children:(0,n.jsx)(o.p,{icon:c.A,note:"Waiting for the first snapshot…"})}):null,d.length>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("h2",{className:"mb-4 text-sm font-medium tracking-tight",children:"Collectors"}),(0,n.jsx)("div",{className:"grid gap-5 xl:grid-cols-[repeat(auto-fit,minmax(30rem,1fr))]",children:d.map(e=>(0,n.jsx)(k,{view:e,now:r},e.machineId))})]}):null]})})}},6351:(e,s,t)=>{Promise.resolve().then(t.bind(t,5773))}},e=>{e.O(0,[157,939,103,130,441,794,358],()=>e(e.s=6351)),_N_E=e.O()}]);