rigscope 0.0.0-stage → 0.1.1

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 (224) hide show
  1. package/.next/BUILD_ID +1 -0
  2. package/.next/app-path-routes-manifest.json +13 -0
  3. package/.next/build-manifest.json +20 -0
  4. package/.next/export-marker.json +6 -0
  5. package/.next/images-manifest.json +68 -0
  6. package/.next/next-minimal-server.js.nft.json +1 -0
  7. package/.next/next-server.js.nft.json +1 -0
  8. package/.next/package.json +1 -0
  9. package/.next/prerender-manifest.json +297 -0
  10. package/.next/react-loadable-manifest.json +1 -0
  11. package/.next/required-server-files.json +369 -0
  12. package/.next/routes-manifest.json +114 -0
  13. package/.next/server/app/_global-error/page.js +31 -0
  14. package/.next/server/app/_global-error/page.js.nft.json +1 -0
  15. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -0
  16. package/.next/server/app/_global-error.html +1 -0
  17. package/.next/server/app/_global-error.meta +35 -0
  18. package/.next/server/app/_global-error.rsc +18 -0
  19. package/.next/server/app/_global-error.segments/_full.segment.rsc +18 -0
  20. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +24 -0
  21. package/.next/server/app/_global-error.segments/_tree.segment.rsc +3 -0
  22. package/.next/server/app/_not-found/page.js +1 -0
  23. package/.next/server/app/_not-found/page.js.nft.json +1 -0
  24. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -0
  25. package/.next/server/app/_not-found.html +1 -0
  26. package/.next/server/app/_not-found.meta +35 -0
  27. package/.next/server/app/_not-found.rsc +24 -0
  28. package/.next/server/app/_not-found.segments/_full.segment.rsc +24 -0
  29. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +30 -0
  30. package/.next/server/app/_not-found.segments/_tree.segment.rsc +4 -0
  31. package/.next/server/app/administration/page.js +1 -0
  32. package/.next/server/app/administration/page.js.nft.json +1 -0
  33. package/.next/server/app/administration/page_client-reference-manifest.js +1 -0
  34. package/.next/server/app/administration.html +1 -0
  35. package/.next/server/app/administration.meta +34 -0
  36. package/.next/server/app/administration.rsc +29 -0
  37. package/.next/server/app/administration.segments/_full.segment.rsc +29 -0
  38. package/.next/server/app/administration.segments/_tree.segment.rsc +4 -0
  39. package/.next/server/app/administration.segments/administration/__PAGE__.segment.rsc +35 -0
  40. package/.next/server/app/alerts/page.js +1 -0
  41. package/.next/server/app/alerts/page.js.nft.json +1 -0
  42. package/.next/server/app/alerts/page_client-reference-manifest.js +1 -0
  43. package/.next/server/app/alerts.html +1 -0
  44. package/.next/server/app/alerts.meta +34 -0
  45. package/.next/server/app/alerts.rsc +28 -0
  46. package/.next/server/app/alerts.segments/_full.segment.rsc +28 -0
  47. package/.next/server/app/alerts.segments/_tree.segment.rsc +4 -0
  48. package/.next/server/app/alerts.segments/alerts/__PAGE__.segment.rsc +34 -0
  49. package/.next/server/app/connections/page.js +1 -0
  50. package/.next/server/app/connections/page.js.nft.json +1 -0
  51. package/.next/server/app/connections/page_client-reference-manifest.js +1 -0
  52. package/.next/server/app/connections.html +1 -0
  53. package/.next/server/app/connections.meta +34 -0
  54. package/.next/server/app/connections.rsc +29 -0
  55. package/.next/server/app/connections.segments/_full.segment.rsc +29 -0
  56. package/.next/server/app/connections.segments/_tree.segment.rsc +4 -0
  57. package/.next/server/app/connections.segments/connections/__PAGE__.segment.rsc +35 -0
  58. package/.next/server/app/history/page.js +2 -0
  59. package/.next/server/app/history/page.js.nft.json +1 -0
  60. package/.next/server/app/history/page_client-reference-manifest.js +1 -0
  61. package/.next/server/app/history.html +1 -0
  62. package/.next/server/app/history.meta +34 -0
  63. package/.next/server/app/history.rsc +33 -0
  64. package/.next/server/app/history.segments/_full.segment.rsc +33 -0
  65. package/.next/server/app/history.segments/_tree.segment.rsc +4 -0
  66. package/.next/server/app/history.segments/history/__PAGE__.segment.rsc +37 -0
  67. package/.next/server/app/icon.svg/route.js +1 -0
  68. package/.next/server/app/icon.svg/route.js.nft.json +1 -0
  69. package/.next/server/app/icon.svg.body +1 -0
  70. package/.next/server/app/icon.svg.meta +1 -0
  71. package/.next/server/app/index.html +1 -0
  72. package/.next/server/app/index.meta +29 -0
  73. package/.next/server/app/index.rsc +26 -0
  74. package/.next/server/app/index.segments/__PAGE__.segment.rsc +31 -0
  75. package/.next/server/app/index.segments/_full.segment.rsc +26 -0
  76. package/.next/server/app/index.segments/_tree.segment.rsc +3 -0
  77. package/.next/server/app/login/page.js +1 -0
  78. package/.next/server/app/login/page.js.nft.json +1 -0
  79. package/.next/server/app/login/page_client-reference-manifest.js +1 -0
  80. package/.next/server/app/login.html +1 -0
  81. package/.next/server/app/login.meta +34 -0
  82. package/.next/server/app/login.rsc +26 -0
  83. package/.next/server/app/login.segments/_full.segment.rsc +26 -0
  84. package/.next/server/app/login.segments/_tree.segment.rsc +4 -0
  85. package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +32 -0
  86. package/.next/server/app/machines/[machineId]/page.js +1 -0
  87. package/.next/server/app/machines/[machineId]/page.js.nft.json +1 -0
  88. package/.next/server/app/machines/[machineId]/page_client-reference-manifest.js +1 -0
  89. package/.next/server/app/page.js +1 -0
  90. package/.next/server/app/page.js.nft.json +1 -0
  91. package/.next/server/app/page_client-reference-manifest.js +1 -0
  92. package/.next/server/app/processes/page.js +2 -0
  93. package/.next/server/app/processes/page.js.nft.json +1 -0
  94. package/.next/server/app/processes/page_client-reference-manifest.js +1 -0
  95. package/.next/server/app/processes.html +1 -0
  96. package/.next/server/app/processes.meta +34 -0
  97. package/.next/server/app/processes.rsc +30 -0
  98. package/.next/server/app/processes.segments/_full.segment.rsc +30 -0
  99. package/.next/server/app/processes.segments/_tree.segment.rsc +4 -0
  100. package/.next/server/app/processes.segments/processes/__PAGE__.segment.rsc +36 -0
  101. package/.next/server/app-paths-manifest.json +13 -0
  102. package/.next/server/chunks/161.js +1 -0
  103. package/.next/server/chunks/168.js +1 -0
  104. package/.next/server/chunks/266.js +68 -0
  105. package/.next/server/chunks/430.js +116 -0
  106. package/.next/server/chunks/721.js +1 -0
  107. package/.next/server/chunks/751.js +1 -0
  108. package/.next/server/chunks/877.js +1 -0
  109. package/.next/server/chunks/894.js +2 -0
  110. package/.next/server/functions-config-manifest.json +4 -0
  111. package/.next/server/interception-route-rewrite-manifest.js +1 -0
  112. package/.next/server/middleware-build-manifest.js +1 -0
  113. package/.next/server/middleware-manifest.json +6 -0
  114. package/.next/server/middleware-react-loadable-manifest.js +1 -0
  115. package/.next/server/next-font-manifest.js +1 -0
  116. package/.next/server/next-font-manifest.json +1 -0
  117. package/.next/server/pages/404.html +1 -0
  118. package/.next/server/pages/500.html +1 -0
  119. package/.next/server/pages-manifest.json +4 -0
  120. package/.next/server/prefetch-hints.json +123 -0
  121. package/.next/server/preview-props.json +5 -0
  122. package/.next/server/server-reference-manifest.js +1 -0
  123. package/.next/server/server-reference-manifest.json +1 -0
  124. package/.next/server/webpack-runtime.js +1 -0
  125. package/.next/static/NE6PGEiJxUnKRceuzUWPc/_buildManifest.js +1 -0
  126. package/.next/static/NE6PGEiJxUnKRceuzUWPc/_ssgManifest.js +1 -0
  127. package/.next/static/chunks/103-c47318242b24e9ac.js +1 -0
  128. package/.next/static/chunks/157-0d36ebf66af048ac.js +1 -0
  129. package/.next/static/chunks/227-417939c480f50747.js +1 -0
  130. package/.next/static/chunks/408-dc6158e0bb450ef6.js +1 -0
  131. package/.next/static/chunks/4bd1b696-c7408084347438ae.js +1 -0
  132. package/.next/static/chunks/794-ceeb732a1a81bc27.js +52 -0
  133. package/.next/static/chunks/939-2600d7c8e583d5ef.js +1 -0
  134. package/.next/static/chunks/app/_global-error/page-aba28f88d5781771.js +1 -0
  135. package/.next/static/chunks/app/_not-found/page-a2a510233e4836e2.js +1 -0
  136. package/.next/static/chunks/app/administration/page-4b16b19bb6a39c36.js +1 -0
  137. package/.next/static/chunks/app/alerts/page-fe0e877778c60af8.js +1 -0
  138. package/.next/static/chunks/app/connections/page-99cd54d6929b3f1f.js +1 -0
  139. package/.next/static/chunks/app/history/page-1475454737279ee0.js +3 -0
  140. package/.next/static/chunks/app/layout-4feff677c4071745.js +1 -0
  141. package/.next/static/chunks/app/login/page-c57e12dbe5146737.js +1 -0
  142. package/.next/static/chunks/app/machines/[machineId]/page-916ee73de5eb067d.js +1 -0
  143. package/.next/static/chunks/app/page-1ae9fc94c897785b.js +1 -0
  144. package/.next/static/chunks/app/processes/page-e471ed23a1d5632f.js +3 -0
  145. package/.next/static/chunks/framework-ea4f97ca039bd777.js +1 -0
  146. package/.next/static/chunks/main-a458d32948147b84.js +5 -0
  147. package/.next/static/chunks/main-app-f92328c8950d2e53.js +1 -0
  148. package/.next/static/chunks/next/dist/client/components/builtin/app-error-aba28f88d5781771.js +1 -0
  149. package/.next/static/chunks/next/dist/client/components/builtin/forbidden-aba28f88d5781771.js +1 -0
  150. package/.next/static/chunks/next/dist/client/components/builtin/global-error-43cbaa3aa1576eb4.js +1 -0
  151. package/.next/static/chunks/next/dist/client/components/builtin/not-found-aba28f88d5781771.js +1 -0
  152. package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-aba28f88d5781771.js +1 -0
  153. package/.next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
  154. package/.next/static/chunks/webpack-9ca43f4ce1bb8938.js +1 -0
  155. package/.next/static/css/e45c0c7ef5ba0336.css +1 -0
  156. package/ARCHITECTURE.md +279 -0
  157. package/CHANGELOG.md +37 -0
  158. package/DESIGN.md +299 -0
  159. package/LICENSE +21 -0
  160. package/README.md +74 -2
  161. package/SECURITY.md +12 -0
  162. package/THIRD_PARTY_NOTICES.md +8847 -0
  163. package/bin/rigscope.cjs +6 -0
  164. package/dist/cli.cjs +9075 -0
  165. package/dist/collector.cjs +5679 -0
  166. package/dist/hub.cjs +8364 -0
  167. package/dist/ops.cjs +4976 -0
  168. package/dist/system.cjs +4333 -0
  169. package/docs/bottlenecks.md +62 -0
  170. package/docs/configuration.md +85 -0
  171. package/docs/development.md +46 -0
  172. package/docs/exports.md +39 -0
  173. package/docs/installation.md +306 -0
  174. package/docs/monitoring.md +112 -0
  175. package/docs/operations.md +550 -0
  176. package/docs/releasing.md +154 -0
  177. package/docs/scale-acceptance.json +412 -0
  178. package/docs/scale-validation.json +1898 -0
  179. package/docs/scale-validation.md +294 -0
  180. package/docs/stress-2026-11-04/180301-probe-m100-u1-s1-20000ms.json +412 -0
  181. package/docs/stress-2026-11-04/180335-probe-m200-u1-s1-20000ms.json +412 -0
  182. package/docs/stress-2026-11-04/180409-probe-m400-u1-s1-20000ms.json +412 -0
  183. package/docs/stress-2026-11-04/180443-probe-m800-u1-s1-20000ms.json +412 -0
  184. package/docs/stress-2026-11-04/180518-probe-m600-u1-s1-20000ms.json +412 -0
  185. package/docs/stress-2026-11-04/180553-probe-m500-u1-s1-20000ms.json +412 -0
  186. package/docs/stress-2026-11-04/180628-probe-m550-u1-s1-20000ms.json +412 -0
  187. package/docs/stress-2026-11-04/180716-probe-m800-u1-s0-20000ms.json +415 -0
  188. package/docs/stress-2026-11-04/180751-probe-m1600-u1-s0-20000ms.json +415 -0
  189. package/docs/stress-2026-11-04/180828-probe-m3200-u1-s0-20000ms.json +416 -0
  190. package/docs/stress-2026-11-04/180941-probe-m2400-u1-s0-20000ms.json +416 -0
  191. package/docs/stress-2026-11-04/181031-probe-m2000-u1-s0-20000ms.json +416 -0
  192. package/docs/stress-2026-11-04/181114-probe-m1800-u1-s0-20000ms.json +416 -0
  193. package/docs/stress-2026-11-04/181203-probe-m100-u64-s64-20000ms.json +418 -0
  194. package/docs/stress-2026-11-04/181304-probe-m200-u64-s64-20000ms.json +418 -0
  195. package/docs/stress-2026-11-04/181405-probe-m400-u64-s64-20000ms.json +418 -0
  196. package/docs/stress-2026-11-04/181507-probe-m500-u64-s64-20000ms.json +418 -0
  197. package/docs/stress-2026-11-04/181609-probe-m450-u64-s64-20000ms.json +418 -0
  198. package/docs/stress-2026-11-04/181845-probe-m2-u2-s2-3000ms.json +419 -0
  199. package/docs/stress-2026-11-04/181931-probe-m500-u64-s64-30000ms.json +420 -0
  200. package/docs/stress-2026-11-04/182108-probe-m1800-u1-s0-120000ms.json +418 -0
  201. package/docs/stress-2026-11-04/182354-probe-m1200-u1-s0-120000ms.json +418 -0
  202. package/docs/stress-2026-11-04/182625-probe-m900-u1-s0-120000ms.json +418 -0
  203. package/docs/stress-2026-11-04/182847-probe-m1050-u1-s0-120000ms.json +418 -0
  204. package/docs/stress-2026-11-04/183112-probe-m1125-u1-s0-120000ms.json +418 -0
  205. package/docs/stress-2026-11-04/193608-probe-m500-u64-s64-120000ms.json +420 -0
  206. package/docs/stress-2026-11-04/193909-probe-m529-u1-s1-15000ms.json +420 -0
  207. package/docs/stress-2026-11-04/193940-probe-m530-u1-s1-15000ms.json +420 -0
  208. package/docs/stress-2026-11-04/194011-probe-m100-u1-s65-10000ms.json +421 -0
  209. package/docs/stress-2026-11-04/README.md +205 -0
  210. package/docs/stress-2026-11-04/index.jsonl +29 -0
  211. package/docs/stress-2026-11-04/manifest.json +13 -0
  212. package/docs/stress-2026-11-04/results.html +22 -0
  213. package/docs/system-installation.md +195 -0
  214. package/next.config.js +38 -0
  215. package/package.json +117 -4
  216. package/packaging/README.md +5 -0
  217. package/packaging/collector.env.example +24 -0
  218. package/packaging/hub.env.example +31 -0
  219. package/packaging/system/90-rigscope-rapl.rules +7 -0
  220. package/packaging/system/README.md +5 -0
  221. package/packaging/system/rigscope-collector.service.example +53 -0
  222. package/packaging/system/rigscope-hub.service.example +50 -0
  223. package/packaging/system/rigscope-rapl.sysusers +5 -0
  224. package/packaging/system/rigscope.sysusers +7 -0
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[939],{592:(e,t,r)=>{r.d(t,{U8:()=>n,Q_:()=>l,FZ:()=>T});let n=1024,i=Date.parse("2000-01-01T00:00:00Z"),s=Date.parse("2200-01-01T00:00:00Z"),a=["metrics","inventory","processes"],o=["cpu","memory","swap","gpus","disks","network"],u=["outbox-age","outbox-bytes","disk-budget","write-failure","rejected"];function l(e){let t=b(e,"collector message");switch(t.type){case"hello":{k(t,["type","collectorId","runId","bootId","hostname","capabilities","expectedIntervalMs","collectorVersion"],"hello");let e=$(t.capabilities,"hello.capabilities",1,a.length).map(e=>A(e,a,"hello.capabilities"));if(new Set(e).size!==e.length||!e.includes("metrics"))throw Error("invalid hello: capabilities must be unique and include metrics");return{type:"hello",collectorId:E(t.collectorId,"collectorId"),runId:E(t.runId,"runId"),bootId:B(t.bootId,"bootId",0,128),hostname:B(t.hostname,"hostname",0,255),capabilities:e,expectedIntervalMs:P(t.expectedIntervalMs,"expectedIntervalMs",100,72e5),collectorVersion:B(t.collectorVersion,"collectorVersion",1,64)}}case"samples":{k(t,["type","mode","records"],"samples");let e=A(t.mode,["live","replay"],"samples.mode"),r=$(t.records,"samples.records",1,32).map((e,t)=>d(e,`records[${t}]`)),n=new Set;for(let e of r){let t=`${e.runId}\0${e.sequence}`;if(n.has(t))throw Error("invalid samples: duplicate record in batch");n.add(t)}return{type:"samples",mode:e,records:r}}case"inventory":return k(t,["type","capturedAt","inventory"],"inventory"),{type:"inventory",capturedAt:x(t.capturedAt,"capturedAt"),inventory:c(t.inventory)};case"status":return k(t,["type","capturedAt","delivery","failures"],"status"),{type:"status",capturedAt:x(t.capturedAt,"capturedAt"),delivery:function(e){let t=b(e,"delivery");if(k(t,["pendingRecords","pendingBytes","oldestPendingCapturedAt","inFlightRecords","droppedRecords","replaying","lastAckAt"],"delivery"),"boolean"!=typeof t.replaying)throw Error("invalid delivery: replaying");let r=(e,t)=>P(e,t,0,Number.MAX_SAFE_INTEGER);return{pendingRecords:r(t.pendingRecords,"pendingRecords"),pendingBytes:r(t.pendingBytes,"pendingBytes"),oldestPendingCapturedAt:v(t.oldestPendingCapturedAt,e=>x(e,"oldestPendingCapturedAt")),inFlightRecords:r(t.inFlightRecords,"inFlightRecords"),droppedRecords:r(t.droppedRecords,"droppedRecords"),replaying:t.replaying,lastAckAt:v(t.lastAckAt,e=>x(e,"lastAckAt"))}}(t.delivery),failures:$(t.failures,"failures",0,32).map(e=>{let t=b(e,"failure");return k(t,["metric","resourceId","reason"],"failure"),{metric:B(t.metric,"metric",1,64),resourceId:null===t.resourceId?null:I(t.resourceId),reason:B(t.reason,"reason",0,256)}})};case"detail.result":return k(t,["type","subscriptionId","capturedAt","snapshot"],"detail.result"),{type:"detail.result",subscriptionId:E(t.subscriptionId,"subscriptionId"),capturedAt:x(t.capturedAt,"capturedAt"),snapshot:function(e){let t=b(e,"process snapshot");if(k(t,["totalProcesses","truncated","inaccessible","processes"],"process snapshot"),"boolean"!=typeof t.truncated)throw Error("invalid process snapshot: truncated");let r=(e,t,r)=>v(e,e=>S(e,t,0,r));return{totalProcesses:P(t.totalProcesses,"totalProcesses",0,1e7),truncated:t.truncated,inaccessible:P(t.inaccessible,"inaccessible",0,1e7),processes:$(t.processes,"processes",0,6e3).map(e=>{let t=b(e,"process");k(t,["pid","ppid","startTicks","name","user","state","cpuPercent","memoryRssBytes","gpuMemoryBytes","ioReadBytesPerSec","ioWriteBytesPerSec","threads","unit"],"process",["command"]);let i={pid:P(t.pid,"pid",0,0x80000000),ppid:P(t.ppid,"ppid",0,0x80000000),startTicks:P(t.startTicks,"startTicks",0,Number.MAX_SAFE_INTEGER),name:B(t.name,"name",0,256),user:v(t.user,e=>B(e,"user",0,64)),state:B(t.state,"state",0,16),cpuPercent:r(t.cpuPercent,"cpuPercent",100*n),memoryRssBytes:v(t.memoryRssBytes,e=>P(e,"memoryRssBytes",0,Number.MAX_SAFE_INTEGER)),gpuMemoryBytes:v(t.gpuMemoryBytes,e=>P(e,"gpuMemoryBytes",0,Number.MAX_SAFE_INTEGER)),ioReadBytesPerSec:r(t.ioReadBytesPerSec,"ioReadBytesPerSec",1e13),ioWriteBytesPerSec:r(t.ioWriteBytesPerSec,"ioWriteBytesPerSec",1e13),threads:v(t.threads,e=>P(e,"threads",0,1e7)),unit:v(t.unit,e=>B(e,"unit",1,256))};return w(t,"command")&&(i.command=B(t.command,"command",0,4096)),i})}}(t.snapshot)};case"detail.ended":return k(t,["type","subscriptionId","reason"],"detail.ended"),{type:"detail.ended",subscriptionId:E(t.subscriptionId,"subscriptionId"),reason:A(t.reason,["expired","cancelled","withheld","unsupported","busy","failed"],"detail.ended.reason")};default:throw Error(`invalid collector message: unsupported type ${M(t.type)}`)}}function d(e,t="record"){let r=b(e,t);k(r,["collectorId","runId","bootId","sequence","capturedAt","kind","payload"],t);let i={collectorId:E(r.collectorId,"collectorId"),runId:E(r.runId,"runId"),bootId:B(r.bootId,"bootId",0,128),sequence:P(r.sequence,"sequence",0,Number.MAX_SAFE_INTEGER),capturedAt:x(r.capturedAt,"capturedAt")};if("metrics"===r.kind){let e;return{...i,kind:"metrics",payload:(k(e=b(r.payload,"metrics payload"),[...o],"metrics payload"),{cpu:y(e.cpu,"cpu",e=>{k(e,["status","usagePercent","perCore"],"cpu",["temperatureC","powerWatts","iowaitPercent","pressureSomePercent"]);let t={status:"ok",usagePercent:S(e.usagePercent,"usagePercent",0,100),perCore:$(e.perCore,"perCore",0,n).map(e=>null===e?null:S(e,"perCore",0,100))},r=g(e,"temperatureC",e=>S(e,"temperatureC",-50,200));void 0!==r&&(t.temperatureC=r);let i=g(e,"powerWatts",e=>S(e,"powerWatts",0,1e4));void 0!==i&&(t.powerWatts=i);let s=g(e,"iowaitPercent",e=>S(e,"iowaitPercent",0,100));void 0!==s&&(t.iowaitPercent=s);let a=g(e,"pressureSomePercent",e=>S(e,"pressureSomePercent",0,100));return void 0!==a&&(t.pressureSomePercent=a),t}),memory:y(e.memory,"memory",m),swap:y(e.swap,"swap",p),gpus:y(e.gpus,"gpus",e=>(k(e,["status","devices"],"gpus"),{status:"ok",devices:h($(e.devices,"gpus.devices",0,16).map(e=>f(e,"gpu",(e,t)=>{k(e,["id","status","utilizationPercent","memoryUsedBytes","memoryTotalBytes","temperatureC","powerWatts"],"gpu");let r=v(e.memoryUsedBytes,e=>P(e,"memoryUsedBytes",0,Number.MAX_SAFE_INTEGER)),n=v(e.memoryTotalBytes,e=>P(e,"memoryTotalBytes",0,Number.MAX_SAFE_INTEGER));if(null!==r&&null!==n&&r>n)throw Error("invalid gpu: memoryUsedBytes exceeds total");return{id:t,status:"ok",utilizationPercent:v(e.utilizationPercent,e=>S(e,"utilizationPercent",0,100)),memoryUsedBytes:r,memoryTotalBytes:n,temperatureC:v(e.temperatureC,e=>S(e,"temperatureC",-50,200)),powerWatts:v(e.powerWatts,e=>S(e,"powerWatts",0,1e4))}})))})),disks:y(e.disks,"disks",e=>{k(e,["status","filesystems","devices"],"disks",["pressureSomePercent","pressureFullPercent"]);let t={status:"ok",filesystems:h($(e.filesystems,"filesystems",0,64).map(e=>f(e,"filesystem",(e,t)=>{k(e,["id","status","usedBytes","totalBytes"],"filesystem",["inodesUsed","inodesTotal"]);let r=p({status:"ok",usedBytes:e.usedBytes,totalBytes:e.totalBytes}),n={id:t,status:"ok",usedBytes:r.usedBytes,totalBytes:r.totalBytes},i=g(e,"inodesUsed",e=>P(e,"inodesUsed",0,Number.MAX_SAFE_INTEGER));void 0!==i&&(n.inodesUsed=i);let s=g(e,"inodesTotal",e=>P(e,"inodesTotal",0,Number.MAX_SAFE_INTEGER));if(void 0!==s&&(n.inodesTotal=s),null!=i&&null!=s&&i>s)throw Error("invalid filesystem: inodesUsed exceeds inodesTotal");return n}))),devices:h($(e.devices,"disk devices",0,64).map(e=>f(e,"disk",(e,t)=>{k(e,["id","status","readBytesPerSec","writeBytesPerSec"],"disk",["readLatencyMs","writeLatencyMs","ioUtilizationPercent"]);let r={id:t,status:"ok",readBytesPerSec:S(e.readBytesPerSec,"readBytesPerSec",0,1e13),writeBytesPerSec:S(e.writeBytesPerSec,"writeBytesPerSec",0,1e13)},n=g(e,"readLatencyMs",e=>S(e,"readLatencyMs",0,864e5));void 0!==n&&(r.readLatencyMs=n);let i=g(e,"writeLatencyMs",e=>S(e,"writeLatencyMs",0,864e5));void 0!==i&&(r.writeLatencyMs=i);let s=g(e,"ioUtilizationPercent",e=>S(e,"ioUtilizationPercent",0,100));return void 0!==s&&(r.ioUtilizationPercent=s),r})))},r=g(e,"pressureSomePercent",e=>S(e,"pressureSomePercent",0,100));void 0!==r&&(t.pressureSomePercent=r);let n=g(e,"pressureFullPercent",e=>S(e,"pressureFullPercent",0,100));return void 0!==n&&(t.pressureFullPercent=n),t}),network:y(e.network,"network",e=>(k(e,["status","interfaces"],"network"),{status:"ok",interfaces:h($(e.interfaces,"interfaces",0,64).map(e=>f(e,"interface",(e,t)=>(k(e,["id","status","rxBytesPerSec","txBytesPerSec"],"interface"),{id:t,status:"ok",rxBytesPerSec:S(e.rxBytesPerSec,"rxBytesPerSec",0,1e13),txBytesPerSec:S(e.txBytesPerSec,"txBytesPerSec",0,1e13)}))))}))})}}if("gap"===r.kind){let e=b(r.payload,`${t}.payload`);k(e,["fromCapturedAt","toCapturedAt","droppedRecords","reason"],"gap payload");let n=x(e.fromCapturedAt,"fromCapturedAt"),s=x(e.toCapturedAt,"toCapturedAt");if(Date.parse(n)>Date.parse(s))throw Error("invalid gap: fromCapturedAt after toCapturedAt");return{...i,kind:"gap",payload:{fromCapturedAt:n,toCapturedAt:s,droppedRecords:P(e.droppedRecords,"droppedRecords",1,Number.MAX_SAFE_INTEGER),reason:A(e.reason,u,"gap.reason")}}}throw Error(`invalid ${t}: unsupported kind ${M(r.kind)}`)}function c(e){let t=b(e,"inventory");k(t,["os","cpu","memory","gpus","filesystems","disks","network","capabilities"],"inventory");let r=b(t.os,"inventory.os");k(r,["platform","release","distro","arch"],"inventory.os");let i=b(t.cpu,"inventory.cpu");k(i,["model","logicalCores"],"inventory.cpu");let s=b(t.memory,"inventory.memory");k(s,["totalBytes","swapTotalBytes"],"inventory.memory");let a=b(t.capabilities,"inventory.capabilities"),u=[...o,"processes"];k(a,[...u],"inventory.capabilities");let l={};for(let e of u){let t=b(a[e],`capability ${e}`);k(t,["status"],`capability ${e}`,["reason"]);let r={status:A(t.status,["supported","unsupported","withheld"],`capability ${e}`)};w(t,"reason")&&(r.reason=B(t.reason,"reason",0,256)),l[e]=r}let d=(e,t)=>v(e,e=>P(e,t,0,Number.MAX_SAFE_INTEGER));return{os:{platform:B(r.platform,"platform",0,64),release:B(r.release,"release",0,256),distro:v(r.distro,e=>B(e,"distro",0,256)),arch:B(r.arch,"arch",0,64)},cpu:{model:v(i.model,e=>B(e,"model",0,256)),logicalCores:P(i.logicalCores,"logicalCores",0,n)},memory:{totalBytes:d(s.totalBytes,"totalBytes"),swapTotalBytes:d(s.swapTotalBytes,"swapTotalBytes")},gpus:h($(t.gpus,"inventory.gpus",0,16).map(e=>{let t=b(e,"gpu inventory");k(t,["id","name","vendor","pciBusId","telemetry","memoryTotalBytes"],"gpu inventory",["reason"]);let r={id:I(t.id),name:B(t.name,"name",0,256),vendor:A(t.vendor,["nvidia","amd","intel","aspeed","other"],"vendor"),pciBusId:v(t.pciBusId,e=>B(e,"pciBusId",1,64)),telemetry:A(t.telemetry,["supported","unsupported"],"telemetry"),memoryTotalBytes:d(t.memoryTotalBytes,"memoryTotalBytes")};return w(t,"reason")&&(r.reason=B(t.reason,"reason",0,256)),r})),filesystems:h($(t.filesystems,"inventory.filesystems",0,64).map(e=>{let t=b(e,"filesystem inventory");return k(t,["id","mountPoint","device","fsType","totalBytes"],"filesystem inventory"),{id:I(t.id),mountPoint:B(t.mountPoint,"mountPoint",1,256),device:B(t.device,"device",0,256),fsType:B(t.fsType,"fsType",0,64),totalBytes:d(t.totalBytes,"totalBytes")}})),disks:h($(t.disks,"inventory.disks",0,64).map(e=>{let t=b(e,"disk inventory");if(k(t,["id","name","model","rotational","sizeBytes"],"disk inventory"),null!==t.rotational&&"boolean"!=typeof t.rotational)throw Error("invalid disk inventory: rotational");return{id:I(t.id),name:B(t.name,"name",1,64),model:v(t.model,e=>B(e,"model",0,256)),rotational:t.rotational,sizeBytes:d(t.sizeBytes,"sizeBytes")}})),network:h($(t.network,"inventory.network",0,64).map(e=>{let t=b(e,"interface inventory");if(k(t,["id","name","mac","addresses","virtual","state","speedMbps"],"interface inventory"),"boolean"!=typeof t.virtual)throw Error("invalid interface inventory: virtual");return{id:I(t.id),name:B(t.name,"name",1,64),mac:v(t.mac,e=>B(e,"mac",1,64)),addresses:$(t.addresses,"addresses",0,32).map(e=>{let t=b(e,"address");k(t,["family","address","prefix"],"address");let r=A(t.family,["ipv4","ipv6"],"family");return{family:r,address:B(t.address,"address",2,64),prefix:P(t.prefix,"prefix",0,"ipv4"===r?32:128)}}),virtual:t.virtual,state:A(t.state,["up","down","unknown"],"state"),speedMbps:v(t.speedMbps,e=>P(e,"speedMbps",0,1e7))}})),capabilities:l}}function p(e){k(e,["status","usedBytes","totalBytes"],"usage");let t=P(e.totalBytes,"totalBytes",0,Number.MAX_SAFE_INTEGER),r=P(e.usedBytes,"usedBytes",0,Number.MAX_SAFE_INTEGER);if(r>t)throw Error("invalid usage: usedBytes exceeds totalBytes");return{status:"ok",usedBytes:r,totalBytes:t}}function m(e){k(e,["status","usedBytes","totalBytes"],"memory",["pressureSomePercent","pressureFullPercent"]);let t=P(e.totalBytes,"totalBytes",0,Number.MAX_SAFE_INTEGER),r=P(e.usedBytes,"usedBytes",0,Number.MAX_SAFE_INTEGER);if(r>t)throw Error("invalid memory: usedBytes exceeds totalBytes");let n={status:"ok",usedBytes:r,totalBytes:t},i=g(e,"pressureSomePercent",e=>S(e,"pressureSomePercent",0,100));void 0!==i&&(n.pressureSomePercent=i);let s=g(e,"pressureFullPercent",e=>S(e,"pressureFullPercent",0,100));return void 0!==s&&(n.pressureFullPercent=s),n}function y(e,t,r){let n=b(e,t);if("ok"===n.status)return r(n);if("unavailable"===n.status)return k(n,["status","reason"],t),{status:"unavailable",reason:B(n.reason,"reason",0,256)};throw Error(`invalid ${t}: unsupported status ${M(n.status)}`)}function f(e,t,r){let n=b(e,t),i=I(n.id);if("ok"===n.status)return r(n,i);if("unavailable"===n.status)return k(n,["id","status","reason"],t),{id:i,status:"unavailable",reason:B(n.reason,"reason",0,256)};throw Error(`invalid ${t}: unsupported status ${M(n.status)}`)}function h(e){let t=new Set;for(let r of e){if(t.has(r.id))throw Error(`invalid resource list: duplicate id ${M(r.id)}`);t.add(r.id)}return e}function v(e,t){return null===e?null:t(e)}function g(e,t,r){if(w(e,t))return v(e[t],r)}function b(e,t){if(null===e||"object"!=typeof e||Array.isArray(e))throw Error(`invalid ${t}: expected object, got ${M(e)}`);return e}function k(e,t,r,n=[]){let i=new Set([...t,...n]);for(let t of Object.keys(e))if(!i.has(t))throw Error(`invalid ${r}: unexpected field "${t}"`);for(let n of t)if(void 0===e[n])throw Error(`invalid ${r}: missing field "${n}"`);for(let t of n)if(w(e,t)&&void 0===e[t])throw Error(`invalid ${r}: ${t} must not be undefined`)}function w(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function $(e,t,r,n){if(!Array.isArray(e))throw Error(`invalid ${t}: expected array`);if(e.length<r||e.length>n)throw Error(`invalid ${t}: length ${e.length} outside ${r}..${n}`);return e}function A(e,t,r){if("string"!=typeof e||!t.includes(e))throw Error(`invalid ${r}: unexpected value ${M(e)}`);return e}function B(e,t,r,n){if("string"!=typeof e)throw Error(`invalid ${t}: expected string, got ${M(e)}`);if(e.length<r||e.length>n)throw Error(`invalid ${t}: length ${e.length} outside ${r}..${n}`);return e}function E(e,t){return B(e,t,1,128)}function I(e){return B(e,"resource id",1,256)}function P(e,t,r,n){if("number"!=typeof e||!Number.isSafeInteger(e))throw Error(`invalid ${t}: expected safe integer, got ${M(e)}`);if(e<r||e>n)throw Error(`invalid ${t}: ${e} outside ${r}..${n}`);return e}function S(e,t,r,n){if("number"!=typeof e||!Number.isFinite(e))throw Error(`invalid ${t}: expected finite number, got ${M(e)}`);if(e<r||e>n)throw Error(`invalid ${t}: ${e} outside ${r}..${n}`);return e}function x(e,t){let r=B(e,t,1,64),n=Date.parse(r);if(!Number.isFinite(n)||n<i||n>s)throw Error(`invalid ${t}: not a parseable timestamp`);return r}function M(e){try{let t=JSON.stringify(e);if("string"==typeof t)return t.length<=80?t:`${t.slice(0,77)}...`}catch{}return String(e)}function T(e){let t=C(e,"hub snapshot");_(t,["hubRunId","machines"],"hub snapshot");let r=j(t.hubRunId,"hubRunId","hub snapshot");if(!Array.isArray(t.machines))throw Error("invalid snapshot machines");let n=new Set;return{hubRunId:r,machines:t.machines.map(e=>{let t=C(e,"machine");_(t,["machineId","collectorId","hostname","connected","lastReceivedAt"],"machine",["expectedIntervalMs","metrics","inventory","delivery","displayName","tags"]);let r=j(t.machineId,"machineId","machine");if(n.has(r))throw Error("duplicate snapshot machine");n.add(r);let i=j(t.collectorId,"collectorId","machine"),s=z(t.hostname,"hostname","machine",0,N);if("boolean"!=typeof t.connected)throw Error("invalid machine connection state");let a=null===t.lastReceivedAt?null:D(t.lastReceivedAt,"lastReceivedAt","machine"),o={},u=L(t,"expectedIntervalMs")?function(e,t,r){if(null===e)return null;if(void 0===e)throw Error(`invalid ${r}: ${t} must not be undefined`);var n=e,i=t,s=r;if("number"!=typeof n||!Number.isSafeInteger(n))throw Error(`invalid ${s}: ${i} must be a safe integer, got ${G(n)}`);if(n<100||n>72e5)throw Error(`invalid ${s}: ${i} ${n} outside ${100}..${72e5}`);return n}(t.expectedIntervalMs,"expectedIntervalMs","machine"):void 0;if(L(t,"metrics")){let{receivedAt:e,...r}=C(t.metrics,"received metrics"),n=d(r);if("metrics"!==n.kind||n.collectorId!==i)throw Error("conflicting machine metrics");if(o.metrics={...n,receivedAt:D(e,"receivedAt","metrics")},o.metrics.receivedAt!==a)throw Error("conflicting metrics receipt time")}if(L(t,"inventory")&&(o.inventory=c(t.inventory)),L(t,"delivery")){let e=l(t.delivery);if("status"!==e.type)throw Error("invalid delivery status");o.delivery=e}if(L(t,"displayName")&&(o.displayName=null===t.displayName?null:z(t.displayName,"displayName","machine",0,128)),L(t,"tags")){if(!Array.isArray(t.tags)||t.tags.length>32)throw Error("invalid machine tags");o.tags=t.tags.map(e=>z(e,"tag","machine",1,64))}return{machineId:r,collectorId:i,hostname:s,connected:t.connected,lastReceivedAt:a,...void 0===u?{}:{expectedIntervalMs:u},...o}})}}let N=255,R=Date.parse("2000-01-01T00:00:00Z"),F=Date.parse("2200-01-01T00:00:00Z");function C(e,t){if(null===e||"object"!=typeof e||Array.isArray(e))throw Error(`invalid ${t}: expected object, got ${G(e)}`);return e}function _(e,t,r,n=[]){let i=new Set([...t,...n]);for(let t of Object.keys(e))if(!i.has(t))throw Error(`invalid ${r}: unexpected field "${t}"`);for(let n of t)if(void 0===e[n])throw Error(`invalid ${r}: missing field "${n}"`);for(let t of n)if(L(e,t)&&void 0===e[t])throw Error(`invalid ${r}: ${t} must not be undefined`)}function L(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function j(e,t,r){return z(e,t,r,1,128)}function z(e,t,r,n,i){if("string"!=typeof e)throw Error(`invalid ${r}: ${t} must be a string, got ${G(e)}`);if(e.length<n||e.length>i)throw Error(`invalid ${r}: ${t} length ${e.length} outside ${n}..${i}`);return e}function D(e,t,r){let n=z(e,t,r,1,64),i=Date.parse(n);if(!Number.isFinite(i)||i<R||i>F)throw Error(`invalid ${r}: ${t} is not a parseable timestamp`);return n}function G(e){try{let t=JSON.stringify(e);if("string"==typeof t)return t.length<=80?t:`${t.slice(0,77)}...`}catch{}return String(e)}},4334:(e,t,r)=>{r.d(t,{K:()=>o,g:()=>s});var n=r(5887),i=r(7586);function s(e,t){let r=new Map;for(let s of t.machines){let a=s.metrics;if(!a)continue;let o=`${t.hubRunId}\0${a.collectorId}\0${a.runId}\0${a.sequence}`,u=e.get(s.machineId)??[],l=u.at(-1);if(l?.sampleId===o){r.set(s.machineId,u);continue}let d=o.slice(0,o.lastIndexOf("\0")+1),c=l?.sampleId.startsWith(d)?u:[],p=a.payload.memory;r.set(s.machineId,[...c,{sampleId:o,receivedAtLocal:Date.parse(a.receivedAt),cpuPercent:"ok"===a.payload.cpu.status?a.payload.cpu.usagePercent:null,memoryPercent:"ok"===p.status&&p.totalBytes>0?100*p.usedBytes/p.totalBytes:null,gapThresholdMs:(0,i.Cj)(s.expectedIntervalMs)}].slice(-n.yY))}return r}function a(e){return"number"==typeof e.gapThresholdMs&&Number.isFinite(e.gapThresholdMs)&&e.gapThresholdMs>0?e.gapThresholdMs:n.vz}function o(e,t=600,r=140){let i;if(e.length<2)return null;let s=e[0].receivedAtLocal,u=Math.max(1e3,e.at(-1).receivedAtLocal-s),l="";for(let o of e){if(null===o.cpuPercent){i=void 0;continue}let e=4+(o.receivedAtLocal-s)/u*(t-8),d=r-4-o.cpuPercent/100*(r-8),c=i?Math.min(a(i),a(o)):n.vz,p=i&&o.receivedAtLocal>=i.receivedAtLocal&&o.receivedAtLocal-i.receivedAtLocal<c;l+=`${p?"L":"M"}${e.toFixed(2)},${d.toFixed(2)} `,i=o}return l.trim()||null}},5887:(e,t,r)=>{r.d(t,{mq:()=>i,vz:()=>n,yY:()=>s});let n=15e3,i=9e4,s=180},7586:(e,t,r)=>{r.d(t,{$:()=>s,A4:()=>d,Cj:()=>i,F2:()=>m,L_:()=>p,fv:()=>c,l9:()=>u,nV:()=>l,vj:()=>a,z3:()=>o});var n=r(5887);function i(e){return null==e||"number"!=typeof e||!Number.isFinite(e)||e<=0?n.vz:Math.max(n.vz,3*e)}function s(e){if(null==e||!Number.isFinite(e)||e<0)return"—";if(e<6e4){let t=e/1e3;return Number.isInteger(t)?`${t} s`:`${t.toFixed(1)} s`}if(e<36e5){let t=e/6e4;return Number.isInteger(t)?`${t} min`:`${t.toFixed(1)} min`}let t=e/36e5;return Number.isInteger(t)?`${t} h`:`${t.toFixed(1)} h`}function a(e,t,r=i(e.expectedIntervalMs)){return function(e,t,r=n.vz){if(null===e)return"unknown";let i=Date.parse(e);return Number.isFinite(i)?t-i>=r?"stale":"live":"unknown"}(e.lastReceivedAt,t,r)}function o(e){if(null==e||!Number.isFinite(e)||e<0)return"—";let t=["B","KiB","MiB","GiB","TiB"],r=e,n=0;for(;r>=1024&&n<t.length-1;)r/=1024,n+=1;return 0===n?`${Math.round(r)} B`:`${r.toFixed(1)} ${t[n]}`}function u(e){return null!=e&&Number.isFinite(e)?`${e.toFixed(1)}%`:"—"}function l(e){if(null===e||!Number.isFinite(e))return"—";let t=Math.round(Math.max(0,e)/1e3);if(t<60)return`${t}s ago`;let r=Math.floor(t/60);if(r<60){let e=t%60;return 0===e?`${r}m ago`:`${r}m ${e}s ago`}let n=Math.floor(r/60);if(n<24){let e=r%60;return 0===e?`${n}h ago`:`${n}h ${e}m ago`}let i=Math.floor(n/24),s=n%24;return 0===s?`${i}d ago`:`${i}d ${s}h ago`}function d(e,t){if(null===e)return null;let r=Date.parse(e);return Number.isFinite(r)?t-r:null}function c(e){switch(e){case"ok":return"Live";case"degraded":return"Degraded";case"stale":return"Stale";case"disconnected":return"Disconnected";case"unseen":return"No sample yet"}}function p(e,t=n.mq){let r=e.metrics;if(!r)return{kind:"unknown"};let i=Date.parse(r.capturedAt),s=Date.parse(r.receivedAt);if(!Number.isFinite(i)||!Number.isFinite(s))return{kind:"unknown"};let a=i-s;return a>t?{kind:"ahead",skewMs:a}:a<-t?{kind:"behind",skewMs:-a}:{kind:"none"}}function m(e,t,r=i(e.expectedIntervalMs)){return{freshness:a(e,t,r),attention:function(e,t,r=i(e.expectedIntervalMs)){var n;let s=a(e,t,r);return e.metrics&&"unknown"!==s?"stale"===s?"stale":(n=e.metrics)&&("unavailable"===n.payload.cpu.status||"unavailable"===n.payload.memory.status)?"degraded":e.connected?"ok":"disconnected":"unseen"}(e,t,r),connection:e.connected?"connected":"disconnected",skew:p(e),thresholdMs:r}}},9939:(e,t,r)=>{r.d(t,{LiveProvider:()=>g,M:()=>v});var n=r(5155),i=r(2115);async function s(e){try{let t=await e.json();if(t&&"object"==typeof t&&"error"in t){let e=t.error;if("string"==typeof e)return e}}catch{}return e.statusText||null}function a(e){if(!e||"object"!=typeof e)return null;let t=e.username,r=e.csrfToken;if("string"!=typeof t||0===t.length||"string"!=typeof r||0===r.length)return null;let n=e.admin;return void 0!==n&&"boolean"!=typeof n?null:{username:t,csrfToken:r,...!0===n?{admin:!0}:{}}}async function o(){try{let e=await fetch("/api/auth/session",{cache:"no-store",signal:AbortSignal.timeout(5e3),headers:{Accept:"application/json"}});if(e.ok){try{let t=a(await e.json());if(t)return{kind:"signed-in",user:t}}catch{}return{kind:"error",detail:"unexpected session response"}}if(401===e.status)return{kind:"signed-out"};if(503===e.status)return{kind:"auth-unavailable",detail:await s(e)};return{kind:"error",detail:`unexpected status ${e.status}`}}catch{return{kind:"unreachable"}}}async function u(e,t){try{let r=await fetch("/api/auth/login",{method:"POST",cache:"no-store",signal:AbortSignal.timeout(5e3),headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({username:e,password:t})});if(r.ok){try{let e=a(await r.json());if(e)return{kind:"signed-in",user:e}}catch{}return{kind:"error",detail:"unexpected sign-in response"}}if(401===r.status)return{kind:"invalid-credentials",detail:await s(r)};if(429===r.status)return{kind:"error",detail:"too many attempts — wait a moment and try again"};if(503===r.status)return{kind:"auth-unavailable",detail:await s(r)};return{kind:"error",detail:`unexpected status ${r.status}`}}catch{return{kind:"unreachable"}}}async function l(e){try{let t=await fetch("/api/auth/logout",{method:"POST",cache:"no-store",signal:AbortSignal.timeout(5e3),headers:{"X-CSRF-Token":e,Accept:"application/json"}});if(t.ok||401===t.status)return"ok";return t.status,{kind:"error",detail:`unexpected status ${t.status}`}}catch{return"unreachable"}}async function d(e=5e3){let t=new AbortController,r=setTimeout(()=>t.abort(),e);try{let e=await fetch("/api/live",{cache:"no-store",signal:t.signal,headers:{Accept:"text/event-stream"}});if(200===e.status)return{kind:"ok"};if(401===e.status)return{kind:"unauthorized"};if(403===e.status)return{kind:"forbidden"};return{kind:"error",detail:`unexpected status ${e.status}`}}catch{return{kind:"unreachable"}}finally{clearTimeout(r);try{t.abort()}catch{}}}var c=r(592);let p=["snapshot","update","reset"];class m{source=null;lastId=null;get lastEventId(){return this.lastId}get isOpen(){return null!==this.source&&2!==this.source.readyState}start(e,t){this.close();let r=new EventSource(e);this.source=r;let n=e=>n=>{if(this.source!==r||null===this.source)return;let i=n.lastEventId;"string"==typeof i&&i.length>0&&(this.lastId=i);try{t.onSnapshot((0,c.FZ)(JSON.parse(n.data)),e,i??"")}catch{this.close(),t.onError()}};for(let e of p)r.addEventListener(e,n(e));r.onerror=()=>{this.source===r&&(this.close(),t.onError())}}close(){this.source?.close(),this.source=null}}var y=r(4334);let f=[1e3,2e3,4e3,8e3,15e3],h=(0,i.createContext)(null);function v(){let e=(0,i.useContext)(h);if(!e)throw Error("useLive must be used inside <LiveProvider>");return e}function g({children:e}){let[t,r]=(0,i.useState)({kind:"restoring"}),[s,a]=(0,i.useState)("idle"),[c,p]=(0,i.useState)(null),[v,b]=(0,i.useState)([]),[k,w]=(0,i.useState)(null),[$,A]=(0,i.useState)(null),[B,E]=(0,i.useState)(null),[I,P]=(0,i.useState)(null),[S,x]=(0,i.useState)(new Map),M=(0,i.useRef)(!0),T=(0,i.useRef)(0),N=(0,i.useRef)(null),R=(0,i.useRef)(null),F=(0,i.useRef)(0),C=(0,i.useRef)(t),_=(0,i.useRef)(0),L=(0,i.useRef)(!1),j=(0,i.useRef)(!1),z=e=>{C.current=e,r(e)},D=()=>{null!==R.current&&(clearTimeout(R.current),R.current=null)},G=()=>{_.current+=1,T.current+=1,N.current?.close(),N.current=null,D()},X=()=>{L.current=!1,b([]),x(new Map),p(null),A(null),E(null),w(null)},O=e=>{let t=C.current;("signed-in"!==t.kind||t.user.csrfToken!==e.csrfToken)&&X(),z({kind:"signed-in",user:e})},U=()=>{if("signed-in"!==C.current.kind)return;G(),a(L.current?"reconnecting":"connecting");let e=new m;N.current=e,e.start("/api/live",{onSnapshot:(t,r,n)=>{M.current&&N.current===e&&(F.current=0,L.current=!0,p(t.hubRunId),b(t.machines),w(Date.now()),A(n||null),E(r),x(e=>(0,y.g)(e,t)),a("live"))},onError:()=>{M.current&&N.current===e&&W()}})},W=async()=>{G();let e=_.current;a("reconnecting");let t=await o();if(!M.current||e!==_.current)return;if("signed-in"===t.kind)O(t.user);else if("signed-out"===t.kind){z({kind:"signed-out"}),X(),a("expired");return}else if("auth-unavailable"===t.kind){z({kind:"auth-unavailable",detail:t.detail}),X(),a("idle");return}let r=Math.min(F.current+1,f.length+1);if(F.current=r,r>f.length){a("disconnected"),Z();return}a("reconnecting"),R.current=setTimeout(()=>{q()},f[r-1])},q=async()=>{if(!M.current||j.current)return;G();let e=_.current,t=await d();if(M.current&&e===_.current){if("forbidden"===t.kind){X(),a("no-permission");return}if("unauthorized"===t.kind){let t=await o();if(!M.current||e!==_.current)return;if("signed-in"===t.kind){O(t.user),U();return}if("signed-out"===t.kind){z({kind:"signed-out"}),X(),a("expired");return}if("auth-unavailable"===t.kind){z({kind:"auth-unavailable",detail:t.detail}),X(),a("idle");return}}U()}},Z=()=>{D(),R.current=setTimeout(()=>{V()},3e4)},V=async()=>{if(!M.current||j.current)return;G();let e=_.current,t=await o();if(M.current&&e===_.current){if("signed-in"===t.kind){O(t.user),U();return}if("signed-out"===t.kind){z({kind:"signed-out"}),X(),a("expired");return}if("auth-unavailable"===t.kind){z({kind:"auth-unavailable",detail:t.detail}),X(),a("idle");return}Z()}},J=async e=>{let t=_.current,r=await o();if(M.current&&T.current===e&&t===_.current){if("signed-in"===r.kind){O(r.user),F.current=0,U();return}if("signed-out"===r.kind){z({kind:"signed-out"}),a("idle");return}if("auth-unavailable"===r.kind){z({kind:"auth-unavailable",detail:r.detail}),a("idle");return}z({kind:"restore-failed",detail:"error"===r.kind?r.detail:null}),a("idle")}},K=async(e,t)=>{G();let r=_.current,n=await u(e,t);return M.current&&r===_.current?("signed-in"===n.kind&&M.current&&(O(n.user),P(null),F.current=0,U()),n):{kind:"error",detail:"Session request superseded. Try again."}},Y=async()=>{let e=C.current;if("signed-in"!==e.kind||j.current)return;j.current=!0,G();let t=_.current;X(),a("idle");let r=await l(e.user.csrfToken);if(j.current=!1,!M.current||t!==_.current)return;if("ok"===r){z({kind:"signed-out"}),X(),a("idle"),P("Signed out.");return}let n=await o();if(M.current&&t===_.current){if("signed-in"===n.kind){O(n.user),P("Sign out failed — try again."),U();return}if("signed-out"===n.kind){z({kind:"signed-out"}),X(),a("idle"),P(null);return}if("auth-unavailable"===n.kind){z({kind:"auth-unavailable",detail:n.detail}),a("idle");return}z({kind:"restore-failed",detail:"error"===n.kind?n.detail:null}),a("idle")}};return(0,i.useEffect)(()=>(M.current=!0,T.current+=1,J(T.current),()=>{M.current=!1,G()}),[]),(0,n.jsx)(h.Provider,{value:{session:t,phase:s,hubRunId:c,machines:v,lastReceivedLocalMs:k,lastEventId:$,lastEventKind:B,notice:I,history:S,login:K,signOut:Y,retryConnection:()=>{if(M.current&&!j.current){if("signed-in"===C.current.kind){F.current=0,q();return}T.current+=1,J(T.current)}},dismissNotice:()=>P(null)},children:e})}}}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[167,819,851,896,988],{4441:()=>{}},_=>{_.O(0,[441,794,358],()=>_(_.s=4441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[492],{1372:(e,t,l)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/_not-found/page",function(){return l(9541)}])},5949:(e,t,l)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"HTTPAccessErrorFallback",{enumerable:!0,get:function(){return o}});let r=l(5155),n=l(7356);function o({status:e,message:t}){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("title",{children:`${e}: ${t}`}),(0,r.jsx)("div",{style:n.styles.error,children:(0,r.jsxs)("div",{children:[(0,r.jsx)("style",{dangerouslySetInnerHTML:{__html:"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}),(0,r.jsx)("h1",{className:"next-error-h1",style:n.styles.h1,children:e}),(0,r.jsx)("div",{style:n.styles.desc,children:(0,r.jsx)("h2",{style:n.styles.h2,children:t})})]})})]})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},7356:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"styles",{enumerable:!0,get:function(){return l}});let l={error:{fontFamily:'system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"',height:"100vh",textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},desc:{display:"inline-block"},h1:{display:"inline-block",margin:"0 20px 0 0",padding:"0 23px 0 0",fontSize:24,fontWeight:500,verticalAlign:"top",lineHeight:"49px"},h2:{fontSize:14,fontWeight:400,lineHeight:"49px",margin:0}};("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},9541:(e,t,l)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return o}});let r=l(5155),n=l(5949),o=function(){return(0,r.jsx)("html",{children:(0,r.jsx)("body",{children:(0,r.jsx)(n.HTTPAccessErrorFallback,{status:404,message:"This page could not be found."})})})};("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)}},e=>{e.O(0,[441,794,358],()=>e(e.s=1372)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[693],{3092:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(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,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(8698).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},4268:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(8698).A)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},4891:(e,t,a)=>{Promise.resolve().then(a.bind(a,7044))},5798:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(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"}]])},7044:(e,t,a)=>{"use strict";a.d(t,{AdministrationView:()=>ee});var s=a(5155),n=a(8500),r=a.n(n),l=a(2115),i=a(6914),d=a(7029),c=a(828),o=a(7422),u=a(3092);class m extends Error{status;constructor(e,t){super(t),this.name="AdminApiError",this.status=e}}function h(){return new m(502,"The hub returned an unexpected response.")}var x=a(4173),p=a(3440),f=a(940),g=a(802),b=a(9939);let j="w-full min-w-0 rounded-md border border-border bg-background px-3 py-2 text-base text-foreground placeholder:text-muted-foreground aria-[invalid=true]:border-crit sm:text-sm",y="inline-flex min-h-9 items-center justify-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 disabled:cursor-not-allowed disabled:opacity-50",v="inline-flex min-h-9 items-center justify-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-card-strong disabled:cursor-not-allowed disabled:opacity-50",w="inline-flex min-h-8 items-center justify-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-card-strong hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",N="inline-flex min-h-9 items-center justify-center gap-1.5 rounded-md border border-crit px-3 py-1.5 text-xs font-medium text-crit transition-colors hover:bg-crit-soft disabled:cursor-not-allowed disabled:opacity-50";function k({id:e,label:t,error:a,children:n}){return(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-1.5",children:[(0,s.jsx)("label",{htmlFor:e,className:"text-xs font-medium text-foreground",children:t}),n,a?(0,s.jsx)("p",{id:`${e}-error`,className:"text-xs text-crit",children:a}):null]})}function C(e,t){if(t)return`${e}-error`}function A({children:e,tone:t="neutral"}){return(0,s.jsx)("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium ${{neutral:"border border-border text-muted-foreground",accent:"bg-selected text-foreground",ok:"bg-ok-soft text-foreground",warn:"bg-warn-soft text-foreground",crit:"bg-crit-soft text-foreground"}[t]}`,children:e})}function S({children:e,tone:t="info",role:a="status"}){return(0,s.jsx)("p",{role:a,className:`rounded-md px-3 py-2 text-xs ${{info:"text-muted-foreground",error:"bg-crit-soft text-foreground",success:"bg-ok-soft text-foreground",warn:"bg-warn-soft text-foreground"}[t]}`,children:e})}function I(e,t){return e instanceof m?e.message:t}function T(e){return e instanceof m&&401===e.status}function $(e){return e instanceof m&&403===e.status}function E(e){return"object"==typeof e&&null!==e&&"AbortError"===e.name}var R=a(8698);let M=(0,R.A)("ScrollText",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]),D=/^[\x21-\x7e]{1,128}$/,U=/[\u0000-\u001f\u007f]/;function L(e){let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"}):"Unknown time"}function G(e){let t=e.displayName?.trim();if(t)return t;let a=e.hostname?.trim();return a||e.machineId}function P(e){let{api:t,revision:a,onSessionLost:n}=e,[r,i]=(0,l.useState)([]),[d,o]=(0,l.useState)(!0),[u,m]=(0,l.useState)(null),h=(0,l.useRef)(null),x=(0,l.useCallback)(async()=>{h.current?.abort();let e=new AbortController;h.current=e,o(!0),m(null);try{let a=await t.listAudit(50,e.signal);e.signal.aborted||i(a)}catch(t){if(e.signal.aborted||E(t))return;if(T(t))return void n();m($(t)?"Administrator access is required to read the audit log.":I(t,"Could not load the audit log."))}finally{e.signal.aborted||o(!1)}},[t,n]);return(0,l.useEffect)(()=>(x(),()=>h.current?.abort()),[x,a]),(0,s.jsxs)(p.Z,{title:"Audit log",className:"min-w-0",action:(0,s.jsxs)("button",{type:"button",className:w,onClick:()=>void x(),disabled:d,children:[(0,s.jsx)(c.A,{className:`h-3.5 w-3.5 ${d?"animate-spin":""}`,"aria-hidden":!0}),"Refresh"]}),children:[(0,s.jsx)("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:(0,s.jsxs)("span",{className:"tnum text-xs text-muted-foreground",children:[r.length," event",1===r.length?"":"s"]})}),u?(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsx)(S,{tone:"error",role:"alert",children:u}),(0,s.jsx)("button",{type:"button",className:w,onClick:()=>void x(),children:"Try again"})]}):null,d&&0===r.length&&!u?(0,s.jsx)("p",{role:"status",className:"py-6 text-sm text-muted-foreground",children:"Loading audit events…"}):null,d||u||0!==r.length?null:(0,s.jsx)(p.p,{icon:M,note:"No administrative changes recorded yet."}),r.length>0?(0,s.jsx)("ol",{className:"mt-2 max-h-96 divide-y divide-border overflow-y-auto border-t border-border",children:r.map((e,t)=>(0,s.jsxs)("li",{className:"flex min-w-0 flex-wrap items-baseline gap-x-3 gap-y-1 py-2.5 text-xs",children:[(0,s.jsx)("time",{dateTime:e.at,className:"tnum shrink-0 text-muted-foreground",children:L(e.at)}),(0,s.jsx)("span",{className:"font-medium text-foreground",children:function(e){switch(e){case"user.create":return"Created user";case"user.update":return"Updated access";case"user.update-password":return"Changed password";case"user.delete":return"Deleted user";default:return e.replace(/[-_.]+/g," ")}}(e.action)}),(0,s.jsxs)("span",{className:"min-w-0 break-all text-muted-foreground",children:[e.target," ",(0,s.jsx)("span",{"aria-hidden":!0,children:"\xb7"})," by ",e.actor]})]},`${e.at}-${e.actor}-${e.action}-${e.target}-${t}`))}):null]})}let q=(0,R.A)("ShieldOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]),F=(0,R.A)("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);var O=a(4268),Y=a(1735);let Z=(0,R.A)("ClipboardCopy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),V=[{value:3e5,label:"5 minutes"},{value:6e5,label:"10 minutes"},{value:9e5,label:"15 minutes"}];function B(e){let{api:t,csrfToken:a,sessionKey:n,machines:r,onAuditChange:i,onSessionLost:d}=e,o=(0,l.useId)(),u=e=>`${o}-${e}`,[m,h]=(0,l.useState)([]),[x,f]=(0,l.useState)(!0),[g,b]=(0,l.useState)(null),[C,R]=(0,l.useState)(""),[M,D]=(0,l.useState)(""),[U,P]=(0,l.useState)(9e5),[B,H]=(0,l.useState)(null),[z,_]=(0,l.useState)(null),[K,J]=(0,l.useState)(!1),[W,X]=(0,l.useState)(""),[Q,ee]=(0,l.useState)(null),[et,ea]=(0,l.useState)(!1),[es,en]=(0,l.useState)(null),er=(0,l.useRef)(null),el=(0,l.useRef)(!0),ei=(0,l.useRef)(null),ed=(0,l.useRef)(null);(0,l.useEffect)(()=>(el.current=!0,()=>{el.current=!1,er.current?.abort()}),[]),(0,l.useEffect)(()=>{H(null),X("")},[n]),(0,l.useEffect)(()=>{B&&(ei.current?.focus(),ei.current?.select())},[B]);let ec=(0,l.useCallback)(async()=>{er.current?.abort();let e=new AbortController;er.current=e,f(!0),b(null);try{let a=await t.listCollectors(e.signal);e.signal.aborted||h(a)}catch(t){if(e.signal.aborted||E(t))return;if(T(t))return void d();b($(t)?"Administrator access is required to inspect collector mappings.":I(t,"Could not load the collector registry."))}finally{e.signal.aborted||f(!1)}},[t,d]);(0,l.useEffect)(()=>{ec()},[ec]),(0,l.useEffect)(()=>{""!==M&&(m.some(e=>e.machineId===M&&!e.revoked)||D(""))},[m,M]);let eo=m.filter(e=>!e.revoked),eu=""!==M,em=B?function(e,t="https://your-hub"){let a=new URL(t);if(!["https:","http:"].includes(a.protocol)||a.username||a.password||a.search||a.hash)throw Error("Invalid hub origin");let s=a.origin.replace(/'/g,"%27");return{command:`rigscope connect '${s}'${"replacement"===e?" --replace":""}`,note:"replacement"===e?"Paste the grant at the prompt. The old credential stays active until replacement succeeds.":"Paste the grant at the prompt, then run rigscope start."}}(B.mode,window.location.origin):null,eh=async()=>{if(!K){_(null),J(!0);try{let e=await t.createGrant({ttlMs:U,...eu?{replaceMachineId:M}:{}},a);if(!el.current)return;H({...e,mode:eu?"replacement":"new"}),X(""),R("Grant created. Copy before leaving."),i()}catch(e){if(!el.current)return;if(T(e))return void d();if($(e))return void _(eu?"You do not have access to that machine, so a replacement grant cannot be created.":"A new installation needs a hub administrator with all-machine scope. Choose an existing mapping for a replacement grant, or ask the hub owner to widen your scope.");_(I(e,"Could not create an enrollment grant."))}finally{el.current&&J(!1)}}},ex=async()=>{if(B)try{if(!navigator.clipboard?.writeText)throw Error("clipboard unavailable");await navigator.clipboard.writeText(B.token),X("Grant copied to the clipboard.")}catch{X("Copy failed. Select the grant field and copy it manually.")}},ep=async()=>{if(em)try{if(!navigator.clipboard?.writeText)throw Error("clipboard unavailable");await navigator.clipboard.writeText(em.command),X("Command copied.")}catch{X("Copy failed. Select the command and copy it manually.")}},ef=async()=>{if(Q&&!et){ea(!0),en(null);try{if(await t.revokeCollector(Q.collectorId,a),!el.current)return;let e=`${Q.collectorId} on ${Q.machineId}`;ee(null),R(`Revoked ${e}. Its live stream was disconnected.`),i(),await ec()}catch(e){if(!el.current)return;if(T(e))return void d();en($(e)?"Your account does not have access to that collector's machine.":I(e,"Could not revoke that collector."))}finally{el.current&&ea(!1)}}},eg=e=>{let t=r.find(t=>t.machineId===e);return t?G(t):e};return(0,s.jsxs)(p.Z,{title:"Collectors",className:"min-w-0",action:(0,s.jsxs)("button",{type:"button",className:w,onClick:()=>void ec(),disabled:x,children:[(0,s.jsx)(c.A,{className:`h-3.5 w-3.5 ${x?"animate-spin":""}`,"aria-hidden":!0}),"Refresh"]}),children:[(0,s.jsx)("p",{role:"status",className:C?"mb-3 rounded-md bg-ok-soft px-3 py-2 text-xs text-foreground":"sr-only",children:C}),g?(0,s.jsxs)("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsx)(S,{tone:"error",role:"alert",children:g}),(0,s.jsx)("button",{type:"button",className:v,onClick:()=>void ec(),children:"Try again"})]}):null,(0,s.jsxs)("div",{className:"grid min-w-0 gap-6 lg:grid-cols-2",children:[(0,s.jsxs)("section",{"aria-labelledby":u("registry-heading"),className:"min-w-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[(0,s.jsx)("h3",{id:u("registry-heading"),className:"text-sm font-medium tracking-tight",children:"Registry"}),(0,s.jsxs)("span",{className:"tnum text-xs text-muted-foreground",children:[eo.length," active / ",m.length," total"]})]}),x&&0===m.length?(0,s.jsx)("p",{role:"status",className:"py-6 text-sm text-muted-foreground",children:"Loading collector mappings…"}):null,x||g||0!==m.length?null:(0,s.jsx)(p.p,{icon:q,note:"No collector mappings are visible."}),m.length>0?(0,s.jsx)("ul",{className:"mt-2 divide-y divide-border border-t border-border",children:m.map(e=>{let t=Q?.collectorId===e.collectorId;return(0,s.jsxs)("li",{className:"min-w-0 py-3",children:[(0,s.jsxs)("div",{className:"flex min-w-0 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-1.5",children:[(0,s.jsx)("span",{className:"break-words text-sm font-medium",children:eg(e.machineId)}),e.revoked?(0,s.jsx)(A,{tone:"crit",children:"Revoked"}):(0,s.jsx)(A,{tone:"ok",children:"Active"})]}),(0,s.jsxs)("dl",{className:"mt-1 flex flex-col gap-0.5 text-xs text-muted-foreground",children:[(0,s.jsxs)("div",{className:"flex min-w-0 gap-1.5",children:[(0,s.jsx)("dt",{className:"shrink-0",children:"Machine"}),(0,s.jsx)("dd",{className:"tnum break-all",children:e.machineId})]}),(0,s.jsxs)("div",{className:"flex min-w-0 gap-1.5",children:[(0,s.jsx)("dt",{className:"shrink-0",children:"Collector"}),(0,s.jsx)("dd",{className:"tnum break-all",children:e.collectorId})]}),(0,s.jsxs)("div",{className:"flex min-w-0 gap-1.5",children:[(0,s.jsx)("dt",{className:"shrink-0",children:"Updated"}),(0,s.jsx)("dd",{children:L(e.updatedAt)})]})]})]}),e.revoked?null:(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1",children:[(0,s.jsxs)("button",{type:"button",className:w,onClick:()=>{D(e.machineId),_(null),requestAnimationFrame(()=>ed.current?.focus())},children:[(0,s.jsx)(F,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Replacement grant"]}),(0,s.jsxs)("button",{type:"button",className:w,"aria-expanded":t,onClick:()=>{en(null),ee(t?null:e)},children:[(0,s.jsx)(q,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Revoke"]})]})]}),t?(0,s.jsxs)("div",{role:"alert",className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-md bg-crit-soft px-3 py-2",children:[(0,s.jsxs)("p",{className:"min-w-0 flex-1 text-xs text-foreground",children:["Revoke ",(0,s.jsx)("strong",{className:"font-medium",children:e.collectorId})," ","on ",(0,s.jsx)("strong",{className:"font-medium",children:eg(e.machineId)}),"? This disconnects the collector and invalidates its credential."]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[(0,s.jsx)("button",{type:"button",className:N,onClick:()=>void ef(),disabled:et,children:et?"Revoking…":"Revoke collector"}),(0,s.jsx)("button",{type:"button",className:v,onClick:()=>ee(null),disabled:et,children:"Cancel"})]})]}):null,t&&es?(0,s.jsx)("p",{role:"alert",className:"mt-2 text-xs text-crit",children:es}):null]},e.collectorId)})}):null]}),(0,s.jsxs)("section",{"aria-labelledby":u("grant-heading"),className:"flex min-w-0 flex-col gap-3 border-t border-border pt-5 lg:border-l lg:border-t-0 lg:pl-6 lg:pt-0",children:[(0,s.jsx)("div",{children:(0,s.jsx)("h3",{id:u("grant-heading"),className:"text-sm font-medium tracking-tight",children:"Add machine"})}),(0,s.jsx)(k,{id:u("target"),label:"Enrollment target",children:(0,s.jsxs)("select",{id:u("target"),value:M,onChange:e=>{D(e.target.value),_(null)},className:j,children:[(0,s.jsx)("option",{value:"",children:"New machine"}),eo.map(e=>(0,s.jsxs)("option",{value:e.machineId,children:["Replacement \xb7 ",eg(e.machineId)," \xb7 ",e.collectorId]},e.collectorId))]})}),(0,s.jsx)(k,{id:u("ttl"),label:"Grant lifetime",children:(0,s.jsx)("select",{id:u("ttl"),value:U,onChange:e=>P(Number(e.target.value)),className:j,children:V.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))})}),z?(0,s.jsx)(S,{tone:"error",role:"alert",children:z}):null,(0,s.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:(0,s.jsxs)("button",{ref:ed,type:"button",className:y,onClick:()=>void eh(),disabled:K,"aria-busy":K,children:[(0,s.jsx)(F,{className:"h-3.5 w-3.5","aria-hidden":!0}),K?"Creating…":eu?"Create replacement grant":"Create connection grant"]})}),B&&em?(0,s.jsxs)("section",{"aria-labelledby":u("grant-reveal-heading"),className:"flex min-w-0 flex-col gap-3 border-t border-border pt-3",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[(0,s.jsx)("h4",{id:u("grant-reveal-heading"),className:"text-sm font-medium",children:"Copy this grant now"}),(0,s.jsxs)("button",{type:"button",className:w,onClick:()=>{H(null),X(""),_(null),R("Grant dismissed."),requestAnimationFrame(()=>ed.current?.focus())},"aria-label":"Dismiss enrollment grant",children:[(0,s.jsx)(O.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Dismiss"]})]}),(0,s.jsx)(S,{tone:"warn",role:"alert",children:(0,s.jsxs)("span",{className:"flex items-start gap-2",children:[(0,s.jsx)(Y.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),(0,s.jsxs)("span",{children:["Single-use grant \xb7 expires"," ",(0,s.jsx)("time",{dateTime:B.expiresAt,children:L(B.expiresAt)}),". Copy before leaving."]})]})}),(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-1.5",children:[(0,s.jsx)("label",{htmlFor:u("grant-token"),className:"text-xs font-medium",children:"One-time grant"}),(0,s.jsxs)("div",{className:"flex min-w-0 flex-wrap gap-1.5",children:[(0,s.jsx)("input",{ref:ei,id:u("grant-token"),readOnly:!0,autoComplete:"off",spellCheck:!1,value:B.token,onFocus:e=>e.currentTarget.select(),className:`${j} tnum min-w-0 flex-1 break-all`}),(0,s.jsxs)("button",{type:"button",className:v,onClick:()=>void ex(),children:[(0,s.jsx)(Z,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Copy grant"]})]}),(0,s.jsx)("p",{className:"sr-only",role:"status",children:W}),W?(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:W}):null]}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-xs font-medium",children:"Run on the new machine"}),(0,s.jsx)("pre",{className:"mt-1.5 overflow-x-auto whitespace-pre-wrap break-all rounded-md bg-card-strong p-3 text-xs text-foreground",children:(0,s.jsx)("code",{children:em.command})}),(0,s.jsx)("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:(0,s.jsxs)("button",{type:"button",className:v,onClick:()=>void ep(),children:[(0,s.jsx)(Z,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Copy command"]})}),(0,s.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:em.note})]})]}):null]})]})]})}var H=a(8731);let z=(0,R.A)("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);function _(e){let{api:t,csrfToken:a,machines:n,machinesPending:r,onSessionLost:i}=e,d=(0,l.useId)(),o=e=>`${d}-${e}`,[u,m]=(0,l.useState)(""),[h,x]=(0,l.useState)(""),[f,g]=(0,l.useState)(""),[b,v]=(0,l.useState)(!1),[w,N]=(0,l.useState)({}),[A,E]=(0,l.useState)(null),[R,M]=(0,l.useState)(!1),[D,L]=(0,l.useState)(""),P=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(0===n.length){""!==u&&m("");return}if(n.some(e=>e.machineId===u))return;let e=n[0];m(e.machineId),x(e.displayName??""),g((e.tags??[]).join(", ")),v(!1)},[n,u]),(0,l.useEffect)(()=>{A&&P.current?.focus()},[A]);let q=n.find(e=>e.machineId===u),F=async e=>{let s,n,r;if(e.preventDefault(),!q||R)return;E(null);let l=(s=h.trim(),n={},s.length>128?n.displayName="Display name must be at most 128 characters.":U.test(s)&&(n.displayName="Display name cannot contain control characters."),null!==(r=function(e){let t=e.split(",").map(e=>e.trim()).filter(e=>e.length>0),a=[],s=new Set;for(let e of t){if(e.length>64)return{tags:a,error:"Each tag must be at most 64 characters."};if(U.test(e))return{tags:a,error:"Tags cannot contain control characters."};s.has(e)||(s.add(e),a.push(e))}return a.length>32?{tags:a,error:"Use at most 32 tags."}:{tags:a,error:null}}(f)).error&&(n.tags=r.error),{displayName:0===s.length?null:s,tags:r.tags,errors:n});if(N(l.errors),l.errors.displayName)return void document.getElementById(o("name"))?.focus();if(l.errors.tags)return void document.getElementById(o("tags"))?.focus();M(!0);try{await t.saveMachineMeta(q.machineId,{displayName:l.displayName,tags:l.tags},a),x(l.displayName??""),g(l.tags.join(", ")),v(!1),L(`Saved metadata for ${G(q)}. Fleet and machine views update from the live stream.`)}catch(e){if(T(e))return void i();E($(e)?"You do not have access to this machine, so its metadata cannot be changed.":I(e,"Could not save machine metadata."))}finally{M(!1)}};return(0,s.jsxs)(p.Z,{title:"Machine metadata",className:"min-w-0",children:[(0,s.jsx)("p",{role:"status",className:D?"mb-3 rounded-md bg-ok-soft px-3 py-2 text-xs text-foreground":"sr-only",children:D}),0===n.length?(0,s.jsx)(p.p,{icon:H.A,note:r?"Waiting for the live machine list…":"No machines are visible to your account."}):(0,s.jsxs)("form",{"aria-busy":R,className:"flex min-w-0 flex-col gap-4",onSubmit:e=>void F(e),children:[(0,s.jsx)(k,{id:o("machine"),label:"Machine",children:(0,s.jsx)("select",{id:o("machine"),value:u,onChange:e=>{var t;let a;return t=e.target.value,a=n.find(e=>e.machineId===t),void(m(t),x(a?.displayName??""),g((a?.tags??[]).join(", ")),v(!1),N({}),E(null),L(""))},className:j,children:n.map(e=>(0,s.jsx)("option",{value:e.machineId,children:G(e)},e.machineId))})}),(0,s.jsx)(k,{id:o("name"),label:"Display name",error:w.displayName,children:(0,s.jsx)("input",{id:o("name"),placeholder:q?.hostname||"Hostname",maxLength:128,value:h,onChange:e=>{x(e.target.value),v(!0)},"aria-invalid":!!w.displayName||void 0,"aria-describedby":C(o("name"),w.displayName),className:j})}),(0,s.jsx)(k,{id:o("tags"),label:"Tags (comma-separated)",error:w.tags,children:(0,s.jsx)("input",{id:o("tags"),value:f,onChange:e=>{g(e.target.value),v(!0)},"aria-invalid":!!w.tags||void 0,"aria-describedby":C(o("tags"),w.tags),className:j})}),A?(0,s.jsx)("div",{ref:P,tabIndex:-1,"aria-live":"assertive",children:(0,s.jsx)(S,{tone:"error",role:"alert",children:A})}):null,(0,s.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:(0,s.jsx)("button",{type:"submit",className:y,disabled:R||!b,children:R?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(c.A,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}),"Saving…"]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(z,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Save metadata"]})})})]})]})}var K=a(3612),J=a(5798),W=a(7241);function X(e){let{api:t,username:a,csrfToken:n,machines:r,machinesPending:d,onAuditChange:o,onSessionLost:m}=e,[h,x]=(0,l.useState)([]),[f,g]=(0,l.useState)(!0),[b,j]=(0,l.useState)(null),[k,C]=(0,l.useState)(""),[R,M]=(0,l.useState)(null),[D,U]=(0,l.useState)(null),[L,G]=(0,l.useState)(!1),[P,q]=(0,l.useState)(null),F=(0,l.useRef)(null),O=(0,l.useRef)(!0);(0,l.useEffect)(()=>(O.current=!0,()=>{O.current=!1,F.current?.abort()}),[]);let Y=(0,l.useCallback)(async()=>{F.current?.abort();let e=new AbortController;F.current=e,g(!0),j(null);try{let a=await t.listUsers(e.signal);e.signal.aborted||x(a)}catch(t){if(e.signal.aborted||E(t))return;if(T(t))return void m();j($(t)?"Administrator access is required. If your access just changed, sign in again.":I(t,"Could not load the browser user directory."))}finally{e.signal.aborted||g(!1)}},[t,m]);(0,l.useEffect)(()=>{Y()},[Y]);let Z=async()=>{if(D&&!L){G(!0),q(null);try{if(await t.deleteUser(D.username,n),!O.current)return;let e=D.username;U(null),C(`Deleted user ${e}. Any active sessions were ended.`),o(),await Y()}catch(e){if(!O.current)return;if(T(e))return void m();q($(e)?"Your account no longer has administrative access.":I(e,"Could not delete that user."))}finally{O.current&&G(!1)}}};return(0,s.jsxs)(p.Z,{title:"Browser users",className:"min-w-0",action:(0,s.jsxs)("button",{type:"button",className:y,"aria-expanded":R?.mode==="create",onClick:()=>{U(null),q(null),M(e=>e?.mode==="create"?null:{mode:"create"})},children:[(0,s.jsx)(K.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Add user"]}),children:[(0,s.jsx)("p",{role:"status",className:k?"rounded-md bg-ok-soft px-3 py-2 text-xs text-foreground":"sr-only",children:k}),(0,s.jsx)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,s.jsxs)("span",{className:"tnum text-xs text-muted-foreground",children:[h.length,"/",50]}),(0,s.jsxs)("button",{type:"button",className:w,onClick:()=>void Y(),disabled:f,children:[(0,s.jsx)(c.A,{className:`h-3.5 w-3.5 ${f?"animate-spin":""}`,"aria-hidden":!0}),"Refresh"]})]})}),R?(0,s.jsx)(Q,{api:t,csrfToken:n,existing:"edit"===R.mode?R.user:void 0,currentUsername:a,machines:r,machinesPending:d,onCancel:()=>M(null),onSaved:e=>{M(null),C(e),o(),Y()},onSessionLost:m},"edit"===R.mode?`edit-${R.user.username}`:"create"):null,(0,s.jsxs)("div",{className:"mt-4 flex min-w-0 flex-col gap-3",children:[b?(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsx)(S,{tone:"error",role:"alert",children:b}),(0,s.jsx)("button",{type:"button",className:v,onClick:()=>void Y(),children:"Try again"})]}):null,f&&0===h.length?(0,s.jsx)("p",{role:"status",className:"py-6 text-sm text-muted-foreground",children:"Loading browser users…"}):null,f||b||0!==h.length?null:(0,s.jsx)(p.p,{icon:i.A,note:"No browser users are stored yet."}),h.length>0?(0,s.jsx)("ul",{className:"divide-y divide-border border-t border-border",children:h.map(e=>{var t;let n=e.username===a,r=D?.username===e.username;return(0,s.jsxs)("li",{className:"min-w-0 py-3",children:[(0,s.jsxs)("div",{className:"flex min-w-0 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-1.5",children:[(0,s.jsx)("span",{className:"break-words text-sm font-medium",children:e.username}),n?(0,s.jsx)(A,{tone:"accent",children:"You"}):null,e.admin?(0,s.jsxs)(A,{tone:"ok",children:[(0,s.jsx)(u.A,{className:"h-3 w-3","aria-hidden":!0}),"Administrator"]}):(0,s.jsx)(A,{children:"Viewer"}),e.disabled?(0,s.jsx)(A,{tone:"warn",children:"Disabled"}):null]}),(0,s.jsx)("p",{className:"mt-1 break-words text-xs text-muted-foreground",title:"*"===e.machineIds?"All machines":e.machineIds.join(", "),children:"*"===(t=e.machineIds)?"All machines":0===t.length?"No machines":1===t.length?t[0]:`${t.length} machines`})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1",children:[(0,s.jsxs)("button",{type:"button",className:w,"aria-expanded":R?.mode==="edit"&&R.user.username===e.username,onClick:()=>{q(null),U(null),M(R?.mode==="edit"&&R.user.username===e.username?null:{mode:"edit",user:e})},children:[(0,s.jsx)(J.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),R?.mode==="edit"&&R.user.username===e.username?"Close editor":"Edit"]}),(0,s.jsxs)("button",{type:"button",className:w,"aria-expanded":r,onClick:()=>{M(null),q(null),U(r?null:e)},children:[(0,s.jsx)(W.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Delete"]})]})]}),r?(0,s.jsxs)("div",{role:"alert",className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-md bg-crit-soft px-3 py-2",children:[(0,s.jsxs)("p",{className:"min-w-0 flex-1 text-xs text-foreground",children:["Delete ",(0,s.jsx)("strong",{className:"font-medium",children:e.username}),"? Their active sessions end immediately, and this cannot be undone."]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[(0,s.jsx)("button",{type:"button",className:N,onClick:()=>void Z(),disabled:L,children:L?"Deleting…":"Delete user"}),(0,s.jsx)("button",{type:"button",className:v,onClick:()=>U(null),disabled:L,children:"Cancel"})]})]}):null,r&&P?(0,s.jsx)("p",{role:"alert",className:"mt-2 text-xs text-crit",children:P}):null]},e.username)})}):null]})]})}function Q(e){let{api:t,csrfToken:a,existing:n,currentUsername:r,machines:i,machinesPending:d,onCancel:c,onSaved:o,onSessionLost:u}=e,m=(0,l.useId)(),h=e=>`${m}-${e}`,x=h("heading"),[p,f]=(0,l.useState)(n?.username??""),[g,b]=(0,l.useState)(""),[N,A]=(0,l.useState)(!!n&&"*"===n.machineIds),[E,R]=(0,l.useState)(n&&"*"!==n.machineIds?[...n.machineIds]:[]),[M,U]=(0,l.useState)(n?.admin??!1),[L,P]=(0,l.useState)(n?.disabled??!1),[q,F]=(0,l.useState)({}),[Z,V]=(0,l.useState)(null),[B,H]=(0,l.useState)(!1),z=(0,l.useRef)(null),_=(0,l.useRef)(!1);(0,l.useEffect)(()=>{_.current||(_.current=!0,document.getElementById(x)?.focus())},[x]),(0,l.useEffect)(()=>{Z&&z.current?.focus()},[Z]);let K=[...i].sort((e,t)=>{let a=G(e).toLocaleLowerCase(),s=G(t).toLocaleLowerCase();return a.localeCompare(s)||e.machineId.localeCompare(t.machineId)}),J=function(e,t){if("*"===e)return[];let a=new Set(t);return e.filter(e=>!a.has(e))}(E,K.map(e=>e.machineId)),W=N?"*":E,X=n?.username===r,Q=async e=>{if(e.preventDefault(),B)return;V(null);let s={username:n?.username??p,password:g,machineIds:W,admin:M,disabled:L},r=function(e,t){let a={};if(D.test(e.username)||(a.username="Use 1–128 printable characters without spaces."),t.existing||0!==e.password.length?e.password.length>1024&&(a.password="Password must be at most 1024 characters."):a.password="Choose a password for the new user.","*"===e.machineIds);else if(Array.isArray(e.machineIds)){let t=new Set,s=2;for(let n of e.machineIds){if(!D.test(n)){a.scope="Every machine ID must be a valid identifier.";break}if((s+=n.length+3)>8192){a.scope="Keep the explicit machine list under 8192 bytes.";break}if(t.has(n)){a.scope="Machine scope contains a duplicate ID.";break}t.add(n)}}else a.scope="Choose all machines or an explicit list of machine IDs.";let s=a.username?"username":a.password?"password":a.scope?"scope":null;return{errors:a,firstInvalid:s}}(s,{existing:void 0!==n});if(F(r.errors),null!==r.firstInvalid){let e="username"===r.firstInvalid?h("username"):"password"===r.firstInvalid?h("password"):h("scope-all");document.getElementById(e)?.focus();return}H(!0);try{await t.saveUser({username:s.username,machineIds:s.machineIds,admin:M,disabled:L,...g.length>0?{password:g}:{}},a),b(""),o(n?`Updated ${n.username}.`:`Created ${s.username}. They can sign in with the password you set.`)}catch(e){if(T(e))return void u();V($(e)?"Your account no longer has administrative access.":I(e,"Could not save that user."))}finally{H(!1)}};return(0,s.jsxs)("form",{"aria-labelledby":x,"aria-busy":B,className:"flex min-w-0 flex-col gap-4 border-t border-border py-4",onSubmit:e=>void Q(e),children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[(0,s.jsx)("div",{children:(0,s.jsx)("h3",{id:x,tabIndex:-1,className:"text-sm font-medium tracking-tight",children:n?`Edit ${n.username}`:"Add a browser user"})}),(0,s.jsx)("button",{type:"button",className:w,onClick:c,disabled:B,children:"Close"})]}),X?(0,s.jsx)(S,{tone:"warn",role:"status",children:(0,s.jsxs)("span",{className:"flex items-start gap-2",children:[(0,s.jsx)(Y.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),(0,s.jsx)("span",{children:"Account changes may sign you out."})]})}):null,Z?(0,s.jsx)("div",{ref:z,tabIndex:-1,"aria-live":"assertive",children:(0,s.jsx)(S,{tone:"error",role:"alert",children:Z})}):null,(0,s.jsxs)("div",{className:"grid min-w-0 gap-4 sm:grid-cols-2",children:[n?(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-1.5",children:[(0,s.jsx)("span",{className:"text-xs font-medium text-foreground",children:"Username"}),(0,s.jsx)("p",{className:"tnum break-words rounded-md border border-border bg-card-strong px-3 py-2 text-sm",children:n.username})]}):(0,s.jsx)(k,{id:h("username"),label:"Username",error:q.username,children:(0,s.jsx)("input",{id:h("username"),name:"username",autoComplete:"username",value:p,onChange:e=>f(e.target.value),"aria-invalid":!!q.username||void 0,"aria-describedby":C(h("username"),q.username),className:j})}),(0,s.jsx)(k,{id:h("password"),label:n?"New password (optional)":"Password",error:q.password,children:(0,s.jsx)("input",{id:h("password"),name:"new-password",type:"password",autoComplete:"new-password",value:g,onChange:e=>b(e.target.value),"aria-invalid":!!q.password||void 0,"aria-describedby":C(h("password"),q.password),className:j})})]}),(0,s.jsxs)("fieldset",{className:"flex min-w-0 flex-col gap-2","aria-invalid":!!q.scope||void 0,"aria-describedby":q.scope?h("scope-error"):void 0,children:[(0,s.jsx)("legend",{className:"text-xs font-medium text-foreground",children:"Machine access"}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-x-5 gap-y-2",children:[(0,s.jsxs)("label",{className:"flex items-center gap-2 text-xs text-foreground",children:[(0,s.jsx)("input",{id:h("scope-all"),type:"radio",name:h("scope"),checked:N,onChange:()=>A(!0)}),"All machines"]}),(0,s.jsxs)("label",{className:"flex items-center gap-2 text-xs text-foreground",children:[(0,s.jsx)("input",{id:h("scope-selected"),type:"radio",name:h("scope"),checked:!N,onChange:()=>A(!1)}),"Selected machines"]})]}),N?null:(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-2 border-t border-border pt-2",children:[0===K.length?(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:d?"Waiting for machines…":"No machines available."}):(0,s.jsx)("div",{className:"max-h-56 overflow-y-auto pr-1",children:(0,s.jsx)("ul",{className:"flex flex-col gap-1.5",children:K.map(e=>(0,s.jsxs)("li",{className:"flex items-start gap-2",children:[(0,s.jsx)("input",{id:h(`machine-${e.machineId}`),type:"checkbox",className:"mt-0.5",checked:E.includes(e.machineId),onChange:()=>R(t=>{var a;return a=e.machineId,t.includes(a)?t.filter(e=>e!==a):[...t,a]})}),(0,s.jsxs)("label",{htmlFor:h(`machine-${e.machineId}`),className:"min-w-0 text-xs text-foreground",children:[(0,s.jsx)("span",{className:"block break-words",children:G(e)}),(0,s.jsx)("span",{className:"tnum block break-all text-muted-foreground",children:e.machineId})]})]},e.machineId))})}),J.length>0?(0,s.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Other saved machines"}),(0,s.jsx)("ul",{className:"flex flex-wrap gap-1.5",children:J.map(e=>(0,s.jsxs)("li",{className:"flex items-center gap-1.5 rounded-full border border-border px-2 py-0.5 text-xs",children:[(0,s.jsx)("span",{className:"tnum break-all",children:e}),(0,s.jsx)("button",{type:"button",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-muted-foreground hover:bg-card-strong hover:text-foreground",onClick:()=>R(t=>t.filter(t=>t!==e)),"aria-label":`Remove ${e} from the machine scope`,children:(0,s.jsx)(O.A,{className:"h-3 w-3","aria-hidden":!0})})]},e))})]}):null]}),q.scope?(0,s.jsx)("p",{id:h("scope-error"),className:"text-xs text-crit",children:q.scope}):null]}),(0,s.jsxs)("div",{className:"flex flex-col gap-2 border-t border-border pt-3",children:[(0,s.jsxs)("label",{className:"flex items-start gap-2 text-xs text-foreground",children:[(0,s.jsx)("input",{type:"checkbox",className:"mt-0.5",checked:M,onChange:e=>U(e.target.checked)}),(0,s.jsxs)("span",{children:["Administrator",(0,s.jsx)("span",{className:"block text-muted-foreground",children:"Explicit administrative access. A wildcard machine scope alone never grants it."})]})]}),(0,s.jsxs)("label",{className:"flex items-start gap-2 text-xs text-foreground",children:[(0,s.jsx)("input",{type:"checkbox",className:"mt-0.5",checked:L,onChange:e=>P(e.target.checked)}),(0,s.jsxs)("span",{children:["Disabled",(0,s.jsx)("span",{className:"block text-muted-foreground",children:"Blocks sign-in and ends active sessions. The account is kept for a later re-enable."})]})]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("button",{type:"submit",className:y,disabled:B,children:B?"Saving…":n?"Save changes":"Create user"}),(0,s.jsx)("button",{type:"button",className:v,onClick:c,disabled:B,children:"Cancel"})]})]})}function ee(){let{session:e,machines:t,phase:a,retryConnection:n}=(0,b.M)(),j=(0,l.useMemo)(()=>(function(e={}){let t=e.fetchImpl??fetch;async function a(e,s={}){let n={Accept:"application/json"};void 0!==s.body&&(n["Content-Type"]="application/json"),void 0!==s.csrfToken&&(n["X-CSRF-Token"]=s.csrfToken);let r=await t(e,{method:s.method??"GET",headers:n,body:void 0===s.body?void 0:JSON.stringify(s.body),signal:s.signal,cache:"no-store",credentials:"same-origin",redirect:"error"}),l=await r.text(),i=null;if(l.length>0)try{i=JSON.parse(l)}catch{i=null}if(!r.ok)throw new m(r.status,function(e,t){if(null!==t&&"object"==typeof t){let e=t.error;if("string"==typeof e&&e.length>0&&e.length<=256)return e}return 400===e?"The request was not valid.":401===e?"Your session ended. Sign in again.":403===e?"Administrative access is required.":404===e?"That record no longer exists.":409===e?"That change conflicts with the current directory.":413===e?"The request was too large.":503===e?"Administration is temporarily unavailable.":"The hub could not complete that request."}(r.status,i));return i}return{async listUsers(e){let t=await a("/api/admin/users",{signal:e});if(!Array.isArray(t?.users))throw h();return t.users},async saveUser(e,t,s){await a("/api/admin/users",{method:"POST",body:e,csrfToken:t,signal:s})},async deleteUser(e,t,s){await a(`/api/admin/users?username=${encodeURIComponent(e)}`,{method:"DELETE",csrfToken:t,signal:s})},async listAudit(e=50,t){let s=Number.isSafeInteger(e)?Math.min(Math.max(e,1),1e3):50,n=await a(`/api/admin/audit?limit=${s}`,{signal:t});if(!Array.isArray(n?.events))throw h();return n.events},async listCollectors(e){let t=await a("/api/admin/collectors",{signal:e});if(!Array.isArray(t?.collectors))throw h();return t.collectors},async revokeCollector(e,t,s){await a("/api/admin/collectors",{method:"POST",body:{action:"revoke",collectorId:e},csrfToken:t,signal:s})},async createGrant(e,t,s){let n=await a("/api/admin/collector-grants",{method:"POST",body:e,csrfToken:t,signal:s});if("string"!=typeof n?.token||"string"!=typeof n.expiresAt)throw h();return{token:n.token,expiresAt:n.expiresAt}},async saveMachineMeta(e,t,s,n){await a(`/api/machines/meta?machineId=${encodeURIComponent(e)}`,{method:"POST",body:t,csrfToken:s,signal:n})}}})(),[]),[w,N]=(0,l.useState)(!1),[k,C]=(0,l.useState)(0),A="signed-in"===e.kind?`${e.user.username}:${e.user.csrfToken}`:e.kind;(0,l.useEffect)(()=>{N(!1)},[A]);let S=(0,l.useCallback)(()=>N(!0),[]),I=(0,l.useCallback)(()=>C(e=>e+1),[]),T=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(f.$E,{}),(0,s.jsx)(g.B,{})]});if("restoring"===e.kind)return(0,s.jsx)(x.G,{title:"Administration",headerRight:T,children:(0,s.jsx)(p.Z,{title:"Checking session",className:"mx-auto my-12 max-w-md",children:(0,s.jsx)(p.p,{icon:i.A,note:"Checking your session…"})})});if("restore-failed"===e.kind)return(0,s.jsx)(x.G,{title:"Administration",headerRight:T,children:(0,s.jsxs)(p.Z,{title:"Hub unreachable",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:d.A,note:"The hub is unreachable right now."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsxs)("button",{type:"button",className:v,onClick:n,children:[(0,s.jsx)(c.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Try again"]})})]})});if("signed-out"===e.kind)return(0,s.jsx)(x.G,{title:"Administration",headerRight:T,children:(0,s.jsxs)(p.Z,{title:"expired"===a?"Session ended":"Sign in required",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:i.A,note:"expired"===a?"Your session ended.":"Sign in required."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(r(),{href:"/login",className:y,children:"Sign in"})})]})});if("auth-unavailable"===e.kind)return(0,s.jsx)(x.G,{title:"Administration",headerRight:T,children:(0,s.jsx)(p.Z,{title:"Sign-in unavailable",className:"mx-auto my-12 max-w-md",children:(0,s.jsx)(p.p,{icon:o.A,note:"Browser sign-in is not configured on this hub."})})});if("expired"===a)return(0,s.jsx)(x.G,{title:"Administration",headerRight:T,children:(0,s.jsxs)(p.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:o.A,note:"Your session ended."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(r(),{href:"/login",className:y,children:"Sign in"})})]})});if(!0!==e.user.admin)return(0,s.jsx)(x.G,{title:"Administration",headerRight:T,children:(0,s.jsxs)(p.Z,{title:"Administrator access required",className:"mx-auto my-12 max-w-lg",children:[(0,s.jsx)(p.p,{icon:o.A,note:`You are signed in as ${e.user.username}, but this account is not an administrator.`}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(r(),{href:"/",className:v,children:"Back to fleet"})})]})});if(w)return(0,s.jsx)(x.G,{title:"Administration",headerRight:T,children:(0,s.jsxs)(p.Z,{title:"Session ended",className:"mx-auto my-12 max-w-lg",children:[(0,s.jsx)(p.p,{icon:o.A,note:"Your administrative session is no longer valid."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(r(),{href:"/login",className:y,children:"Sign in again"})})]})});let $=t.map(e=>({machineId:e.machineId,hostname:e.hostname,displayName:e.displayName,tags:e.tags})),E="connecting"===a||"idle"===a;return(0,s.jsx)(x.G,{title:"Administration",headerRight:T,children:(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-5",children:[(0,s.jsx)("div",{className:"flex flex-wrap items-start justify-between gap-x-6 gap-y-3",children:(0,s.jsxs)("span",{className:"inline-flex min-w-0 max-w-full flex-wrap items-center gap-1.5 rounded-full bg-selected px-3 py-1 text-xs font-medium text-foreground",children:[(0,s.jsx)(u.A,{className:"h-3.5 w-3.5 shrink-0 text-accent","aria-hidden":!0}),(0,s.jsxs)("span",{className:"min-w-0 break-all",children:["Administrator \xb7 ",e.user.username]})]})}),(0,s.jsxs)("div",{className:"grid min-w-0 gap-5 xl:grid-cols-12",children:[(0,s.jsx)("div",{className:"min-w-0 xl:col-span-7",children:(0,s.jsx)(X,{api:j,username:e.user.username,csrfToken:e.user.csrfToken,machines:$,machinesPending:E,onAuditChange:I,onSessionLost:S})}),(0,s.jsx)("div",{className:"min-w-0 xl:col-span-5",children:(0,s.jsx)(_,{api:j,csrfToken:e.user.csrfToken,machines:$,machinesPending:E,onSessionLost:S})}),(0,s.jsx)("div",{id:"collectors",className:"min-w-0 scroll-mt-6 xl:col-span-12",children:(0,s.jsx)(B,{api:j,csrfToken:e.user.csrfToken,sessionKey:A,machines:$,onAuditChange:I,onSessionLost:S})}),(0,s.jsx)("div",{className:"min-w-0 xl:col-span-12",children:(0,s.jsx)(P,{api:j,revision:k,onSessionLost:S})})]})]})})}},7241:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(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=4891)),_N_E=e.O()}]);
@@ -0,0 +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()}]);
@@ -0,0 +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()}]);
@@ -0,0 +1,3 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[429],{1:(e,t,s)=>{"use strict";s.d(t,{PE:()=>o,UR:()=>d,kg:()=>l,uW:()=>c});let r=/^[\u0009\u000a\u000d ]*[=+\-@]/,n=/^[\u0009\u000a\u000d]/;function i(e){if(null==e)return"";if("number"==typeof e)return Number.isFinite(e)?String(e):"";if("boolean"==typeof e)return e?"true":"false";let t=0===e.length?e:r.test(e)||n.test(e)?`'${e}`:e;return/[",\t\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function a(e){return e.map(i).join(",")}function l(e){return`${e.map(a).join("\r\n")}\r
2
+ `}function o(e,t,s){if("u"<typeof document)return;let r=new Blob([t],{type:s}),n=URL.createObjectURL(r),i=document.createElement("a");i.href=n,i.download=e,i.rel="noopener",i.style.display="none",document.body.append(i),i.click(),i.remove(),globalThis.setTimeout(()=>URL.revokeObjectURL(n),0)}let d="text/csv;charset=utf-8",c="application/json;charset=utf-8"},438:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(8698).A)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},2910:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(8698).A)("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]])},6582:(e,t,s)=>{"use strict";s.d(t,{E:()=>f,x:()=>g});var r=s(5155),n=s(8500),i=s.n(n),a=s(828),l=s(6914),o=s(7029),d=s(438),c=s(7422),u=s(1735),m=s(3440),h=s(9939);function p(e){return(0,r.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,r.jsx)(a.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.children]})}function x(e){return(0,r.jsx)(i(),{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 g(){let{session:e,phase:t,retryConnection:s}=(0,h.M)();switch(e.kind){case"restoring":return(0,r.jsx)(m.Z,{title:"Checking session",className:"mx-auto my-12 max-w-md",children:(0,r.jsx)(m.p,{icon:l.A,note:"Checking your session…"})});case"restore-failed":return(0,r.jsxs)(m.Z,{title:"Hub unreachable",className:"mx-auto my-12 max-w-md",children:[(0,r.jsx)(m.p,{icon:o.A,note:"The hub is unreachable right now."}),(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(p,{onClick:s,children:"Check again"})})]});case"signed-out":if("expired"===t)return(0,r.jsxs)(m.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,r.jsx)(m.p,{icon:d.A,note:"Your session ended."}),(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(x,{href:"/login",primary:!0,children:"Sign in"})})]});return(0,r.jsxs)(m.Z,{title:"Sign in required",className:"mx-auto my-12 max-w-md",children:[(0,r.jsx)(m.p,{icon:l.A,note:"Sign in required."}),(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(x,{href:"/login",primary:!0,children:"Sign in"})})]});case"auth-unavailable":return(0,r.jsx)(m.Z,{title:"Sign-in unavailable",className:"mx-auto my-12 max-w-md",children:(0,r.jsx)(m.p,{icon:c.A,note:"Browser sign-in is not configured on this hub."})})}return"expired"===t?(0,r.jsxs)(m.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,r.jsx)(m.p,{icon:d.A,note:"Your session ended."}),(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(x,{href:"/login",primary:!0,children:"Sign in"})})]}):"no-permission"===t?(0,r.jsxs)(m.Z,{title:"No permission",className:"mx-auto my-12 max-w-md",children:[(0,r.jsx)(m.p,{icon:c.A,note:`You are signed in as ${e.user.username}, but this hub grants no machine view to this account.`}),(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(p,{onClick:s,children:"Check again"})})]}):null}function f(){let{phase:e,retryConnection:t}=(0,h.M)();return"reconnecting"!==e&&"disconnected"!==e&&"connecting"!==e?null:"connecting"===e?(0,r.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,r.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,r.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,r.jsx)(u.A,{className:"h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,r.jsxs)("span",{children:["Connection lost — values below are ",(0,r.jsx)("strong",{className:"font-medium text-foreground",children:"last known"}),", not live measurements","reconnecting"===e?" — retrying with backoff…":" — retries stopped."]}),"disconnected"===e?(0,r.jsx)(p,{onClick:t,children:"Retry now"}):null]})}},7148:(e,t,s)=>{Promise.resolve().then(s.bind(s,8250)),Promise.resolve().then(s.bind(s,1721)),Promise.resolve().then(s.bind(s,2701)),Promise.resolve().then(s.bind(s,2394))},7499:(e,t,s)=>{"use strict";function r(e,t,s,r){return`rigscope-${e}-${function(e,t="machine"){let s=e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48).replace(/-+$/g,"");return s.length>0?s:t}(t)}-${!Number.isFinite(s)?"unknown-time":new Date(s).toISOString().replace(/[-:]/g,"").replace(/\.\d{3}Z$/,"Z")}.${r}`}s.d(t,{Y8:()=>r})},8250:(e,t,s)=>{"use strict";s.d(t,{HistoryView:()=>eC});var r=s(5155),n=s(8500),i=s.n(n),a=s(2115),l=s(7422),o=s(3896),d=s(1735),c=s(7029),u=s(828),m=s(4173),h=s(3440),p=s(940),x=s(802),g=s(6582),f=s(9939),b=s(8664),y=s(4567),j=s(592);let N=j.U8,v=/^core:(\d+)$/;function w(e){let t=v.exec(e);if(null===t)return null;let s=Number(t[1]);return!Number.isSafeInteger(s)||s<0||s>=j.U8?null:s}function k(e){return[...new Set(e)].sort((e,t)=>(w(e)??0)-(w(t)??0))}function M(e,t=[]){var s;let r=e?.metrics?.payload.cpu,n=new Set(!Number.isFinite(s=Math.max(e?.inventory?.cpu.logicalCores??0,r?.status==="ok"?r.perCore.length:0))?[]:Array.from({length:Math.min(j.U8,Math.max(0,Math.floor(s)))},(e,t)=>`core:${t}`));for(let e of t)"cpu.core"===e.metric&&null!==w(e.resourceId)&&n.add(e.resourceId);return k([...n])}function $(e,t){let s=new Set(t);if(null===e)return k(t).slice(0,N);let r=[];for(let t of e)if(s.has(t)&&null!==w(t)&&(r.push(t),r.length>=N))break;return k(r)}function C(e){let t=w(e);return null===t?e:`Core ${t}`}var A=s(5078),S=s(2910),I=s(9942),P=s(8698);let R=(0,P.A)("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),U=(0,P.A)("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);var L=s(6114);let _=Object.freeze([]),B=new Set(y.H9.map(e=>e.metric)),T=e=>"boolean"==typeof e?e:null,z=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e)?e.slice(0,1e3):null,E=e=>A.pI.some(t=>t.id===e)?e:null,O=e=>"string"==typeof e&&(""===e||e.split(",").every(e=>B.has(e)))?e:null,D=/^core:\d+$/,H=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e&&D.test(e))?[...new Set(e)].slice(0,j.U8):null;function Z(e,t){return(0,L.u)(`history.hidden.${t}.${e}`,_,z)}function F(e){return(0,L.u)(`history.cores.${e}`,null,H)}let G=e=>"bytes"===e||"percent"===e?e:null;function q(e,t){return(0,L.u)(`history.units.${t}.${e}`,"bytes",G)}let V="peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:[outline-color:var(--focus)]";function W({label:e,action:t}){return(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:e}),(0,r.jsx)("span",{"aria-hidden":!0,className:"h-px min-w-0 flex-1 bg-border"}),t]})}let K="inline-flex min-h-8 items-center gap-1.5 rounded-md border border-transparent px-2.5 text-xs transition-colors",Y=`${K} ${V} bg-selected text-foreground`,J=`${K} ${V} bg-card-strong text-muted-foreground hover:text-foreground`;function Q(e){let{machine:t,range:s,selectedMetrics:n,catalog:i,catalogError:a,gpuCards:l,hiddenCards:o,autoRefresh:d,loading:c,manualRefreshing:m,statusText:h,onRangeChange:p,onToggleMetric:x,onSetMetrics:g,onToggleCard:f,onToggleAutoRefresh:b,onRefresh:j}=e,[N,v]=(0,L.u)("history.controlsOpen",!1,T,"session"),w=new Set(n),k=y.H9.filter(({metric:e})=>(0,y.yv)(t,e).available&&(null===i||void 0!==i[e])).map(({metric:e})=>e),P=new Set(k),_=(e,t)=>{let s=new Set(n);for(let r of e)t&&P.has(r)?s.add(r):t||s.delete(r);g([...s])},B=n.some(e=>e.startsWith("gpu.")),z=w.has("cpu.core"),[E,O]=F(t?.machineId??""),D=z?M(t):[],H=$(E,D),Z=new Set(H);return(0,r.jsxs)("section",{"aria-labelledby":"history-query-heading","aria-busy":c,className:"mb-5 min-w-0 rounded-xl border border-border bg-card",children:[(0,r.jsx)("h2",{id:"history-query-heading",className:"sr-only",children:"History query"}),(0,r.jsxs)("div",{className:"flex flex-wrap items-end gap-x-5 gap-y-4 p-4 md:p-5",children:[(0,r.jsxs)("fieldset",{className:"flex min-w-0 flex-col gap-1.5",children:[(0,r.jsx)("legend",{className:"mb-1.5 text-xs text-muted-foreground",children:"Time range"}),(0,r.jsx)("div",{className:"inline-flex flex-wrap rounded-lg border border-border bg-background p-0.5",children:A.pI.map(e=>{let t=s===e.id;return(0,r.jsxs)("label",{className:"cursor-pointer",children:[(0,r.jsx)("input",{type:"radio",name:"history-range",value:e.id,checked:t,onChange:()=>p(e.id),className:"peer sr-only"}),(0,r.jsxs)("span",{className:`inline-flex min-h-8 items-center rounded-md px-2.5 text-xs transition-colors ${V} ${t?"bg-selected font-medium text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[e.shortLabel,(0,r.jsxs)("span",{className:"sr-only",children:[" — ",e.label]})]})]},e.id)})})]}),(0,r.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 sm:ml-auto",children:[(0,r.jsx)("p",{className:"order-first w-full text-xs text-muted-foreground sm:order-none sm:w-auto",children:h}),(0,r.jsxs)("button",{type:"button",onClick:j,disabled:m,className:"inline-flex min-h-8 items-center gap-1.5 rounded-md border border-border bg-background px-2.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-60",children:[(0,r.jsx)(u.A,{className:`h-3.5 w-3.5 ${m?"animate-spin":""}`,"aria-hidden":!0}),"Refresh"]}),(0,r.jsxs)("button",{type:"button",onClick:b,"aria-pressed":d,className:`inline-flex min-h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs transition-colors ${d?"border-accent/40 bg-selected text-foreground":"border-border bg-background text-muted-foreground hover:bg-card-strong hover:text-foreground"}`,children:[d?(0,r.jsx)(S.A,{className:"h-3.5 w-3.5","aria-hidden":!0}):(0,r.jsx)(I.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),d?"Pause":"Resume"]})]})]}),(0,r.jsxs)("div",{className:"border-t border-border px-4 py-4 md:px-5",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsxs)("button",{type:"button","aria-expanded":N,"aria-controls":"history-metric-options",onClick:()=>v(!N),className:"inline-flex min-h-8 items-center gap-1.5 rounded-md text-sm font-medium",children:["Metrics ",(0,r.jsxs)("span",{className:"tnum text-xs font-normal text-muted-foreground",children:[w.size," selected"]}),(0,r.jsx)(R,{"aria-hidden":!0,className:`h-3.5 w-3.5 text-muted-foreground transition-transform ${N?"rotate-180":""}`})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>_(k,!0),disabled:k.every(e=>w.has(e)),className:"inline-flex min-h-8 items-center rounded-md border border-border bg-background px-2.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Select all"}),(0,r.jsx)("button",{type:"button",onClick:()=>g([]),disabled:0===w.size,className:"inline-flex min-h-8 items-center rounded-md border border-border bg-background px-2.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Unselect all"})]})]}),(0,r.jsx)("div",{id:"history-metric-options",hidden:!N,children:(0,r.jsxs)("div",{className:"mt-4 min-w-0 md:col-span-2",children:[(0,r.jsx)("div",{className:"min-w-0",children:(0,r.jsx)("div",{className:"grid gap-x-6 gap-y-5 md:grid-cols-2 xl:grid-cols-3",children:y.P$.map(e=>(0,r.jsxs)("fieldset",{className:`min-w-0 ${"disk"===e.id?"xl:col-span-2":""}`,children:[(0,r.jsx)("legend",{className:"sr-only",children:e.label}),(0,r.jsx)(W,{label:e.label,action:(0,r.jsxs)("div",{className:"flex shrink-0 gap-2",children:[(0,r.jsx)("button",{type:"button","aria-label":`Select all ${e.label} metrics`,onClick:()=>_(e.metrics,!0),disabled:e.metrics.filter(e=>P.has(e)).every(e=>w.has(e)),className:"min-h-6 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:underline disabled:opacity-50",children:"All"}),(0,r.jsx)("button",{type:"button","aria-label":`Unselect all ${e.label} metrics`,onClick:()=>_(e.metrics,!1),disabled:!e.metrics.some(e=>w.has(e)),className:"min-h-6 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:underline disabled:opacity-50",children:"None"})]})}),(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:e.metrics.map(e=>{var s;let n=(0,y.oB)(e);if(null===n)return null;let a=(0,y.yv)(t,e),l=null===i||void 0!==i[e],o=a.available&&l,d=w.has(e),c=(0,y.Lf)(n,0);return(0,r.jsxs)("label",{className:o?"cursor-pointer":"cursor-not-allowed",title:a.available?l?n.description:"This hub does not record this metric.":a.reason??void 0,children:[(0,r.jsx)("input",{type:"checkbox",checked:d,onChange:()=>x(e),disabled:!o&&!d,className:"peer sr-only","aria-label":n.label}),(0,r.jsxs)("span",{className:`${!o?d?`${K} ${V} bg-card-strong text-muted-foreground line-through`:`${K} text-muted-foreground opacity-50`:d?Y:J}`,children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border border-current",style:{color:c.color},children:d?(0,r.jsx)(U,{className:"h-3 w-3",strokeWidth:3}):null}),(s=n.label,({"cpu.usage":"Usage","cpu.core":"Per-core","cpu.iowait":"I/O wait","cpu.pressure":"Pressure","cpu.temperature":"Temperature","cpu.power":"Package power","memory.used":"Used bytes","memory.usage":"Usage %","swap.used":"Swap","memory.pressure.some":"Pressure (some)","memory.pressure.full":"Pressure (full)","gpu.utilization":"Utilization","gpu.memory.used":"VRAM","gpu.temperature":"Temperature","gpu.power":"Power","fs.used":"Space used","fs.usage":"Capacity %","fs.inodes.usage":"Inodes %","net.rx":"Received","net.tx":"Sent"})[e]??s)]})]},e)})}),"gpu"===e.id&&B&&l.length>0?(0,r.jsxs)("fieldset",{className:"mt-4 border-t border-border pt-3",children:[(0,r.jsx)("legend",{className:"sr-only",children:"GPU cards"}),(0,r.jsx)(W,{label:"GPU cards"}),(0,r.jsx)("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:l.map((e,t)=>{let s=e.id,n=!o.has(s);return(0,r.jsxs)("label",{className:"cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:n,onChange:()=>f(s),className:"peer sr-only"}),(0,r.jsxs)("span",{className:n?Y:J,children:[(0,r.jsx)("span",{className:"tnum text-xs text-muted-foreground",children:t+1}),e.label]})]},e.id)})})]}):null,"cpu"===e.id&&z?(0,r.jsxs)("fieldset",{className:"mt-4 border-t border-border pt-3",children:[(0,r.jsx)("legend",{className:"sr-only",children:"CPU cores"}),(0,r.jsx)(W,{label:`CPU cores \xb7 ${H.length} / ${D.length}`,action:(0,r.jsxs)("div",{className:"flex shrink-0 gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>O(null),disabled:H.length===D.length,className:"min-h-6 rounded-sm text-xs text-muted-foreground hover:text-foreground disabled:opacity-50",children:"All cores"}),(0,r.jsx)("button",{type:"button",onClick:()=>O([]),disabled:0===H.length,"aria-label":"Unselect all CPU cores",className:"min-h-6 rounded-sm text-xs text-muted-foreground hover:text-foreground disabled:opacity-50",children:"None"})]})}),0===D.length?(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Core count unavailable."}):(0,r.jsxs)("details",{className:"mt-2",children:[(0,r.jsxs)("summary",{className:"inline-flex min-h-8 cursor-pointer items-center gap-1 rounded-md text-xs text-muted-foreground hover:text-foreground",children:["Choose cores ",(0,r.jsx)(R,{className:"h-3.5 w-3.5","aria-hidden":!0})]}),(0,r.jsx)("div",{className:"mt-2 grid max-h-48 grid-cols-3 gap-1.5 overflow-y-auto p-1",children:D.map(e=>{let t=Z.has(e);return(0,r.jsxs)("label",{className:"min-w-0 cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:t,onChange:()=>{var s;return s=!t,void O(t=>{let r=$(t,D);return s?r.includes(e)?t:[...r,e]:r.filter(t=>t!==e)})},className:"peer sr-only"}),(0,r.jsxs)("span",{className:`${t?Y:J} w-full px-1.5`,children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border border-current",children:t?(0,r.jsx)(U,{className:"h-3 w-3"}):null}),C(e)]})]},e)})})]})]}):null]},e.id))})}),a?(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:a}):null]})})]})]})}var X=s(9429),ee=s(7726),et=s(7284),es=s(6304),er=s(4150);let en="grid grid-cols-[3rem_minmax(0,1fr)_2.5rem] items-center gap-2 sm:grid-cols-[3.5rem_minmax(0,1fr)_3rem_3rem]";function ei({title:e,series:t,fromMs:s,toMs:n,stepMs:i,gaps:l,hiddenKeys:o,onToggleSeries:d}){let[c,u]=(0,a.useState)(!1),m=(0,a.useMemo)(()=>t.filter(e=>!o.has(e.key)),[t,o]),h=(0,er.Au)({series:m,fromMs:s,toMs:n,stepMs:i,gaps:l}),p=(0,a.useMemo)(()=>{let e=t.map(e=>{let t=Array(10).fill("");return(function(e,t,s,r=120){let n=Array(r).fill(null),i=Math.max(1,s-t);for(let a of e){if(a.t<t||a.t>s)continue;let e=a.max??a.avg;if(null===e||!Number.isFinite(e))continue;let l=Math.min(r-1,Math.floor((a.t-t)/i*r));n[l]=Math.max(n[l]??0,Math.min(100,Math.max(0,e)))}return n})(e.points,s,n,120).forEach((e,s)=>{if(null===e)return;let r=Math.min(9,Math.floor(e/10));t[r]+=`M${s},1h1v16h-1z`}),{...e,stats:(0,ee.T6)(e.points),paths:t}});return c&&e.sort((e,t)=>(t.stats.max??-1)-(e.stats.max??-1)),e},[t,s,n,c]),x=p.filter(e=>!o.has(e.key)).reduce((e,t)=>null!==t.stats.max&&(e?.stats.max===null||null===e||t.stats.max>e.stats.max)?t:e,null),g=Math.max(1,n-s),f=(0,ee.$z)(l,s,n);return(0,r.jsxs)("figure",{className:"min-w-0 lg:col-span-full",onPointerLeave:h.clear,children:[(0,r.jsxs)("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsx)("h3",{className:"text-xs font-medium text-foreground",children:e}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-xs",children:[null!==h.timeMs?(0,r.jsxs)("span",{className:"tnum text-muted-foreground",children:[(0,A.r6)(h.timeMs)," \xb7 bucket peak"]}):x?(0,r.jsxs)("span",{className:"tnum text-muted-foreground",children:["Peak \xb7 ",x.label," ",(0,r.jsx)("span",{className:"text-foreground",children:(0,A.dd)(x.stats.max,"percent")})]}):null,(0,r.jsx)("button",{type:"button","aria-pressed":c,onClick:()=>u(!c),className:`min-h-8 rounded-md border border-border px-2 ${c?"bg-selected text-foreground":"bg-background text-muted-foreground hover:text-foreground"}`,children:"Busiest first"})]})]}),(0,r.jsxs)("div",{className:`${en} mb-1 text-xs text-muted-foreground`,"aria-hidden":!0,children:[(0,r.jsx)("span",{children:"Core"}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"sm:hidden",children:"History"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Peak usage over time"})]}),(0,r.jsx)("span",{className:"hidden text-right sm:block",children:null!==h.timeMs?"At cursor":"Last"}),(0,r.jsxs)("span",{className:"text-right",children:[(0,r.jsx)("span",{className:"hidden sm:inline",children:"Peak"}),(0,r.jsx)("span",{className:"sm:hidden",children:null!==h.timeMs?"At cursor":"Peak"})]})]}),(0,r.jsx)("p",{id:`${h.id}-instructions`,className:"sr-only",children:"Focus a core chart and use Left and Right arrows to inspect recorded bucket peaks, Home or End to jump, and Escape to dismiss."}),(0,r.jsx)("div",{role:"region","aria-label":"Per-core history rows",tabIndex:0,className:"max-h-96 overflow-y-auto rounded-md",children:0===p.length?(0,r.jsx)("p",{className:"py-8 text-center text-xs text-muted-foreground",children:"No stored per-core readings."}):p.map(e=>{let t=!o.has(e.key),a=null===h.timeMs?null:(0,es.bO)(e.points,h.timeMs,i,l),c=a?.max??a?.avg??null;return(0,r.jsxs)("div",{className:`${en} min-h-7 border-b border-border/40 text-xs`,children:[(0,r.jsxs)("label",{className:"inline-flex min-h-7 cursor-pointer items-center rounded-sm",children:[(0,r.jsx)("input",{type:"checkbox",checked:t,onChange:()=>d(e.key),className:"peer sr-only"}),(0,r.jsx)("span",{className:`${t?"text-foreground":"text-muted-foreground line-through"} rounded-sm peer-focus-visible:outline-2 peer-focus-visible:outline-accent`,children:e.label})]}),(0,r.jsxs)("svg",{viewBox:"0 0 120 18",preserveAspectRatio:"none",role:"img","aria-label":`${e.label}: ${null!==h.timeMs?`${(0,A.dd)(c,"percent")} at ${(0,A.r6)(h.timeMs)}`:`latest ${(0,A.dd)(e.stats.latest,"percent")}`}, peak ${(0,A.dd)(e.stats.max,"percent")}${t?"":", hidden"}`,"aria-describedby":`${h.id}-instructions`,tabIndex:t?0:void 0,onPointerMove:t?e=>{let t=e.currentTarget.getBoundingClientRect();h.inspect((0,es.yk)(e.clientX,t.left,t.width,s,n))}:void 0,onFocus:h.onFocus,onBlur:h.clear,onKeyDown:h.onKeyDown,className:`h-5 w-full cursor-crosshair rounded-sm focus-visible:outline-2 focus-visible:outline-accent ${t?"":"opacity-20"}`,children:[(0,r.jsxs)("title",{children:[e.label," \xb7 Last ",(0,A.dd)(e.stats.latest,"percent")," \xb7 Peak ",(0,A.dd)(e.stats.max,"percent")]}),t?e.paths.map((e,t)=>e?(0,r.jsx)("path",{d:e,fill:t<5?"var(--cpu)":t<8?"var(--warn)":"var(--crit)",opacity:t<5?.15+.17*t:.65+t%5*.07},t):null):null,f.map(e=>(0,r.jsx)("rect",{x:(e.fromMs-s)/g*120,width:(e.toMs-e.fromMs)/g*120,y:0,height:18,fill:"var(--card)"},`${e.fromMs}-${e.toMs}`)),null!==h.timeMs?(0,r.jsx)("line",{"aria-hidden":!0,x1:(h.timeMs-s)/g*120,x2:(h.timeMs-s)/g*120,y1:0,y2:18,stroke:"var(--foreground)",strokeWidth:"1",vectorEffect:"non-scaling-stroke",pointerEvents:"none"}):null]}),(0,r.jsx)("span",{className:"tnum hidden text-right text-muted-foreground sm:block",children:t?(0,A.dd)(null!==h.timeMs?c:e.stats.latest,"percent"):"—"}),(0,r.jsxs)("span",{className:`tnum text-right ${t&&(e.stats.max??0)>=80?"text-crit":"text-muted-foreground"}`,children:[(0,r.jsx)("span",{className:"hidden sm:inline",children:t?(0,A.dd)(e.stats.max,"percent"):"—"}),(0,r.jsx)("span",{className:"sm:hidden",children:t?(0,A.dd)(null!==h.timeMs?c:e.stats.max,"percent"):"—"})]})]},e.key)})}),(0,r.jsxs)("div",{className:`${en} mt-2 text-xs text-muted-foreground`,"aria-hidden":!0,children:[(0,r.jsx)("span",{}),(0,r.jsx)("div",{className:"flex justify-between gap-2 tnum",children:(0,ee.Cf)(s,n,3).map((e,t)=>(0,r.jsx)("span",{className:1===t?"hidden sm:inline":"",children:(0,A.O5)(e,g)},e))}),(0,r.jsx)("span",{className:"hidden sm:block"}),(0,r.jsx)("span",{})]}),(0,r.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[[{label:"0–49%",color:"var(--cpu)"},{label:"50–79%",color:"var(--warn)"},{label:"80–100%",color:"var(--crit)"}].map(e=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"h-2 w-4 rounded-sm",style:{backgroundColor:e.color}}),e.label]},e.label)),(0,r.jsx)("span",{children:"No fill \xb7 no reading"})]})]})}function ea(e,t){return`${e}\0${t}`}function el(e,t,s,r,n){let i=(0,y.oB)(s);return null===i?[]:e.series.filter(e=>e.metric===s&&(void 0===r||e.resourceId===r)).map((e,r)=>{let a=(0,y.Lf)(i,r),l=n?.(e,i,r)??(0,y.bP)(t,s,e.resourceId);return{key:ea(e.metric,e.resourceId),label:l,metric:e.metric,resourceId:e.resourceId,color:a.color,dash:a.dash,points:e.points}})}function eo(e){let{machine:t,result:s,selectedMetrics:n,hiddenCards:i,hiddenSeries:a,onToggleSeries:l}=e,[o]=F(t.machineId),d=$(o,M(t,s.series)),c=function(e){let{machine:t,result:s,selectedMetrics:r,hiddenCards:n,coreIds:i}=e,a=new Set(r),l=[];if(["cpu.usage","cpu.core","cpu.temperature","cpu.power","cpu.iowait","cpu.pressure"].filter(e=>a.has(e)).length>0){let e=[],r=["cpu.usage","cpu.iowait","cpu.pressure"].filter(e=>a.has(e));if(r.length>0&&e.push({key:"cpu.usage",title:r.length>1?"Usage & stalls":(0,y.oB)(r[0]).label,unit:"percent",series:r.flatMap(e=>el(s,t,e,void 0,(t,s)=>"cpu.pressure"===e?"Pressure (some)":s.shortLabel)),emptyMessage:"No stored CPU readings in this range."}),a.has("cpu.core")){let r=(0,y.oB)("cpu.core"),n=M(t,s.series),a=i??$(null,n),l=function(e,t){let s=(0,y.oB)("cpu.core");if(null===s)return[];let r=new Map(e.series.filter(e=>"cpu.core"===e.metric).map(e=>[e.resourceId,e]));return t.flatMap((e,t)=>{let n=r.get(e),i=(0,y.Lf)(s,t);return[{key:ea("cpu.core",e),label:C(e),metric:"cpu.core",resourceId:e,color:i.color,dash:i.dash,points:n?.points??[]}]})}(s,a),o=n.length>a.length;e.push({key:"cpu.core",title:o?`Per-core usage \xb7 ${a.length} of ${n.length}`:"Per-core usage",unit:r.unit,series:l,emptyMessage:0===n.length?"No stored per-core readings in this range.":0===a.length?"No CPU cores are selected. Choose cores under Metrics.":"No stored per-core readings for the selected cores in this range."})}if(a.has("cpu.temperature")){let r=(0,y.oB)("cpu.temperature");e.push({key:"cpu.temperature",title:"Temperature",unit:r.unit,series:el(s,t,"cpu.temperature"),emptyMessage:"No stored CPU temperature readings in this range."})}if(a.has("cpu.power")){let r=(0,y.oB)("cpu.power");e.push({key:"cpu.power",title:"Package power",unit:r.unit,series:el(s,t,"cpu.power"),emptyMessage:"No stored CPU package power readings in this range."})}l.push({key:"cpu",title:"CPU",charts:e})}if(["memory.used","memory.usage","memory.pressure.some","memory.pressure.full","swap.used"].filter(e=>a.has(e)).length>0){let e=[],r=["memory.used","memory.usage"].filter(e=>a.has(e));if(r.length>0){let n=r.map(e=>({unit:(0,y.oB)(e).unit,series:el(s,t,e,void 0,()=>"RAM")}));e.push({key:"memory.capacity",title:"RAM",...n[0],unitGroup:"memory",views:n,emptyMessage:"No stored memory readings in this range."})}a.has("swap.used")&&e.push({key:"swap.used",title:"Swap",unit:"bytes",series:el(s,t,"swap.used"),emptyMessage:"No stored swap readings in this range."});let n=["memory.pressure.some","memory.pressure.full"].filter(e=>a.has(e));if(n.length>0){let r=(0,y.oB)(n[0]),i=n.flatMap(e=>el(s,t,e,void 0,(t,s)=>"memory.pressure.some"===e?"Some":"memory.pressure.full"===e?"Full":s.shortLabel));e.push({key:"memory.pressure",title:"Memory pressure",unit:r.unit,series:i,emptyMessage:"No stored memory pressure in this range."})}l.push({key:"memory",title:"Memory",charts:e})}let o=["gpu.utilization","gpu.memory.used","gpu.temperature","gpu.power"].filter(e=>a.has(e));if(o.length>0){let e=(0,y.ue)(t,s.series),r=e.filter(e=>!n.has(e.id));for(let n of(0===r.length&&l.push({key:"gpu-empty",title:"GPU",charts:[{key:"gpu-empty",title:"Per-card history",unit:"percent",series:[],emptyMessage:e.length>0?"All GPU cards are hidden. Re-enable a card under Metrics to see its panels.":"No supported GPU cards or stored GPU history in this range."}]}),r)){let e=o.map(e=>{let r=(0,y.oB)(e),i=function(e,t,s,r){return el(e,t,s,r,(e,t)=>"gpu.utilization"===s?"Utilization":"gpu.memory.used"===s?"VRAM used":t.shortLabel).map(e=>({...e}))}(s,t,e,n.id),a="gpu.memory.used"===e&&null!==n.totalBytes?`of ${(0,A.dd)(n.totalBytes,"bytes")}`:void 0;return{key:`${n.id}-${e}`,title:r.shortLabel,unit:r.unit,series:i,emptyMessage:`No stored ${r.shortLabel.toLowerCase()} readings for this card in this range.`,note:a}});l.push({key:`gpu-${n.id}`,title:`GPU ${n.index+1}${n.label?` \xb7 ${n.label}`:""}`,charts:e})}}if(["fs.used","fs.usage","fs.inodes.usage"].filter(e=>a.has(e)).length>0){let e=[],r=["fs.used","fs.usage"].filter(e=>a.has(e));if(r.length>0){let n=r.map(e=>({unit:(0,y.oB)(e).unit,series:el(s,t,e)}));e.push({key:"fs.capacity",title:"Capacity used",...n[0],unitGroup:"filesystem",views:n,emptyMessage:"No stored filesystem usage in this range."})}if(a.has("fs.inodes.usage")){let r=(0,y.oB)("fs.inodes.usage");e.push({key:"fs.inodes.usage",title:"Inodes used",unit:r.unit,series:el(s,t,"fs.inodes.usage"),emptyMessage:"No stored inode usage in this range."})}l.push({key:"filesystems",title:"Filesystems",charts:e})}let d=["disk.read","disk.write"].filter(e=>a.has(e));if(d.length>0){let e=d.flatMap(e=>{let r=(0,y.oB)(e);return el(s,t,e,void 0,s=>`${(0,y.bP)(t,e,s.resourceId)} ${r.shortLabel.toLowerCase()}`)});l.push({key:"disk",title:"Disk throughput",charts:[{key:"disk",title:"Read and write",unit:"bytes_per_second",series:e,emptyMessage:"No stored disk throughput in this range."}]})}let c=["disk.read.latency","disk.write.latency"].filter(e=>a.has(e)),u=["io.pressure.some","io.pressure.full"].filter(e=>a.has(e));if(c.length>0||u.length>0||a.has("disk.utilization")){let e=[];if(c.length>0){let r=c.flatMap(e=>{let r=(0,y.oB)(e);return el(s,t,e,void 0,s=>`${(0,y.bP)(t,e,s.resourceId)} ${r.shortLabel.toLowerCase()}`)}),n=(0,y.oB)(c[0]);e.push({key:"disk.latency",title:"Latency",unit:n.unit,series:r,emptyMessage:"No stored disk latency in this range."})}if(a.has("disk.utilization")){let r=(0,y.oB)("disk.utilization");e.push({key:"disk.utilization",title:"Utilization",unit:r.unit,series:el(s,t,"disk.utilization"),emptyMessage:"No stored disk utilization in this range."})}if(u.length>0){let r=(0,y.oB)(u[0]),n=u.flatMap(e=>el(s,t,e,void 0,(t,s)=>"io.pressure.some"===e?"Some":"io.pressure.full"===e?"Full":s.shortLabel));e.push({key:"io.pressure",title:"I/O pressure",unit:r.unit,series:n,emptyMessage:"No stored I/O pressure in this range."})}l.push({key:"disk-health",title:"Disk health",charts:e})}let m=["net.rx","net.tx"].filter(e=>a.has(e));if(m.length>0){let e=m.flatMap(e=>{let r=(0,y.oB)(e);return el(s,t,e,void 0,s=>`${(0,y.bP)(t,e,s.resourceId)} ${r.shortLabel.toLowerCase()}`)});l.push({key:"network",title:"Network throughput",charts:[{key:"network",title:"Received and sent",unit:"bytes_per_second",series:e,emptyMessage:"No stored network throughput in this range."}]})}return l}({machine:t,result:s,selectedMetrics:n,hiddenCards:i,coreIds:d});return(0,r.jsx)(er._C,{children:(0,r.jsx)("div",{className:"grid grid-cols-1 gap-5",children:c.map(n=>{let i=n.charts.find(e=>"cpu.core"===e.key&&e.series.length>4),o=i?[...n.charts.filter(e=>e!==i),i]:n.charts,d=i&&4===o.length?"grid gap-6 lg:grid-cols-2 xl:grid-cols-3":o.length>1&&!(i&&2===o.length)?"grid gap-6 lg:grid-cols-2":"flex flex-col gap-6";return(0,r.jsx)(h.Z,{title:n.title,children:(0,r.jsx)("div",{className:d,children:o.map((n,d)=>{let c=n.unitGroup,u=c?e.capacityUnits[c]:void 0,m=n.views?.find(e=>e.unit===u)??n.views?.[0]??n,h=n===i||!i&&o.length%2==1&&d===o.length-1;return"cpu.core"===n.key&&n.series.length>8?(0,r.jsx)(ei,{title:n.title,series:n.series,fromMs:s.fromMs,toMs:s.toMs,gaps:s.gaps,stepMs:(0,ee.jl)(s.stepMs,s.tier,t.expectedIntervalMs),hiddenKeys:a,onToggleSeries:l},n.key):(0,r.jsx)(et.t,{title:n.title,unit:m.unit,series:m.series,fromMs:s.fromMs,toMs:s.toMs,stepMs:(0,ee.jl)(s.stepMs,s.tier,t.expectedIntervalMs),gaps:s.gaps,hiddenKeys:a,onToggleSeries:l,emptyMessage:n.emptyMessage,note:n.note,action:c&&n.views&&n.views.length>1?(0,r.jsx)("div",{role:"group","aria-label":`${n.title} units`,className:"inline-flex rounded-md border border-border bg-background p-0.5",children:n.views.map(t=>(0,r.jsx)("button",{type:"button","aria-pressed":t.unit===m.unit,onClick:()=>e.onCapacityUnitChange(c,t.unit),className:`min-h-7 rounded px-2 text-xs transition-colors ${t.unit===m.unit?"bg-selected text-foreground":"text-muted-foreground hover:text-foreground"}`,children:"bytes"===t.unit?"Bytes":"%"},t.unit))}):void 0,maxDrawPoints:"cpu.core"===n.key?150:void 0,className:h?"lg:col-span-full":void 0},n.key)})})},n.key)})})},`${t.machineId}|${s.toMs-s.fromMs}`)}var ed=s(1),ec=s(7499);let eu={raw:"raw samples","1m":"1-minute rollups","1h":"1-hour rollups"};function em(e){return e.displayName?.trim()||e.hostname.trim()||e.machineId}function eh(e,t){return`${e}\0${t}`}function ep(e){let t=new Set(e.selectedMetrics),s=new Set((0,y.ue)(e.machine,e.result.series).filter(t=>!e.hiddenCards.has(t.id)).map(e=>e.id));return e.result.series.filter(r=>!(!t.has(r.metric)||e.hiddenSeries.has(eh(r.metric,r.resourceId))||"cpu.core"===r.metric&&void 0!==e.coreIds&&!e.coreIds.includes(r.resourceId)||r.metric.startsWith("gpu.")&&""!==r.resourceId&&!s.has(r.resourceId)))}function ex(e){return new Date(e).toISOString()}function eg(e){return(0,y.oB)(e)?.label??e}function ef(e){return ep(e).map(t=>({metric:t.metric,label:eg(t.metric),resourceId:t.resourceId,resourceLabel:(0,y.bP)(e.machine,t.metric,t.resourceId),unit:t.unit,unitLabel:(0,y.RL)(t.unit),stats:(0,ee.T6)(t.points),points:t.points.map(t=>{let s=Math.min(e.result.toMs,t.t+e.result.stepMs),r=null!==t.min||null!==t.max||null!==t.avg;return{t:t.t,tIso:ex(t.t),bucketStartMs:t.t,bucketStartIso:ex(t.t),bucketEndMs:s,bucketEndIso:ex(s),min:t.min,max:t.max,avg:t.avg,state:r?"recorded":"unavailable"}})}))}function eb(e){return(0,ee.$z)(e.result.gaps,e.result.fromMs,e.result.toMs).map(e=>({...e,fromIso:ex(e.fromMs),toIso:ex(e.toMs)}))}function ey(e){let t=new Set(e.result.series.map(e=>e.metric));return e.selectedMetrics.filter(e=>!t.has(e))}function ej(e){let t=new Set(e.selectedMetrics),s=new Set(ep(e).map(e=>eh(e.metric,e.resourceId)));return e.result.series.filter(e=>t.has(e.metric)&&!s.has(eh(e.metric,e.resourceId))).length}function eN(e,t){let s=e.result,r=["Only the visible series from the loaded History result are included; this export does not query more data."];"raw"!==s.tier&&r.push(`Values are ${eu[s.tier]}, not individual raw samples.`),s.truncated&&r.push("The loaded result is partial: the hub limited or shortened this history query.");let n=eb(e);n.length>0&&r.push(`${n.length} recorded data gap${1===n.length?"":"s"} included.`),t.length>0&&r.push(`Selected metrics without stored data: ${t.join(", ")}.`);let i=ej(e);return i>0&&r.push(`${i} selected series hidden in this view were not exported.`),r}let ev=["record_type","metric","metric_label","resource_id","resource_label","unit","bucket_start_ms","bucket_start_iso","bucket_end_ms","bucket_end_iso","min","max","avg","value_state","gap_kind","gap_reason","gap_dropped_records"],ew="inline-flex min-h-7 items-center rounded-md border border-border bg-background px-2 text-xs text-foreground transition-colors hover:bg-card-strong disabled:cursor-not-allowed disabled:opacity-50";function ek(e){let[t,s]=(0,a.useState)(null),n=ep(e).length,i=t=>{let r=Date.now(),n={...e,exportedAt:r};try{let e,i,a,l,o,d,c,u,m=function(e,t,s=Date.now()){return(0,ec.Y8)("history",em(e.machine),s,t)}(n,t,r),h="csv"===t?function(e){let t,s,r,n,i,a,l=e.exportedAt??Date.now(),o=(t=(0,A.ly)(e.range),s=e.result,r=ep(e),n=ey(e),i=eb(e),a=e.selectedMetrics.map(eg).join("; "),[["Rigscope History export"],["Scope","Visible series from the loaded History result"],["Machine",em(e.machine)],["Machine ID",e.machine.machineId],["Query",a],["Range",`${t.label} (${ex(s.fromMs)} – ${ex(s.toMs)})`],["Resolution",`${eu[s.tier]} \xb7 ${s.stepMs} ms buckets`],["Loaded at",ex(e.loadedAt)],["Exported at",ex(l)],["Partial",s.truncated?"true":"false"],["Gaps",String(i.length)],["Visible series",String(r.length)],["Selected without stored data",n.length>0?n.join(", "):"none"],["Note",eN(e,n).join(" ")],[]]);for(let t of(o.push([...ev]),ef(e)))for(let e of t.points)o.push(["bucket",t.metric,t.label,t.resourceId,t.resourceLabel,t.unit,e.bucketStartMs,e.bucketStartIso,e.bucketEndMs,e.bucketEndIso,e.min,e.max,e.avg,e.state,"","",""]);for(let t of eb(e))o.push(["gap","","","","","",t.fromMs,t.fromIso,t.toMs,t.toIso,"","","","gap",t.kind,t.reason??"",t.droppedRecords??""]);return(0,ed.kg)(o)}(n):(e=n.exportedAt??Date.now(),i=(0,A.ly)(n.range),a=n.result,l=ef(n),o=ey(n),d=eb(n),c=ej(n),u={app:"Rigscope",kind:"history",version:1,exportedAt:ex(e),scope:{description:"Visible series from the loaded History result",machine:{id:n.machine.machineId,name:em(n.machine),hostname:n.machine.hostname,connected:n.machine.connected,lastReceivedAt:n.machine.lastReceivedAt},query:{range:{id:i.id,label:i.label,fromMs:a.fromMs,fromIso:ex(a.fromMs),toMs:a.toMs,toIso:ex(a.toMs)},selectedMetrics:[...n.selectedMetrics],visibleSeries:l.length,hiddenSeriesCount:c}},resolution:{tier:a.tier,label:eu[a.tier],stepMs:a.stepMs,expectedIntervalMs:n.machine.expectedIntervalMs??null},loadedAt:ex(n.loadedAt),partial:a.truncated,gaps:d,series:l.map(e=>({metric:e.metric,label:e.label,resourceId:e.resourceId,resourceLabel:e.resourceLabel,unit:e.unit,unitLabel:e.unitLabel,summary:{points:e.stats.count,min:e.stats.min,max:e.stats.max,averageOfBucketAverages:e.stats.avg,latest:e.stats.latest,latestAt:null===e.stats.latestT?null:ex(e.stats.latestT),firstAt:null===e.stats.firstT?null:ex(e.stats.firstT),lastAt:null===e.stats.lastT?null:ex(e.stats.lastT)},points:e.points})),missingData:o.map(e=>({metric:e,label:eg(e),reason:"No stored series in the loaded result."})),notes:eN(n,o)},`${JSON.stringify(u,null,2)}
3
+ `);(0,ed.PE)(m,h,"csv"===t?ed.UR:ed.uW),s(null)}catch{s("The history export could not be created.")}};return(0,r.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Export visible",(0,r.jsx)("span",{className:"sr-only",children:` (${n} series from the loaded result)`})]}),(0,r.jsx)("button",{type:"button",onClick:()=>i("csv"),"aria-label":"Download visible history as CSV",title:"Download the visible series from this loaded result as CSV",className:ew,children:"CSV"}),(0,r.jsx)("button",{type:"button",onClick:()=>i("json"),"aria-label":"Download visible history as JSON",title:"Download the visible series from this loaded result as JSON",className:ew,children:"JSON"}),null!==t?(0,r.jsxs)("span",{role:"status",className:"inline-flex items-center gap-1 text-xs text-warn",children:[(0,r.jsx)(d.A,{className:"h-3 w-3","aria-hidden":!0}),t]}):null]})}function eM(e){return e.displayName?.trim()||e.hostname.trim()||e.machineId}function e$(){return(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-5 xl:grid-cols-2","aria-busy":"true",children:[(0,r.jsx)(h.Z,{title:"Loading stored history",children:(0,r.jsx)("div",{className:"h-40 animate-pulse rounded-lg bg-card-strong","aria-hidden":!0})}),(0,r.jsx)(h.Z,{title:"Preparing charts",children:(0,r.jsx)("div",{className:"h-40 animate-pulse rounded-lg bg-card-strong","aria-hidden":!0})})]})}function eC(){let e,t,s,n,{session:j,phase:N,machines:v,retryConnection:w}=(0,f.M)(),k=(0,g.x)(),{machine:C,machineId:S,requestedMachineId:I}=(0,b.JG)("history"),[P,R]=q(S,"memory"),[U,_]=q(S,"filesystem"),B={memory:P,filesystem:U},[z,D]=(0,L.u)("history.range","10m",E),[H,G]=(0,L.u)(`history.metrics.${S}`,null,O),[V]=F(S),W=M(C),K=$(V,W),[Y,J]=Z(S,"cards"),[ee,et]=Z(S,"series"),es=(0,a.useMemo)(()=>new Set(Y),[Y]),er=(0,a.useMemo)(()=>new Set(ee),[ee]),[en,ei]=(0,L.u)("history.autoRefresh",!0,T,"session"),[ea,el]=(0,a.useState)(null),[ed,ec]=(0,a.useState)(null),[eu,em]=(0,a.useState)(0),eh=(0,a.useMemo)(()=>void 0===C?"":(0,y.er)(C).join(","),[C?.machineId,C?.inventory,C?.metrics?.payload.gpus]),ep=H??eh,ex=""===ep?[]:ep.split(","),eg="signed-in"===j.kind&&void 0!==C&&""!==S&&""!==ep;(0,a.useEffect)(()=>{if(""===S){el(null),ec(null);return}let e=new AbortController;return el(null),ec(null),fetch(`/api/history/metrics?machineId=${encodeURIComponent(S)}`,{signal:e.signal,cache:"no-store",headers:{Accept:"application/json"}}).then(async t=>{if(!t.ok){if(401===t.status||403===t.status||404===t.status)return;throw Error(`catalog ${t.status}`)}let s=await t.json();if(null===s||"object"!=typeof s||!("metrics"in s))throw Error("catalog shape");let r=s.metrics;if(null===r||"object"!=typeof r)throw Error("catalog shape");let n=Object.create(null);for(let[e,t]of Object.entries(r))null!==t&&"object"==typeof t&&"string"==typeof t.unit&&(n[e]={unit:t.unit});e.signal.aborted||el(n)}).catch(()=>{e.signal.aborted||ec("The hub's metric catalog could not be loaded; standard metric names are shown.")}),()=>e.abort()},[S]);let{data:ef,error:eb,loading:ey,manualRefreshing:ej}=(0,X.n)({machineId:S,metricsKey:ep,coreIdsKey:ex.includes("cpu.core")&&K.length!==W.length?K.join(","):void 0,range:z,enabled:eg,autoRefresh:en,refreshNonce:eu});(0,a.useEffect)(()=>{eb?.kind==="rate-limited"&&ei(!1)},[eb?.kind,ei]);let eN=ef?.result??null,ev=void 0===C?[]:(0,y.ue)(C,eN?.series??[]),ew=(0,A.ly)(z),eC=null!==eb?null!==ef?`${"rate-limited"===eb.kind?"Refresh paused":"Refresh failed"} \xb7 ${(0,A.ei)(ef.loadedAt)}`:"History unavailable":null!==ef?`Updated ${(0,A.ei)(ef.loadedAt)}`:ey?"Loading…":"",eA=eg&&null===ef&&null===eb,eS=v.length,eI="disconnected"===N;return(0,r.jsx)(m.G,{title:"History",machineId:S,machineView:"history",headerRight:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(p.$E,{}),(0,r.jsx)(x.B,{})]}),children:k||(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{role:"status","aria-live":"polite",className:"sr-only",children:eb?.message??""}),(0,r.jsx)(Q,{machine:C,range:z,selectedMetrics:ex,catalog:ea,catalogError:ed,gpuCards:ev,hiddenCards:es,autoRefresh:en,loading:ey,manualRefreshing:ej,statusText:eC,onRangeChange:D,onToggleMetric:e=>{let t=new Set(ex);t.has(e)?t.delete(e):t.add(e),G([...t].sort().join(","))},onSetMetrics:e=>G([...new Set(e)].sort().join(",")),onToggleCard:e=>{J(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),[...s]})},onToggleAutoRefresh:()=>ei(e=>!e),onRefresh:()=>em(e=>e+1)}),"reconnecting"===N||"disconnected"===N?(0,r.jsxs)("div",{role:"status",className:"mb-4 flex items-start gap-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,r.jsx)(d.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,r.jsxs)("span",{children:["Live feed ","disconnected"===N?"disconnected":"reconnecting"," \xb7 stored history available"]}),"disconnected"===N?(0,r.jsxs)("button",{type:"button",onClick:w,className:"ml-auto inline-flex min-h-8 shrink-0 items-center gap-1.5 rounded-md border border-border px-2.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,r.jsx)(u.A,{className:"h-3 w-3","aria-hidden":!0}),"Retry now"]}):null]}):null,void 0===C?eI?(0,r.jsxs)(h.Z,{title:"Hub disconnected",className:"mx-auto mt-3 max-w-xl",children:[(0,r.jsx)(h.p,{icon:c.A,note:"The hub is unreachable, so the authorized machine list is unavailable."}),(0,r.jsx)("div",{className:"mt-2 flex justify-center",children:(0,r.jsxs)("button",{type:"button",onClick:w,className:"inline-flex min-h-8 items-center gap-1.5 rounded-md border border-border px-3 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,r.jsx)(u.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Check again"]})})]}):0!==eS||eI||"idle"!==N&&"connecting"!==N&&"reconnecting"!==N?0===eS?(0,r.jsx)(h.Z,{title:"No machines",className:"mx-auto mt-3 max-w-xl",children:(0,r.jsx)(h.p,{icon:o.A,note:"No machines are available in your authorized fleet."})}):(0,r.jsxs)(h.Z,{title:"Machine not found",className:"mx-auto mt-3 max-w-xl",children:[(0,r.jsx)(h.p,{icon:o.A,note:"This machine is unavailable or outside your access."}),I?(0,r.jsxs)("p",{className:"tnum mt-2 text-center text-xs text-muted-foreground",children:["Requested identifier: ",I]}):null,(0,r.jsx)("div",{className:"mt-2 flex justify-center",children:(0,r.jsx)(i(),{href:"/",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:"Back to fleet"})})]}):(0,r.jsx)(h.Z,{title:"Waiting for machines",className:"mx-auto mt-3 max-w-xl",children:(0,r.jsx)(h.p,{icon:o.A,note:"Waiting for the hub to report your authorized machines…"})}):0===ex.length?(0,r.jsx)(h.Z,{title:"No metrics selected",className:"mx-auto mt-3 max-w-xl",children:(0,r.jsx)(h.p,{icon:o.A,note:""===eh?"No metric families are shared with this hub.":"Choose at least one metric above to draw history."})}):null!==eb&&null===ef?(t=(e=function(e){switch(e.kind){case"unauthorized":return{title:"Session ended",note:"Your session is no longer accepted, so stored history is hidden.",icon:l.A};case"denied":return{title:"History access denied",note:e.message,icon:l.A};case"missing":return{title:"Machine unavailable",note:e.message,icon:o.A};case"rate-limited":return{title:"History requests limited",note:e.message,icon:d.A};case"unavailable":return{title:"History unavailable",note:e.message,icon:c.A};case"network":return{title:"Hub unreachable",note:"The hub could not be reached for stored history.",icon:c.A};case"invalid":return{title:"Unexpected history response",note:e.message,icon:d.A}}}(eb)).icon,(0,r.jsxs)(h.Z,{title:e.title,className:"mx-auto mt-3 max-w-xl",children:[(0,r.jsx)(h.p,{icon:t,note:e.note}),(0,r.jsxs)("div",{className:"mt-2 flex flex-wrap justify-center gap-2",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>em(e=>e+1),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,r.jsx)(u.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Try again"]}),"unauthorized"===eb.kind?(0,r.jsx)(i(),{href:"/login",className:"inline-flex items-center rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90",children:"Sign in"}):null]})]})):(ey||eA)&&null===ef?(0,r.jsx)(e$,{}):null===ef?(0,r.jsx)(h.Z,{title:"History",className:"mx-auto mt-3 max-w-xl",children:(0,r.jsx)(h.p,{icon:o.A,note:"No stored history has arrived yet."})}):(n="raw"===(s=ef.result).tier?"raw samples":"1m"===s.tier?"1-minute rollups":"1-hour rollups",(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"mb-3 flex flex-wrap items-baseline gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-foreground",children:[(0,r.jsx)("span",{"aria-hidden":!0,className:`inline-block h-2 w-2 shrink-0 rounded-full ${C.connected?"bg-ok":"bg-crit"}`}),eM(C)]}),(0,r.jsxs)("span",{children:[(0,A.r6)(s.fromMs)," – ",(0,A.r6)(s.toMs)]}),(0,r.jsxs)("span",{className:"tnum",title:n,children:[(0,A.I_)(s.stepMs)," buckets"]}),(0,r.jsx)("div",{className:"ml-auto self-center",children:(0,r.jsx)(ek,{machine:C,result:s,range:z,selectedMetrics:(0,y.Cv)(ex,B),hiddenCards:es,hiddenSeries:er,coreIds:K,loadedAt:ef.loadedAt})})]}),s.truncated?(0,r.jsxs)("div",{role:"status",className:"mb-4 flex items-start gap-2 rounded-lg bg-warn-soft px-4 py-2.5 text-xs text-foreground",children:[(0,r.jsx)(d.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,r.jsx)("span",{children:"Partial history \xb7 narrow the range for more detail."})]}):null,s.gaps.length>0?(0,r.jsxs)("details",{className:"mb-4 max-w-3xl text-xs text-muted-foreground",children:[(0,r.jsxs)("summary",{className:"inline-flex min-h-8 cursor-pointer items-center gap-2 rounded-md text-warn",children:[(0,r.jsx)(d.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,r.jsxs)("span",{children:[(0,r.jsx)("strong",{className:"font-medium",children:"Data gaps:"})," ",(0,A.fH)(s.gaps,s.fromMs,s.toMs)]})]}),(0,r.jsxs)("ul",{className:"mt-1.5 flex flex-col gap-1",children:[s.gaps.slice(0,20).map(e=>(0,r.jsxs)("li",{className:"tnum text-xs",children:[(0,A.r6)(e.fromMs)," – ",(0,A.r6)(e.toMs)," (",(0,A.I_)(e.toMs-e.fromMs),"):"," ","dropped"===e.kind?"dropped":"missed",e.reason?` \xb7 ${e.reason}`:"",void 0!==e.droppedRecords?` \xb7 ${e.droppedRecords} record${1===e.droppedRecords?"":"s"}`:""]},`${e.fromMs}-${e.toMs}-${e.kind}`)),s.gaps.length>20?(0,r.jsxs)("li",{className:"text-xs text-muted-foreground",children:["…and ",s.gaps.length-20," more."]}):null]})]}):null,0===s.series.length?(0,r.jsx)(h.Z,{title:"No stored points",className:"mx-auto max-w-xl",children:(0,r.jsx)(h.p,{icon:o.A,note:`No stored readings for ${void 0===C?"this machine":eM(C)} in ${ew.label.toLowerCase()}.`})}):(0,r.jsx)(eo,{machine:C,result:s,selectedMetrics:ex,hiddenCards:es,hiddenSeries:er,onToggleSeries:e=>{et(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),[...s]})},capacityUnits:B,onCapacityUnitChange:(e,t)=>("memory"===e?R:_)(t)})]}))]})})}},9942:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(8698).A)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]])}},e=>{e.O(0,[157,939,103,408,441,794,358],()=>e(e.s=7148)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[177],{460:(e,t,r)=>{"use strict";r.d(t,{D:()=>m,N:()=>c});var n=r(2115),s=(e,t,r,n,s,a,o,l)=>{let i=document.documentElement,m=["light","dark"];function c(t){var r;(Array.isArray(e)?e:[e]).forEach(e=>{let r="class"===e,n=r&&a?s.map(e=>a[e]||e):s;r?(i.classList.remove(...n),i.classList.add(a&&a[t]?a[t]:t)):i.setAttribute(e,t)}),r=t,l&&m.includes(r)&&(i.style.colorScheme=r)}if(n)c(n);else try{let e=localStorage.getItem(t)||r,n=o&&"system"===e?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e;c(n)}catch(e){}},a=["light","dark"],o="(prefers-color-scheme: dark)",l=n.createContext(void 0),i={setTheme:e=>{},themes:[]},m=()=>{var e;return null!=(e=n.useContext(l))?e:i},c=e=>n.useContext(l)?n.createElement(n.Fragment,null,e.children):n.createElement(u,{...e}),d=["light","dark"],u=({forcedTheme:e,disableTransitionOnChange:t=!1,enableSystem:r=!0,enableColorScheme:s=!0,storageKey:i="theme",themes:m=d,defaultTheme:c=r?"system":"light",attribute:u="data-theme",value:b,children:p,nonce:g,scriptProps:E})=>{let[w,S]=n.useState(()=>y(i,c)),[k,C]=n.useState(()=>"system"===w?v():w),T=b?Object.values(b):m,L=n.useCallback(e=>{let n=e;if(!n)return;"system"===e&&r&&(n=v());let o=b?b[n]:n,l=t?f(g):null,i=document.documentElement,m=e=>{"class"===e?(i.classList.remove(...T),o&&i.classList.add(o)):e.startsWith("data-")&&(o?i.setAttribute(e,o):i.removeAttribute(e))};if(Array.isArray(u)?u.forEach(m):m(u),s){let e=a.includes(c)?c:null,t=a.includes(n)?n:e;i.style.colorScheme=t}null==l||l()},[g]),A=n.useCallback(e=>{let t="function"==typeof e?e(w):e;S(t);try{localStorage.setItem(i,t)}catch(e){}},[w]),P=n.useCallback(t=>{C(v(t)),"system"===w&&r&&!e&&L("system")},[w,e]);n.useEffect(()=>{let e=window.matchMedia(o);return e.addListener(P),P(e),()=>e.removeListener(P)},[P]),n.useEffect(()=>{let e=e=>{e.key===i&&(e.newValue?S(e.newValue):A(c))};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[A]),n.useEffect(()=>{L(null!=e?e:w)},[e,w]);let _=n.useMemo(()=>({theme:w,setTheme:A,forcedTheme:e,resolvedTheme:"system"===w?k:w,themes:r?[...m,"system"]:m,systemTheme:r?k:void 0}),[w,A,e,k,r,m]);return n.createElement(l.Provider,{value:_},n.createElement(h,{forcedTheme:e,storageKey:i,attribute:u,enableSystem:r,enableColorScheme:s,defaultTheme:c,value:b,themes:m,nonce:g,scriptProps:E}),p)},h=n.memo(({forcedTheme:e,storageKey:t,attribute:r,enableSystem:a,enableColorScheme:o,defaultTheme:l,value:i,themes:m,nonce:c,scriptProps:d})=>{let u=JSON.stringify([r,t,l,e,m,i,a,o]).slice(1,-1);return n.createElement("script",{...d,suppressHydrationWarning:!0,nonce:"",dangerouslySetInnerHTML:{__html:`(${s.toString()})(${u})`}})}),y=(e,t)=>{let r;try{r=localStorage.getItem(e)||void 0}catch(e){}return r||t},f=e=>{let t=document.createElement("style");return e&&t.setAttribute("nonce",e),t.appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(t),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(t)},1)}},v=e=>(e||(e=window.matchMedia(o)),e.matches?"dark":"light")},1743:()=>{},2737:(e,t,r)=>{"use strict";r.d(t,{ThemeProvider:()=>a});var n=r(5155),s=r(460);function a({children:e,...t}){return(0,n.jsx)(s.N,{...t,children:e})}},7311:(e,t,r)=>{Promise.resolve().then(r.t.bind(r,1743,23)),Promise.resolve().then(r.bind(r,2737)),Promise.resolve().then(r.bind(r,9939))}},e=>{e.O(0,[334,939,441,794,358],()=>e(e.s=7311)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[520],{1735:(e,t,a)=>{"use strict";a.d(t,{A:()=>r});let r=(0,a(8698).A)("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},3321:(e,t,a)=>{"use strict";var r=a(4645);a.o(r,"usePathname")&&a.d(t,{usePathname:function(){return r.usePathname}}),a.o(r,"useRouter")&&a.d(t,{useRouter:function(){return r.useRouter}}),a.o(r,"useSearchParams")&&a.d(t,{useSearchParams:function(){return r.useSearchParams}})},5e3:(e,t,a)=>{"use strict";a.d(t,{LoginView:()=>h});var r=a(5155),s=a(3321),n=a(2115),i=a(1735),l=a(7422),d=a(7029),o=a(8773),c=a(9939);function u(e){let{outcome:t}=e;switch(t.kind){case"invalid-credentials":return(0,r.jsxs)("p",{role:"alert",className:"flex items-center gap-2 text-xs text-warn",children:[(0,r.jsx)(i.A,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),"That username or password does not match."]});case"auth-unavailable":return(0,r.jsxs)("p",{role:"alert",className:"flex items-start gap-2 text-xs text-warn",children:[(0,r.jsx)(l.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),(0,r.jsx)("span",{children:"Sign-in is unavailable. Contact your administrator."})]});case"unreachable":return(0,r.jsxs)("p",{role:"alert",className:"flex items-center gap-2 text-xs text-crit",children:[(0,r.jsx)(d.A,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),"Cannot reach the hub. Try again."]});case"error":return(0,r.jsxs)("p",{role:"alert",className:"flex items-center gap-2 text-xs text-crit",children:[(0,r.jsx)(i.A,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),t.detail??"Sign-in failed."]});case"signed-in":return null}}function h(){let{session:e,login:t}=(0,c.M)(),a=(0,s.useRouter)(),[i,d]=(0,n.useState)(""),[h,m]=(0,n.useState)(""),[x,p]=(0,n.useState)(!1),[f,g]=(0,n.useState)(null),b=async e=>{if(e.preventDefault(),x)return;p(!0),g(null);let a=await t(i,h);"signed-in"!==a.kind&&(p(!1),g(a))},k=x||"signed-in"===e.kind;return(0,n.useEffect)(()=>{"signed-in"===e.kind&&a.replace("/")},[e.kind,x,a]),(0,r.jsx)("main",{className:"flex min-h-dvh items-center justify-center bg-background p-6",children:(0,r.jsxs)("div",{className:"w-full max-w-sm",children:[(0,r.jsxs)("div",{className:"mb-6 flex items-center gap-2.5",children:[(0,r.jsx)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-border text-accent",children:(0,r.jsx)(o.R,{className:"h-4 w-4","aria-hidden":!0})}),(0,r.jsx)("span",{className:"text-sm font-semibold tracking-tight",children:"Rigscope"})]}),(0,r.jsxs)("div",{className:"rounded-xl border border-border bg-card p-6",children:[(0,r.jsx)("h1",{className:"text-lg font-semibold tracking-tight",children:"Sign in"}),"auth-unavailable"===e.kind?(0,r.jsx)("div",{className:"mt-5 flex flex-col gap-3",children:(0,r.jsxs)("p",{role:"alert",className:"flex items-start gap-2 text-xs text-warn",children:[(0,r.jsx)(l.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),(0,r.jsx)("span",{children:"Sign-in is unavailable. Contact your administrator."})]})}):(0,r.jsxs)("form",{onSubmit:b,className:"mt-5 flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,r.jsx)("label",{htmlFor:"login-username",className:"text-xs font-medium",children:"Username"}),(0,r.jsx)("input",{id:"login-username",name:"username",type:"text",autoComplete:"username",required:!0,value:i,onChange:e=>d(e.target.value),className:"rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/70",disabled:k})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,r.jsx)("label",{htmlFor:"login-password",className:"text-xs font-medium",children:"Password"}),(0,r.jsx)("input",{id:"login-password",name:"password",type:"password",autoComplete:"current-password",required:!0,value:h,onChange:e=>m(e.target.value),className:"rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/70",disabled:k})]}),f?(0,r.jsx)(u,{outcome:f}):null,(0,r.jsx)("button",{type:"submit",disabled:k,className:"mt-1 inline-flex items-center justify-center rounded-md bg-accent px-3 py-2 text-sm font-medium text-accent-foreground transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-60",children:k?"Signing in…":"Sign in"})]})]})]})})}},7029:(e,t,a)=>{"use strict";a.d(t,{A:()=>r});let r=(0,a(8698).A)("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]])},7422:(e,t,a)=>{"use strict";a.d(t,{A:()=>r});let r=(0,a(8698).A)("ShieldAlert",[["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:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]])},8698:(e,t,a)=>{"use strict";a.d(t,{A:()=>l});var r=a(2115);let s=(...e)=>e.filter((e,t,a)=>!!e&&""!==e.trim()&&a.indexOf(e)===t).join(" ").trim();var n={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let i=(0,r.forwardRef)(({color:e="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:i,className:l="",children:d,iconNode:o,...c},u)=>(0,r.createElement)("svg",{ref:u,...n,width:t,height:t,stroke:e,strokeWidth:i?24*Number(a)/Number(t):a,className:s("lucide",l),...c},[...o.map(([e,t])=>(0,r.createElement)(e,t)),...Array.isArray(d)?d:[d]])),l=(e,t)=>{let a=(0,r.forwardRef)(({className:a,...n},l)=>(0,r.createElement)(i,{ref:l,iconNode:t,className:s(`lucide-${e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,a),...n}));return a.displayName=`${e}`,a}},8773:(e,t,a)=>{"use strict";a.d(t,{R:()=>s});var r=a(5155);function s(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"})]})}},8858:(e,t,a)=>{Promise.resolve().then(a.bind(a,5e3))}},e=>{e.O(0,[939,441,794,358],()=>e(e.s=8858)),_N_E=e.O()}]);