@camstack/addon-admin-ui 1.2.604 → 1.2.606
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/assets/Addons-DwdVdYn5.js +5 -0
- package/dist/assets/{AdminPage-B9sdR6yD.js → AdminPage-qR6elCnl.js} +1 -1
- package/dist/assets/{AdminSectionedPage-Di2VI8A1.js → AdminSectionedPage-6893SaIU.js} +1 -1
- package/dist/assets/{AiProfiles-DwQZldFN.js → AiProfiles-qBmxjey8.js} +2 -2
- package/dist/assets/{Authentication-CMBgIYCp.js → Authentication-CDgdDuh0.js} +1 -1
- package/dist/assets/{Build-BPF-jpLK.js → Build-DaOoHR-6.js} +3 -3
- package/dist/assets/{Calendars-lddz6ZEe.js → Calendars-BGQ8HwrY.js} +1 -1
- package/dist/assets/CameraGrids-UIVs5OTB.js +1 -0
- package/dist/assets/{Cluster-De1RL3Fs.js → Cluster-D2l7vSfX.js} +1 -1
- package/dist/assets/{CompositionBlockEditor-B0oU4gJG.js → CompositionBlockEditor-CSCK2rCI.js} +2 -2
- package/dist/assets/{CompositionEditorPage-o4_rUh83.js → CompositionEditorPage-D2LWLo3H.js} +1 -1
- package/dist/assets/{Data-BrdEF29B.js → Data-BVrTjAgG.js} +2 -2
- package/dist/assets/{DeviceDetail-BZUd-DAf.js → DeviceDetail-CDHbp6Im.js} +2 -2
- package/dist/assets/{DeviceDoActionFields-BPsB-f31.js → DeviceDoActionFields-NY7wB-VN.js} +1 -1
- package/dist/assets/{Devices-DmDA_J0U.js → Devices-BPiNbgT8.js} +1 -1
- package/dist/assets/{EditTemplateButton-Bazz4Pt4.js → EditTemplateButton-B8SCTea8.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-B28rSWqV.js → EmbedPlayerPage--uqLrJXG.js} +1 -1
- package/dist/assets/History-BP-AB2nV.js +1 -0
- package/dist/assets/Identity-CocJq58e.js +1 -0
- package/dist/assets/InstancesTable-CgR4OQbD.js +1 -0
- package/dist/assets/IntegrationDetail-puYzC2ri.js +1 -0
- package/dist/assets/{IntegrationHub-DwJAPbKr.js → IntegrationHub-50C35JXv.js} +1 -1
- package/dist/assets/{Integrations-Be3dLjNq.js → Integrations-DJpMIOMj.js} +1 -1
- package/dist/assets/{Integrations-BWF9wcWz.js → Integrations-qPptabot.js} +2 -2
- package/dist/assets/{Library-CvnIw7kn.js → Library-BJHez0dz.js} +1 -1
- package/dist/assets/{Locations-BMg1Zl7f.js → Locations-BAf5NoRS.js} +1 -1
- package/dist/assets/{Logs-CLzySzHb.js → Logs-LsCNqILy.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-DfSAMcgB.js → MaskShapeCanvas-D1jjdVSr.js} +1 -1
- package/dist/assets/{MotionZonesSettings-lq8C670W.js → MotionZonesSettings-DiIPf88t.js} +1 -1
- package/dist/assets/MyAccess-D4Hu1xA1.js +2 -0
- package/dist/assets/{Network-whsaEkOS.js → Network-CRa159Fl.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-B8UxjFBZ.js → NodeAddonsSettingsPanel-hPglGkot.js} +1 -1
- package/dist/assets/{Notifications-CurhviRP.js → Notifications-CLYFpSJP.js} +1 -1
- package/dist/assets/{Pipeline-C2akOMKR.js → Pipeline-CawM5bRg.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-Cp5Q0GE2.js → PrivacyMaskSettings-tg9GXaVS.js} +1 -1
- package/dist/assets/Recordings-CRp_FkXE.js +1 -0
- package/dist/assets/{ScanSubnetEditor-lKcDCgXF.js → ScanSubnetEditor-DN3Ie7Og.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-D4HtqSC1.js → SceneMonitorEditor-CINJ-4Mp.js} +1 -1
- package/dist/assets/SessionsList-DwHQoi9f.js +2 -0
- package/dist/assets/{Showroom-C25UNaak.js → Showroom-DMiHvqBS.js} +1 -1
- package/dist/assets/StorageLocationsTable-Cd_oXHgn.js +1 -0
- package/dist/assets/{System-DXfDAESB.js → System-C4UGj5Nu.js} +1 -1
- package/dist/assets/{Templates-C-6WUOdi.js → Templates-mjnjZIoX.js} +1 -1
- package/dist/assets/{Terminal-DNZoAT74.js → Terminal-BRS-F-xZ.js} +3 -5
- package/dist/assets/{TrainingProviders-CRP4iTuX.js → TrainingProviders-Sy1iY23E.js} +1 -1
- package/dist/assets/{Viewer-CVu0k37l.js → Viewer-D8XgtpH4.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-PiMYY04-.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Dx3SvE4V.js} +1 -1
- package/dist/assets/{addon-icons-context-DzG39awM.js → addon-icons-context-DihpM3HF.js} +1 -1
- package/dist/assets/{ai-page.helpers-tWf2BKhe.js → ai-page.helpers-BrgCvprD.js} +1 -1
- package/dist/assets/{archive-7oqv5c2w.js → archive-B2eCCknS.js} +1 -1
- package/dist/assets/{assignment-candidates-B8uBn9td.js → assignment-candidates-C6YdocP-.js} +1 -1
- package/dist/assets/{authed-media-BsEr81QN.js → authed-media-C1aRt5ci.js} +1 -1
- package/dist/assets/{bell-off-CGgJclc7.js → bell-off-CHS3Aly3.js} +1 -1
- package/dist/assets/{board-model-UxhF05M4.js → board-model-C14bsdrK.js} +1 -1
- package/dist/assets/{boxes-B_Y4V3Ek.js → boxes-DftcHvx4.js} +1 -1
- package/dist/assets/{calendar-clock-B0-YSjGo.js → calendar-clock-DHLZaiyj.js} +1 -1
- package/dist/assets/circle-slash-C5yZWtgS.js +1 -0
- package/dist/assets/client-DTyBaAoV.js +809 -0
- package/dist/assets/{create-composition-DhUup0uF.js → create-composition-gstr8g_x.js} +2 -2
- package/dist/assets/crop-CvVxDKo4.js +1 -0
- package/dist/assets/{database-zap-BC8v5Gc5.js → database-zap-B8fphlJj.js} +1 -1
- package/dist/assets/{device-integration-icon-Cvjh6ihp.js → device-integration-icon-Cap0VdNl.js} +1 -1
- package/dist/assets/device-picker-model-DgL25n41.js +1 -0
- package/dist/assets/dist-B57q2s8O.js +809 -0
- package/dist/assets/{dist-BZOmaLJ2.js → dist-CIX_FLwE.js} +1 -1
- package/dist/assets/{eraser-BN9Jm7v9.js → eraser-DnVOOBJ7.js} +1 -1
- package/dist/assets/{file-up-D3z4d_SX.js → file-up-CS3QVGu0.js} +1 -1
- package/dist/assets/{format-kc3FiPSl.js → format-Ch0AKvVb.js} +1 -1
- package/dist/assets/{grip-vertical-CVi57Mnf.js → grip-vertical-Dx0Aqv-v.js} +1 -1
- package/dist/assets/{hard-drive-download-XJqU5Yhh.js → hard-drive-download-BL7h_atC.js} +1 -1
- package/dist/assets/{hostInit-D412Cho_.js → hostInit-BpnP417g.js} +1 -1
- package/dist/assets/i18n-BETemoOB.js +1 -0
- package/dist/assets/{icons-DZNWg00W.js → icons-C5yBX8zj.js} +1 -1
- package/dist/assets/index-Cr7bUFvd.js +4 -0
- package/dist/assets/{key-CXhExtg1.js → key-KMleps0f.js} +1 -1
- package/dist/assets/{key-square-OYFlMu43.js → key-square-CknpM0L_.js} +1 -1
- package/dist/assets/{layers-B8emxX0I.js → layers-CA0xrUXV.js} +1 -1
- package/dist/assets/{link-2-off-C4UZJh-L.js → link-2-off-I79TL553.js} +1 -1
- package/dist/assets/{linked-devices-model-DIyr-r0R.js → linked-devices-model-Di0tfcU-.js} +1 -1
- package/dist/assets/{list-ordered-COE9JhoK.js → list-ordered-H5cpKqfQ.js} +1 -1
- package/dist/assets/{memory-stick-DxMJDVF9.js → memory-stick-BYu3Pl2-.js} +1 -1
- package/dist/assets/{message-square-plus-mfEtoXqX.js → message-square-plus-C-VzE-nz.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-4af06987.js → mf-entry-bootstrap-0-09df2f33.js} +2 -2
- package/dist/assets/{mic-off-chy45-le.js → mic-off-BB0y3SKK.js} +1 -1
- package/dist/assets/{monitor-off-CYZktw89.js → monitor-off-CeTiFn5M.js} +1 -1
- package/dist/assets/{monitor-smartphone-Cla2sWWl.js → monitor-smartphone-DiwqWkLr.js} +1 -1
- package/dist/assets/mount-DgL25n41.js +1 -0
- package/dist/assets/{notification-rule-status-CX6NUm4f.js → notification-rule-status-BaNEQqyB.js} +1 -1
- package/dist/assets/{player-overlays-Dikds8gI.js → player-overlays-BDeIsXux.js} +1 -1
- package/dist/assets/remoteEntry-C_e5pzbe.js +1 -0
- package/dist/assets/{ruler-Bc_pxTOp.js → ruler-Cuy2zovK.js} +1 -1
- package/dist/assets/{scan-eye-BUPnUTKr.js → scan-eye-BuWxqByv.js} +1 -1
- package/dist/assets/{scissors-DdbRlSDX.js → scissors-BJTb03-b.js} +1 -1
- package/dist/assets/{search-x-eS925uQD.js → search-x-D8VnLXBR.js} +1 -1
- package/dist/assets/{send-BHWiY78y.js → send-B00RXUVi.js} +1 -1
- package/dist/assets/{settings-2-CyRa-bUA.js → settings-2-C90cMzQT.js} +1 -1
- package/dist/assets/{shapes-C9UDTqdB.js → shapes-CBF9943U.js} +1 -1
- package/dist/assets/{sigma-D5JGGdP2.js → sigma-CJJT2Cam.js} +1 -1
- package/dist/assets/{speaker-Cl3Koi46.js → speaker-B5S7k0DT.js} +1 -1
- package/dist/assets/src-Da4HIMZv.js +100 -0
- package/dist/assets/{sso-popup-BaK-NY5x.js → sso-popup-DF07jkOe.js} +1 -1
- package/dist/assets/{step-inspector-model-BDAJBL2T.js → step-inspector-model-Czc1qNL0.js} +1 -1
- package/dist/assets/{table-2-BV86FpaK.js → table-2-l7PUi3h6.js} +1 -1
- package/dist/assets/{timer-reset-CQFbOsih.js → timer-reset-DqOUz58T.js} +1 -1
- package/dist/assets/{unlink-CO3ZHU5X.js → unlink-Bj6T0cfp.js} +1 -1
- package/dist/assets/{usb-Ib0Kj-IW.js → usb-7d2iIO7E.js} +1 -1
- package/dist/assets/{use-device-bound-caps-WSOdDrrB.js → use-device-bound-caps-Davivnb7.js} +1 -1
- package/dist/assets/{use-scenes-feed-BydEv6TD.js → use-scenes-feed-DpaATilO.js} +1 -1
- package/dist/assets/{use-stationary-objects-CcgUGmNJ.js → use-stationary-objects-Cu-P84Mj.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-BdSgd4AO.js → useAdminDeviceRemoval-COqvh6I9.js} +1 -1
- package/dist/assets/useEventInvalidation-DgL25n41.js +1 -0
- package/dist/assets/{useNodeUrlSelection-mzzzEn3T.js → useNodeUrlSelection-DSNzRVoI.js} +1 -1
- package/dist/assets/user-round-BvKrqouP.js +1 -0
- package/dist/assets/{user-x-CUrAwpls.js → user-x-CK_55Ufn.js} +1 -1
- package/dist/assets/{variable-COKKMJbR.js → variable-qhs89ABT.js} +1 -1
- package/dist/assets/{video-BSNDvfCe.js → video-BMbZ77OA.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-De1PJyhy.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-tmFYPP3M.js} +2 -2
- package/dist/index.html +10 -10
- package/dist/server/addon.js +3 -72
- package/package.json +2 -2
- package/dist/assets/Addons-cMrauTBc.js +0 -5
- package/dist/assets/History-BQYmqLbi.js +0 -1
- package/dist/assets/Identity-DZe6EnfF.js +0 -1
- package/dist/assets/InstancesTable-tMHEIn4o.js +0 -1
- package/dist/assets/IntegrationDetail-DbyHZmhw.js +0 -1
- package/dist/assets/MyAccess-nVzeQLPF.js +0 -2
- package/dist/assets/Recordings-k9xWpSTi.js +0 -1
- package/dist/assets/SessionsList-CxJU6jkU.js +0 -2
- package/dist/assets/StorageLocationsTable-BeMq-Y4a.js +0 -1
- package/dist/assets/circle-slash-CeIIQW23.js +0 -1
- package/dist/assets/client-C3Nr53Gn.js +0 -809
- package/dist/assets/crop-BCtCO5Qk.js +0 -1
- package/dist/assets/device-picker-model-TeZnNAB7.js +0 -1
- package/dist/assets/dist-Du8dfILw.js +0 -809
- package/dist/assets/i18n-ChjX2Pvm.js +0 -1
- package/dist/assets/index-Bec3SQjl.js +0 -4
- package/dist/assets/mount-TeZnNAB7.js +0 -1
- package/dist/assets/remoteEntry-4sXHM_Xw.js +0 -1
- package/dist/assets/src-VAvW-zoJ.js +0 -100
- package/dist/assets/useEventInvalidation-TeZnNAB7.js +0 -1
- package/dist/assets/user-round-C9-NR3Al.js +0 -1
package/dist/server/addon.js
CHANGED
|
@@ -73085,7 +73085,7 @@ var TerminalInstanceInfoSchema = object({
|
|
|
73085
73085
|
/**
|
|
73086
73086
|
* False while the node the instance is bound to is not in the cluster
|
|
73087
73087
|
* topology (forgotten, renamed, re-paired). The instance is kept; the
|
|
73088
|
-
* operator re-points it
|
|
73088
|
+
* operator re-points it on the Terminal page.
|
|
73089
73089
|
*/
|
|
73090
73090
|
nodeInCluster: boolean(),
|
|
73091
73091
|
profileId: string(),
|
|
@@ -73123,41 +73123,7 @@ var TerminalOutputBatchSchema = object({
|
|
|
73123
73123
|
snapshot: string().optional(),
|
|
73124
73124
|
events: array(TerminalOutputEventSchema).readonly()
|
|
73125
73125
|
});
|
|
73126
|
-
method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(
|
|
73127
|
-
targetNodeId: string().min(1),
|
|
73128
|
-
profileId: string().min(1),
|
|
73129
|
-
name: string().trim().min(1).max(160).optional(),
|
|
73130
|
-
executable: string().max(1024).optional(),
|
|
73131
|
-
args: array(string().max(2048)).max(64).optional(),
|
|
73132
|
-
cwd: string().max(1024).optional(),
|
|
73133
|
-
environment: array(string().max(4096)).max(64).optional(),
|
|
73134
|
-
profileSettings: ProfileSettingsBagSchema.optional()
|
|
73135
|
-
}), TerminalInstanceInfoSchema, {
|
|
73136
|
-
kind: "mutation",
|
|
73137
|
-
auth: "admin"
|
|
73138
|
-
}), method(object({
|
|
73139
|
-
instanceId: string().min(1),
|
|
73140
|
-
/** Re-point the instance to another node; the profile must exist there. */
|
|
73141
|
-
targetNodeId: string().min(1).max(256).optional(),
|
|
73142
|
-
name: string().trim().min(1).max(160).optional(),
|
|
73143
|
-
executable: string().max(1024).optional(),
|
|
73144
|
-
args: array(string().max(2048)).max(64).optional(),
|
|
73145
|
-
cwd: string().max(1024).optional(),
|
|
73146
|
-
environment: array(string().max(4096)).max(64).optional(),
|
|
73147
|
-
profileSettings: ProfileSettingsBagSchema.optional()
|
|
73148
|
-
}), TerminalInstanceInfoSchema, {
|
|
73149
|
-
kind: "mutation",
|
|
73150
|
-
auth: "admin"
|
|
73151
|
-
}), method(object({ instanceId: string().min(1) }), _void(), {
|
|
73152
|
-
kind: "mutation",
|
|
73153
|
-
auth: "admin"
|
|
73154
|
-
}), method(object({
|
|
73155
|
-
instanceId: string().min(1),
|
|
73156
|
-
enabled: boolean()
|
|
73157
|
-
}), TerminalInstanceInfoSchema, {
|
|
73158
|
-
kind: "mutation",
|
|
73159
|
-
auth: "admin"
|
|
73160
|
-
}), method(_void(), array(TerminalLegacyCameraSchema).readonly(), { auth: "admin" }), method(object({
|
|
73126
|
+
method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalLegacyCameraSchema).readonly(), { auth: "admin" }), method(object({
|
|
73161
73127
|
stableId: string().min(1),
|
|
73162
73128
|
name: string().trim().min(1).max(160).optional()
|
|
73163
73129
|
}), TerminalInstanceInfoSchema, {
|
|
@@ -84907,27 +84873,6 @@ Object.freeze({
|
|
|
84907
84873
|
access: "create",
|
|
84908
84874
|
role: "admin"
|
|
84909
84875
|
},
|
|
84910
|
-
"terminalSession.createInstance": {
|
|
84911
|
-
capName: "terminal-session",
|
|
84912
|
-
capScope: "system",
|
|
84913
|
-
addonId: null,
|
|
84914
|
-
access: "create",
|
|
84915
|
-
role: "admin"
|
|
84916
|
-
},
|
|
84917
|
-
"terminalSession.deleteInstance": {
|
|
84918
|
-
capName: "terminal-session",
|
|
84919
|
-
capScope: "system",
|
|
84920
|
-
addonId: null,
|
|
84921
|
-
access: "delete",
|
|
84922
|
-
role: "admin"
|
|
84923
|
-
},
|
|
84924
|
-
"terminalSession.listInstances": {
|
|
84925
|
-
capName: "terminal-session",
|
|
84926
|
-
capScope: "system",
|
|
84927
|
-
addonId: null,
|
|
84928
|
-
access: "view",
|
|
84929
|
-
role: "admin"
|
|
84930
|
-
},
|
|
84931
84876
|
"terminalSession.listLegacyCameras": {
|
|
84932
84877
|
capName: "terminal-session",
|
|
84933
84878
|
capScope: "system",
|
|
@@ -84970,20 +84915,6 @@ Object.freeze({
|
|
|
84970
84915
|
access: "create",
|
|
84971
84916
|
role: "admin"
|
|
84972
84917
|
},
|
|
84973
|
-
"terminalSession.setInstanceEnabled": {
|
|
84974
|
-
capName: "terminal-session",
|
|
84975
|
-
capScope: "system",
|
|
84976
|
-
addonId: null,
|
|
84977
|
-
access: "create",
|
|
84978
|
-
role: "admin"
|
|
84979
|
-
},
|
|
84980
|
-
"terminalSession.updateInstance": {
|
|
84981
|
-
capName: "terminal-session",
|
|
84982
|
-
capScope: "system",
|
|
84983
|
-
addonId: null,
|
|
84984
|
-
access: "create",
|
|
84985
|
-
role: "admin"
|
|
84986
|
-
},
|
|
84987
84918
|
"terminalSession.writeInput": {
|
|
84988
84919
|
capName: "terminal-session",
|
|
84989
84920
|
capScope: "system",
|
|
@@ -90299,7 +90230,7 @@ var AdminUIAddon = class extends BaseAddon {
|
|
|
90299
90230
|
capability: adminUiCapability,
|
|
90300
90231
|
provider: {
|
|
90301
90232
|
getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
|
|
90302
|
-
getVersion: async () => ({ version: "1.2.
|
|
90233
|
+
getVersion: async () => ({ version: "1.2.606" })
|
|
90303
90234
|
}
|
|
90304
90235
|
}];
|
|
90305
90236
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-admin-ui",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.606",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Admin UI — Vite frontend build and server-side addon",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
}
|
|
51
51
|
],
|
|
52
52
|
"requires": {
|
|
53
|
-
"server": ">=1.2.
|
|
53
|
+
"server": ">=1.2.795"
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{B as e,C as t,J as n,K as r,R as i,S as a,V as o,Y as s,et as c,o as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$n as d,Bn as f,Fn as p,Ii as m,Kt as h,Li as g,Ni as _,Oi as v,Q as y,Rt as b,Sn as x,Tn as S,Ut as C,ai as w,bi as T,bt as ee,ct as te,fn as ne,ot as re,ut as E,wn as ie,xr as D}from"./player-overlays-Dikds8gI.js";import{us as O}from"./client-C3Nr53Gn.js";import{a as k,p as ae}from"./video-BSNDvfCe.js";import{Br as oe,Ei as se,Fr as ce,Ir as le,Lf as ue,Pf as A,Pr as de,Qi as fe,Rr as pe,Sa as me,Uc as j,Vt as he,Zs as M,_a as ge,_n as N,aa as P,ar as F,ba as I,da as _e,df as L,ea as R,er as z,fa as B,ga as V,gn as ve,ha as ye,ia as be,jt as xe,la as H,na as Se,nr as Ce,oa as we,pa as Te,ra as U,rr as Ee,sa as De,ta as Oe,tr as ke,ua as Ae,va as je,vi as W,xa as Me,zr as Ne}from"./src-VAvW-zoJ.js";import{t as G}from"./useTranslation-BJr-n0es.js";import"./mount-TeZnNAB7.js";import{Fr as Pe,Nr as Fe,kr as K}from"./index-Bec3SQjl.js";import{t as q}from"./AdminPage-B9sdR6yD.js";import{i as Ie,r as Le,t as Re}from"./addon-kind-filter-CEGKkC1O.js";import{t as J}from"./NodeAddonsSettingsPanel-B8UxjFBZ.js";import{t as ze}from"./framework-packages-DoBKjjer.js";import{n as Be,t as Y}from"./useNodeUrlSelection-mzzzEn3T.js";function Ve(e){if(e===void 0)return null;switch(e.state){case`failed`:case`refused`:case`missing`:case`crashed`:return{kind:e.state,...e.reason===void 0?{}:{reason:e.reason}};default:return null}}c();var X={queued:{icon:T,bg:`bg-muted text-foreground-subtle`,labelKey:`addons.addonRowBadge.queued`},updating:{icon:D,bg:`bg-primary/10 text-primary`,labelKey:`addons.addonRowBadge.updating`,spin:!0},"done-pending-restart":{icon:p,bg:`bg-amber-500/10 text-amber-700`,labelKey:`addons.addonRowBadge.pendingRestart`},done:{icon:g,bg:`bg-success/10 text-success`,labelKey:`addons.addonRowBadge.done`},failed:{icon:k,bg:`bg-danger/10 text-danger`,labelKey:`addons.addonRowBadge.failed`}};function Z({item:e}){let{t:n}=G(),r=X[e.status],i=r.icon;return t(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${r.bg}`,title:e.error,children:[a(i,{className:`w-2.5 h-2.5 ${r.spin?`animate-spin`:``}`}),n(r.labelKey)]})}var He=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),Ue=new Set([`done`,`failed`,`skipped`]);function We(e){return!Ue.has(e.phase)&&!He.has(e.jobState)}function Ge(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=He.has(e.state);for(let i of e.tasks)r&&i.finishedAtMs!==null&&t-i.finishedAtMs>6e4||n.set(i.packageName,{jobId:e.jobId,packageName:i.packageName,phase:i.phase,fromVersion:i.fromVersion,toVersion:i.toVersion,error:i.error,jobState:e.state,finishedAtMs:i.finishedAtMs})}return n}function Ke(){let{data:e}=Ae({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=ue(O.AddonsJobProgress,e=>e.job.jobId);return r(()=>{let n=new Map;for(let t of e??[])n.set(t.jobId,t);for(let[e,r]of t)n.set(e,r.job);return Ge([...n.values()],Date.now())},[e,t])}var qe={queued:{icon:T,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.queued`},fetching:{icon:D,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.fetching`,spin:!0},staged:{icon:D,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.staged`,spin:!0},validating:{icon:D,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.validating`,spin:!0},applying:{icon:D,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.applying`,spin:!0},restarting:{icon:D,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,labelKey:`addons.jobProgress.restarting`,spin:!0},applied:{icon:D,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.finalizing`,spin:!0},done:{icon:g,cls:`bg-success/10 text-success`,labelKey:`addons.jobProgress.updated`},failed:{icon:k,cls:`bg-danger/10 text-danger`,labelKey:`addons.jobProgress.failed`},skipped:{icon:ne,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.skipped`}};function Je({progress:e}){let{t:n}=G(),r=qe[e.phase],i=r.icon,o=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return t(`span`,{"data-testid":`addon-job-progress`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded shrink-0 ${r.cls}`,title:o,children:[a(i,{className:`w-2.5 h-2.5 ${r.spin?`animate-spin`:``}`}),n(r.labelKey),t(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function Ye(e,t){return e.filter(e=>e.packageName===t).slice().sort((e,t)=>e.isHub===t.isHub?e.nodeName.localeCompare(t.nodeName):e.isHub?-1:1)}function Xe(e){let t=e.version===null?``:` ${e.version}`,n=e.isOnline?``:` (offline: removed when it reconnects)`;return`- ${e.nodeName}${t}${n}`}function Q(e,t,n){let r=[`${e} will be uninstalled from ${t.length} node(s). Its runners stop, its capabilities are deregistered and its code is deleted:`,...t.map(Xe)];return n.length>0&&r.push(`Could not ask: ${n.join(`, `)} — not included.`),r.push(`This cannot be undone.`),r.join(`
|
|
2
|
-
`)}function Ze(e,t,n){let r=[`${e} will be uninstalled from ${t}: its runners stop and its code is deleted.`];return n.length>0&&r.push(`It stays installed on: ${n.map(e=>e.nodeName).join(`, `)}. Use "Everywhere" to remove it from every node.`),r.push(`This cannot be undone.`),r.join(`
|
|
3
|
-
`)}var Qe={uninstalled:`uninstalled`,"not-installed":`was not installed`,refused:`REFUSED`,failed:`FAILED`,"pending-reconnect":`offline — removed when it reconnects`};function $e(e,t){let n=[];for(let r of e.results){let e=r.runnersStopped.length>0?` (stopped ${r.runnersStopped.join(`, `)})`:``;n.push(`${t(r.nodeId)}: ${Qe[r.outcome]}${e}`),r.error!==void 0&&n.push(` ${r.error}`);for(let e of r.warnings)n.push(` ${e}`)}return n.join(`
|
|
4
|
-
`)}var et={},tt=3e4,nt=`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-red-400 hover:border-red-500/30 hover:bg-red-500/10 disabled:opacity-50 transition-colors`;function rt({packageName:e,displayName:n,selectedNode:r,hideNodeAction:i,disabled:o}){let{t:s}=G(),c=l(),u=te(),d=re(),f=H(et,{staleTime:tt}),p=f.data?.installations??[],m=(f.data?.unreachable??[]).map(e=>e.nodeId),g=Ye(p,e),_=e=>g.find(t=>t.nodeId===e)?.nodeName??(e===r.id?r.name:e),v=Me({onSettled:()=>{c.invalidateQueries({queryKey:[[`addons`]]}),c.invalidateQueries({queryKey:[[`addonPages`]]}),c.invalidateQueries({queryKey:[[`capabilities`]]}),c.invalidateQueries({queryKey:[[`nodes`]]})}}),y=async e=>{await d({title:e.success?s(`addons.addonUninstallControls.uninstalled`,`{{displayName}} uninstalled`,{displayName:n}):s(`addons.addonUninstallControls.notEveryNodeWasCleaned`,`{{displayName}}: not every node was cleaned`,{displayName:n}),message:$e(e,_),variant:e.success?`default`:`danger`})},b=async t=>{try{await y(await v.mutateAsync({packageName:e,...t}))}catch(e){await d({title:s(`addons.addonUninstallControls.uninstallFailed`,`Uninstall {{displayName}} failed`,{displayName:n}),message:e instanceof Error?e.message:String(e),variant:`danger`})}},x=async()=>{let e=g.filter(e=>e.nodeId!==r.id);await u({title:s(`addons.addonUninstallControls.uninstallFrom`,`Uninstall {{displayName}} from {{name}}?`,{displayName:n,name:r.name}),message:Ze(n,r.name,e),confirmLabel:s(`addons.addonUninstallControls.uninstall`,`Uninstall`),variant:`danger`})&&await b(r.isHub?{}:{nodeId:r.id})},S=async()=>{let t=(await f.refetch()).data;if(t===void 0){await d({title:s(`addons.addonUninstallControls.cannotListTheNodes`,`Cannot list the nodes`),message:s(`addons.addonUninstallControls.theHubDidNotAnswer`,`The hub did not answer which nodes have this package — nothing was removed.`),variant:`danger`});return}let r=Ye(t.installations,e);await u({title:s(`addons.addonUninstallControls.uninstallEverywhere`,`Uninstall {{displayName}} everywhere?`,{displayName:n}),message:Q(n,r,t.unreachable.map(e=>e.nodeId)),confirmLabel:s(`addons.addonUninstallControls.uninstallFromNodeS`,`Uninstall from {{length}} node(s)`,{length:r.length}),variant:`danger`})&&await b({everywhere:!0})},C=v.isPending||o===!0;return t(`div`,{className:`flex items-center gap-1.5`,children:[i!==!0&&t(W,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),x()},disabled:C,className:nt,title:s(`addons.addonUninstallControls.uninstallFrom2`,`Uninstall from {{name}}`,{name:r.name}),children:[a(h,{className:`h-3 w-3`}),v.isPending?s(`addons.addonUninstallControls.removing`,`Removing...`):s(`addons.addonUninstallControls.uninstall`,`Uninstall`)]}),(g.length>1||i===!0||m.length>0)&&t(W,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),S()},disabled:C,className:nt,title:s(`addons.addonUninstallControls.uninstallFromEveryNodeThat`,`Uninstall from every node that has it`),children:[a(ae,{className:`h-3 w-3`}),g.length>0?s(`addons.uninstallControls.everywhereCount`,{count:g.length}):s(`addons.uninstallControls.everywhere`)]})]})}function it(e){return typeof e.deprecated==`string`&&e.deprecated.length>0}function at(e,t){return t?e:e.filter(e=>e.distTags.includes(`latest`)||!it(e))}function ot(e){return e.length-at(e,!1).length}c();function st({packageName:e,currentVersion:n,installSource:r,onInstall:i,onClose:o,onSelect:c,selectedVersion:l}){let{t:d}=G(),f=r===`upload`||r===`local`,[p,m]=s(!1),{data:h,isLoading:_,isError:v}=P({name:e}),y=h?at(h,p):[],x=h?ot(h):0;return t(`div`,{className:`fixed z-50 w-72 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,style:{top:`auto`,bottom:`auto`},ref:e=>{if(!e)return;let t=e.parentElement?.getBoundingClientRect();if(!t)return;let n=window.innerHeight-t.bottom,r=t.top;n<280&&r>n?(e.style.bottom=`${window.innerHeight-t.top+4}px`,e.style.top=`auto`):(e.style.top=`${t.bottom+4}px`,e.style.bottom=`auto`),e.style.right=`${window.innerWidth-t.right}px`},onClick:e=>e.stopPropagation(),children:[t(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[a(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:d(`addons.versionPicker.versions`,`Versions`)}),a(W,{variant:`unstyled`,type:`button`,onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:a(ee,{className:`h-3 w-3`})})]}),f&&t(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[a(b,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),t(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[a(`span`,{className:`font-semibold`,children:d(`addons.versionPicker.inPlace`,{kind:r===`upload`?d(`addons.versionPicker.uploadedCopy`,`Uploaded copy`):d(`addons.versionPicker.localCopy`,`Local copy`)})}),` `,a(K,{i18nKey:`addons.versionPicker.reinstall`,values:{version:n},components:{mono:a(`span`,{className:`font-mono`})}})]})]}),_&&t(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[a(D,{className:`h-3.5 w-3.5 animate-spin`}),d(`addons.versionPicker.loadingVersions`,`Loading versions...`)]}),v&&a(`div`,{className:`px-3 py-4 text-center text-[10px] text-danger`,children:d(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),y.length>0&&a(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:y.map(e=>{let r=e.version===n,o=c!==void 0&&e.version===l,s=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),f=t(u,{children:[a(`span`,{className:`font-mono flex-1 text-left ${r?`text-primary font-semibold`:s?`text-amber-400`:`text-foreground`}`,children:e.version}),r&&a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:d(`common.current`)}),e.distTags.map(e=>a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e===`latest`?`bg-emerald-500/15 text-emerald-400`:e===`beta`?`bg-amber-500/15 text-amber-400`:`bg-gray-500/15 text-gray-400`}`,children:e},e)),it(e)&&a(`span`,{className:`text-[9px] text-red-400 line-through`,children:d(`common.deprecated`)}),a(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return c?t(W,{variant:`unstyled`,type:`button`,"aria-label":d(`addons.versionPicker.select`,`Select {{version}}`,{version:e.version}),onClick:()=>c(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${o?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,o?a(g,{className:`h-3 w-3 text-primary shrink-0`}):a(`span`,{className:`w-3 shrink-0`})]},e.version):t(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${r?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,a(W,{variant:`unstyled`,type:`button`,onClick:()=>i(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:r?d(`addons.versionPicker.reInstallFromNpm`,`Re-install {{version}} from npm`,{version:e.version}):d(`addons.versionPicker.install`,`Install {{version}}`,{version:e.version}),children:a(w,{className:`h-3 w-3`})})]},e.version)})}),!_&&!v&&h&&h.length===0&&a(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:d(`addons.versionPicker.noVersionsFound`,`No versions found`)}),x>0&&a(W,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto w-full justify-start rounded-none border-t border-border px-3 py-2 text-left text-[10px] font-normal text-foreground-subtle`,onClick:()=>m(e=>!e),children:p?d(`addons.versionPicker.hideOlder`,`Hide older versions`):d(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:x})})]})}c();var ct=`device-export`;function lt(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===ct)}function ut(e){return e!==`local`&&e!==`upload`}function dt({isBundle:e,installSource:n,addonId:r,iconPath:i,color:o}){let[c,l]=s(!1),u=o?{backgroundColor:`${o.startsWith(`#`)?o:`#${o}`}26`}:void 0,p=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,m=r&&i?y(`/api/addon-assets/${r}/${i}`):null,h=!!m&&!c;return t(`div`,{className:`relative flex-shrink-0`,children:[a(`div`,{className:`h-8 w-8 rounded-md flex items-center justify-center ${u?``:p}`,style:u,children:h?a(`img`,{src:m,alt:r,className:`h-4 w-4`,onError:()=>l(!0)}):a(e?d:f,{className:`h-3.5 w-3.5`})}),n===`local`&&a(`span`,{className:`absolute -top-1.5 -left-1.5 text-[7px] font-bold leading-none bg-orange-500 text-white px-1 py-0.5 rounded -rotate-12 shadow-sm`,children:`DEV`}),ut(n)&&a(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:a(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:a(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),n===`upload`&&a(`span`,{className:`absolute -top-1.5 -left-1.5 flex items-center justify-center h-4 w-4 rounded bg-cyan-500 -rotate-12 shadow-sm`,children:a(b,{className:`h-2.5 w-2.5 text-white`})})]})}function ft({version:e,availableUpdate:n,selectedVersion:r,isUpdating:i,installSource:o,disabled:s,onUpdate:c,onOpenPicker:l,children:u}){let{t:d}=G();if(i)return t(`span`,{className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400 shrink-0`,children:[a(D,{className:`h-3 w-3 animate-spin`}),d(`addons.addonCard.updating`,`Updating…`)]});if(n){let i=r??n;return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[c&&t(W,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:s,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-semibold border border-blue-500/30 bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,title:d(`addons.addonCard.updateTo`,`Update to {{target}}`,{target:i}),children:[a(w,{className:`h-3 w-3`}),d(`addons.addonCard.update`,`Update`)]}),t(W,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,"aria-label":d(`addons.addonCard.selectVersionToInstall`,`Select version to install`),title:d(`addons.addonCard.installedUpdateAvailableSelectedTap`,`Installed {{version}} — update available. Selected {{target}}; tap to choose another version.`,{version:e,target:i}),className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border border-amber-500/40 bg-amber-500/15 text-amber-500 hover:bg-amber-500/25 animate-pulse disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[a(`span`,{className:`font-normal opacity-70`,children:e}),a(`span`,{className:`font-normal opacity-70`,children:`→`}),i,a(m,{className:`h-3 w-3`})]}),u]})}return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[t(W,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,className:[`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,o===`local`?`border-orange-500/30 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20`:`border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20`].join(` `),title:d(`addons.addonCard.versionTapToViewAll`,`Version {{version}} — tap to view all versions`,{version:e}),children:[e,a(m,{className:`h-3 w-3 opacity-50`})]}),u]})}function pt({addonId:e}){let t=l(),{data:n=`inherit`}=Oe({addonId:e}),r=ge({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return a(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>a(W,{variant:`unstyled`,type:`button`,onClick:n=>{n.stopPropagation(),r.mutate({addonId:e,channel:t})},disabled:r.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===t?t===`inherit`?`bg-gray-700/50 text-gray-700 dark:text-gray-300`:t===`off`?`bg-gray-700 text-gray-700 dark:text-gray-300`:t===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${t===`inherit`?``:`border-l border-border`}`,children:t},t))})}var mt={id:`hub`,name:`Hub`,isHub:!0};function ht({addon:e,clusterStatus:n,hideVersion:r,availableUpdate:i,blockedUpdate:c,onUpdate:f,isUpdating:h,jobProgress:g,bundle:v,bulkItem:y,disabledByBulk:b,isSystem:C,selectedNode:w}){let{t:T}=G(),[te,ne]=s(!1),[re,E]=s(!1),[ie,D]=s(null);o(()=>{D(null)},[i]);let O=ie??i,[ae,ue]=s(!1),[A,fe]=s(!1),[me,j]=s(`logs`),M=l(),ge=Fe(),{manifest:P}=e,F=!v&&!P.protected&&P.removable!==!1,I=!!v,_e=v?.displayName??P.name,L=v?.packageName??P.packageName,R=v?.version??P.packageVersion??P.version,z=v?.installSource??e.installSource,B=v?v.bundle?.description??v.addons[0]?.manifest.description:P.description,V=Te({onSuccess:()=>{M.invalidateQueries({queryKey:[[`addons`]]})}}),be=we({onSuccess:()=>{M.invalidateQueries({queryKey:[[`addons`]]}),M.invalidateQueries({queryKey:[[`addonPages`]]}),M.invalidateQueries({queryKey:[[`capabilities`]]}),M.invalidateQueries({queryKey:[[`integrations`]]})}}),xe=ye({onSuccess:()=>{M.invalidateQueries({queryKey:[[`addons`]]}),M.invalidateQueries({queryKey:[[`alerts`]]})}}),H=e.health,Se=H?.phase===`failed`&&!H.inGracePeriod,Ce=Se&&H?.nextRetryAt&&!H.retrying,U=Ve(e.process);return t(`div`,{className:`rounded-md border bg-surface overflow-hidden ${Se?`border-red-500/50`:`border-border`}`,children:[Se&&H&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(k,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),t(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-xs font-semibold text-danger`,children:T(`addons.addonCard.failedToLoad`,{attempt:H.retryCount})}),a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:H.lastError?.message??T(`addons.addonCard.unknownError`,`Unknown error`)}),Ce&&H.nextRetryAt&&a(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:T(`addons.addonCard.autoRetryAt`,{time:new Date(H.nextRetryAt).toLocaleTimeString()})})]}),t(W,{variant:`unstyled`,type:`button`,disabled:xe.isPending||H.retrying,onClick:e=>{e.stopPropagation(),xe.mutate({packageName:L})},className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-semibold border border-red-400/40 bg-red-400/10 text-red-700 dark:text-red-300 hover:bg-red-400/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0`,title:T(`addons.addonCard.resetRetryCounterAndForce`,`Reset retry counter and force immediate reload`),children:[a(p,{className:`h-3 w-3 ${xe.isPending||H.retrying?`animate-spin`:``}`}),T(`addons.addonCard.retryNow`,`Retry now`)]})]}),U!==null&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(k,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),t(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-xs font-semibold text-danger`,children:T(`addons.addonCard.processProblem.${U.kind}`)}),U.reason!==void 0&&a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:U.reason})]})]}),t(`div`,{className:`flex items-start gap-2.5 px-3 py-2`,children:[a(dt,{isBundle:I||!!P.components&&P.components.length>1,installSource:z,addonId:I?v.addons[0]?.manifest.id:P.id,iconPath:I?v.bundle?.icon??v.addons[0]?.manifest.icon:P.icon,color:I?v.addons[0]?.manifest.color:P.color}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-start justify-between gap-2`,children:[a(`span`,{className:`text-xs font-semibold text-foreground truncate min-w-0`,children:_e}),!r&&a(ft,{version:R,availableUpdate:i,...O===void 0?{}:{selectedVersion:O},isUpdating:h,installSource:z,disabled:b,...f&&O!==void 0?{onUpdate:()=>f(O)}:{},onOpenPicker:()=>E(e=>!e),children:re&&a(st,{packageName:L,currentVersion:R,...z?{installSource:z}:{},...i!==void 0&&O!==void 0?{selectedVersion:O,onSelect:e=>{D(e),E(!1)}}:{},onInstall:e=>{E(!1),be.mutate({packageName:L,version:e})},onClose:()=>E(!1)})})]}),t(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[L!==_e&&a(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:L}),I&&t(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,children:[a(d,{className:`h-3 w-3`}),v.addons.length]}),C&&t(`span`,{className:`text-[10px] rounded-full bg-amber-500/15 text-amber-700 dark:text-amber-300 px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,title:T(`addons.addonCard.systemPackageUpdatingRestartsThe`,`System package — updating restarts the hub`),children:[a(p,{className:`h-3 w-3`}),T(`addons.addonCard.system`,`System`)]}),y!=null&&a(Z,{item:y}),c!==void 0&&a(se,{variant:`warning`,title:T(`addons.addonCard.updateHeldTitle`,{defaultValue:`{{latest}} is held until the server is {{required}} or newer`,latest:c.latestVersion,required:c.requiredServer}),children:T(`addons.addonCard.requiresServer`,{defaultValue:`requires server ≥ {{version}}`,version:c.requiredServer})}),g!=null&&a(Je,{progress:g})]}),B&&a(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:B}),!I&&e.process&&t(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.mode===`forked`?`bg-blue-500/15 text-blue-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.mode===`forked`?T(`addons.addonCard.forked`):T(`addons.addonCard.inProcess`)}),e.process.pid!=null&&t(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state===`running`?`bg-emerald-500/15 text-emerald-400`:U===null?`bg-gray-500/15 text-gray-400`:`bg-red-500/15 text-red-400`}`,children:e.process.state})]})]})]}),!I&&t(`div`,{className:`flex items-center gap-1 px-3 py-1 border-t border-border/50 bg-surface-hover/20`,children:[t(W,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),V.mutate({addonId:P.id})},disabled:V.isPending||b,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-border text-foreground-subtle hover:text-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors`,children:[a(p,{className:`h-3 w-3 ${V.isPending?`animate-spin`:``}`}),T(`addons.addonCard.restart`,`Restart`)]}),t(W,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),ue(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${ae?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[a(S,{className:`h-3 w-3`}),T(`addons.addonCard.logs`,`Logs`)]}),!I&&t(W,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),fe(!0)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${A?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[a(x,{className:`h-3 w-3`}),T(`addons.addonCard.settings`,`Settings`)]}),a(`div`,{className:`flex-1`}),F&&a(rt,{packageName:P.packageName,displayName:P.name,selectedNode:w??mt,disabled:b})]}),n&&n.nodes.length>1&&!I&&t(`div`,{className:`border-t border-border px-3 py-1.5 bg-muted/10`,children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:T(`addons.addonCard.clusterDeployment`,`Cluster Deployment`)}),a(`div`,{className:`space-y-1`,children:n.nodes.map(e=>t(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[a(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`offline`?`bg-muted-foreground/30`:e.synced?`bg-success`:`bg-amber-500`}`}),a(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),a(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:T(`addons.addonCard.outdated`)}),e.status===`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:T(`common.offline`)}),e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] text-success`,children:T(`common.synced`)})]},e.nodeId))})]}),ae&&!I&&t(`div`,{className:`border-t border-border`,children:[t(`div`,{className:`flex items-center px-3 py-0.5 bg-surface-hover/20 border-b border-border/50`,children:[t(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[a(W,{variant:`unstyled`,type:`button`,onClick:()=>j(`logs`),className:`px-2 py-0.5 transition-colors ${me===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:T(`addons.addonCard.logs`,`Logs`)}),a(W,{variant:`unstyled`,type:`button`,onClick:()=>j(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${me===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:T(`addons.addonCard.events`,`Events`)})]}),a(`div`,{className:`flex-1`}),a(W,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),ue(!1)},className:`text-foreground-subtle hover:text-foreground`,children:a(ee,{className:`h-3.5 w-3.5`})})]}),me===`logs`&&a(N,{addonId:P.id,maxHeight:`max-h-64`,showFilters:!1}),me===`events`&&a(ve,{addonId:P.id,category:`addon.*`,maxHeight:`max-h-64`})]}),I&&t(u,{children:[a(W,{variant:`unstyled`,type:`button`,onClick:()=>ne(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:a(te?_:m,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),te&&a(`div`,{className:`border-t border-border px-2.5 py-1.5 space-y-1.5`,children:v.addons.map(e=>a(ht,{addon:e,hideVersion:!0},e.manifest.id))})]}),A&&!I&&a(de,{open:!0,onOpenChange:e=>!e&&fe(!1),children:t(le,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(Ne,{children:t(oe,{className:`flex items-center gap-2`,children:[a(x,{className:`h-4 w-4 text-primary`}),T(`addons.addonCard.settingsTitle`,{name:_e})]})}),t(ce,{className:`space-y-4`,children:[a(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:T(`addons.addonCard.clusterWideSettingsOneValue`,`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`)}),a(J,{nodeId:null,addonIds:[P.id],level:`global`,fieldScope:`cluster`,emptyMessage:T(`addons.addonCard.thisAddonExposesNoCluster`,`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`)}),lt(P)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:T(`addons.addonCard.deviceExport`,`Device export`)}),a(he,{addonId:P.id,onOpenDevice:e=>ge(`/devices/${e}`)})]}),ut(z)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:T(`addons.addonCard.autoUpdate`,`Auto-Update`)}),a(pt,{addonId:P.id})]}),P.components&&P.components.length>0&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:T(`addons.addonCard.components`,{count:P.components.length})}),a(`div`,{className:`flex flex-wrap gap-1`,children:P.components.map(e=>a(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]})]}),a(pe,{children:a(W,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>fe(!1),children:T(`common.close`,`Close`)})})]})})]})}c();var gt=`.tgz,.tar.gz,.zip`;function _t({onUploadSuccess:e}){let{t:r}=G(),[o,c]=s(!1),l=n(null),d=i(async t=>{c(!0);let n=new FormData;n.append(`file`,t);let r=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(y(`/api/addons/upload`),{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:n})).json()).success&&e()}finally{c(!1)}},[e]);return t(u,{children:[a(F,{ref:l,accept:gt,onChange:i(e=>{let t=e.target.files?.[0];t&&d(t),e.target.value=``},[d]),className:`hidden`}),t(W,{variant:`unstyled`,type:`button`,onClick:()=>l.current?.click(),disabled:o,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[o?a(D,{className:`w-3.5 h-3.5 animate-spin`}):a(b,{className:`w-3.5 h-3.5`}),o?r(`addons.addonUploadZone.uploading`,`Uploading...`):r(`addons.addonUploadZone.upload`,`Upload`)]})]})}var vt=/```[^\n]*\n([\s\S]*?)```/g;function yt(e){let t=[],n=0;for(let r of e.matchAll(vt)){let i=r.index??0;i>n&&t.push({kind:`text`,body:e.slice(n,i)}),t.push({kind:`code`,body:r[1]??``}),n=i+r[0].length}return n<e.length&&t.push({kind:`text`,body:e.slice(n)}),t}function bt(e){let t=e.trim();return t.startsWith(`https://`)||t.startsWith(`http://`)?t:null}function xt(e,t){let n=[],r=/(\*\*[^*]+\*\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/g,i=0,o=0;for(let s of e.matchAll(r)){let r=s.index??0;r>i&&n.push(e.slice(i,r));let c=s[0],l=`${t}-${o}`;if(o+=1,c.startsWith(`**`))n.push(a(`strong`,{children:c.slice(2,-2)},l));else if(c.startsWith("`"))n.push(a(`code`,{className:`font-mono text-[0.9em]`,children:c.slice(1,-1)},l));else{let e=/^\[([^\]]+)\]\(([^)]+)\)$/.exec(c),t=e?.[1]??c,r=e?bt(e[2]??``):null;n.push(r?a(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:`text-primary underline`,children:t},l):a(`span`,{children:t},l))}i=r+c.length}return i<e.length&&n.push(e.slice(i)),n}function St(e,t){let n=e.split(`
|
|
5
|
-
`),r=[],i=[],o=[],s=0,c=()=>{if(i.length===0)return;let e=i.join(` `).trim();i=[],e.length!==0&&(r.push(a(`p`,{className:`mb-2 last:mb-0`,children:xt(e,`${t}-p-${s}`)},`${t}-p-${s}`)),s+=1)},l=()=>{if(o.length===0)return;let e=o;o=[],r.push(a(`ul`,{className:`mb-2 list-disc pl-4 last:mb-0`,children:e.map((e,n)=>a(`li`,{children:xt(e,`${t}-li-${s}-${n}`)},`${t}-li-${s}-${n}`))},`${t}-ul-${s}`)),s+=1};for(let e of n){let n=/^(#{1,3})\s+(.*)$/.exec(e),u=/^\s*[-*]\s+(.*)$/.exec(e);if(n){c(),l();let e=n[1]?.length??1,i=xt(n[2]??``,`${t}-h-${s}`),o=e===1?`text-sm font-semibold mb-2`:`text-xs font-semibold mb-1.5 mt-2`;r.push(a(e===1?`h3`:`h4`,{className:o,children:i},`${t}-h-${s}`)),s+=1;continue}if(u){c(),o=[...o,u[1]??``];continue}if(e.trim().length===0){c(),l();continue}l(),i=[...i,e.trim()]}return c(),l(),r}function Ct({markdown:e}){return a(`div`,{className:`text-xs text-foreground leading-relaxed`,children:yt(e).map((e,t)=>e.kind===`code`?a(`pre`,{className:`mb-2 overflow-auto rounded-md bg-surface-hover p-2 font-mono text-[10px] last:mb-0`,children:e.body.replace(/\n$/,``)},`code-${t}`):a(`div`,{children:St(e.body,`b${t}`)},`text-${t}`))})}c();function wt(e){return e.replace(/^@camstack\/(addon-)?/,``)}function Tt(e,t,n){let r=at(e,n);return r.some(e=>e.version===t)?r:[{version:t,distTags:[],deprecated:void 0},...r]}function Et({pending:e,failed:n,body:r,missing:i}){let{t:o}=G();return e?t(`div`,{className:`flex items-center gap-2 py-6 text-xs text-foreground-subtle`,children:[a(D,{className:`h-3.5 w-3.5 animate-spin`}),o(`addons.installDialog.loadingDocument`,`Loading…`)]}):n||r===void 0?a(`p`,{className:`py-4 text-xs text-danger`,children:o(`addons.installDialog.couldNotLoadDocument`,`Could not load this file from the registry.`)}):r.status===`ok`&&r.markdown!==void 0?a(Ct,{markdown:r.markdown}):r.status===`error`?a(`p`,{className:`py-4 text-xs text-danger`,children:o(`addons.installDialog.documentError`,`Could not load this file. {{message}}`,{message:r.message??``})}):a(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:i})}function Dt({target:e,installing:n,installError:r,onClose:i,onInstall:o}){let{t:c}=G(),[l,u]=s(e.version),[d,f]=s(!1),p=P({name:e.name}),m=be({name:e.name,version:l}),h=p.data??[],g=ot(h),_=Tt(h,l,d),v=m.data;return a(de,{open:!0,onOpenChange:e=>!e&&i(),children:t(le,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(Ne,{children:a(oe,{children:c(`addons.installDialog.title`,`Install {{name}}`,{name:wt(e.name)})})}),t(ce,{className:`space-y-3`,children:[a(`p`,{className:`font-mono text-[10px] text-foreground-subtle`,children:e.name}),e.description.length>0&&a(`p`,{className:`text-xs text-foreground`,children:e.description}),t(`div`,{className:`space-y-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:c(`addons.installDialog.version`,`Version`)}),a(E,{"aria-label":c(`addons.installDialog.version`,`Version`),value:l,options:_.map(e=>({value:e.version,label:it(e)?c(`addons.installDialog.deprecatedVersion`,`{{version}} (deprecated)`,{version:e.version}):e.version})),onChange:e=>u(e.target.value)}),p.isError&&a(`p`,{className:`text-[10px] text-danger`,children:c(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),g>0&&a(W,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto justify-start px-0 text-[10px] font-normal text-foreground-subtle underline`,onClick:()=>f(e=>!e),children:d?c(`addons.versionPicker.hideOlder`,`Hide older versions`):c(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:g})})]}),t(z,{defaultValue:`readme`,children:[t(Ce,{children:[a(Ee,{value:`readme`,children:c(`addons.installDialog.readme`,`README`)}),a(Ee,{value:`changelog`,children:c(`addons.installDialog.changelog`,`CHANGELOG`)})]}),a(ke,{value:`readme`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(Et,{pending:m.isPending,failed:m.isError,body:v?.readme,missing:c(`addons.installDialog.missingReadme`,`This package has no README.`)})})}),a(ke,{value:`changelog`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(Et,{pending:m.isPending,failed:m.isError,body:v?.changelog,missing:c(`addons.installDialog.missingChangelog`,`This package has no CHANGELOG.`)})})})]}),r!=null&&r.length>0&&a(`p`,{className:`text-xs text-danger`,children:r})]}),t(pe,{children:[a(W,{type:`button`,variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),a(W,{type:`button`,size:`sm`,disabled:n||l.length===0,onClick:()=>o(e.name,l),children:n?a(D,{className:`h-3.5 w-3.5 animate-spin`}):c(`addons.installDialog.install`,`Install`)})]})]})})}var Ot=new Set([`@camstack/server`,`@camstack/types`,`@camstack/sdk`,`@camstack/ui-library`,`@camstack/addon-agent-ui`]);function kt(e,t){let n=new Map;for(let r of e){if(r.isHub||r.onHub||Ot.has(r.packageName)||!t.isHub&&r.nodeId!==t.id)continue;let e=n.get(r.packageName)??[];e.push(r),n.set(r.packageName,e)}return[...n].map(([e,t])=>({packageName:e,rows:t})).sort((e,t)=>e.packageName.localeCompare(t.packageName))}function At({selectedNode:e}){let{t:n}=G(),{data:r}=H(et,{staleTime:tt});if(r===void 0)return null;let i=kt(r.installations,e),o=r.unreachable.filter(t=>e.isHub||t.nodeId===e.id);return i.length===0&&o.length===0?null:t(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 px-3 py-2.5 space-y-2`,children:[t(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold text-foreground`,children:[a(C,{className:`h-3.5 w-3.5 text-warning`}),e.isHub?n(`addons.nodeOnlyPackagesPanel.installedOnAgentsButNot`,`Installed on agents but not on the hub`):n(`addons.nodeOnlyPackagesPanel.installedOnButNotOn`,`Installed on {{name}} but not on the hub`,{name:e.name})]}),o.length>0&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:n(`addons.nodeOnlyPackagesPanel.unreachable`,{nodes:o.map(e=>e.nodeId).join(`, `)})}),i.map(n=>t(`div`,{className:`flex items-center justify-between gap-3 flex-wrap rounded-md border border-border bg-surface px-3 py-2`,children:[t(`div`,{className:`min-w-0`,children:[a(`div`,{className:`text-xs font-mono text-foreground break-all`,children:n.packageName}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:n.rows.map(e=>`${e.nodeName}${e.version===null?``:` ${e.version}`}${e.isOnline?``:` (offline)`}`).join(` · `)})]}),a(rt,{packageName:n.packageName,displayName:n.packageName,selectedNode:e,hideNodeAction:e.isHub})]},n.packageName))]})}function jt({addon:e,installing:n,onInstall:r}){let{t:i}=G();return t(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[a(`div`,{className:`w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center text-primary text-[9px] font-bold shrink-0`,children:e.name.replace(`@camstack/addon-`,``).charAt(0).toUpperCase()}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[a(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),t(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),a(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&a(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?a(se,{variant:`success`,icon:a(g,{className:`h-3 w-3`}),children:e.installedVersion??i(`system.capabilityCatalog.installed`,`Installed`)}):t(W,{size:`sm`,onClick:()=>r(e),disabled:n,className:`shrink-0`,children:[n?a(D,{className:`h-3 w-3 animate-spin`}):a(w,{className:`h-3 w-3`}),i(`system.capabilityCatalog.install`,`Install`)]})]})}function Mt({capability:e,installing:n,onInstall:r}){let{t:i}=G(),{data:o,isPending:s,isError:c}=V({capability:e}),l;if(c)l=a(`div`,{className:`px-3 py-2 text-xs text-danger`,children:i(`system.capabilityCatalog.couldNotSearchTheNpm`,`Could not search the npm catalog right now. Try again in a moment.`)});else if(s||o===void 0)l=t(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground-subtle`,children:[a(D,{className:`h-3 w-3 animate-spin`}),i(`system.capabilityCatalog.searchingTheNpmCatalog`,`Searching the npm catalog…`)]});else{let t=o.filter(e=>!e.installed);l=t.length===0?a(`div`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:o.length===0?i(`system.capabilityCatalog.noPublishedAddonDeclaresThe`,`No published addon declares the "{{capability}}" capability.`,{capability:e}):i(`system.capabilityCatalog.everyPublishedAddonThatDeclares`,`Every published addon that declares "{{capability}}" is already installed.`,{capability:e})}):a(`div`,{className:`divide-y divide-border`,children:t.map(e=>a(jt,{addon:e,installing:n,onInstall:r},e.name))})}return t(`section`,{className:`rounded-md border border-border bg-surface overflow-hidden`,"aria-label":i(`system.capabilityCatalog.availableToInstall`,`Available to install`),children:[a(`h2`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:i(`system.capabilityCatalog.availableToInstall`,`Available to install`)}),l]})}c();function Nt(e){return e===`npm`||e===`dev`?e:null}var Pt=`rounded-full border border-primary bg-primary/10 px-2 py-0.5 text-[10px] text-foreground`,Ft=`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-muted hover:bg-surface-hover`,It=[{seconds:900,label:`15m`},{seconds:3600,label:`1h`},{seconds:21600,label:`6h`},{seconds:43200,label:`12h`},{seconds:86400,label:`24h`}],Lt={id:`hub`,name:`Hub`,isHub:!0,isOnline:!0};function Rt(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function zt(e){return e===`local`?`dev`:`npm`}function Bt(e){let t=e;if(!t?.manifest)return null;let n={...t.manifest,name:t.manifest.name??t.manifest.id,version:t.manifest.version??`0.0.0`,capabilities:t.manifest.capabilities??[]},r=t.process,i=r?{pid:r.pid,mode:r.mode===`forked`?`forked`:`in-process`,state:r.state??`unknown`,...r.reason===void 0?{}:{reason:r.reason}}:void 0,a=t.health,o=t.declaration?.execution,s=t.manifest.execution,c=o?.placement??s?.placement;return{manifest:n,enabled:!0,source:t.source,installSource:t.installSource,installedOn:[],...i?{process:i}:{},hasBackup:t.hasBackup,...a?{health:a}:{},...c?{placement:c}:{}}}function Vt(e){let t=new Map,n=[];for(let r of e){let e=r.manifest.packageName;if(!e){n.push(r);continue}let i=t.get(e);if(i)i.addons.push(r);else{let n=r.manifest.bundle,i={packageName:e,displayName:n?.displayName??r.manifest.packageDisplayName??r.manifest.name,version:r.manifest.packageVersion,addons:[r],...r.installSource===void 0?{}:{installSource:r.installSource},...n===void 0?{}:{bundle:n}};t.set(e,i)}}let r=[];for(let e of t.values())e.bundle!==void 0||e.addons.length>=2?r.push({bundle:e,representative:e.addons[0]}):r.push(e.addons[0]);return r.push(...n),r}function $(e){return`bundle`in e}function Ht({addons:c,clusterStatus:u,selectedNode:d,onRefresh:f,listPhase:m}){let{t:h}=G(),g=l(),[_,y]=s(``),b=e(_),[x,S]=s(!1),C=n(null);o(()=>{if(!x)return;let e=e=>{C.current&&!C.current.contains(e.target)&&S(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[x]);let{data:T}=_e({nodeId:d.id}),ee=r(()=>{let e=new Map;for(let t of T??[])t.blockedBy===void 0&&e.set(t.name,t.latestVersion);return e},[T]),ne=r(()=>{let e=new Map;for(let t of T??[]){let n=t.blockedBy?.find(e=>e.kind===`server-too-old`);n!==void 0&&e.set(t.name,{latestVersion:t.latestVersion,requiredServer:n.required})}return e},[T]),re=r(()=>(T??[]).filter(e=>!e.isSystem&&e.blockedBy===void 0).length,[T]),[O,k]=s(()=>new Set),[ae,oe]=s(()=>new Map),se=i(e=>{k(t=>new Set(t).add(e))},[]),ce=i(e=>{k(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),le=i((e,t)=>{oe(n=>new Map(n).set(e,t))},[]),ue=i(e=>{oe(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),A=me({onMutate:e=>{se(e.name),ue(e.name)},onSuccess:(e,t)=>{ce(t.name);let n=e;if(n&&n.success===!1){le(t.name,n.error??`Update failed (no error message returned by server)`);return}g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{ce(t.name),le(t.name,e instanceof Error?e.message:String(e))}}),de=Ke(),pe=n(new Set);o(()=>{let e=new Set;for(let[t,n]of de)We(n)&&e.add(t);let t=[...pe.current].some(t=>!e.has(t));pe.current=e,t&&(g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[de,g]);let{data:j}=Se(void 0),he=fe({onSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),ge=je({onSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:N,isFetching:P}=V({query:b||void 0},{enabled:x}),F=I(),{data:R}=U(void 0),z=R?.requestedAt,[B,ve]=s(null),[ye,be]=s(!1);o(()=>{if(R?.kind===`framework-bulk-update`&&R.requestedAt!==B){ve(R.requestedAt),be(!0);let e=window.setTimeout(()=>be(!1),6e3);return()=>window.clearTimeout(e)}},[z,B,R]),te();let xe=i(async()=>{let e=(T??[]).filter(e=>!e.isSystem&&e.blockedBy===void 0);if(e.length!==0){if(!d.isHub){for(let t of e)await A.mutateAsync({name:t.name,version:t.latestVersion,nodeId:d.id});return}await F.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[d.id]})}},[T,d.id,d.isHub,F,A]),[H,Ce]=s(null),[Te,Ee]=s(null),De=e=>{Ee(null),Ce(e)},Oe=we({onSuccess:()=>{Ce(null),Ee(null),g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addonPages`]]}),g.invalidateQueries({queryKey:[[`capabilities`]]}),g.invalidateQueries({queryKey:[[`integrations`]]})},onError:e=>{Ee(e instanceof Error?e.message:`Install failed`)}}),[ke,Ae]=s(`type`),[Me,Ne]=s(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),Fe=e=>{Ne(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[K,q]=Pe(),J=K.get(`capability`),Be=K.get(`updatable`)===`1`,Y=K.get(`error`)===`1`,X=Nt(K.get(`source`)),Z=Ie(K.get(Re))===`integration`,{data:He}=M(void 0,{enabled:Z}),Ue=r(()=>He===void 0?null:new Set(He.map(e=>e.addonId)),[He]),Ge=i(e=>{let t=new URLSearchParams(K);e?t.set(Re,`integration`):t.delete(Re),q(t,{replace:!0})},[K,q]),qe=i(e=>{let t=new URLSearchParams(K);e?t.set(`updatable`,`1`):t.delete(`updatable`),q(t,{replace:!0})},[K,q]),Je=i(e=>{let t=new URLSearchParams(K);e?t.set(`error`,`1`):t.delete(`error`),q(t,{replace:!0})},[K,q]),Ye=i(e=>{let t=new URLSearchParams(K);e===null?t.delete(`source`):t.set(`source`,e),q(t,{replace:!0})},[K,q]),Xe=r(()=>c.filter(e=>Ve(e.process)!==null).length,[c]),Q=r(()=>{let e=c.filter(e=>!ze(e.manifest.packageName));return d.isHub||(e=e.filter(e=>Rt(e.placement,d.isHub))),J&&(e=e.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===J))),Z&&(e=[...Le(e,Ue)]),Be&&(e=e.filter(e=>{let t=e.manifest.packageName;return t!==void 0&&ee.has(t)})),X!==null&&(e=e.filter(e=>zt(e.installSource)===X)),Y&&(e=e.filter(e=>Ve(e.process)!==null)),e},[c,d.isHub,J,Be,X,Y,Z,Ue,ee]),Ze=()=>{let e=new URLSearchParams(K);e.delete(`capability`),q(e,{replace:!0})},Qe=Me===`flat`?Q:Vt(Q),$e=r(()=>{let e=[...Qe];switch(ke){case`type`:e.sort((e,t)=>{let n=+!$(e),r=+!$(t);if(n!==r)return n-r;let i=$(e)?e.bundle.displayName:e.manifest.name,a=$(t)?t.bundle.displayName:t.manifest.name;return i.localeCompare(a)});break;case`name`:e.sort((e,t)=>{let n=$(e)?e.bundle.displayName:e.manifest.name,r=$(t)?t.bundle.displayName:t.manifest.name;return n.localeCompare(r)});break;case`source`:e.sort((e,t)=>{let n=$(e)?e.bundle.installSource??``:e.installSource??``,r=$(t)?t.bundle.installSource??``:t.installSource??``;return n.localeCompare(r)});break}return e},[Qe,ke]);return t(`div`,{className:`space-y-3`,children:[[...ae.entries()].map(([e,n])=>a(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-2.5 py-1.5 text-[11px]`,children:t(`div`,{className:`flex items-start justify-between gap-3`,children:[t(`div`,{className:`space-y-0.5`,children:[a(`div`,{className:`font-medium text-danger`,children:h(`systemPage.addons.updateFailed`,{name:e})}),a(`div`,{className:`text-foreground-subtle font-mono`,children:n})]}),a(W,{variant:`unstyled`,type:`button`,onClick:()=>ue(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:h(`common.dismiss`)})]})},e)),t(`div`,{className:`flex items-center gap-x-2 gap-y-1.5 flex-wrap`,children:[t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.sort`,`Sort:`)}),t(E,{wrapperClassName:`inline-block w-auto`,value:ke,onChange:e=>Ae(e.target.value),children:[a(`option`,{value:`type`,children:h(`admin.system.addons.bundlesFirst`,`Bundles first`)}),a(`option`,{value:`name`,children:h(`admin.system.addons.name`,`Name`)}),a(`option`,{value:`source`,children:h(`admin.system.addons.installSource`,`Install source`)})]})]}),t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.view`,`View:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>a(W,{variant:`unstyled`,type:`button`,onClick:()=>Fe(e),className:`px-2 py-1 transition-colors capitalize ${Me===e?`bg-primary/10 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`}`,title:e===`grouped`?h(`admin.system.addons.groupMultiAddonPackagesInto`,`Group multi-addon packages into a bundle card`):h(`admin.system.addons.showEveryAddonAsIts`,`Show every addon as its own card`),children:e},e))})]}),d.isHub&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(p,{className:`h-3 w-3 text-foreground-subtle`}),a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.autoUpdate`,`Auto-Update:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>a(W,{variant:`unstyled`,type:`button`,onClick:()=>he.mutate({channel:e}),disabled:he.isPending,className:`px-2 py-1 transition-colors capitalize ${j?.channel===e?e===`off`?`bg-gray-700 text-gray-200`:e===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${e===`off`?``:`border-l border-border`}`,children:e},e))})]}),d.isHub&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.checkEvery`,`Check every:`)}),a(E,{wrapperClassName:`inline-block w-auto`,className:`font-medium text-foreground-subtle`,value:j?.updateCheckIntervalSeconds??21600,disabled:ge.isPending||j===void 0,onChange:e=>{j!==void 0&&ge.mutate({channel:j.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:It.map(e=>a(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),re>0&&t(W,{variant:`unstyled`,type:`button`,onClick:()=>void xe(),disabled:F.isPending,className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 border border-blue-500/30 disabled:opacity-50 transition-colors font-medium`,children:[F.isPending?a(D,{className:`w-3 h-3 animate-spin`}):a(w,{className:`w-3 h-3`}),F.isPending?h(`admin.system.addons.updating`,`Updating…`):h(`admin.system.addons.updateAll`,`Update All ({{nonSystemUpdateCount}})`,{nonSystemUpdateCount:re})]})]}),t(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`group`,"aria-label":h(`admin.system.addons.filterInstalledAddons`,`Filter installed addons`),children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.filter`,`Filter:`)}),[{id:`integrations`,label:h(`admin.system.addons.integrations`,`Integrations`),pressed:Z,toggle:()=>Ge(!Z)},{id:`updatable`,label:h(`admin.system.addons.updatable`,`Updatable`),pressed:Be,toggle:()=>qe(!Be)},{id:`error`,label:h(`admin.system.addons.inError`,`In error ({{count}})`,{count:Xe}),pressed:Y,toggle:()=>Je(!Y)},{id:`npm`,label:`npm`,pressed:X===`npm`,toggle:()=>Ye(X===`npm`?null:`npm`)},{id:`dev`,label:h(`admin.system.addons.dev`,`Dev`),pressed:X===`dev`,toggle:()=>Ye(X===`dev`?null:`dev`)}].map(e=>a(W,{variant:`unstyled`,type:`button`,"aria-pressed":e.pressed,onClick:e.toggle,className:e.pressed?Pt:Ft,children:e.label},e.id))]}),t(`div`,{className:`flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-2`,children:[t(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:C,children:[a(L,{type:`text`,searchHotkey:!0,value:_,onChange:e=>{y(e.target.value),S(!0)},onFocus:()=>S(!0),placeholder:h(`admin.system.addons.searchAddonsOnNpm`,`Search addons on npm...`),"aria-label":h(`admin.system.addons.searchAddonsOnNpm2`,`Search addons on npm`),disabled:F.isPending,leftSlot:a(ie,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),rightSlot:P?a(D,{className:`h-3 w-3 animate-spin`}):void 0}),x&&N&&N.length>0&&t(`div`,{className:`absolute left-0 right-0 top-full mt-1 z-40 rounded-md border border-border bg-surface shadow-xl overflow-hidden`,children:[N.length>0&&a(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:h(`systemPage.addons.npmResults`,{count:N.length})}),N&&N.length>0&&a(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:N.map(e=>a(jt,{addon:e,installing:Oe.isPending,onInstall:e=>De({name:e.name,version:e.version,description:e.description})},e.name))})]})]}),a(_t,{onUploadSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`]]}),f()}})]}),J&&t(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5 rounded-md bg-primary/10 border border-primary/30 text-xs`,children:[a(`span`,{className:`text-foreground-subtle`,children:h(`admin.system.addons.filteringByCapability`,`Filtering by capability:`)}),a(`span`,{className:`font-mono text-primary font-semibold`,children:J}),a(W,{variant:`unstyled`,type:`button`,onClick:Ze,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:h(`admin.system.addons.clear`,`Clear`)})]}),J&&a(Mt,{capability:J,installing:Oe.isPending,onInstall:e=>De({name:e.name,version:e.version,description:e.description})}),J&&Q.length>0&&a(`h2`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:h(`admin.system.addons.installed`,`Installed`)}),ye&&t(`div`,{className:`fixed top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg max-w-sm pointer-events-auto`,children:[a(v,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),t(`div`,{children:[a(`div`,{className:`text-[11px] font-semibold text-foreground`,children:h(`admin.system.addons.bulkUpdateCompleted`,`Bulk update completed`)}),a(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:h(`admin.system.addons.systemPackagesUpdatedHubRestarted`,`System packages updated — hub restarted successfully.`)})]})]}),m===`pending`&&t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(D,{className:`h-3 w-3 animate-spin`}),h(`admin.system.addons.loadingInstalled`,`Loading installed addons…`)]}),m===`error`&&a(`div`,{className:`text-xs text-danger`,children:h(`admin.system.addons.failedToLoadAddons`,`Failed to load addons`)}),m===`ready`&&Q.length===0&&a(`div`,{className:`text-xs text-foreground-subtle`,children:c.length===0?h(`admin.system.addons.noAddonsInstalled`,`No addons installed`):J?h(`admin.system.addons.noInstalledAddonDeclaresThe`,`No installed addon declares the "{{capabilityFilter}}" capability. Any addon you can install appears under "Available to install" above.`,{capabilityFilter:J}):h(`admin.system.addons.noAddonsCompatibleWithPlacement`,`No addons compatible with {{name}} (placement filter active)`,{name:d.name})}),a(`div`,{className:`space-y-1.5`,children:m===`ready`&&$e.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=ee.get(t),r=ne.get(t),i=$(e)?e.representative:e,o=n?e=>A.mutate({name:t,version:e,nodeId:d.id}):void 0,s=de.get(t)??null,c=s!==null&&We(s);return a(ht,{addon:i,clusterStatus:u?.[i.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,...r===void 0?{}:{blockedUpdate:r},isUpdating:O.has(t)||c,jobProgress:s,onUpdate:o,disabledByBulk:F.isPending,selectedNode:d},$(e)?t:e.manifest.id)})}),H!==null&&a(Dt,{target:H,installing:Oe.isPending,installError:Te,onClose:()=>Ce(null),onInstall:(e,t)=>Oe.mutate({packageName:e,version:t})})]})}function Ut(){let{t:e}=G(),r=l(),{data:i}=j(void 0),{nodes:s}=A(),{selection:c,selectNode:u,requestedNodeId:d}=Y(s.length>0?s:[Lt]),f=c.node??Lt,m=f.id,h=s.length>0?c.staleNodeId:null,{data:g,isLoading:_,isError:v}=De({nodeId:m}),y=R(),b=B(),x=y.isPending||b.isPending,S=async()=>{await y.mutateAsync({nodeId:m}),await b.mutateAsync(),r.invalidateQueries({queryKey:[[`addons`]]})},C=n(y);C.current=y;let w=n(d??`hub`);o(()=>{C.current.mutate({nodeId:w.current})},[]);let T=(g??[]).map(Bt).filter(e=>e!==null);return t(q,{children:[t(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[a(xe,{selectedNodeId:m,onSelect:u}),t(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[!_&&!v&&a(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:e(`systemPage.addons.installedCount`,{count:T.length})}),t(W,{variant:`unstyled`,type:`button`,onClick:()=>void S(),disabled:x,className:`inline-flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,title:e(`admin.system.addons.reFetchAddonsCheckNpm`,`Re-fetch addons + check npm for new versions`),children:[a(p,{className:`w-3 h-3 ${x?`animate-spin`:``}`}),e(`admin.system.addons.checkForUpdates`,`Check for updates`)]})]})]}),a(Be,{staleNodeId:h,shownNodeName:f.name}),a(At,{selectedNode:f}),a(Ht,{addons:T,clusterStatus:i,selectedNode:f,onRefresh:()=>void S(),listPhase:_?`pending`:v?`error`:`ready`})]})}export{Ut as AddonsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,K as t,S as n,Y as r,et as i,i as a,x as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Dn as s,Fn as c,Kt as l,Pr as u,Ri as d,Sa as f,bt as p,ct as m,ht as h,lt as g,xr as _}from"./player-overlays-Dikds8gI.js";import{fo as v,zr as y}from"./client-C3Nr53Gn.js";import{A as b,B as x,Br as S,C,D as w,E as T,Ei as E,F as D,Fr as O,H as k,I as A,In as j,Ir as M,Jr as N,Ko as P,Kr as ee,L as te,M as ne,N as re,On as ie,Pf as ae,Pr as oe,R as se,Rn as F,Rr as ce,U as le,V as I,Xr as ue,Yr as L,Zr as R,b as de,bo as fe,j as pe,k as z,kn as me,oi as B,ri as he,td as ge,ui as V,vi as H,w as _e,x as ve,y as ye,yo as be,z as xe,zn as U,zr as Se}from"./src-VAvW-zoJ.js";import{t as W}from"./useTranslation-BJr-n0es.js";import{Fr as Ce}from"./index-Bec3SQjl.js";import{t as we}from"./AdminPage-B9sdR6yD.js";i();function G(e,t){return e.scope===``?e.displayName:`${e.displayName} · ${t?.(e)??e.scope}`}function Te(e,t,n){let r=[];for(let{device:t,series:i}of e)for(let e of i){let i={subject:{kind:`device`,deviceId:t.id},key:e.key,scope:e.scope};r.push({id:b(i),ref:i,info:e,subjectName:t.name,location:t.location??``,nodeId:``,metric:G(e,n)})}for(let{node:e,series:i}of t)for(let t of i){let i={subject:{kind:`node`,nodeId:e.id},key:t.key,scope:t.scope};r.push({id:b(i),ref:i,info:t,subjectName:e.name,location:``,nodeId:e.id,metric:G(t,n)})}return r}function Ee(e){return[e.subjectName,e.location,e.metric,e.info.key,e.info.unit??``,e.nodeId].join(` `)}function K(e,t,n){if(e.ref.subject.kind!==`device`||t===null)return e.subjectName;let r=t.byId.get(e.ref.subject.deviceId);return r===void 0?e.subjectName:he(r,`compact`,t,n)}var De=[`energy`,`temperatures`,`nodes`,`storage`],Oe=new Set([`cap:temperature-sensor.temperature`,`cap:climate-control.currentTemp`]),q=[`addon:metrics-native/node-cpu-percent`,`addon:metrics-native/node-memory-percent`],ke=`addon:storage-orchestrator/location-used-percent`;function Ae(e,t){let n=(e,n)=>{let r=t.filter(e);return z((n?[...r].sort(n):r).map(e=>e.ref))};switch(e){case`energy`:return n(e=>e.ref.subject.kind===`device`&&e.info.key===`derived:energy.kwh`);case`temperatures`:return n(e=>e.ref.subject.kind===`device`&&Oe.has(e.info.key)&&e.info.scope===``,(e,t)=>e.location.localeCompare(t.location)||e.subjectName.localeCompare(t.subjectName));case`nodes`:return n(e=>e.ref.subject.kind===`node`&&q.includes(e.info.key)&&e.info.scope===``,(e,t)=>q.indexOf(e.info.key)-q.indexOf(t.info.key)||e.subjectName.localeCompare(t.subjectName));case`storage`:return n(e=>e.ref.subject.kind===`node`&&e.info.key===ke)}}function je(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[],i=[],a=[],o=[];for(let t of z(e)){let e=n.get(b(t));if(e===void 0){o.push(t);continue}e.info.key===`derived:energy.kwh`?a.push(e):e.info.kind===`boolean`||e.info.kind===`enum`?i.push(e):r.push(e)}return{lines:r,states:i,energy:a,missing:o}}function Me(e){return e.subject.kind===`device`?{deviceId:e.subject.deviceId,key:e.key,scope:e.scope}:{forNodeId:e.subject.nodeId,key:e.key,scope:e.scope}}var J=`history-page`;function Ne({part:r,window:i}){let{t:a}=W(),o=f(),s=V(),c=B(),l=e=>`${K(e,s,c)} · ${e.metric}`,u=t(()=>[...r.lines,...r.states,...r.energy],[r]),p=C(t(()=>u.map(e=>Me(e.ref)),[u]),i,!1),m=e=>p.status===`ok`?p.data.current.get(ve(Me(e.ref))):void 0,h=e=>{let t=m(e);return t?.ok?t.result:void 0};if(u.length===0)return n(L,{icon:d,title:a(`history.page.emptyTitle`,`Pick series to compare`),description:a(`history.page.emptyHint`,`Choose up to 24 series on the left, or start from a panel above.`)});if(p.status===`error`)return n(N,{title:a(`history.page.readFailed`,`History could not be read`),message:p.error});let g=p.status===`pending`,_=u.map(e=>({c:e,e:m(e)})).filter(e=>e.e?.ok===!1),v=r.lines.map((e,t)=>{let n=h(e),r=A(e.info,n,i.from);return{id:e.id,label:l(e),unit:e.info.unit,colorIndex:t,points:r.points,gapMs:r.gapMs,interpolation:r.held&&n?.resolution===`raw`?`step`:`linear`}}),y=r.states.map((e,t)=>{let n=te(e.info,h(e),i.from,i.to),r=re(e.info.key,o);return{id:e.id,label:l(e),kind:e.info.kind===`boolean`?`boolean`:`enum`,colorIndex:e.info.kind===`boolean`?t:0,states:n.states,segments:n.segments,totals:n.totals,stateLabel:e.info.kind===`boolean`?e=>e===`true`?r.on:r.off:void 0}}),b=r.energy.map(e=>({c:e,...D(h(e))})),x=b[0]?.bucketMs??36e5,S=[...new Set(b.flatMap(e=>e.buckets.map(e=>e.t)))].sort((e,t)=>e-t).map(e=>({t:e,values:b.map(t=>t.buckets.find(t=>t.t===e)?.values[0]??null)}));return e(`div`,{className:`space-y-5 min-w-0`,children:[_.length>0&&n(N,{title:a(`history.page.someFailed`,`Some series could not be read`),message:_.map(e=>`${l(e.c)}: ${e.e.error}`).join(` · `)}),v.length>0&&n(le,{title:a(`history.page.lines`,`Measurements`),series:v,range:i,height:260,syncKey:J,pending:g}),b.length>0&&n(ee,{title:a(`history.page.energy`,`Energy`),layers:b.map((e,t)=>({id:e.c.id,label:K(e.c,s,c),colorIndex:t})),buckets:S,bucketMs:x,range:i,unit:`kWh`,showTotal:!0,height:160,syncKey:J,pending:g}),y.length>0&&n(k,{title:y.length===1?y[0]?.label??``:a(`history.page.states`,`States`),rows:y,range:i,syncKey:J,pending:g})]})}function Pe(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}async function Fe(e,t){let n=[];for(let r of Pe(e,50))try{let{results:e}=await t(r),i=new Map(e.map(e=>[e.seriesId,e]));for(let e of r)n.push(i.get(e)??{seriesId:e,ok:!1,reason:`not-found`})}catch(e){let t=e instanceof Error?e.message:String(e);for(let e of r)n.push({seriesId:e,ok:!1,reason:`request-failed`,message:t})}return n}function Y(e){return e.raw+e[`5m`]+e[`1h`]+e[`1d`]}function Ie(e){return e.reduce((e,t)=>t.ok?{...e,deleted:e.deleted+1,points:e.points+Y(t.deleted)}:{...e,refused:e.refused+1},{deleted:0,refused:0,points:0})}function Le(e,t){let n=new Map(e.map(e=>[e.seriesId,e]));return t.flatMap(e=>{let t=n.get(e.seriesId);return t===void 0?[]:[{series:t,outcome:e}]})}var X=e=>new Date(e).toLocaleDateString(void 0,{dateStyle:`short`});function Z(e,t,n){let r=t.get(e.deviceId);return r===void 0?e.reason===`device-gone`?n(`history.orphans.deviceRemoved`,`#{{id}} (removed)`,{id:e.deviceId}):n(`history.orphans.deviceId`,`#{{id}}`,{id:e.deviceId}):r}function Q(e){let t=e.displayName??e.key;return e.scope===``?t:`${t} · ${e.scope}`}function Re(t,r,i){return{key:`series`,header:i(`history.orphans.colSeries`,`Series`),render:a=>{let o=t(a);return e(`div`,{className:`min-w-0 max-w-[16rem]`,children:[n(`div`,{className:`truncate text-foreground`,title:o.key,children:Q(o)}),n(`div`,{className:`truncate text-[10px] text-foreground-subtle`,children:Z(o,r,i)})]})},sortValue:e=>`${Z(t(e),r,i)} ${Q(t(e))}`}}var ze=[`raw`,`5m`,`1h`,`1d`];function Be(e,t){return e===`raw`?t(`history.orphans.colRaw`,`Raw points`):e===`5m`?t(`history.orphans.col5m`,`5 min`):e===`1h`?t(`history.orphans.col1h`,`1 h`):t(`history.orphans.col1d`,`1 day`)}function Ve(t,r){return[Re(e=>e,t,r),{key:`reason`,header:r(`history.orphans.colReason`,`Reason`),render:t=>e(`div`,{className:`flex flex-col items-start gap-0.5`,children:[n(E,{variant:t.reason===`device-gone`?`warning`:`neutral`,className:`text-[10px]`,children:t.reason===`device-gone`?r(`history.orphans.deviceGone`,`Device removed`):r(`history.orphans.undeclared`,`No longer declared`)}),t.missingSince!==null&&n(`span`,{className:`text-[10px] text-foreground-subtle`,children:r(`history.orphans.since`,`since {{date}}`,{date:X(t.missingSince)})})]}),sortValue:e=>e.reason},{key:`span`,header:r(`history.orphans.colSpan`,`Recorded`),render:t=>e(`span`,{className:`tabular-nums text-foreground-muted`,children:[X(t.firstTs),` → `,X(t.lastTs)]}),sortValue:e=>e.lastTs},...ze.map(e=>({key:`rows-${e}`,header:Be(e,r),align:`right`,render:t=>n(`span`,{className:`tabular-nums text-foreground-muted`,children:t.rows[e].toLocaleString()}),sortValue:t=>t.rows[e]}))]}function He(e,t){if(e.ok)return n(E,{variant:`success`,className:`text-[10px]`,children:t(`history.orphans.deleted`,{count:Y(e.deleted),points:Y(e.deleted).toLocaleString(),defaultValue_one:`Deleted · {{points}} point`,defaultValue_other:`Deleted · {{points}} points`})});let r=e.reason===`request-failed`?t(`history.orphans.requestFailed`,`Not sent: {{message}}`,{message:e.message}):e.reason===`not-orphan`?t(`history.orphans.refusedNotOrphan`,`Kept: no longer orphan`):e.reason===`not-found`?t(`history.orphans.refusedNotFound`,`Already gone`):t(`history.orphans.refusedFailed`,`The hub could not delete it`);return n(E,{variant:e.reason===`not-found`?`neutral`:`warning`,className:`text-[10px]`,children:r})}function Ue(e,t){return[Re(e=>e.series,e,t),{key:`result`,header:t(`history.orphans.colResult`,`Result`),render:e=>He(e.outcome,t),sortValue:e=>+!e.outcome.ok}]}i();function We({open:i,onClose:a,list:o,deviceNames:s,onDelete:u,onRefresh:d,refreshing:f}){let{t:p}=W(),h=m(),[g,v]=r(new Set),[y,b]=r(!1),[x,C]=r([]),w=t(()=>Ve(s,p),[s,p]),T=t(()=>Ue(s,p),[s,p]),E=t(()=>new Set(o.series.map(e=>String(e.seriesId))),[o.series]),D=[...g].filter(e=>E.has(e)).map(Number),k=Ie(x.map(e=>e.outcome)),A=async()=>{if(await h({title:p(`history.orphans.confirmTitle`,{count:D.length,defaultValue_one:`Delete {{count}} series`,defaultValue_other:`Delete {{count}} series`}),message:p(`history.orphans.confirmMessage`,`Every recorded point of these series is removed from the hub. This cannot be undone.`),confirmLabel:p(`history.orphans.confirmLabel`,`Delete`),variant:`danger`})){b(!0);try{let e=await Fe(D,u);C(Le(o.series,e)),v(new Set)}finally{b(!1),d()}}};return n(oe,{open:i,onOpenChange:e=>!e&&a(),children:e(M,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,"data-testid":`orphan-series-dialog`,children:[n(Se,{children:n(S,{children:p(`history.orphans.title`,`Series no longer linked to a device`)})}),e(O,{className:`space-y-3`,children:[n(`p`,{className:`text-xs text-foreground-muted`,children:p(`history.orphans.intro`,`Nothing records into these series any more: their device was removed, or no capability declares them now. Select the ones to delete.`)}),o.truncated&&e(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`orphan-truncated`,children:[n(`p`,{className:`text-xs text-warning`,children:p(`history.orphans.truncated`,`More series are unlinked than are listed here. Delete these, then load the rest.`)}),e(H,{size:`sm`,variant:`outline`,onClick:d,disabled:f,children:[n(c,{className:`h-3 w-3`,"aria-hidden":!0}),p(`history.orphans.loadAgain`,`Load again`)]})]}),x.length>0&&e(`div`,{className:`space-y-2`,"data-testid":`orphan-outcomes`,children:[n(`p`,{className:`text-xs text-foreground`,"aria-live":`polite`,children:p(`history.orphans.summary`,{count:k.deleted,refused:k.refused,points:k.points.toLocaleString(),defaultValue_one:`{{count}} series deleted ({{points}} points), {{refused}} kept.`,defaultValue_other:`{{count}} series deleted ({{points}} points), {{refused}} kept.`})}),n(F,{columns:T,rows:x,rowKey:e=>String(e.series.seriesId),minWidthPx:420,maxBodyHeight:`max-h-[60vh]`,emptyMessage:``})]}),n(F,{columns:w,rows:o.series,rowKey:e=>String(e.seriesId),minWidthPx:760,maxBodyHeight:U,defaultSort:{columnKey:`series`,dir:`asc`},emptyMessage:p(`history.orphans.empty`,`Every series is linked to a device.`),selection:{selected:g,onChange:v,rowLabel:e=>`${Q(e)} — ${Z(e,s,p)}`,pageLabel:p(`history.orphans.selectAll`,`Select every listed series`)}})]}),e(ce,{children:[n(`span`,{className:`mr-auto text-[11px] tabular-nums text-foreground`,"aria-live":`polite`,children:p(`history.orphans.selected`,{count:D.length,defaultValue_one:`{{count}} selected`,defaultValue_other:`{{count}} selected`})}),n(H,{variant:`ghost`,size:`sm`,onClick:a,children:p(`history.orphans.close`,`Close`)}),e(H,{variant:`danger`,size:`sm`,disabled:D.length===0||y,onClick:()=>void A(),children:[y?n(_,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):n(l,{className:`h-3 w-3`,"aria-hidden":!0}),p(`history.orphans.deleteSelected`,`Delete selected`)]})]})]})})}i();var Ge=5*6e4;function Ke({enabled:i}){let{t:a}=W(),[s,c]=r(!1),l=fe({},{enabled:i,staleTime:Ge}),u=P({projection:`slim`},{enabled:i}),d=be(),f=t(()=>new Map((u.data??[]).map(e=>[e.id,e.name])),[u.data]),p=e=>d.mutateAsync({seriesIds:[...e]});if(!i||l.status===`pending`)return null;if(l.status===`error`)return n(N,{variant:`warning`,title:a(`history.orphans.checkFailedTitle`,`Could not check for unlinked series`),message:l.error.message,onRetry:()=>void l.refetch()});let m=l.data;if(m.series.length===0&&!s)return null;let h=m.series.length;return e(o,{children:[h>0&&n(N,{variant:`warning`,message:m.truncated?a(`history.orphans.noticeMore`,{count:h,defaultValue_one:`More than {{count}} series are no longer linked to a device.`,defaultValue_other:`More than {{count}} series are no longer linked to a device.`}):a(`history.orphans.notice`,{count:h,defaultValue_one:`{{count}} series is no longer linked to a device.`,defaultValue_other:`{{count}} series are no longer linked to a device.`}),action:n(H,{size:`sm`,variant:`outline`,onClick:()=>c(!0),children:a(`history.orphans.review`,`Review`)})}),n(We,{open:s,onClose:()=>c(!1),list:m,deviceNames:f,onDelete:p,onRefresh:()=>void l.refetch(),refreshing:l.isFetching})]})}i();var qe=`device`,Je=`node`;function Ye({catalog:r,selected:i,onChange:a,loading:o}){let{t:s}=W(),c=V(),l=B(),u=e=>K(e,c,l),d=ie(r,{searchText:e=>[Ee(e)],facetGroups:[{id:`subject`,value:e=>e.ref.subject.kind===`device`?qe:Je},{id:`room`,value:e=>e.location},{id:`unit`,value:e=>e.info.unit??``}]}),f=t(()=>[{key:`metric`,header:s(`history.picker.series`,`Series`),render:t=>e(`div`,{className:`min-w-0`,children:[n(`div`,{className:`truncate text-foreground`,children:t.metric}),n(`div`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.location===``?u(t):`${u(t)} · ${t.location}`})]}),sortValue:e=>`${e.subjectName} ${e.metric}`},{key:`unit`,header:s(`history.picker.unit`,`Unit`),render:e=>n(`span`,{className:`text-foreground-muted`,children:e.info.unit??`—`}),sortValue:e=>e.info.unit??``}],[s,c,l]),p=i.size>=24;return e(`div`,{className:`space-y-2 min-w-0`,children:[n(me,{state:d.state,facets:[],groups:[{...d.groups.find(e=>e.id===`subject`)??{id:`subject`,facets:[],selected:[]},label:s(`history.picker.subject`,`Source`),facetLabel:e=>e===qe?s(`history.picker.devices`,`Devices`):s(`history.picker.nodes`,`Nodes`)},{...d.groups.find(e=>e.id===`room`)??{id:`room`,facets:[],selected:[]},label:s(`history.picker.room`,`Room`),facetLabel:e=>e===``?s(`history.picker.noRoom`,`No room`):e},{...d.groups.find(e=>e.id===`unit`)??{id:`unit`,facets:[],selected:[]},label:s(`history.picker.metricType`,`Unit`),facetLabel:e=>e===``?s(`history.picker.noUnit`,`States & counts`):e}],labels:{searchPlaceholder:s(`history.picker.search`,`Search device, room, metric or node…`),searchLabel:s(`history.picker.searchLabel`,`Search series`),facetsLabel:s(`history.picker.facets`,`Filters`),clearLabel:s(`history.picker.clear`,`Clear`)},onSearch:d.setSearch,onToggleFacet:d.toggleFacet,onToggleGroupFacet:d.toggleGroupFacet,onClear:d.clear}),n(`p`,{className:`text-[10px] text-foreground-subtle`,"aria-live":`polite`,children:s(`history.picker.count`,`{{count}} of {{max}} selected`,{count:i.size,max:24})}),n(F,{columns:f,rows:d.rows,rowKey:e=>e.id,maxBodyHeight:U,pageSize:50,defaultSort:{columnKey:`metric`,dir:`asc`},emptyMessage:o?s(`history.picker.loading`,`Reading the series of every device…`):d.active?s(`history.picker.emptyFiltered`,`No series match these filters.`):s(`history.picker.empty`,`Nothing is recorded yet.`),selection:{selected:i,onChange:e=>{let t=[...e].filter(e=>i.has(e)),n=[...e].filter(e=>!i.has(e));a(new Set([...t,...n].slice(0,24)))},isSelectable:e=>i.has(e.id)||!p,rowLabel:e=>`${u(e)} · ${e.metric}`,pageLabel:s(`history.picker.selectPage`,`Select every series on this page`)}})]})}i();var Xe=new Set([v.Hub,v.Container]),$=5*6e4;function Ze(){let{t:r}=W(),i=ue(`device-history`),[a,o]=Ce(),c=t(()=>z(a.getAll(`s`).flatMap(e=>{let t=T(e);return t===null?[]:[t]})),[a]),l=a.get(`window`),f=x(l)?l:`7d`,h=se(a.get(`range`)),_=(e,t,n)=>{let r=new URLSearchParams;for(let t of z(e))r.append(`s`,w(t));t!==`7d`&&r.set(`window`,t);let i=n===void 0?a.get(`range`):n;t===`custom`&&i&&r.set(`range`,i),o(r,{replace:!0})},v=Qe(i===`present`),y=I(f,Date.now(),h),S=I(f,de(Date.now(),y.to-y.from),h),C=t(()=>je(c,v.candidates),[c,v.candidates]),E=t(()=>new Set(c.map(b)),[c]),D=ye(),O=g(),k=m(),A=async()=>{let e=await O({title:r(`history.page.saveTitle`,`Save as panel`),label:r(`history.page.saveName`,`Panel name`),confirmLabel:r(`history.page.save`,`Save`)});e===null||e.trim()===``||await D.update(t=>pe(t,{id:`panel-${Date.now().toString(36)}`,name:e.trim().slice(0,80),window:f,selection:[...c]}))},M=async(e,t)=>{await k({title:r(`history.page.deleteTitle`,`Delete panel`),message:r(`history.page.deleteMessage`,`The panel "{{name}}" is removed from your account.`,{name:t}),confirmLabel:r(`history.page.delete`,`Delete`),variant:`danger`})&&await D.update(t=>ne(t,e))},P=e=>e===`energy`?r(`history.panels.energy`,`Total energy`):e===`temperatures`?r(`history.panels.temperatures`,`Temperatures by room`):e===`nodes`?r(`history.panels.nodes`,`Cluster nodes`):r(`history.panels.storage`,`Storage locations`);return n(we,{icon:d,title:r(`history.page.title`,`History`),subtitle:r(`history.page.subtitle`,`What devices, nodes and storage recorded over time, side by side.`),actions:i===`present`?e(H,{size:`sm`,variant:`outline`,onClick:()=>void A(),disabled:c.length===0||!D.writable,children:[n(s,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),r(`history.page.saveTitle`,`Save as panel`)]}):void 0,children:i===`pending`?n(R,{className:`h-64 w-full`}):i===`unknown`?n(N,{title:r(`history.page.presenceUnknownTitle`,`Could not reach the hub`),message:r(`history.page.presenceUnknown`,`The hub did not say whether device history is installed. Try again in a moment.`)}):i===`absent`?n(L,{icon:u,title:r(`history.page.absentTitle`,`Device history is not running on this hub`),description:r(`history.page.absent`,`Nothing is recorded until the device-history system addon is enabled.`)}):e(`div`,{className:`space-y-3 sm:space-y-4`,children:[n(Ke,{enabled:i===`present`}),e(`div`,{className:`flex flex-wrap items-center gap-2`,role:`group`,"aria-label":r(`history.page.panels`,`Panels`),children:[De.map(e=>n(H,{size:`sm`,variant:`outline`,disabled:v.status!==`ok`,onClick:()=>_(Ae(e,v.candidates),f),children:P(e)},e)),D.value.panels.map(t=>e(`span`,{className:`inline-flex items-center`,children:[n(H,{size:`sm`,variant:`secondary`,onClick:()=>_(t.selection,t.window,null),children:t.name}),n(H,{size:`sm`,variant:`ghost`,"aria-label":r(`history.page.deleteNamed`,`Delete panel {{name}}`,{name:t.name}),onClick:()=>void M(t.id,t.name),disabled:!D.writable,children:n(p,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})]},t.id))]}),e(`div`,{className:`grid grid-cols-1 gap-3 sm:gap-4 xl:grid-cols-5`,children:[n(`div`,{className:`min-w-0 xl:col-span-2`,children:n(j,{headingId:`history-picker`,title:r(`history.picker.title`,`Series`),children:n(`div`,{className:`p-2 sm:p-3`,children:v.status===`error`?n(N,{message:v.error}):n(Ye,{catalog:v.candidates,loading:v.status===`pending`,selected:E,onChange:e=>{let t=c.filter(t=>e.has(b(t))),n=v.candidates.filter(t=>e.has(t.id)&&!E.has(t.id)).map(e=>e.ref);_([...t,...n],f)}})})})}),n(`div`,{className:`min-w-0 xl:col-span-3`,children:n(j,{headingId:`history-overlay`,title:r(`history.page.overlay`,`Overlay`),actions:c.length>0?n(H,{size:`sm`,variant:`ghost`,onClick:()=>_([],f),children:r(`history.page.clear`,`Clear`)}):void 0,children:e(`div`,{className:`p-2 sm:p-3 space-y-3 min-w-0`,children:[n(_e,{value:f,onChange:e=>_(c,e),custom:h,onCustomChange:e=>_(c,`custom`,xe(e))}),v.status===`pending`&&c.length>0?n(R,{className:`h-64 w-full`}):n(Ne,{part:C,window:S}),C.missing.length>0&&v.status===`ok`&&n(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`history.page.missing`,{count:C.missing.length,defaultValue_one:`{{count}} selected series is no longer recorded.`,defaultValue_other:`{{count}} selected series are no longer recorded.`})})]})})})]})]})})}function Qe(e){let{t:n}=W(),r=n(`history.picker.wholeFrame`,`Whole frame`),i=h().trpcClient,o=P({projection:`slim`},{enabled:e}),{nodes:s}=ae(),c=t(()=>(o.data??[]).filter(e=>!Xe.has(String(e.type))),[o.data]),l=a({queries:c.map(t=>({queryKey:[`device-history`,`listSeries`,t.id],queryFn:()=>i.deviceHistory.listSeries.query({deviceId:t.id}),enabled:e,staleTime:$}))}),u=a({queries:s.map(t=>({queryKey:[`device-history`,`listNodeSeries`,t.id],queryFn:()=>i.deviceHistory.listNodeSeries.query({forNodeId:t.id}),enabled:e,staleTime:$}))}),d=ge({},{enabled:e,staleTime:$}),f=t(()=>new Map((d?.data??[]).map(e=>[e.id,e.displayName])),[d?.data]),p=l.map(e=>e.data),m=u.map(e=>e.data),g=t(()=>Te(c.flatMap((e,t)=>{let n=p[t];return n===void 0?[]:[{device:{id:e.id,name:e.name,location:e.location??null},series:n}]}),s.flatMap((e,t)=>{let n=m[t];return n===void 0?[]:[{node:{id:e.id,name:e.name},series:n}]}),e=>{if(e.key!==`addon:pipeline-analytics/occupancy`)return f.get(e.scope)??e.scope;let{zoneId:t,className:n}=y(e.scope),i=t===``?r:t;return n===void 0?i:`${i} · ${n}`}),[c,s,f,[...l,...u].map(e=>e.dataUpdatedAt).join(`,`),r]);return o.status===`error`?{status:`error`,error:o.error.message,candidates:[]}:{status:o.status===`pending`||l.some(e=>e.isPending)||u.some(e=>e.isPending)?`pending`:`ok`,error:``,candidates:g}}export{Ze as HistoryPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,S as r,V as i,Y as a,a as o,et as s,o as c,x as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$r as u,Cn as d,D as f,Fn as p,Ft as m,Kt as h,Tn as g,Ut as _,Wn as v,Xn as y,_n as b,ai as x,bn as S,bt as C,ct as w,ht as T,ki as E,kr as ee,lt as te,oa as ne,un as D,ut as re,vr as ie,wr as O,xr as k,yn as ae}from"./player-overlays-Dikds8gI.js";import{l as A,mo as oe,po as se}from"./client-C3Nr53Gn.js";import{c as j,f as M,h as ce,r as le}from"./video-BSNDvfCe.js";import{t as ue}from"./file-up-D3z4d_SX.js";import{t as de}from"./key-CXhExtg1.js";import{t as fe}from"./monitor-smartphone-Cla2sWWl.js";import{t as pe}from"./unlink-CO3ZHU5X.js";import{$d as me,An as he,Br as N,Ei as P,Et as ge,Fr as F,Gd as _e,In as ve,Ir as I,Jd as ye,Jr as L,Kd as R,Ko as z,Ln as B,Mr as be,Oc as xe,Pr as V,Pt as H,Qd as Se,Rn as Ce,Rr as we,Ud as Te,Wd as Ee,X as De,Xd as Oe,Yd as ke,Yr as Ae,Zd as je,ar as Me,cf as Ne,cr as Pe,df as Fe,ef as Ie,er as Le,ht as Re,ir as ze,jn as Be,kc as Ve,lf as He,lr as Ue,nr as We,or as Ge,qd as Ke,rr as qe,sf as Je,uf as Ye,vi as U,wc as Xe,wt as Ze,xc as Qe,yc as $e,zf as W,zn as et,zr as tt}from"./src-VAvW-zoJ.js";import{t as G}from"./i18n-ChjX2Pvm.js";import{t as K}from"./useTranslation-BJr-n0es.js";import{Fr as nt,Nr as rt,P as it,a as at,b as ot,d as st,i as ct,jr as lt,l as ut,t as dt}from"./index-Bec3SQjl.js";import{t as ft}from"./AdminSectionedPage-Di2VI8A1.js";import{t as pt}from"./AdminPage-B9sdR6yD.js";import{C as mt,D as q,E as ht,O as J,S as gt,T as _t,_ as vt,a as yt,b as bt,c as xt,d as St,f as Ct,g as wt,h as Tt,i as Et,k as Dt,l as Ot,m as kt,n as At,o as jt,p as Mt,s as Nt,t as Pt,u as Ft,v as It,w as Lt,x as Rt,y as zt}from"./SessionsList-CxJU6jkU.js";import{r as Bt}from"./IntegrationHub-DwJAPbKr.js";import{n as Vt}from"./Authentication-CMBgIYCp.js";s();function Ht(){let{t:e}=K(),t=w(),i=W.useUtils(),o=Dt(),{data:s,isLoading:c}=ke(),l=n(()=>s??[],[s]),u=W.useQueries(e=>l.map(t=>e.userManagement.listExternalIdentities({userId:t.id}))),d=W.auth.listLoginMethods.useQuery(),[f,p]=a(null),m=me({onSuccess:()=>void i.userManagement.listExternalIdentities.invalidate(),onError:e=>p(`Remove failed: ${e.message}`)}),h=n(()=>new Map((d.data??[]).flatMap(e=>e.kind===`redirect`?[[e.id,e.label]]:[])),[d.data]),g=l.flatMap((e,t)=>u[t]?.data??[]),_=g.map(e=>({...Rt(e,o),kind:h.get(e.provider)??e.provider})),v=async n=>{let r=g.find(e=>bt(e)===n.id);r!==void 0&&await t({title:e(`access.externalIdentitiesSection.removeSignInLink`,`Remove sign-in link`),message:e(`access.externalIdentitiesSection.willNoLongerBeAble`,`"{{ownerName}}" will no longer be able to sign in with this {{kind}} account.`,{ownerName:n.ownerName,kind:n.kind}),confirmLabel:e(`common.remove`,`Remove`),variant:`danger`})&&(p(null),m.mutate({userId:r.userId,provider:r.provider,subject:r.subject}))};return r(q,{notice:J(f),onDismissNotice:()=>{p(null)},id:`external-identities`,title:e(`access.externalIdentitiesSection.signInLinks`,`Sign-in links`),icon:ce,description:e(`access.externalIdentitiesSection.externalAccountsSingleSignOn`,`External accounts (single sign-on) each user linked to their CamStack account. Only the owner can link one, from their profile; an admin can remove it.`),children:r(Lt,{rows:_,label:`sign-in links`,isLoading:c||u.some(e=>e.isLoading),loadError:u.find(e=>e.isError)?.error?.message??null,emptyText:`No user has linked a sign-in account.`,expiresNone:`—`,action:{label:e(`common.remove`,`Remove`),icon:pe,isAvailable:()=>!0,onRun:e=>void v(e),busyId:null,disabled:m.isPending}})})}s();var Ut={key:`access.nouns.linkedApp`};function Wt(e){if(e.type===`category`){let t=e.target??``;return t===`device`?G.t(`access.linkedAppsSection.allDevices`):G.t(`access.linkedAppsSection.allTarget`,{target:t})}if(e.type===`device`)return`device:[${(e.targets??[]).join(`,`)}]`;let t=e;return`${t.type}:${t.target??``}`}function Gt(){let{t:e}=K(),t=w(),i=c(),o=ye(),[s,l]=a(null),u=()=>void i.invalidateQueries({queryKey:[[`userManagement`,`listOauthSessions`]]}),d=je({onSuccess:u,onError:e=>l(`Revoke failed: ${e.message}`)}),f=_t(Ut,u),p=n(()=>(o.data??[]).map(e=>gt(e,e.scopes.map(Wt).join(`, `))),[o.data]),m=async n=>{await t({title:e(`access.linkedAppsSection.revokeTheLink`,`Revoke the "{{name}}" link?`,{name:n.name}),message:e(`access.linkedAppsSection.losesAccessForOnIts`,`{{name}} loses access for {{ownerName}} on its next call. Linking it again needs the account-link flow from the start.`,{name:n.name,ownerName:n.ownerName}),confirmLabel:e(`access.linkedAppsSection.revoke`,`Revoke`),variant:`danger`})&&(l(null),d.mutate({id:n.id}))},g=d.isPending?d.variables?.id??null:null;return r(q,{notice:J(s,f.outcome),onDismissNotice:()=>{l(null),f.dismiss()},id:`linked-apps`,title:e(`access.linkedAppsSection.linkedApps`,`Linked apps`),icon:O,description:e(`access.linkedAppsSection.externalIntegrationsAlexaLinkedTo`,`External integrations (Alexa, …) linked to this hub through OAuth. Revoking one stops that integration on its next call. Already-revoked rows can be selected and removed from the list.`),children:r(Lt,{rows:p,label:e(`access.linkedAppsSection.linkedApps2`,`linked apps`),isLoading:o.isLoading,loadError:o.isError?o.error?.message??`Request failed`:null,emptyText:`No linked apps — an integration appears here once it completes the account-link flow.`,expiresNone:`—`,action:{label:e(`access.linkedAppsSection.revoke`,`Revoke`),icon:h,isAvailable:e=>e.status===`active`||e.status===`revoked`,onRun:e=>void m(e),busyId:g,disabled:d.isPending||f.busy},bulk:{revoke:f,noun:Ut,isSelectable:e=>e.status===`active`||e.status===`revoked`,quickSelect:[{label:e(`access.linkedAppsSection.selectRevoked`,`Select revoked`),match:e=>e.status===`revoked`}]}})})}var Kt=5e3;function qt(){let{t}=K(),n=W.useUtils(),i=W.auth.cliLoginPending.useQuery(void 0,{refetchInterval:Kt}),a=W.auth.cliLoginDeny.useMutation({onSuccess:()=>void n.auth.cliLoginPending.invalidate()}),o=i.data??[];if(o.length===0)return null;let s=Date.now();return e(`div`,{className:`space-y-2 rounded-md border border-border bg-background-elevated p-3`,"data-testid":`pending-terminal-signins`,children:[e(`div`,{className:`flex items-center gap-2 text-xs font-medium text-foreground`,children:[r(le,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),t(`cliLogin.pendingTitle`,`Pending terminal sign-ins`)]}),r(`ul`,{className:`space-y-1`,children:o.map(n=>{let i=dt(n.createdAt,s);return e(`li`,{className:`flex items-center justify-between gap-3 text-xs`,children:[e(`span`,{className:`min-w-0 truncate text-foreground-muted`,children:[n.userAgent??t(`cliLogin.unknownValue`,`Unknown`),` · `,n.ip??t(`cliLogin.unknownValue`,`Unknown`),` · `,i.key===`justNow`?t(`cliLogin.ageNow`,`just now`):i.key===`seconds`?t(`cliLogin.ageSeconds`,`{{count}} s ago`,{count:i.value}):t(`cliLogin.ageMinutes`,`{{count}} min ago`,{count:i.value})]}),r(U,{type:`button`,size:`sm`,variant:`ghost`,disabled:a.isPending,onClick:()=>a.mutate({requestId:n.requestId}),children:t(`cliLogin.notMe`,`Not me`)})]},n.requestId)})}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`cliLogin.pendingHint`,`To approve one, open the approval page and type the code the terminal shows.`)})]})}s();var Jt={key:`access.nouns.session`};function Yt(){let{t}=K(),i=w(),o=W.useUtils(),s=Dt(),c=W.auth.listSessions.useQuery(),[l,u]=a(null),d=()=>void o.auth.listSessions.invalidate(),f=W.auth.revokeSessions.useMutation({onSuccess:d,onError:e=>u(`Sign out failed: ${e.message}`)}),p=_t(Jt,d),m=n(()=>(c.data??[]).map(e=>mt(e,s,{client:e=>vt(e).label,method:It})),[c.data,s]),h=async e=>{await i({title:t(`access.loginSessionsSection.signOutThisSession`,`Sign out this session`),message:t(`access.loginSessionsSection.onWillHaveToSign`,`{{ownerName}} on {{name}} will have to sign in again.`,{ownerName:e.ownerName,name:e.name}),confirmLabel:t(`access.loginSessionsSection.signOut`,`Sign out`),variant:`danger`})&&(u(null),f.mutate({id:e.id}))};return e(q,{notice:J(l,p.outcome),onDismissNotice:()=>{u(null),p.dismiss()},id:`login-sessions`,title:t(`access.loginSessionsSection.loginSessions`,`Login sessions`),icon:fe,description:t(`access.loginSessionsSection.everyBrowserAndAppSigned`,`Every browser and app signed in to this hub, for every user. Signing one out ends it at once; it has to sign in again. Your own current session is marked and never included in a bulk sign-out.`),children:[r(qt,{}),r(Lt,{rows:m,label:t(`common.sessionsLabel`),isLoading:c.isLoading,loadError:c.isError?c.error?.message??`Request failed`:null,emptyText:`No active sessions.`,action:{label:t(`access.loginSessionsSection.signOut`,`Sign out`),icon:j,isAvailable:e=>e.status===`active`,onRun:e=>void h(e),busyId:f.isPending&&f.variables!==void 0&&`id`in f.variables?f.variables.id:null,disabled:f.isPending||p.busy},bulk:{revoke:p,noun:Jt,isSelectable:e=>e.status===`active`}})]})}var Xt={"by-id":`helpers.authAuditWording.bulkNoun.credential`,"share-link":`helpers.authAuditWording.bulkNoun.shareLink`,"admin-token":`helpers.authAuditWording.bulkNoun.adminToken`,"login-session":`helpers.authAuditWording.bulkNoun.loginSession`};function Y(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function X(e,t){let n=Y(e,`tokenId`);return Y(e,`name`)??(n===null?void 0:t.get(n))??n??`?`}function Z(e){return e.filter(e=>e!==null)}function Zt(e){let t=Y(e,`prefix`);return t===null?null:G.t(`helpers.authAuditWording.prefix`,{prefix:t})}function Qt(e,t){let n=e.detail??{};switch(e.action){case`admin-token-created`:{let e=n.expiresAt;return{title:G.t(`helpers.authAuditWording.tokenCreated`,{name:X(n,t)}),details:Z([Zt(n),typeof e==`number`?G.t(`helpers.authAuditWording.expires`,{at:zt(e)}):null])}}case`admin-token-used`:{let e=Y(n,`path`);return{title:G.t(`helpers.authAuditWording.tokenUsed`,{name:X(n,t)}),details:Z([Zt(n),e===null?null:G.t(`helpers.authAuditWording.call`,{path:e})])}}case`token-minted`:{let e=n.expiresAt;return{title:G.t(`helpers.authAuditWording.tokenMinted`,{name:X(n,t)}),details:Z([typeof e==`number`?G.t(`helpers.authAuditWording.expires`,{at:zt(e)}):null])}}case`token-revoked`:return{title:G.t(`helpers.authAuditWording.anyTokenRevoked`,{name:X(n,t)}),details:[]};case`admin-token-revoked`:return{title:G.t(`helpers.authAuditWording.tokenRevoked`,{name:X(n,t)}),details:Z([Zt(n)])};case`credentials-revoked`:{let e=Y(n,`kind`)??`credential`,t=n.revoked,r=n.skipped,i=Xt[e],a=i===void 0?`${e}s`:G.t(i);return{title:G.t(`helpers.authAuditWording.bulkRevoked`,{n:typeof t==`number`?String(t):`?`,noun:a}),details:Z([typeof r==`number`&&r>0?G.t(`helpers.authAuditWording.skipped`,{count:r}):null,Y(n,`ids`)===null?null:G.t(`helpers.authAuditWording.ids`,{ids:Y(n,`ids`)??``})])}}case`second-factor-skipped`:{let e=Y(n,`method`),t=Y(n,`factors`);return{title:G.t(`helpers.authAuditWording.secondFactorSkipped`),details:Z([e===null?null:G.t(`helpers.authAuditWording.signedInWith`,{method:It(e)}),t===null?null:G.t(`helpers.authAuditWording.skippedFactors`,{factors:t.split(`,`).join(`, `)})])}}default:return{title:e.action,details:Object.entries(n).map(([e,t])=>`${e}: ${String(t)}`)}}}s();var $t=100;function en(){let{user:e}=it();return e?.isAdmin?r(nn,{}):null}function tn(){let{data:e}=ke(),{data:t}=W.auth.listTokens.useQuery(void 0);return n(()=>{let n=new Map;for(let t of e??[])n.set(t.id,t.username);let r=new Map;for(let e of t??[])r.set(e.id,e.label);return{userNameById:n,tokenNameById:r}},[e,t])}function nn(){let{t}=K(),n=W.auth.listAuthAudit.useQuery({limit:$t}),{userNameById:i,tokenNameById:a}=tn(),o=n.data??[];return e(`div`,{"data-testid":`auth-audit`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[e(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[r(g,{className:`h-3.5 w-3.5 text-foreground-subtle`}),r(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`auth.authAuditSection.authenticationAudit`,`Authentication audit`)}),r(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:t(`auth.authAuditSection.latest`,{count:$t})})]}),r(`div`,{className:`p-4`,children:n.isLoading?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(k,{className:`h-3.5 w-3.5 animate-spin`}),t(`auth.authAuditSection.loadingAuditTrail`,`Loading audit trail…`)]}):n.isError?e(`div`,{className:`text-[11px] text-danger`,children:[t(`auth.authAuditSection.couldNotLoadTheAudit`,`Could not load the audit trail:`),` `,n.error?.message??t(`auth.authAuditSection.requestFailed`,`Request failed`)]}):o.length===0?e(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center space-y-1`,children:[r(`div`,{children:t(`auth.authAuditSection.noAuthenticationEventsRecordedYet`,`No authentication events recorded yet.`)}),r(`div`,{className:`text-[11px] text-foreground-subtle/90`,children:t(`auth.authAuditSection.thisTrailRecordsAdminToken`,`This trail records admin-token create/use/revoke, trusted-network 2FA skips, and credential revokes (including single share-link revoke). Browser password logins are not listed here.`)})]}):r(`ul`,{className:`divide-y divide-border rounded-md border border-border max-h-[420px] overflow-y-auto`,children:o.map(e=>r(rn,{record:e,userName:e.userId===void 0?null:i.get(e.userId)??e.userId,tokenNameById:a},e.id))})})]})}function rn({record:t,userName:n,tokenNameById:i}){let a=Qt(t,i);return e(`li`,{"data-testid":`auth-audit-row`,className:`px-3 py-2 text-xs space-y-0.5`,children:[e(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[r(`span`,{className:`font-medium text-foreground`,children:a.title}),r(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:zt(t.at)})]}),e(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[n!==null&&r(`span`,{className:`text-foreground`,children:n}),t.ip!==void 0&&r(`span`,{className:`font-mono`,children:t.ip}),a.details.map(e=>r(`span`,{className:`font-mono`,children:e},e))]})]})}s();var Q={loginSessions:`login-sessions`,linkedApps:`linked-apps`,tokens:`tokens`,scopedTokens:`scoped-tokens`,adminTokens:`admin-tokens`,shareLinks:`share-links`,externalIdentities:`external-identities`,audit:`auth-audit`},an={[Q.scopedTokens]:Q.tokens,[Q.adminTokens]:Q.tokens,[Q.shareLinks]:Q.tokens};function on(){return[{id:Q.loginSessions,label:G.t(`system.access.loginSessions`,`Login sessions`),icon:fe,render:()=>r(Yt,{})},{id:Q.linkedApps,label:G.t(`system.access.linkedApps`,`Linked apps`),icon:O,render:()=>r(Gt,{})},{id:Q.tokens,label:G.t(`system.access.tokens`,`Tokens`),icon:M,render:({createRequested:e,onCreateConsumed:t})=>r(Tt,{headerOwnsCreate:!0,createRequested:e,onCreateConsumed:t})},{id:Q.externalIdentities,label:G.t(`system.access.signInLinks`,`Sign-in links`),icon:ce,render:()=>r(Ht,{})},{id:Q.audit,label:G.t(`system.access.audit`,`Audit`),icon:g,render:()=>r(en,{})}]}function sn({createRequested:t=!1,onCreateConsumed:i}){let{t:a}=K(),o=n(()=>on(),[]),s=Bt({ids:n(()=>o.map(e=>e.id),[o]),answered:!0}),c=rt(),[l]=nt(),u=l.get(`integration`),d=u===null?void 0:an[u];if(d!==void 0){let e=new URLSearchParams(l);return e.set(`integration`,d),r(lt,{to:`?${e.toString()}`,replace:!0})}let f=o.find(e=>e.id===s.selectedId)??o[0];return e(`div`,{className:`flex flex-col gap-3`,"data-testid":`access-page`,children:[r(Le,{appearance:`pills`,value:f?.id??Q.loginSessions,onValueChange:e=>{c(`?${st(l,e,null,null).toString()}`)},children:r(We,{"aria-label":a(`system.access.credentialKinds`,`Credential kinds`),children:o.map(t=>e(qe,{value:t.id,"data-testid":`access-kind-${t.id}`,children:[r(t.icon,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),t.label]},t.id))})}),f===void 0?null:r(`div`,{role:`region`,"aria-label":f.label,"data-testid":`access-kind-body`,children:f.render({createRequested:t&&f.id===Q.tokens,onCreateConsumed:i??(()=>void 0)})},f.id)]})}function cn(t,n){if(t===Q.tokens)return e(U,{size:`sm`,type:`button`,"data-testid":`access-new-token`,onClick:n,children:[r(M,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),G.t(`system.access.newToken`,`New token`)]})}function ln(){let[e,t]=a(!1);return{createRequested:e,requestCreate:()=>t(!0),clearCreate:()=>t(!1)}}function un({isPending:t,error:n,what:i,onRetry:a,children:o}){let{t:s}=K();return t?e(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,role:`status`,"data-testid":`query-pending`,children:[r(k,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),s(`certificates.queryBody.reading`,{what:i})]}):n===null?o:r(L,{title:s(`certificates.queryBody.couldNotRead`,`Could not read {{what}}`,{what:i}),message:n.message.length>0?n.message:s(`certificates.queryBody.requestFailed`,`Request failed`),onRetry:a})}function dn(){let{t}=K(),n=W.deviceCredentials.getDeviceCaStatus.useQuery({}),i=n.data;return r(q,{id:`device-ca`,title:t(`certificates.deviceCaCard.deviceCertificateAuthority`,`Device certificate authority`),icon:ae,description:t(`certificates.deviceCaCard.signsTheCertificateEachPaired`,`Signs the certificate each paired device holds. It is created the first time a device is paired.`),children:r(un,{isPending:n.isPending,error:n.error,what:`the device CA`,onRetry:()=>void n.refetch(),children:i!==void 0&&e(`div`,{className:`space-y-1`,"data-testid":`device-ca-status`,children:[e(B,{label:t(`certificates.deviceCaCard.state`,`State`),children:[i.state===`ready`&&r(P,{variant:`success`,children:t(`certificates.deviceCaCard.ready`,`Ready`)}),i.state===`absent`&&r(P,{variant:`default`,children:t(`certificates.deviceCaCard.notCreatedYet`,`Not created yet`)}),i.state===`unavailable`&&r(P,{variant:`danger`,children:t(`certificates.deviceCaCard.unavailable`,`Unavailable`)})]}),i.state===`ready`&&e(l,{children:[r(B,{label:t(`certificates.deviceCaCard.subject`,`Subject`),valueClassName:`font-mono`,children:i.subject}),r(B,{label:t(`certificates.deviceCaCard.fingerprintSha256`,`Fingerprint (SHA-256)`),valueClassName:`font-mono`,children:i.fingerprintSha256}),r(B,{label:t(`certificates.deviceCaCard.validUntil`,`Valid until`),children:i.validTo})]}),i.state===`unavailable`&&r(B,{label:t(`certificates.deviceCaCard.reason`,`Reason`),children:r(`span`,{className:`text-danger`,children:i.reason})})]})})})}s();function fn(){let{t}=K(),n=W.useUtils(),i=W.deviceCredentials.getDeviceCertificateSettings.useQuery({}),[o,s]=a(null),c=W.deviceCredentials.setDeviceCertificateSettings.useMutation({onSuccess:()=>{s(null),n.deviceCredentials.getDeviceCertificateSettings.invalidate()},onError:e=>s(`Could not save: ${e.message}`)});return r(un,{isPending:i.isPending,error:i.error,what:`the enrollment setting`,onRetry:()=>void i.refetch(),children:i.data!==void 0&&e(B,{label:t(`certificates.deviceSettingsRow.usersCanEnrollTheirOwn`,`Users can enroll their own devices`),actions:r(ze,{checked:i.data.selfEnrollment===`allowed`,disabled:c.isPending,"aria-label":t(`certificates.deviceSettingsRow.usersCanEnrollTheirOwn`,`Users can enroll their own devices`),onCheckedChange:e=>c.mutate({selfEnrollment:e?`allowed`:`disabled`})}),children:[r(`span`,{className:`text-[11px] text-foreground-subtle`,children:i.data.selfEnrollment===`allowed`?t(`certificates.deviceSettingsRow.allowedAUserSignedIn`,`Allowed - a user signed in on a phone can keep it signed in. Pairing by QR works either way.`):t(`certificates.deviceSettingsRow.disabledOnlyAnAdminCan`,`Disabled - only an admin can pair a device, with a QR code.`)}),o!==null&&r(`span`,{className:`block text-[11px] text-danger`,children:o})]})})}s();function pn(e){let[t,n]=a(()=>Date.now());return i(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}s();var mn=80,hn=208;function gn({open:t,users:n,onClose:i,onPaired:o}){let{t:s}=K(),c=W.deviceCredentials.startEnrollment.useMutation({onSuccess:o}),[l,u]=a(``),[d,f]=a(``),p=l===``?n[0]?.id??``:l,m=c.data,h=()=>{c.reset(),f(``),i()};return r(ge,{open:t,onClose:h,title:s(`certificates.pairDeviceDialog.pairADevice`,`Pair a device`),icon:D,width:`md`,testId:`pair-device-dialog`,error:c.isError?c.error.message:null,footer:m===void 0?e(U,{type:`button`,onClick:()=>{let e=d.trim();p===``||e===``||c.mutate({userId:p,deviceName:e})},disabled:c.isPending||p===``||d.trim()===``,children:[c.isPending&&r(k,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),s(`certificates.pairDeviceDialog.createPairingCode`,`Create pairing code`)]}):r(U,{type:`button`,variant:`outline`,onClick:h,children:s(`certificates.pairDeviceDialog.done`,`Done`)}),children:m===void 0?e(`div`,{className:`space-y-3`,children:[r(`p`,{className:`text-[11px] text-foreground-subtle`,children:s(`certificates.pairDeviceDialog.createsAOneTimeCode`,`Creates a one-time code for a phone you hold. Scan it with the CamStack app on that phone; the phone then stays signed in as the chosen user until you revoke it.`)}),r(H,{label:s(`certificates.pairDeviceDialog.user`,`User`),required:!0,children:r(re,{value:p,onChange:e=>u(e.target.value),options:n.map(e=>({value:e.id,label:e.username}))})}),r(H,{label:s(`certificates.pairDeviceDialog.deviceName`,`Device name`),required:!0,description:s(`certificates.pairDeviceDialog.howThisPhoneIsListed`,`How this phone is listed, e.g. Anna's iPhone.`),children:r(Fe,{value:d,maxLength:mn,onChange:e=>f(e.target.value),placeholder:s(`certificates.pairDeviceDialog.annaSIphone`,`Anna's iPhone`),autoFocus:!0})})]}):r(_n,{enrollUrl:m.enrollUrl,expiresAt:m.expiresAt,hubKnown:m.hubOrigin!==null,onRestart:()=>c.reset()})})}function _n({enrollUrl:t,expiresAt:n,hubKnown:i,onRestart:a}){let{t:o}=K(),s=jt(n,pn(1e3));return r(`div`,{className:`space-y-3`,"data-testid":`pair-issued`,children:e(`div`,{className:`flex flex-col items-center gap-3 sm:flex-row sm:items-start`,children:[r(`div`,{className:s.expired?`opacity-30`:void 0,children:r(be,{value:t,size:hn,alt:o(`certificates.pairDeviceDialog.enrollmentQrCode`,`Enrollment QR code`)})}),e(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[r(`p`,{className:`text-[11px] text-foreground-subtle`,children:o(`certificates.pairDeviceDialog.openTheCamstackAppOn`,`Open the CamStack app on the phone and scan this code. It works once.`)}),r(`div`,{className:`text-sm font-semibold tabular-nums text-foreground`,role:`timer`,"data-testid":`pair-countdown`,children:s.expired?o(`certificates.pairDeviceDialog.expiredCreateANewCode`,`Expired - create a new code`):o(`certificates.pairDeviceDialog.expiresIn`,`Expires in {{label}}`,{label:s.label})}),e(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[r(`code`,{className:`min-w-0 flex-1 select-all break-all font-mono text-[11px] text-foreground`,children:t}),r(he,{value:t,srLabel:`Enrollment link`})]}),!i&&e(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-1.5 text-[11px] text-foreground`,children:[r(_,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`,"aria-hidden":!0}),r(`span`,{children:o(`certificates.pairDeviceDialog.theHubCouldNotName`,`The hub could not name an address for this link, so the app must already know it.`)})]}),s.expired&&r(U,{type:`button`,variant:`outline`,size:`sm`,onClick:a,children:o(`certificates.pairDeviceDialog.newCode`,`New code`)})]})]})})}s();var vn={key:`access.nouns.device`};function yn({pairOpen:t,onPairClose:i}){let{t:o}=K(),s=w(),c=te(),l=W.useUtils(),u=W.deviceCredentials.listDeviceCredentials.useQuery({includeRevoked:!0}),d=ke(),[f,p]=a(null),[m,g]=a(null),_=()=>void l.deviceCredentials.listDeviceCredentials.invalidate(),v=e=>t=>{g(null),p(`${e} failed: ${t.message}`)},b=()=>{g(null),_()},x=W.deviceCredentials.revokeDeviceCredential.useMutation({onSuccess:b,onError:v(`Revoke`)}),S=W.deviceCredentials.deleteDeviceCredential.useMutation({onSuccess:e=>{e.result!==`deleted`&&p(e.result===`live`?`Only a revoked device can be deleted: revoke it first.`:`That device no longer exists.`),b()},onError:v(`Delete`)}),C=W.deviceCredentials.renameDeviceCredential.useMutation({onSuccess:b,onError:v(`Rename`)}),T=ht(vn,e=>x.mutateAsync({id:e}),_),E=T.busy||m!==null,ee=n(()=>(u.data??[]).map(At),[u.data]),re=async e=>{await s({title:o(`certificates.devicesCard.revoke`,`Revoke "{{name}}"?`,{name:e.name}),message:o(`certificates.devicesCard.sDeviceStopsSigningIn`,`{{ownerName}}'s device stops signing in at once and its open sessions end. To use it again it has to be paired anew. This cannot be undone.`,{ownerName:e.ownerName}),confirmLabel:o(`certificates.devicesCard.revoke2`,`Revoke`),variant:`danger`})&&(p(null),g(e.id),x.mutate({id:e.id}))},ie=async e=>{await s({title:o(`certificates.devicesCard.delete`,`Delete "{{name}}"?`,{name:e.name}),message:o(`certificates.devicesCard.isRemovedFromTheList`,`{{name}} is removed from the list. The audit trail keeps the revocation.`,{name:e.name}),confirmLabel:o(`common.delete`,`Delete`),variant:`danger`})&&(p(null),g(e.id),S.mutate({id:e.id}))},O=async e=>{let t=(await c({title:o(`certificates.devicesCard.renameDevice`,`Rename device`),label:o(`certificates.devicesCard.deviceName`,`Device name`),defaultValue:e.name,confirmLabel:o(`certificates.devicesCard.rename`,`Rename`)}))?.trim()??``;t===``||t===e.name||(p(null),g(e.id),C.mutate({id:e.id,deviceName:t}))},k={label:o(`certificates.devicesCard.revoke2`,`Revoke`),icon:ne,isAvailable:yt,onRun:e=>void re(e),busyId:x.isPending?m:null,disabled:E},ae=[{label:o(`certificates.devicesCard.rename`,`Rename`),icon:y,tone:`neutral`,isAvailable:()=>!0,onRun:e=>void O(e),busyId:C.isPending?m:null,disabled:E},{label:o(`common.delete`,`Delete`),icon:h,isAvailable:Et,onRun:e=>void ie(e),busyId:S.isPending?m:null,disabled:E}];return e(q,{id:`devices`,title:o(`certificates.devicesCard.devices`,`Devices`),icon:D,description:o(`certificates.devicesCard.phonesThatStaySignedIn`,`Phones that stay signed in with a certificate instead of a login. Revoking one signs it out at once; it has to be paired again.`),notice:J(f,T.outcome),onDismissNotice:()=>{p(null),T.dismiss()},children:[r(fn,{}),r(Lt,{rows:ee,label:o(`certificates.devicesCard.label`),isLoading:u.isPending,loadError:u.error===null?null:u.error.message||`Request failed`,emptyText:`No devices paired yet.`,expiresNone:`—`,action:k,extraActions:ae,bulk:{revoke:T,noun:vn,isSelectable:yt}}),r(gn,{open:t,users:d.data??[],onClose:i,onPaired:_})]})}var bn=/-----BEGIN CERTIFICATE-----[\s\S]+?-----END CERTIFICATE-----/,xn=/-----BEGIN ((?:RSA |EC |ENCRYPTED )?PRIVATE KEY)-----[\s\S]+?-----END \1-----/,Sn={certificate:`.pem,.crt,.cer`,privateKey:`.pem,.key`,ca:`.pem,.crt,.cer`};function Cn(e,t){if(t.trim()===``)return null;if(e===`privateKey`){let e=xn.exec(t);return e===null?bn.test(t)?G.t(`helpers.pemFile.isCert`):G.t(`helpers.pemFile.notKey`):e[1]===`ENCRYPTED PRIVATE KEY`?G.t(`helpers.pemFile.encrypted`):null}return bn.test(t)?e===`certificate`&&xn.test(t)?G.t(`helpers.pemFile.certHasKey`):null:xn.test(t)?G.t(`helpers.pemFile.isKey`):G.t(`helpers.pemFile.notCert`)}function wn(e){return e.text()}s();function Tn({kind:n,label:i,value:o,onChange:s,rows:c=6}){let{t:l}=K(),u=t(null),[d,f]=a(null),[p,m]=a(null),h=p??Cn(n,o),g=`pem-${n}`,_=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t!==void 0){f(t.name);try{let e=await wn(t);m(null),s(e)}catch(e){m(`Could not read ${t.name}: ${e instanceof Error?e.message:String(e)}`)}}};return e(`div`,{className:`space-y-1`,children:[e(`div`,{className:`flex items-center justify-between gap-2`,children:[r(`label`,{htmlFor:g,className:`text-[11px] text-foreground-subtle`,children:i}),e(`div`,{className:`flex min-w-0 items-center gap-2`,children:[d!==null&&r(`span`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,"data-testid":`${g}-file-name`,children:d}),r(Me,{ref:u,accept:Sn[n],onChange:e=>void _(e),className:`hidden`,"data-testid":`${g}-file`}),e(U,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>u.current?.click(),children:[r(ue,{className:`mr-1 h-3 w-3`}),l(`system.pemField.chooseFile`,`Choose file`)]})]})]}),r(Pe,{id:g,value:o,onChange:e=>{f(null),m(null),s(e.target.value)},rows:c,"aria-invalid":h!==null,className:`w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`}),h!==null&&r(`p`,{className:`text-[11px] text-danger`,role:`alert`,children:h})]})}s();var En=30;function Dn(e){let t=Date.parse(e);return!Number.isNaN(t)&&Date.now()-t<En*864e5}function On(e){if(e===null||e===``)return`—`;let t=e.replace(/:/g,``);return t.length<=16?e:`${t.slice(0,8)}…${t.slice(-8)}`}function kn(){let{t}=K(),n=c(),i=$e(void 0,{refetchInterval:15e3}),o=Qe({onSuccess:()=>void n.invalidateQueries({queryKey:[[`localNetwork`]]})}),s=Xe({onSuccess:()=>void n.invalidateQueries({queryKey:[[`localNetwork`]]})}),l=Ve({onSuccess:()=>void n.invalidateQueries({queryKey:[[`localNetwork`]]})}),u=xe({onSuccess:()=>{m(!1),g(``),v(``),x(``),n.invalidateQueries({queryKey:[[`localNetwork`]]})}}),d=i.data,[p,m]=a(!1),[h,g]=a(``),[_,v]=a(``),[y,x]=a(``),S=()=>{if(!d?.caCertPem)return;let e=new Blob([d.caCertPem],{type:`application/x-pem-file`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`camstack-ca.crt`,n.click(),URL.revokeObjectURL(t)},C=d?.mode===`uploaded`?`Uploaded`:d?.mode===`generated`?`Generated local CA`:`TLS disabled`;return r(ve,{headingId:`local-access-certificate`,title:t(`system.localAccess.certificate`,`Certificate`),icon:b,children:e(`div`,{className:`${f} space-y-3`,children:[i.isError&&r(`p`,{className:`text-xs text-danger`,children:t(`system.localAccess.couldNotReadTlsStatus`,`Could not read TLS status.`)}),d?.reissueError&&r(L,{variant:`warning`,title:t(`system.localAccess.certificateReissue`,`Certificate reissue`),message:d.reissueError}),d?.restartRequired&&r(L,{variant:`warning`,title:t(`system.localAccess.restartRequired`,`Restart required`),message:t(`system.localAccess.theHttpsListenerStillServes`,`The HTTPS listener still serves the previous certificate. Restart the hub to apply it.`)}),d?.caMissing===!0&&r(L,{variant:`warning`,title:t(`system.localAccess.caMissingTitle`,`CA missing - devices cannot trust this hub`),message:t(`system.localAccess.caMissingBody`,"The uploaded certificate was not issued by a public CA and no CA was stored with it, so Download CA has nothing to hand out. Upload the certificate again together with its CA (for mkcert, the rootCA.pem in the folder `mkcert -CAROOT` prints).")}),d?.caReplacedAt!=null&&Dn(d.caReplacedAt)&&r(L,{variant:`warning`,title:t(`system.localAccess.caReplacedTitle`,`The local CA was replaced - re-install it on your devices`),message:t(`system.localAccess.caReplacedBody`,`The previous local CA had no name constraints: if its key ever leaked it could vouch for any website. The hub now uses a CA limited to private addresses and local names. Download it again and trust it on every phone and computer that used the old one (replaced {{when}}).`,{when:new Date(d.caReplacedAt).toLocaleString()})}),e(`dl`,{className:`grid grid-cols-1 gap-2 text-xs sm:grid-cols-2`,children:[e(`div`,{children:[r(`dt`,{className:`text-foreground-subtle`,children:t(`system.localAccess.mode`,`Mode`)}),r(`dd`,{className:`font-medium`,children:C})]}),e(`div`,{children:[r(`dt`,{className:`text-foreground-subtle`,children:t(`system.localAccess.validTo`,`Valid to`)}),r(`dd`,{className:`font-mono`,children:d?.validTo?new Date(d.validTo).toLocaleString():`—`})]}),e(`div`,{children:[r(`dt`,{className:`text-foreground-subtle`,children:t(`system.localAccess.leafSha256`,`Leaf SHA-256`)}),r(`dd`,{className:`font-mono`,title:d?.leafFingerprintSha256??void 0,children:On(d?.leafFingerprintSha256??null)})]}),d?.storedUpload!=null&&e(`div`,{children:[r(`dt`,{className:`text-foreground-subtle`,children:t(`system.localAccess.storedUpload`,`Stored upload`)}),r(`dd`,{className:`font-medium`,children:t(`system.localAccess.storedUploadValue`,`valid to {{validTo}}, {{ca}}`,{validTo:new Date(d.storedUpload.validTo).toLocaleDateString(),ca:d.storedUpload.hasCa?t(`system.localAccess.storedUploadWithCa`,`with its CA`):t(`system.localAccess.storedUploadNoCa`,`no CA`)})})]}),e(`div`,{children:[r(`dt`,{className:`text-foreground-subtle`,children:t(`system.localAccess.caSha256`,`CA SHA-256`)}),r(`dd`,{className:`font-mono`,title:d?.caFingerprintSha256??void 0,children:d?.mode===`uploaded`&&d.caFingerprintSha256===null?r(`span`,{className:`font-sans text-foreground-subtle`,children:t(`system.localAccess.issuerNotIncludedInThe`,`Issuer not included in the upload (not the local CA)`)}):On(d?.caFingerprintSha256??null)})]})]}),d&&d.sans.length>0&&r(`div`,{className:`flex flex-wrap gap-1`,children:d.sans.map(e=>r(`span`,{className:`rounded border border-border bg-surface px-1.5 py-0.5 font-mono text-[10px] text-foreground-subtle`,children:e},e))}),e(`div`,{className:`flex flex-wrap gap-2`,children:[r(Be,{label:t(`system.localAccess.regenerate`,`Regenerate`),title:t(`system.localAccess.issueANewLeaf`,`Issue a new leaf?`),description:t(`system.localAccess.issuesANewLeafUnder`,`Issues a new leaf under the current local CA. Clients that trust the CA keep working. The HTTPS listener reloads.`),confirmLabel:t(`system.localAccess.regenerate`,`Regenerate`),disabled:d?.mode===`uploaded`||o.isPending,action:()=>o.mutateAsync({})}),r(U,{size:`sm`,variant:`outline`,onClick:()=>m(e=>!e),children:t(`system.localAccess.upload`,`Upload`)}),d?.caCertPem&&r(U,{size:`sm`,variant:`outline`,onClick:S,children:t(`system.localAccess.downloadCa`,`Download CA`)}),d?.mode===`uploaded`&&r(Be,{label:t(`system.localAccess.revertToGenerated`,`Revert to generated`),title:t(`system.localAccess.revertTitle`,`Switch back to the generated certificate?`),description:t(`system.localAccess.keepsTheUploadedPair`,`Returns to the generated local CA. The uploaded certificate and its CA stay stored here; you can select them again.`),confirmLabel:t(`system.localAccess.revert`,`Revert`),disabled:s.isPending,action:()=>s.mutateAsync({})}),d?.mode===`generated`&&d.storedUpload!=null&&r(Be,{label:t(`system.localAccess.useUploaded`,`Use uploaded certificate`),title:t(`system.localAccess.useUploadedTitle`,`Serve the stored upload again?`),description:t(`system.localAccess.useUploadedDescription`,`The stored uploaded certificate replaces the generated one on the HTTPS listener. The generated certificate stays stored.`),confirmLabel:t(`system.localAccess.useUploaded`,`Use uploaded certificate`),disabled:l.isPending,action:()=>l.mutateAsync(void 0)})]}),p&&e(`div`,{className:`space-y-2 border-t border-border pt-3`,children:[r(Tn,{kind:`certificate`,label:t(`system.localAccess.certificateOrFullChainPem`,`Certificate or full chain (PEM)`),value:h,onChange:g}),r(Tn,{kind:`privateKey`,label:t(`system.localAccess.privateKeyPem`,`Private key (PEM)`),value:_,onChange:v}),r(Tn,{kind:`ca`,label:t(`system.localAccess.caPemRequired`,`CA (PEM) - required unless the certificate comes from a public CA`),value:y,onChange:x,rows:4}),r(U,{size:`sm`,disabled:!h.trim()||!_.trim()||Cn(`certificate`,h)!==null||Cn(`privateKey`,_)!==null||Cn(`ca`,y)!==null||u.isPending,onClick:()=>u.mutate({certPem:h,keyPem:_,...y.trim()?{caPem:y}:{}}),children:t(`system.localAccess.saveCertificate`,`Save certificate`)}),u.isError&&r(`p`,{className:`text-xs text-danger`,children:u.error instanceof Error?u.error.message:t(`system.localAccess.uploadFailed`,`Upload failed`)})]})]})})}var An={ok:`text-foreground-subtle`,soon:`text-warning`,expired:`text-danger`,unknown:`text-foreground-subtle`};function jn(e){let t=e.find(e=>e.isHub);return t?.https.kind===`served`?t.https.status.caFingerprintSha256:null}function Mn({https:t,mesh:n,now:i}){let{t:a}=K(),o=$e().data?.caCertPem??``,s=()=>{if(o===``)return;let e=URL.createObjectURL(new Blob([o],{type:`application/x-pem-file`})),t=document.createElement(`a`);t.href=e,t.download=`camstack-ca.crt`,t.click(),URL.revokeObjectURL(e)},c=n?.ca,l=c?.state===`ready`?Date.parse(c.validTo):null,u=n?.listener;return e(`div`,{className:`space-y-1`,"data-testid":`ca-strip`,children:[r(B,{label:a(`certificates.caStrip.localHttpsCaSha256`,`Local HTTPS CA (SHA-256)`),valueClassName:`font-mono`,children:e(`span`,{className:`flex flex-wrap items-center gap-2`,children:[jn(t)??`—`,o!==``&&e(U,{type:`button`,variant:`ghost`,size:`sm`,onClick:s,children:[r(x,{className:`h-3 w-3`,"aria-hidden":!0}),a(`certificates.caStrip.downloadCa`,`Download CA`)]})]})}),r(B,{label:a(`certificates.caStrip.clusterCaSha256`,`Cluster CA (SHA-256)`),valueClassName:`font-mono`,children:c===void 0?`—`:c.state===`ready`?c.fingerprintSha256:r(`span`,{className:`text-danger`,children:a(`certificates.caStrip.unavailable`,{reason:c.reason})})}),c?.state===`ready`&&e(B,{label:a(`certificates.caStrip.clusterCaValidUntil`,`Cluster CA valid until`),children:[c.validTo,l!==null&&!Number.isNaN(l)&&e(`span`,{className:`ml-2 text-[10px] ${An[Ft(l,i)]}`,children:[`(`,xt(l,i),`)`]})]}),u!==void 0&&e(B,{label:a(`certificates.caStrip.nodeListener`,`Node listener`),children:[u.state===`open`&&r(P,{variant:`success`,children:a(`certificates.caStrip.open`,`Open`)}),u.state===`not-started`&&r(P,{variant:`default`,children:a(`certificates.caStrip.notStarted`,`Not started`)}),u.state===`closed`&&e(`span`,{className:`text-danger`,children:[a(`certificates.caStrip.closedSince`,{when:St(u.since)}),` `,u.reason]})]}),n!==void 0&&!n.registryAvailable&&e(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-1.5 text-[11px] text-foreground`,children:[r(_,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`,"aria-hidden":!0}),r(`span`,{children:a(`certificates.caStrip.theCertificateRegistryIsNot`,`The certificate registry is not up, so the node list below is incomplete.`)})]})]})}function Nn(e,t){let n=new Set;for(let t of e)n.add(t.nodeId);for(let e of t?.nodes??[])n.add(e.nodeId);return[...n].map(n=>{let r=e.find(e=>e.nodeId===n)??null,i=t?.nodes.find(e=>e.nodeId===n)??null;return{nodeId:n,isHub:r?.isHub??n===`hub`,online:r?.online??i?.online??!1,https:r,mesh:i}}).toSorted((e,t)=>Number(t.isHub)-Number(e.isHub)||e.nodeId.localeCompare(t.nodeId))}function Pn(e){return e.isHub?G.t(`helpers.nodesModel.hubReissued`):e.mesh===null?G.t(`helpers.nodesModel.noCertRecorded`):e.online?null:G.t(`helpers.certificateModel.nodeOffline`)}function Fn(e){return e.isHub||e.mesh===null?Pn(e):null}var In={ok:`text-foreground-subtle`,soon:`text-warning`,expired:`text-danger`,unknown:`text-foreground-subtle`},Ln={enroll:`Issued at enrollment`,renewal:`Issued by a renewal`,boot:`Issued at boot`,pairing:`Issued at pairing`,observed:`Observed on its connection`},Rn={uploaded:`Uploaded`,generated:`Generated`,disabled:`Disabled`};function zn(e){let t=e.https?.https;return t?.kind===`served`?Nt(t.status.validTo):null}function Bn({ms:t,now:n}){return t===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):e(`div`,{children:[r(`div`,{children:St(t)}),r(`div`,{className:`text-[10px] ${In[Ft(t,n)]}`,children:xt(t,n)})]})}function Vn({row:t}){let{t:n}=K(),i=t.https?.https;return i===void 0?r(`span`,{className:`text-foreground-subtle`,children:`—`}):i.kind===`served`?e(`div`,{title:i.status.leafFingerprintSha256??``,children:[r(P,{variant:`success`,className:`text-[10px]`,children:n(`certificates.nodesColumns.served`,`Served`)}),r(`span`,{className:`ml-1.5 text-[10px] text-foreground-subtle`,children:Rn[i.status.mode]}),r(`div`,{className:`mt-1 font-mono text-[10px] text-foreground-subtle`,children:Mt(i.status.leafFingerprintSha256)}),i.status.sans.length>0&&r(`div`,{className:`mt-0.5 max-w-[14rem] truncate font-mono text-[10px] text-foreground-subtle`,title:i.status.sans.join(`, `),children:i.status.sans.join(`, `)})]}):e(`div`,{className:`max-w-[16rem]`,children:[r(P,{variant:i.kind===`unreadable`?`danger`:`warning`,className:`text-[10px]`,children:i.kind===`unreadable`?n(`certificates.nodesColumns.unreadable`,`Unreadable`):n(`certificates.nodesColumns.notServed`,`Not served`)}),r(`div`,{className:`mt-1 whitespace-normal text-[10px] text-foreground-subtle`,children:i.reason})]})}function Hn({row:t}){let{t:n}=K(),i=t.mesh?.current??null;if(i===null)return r(`span`,{className:`text-foreground-subtle`,children:n(`certificates.nodesColumns.noneRecorded`,`None recorded`)});let a=t.mesh?.history.length??0;return e(`div`,{children:[r(`div`,{className:`font-mono text-[11px]`,title:i.serial,children:kt(i.serial)}),r(`div`,{className:`font-mono text-[10px] text-foreground-subtle`,title:i.fingerprintSha256,children:Mt(i.fingerprintSha256)}),e(`div`,{className:`text-[10px] text-foreground-subtle`,children:[Ln[i.issuedVia],a>0?` · ${n(`certificates.nodesColumns.earlier`,{count:a})}`:``]})]})}function Un({row:e}){let{t}=K(),n=e.mesh?.presentingCurrent??null;return n===null?r(`span`,{className:`text-foreground-subtle`,children:e.online?`—`:t(`certificates.nodesColumns.offline`,`Offline`)}):n?r(P,{variant:`success`,className:`text-[10px]`,children:t(`common.yes`,`Yes`)}):r(P,{variant:`warning`,className:`text-[10px]`,children:t(`certificates.nodesColumns.noPresentsAnother`,`No - presents another`)})}function Wn(t){let n=t.icon;return e(U,{type:`button`,variant:`ghost`,size:`sm`,className:t.danger?`text-danger hover:bg-danger/10`:void 0,disabled:t.reason!==null||t.busy,title:t.reason??void 0,"aria-label":t.ariaLabel,onClick:t.onClick,children:[t.spinning?r(k,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):r(n,{className:`h-3 w-3`,"aria-hidden":!0}),t.label]})}function Gn({reasons:t}){let{t:n}=K();return e(Ne,{className:`inline-block`,children:[r(Ye,{children:r(`span`,{className:`cursor-help text-[11px] text-foreground-subtle`,"data-testid":`hub-managed-note`,children:n(`certificates.nodesColumns.managedByTheHub`,`Managed by the hub`)})}),r(He,{children:r(`ul`,{className:`max-w-xs space-y-1 whitespace-normal text-left text-[11px]`,children:t.map(e=>r(`li`,{children:e},e))})})]})}function Kn({row:t,o:n}){let{t:i}=K(),a=t.https===null?`No HTTPS inventory for this node.`:Ct(t.https).reason,o=Pn(t),s=Fn(t),c=e=>n.running?.nodeId===t.nodeId&&n.running.action===e,l=e=>!t.isHub||e===null,u=[a,o,s].filter((e,t,n)=>e!==null&&n.indexOf(e)===t);return e(`div`,{className:`flex w-44 flex-col items-end gap-1`,children:[e(`div`,{className:`flex flex-col items-end gap-0.5`,children:[l(a)&&r(Wn,{label:i(`certificates.nodesColumns.renewHttps`,`Renew HTTPS`),ariaLabel:i(`certificates.nodesColumns.renewTheCertificateOn`,`Renew the certificate on {{nodeId}}`,{nodeId:t.nodeId}),icon:p,reason:a,busy:n.busy,spinning:c(`renew-https`),danger:!1,onClick:()=>n.onRenewHttps(t)}),l(o)&&r(Wn,{label:c(`renew-identity`)?i(`certificates.nodesColumns.renewing`,`Renewing…`):i(`certificates.nodesColumns.renewIdentity`,`Renew identity`),ariaLabel:i(`certificates.nodesColumns.renewTheClusterCertificateOf`,`Renew the cluster certificate of {{nodeId}}`,{nodeId:t.nodeId}),icon:p,reason:o,busy:n.busy,spinning:c(`renew-identity`),danger:!1,onClick:()=>n.onRenewIdentity(t)}),l(s)&&r(Wn,{label:i(`certificates.nodesColumns.revokeIdentity`,`Revoke identity`),ariaLabel:i(`certificates.nodesColumns.revokeTheClusterCertificateOf`,`Revoke the cluster certificate of {{nodeId}}`,{nodeId:t.nodeId}),icon:ne,reason:s,busy:n.busy,spinning:c(`revoke-identity`),danger:!0,onClick:()=>n.onRevokeIdentity(t)})]}),t.isHub&&u.length>0&&r(Gn,{reasons:u}),!t.isHub&&a!==null&&t.https!==null&&r(`div`,{className:`w-full whitespace-normal text-right text-[10px] text-foreground-subtle`,"data-testid":`renew-reason-${t.nodeId}`,children:a}),!t.isHub&&o!==null&&r(`div`,{className:`w-full whitespace-normal text-right text-[10px] text-foreground-subtle`,"data-testid":`mesh-reason-${t.nodeId}`,children:o})]})}function qn(t){return[{key:`node`,header:G.t(`certificates.nodesColumns.node`,`Node`),sortValue:e=>e.isHub?``:e.nodeId.toLowerCase(),render:t=>e(`div`,{className:`flex items-center gap-1.5`,children:[r(`span`,{className:`font-medium text-foreground`,children:t.nodeId}),t.nodeId===`hub`&&r(P,{variant:`info`,className:`text-[10px]`,children:G.t(`common.hubWord`)}),!t.online&&r(P,{variant:`default`,className:`text-[10px]`,children:G.t(`common.offline`)})]})},{key:`https-state`,header:`HTTPS`,notSortableReason:`A state with a reason has no single order.`,render:e=>r(Vn,{row:e})},{key:`https-expires`,header:G.t(`certificates.nodesColumns.httpsExpires`,`HTTPS expires`),sortValue:e=>zn(e),render:e=>r(Bn,{ms:zn(e),now:t.now})},{key:`identity`,header:G.t(`certificates.nodesColumns.identity`,`Identity`),sortValue:e=>e.mesh?.current?.serial??null,render:e=>r(Hn,{row:e})},{key:`identity-expires`,header:G.t(`certificates.nodesColumns.identityExpires`,`Identity expires`),sortValue:e=>e.mesh?.current?.notAfter??null,render:e=>r(Bn,{ms:e.mesh?.current?.notAfter??null,now:t.now})},{key:`presenting`,header:G.t(`certificates.nodesColumns.inUse`,`In use`),notSortableReason:`Offline nodes have no answer to order by.`,render:e=>r(Un,{row:e})},{key:`actions`,header:G.t(`certificates.nodesColumns.actions`,`Actions`),align:`right`,notSortableReason:`Actions have no order.`,render:e=>r(Kn,{row:e,o:t})}]}s();function Jn(){let{t}=K(),i=w(),o=W.useUtils(),s=pn(6e4),c=W.certificates.listHttpsCertificates.useQuery(),l=W.certificates.getMeshCertificates.useQuery(),[u,f]=a(null),[p,m]=a(null),[h,g]=a(null),_=()=>{g(null),o.certificates.listHttpsCertificates.invalidate(),o.certificates.getMeshCertificates.invalidate()},v=e=>(t,n)=>{g(null),f(`${n.nodeId}: ${e} - ${t.message}`)},y=W.certificates.renewHttpsOnNode.useMutation({onSuccess:(e,n)=>{m({tone:`success`,message:e.restartRequired?t(`certificates.nodesCard.newCertificateIssuedRestartThe`,`{{nodeId}}: new certificate issued. Restart the node to serve it.`,{nodeId:n.nodeId}):t(`certificates.nodesCard.newCertificateIssuedAndServed`,`{{nodeId}}: new certificate issued and served.`,{nodeId:n.nodeId})}),_()},onError:v(`renewal failed`)}),b=W.certificates.renewMeshOnNode.useMutation({onSuccess:e=>{m(Ot(e)),_()},onError:v(`renewal could not start`)}),x=W.certificates.revokeMeshOnNode.useMutation({onSuccess:e=>{m({tone:`success`,message:`${e.nodeId}: ${e.next}`}),_()},onError:v(`revoke failed`)}),S=y.isPending||b.isPending||x.isPending,C=(e,t)=>{f(null),m(null),g({nodeId:e,action:t})},T=async e=>{await i({title:t(`certificates.nodesCard.renewHttpsOn`,`Renew HTTPS on "{{nodeId}}"?`,{nodeId:e.nodeId}),message:e.isHub?t(`certificates.nodesCard.aNewCertificateIsIssued`,`A new certificate is issued from the local CA. Clients that trust the CA keep working.`):t(`certificates.nodesCard.theNodeMakesANew`,`The node makes a new key, the hub signs it and the node switches over without a restart. It keeps serving what it had if anything fails.`),confirmLabel:t(`certificates.nodesCard.renew`,`Renew`)})&&(C(e.nodeId,`renew-https`),y.mutate({nodeId:e.nodeId}))},E=e=>{C(e.nodeId,`renew-identity`),b.mutate({nodeId:e.nodeId})},ee=async e=>{await i({title:t(`certificates.nodesCard.revokeTheIdentityOf`,`Revoke the identity of "{{nodeId}}"?`,{nodeId:e.nodeId}),message:t(`certificates.nodesCard.isDisconnectedAtOnceAnd`,`{{nodeId}} is disconnected at once and can no longer connect. To bring it back it must be paired again from System → Cluster → Agents. It stays in the node list until you forget it on the Cluster page. This cannot be undone.`,{nodeId:e.nodeId}),confirmLabel:t(`certificates.nodesCard.revokeAndDisconnect`,`Revoke and disconnect`),variant:`danger`})&&(C(e.nodeId,`revoke-identity`),x.mutate({nodeId:e.nodeId}))},te=qn({now:s,busy:S,running:h,onRenewHttps:e=>void T(e),onRenewIdentity:E,onRevokeIdentity:e=>void ee(e)}),ne=n(()=>Nn(c.data??[],l.data),[c.data,l.data]),D=l.data?.registryAvailable??!0;return r(q,{id:`nodes`,title:t(`certificates.nodesCard.nodes`,`Nodes`),icon:d,description:t(`certificates.nodesCard.eachNodeHoldsTwoCertificates`,`Each node holds two certificates: one it serves over HTTPS, one that proves its identity to the hub. Renewing replaces a certificate without a gap; revoking an identity cuts the node off until it re-joins.`),notice:J(u,p),onDismissNotice:()=>{f(null),m(null)},children:r(un,{isPending:c.isPending||l.isPending,error:c.error??l.error,what:`node certificates`,onRetry:()=>{c.refetch(),l.refetch()},children:e(`div`,{className:`space-y-3`,children:[r(Mn,{https:c.data??[],mesh:l.data,now:s}),r(Ce,{columns:te,rows:ne,rowKey:e=>e.nodeId,minWidthPx:960,maxBodyHeight:et,defaultSort:{columnKey:`node`,dir:`asc`},emptyMessage:D?t(`certificates.nodesCard.noNodesReported`,`No nodes reported.`):t(`certificates.nodesCard.theCertificateRegistryIsNot`,`The certificate registry is not available yet, so nodes cannot be listed.`)})]})})})}function Yn({pairOpen:t,onPairClose:n}){return e(`div`,{className:`space-y-4`,"data-testid":`certificates-page`,children:[r(yn,{pairOpen:t,onPairClose:n}),r(dn,{}),r(kn,{}),r(Jn,{})]})}function Xn({userId:t,username:n,onClose:i}){let{t:a}=K(),o=w(),s=W.useUtils(),c=Ke({userId:t}),l=W.auth.listLoginMethods.useQuery(),u=me({onSuccess:()=>void s.userManagement.listExternalIdentities.invalidate()}),d=new Map((l.data??[]).flatMap(e=>e.kind===`redirect`?[[e.id,e.label]]:[])),f=c.data??[],p=async(e,r)=>{await o({title:a(`users.externalIdentitiesModal.removeSignInLink`,`Remove sign-in link`),message:a(`users.externalIdentitiesModal.willNoLongerBeAble`,`"{{username}}" will no longer be able to sign in with this {{label}} account.`,{username:n,label:r}),confirmLabel:a(`common.remove`,`Remove`),variant:`danger`})&&u.mutate({userId:t,provider:e.provider,subject:e.subject})};return r(V,{open:!0,onOpenChange:e=>!e&&i(),children:e(I,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,"data-testid":`external-identities-modal`,children:[r(tt,{children:e(N,{className:`flex items-center gap-2`,children:[r(O,{className:`h-4 w-4 text-primary`}),e(`span`,{children:[a(`users.externalIdentitiesModal.linkedSignInAccounts`,`Linked sign-in accounts`),e(`span`,{className:`mt-0.5 block text-[11px] font-normal text-foreground-subtle`,children:[a(`users.externalIdentitiesModal.user`,`User:`),` `,r(`span`,{className:`font-mono`,children:n})]})]})]})}),r(F,{className:`space-y-3`,children:c.isLoading?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(k,{className:`h-3.5 w-3.5 animate-spin`}),a(`common.loading`,`Loading…`)]}):f.length===0?r(`p`,{className:`text-xs text-foreground-subtle`,children:a(`users.externalIdentitiesModal.noLinkedAccountsOnlyThe`,`No linked accounts. Only the user can link one, from their own profile page.`)}):r(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:f.map(t=>{let n=d.get(t.provider),i=n??t.provider;return e(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[e(`div`,{className:`flex-1 min-w-0`,children:[e(`div`,{className:`font-medium text-foreground truncate`,children:[i,n===void 0&&r(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:a(`users.externalIdentitiesModal.providerUnavailable`,`provider unavailable`)})]}),e(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:[t.label??t.subject,` ·`,` `,new Date(t.linkedAt).toLocaleDateString()]})]}),e(U,{variant:`unstyled`,onClick:()=>void p(t,i),disabled:u.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[r(pe,{className:`h-3 w-3`}),a(`common.remove`,`Remove`)]})]},`${t.provider}|${t.subject}`)})})}),r(we,{children:r(U,{onClick:i,variant:`secondary`,children:a(`common.close`,`Close`)})})]})})}function Zn({userId:t,username:n,onClose:i}){let{t:a}=K(),o=c(),s=w(),u=R({userId:t}),d=u.data,f=()=>o.invalidateQueries({queryKey:[[`userManagement`,`getTotpStatus`]]}),p=_e({onSuccess:()=>{f(),i()}}),m=u.isLoading?`loading`:d?.enabled?`enrolled`:`not_enrolled`;return r(V,{open:!0,onOpenChange:e=>!e&&i(),children:e(I,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(tt,{children:e(N,{className:`flex items-center gap-2`,children:[r(D,{className:`h-4 w-4 text-primary`}),e(`span`,{children:[a(`users.totpModal.twoFactorAuthentication`,`Two-factor authentication`),e(`span`,{className:`mt-0.5 block text-[11px] font-normal text-foreground-subtle`,children:[a(`users.totpModal.user`,`User:`),` `,r(`span`,{className:`font-mono`,children:n})]})]})]})}),e(F,{className:`space-y-4`,children:[m===`loading`&&e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(k,{className:`h-3.5 w-3.5 animate-spin`}),a(`users.totpModal.checkingStatus`,`Checking status…`)]}),m===`not_enrolled`&&e(`div`,{className:`rounded-md border border-border bg-surface-hover/30 px-3 py-2.5 flex items-start gap-2.5 text-xs text-foreground-subtle`,children:[r(ee,{className:`h-4 w-4 mt-0.5 shrink-0`}),e(`div`,{children:[r(`div`,{className:`font-medium text-foreground`,children:a(`users.totpModal.2faNotEnrolled`,`2FA not enrolled`)}),r(`p`,{className:`mt-0.5`,children:a(`users.totpModal.onlyTheUserThemselvesCan`,`Only the user themselves can enable 2FA, from their own profile page.`)})]})]}),m===`enrolled`&&d&&e(l,{children:[e(`div`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2.5 flex items-start gap-2.5`,children:[r(E,{className:`h-4 w-4 mt-0.5 text-emerald-500 shrink-0`}),e(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[r(`div`,{className:`font-medium`,children:a(`users.totpModal.2faIsActive`,`2FA is active`)}),r(`div`,{className:`text-foreground-subtle`,children:a(`common.enrolledOn`,{when:d.confirmedAt?new Date(d.confirmedAt).toLocaleString():`—`})})]})]}),r(`div`,{className:`text-[11px] text-foreground-subtle`,children:a(`users.totpModal.removingHereClearsTheServer`,`Removing here clears the server-side secret. Use this only when the user has lost access — they'll have to re-enroll from their profile page afterwards.`)}),e(`div`,{className:`flex justify-end gap-2`,children:[r(U,{onClick:i,variant:`secondary`,children:a(`common.close`,`Close`)}),e(U,{variant:`unstyled`,onClick:async()=>{await s({title:a(`users.totpModal.remove2fa`,`Remove 2FA`),message:a(`users.totpModal.removeTwoFactorAuthenticationFor`,`Remove two-factor authentication for "{{username}}"? They'll be able to log in with just their password until they re-enroll from their own profile page.`,{username:n}),confirmLabel:a(`common.remove`,`Remove`),variant:`danger`})&&p.mutate({userId:t})},disabled:p.isPending,className:`rounded bg-danger px-3 py-1.5 text-xs font-medium text-white hover:bg-danger/90 disabled:opacity-50 inline-flex items-center gap-1`,children:[p.isPending?r(k,{className:`h-3 w-3 animate-spin`}):r(C,{className:`h-3 w-3`}),a(`users.totpModal.remove2fa`,`Remove 2FA`)]})]})]})]})]})})}s();function Qn({userId:t,username:n,onClose:i}){let{t:o}=K(),{user:s,logout:c}=it(),l=s?.id===t,u=w(),d=W.useUtils(),f=W.auth.listSessions.useQuery({userId:t}),[p,m]=a(null),h=W.auth.revokeSessions.useMutation({onSuccess:(e,t)=>{if(l&&`userId`in t){c();return}d.auth.listSessions.invalidate()},onError:e=>m(`Sign out failed: ${e.message}`)}),g=async e=>{await u({title:o(`users.userSessionsModal.signOutThisSession`,`Sign out this session`),message:o(`users.userSessionsModal.onWillHaveToSign`,`"{{username}}" on {{label}} will have to sign in again.`,{username:n,label:vt(e.client).label}),confirmLabel:o(`users.userSessionsModal.signOut`,`Sign out`),variant:`danger`})&&(m(null),h.mutate({id:e.id}))},_=async()=>{await u({title:o(`users.userSessionsModal.signOutEverywhere`,`Sign out everywhere`),message:l?o(`users.userSessionsModal.everySessionOfYourOwn`,`Every session of your own account ends, this browser included: you will be signed out here too.`):o(`users.userSessionsModal.everySessionOfEndsAt`,`Every session of "{{username}}" ends at once; each device has to sign in again.`,{username:n}),confirmLabel:o(`users.userSessionsModal.signOutEverywhere`,`Sign out everywhere`),variant:`danger`})&&(m(null),h.mutate({userId:t}))},v=h.isPending&&h.variables!==void 0&&`id`in h.variables?h.variables.id:null;return r(V,{open:!0,onOpenChange:e=>!e&&i(),children:e(I,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,"data-testid":`user-sessions-modal`,children:[r(tt,{children:e(N,{className:`flex items-center gap-2`,children:[r(fe,{className:`h-4 w-4 text-primary`}),e(`span`,{children:[o(`users.userSessionsModal.activeSessions`,`Active sessions`),e(`span`,{className:`mt-0.5 block text-[11px] font-normal text-foreground-subtle`,children:[o(`users.userSessionsModal.user`,`User:`),` `,r(`span`,{className:`font-mono`,children:n})]})]})]})}),e(F,{className:`space-y-3`,children:[p!==null&&r(`div`,{className:`text-[11px] text-danger`,children:p}),r(Pt,{sessions:f.data??[],isLoading:f.isLoading,loadError:f.isError?f.error?.message??`Request failed`:null,emptyText:`No active sessions.`,onRevoke:e=>void g(e),revokingId:v})]}),e(we,{className:`justify-between`,children:[e(U,{variant:`unstyled`,onClick:()=>void _(),disabled:h.isPending||(f.data??[]).length===0,className:`inline-flex items-center gap-1.5 rounded border border-danger/40 px-2.5 py-1 text-[11px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,children:[h.isPending&&v===null?r(k,{className:`h-3 w-3 animate-spin`}):r(j,{className:`h-3 w-3`}),o(`users.userSessionsModal.signOutEverywhere`,`Sign out everywhere`)]}),r(U,{onClick:i,variant:`secondary`,children:o(`common.close`,`Close`)})]})]})})}function $n({scopes:t,invalidReason:n}){let{t:i}=K(),a=T(),s=o({queryKey:[`auth`,`previewScope`,t,!1],enabled:n===null,queryFn:()=>a.trpcClient.auth.previewScope.query({scopes:[...t],isAdmin:!1})}),{data:c}=z({projection:`slim`}),l=c?.length??null;if(n!==null)return e(`p`,{className:`flex items-center gap-1.5 text-[11px] text-warning`,"data-testid":`role-preview`,children:[r(S,{className:`h-3 w-3 shrink-0`}),n]});if(s.isLoading)return e(`p`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,"data-testid":`role-preview`,children:[r(k,{className:`h-3 w-3 shrink-0 animate-spin`}),i(`users.rolePreview.resolving`)]});if(s.isError||!s.data)return r(`p`,{className:`text-[11px] text-danger`,"data-testid":`role-preview`,children:i(`users.rolePreview.couldNotResolve`)});let d=s.data.viewableDeviceCount,f=s.data.device.view.all?i(`users.rolePreview.everyDevice`,{count:d}):l===null?i(`users.rolePreview.devicesVisible`,{count:d}):i(`users.rolePreview.devicesVisibleOf`,{count:d,total:l});return e(`p`,{className:`flex items-center gap-1.5 text-[11px] ${d===0?`text-warning`:`text-foreground`}`,"data-testid":`role-preview`,children:[d===0?r(S,{className:`h-3 w-3 shrink-0`}):r(u,{className:`h-3 w-3 shrink-0 text-foreground-subtle`}),d===0?i(`users.rolePreview.noDevice`):f]})}function er(e){let t=A(e.scopes??[]);if(t===null)return{role:e.isAdmin?`admin`:`viewer`,mode:`except`,pickedIds:[],viewer:se,unconfigured:!e.isAdmin};let n=sr(t);return{role:e.isAdmin?`admin`:`viewer`,mode:n.mode,pickedIds:n.pickedIds,viewer:cr(n.mode,n.pickedIds,t.features),unconfigured:!1}}function tr(e,t){return{...e,role:t}}function nr(e,t){return{...e,mode:t,viewer:cr(t,e.pickedIds,e.viewer.features)}}function rr(e,t){let n=lr(t);return{...e,pickedIds:n,viewer:cr(e.mode,n,e.viewer.features)}}function ir(e,t,n){let r=e.viewer.features.filter(e=>e!==t),i=n?[...r,t]:r;return{...e,viewer:cr(e.mode,e.pickedIds,i)}}function ar(e){return e.role===`viewer`&&e.mode===`only`&&e.pickedIds.length===0?`no-allowed-device`:null}function or(e){return ar(e)===null?e.role===`admin`?{isAdmin:!0,scopes:[]}:{isAdmin:!1,scopes:[e.viewer]}:null}function sr(e){if(e.allow===`*`)return{mode:`except`,pickedIds:e.block};let t=new Set(e.block);return{mode:`only`,pickedIds:e.allow.filter(e=>!t.has(e))}}function cr(e,t,n){let r=lr(t);return e===`except`?{type:`viewer`,allow:`*`,block:r,features:[...n]}:{type:`viewer`,allow:r,block:[],features:[...n]}}function lr(e){return[...new Set(e)]}s();var ur=`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`;function dr(e,t){return e?`failed`:t===void 0?`pending`:`answered`}function fr(e){let t=[];for(let n of e)n.parentDeviceId===null&&t.push({id:n.id,name:n.name,type:String(n.type),...n.location===null?{}:{location:n.location}});return t}function pr({user:t,isSelf:i,onClose:o,onSubmit:s,submitting:c,error:u}){let{t:d}=K(),[f,p]=a(n(()=>er(t),[t])),m=z({projection:`slim`}),h=m.data,g=dr(m.isError,h),_=n(()=>fr(h??[]),[h]),v=n(()=>({state:g,devices:g===`answered`?(h??[]).map(e=>({id:e.id,name:e.name})):void 0}),[g,h]),y=ar(f),b=or(f),x=y===`no-allowed-device`?d(`users.userAccessModal.pickAllowedDevice`):null,S=e=>{p(tr(f,e))},C=[{value:`except`,label:d(`users.userAccessModal.modeExcept`)},{value:`only`,label:d(`users.userAccessModal.modeOnly`)}];return r(V,{open:!0,onOpenChange:e=>!e&&o(),children:e(I,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-2xl`,children:[r(tt,{children:r(N,{children:d(`users.userAccessModal.title`,{name:t.username})})}),e(F,{className:`space-y-4`,children:[f.unconfigured&&f.role===`viewer`&&r(L,{variant:`warning`,title:d(`users.userAccessModal.noAccessYet`),message:d(`users.userAccessModal.noAccessYetDetail`,{name:t.username})}),e(`section`,{className:`space-y-2`,children:[r(`h3`,{className:ur,children:d(`users.userAccessModal.role`)}),e(`div`,{role:`radiogroup`,"aria-label":d(`users.userAccessModal.role`),className:`grid gap-1.5 sm:grid-cols-2`,children:[r(mr,{name:`admin`,checked:f.role===`admin`,label:d(`users.userAccessModal.admin`),description:d(`users.userAccessModal.adminDescription`),onPick:()=>S(`admin`)}),r(mr,{name:`viewer`,checked:f.role===`viewer`,disabled:i,label:d(`users.userAccessModal.viewer`),description:d(i?`users.userAccessModal.cannotDemoteSelf`:`users.userAccessModal.viewerDescription`),onPick:()=>S(`viewer`)})]})]}),f.role===`viewer`&&e(l,{children:[e(`section`,{className:`space-y-3`,children:[r(`h3`,{className:ur,children:d(`users.userAccessModal.devices`)}),r(Re,{label:d(`users.userAccessModal.whichDevices`),value:f.mode,options:C,onChange:e=>p(nr(f,e))}),r(De,{devices:_,listState:g,fleet:v,value:[...f.pickedIds],onChange:e=>p(rr(f,e)),emptyMeansAll:f.mode===`except`,noun:`device`,testId:`viewer-device-picker`}),r($n,{scopes:b?.scopes??[],invalidReason:x})]}),e(`section`,{className:`space-y-2`,children:[r(`h3`,{className:ur,children:d(`users.userAccessModal.features`)}),r(`div`,{className:`space-y-1`,children:oe.map(t=>e(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md p-1.5 hover:bg-surface-hover`,children:[r(Ue,{className:`mt-0.5`,checked:f.viewer.features.includes(t.id),onChange:e=>p(ir(f,t.id,e.target.checked))}),e(`span`,{className:`min-w-0`,children:[r(`span`,{className:`block text-[12px] font-medium text-foreground`,children:d(`users.viewerFeatures.${t.id}.label`,t.label)}),r(`span`,{className:`block text-[10px] text-foreground-subtle`,children:d(`users.viewerFeatures.${t.id}.description`,t.description)})]})]},t.id))})]})]}),u!==null&&r(L,{message:u})]}),e(we,{children:[r(U,{variant:`outline`,size:`sm`,onClick:o,children:d(`common.cancel`,`Cancel`)}),r(U,{size:`sm`,onClick:()=>b!==null&&s(b),disabled:c||b===null,children:c?r(k,{className:`h-3 w-3 animate-spin`}):d(`users.userAccessModal.saveAccess`)})]})]})})}function mr({name:t,checked:n,disabled:i=!1,label:a,description:o,onPick:s}){return e(`label`,{className:`flex items-start gap-2 rounded-lg border p-2.5 transition-colors ${n?`border-primary bg-primary/5`:`border-border hover:bg-surface-hover`} ${i?`cursor-not-allowed opacity-60`:`cursor-pointer`}`,children:[r(Ge,{name:`user-role`,value:t,checked:n,disabled:i,onChange:s,className:`mt-0.5`}),e(`span`,{className:`min-w-0`,children:[r(`span`,{className:`block text-[12px] font-medium text-foreground`,children:a}),r(`span`,{className:`block text-[10px] text-foreground-subtle`,children:o})]})]})}s();var $=8;function hr(){return{username:``,password:``,isAdmin:!1}}function gr(e){return{id:e.id,username:e.username,password:``,isAdmin:e.isAdmin}}function _r(e){return e instanceof Error?e.message:G.t(`admin.system.users.genericError`)}function vr(){let{t}=K(),n=c(),{user:o}=it(),{state:s,openNew:u,openEdit:d,close:f}=Ze(),[p,g]=a(null),[_,b]=a(null),[x,S]=a(!1),{data:C,isLoading:T,isError:E,error:ee,refetch:ne}=ke(),re=w(),ie=te(),A=()=>n.invalidateQueries({queryKey:[[`userManagement`,`listUsers`]]}),oe=Te(),se=Ee({onSuccess:A}),j=Ie({onSuccess:A}),M=Oe({onSuccess:A}),ce=Se(),[le,ue]=a(null),[pe,me]=a(!1),[he,N]=a(null),[P,F]=a(null),[_e,ve]=a(null),[I,ye]=a(null),R=C??[],z=s.mode===`edit`?R.find(e=>e.id===s.id)??null:null,B=()=>{g(null),b(null),S(!1),oe.reset(),j.reset(),f()};i(()=>{if(s.mode===`closed`){g(null),b(null),S(!1);return}if(s.mode===`new`){g(e=>e!==null&&e.id===void 0?e:hr());return}if(z===null){T||f();return}g(e=>e?.id===z.id?e:gr(z))},[s,z,T,f]);let be=s.mode===`new`&&p!==null&&p.id===void 0||s.mode===`edit`&&p!==null&&z!==null;async function xe(e){await re({title:t(`admin.system.users.deleteUser`,`Delete user`),message:t(`admin.system.users.permanentlyDeleteUserThisCannot`,`Permanently delete user "{{username}}"? This cannot be undone — any active sessions will be revoked on next request.`,{username:e.username}),confirmLabel:t(`common.delete`,`Delete`),variant:`danger`})&&(se.mutate({id:e.id}),s.mode===`edit`&&s.id===e.id&&B())}async function V(e){let n=await ie({title:t(`admin.system.users.resetPassword`,`Reset password`),message:t(`admin.system.users.setANewPasswordFor`,`Set a new password for "{{username}}".`,{username:e.username}),label:t(`admin.system.users.newPassword`,`New password`),inputType:`password`,placeholder:t(`admin.system.users.atLeast8Characters`,`At least 8 characters`),confirmLabel:t(`admin.system.users.continue`,`Continue`),validate:e=>e.length<$?G.t(`admin.system.users.passwordTooShort`,{min:$}):null});n===null||n.length===0||await re({title:t(`admin.system.users.resetPassword`,`Reset password`),message:t(`admin.system.users.resetThePasswordForThey`,`Reset the password for "{{username}}"? They will need to use the new password on their next login.`,{username:e.username}),confirmLabel:t(`common.reset`,`Reset`)})&&M.mutate({id:e.id,newPassword:n})}function we(e){N(null),ue(e)}async function De(e,t){me(!0),N(null);try{t.isAdmin!==e.isAdmin&&await j.mutateAsync({id:e.id,isAdmin:t.isAdmin}),await ce.mutateAsync({userId:e.id,scopes:[...t.scopes]}),ue(null)}catch(e){N(_r(e))}finally{me(!1),A()}}async function je(){if(p!==null){b(null);try{if(p.id===void 0){let e=p.username.trim();if(e===``||p.password.length<$)return;await oe.mutateAsync({username:e,password:p.password,isAdmin:p.isAdmin})}else await j.mutateAsync({id:p.id,isAdmin:p.isAdmin});A(),B()}catch(e){b(_r(e))}}}function Me(e){return e?new Date(typeof e==`number`?e:String(e)).toLocaleDateString(`en-GB`,{day:`2-digit`,month:`short`,year:`numeric`}):`—`}let Ne=oe.isPending||j.isPending,Pe=p!==null&&p.id===void 0&&p.username.trim()!==``&&p.password.length>=$,Le=p!==null&&p.id!==void 0,Re=Ne||(p?.id===void 0?!Pe:!Le),ze=e=>se.isPending&&se.variables?.id===e.id||j.isPending&&j.variables?.id===e.id||M.isPending&&M.variables?.id===e.id,Be=[{key:`username`,header:t(`admin.system.users.username`,`Username`),sortValue:e=>e.username,render:e=>r(`span`,{className:`font-medium text-foreground`,"data-testid":`user-open-${e.id}`,children:e.username})},{key:`scopes`,header:t(`admin.system.users.access`,`Access`),sortValue:e=>yr(e),render:n=>r(`span`,{onClick:e=>e.stopPropagation(),children:e(U,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>we(n),disabled:ze(n),title:t(`admin.system.users.configureAccess`,`Configure access`),"data-testid":`user-access-${n.id}`,children:[r(ae,{className:`h-3 w-3 shrink-0 text-foreground-subtle`}),r(br,{user:n})]})})},{key:`createdAt`,header:t(`admin.system.users.created`,`Created`),nowrap:!0,sortValue:e=>e.createdAt,render:e=>r(`span`,{className:`text-foreground-subtle`,children:Me(e.createdAt)})},{key:`actions`,header:t(`admin.system.users.actions`,`Actions`),align:`right`,nowrap:!0,notSortableReason:`Row actions`,render:n=>{let i=ze(n),a=n.id!==o?.id&&n.totpEnabled;return e(`div`,{className:`flex items-center justify-end gap-1`,onClick:e=>e.stopPropagation(),children:[e(U,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>d(n.id),disabled:i,title:t(`admin.system.users.editUser`,`Edit user`),children:[r(y,{className:`h-3 w-3`}),t(`common.edit`,`Edit`)]}),a&&e(U,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>F(n),disabled:i,title:t(`admin.system.users.removeTwoFactorAuthentication`,`Remove two-factor authentication`),children:[r(D,{className:`h-3 w-3`}),t(`admin.system.users.remove2fa`,`Remove 2FA`)]}),e(U,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>ve(n),disabled:i,title:t(`admin.system.users.linkedSignInAccounts`,`Linked sign-in accounts`),children:[r(O,{className:`h-3 w-3`}),t(`admin.system.users.signInLinks`,`Sign-in links`)]}),e(U,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>ye(n),disabled:i,title:t(`admin.system.users.activeSessions`,`Active sessions`),children:[r(fe,{className:`h-3 w-3`}),t(`admin.system.users.sessions`,`Sessions`)]}),e(U,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>void V(n),disabled:i,title:t(`admin.system.users.resetPassword`,`Reset password`),children:[r(de,{className:`h-3 w-3`}),t(`admin.system.users.resetPassword`,`Reset password`)]}),e(U,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>void xe(n),disabled:i,title:t(`admin.system.users.deleteUser`,`Delete user`),className:`text-danger hover:bg-danger/10`,children:[i?r(k,{className:`h-3 w-3 animate-spin`}):r(h,{className:`h-3 w-3`}),t(`common.delete`,`Delete`)]})]})}}];return e(pt,{embedded:!0,icon:m,title:t(`admin.system.users.users`,`Users`),subtitle:t(`admin.system.users.hubAccountsAdminFlagAccess`,`Hub accounts, admin flag, access scopes, sessions and sign-in links.`),actions:e(U,{size:`sm`,type:`button`,onClick:()=>{b(null),u()},children:[r(v,{className:`h-3.5 w-3.5`}),t(`admin.system.users.createUser`,`Create User`)]}),children:[E&&r(L,{title:t(`admin.system.users.couldNotLoadUsers`,`Could not load users`),message:_r(ee),onRetry:()=>void ne()}),T&&e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(k,{className:`h-3.5 w-3.5 animate-spin`}),t(`common.loading`,`Loading…`)]}),!T&&!E&&R.length===0&&r(Ae,{icon:m,title:t(`admin.system.users.noUsersYet`,`No users yet`),description:t(`admin.system.users.createAUserToGrant`,`Create a user to grant hub access.`)}),!T&&!E&&R.length>0&&r(Ce,{columns:Be,rows:R,rowKey:e=>e.id,minWidthPx:560,maxBodyHeight:`max-h-[60vh]`,onRowClick:e=>d(e.id)}),r(ge,{open:be,onClose:B,title:p?.id===void 0?t(`admin.system.users.createUser`,`Create User`):t(`admin.system.users.edit`,`Edit {{value1}}`,{value1:p.username||`user`}),icon:m,error:_,testId:`user-form-dialog`,footer:r(U,{size:`sm`,type:`button`,disabled:Re,onClick:()=>void je(),children:Ne?e(l,{children:[r(k,{className:`h-3.5 w-3.5 animate-spin`}),t(`admin.system.users.saving`,`Saving…`)]}):p?.id===void 0?t(`admin.system.users.create`,`Create`):t(`common.save`,`Save`)}),children:p!==null&&e(`div`,{className:`space-y-3`,children:[r(H,{label:t(`admin.system.users.username`,`Username`),required:p.id===void 0,children:r(Fe,{value:p.username,onChange:e=>g({...p,username:e.target.value}),placeholder:`john`,autoFocus:p.id===void 0,disabled:p.id!==void 0,"data-testid":`user-form-username`})}),p.id===void 0&&r(H,{label:t(`admin.system.users.password`,`Password`),required:!0,description:t(`admin.system.users.atLeastCharacters`,`At least {{value1}} characters.`,{value1:String($)}),children:r(Je,{value:p.password,onValueChange:e=>g({...p,password:e}),shown:x,onToggleShown:()=>S(e=>!e),placeholder:`••••••••`,"data-testid":`user-form-password`})}),r(H,{label:t(`admin.system.users.admin`,`Admin`),description:t(`admin.system.users.unrestrictedAccessToEveryCapability`,`Unrestricted access to every capability and device.`),children:e(`label`,{className:`inline-flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[r(Ue,{checked:p.isAdmin,onChange:e=>g({...p,isAdmin:e.target.checked}),className:`rounded border-border focus:ring-primary`,"data-testid":`user-form-admin`}),r(`span`,{children:t(`admin.system.users.admin`,`Admin`)})]})}),p.id!==void 0&&r(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`admin.system.users.toChangeThePasswordUse`,`To change the password, use Reset password on the user's row. Access scopes are configured from the Access column.`)})]})}),P&&r(Zn,{userId:P.id,username:P.username,onClose:()=>F(null)}),_e&&r(Xn,{userId:_e.id,username:_e.username,onClose:()=>ve(null)}),I&&r(Qn,{userId:I.id,username:I.username,onClose:()=>ye(null)}),le&&r(pr,{user:le,isSelf:le.id===o?.id,onClose:()=>ue(null),onSubmit:e=>void De(le,e),submitting:pe,error:he})]})}function yr(e){let t=er(e);return t.role===`admin`?0:t.unconfigured?2:1}function br({user:t}){let{t:n}=K(),i=er(t);if(i.role===`admin`)return r(`span`,{className:`font-medium text-foreground`,children:n(`users.accessSummary.admin`)});if(i.unconfigured)return r(`span`,{className:`font-medium text-warning`,children:n(`admin.system.users.noAccess`,`No access`)});let{allow:a,block:o,features:s}=i.viewer,c=a===`*`?n(`users.accessSummary.allDevices`):n(`users.accessSummary.devices`,{count:a.length});return e(`span`,{className:`text-foreground-subtle`,children:[r(`span`,{className:`font-medium text-foreground`,children:n(`users.accessSummary.viewer`)}),` ·`,` `,c,o.length>0&&e(l,{children:[` · `,n(`users.accessSummary.blocked`,{count:o.length})]}),s.length>0&&e(l,{children:[` · `,n(`users.accessSummary.features`,{count:s.length})]})]})}s();var xr={"api-keys":Q.tokens,"linked-sessions":Q.linkedApps},Sr=`certificates`;function Cr(t){return e(U,{size:`sm`,type:`button`,"data-testid":`certificates-pair-device`,onClick:t,children:[r(D,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),G.t(`systemPage.identity.pairADevice`,`Pair a device`)]})}function wr(){let{t:e}=K(),[t]=nt(),n=ln(),[i,o]=a(!1),s=xr[t.get(`tab`)??``];if(s!==void 0)return r(lt,{to:ut(`access`,{integration:s}),replace:!0});let c=ot(`/system/identity`,{t:e,isAdmin:!0})??{icon:ie,title:e(`system.identity`,`Identity & Access`)},l=t.get(`tab`)??`users`,u=t.get(`integration`),d=l===at.access.tab?cn(u,n.requestCreate):l===`certificates`?Cr(()=>o(!0)):void 0;return r(ft,{icon:c.icon,title:c.title,defaultSection:`users`,sectionsLabel:`${c.title} sections`,actions:d,sections:[{id:`users`,label:e(`systemPage.identity.users`,`Users`),content:r(vr,{})},{id:at.access.tab,label:e(`systemPage.identity.tokensSessions`,`Tokens & sessions`),ownedParams:ct.concat([wt.token,wt.scoped,wt.admin]),content:r(sn,{createRequested:n.createRequested,onCreateConsumed:n.clearCreate})},{id:Sr,label:e(`systemPage.identity.certificates`,`Certificates`),content:r(Yn,{pairOpen:i,onPairClose:()=>o(!1)})},{id:at.authentication.tab,label:e(`systemPage.identity.authentication`,`Authentication`),content:r(Vt,{}),ownedParams:ct}]})}export{wr as IdentityPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,k as c,o as l,x as u,z as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Fn as f,Gn as p,Kt as m,Qi as h,Tn as g,V as _,Wn as ee,Xn as te,ct as ne,ht as re,on as v,wr as ie,xr as y}from"./player-overlays-Dikds8gI.js";import{dr as b}from"./client-C3Nr53Gn.js";import{t as ae}from"./link-2-off-C4UZJh-L.js";import{Br as x,Ei as S,Et as oe,Fr as C,Gs as w,In as se,Ir as T,Jr as ce,Oi as le,Pr as E,Rn as ue,Yr as de,_n as D,ff as O,gn as k,ir as A,jn as j,kt as fe,pa as M,vi as N,wt as pe,ya as P,zr as F}from"./src-VAvW-zoJ.js";import{t as I}from"./useTranslation-BJr-n0es.js";import{n as L}from"./addon-icons-context-DzG39awM.js";import{$ as R,Ar as z,Dr as me,G as he,K as B,Or as ge,Q as V,Y as _e,Z as ve,at as ye,et as be,nt as xe,ot as Se,q as Ce,r as H,rt as we,st as Te,tt as Ee}from"./index-Bec3SQjl.js";import{t as U}from"./NodeAddonsSettingsPanel-B8UxjFBZ.js";s();var W=[[[`addons`,`listCapabilityProviders`]],[[`addons`,`list`]]],G=`text-[10px]`;function De({isActive:e}){let{t}=I();return i(S,{variant:e?`success`:`default`,className:G,children:e?t(`integrationHub.addonControls.enabled`,`Enabled`):t(`integrationHub.addonControls.disabled`,`Disabled`)})}function K({capName:t,addonId:n,isActive:r}){let{t:a}=I(),o=l(),s=P({onSuccess:()=>{for(let e of W)o.invalidateQueries({queryKey:e})}}),c=s.isPending;return e(N,{size:`sm`,variant:r?`secondary`:`primary`,disabled:c,onClick:()=>s.mutate({capName:t,addonId:n,enabled:!r}),children:[c?i(y,{className:`h-3 w-3 animate-spin`}):i(r?v:p,{className:`h-3 w-3`}),r?a(`common.disable`,`Disable`):a(`common.enable`,`Enable`)]})}function q(){let e=l();return M({onSuccess:()=>{for(let t of W)e.invalidateQueries({queryKey:t})}})}function J({addonId:e,displayName:t,message:n}){let{t:r}=I(),a=ne(),o=q();return i(O,{icon:o.isPending?y:f,variant:`ghost`,size:`sm`,"aria-label":r(`integrationHub.addonControls.restartNamed`,`Restart {{name}}`,{name:t}),disabled:o.isPending,onClick:()=>void a({title:r(`integrationHub.addonControls.restart2`,`Restart "{{displayName}}"?`,{displayName:t}),message:n,confirmLabel:r(`integrationHub.addonControls.restart`,`Restart`),variant:`danger`}).then(t=>t?o.mutateAsync({addonId:e}):void 0)})}function Oe({addonId:e,displayName:t,iconOnly:n=!1,description:r}){let{t:a}=I(),o=q(),s=r??a(`integrationHub.addonControls.restartingTheAddonBouncesIts`,`Restarting the addon bounces its subprocess — the provider will briefly drop and reconnect automatically.`);return n?i(J,{addonId:e,displayName:t,message:s}):i(j,{label:a(`integrationHub.addonControls.restart`,`Restart`),icon:f,size:`sm`,title:a(`integrationHub.addonControls.restart2`,`Restart "{{displayName}}"?`,{displayName:t}),description:s,confirmLabel:a(`integrationHub.addonControls.restart`,`Restart`),triggerVariant:`ghost`,confirmVariant:`danger`,disabled:o.isPending,action:()=>o.mutateAsync({addonId:e})})}var Y=600,X=c(null);function Z({id:n,title:r,icon:a,actions:o,framed:s=!1,children:c}){let{t:l}=I(),f=d(X),p=t(null),m=`integration-section-${n}`;ke(p,f,n);let h=e(u,{children:[f===null?null:i(z,{to:f.sectionHref(n),"aria-label":l(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:r}),title:l(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:r}),className:`rounded p-0.5 text-foreground-subtle/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,children:i(ie,{className:`h-3 w-3`,"aria-hidden":!0})}),o]});return s?i(`div`,{ref:p,className:`scroll-mt-4`,children:i(se,{headingId:m,title:r,icon:a,actions:h,children:c})}):e(`section`,{ref:p,"aria-labelledby":m,className:`scroll-mt-4 space-y-2`,children:[e(`header`,{className:`flex min-h-7 flex-wrap items-center gap-2 px-0.5`,children:[a!==void 0&&i(a,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),i(`h2`,{id:m,className:`${_} min-w-0 flex-1`,children:r}),h]}),c]})}function ke(e,t,n){let r=t?.requestedSection===n,i=t?.integrationId;a(()=>{if(!r)return;let t=()=>e.current?.scrollIntoView?.({block:`start`});t();let n=!1,i=()=>{n=!0},a=[`wheel`,`touchmove`,`keydown`];for(let e of a)window.addEventListener(e,i,{once:!0,passive:!0});let o=window.setTimeout(()=>{n||t()},Y);return()=>{window.clearTimeout(o);for(let e of a)window.removeEventListener(e,i)}},[r,i,e])}s();var Q=`max-h-72`,$=[{kind:`logs`,labelKey:`common.logs`,icon:g},{kind:`events`,labelKey:`common.events`,icon:h}];function Ae({addonId:t,switcher:n}){let{t:r}=I(),[a,s]=o(`logs`);return e(Z,{id:H,title:r(`integrationHub.addonIntegrationBody.activity`,`Activity`),framed:!0,actions:i(`div`,{className:`flex flex-wrap items-center gap-2`,children:i(`div`,{role:`group`,"aria-label":r(`integrationHub.addonIntegrationBody.activityStream`,`Activity stream`),className:`flex items-center gap-1`,children:$.map(({kind:t,labelKey:n,icon:o})=>e(N,{variant:`unstyled`,type:`button`,"aria-pressed":a===t,onClick:()=>s(t),className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${a===t?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[i(o,{className:`h-3 w-3`,"aria-hidden":!0}),r(n)]},t))})}),children:[n!==void 0&&i(`div`,{className:`px-3 pt-2`,children:n}),a===`logs`?i(D,{addonId:t,maxHeight:Q,showFilters:!1}):i(k,{addonId:t,category:`addon.*`,maxHeight:Q})]})}function je({addonId:t,title:n=`Settings`,subtitle:r,fieldScope:a,onClose:o}){return i(E,{open:!0,onOpenChange:e=>!e&&o(),children:e(T,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-3xl`,children:[e(F,{children:[i(x,{children:n}),r&&i(`p`,{className:`text-xs text-foreground-subtle`,children:r})]}),i(C,{children:i(U,{nodeId:null,addonIds:[t],level:`global`,...a===void 0?{}:{fieldScope:a}})})]})})}function Me({addonId:e,title:t,onClose:n}){return i(je,{addonId:e,title:t,fieldScope:`cluster`,onClose:n})}var Ne=`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,Pe=`border-primary bg-primary/10 text-primary font-medium`,Fe=`border-border bg-surface text-foreground-subtle hover:bg-surface-hover hover:text-foreground`;s();var Ie={md:{tile:`h-10 w-10 rounded-lg`,img:`h-7 w-7 rounded-md p-1`,fallback:`h-5 w-5`},sm:{tile:`h-5 w-5 rounded`,img:`h-5 w-5 rounded p-0.5`,fallback:`h-3.5 w-3.5`}};function Le({addonId:e,fallback:t,tileClassName:n,size:r=`md`}){let[a,s]=o(!1),c=L(e),l=Ie[r];return i(`div`,{className:`${l.tile} flex items-center justify-center shrink-0 ${n}`,children:a||!c?i(t,{className:l.fallback,"aria-hidden":!0}):i(`img`,{src:c,alt:``,className:`${l.img} bg-white ring-1 ring-black/5`,onError:()=>s(!0)})})}var Re={ok:`bg-success`,off:`bg-foreground-subtle/60`,error:`bg-danger`,unknown:`border border-foreground-subtle bg-transparent`};function ze(e,t){switch(t){case`ok`:return e(`instances.health.ok`,`Healthy`);case`error`:return e(`instances.health.error`,`Error`);case`off`:return e(`instances.health.off`,`Off`);case`unknown`:return e(`instances.health.unknown`,`Unknown`)}}function Be({pills:t,selected:n,onSelect:r,fallbackIcon:a,install:o}){let{t:s}=I(),c=t.length>1;return!c&&o===void 0?null:i(`div`,{className:`px-3 pt-2`,children:e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[c&&i(`div`,{role:`group`,"aria-label":s(`instances.filterByProvider`,`Filter by provider`),className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:t.map(t=>e(N,{variant:`unstyled`,type:`button`,"aria-pressed":n===t.addonId,"data-testid":`instance-pill-${t.addonId}`,onClick:()=>r(n===t.addonId?null:t.addonId),className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 ${n===t.addonId?`border-primary bg-primary/10 text-primary font-medium`:`border-border bg-surface text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[i(Le,{addonId:t.addonId,fallback:a,tileClassName:``,size:`sm`}),i(`span`,{className:`truncate`,children:t.name}),i(`span`,{className:`shrink-0 text-[10px] font-normal text-foreground-subtle`,children:t.count}),i(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${Re[t.health]}`,"aria-hidden":!0}),i(`span`,{className:`sr-only`,children:ze(s,t.health)})]},t.addonId))}),o!==void 0&&e(z,{to:b(o.capability),className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 border-dashed border-border pl-2 text-foreground-subtle hover:border-primary/50 hover:text-foreground`,children:[i(ee,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),i(`span`,{className:`truncate`,children:o.label})]})]})})}function Ve({providers:t,title:n,onPick:r,onCancel:a}){let{t:o}=I();return e(oe,{open:!0,onClose:a,title:n,width:`lg`,children:[i(`p`,{className:`mb-3 text-xs text-foreground-muted`,children:o(`providerInstances.pickProvider`,`Choose which provider the new one belongs to.`)}),i(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:t.map(t=>e(`button`,{type:`button`,onClick:()=>r(t.addonId),className:`flex flex-col items-start gap-1 rounded-lg border border-border bg-surface px-3 py-3 text-left text-xs transition-colors hover:border-primary/50 hover:bg-surface-hover`,children:[i(`span`,{className:`font-medium text-foreground`,children:t.name}),t.description.length>0&&i(`span`,{className:`line-clamp-2 text-[11px] text-foreground-subtle`,children:t.description})]},t.addonId))})]})}function He(e){let t=w({onSuccess:e.onSuccess});return{mutate:e=>t.mutate({...e}),isPending:t.isPending}}s();var Ue=`instance`;function We(e){let t=[e.status?.detail,e.lastCheckedAt===void 0?void 0:new Date(e.lastCheckedAt).toLocaleString()].filter(e=>e!==void 0&&e.length>0);return t.length>0?t.join(` · `):void 0}function Ge({row:t}){let{t:n}=I();return t.enabled?e(`span`,{className:`flex flex-wrap items-center gap-1`,children:[i(S,{variant:t.configured?`success`:`default`,children:t.configured?n(`providerInstances.configured`,`Configured`):n(`providerInstances.notConfigured`,`Not configured`)}),t.status!==void 0&&i(S,{variant:t.status.state===`error`?`danger`:t.status.state===`ok`?`success`:`default`,title:We(t),children:xe(t.status)})]}):i(`span`,{className:`flex flex-wrap items-center gap-1`,children:i(S,{variant:`default`,children:n(`providerInstances.off`,`Off`)})})}function Ke({row:t,pinning:n}){let{t:r}=I(),a=l(),o=He({onSuccess:()=>void a.invalidateQueries({queryKey:[B]})});return e(`span`,{className:`flex flex-col gap-1`,children:[i(A,{checked:t.enabled,disabled:o.isPending,"aria-label":r(`providerInstances.enable`,`Enable {{name}}`,{name:t.name}),onCheckedChange:e=>o.mutate({addonId:t.addonId,id:t.id,enabled:e})}),n>0&&i(`span`,{className:`text-[11px] text-foreground-subtle`,children:r(`providerInstances.pinnedBy`,{count:n})})]})}function qe({row:e,functionCap:t}){let{t:n}=I(),r=l(),a=P({onSuccess:()=>void r.invalidateQueries()});return i(A,{checked:e.isActive,disabled:a.isPending,"aria-label":n(`providerInstances.enable`,`Enable {{name}}`,{name:e.providerName}),onCheckedChange:n=>a.mutate({capName:t,addonId:e.addonId,enabled:n})})}function Je({functionCap:t,icon:a,title:s,subtitle:c,emptyTitle:d,emptyDescription:f,addLabel:h,install:g,extraColumns:_,lead:v,rowActions:b,canDelete:x,pageActions:oe,typedId:C,rowFilter:w}){let{t:T}=I(),E=re(),D=l(),k=ne(),A=Ce(t),j=pe({editKey:Ue,newKey:`${Ue}-new`}),[M,P]=o(null),[F,L]=o(null),R=le({functionCap:`notification-output`}),z=r(e=>we(R.data??[],e).length,[R.data]),[he,xe]=o(null),[H,Ee]=o(null),U=n(()=>_e(A.holders),[A.holders]),W=n(()=>be(A.functionProviders,A.rows,A.displayNames),[A.functionProviders,A.rows,A.displayNames]),G=W.some(e=>e.addonId===H)?H:null,De=n(()=>{let e=ve(A.rows,G);return w===void 0?e:e.filter(w)},[A.rows,G,w]),K=r(e=>A.displayNames.get(e)??e,[A.displayNames]),q=r(async e=>{P(e.key),L(null);try{let t=await E.trpcClient.integrationInstances.testInstance.mutate({addonId:e.addonId,id:e.id,values:{}});L({name:e.name,verdict:Te(t)})}catch(t){let n=t instanceof Error?t.message:String(t);L({name:e.name,verdict:{status:`inconclusive`,error:n}})}finally{P(null)}},[E]),J=r(async e=>{let t=we(R.data??[],e.id),n=t.length>0?` ${T(`providerInstances.deletePinned`,`These notification targets use it and will stop delivering: {{names}}.`,{names:t.join(`, `)})}`:``;if(await k({title:T(`providerInstances.deleteTitle`,`Delete {{name}}?`,{name:e.name}),message:`${T(`providerInstances.deleteMessage`,`The record and its stored credentials are removed.`)}${n}`,confirmLabel:T(`common.delete`,`Delete`),variant:`danger`}))try{await E.trpcClient.integrationInstances.deleteInstance.mutate({addonId:e.addonId,id:e.id}),await D.invalidateQueries({queryKey:[B]})}catch(t){ye({title:T(`providerInstances.deleteFailed`,`Could not delete`),message:`${e.name}: ${t instanceof Error?t.message:String(t)}`,severity:`critical`})}},[k,D,E,T,R.data]),Y=n(()=>A.rows.some(e=>e.kind===`instance`&&e.kindLabel!==void 0),[A.rows]),X=r((e,t)=>{e!==void 0&&ge(me(e,t),()=>{D.invalidateQueries({queryKey:[B]})})},[D]),Z=n(()=>[{key:`name`,nowrap:!1,header:T(`providerInstances.colName`,`Name`),sortValue:e=>e.name,render:t=>e(`span`,{className:`flex flex-col`,children:[i(`span`,{className:`font-medium ${t.kind===`instance`&&!t.enabled?`text-foreground-muted`:`text-foreground`}`,children:t.name}),t.kind===`fixed`&&t.description.length>0&&i(`span`,{className:`line-clamp-2 text-[11px] text-foreground-subtle`,title:t.description,children:t.description})]})},{key:`provider`,header:T(`providerInstances.colProvider`,`Provider`),sortValue:e=>e.providerName,render:e=>i(`span`,{className:`text-foreground-muted`,children:e.providerName})},...Y?[{key:`kind`,header:T(`providerInstances.colKind`,`Kind`),sortValue:e=>e.kind===`instance`?e.kindLabel??``:``,render:e=>i(`span`,{className:`text-foreground-muted`,children:e.kind===`instance`?e.kindLabel??``:``})}]:[],{key:`state`,header:T(`instances.colStatus`,`Status`),notSortableReason:T(`providerInstances.stateNotSortable`,`A row carries a badge, not a value to order by.`),render:e=>e.kind===`instance`?i(Ge,{row:e}):i(S,{variant:e.isActive?`success`:`default`,children:e.isActive?T(`instances.active`,`Active`):T(`providerInstances.off`,`Off`)})},{key:`on`,header:T(`providerInstances.colOn`,`On`),notSortableReason:T(`providerInstances.onNotSortable`,`A switch is not a value to order by.`),render:e=>e.kind===`fixed`?i(qe,{row:e,functionCap:t}):i(Ke,{row:e,pinning:z(e.id)})},..._??[],{key:`actions`,align:`right`,notSortableReason:T(`providerInstances.actionsNotSortable`,`Row actions are not values.`),render:t=>e(`span`,{className:`inline-flex items-center gap-1`,children:[t.kind===`instance`&&t.connectPath!==void 0&&i(O,{icon:ie,variant:`ghost`,size:`sm`,"aria-label":T(`providerInstances.connectRow`,`Connect {{name}}`,{name:t.name}),onClick:()=>X(t.connectPath,t.id)}),t.kind===`instance`&&t.disconnectPath!==void 0&&i(O,{icon:ae,variant:`ghost`,size:`sm`,"aria-label":T(`providerInstances.disconnectRow`,`Disconnect {{name}}`,{name:t.name}),onClick:()=>X(t.disconnectPath,t.id)}),t.kind===`instance`&&t.canTest&&i(O,{icon:M===t.key?y:p,variant:`ghost`,size:`sm`,"aria-label":T(`providerInstances.testRow`,`Test {{name}}`,{name:t.name}),disabled:M!==null,onClick:()=>void q(t)}),t.kind===`instance`&&b?.(t),i(O,{icon:te,variant:`ghost`,size:`sm`,"aria-label":T(`providerInstances.editRow`,`Edit {{name}}`,{name:t.name}),onClick:()=>j.openEdit(V(t.addonId,t.kind===`instance`?t.id:void 0))}),i(Oe,{iconOnly:!0,addonId:t.addonId,displayName:t.providerName,description:T(`providerInstances.restartConfirm`,`Restarts the addon on the hub. If it shares a runner group, every addon in that group restarts with it.`)}),t.kind===`instance`&&(x?.(t)??!0)&&i(O,{icon:m,variant:`ghost`,size:`sm`,"aria-label":T(`providerInstances.deleteRow`,`Delete {{name}}`,{name:t.name}),onClick:()=>void J(t)})]})}],[_,j,t,z,b,x,J,X,q,Y,T,M]),ke;ke=A.state===`error`?i(`div`,{className:`p-3`,children:i(ce,{title:T(`providerInstances.loadFailed`,`Could not load the list`),message:A.error??``,onRetry:A.refetch})}):A.state===`pending`?e(`div`,{className:`flex items-center gap-2 p-3 text-xs text-foreground-subtle`,children:[i(y,{className:`h-3 w-3 animate-spin`}),T(`providerInstances.loading`,`Loading…`)]}):A.rows.length===0?i(de,{icon:a,title:d,description:f}):i(ue,{columns:Z,rows:De,rowKey:e=>e.key,bordered:!1,emptyMessage:T(`instances.noneForProvider`,`This provider has no instance yet.`)});let Q=A.holders.filter(e=>!U.includes(e)).map(e=>K(e.addonId)),$=U.length>0?void 0:Q.length>0?T(`instances.addBlocked`,`{{names}}: only one instance is allowed and it already exists.`,{names:Q.join(`, `)}):T(`instances.addNone`,`No provider here can hold instances.`);return e(se,{headingId:`provider-instances-${t}`,title:s,icon:a,children:[i(`p`,{className:`px-3 pt-2 text-xs text-foreground-muted`,children:c}),A.state===`ready`&&$!==void 0&&i(`p`,{className:`px-3 pt-1 text-[11px] text-foreground-subtle`,children:$}),A.state===`ready`&&e(u,{children:[e(fe,{children:[oe?.(A.rows.filter(e=>e.kind===`instance`)),e(N,{size:`sm`,variant:`primary`,disabled:$!==void 0,title:$,onClick:()=>{let e=U.find(e=>e.addonId===G)??(U.length===1?U[0]:void 0);e===void 0?j.openNew():j.openEdit(V(e.addonId,null))},children:[i(ee,{className:`h-3.5 w-3.5`}),h]})]}),i(Be,{pills:W,selected:G,onSelect:Ee,fallbackIcon:a,...g===void 0?{}:{install:g}})]}),ke,A.state===`ready`&&A.rows.length>0&&i(Ye,{rows:A.rows,selected:he,onSelect:xe}),F!==null&&e(`div`,{className:`space-y-1 p-3`,children:[i(`p`,{className:`text-[11px] font-medium text-foreground`,children:F.name}),i(Se,{verdict:F.verdict})]}),A.state===`ready`&&j.state.mode===`new`&&i(Ve,{title:h,providers:U.map(e=>({addonId:e.addonId,name:K(e.addonId),description:A.descriptions.get(e.addonId)??``})),onPick:e=>j.openEdit(V(e,null)),onCancel:j.close}),A.state===`ready`&&j.state.mode===`edit`&&i(Xe,{refValue:j.state.id,data:A,nameOf:K,onClose:j.close,onOpen:(e,t)=>j.openEdit(V(e,t)),...v===void 0?{}:{lead:v},...C===void 0?{}:{typedId:C}},j.state.id)]})}function Ye({rows:e,selected:t,onSelect:r}){let{t:a}=I(),o=n(()=>Ee(e),[e]),s=o[0];if(s===void 0)return null;let c=o.find(e=>e.addonId===t)??s;return i(`div`,{className:`p-3`,children:i(Ae,{addonId:c.addonId,switcher:o.length>1?i(`div`,{role:`group`,"aria-label":a(`providerInstances.activityProvider`,`Activity of`),className:`flex flex-wrap items-center gap-1`,children:o.map(e=>i(N,{variant:`unstyled`,type:`button`,"aria-pressed":e.addonId===c.addonId,onClick:()=>r(e.addonId),className:`rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${e.addonId===c.addonId?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.name},e.addonId))}):void 0})})}function Xe({refValue:e,data:t,nameOf:n,onClose:r,onOpen:a,lead:o,typedId:s}){let c=R(e);if(c.kind===`fixed`)return i(Me,{addonId:c.addonId,title:n(c.addonId),onClose:r});let l=t.holders.find(e=>e.addonId===c.addonId);if(l===void 0)return null;let u=c.kind===`instance`?l.instances.find(e=>e.id===c.id)??null:null;if(c.kind===`instance`&&u===null)return null;let d=t.rows.find(e=>e.kind===`instance`&&e.addonId===c.addonId&&e.id===u?.id);return i(Ze,{addonId:c.addonId,...o!==void 0&&d!==void 0?{lead:o(d)}:{},providerName:n(c.addonId),description:l.description,instance:u,onClose:r,onOpen:a,...s===void 0?{}:{typedId:s}})}function Ze(e){let{onOpen:n,onClose:r,onSaved:a,...o}=e,s=t(null),c=e.instance===null;return i(he,{...o,onSaved:e=>{c&&(s.current=e),a?.(e)},onClose:()=>{s.current===null?r():n(e.addonId,s.current)}})}export{Fe as a,X as c,Oe as d,G as f,Pe as i,K as l,Le as n,Ae as o,Ne as r,Z as s,Je as t,De as u};
|