@camstack/addon-admin-ui 1.2.422 → 1.2.424
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/dist/assets/{AddonAssetIcon-CsoRkxbe.js → AddonAssetIcon-DpRGr6eL.js} +1 -1
- package/dist/assets/{Addons-D6p7m_1Q.js → Addons-Cy2vW-GC.js} +1 -1
- package/dist/assets/{AdminPage-BXCcRjRj.js → AdminPage-3IR6Hk67.js} +1 -1
- package/dist/assets/{AdminSectionedPage-Dn3pfXpN.js → AdminSectionedPage-4SkTwpI5.js} +1 -1
- package/dist/assets/{AiProfiles-A_EtYWgt.js → AiProfiles-CCMhrKGR.js} +1 -1
- package/dist/assets/{BrokerForm-B50lYczl.js → BrokerForm-knwGVvlP.js} +1 -1
- package/dist/assets/{Build-CYzfQeUi.js → Build-PdGYsW_d.js} +1 -1
- package/dist/assets/{Calendars-DxzSNlaT.js → Calendars-sN0mcmx8.js} +1 -1
- package/dist/assets/Cluster-B-8RNoJl.js +1 -0
- package/dist/assets/{ClusterStepModel-CL6OTKoe.js → ClusterStepModel-B-BZmPhO.js} +1 -1
- package/dist/assets/{CompositionEditor-BpioOiB6.js → CompositionEditor-DPCOBkAG.js} +1 -1
- package/dist/assets/{CompositionEditorPage-BtUyHyvc.js → CompositionEditorPage-DGyqKaco.js} +1 -1
- package/dist/assets/{Data-DjwFU5Th.js → Data-BTU_oZFA.js} +1 -1
- package/dist/assets/{DeviceDetail-_84gb-7d.js → DeviceDetail-Cfj4KCjC.js} +1 -1
- package/dist/assets/{DeviceDoActionFields-CaAhrBBq.js → DeviceDoActionFields-BKCPjNdJ.js} +1 -1
- package/dist/assets/{Devices-Bn806mzY.js → Devices-Co8gpzOv.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-BKa9M_Zh.js → EmbedPlayerPage-BycHbxaz.js} +1 -1
- package/dist/assets/Identity-Bu6tV79U.js +1 -0
- package/dist/assets/{IntegrationDetail-NFPFWNqY.js → IntegrationDetail-Dh95e-ov.js} +1 -1
- package/dist/assets/{IntegrationHub-nkG_70wF.js → IntegrationHub-DA5-5WRz.js} +1 -1
- package/dist/assets/{Integrations-DwbH7OPk.js → Integrations-BIRnKHr_.js} +1 -1
- package/dist/assets/{Integrations-BnJ0plVy.js → Integrations-BPYi4NML.js} +1 -1
- package/dist/assets/{Library-BeKXIn8H.js → Library-BjmrQqUX.js} +1 -1
- package/dist/assets/Locations-BDXa1xhP.js +3 -0
- package/dist/assets/{Logs-Bv7UFKGr.js → Logs-CmQq6sTE.js} +1 -1
- package/dist/assets/{MotionZonesSettings-D_qLVNYH.js → MotionZonesSettings-ChKtiEGg.js} +1 -1
- package/dist/assets/MyAccess-DNUWFuuc.js +2 -0
- package/dist/assets/{Network-Dm89K78z.js → Network-CON3pH6E.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-DW1CFRqr.js → NodeAddonsSettingsPanel-BJZk7zTu.js} +1 -1
- package/dist/assets/{Notifications--YlWuq7D.js → Notifications-CJCLRZ7G.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-C_nHi8iw.js → PrivacyMaskSettings-Cpbt8TIJ.js} +1 -1
- package/dist/assets/{Recordings-B3tdsucL.js → Recordings-YZtEVeYP.js} +1 -1
- package/dist/assets/{ScanNetworkModal-DVDP8rFS.js → ScanNetworkModal-CYyrjEsB.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-BzVlh6Gr.js → SceneMonitorEditor-CaUk0FYV.js} +1 -1
- package/dist/assets/SessionsList-BwcT1neM.js +2 -0
- package/dist/assets/{Showroom-DBz_kmHd.js → Showroom-BIRKF0dk.js} +1 -1
- package/dist/assets/{System-CbZHPKfq.js → System-myhV_MaL.js} +1 -1
- package/dist/assets/{Terminal-CECng0sk.js → Terminal-CZIrea8T.js} +1 -1
- package/dist/assets/{Viewer-Dqzwha2F.js → Viewer-CMNSu0lq.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-KEhfqRL3.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DtZaYSQH.js} +1 -1
- package/dist/assets/{addon-icons-context-ESxHkko-.js → addon-icons-context-BavDxTPH.js} +1 -1
- package/dist/assets/{archive-EESnpwDQ.js → archive-3M3ozcU0.js} +1 -1
- package/dist/assets/{authed-media-DbWnolm6.js → authed-media-D56U-4qh.js} +1 -1
- package/dist/assets/{bell-off-CSUO3NcL.js → bell-off-5pZv5sKf.js} +1 -1
- package/dist/assets/{boxes-F2kcHJh3.js → boxes-1pLz5hUM.js} +1 -1
- package/dist/assets/circle-slash-DdZfDqQG.js +1 -0
- package/dist/assets/client-CPAjuyjS.js +358 -0
- package/dist/assets/{cloud-upload-DaYCZ49o.js → cloud-upload-DGbtl7kl.js} +1 -1
- package/dist/assets/crop-C8MmVjW3.js +1 -0
- package/dist/assets/{device-integration-icon-DC6GK3pO.js → device-integration-icon-58hSioYq.js} +1 -1
- package/dist/assets/device-picker-model-BviOkzyX.js +1 -0
- package/dist/assets/{dist-8eKR6eC_.js → dist-BNYk89Zc.js} +4 -4
- package/dist/assets/{dist-CD_P-W4K.js → dist-IPJ6n7RQ.js} +1 -1
- package/dist/assets/{eraser-Lfy_pBOl.js → eraser-DTrp1IIZ.js} +1 -1
- package/dist/assets/{file-up-D4zDJB-k.js → file-up-_ULNp_05.js} +1 -1
- package/dist/assets/{hard-drive-download-W35XVpPS.js → hard-drive-download-HQkd9SLO.js} +1 -1
- package/dist/assets/{history-DQ9vKorT.js → history-DsADJO4y.js} +1 -1
- package/dist/assets/{hostInit-CQubQ_OP.js → hostInit-BnVYvsSx.js} +1 -1
- package/dist/assets/{icons-dYEMPXRw.js → icons-Bxqmmfam.js} +1 -1
- package/dist/assets/{index-Dbcd0nug.js → index-D6a_-apt.js} +3 -3
- package/dist/assets/index-dmZ34NAY.css +2 -0
- package/dist/assets/{key-BL3RAip-.js → key-CA_hxP8X.js} +1 -1
- package/dist/assets/{key-round-WrVw9weZ.js → key-round-ClhiHwZi.js} +1 -1
- package/dist/assets/{layers-BagSqCNw.js → layers-BGwl7aC_.js} +1 -1
- package/dist/assets/{list-ordered-DZPbjPqk.js → list-ordered-DQLdQGqt.js} +1 -1
- package/dist/assets/{location-owned-usage-D9_fG4z9.js → location-owned-usage-C0JfjuuV.js} +1 -1
- package/dist/assets/{log-in-CPy0U03d.js → log-in-BdBi9Cme.js} +1 -1
- package/dist/assets/{memory-stick-DyJ5Tk7i.js → memory-stick-bH-Zu951.js} +1 -1
- package/dist/assets/{message-square-plus-brBt7pwi.js → message-square-plus-DR40ZFS6.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-dcb80f94.js → mf-entry-bootstrap-0-3c4040d4.js} +2 -2
- package/dist/assets/{mic-off-DjwMxkEf.js → mic-off-B59TJIsA.js} +1 -1
- package/dist/assets/{monitor-off-B51Pk6ca.js → monitor-off-MgjzxGSz.js} +1 -1
- package/dist/assets/{monitor-smartphone-BL4hI9CF.js → monitor-smartphone-DFPo3Yqb.js} +1 -1
- package/dist/assets/mount-BviOkzyX.js +1 -0
- package/dist/assets/{notification-schedule-field-C4N-WcPT.js → notification-schedule-field-Do5St1AP.js} +1 -1
- package/dist/assets/{octagon-alert-jd1vv87l.js → octagon-alert-CLNUgI7g.js} +1 -1
- package/dist/assets/{player-overlays-BOsDheHc.js → player-overlays-Bthpd_DK.js} +1 -1
- package/dist/assets/{recycle-CBztR-tu.js → recycle-BX6tC5Kj.js} +1 -1
- package/dist/assets/remoteEntry-DJ-QvmdF.js +1 -0
- package/dist/assets/{scan-eye-DbKZpfih.js → scan-eye-g_G1zr8C.js} +1 -1
- package/dist/assets/{scissors-DCPxjz4N.js → scissors-DPmzGgFW.js} +1 -1
- package/dist/assets/{search-x-DUTyCa9Y.js → search-x-CsJ3H_wC.js} +1 -1
- package/dist/assets/{send-Boyf3SIM.js → send-BpC90RvW.js} +1 -1
- package/dist/assets/{settings-2-BkCzMVmr.js → settings-2-C6pa-cFa.js} +1 -1
- package/dist/assets/{speaker-nmF_x7US.js → speaker-Bm3mNOfG.js} +1 -1
- package/dist/assets/{src-CCd-7AXY.js → src-ASnW4RHZ.js} +3 -3
- package/dist/assets/{timer-reset-CkFpFTeE.js → timer-reset-DWjb5kqA.js} +1 -1
- package/dist/assets/{ungroup-BdveVhZq.js → ungroup-CzP2h8wq.js} +1 -1
- package/dist/assets/{unlink-Biu31rTD.js → unlink-BezflwNM.js} +1 -1
- package/dist/assets/{usb-B3PCv4C7.js → usb-DxAlRKBK.js} +1 -1
- package/dist/assets/{use-scenes-feed-CVqgJ1dp.js → use-scenes-feed-CkLZiYoX.js} +1 -1
- package/dist/assets/{use-stationary-objects-DBx5Fmhe.js → use-stationary-objects-NTMGbBMt.js} +1 -1
- package/dist/assets/useEventInvalidation-BviOkzyX.js +1 -0
- package/dist/assets/{useNodeUrlSelection-DD1VIgYL.js → useNodeUrlSelection-Bu7K2QJ7.js} +1 -1
- package/dist/assets/user-round-CVUJjDWY.js +1 -0
- package/dist/assets/{user-x-C34u0XHr.js → user-x-DRrbPPEj.js} +1 -1
- package/dist/assets/{video-c8H5Zs-y.js → video-BYsOgJ3d.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-U-kBwSSC.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-vl-v33Ir.js} +2 -2
- package/dist/index.html +10 -10
- package/dist/server/addon.js +10 -1
- package/package.json +1 -1
- package/dist/assets/Cluster-CdpU74GH.js +0 -1
- package/dist/assets/Identity-aeXxefik.js +0 -1
- package/dist/assets/Locations-LFHKGJj6.js +0 -3
- package/dist/assets/MyAccess-BrfWHy-Y.js +0 -2
- package/dist/assets/SessionsList-BFeOCT72.js +0 -2
- package/dist/assets/circle-slash-C8fnQfsA.js +0 -1
- package/dist/assets/client-CLcJeoH9.js +0 -358
- package/dist/assets/crop-CA89ugtQ.js +0 -1
- package/dist/assets/device-picker-model-BmKHpH-F.js +0 -1
- package/dist/assets/index-Q7OTRxZX.css +0 -2
- package/dist/assets/mount-BmKHpH-F.js +0 -1
- package/dist/assets/remoteEntry-DLWJ6wcK.js +0 -1
- package/dist/assets/useEventInvalidation-BmKHpH-F.js +0 -1
- package/dist/assets/user-round-C2xetSEU.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,V as i,W as a,b as o,o as s,q as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{It as d,Jr as f,Nt as p,Oi as m,Pn as h,Rn as g,Rr as _,Yi as v,_i as y,_n as b,ar as x,bi as S,bn as C,dn as w,dt as T,fn as E,ot as D,pi as O,un as k,yi as A,yn as j}from"./player-overlays-BOsDheHc.js";import{t as M}from"./hard-drive-download-W35XVpPS.js";import{t as ee}from"./memory-stick-DyJ5Tk7i.js";import{Qr as te,Xr as ne,Zr as re,ti as ie}from"./client-CLcJeoH9.js";import{$o as ae,Bn as N,Fc as oe,Go as se,Ht as ce,Ic as le,Lc as ue,M as de,Ns as fe,Pc as pe,Qo as me,Tt as he,U as ge,Ut as _e,Vs as ve,Wo as ye,Wt as P,Xl as be,Xs as xe,Xt as Se,Zn as Ce,Zo as we,cr as Te,dr as Ee,es as De,fu as Oe,il as ke,lr as Ae,ma as je,pu as F,rc as Me,ur as Ne,wt as Pe,yn as Fe}from"./src-CCd-7AXY.js";import{t as I}from"./useTranslation-Bc5yH9V9.js";import{Q as Ie}from"./index-Dbcd0nug.js";import{t as Le}from"./AdminPage-BXCcRjRj.js";import{t as Re}from"./NodeAddonsSettingsPanel-DW1CFRqr.js";import{f as ze,l as Be,m as Ve,u as He}from"./board-model-Bmts6hrg.js";import{t as L}from"./format-size-DIxKXxtj.js";import{n as Ue,t as We}from"./useNodeUrlSelection-DD1VIgYL.js";n();var Ge=`system-config-cluster`;function Ke(){return l(Fe,{trpc:D().trpcClient,addonId:`system-config`,nodeId:`hub`,sectionIds:[Ge],bare:!0})}function qe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Je(e){if(!qe(e))return null;let t=e.ticket;if(typeof t!=`string`||t.length===0)return null;let n=e.dashboardUrl;return typeof n==`string`&&n.length>0?{ticket:t,dashboardUrl:n}:{ticket:t}}function Ye(e){let t=e.trim();return!(t.length===0||t.includes(`/`)||t.includes(`?`)||t.includes(`#`)||t.includes(`@`)||t.includes(`:`))}function R(e){return e.startsWith(`172.17.`)}function Xe(e){let t=/^100\.(\d+)\./.exec(e);if(t===null)return!1;let n=Number(t[1]);return n>=64&&n<=127}function Ze(e){if(e.startsWith(`10.`)||e.startsWith(`192.168.`))return!0;let t=/^172\.(\d+)\./.exec(e);if(t===null)return!1;let n=Number(t[1]);return n>=16&&n<=31&&!R(e)}function Qe(e,t){if(typeof t==`string`&&Ye(t))return t.trim();let n=e.filter(e=>!e.includes(`:`)),r=n.find(e=>!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!R(e)&&!Xe(e)&&Ze(e));if(r!==void 0)return r;for(let e of n)if(!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!R(e))return e;return null}function $e(e){return`http://${e}:4444/`}function et(e,t){let n=new URL($e(e));return n.searchParams.set(`ticket`,t),n.toString()}function tt(){return window.open(`about:blank`,`_blank`)}function nt(e,t){return e===null||e.closed?!1:(e.location.href=t,!0)}function rt(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m`;let n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`}function it(e){return e===`running`?`running`:e===`crashed`||e===`failed`?`error`:`stopped`}var at=[`trace`,`debug`,`info`,`warn`,`error`];function ot({proc:e,nodeId:t,defaultExpanded:n,activePanel:i,onTogglePanel:a}){let o=e.services??[],s=o.length===1,[u,d]=c(s||n),[f,p]=c(null),[h,g]=c(`info`),_=e.name.includes(`(core)`),v=me(),x=ae(),S=De(),w=async e=>{p(e);try{await v.mutateAsync({nodeId:t,addonId:e})}catch(e){console.error(`Failed to restart addon:`,e)}finally{p(null)}},T=async()=>{p(e.name);try{await x.mutateAsync({nodeId:t,processName:e.name})}catch(e){console.error(`Failed to restart process:`,e)}finally{p(null)}},D=async n=>{let r=`${t}/${e.name}`;try{await S.mutateAsync({nodeId:r,level:n}),g(n)}catch(e){console.error(`Failed to set log level:`,e)}};return r(`div`,{className:`border border-border/50 rounded-lg overflow-hidden`,children:[r(`div`,{role:s?void 0:`button`,tabIndex:s?void 0:0,onClick:s?void 0:()=>d(!u),onKeyDown:s?void 0:e=>{(e.key===`Enter`||e.key===` `)&&d(!u)},className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 w-full px-3 py-2 bg-muted/20 transition-colors text-left select-none ${s?``:`hover:bg-muted/40 cursor-pointer`}`,children:[s?l(`span`,{className:`h-3 w-3 shrink-0`}):l(u?A:y,{className:`h-3 w-3 text-muted-foreground shrink-0`}),_?l(k,{className:`h-3.5 w-3.5 text-primary shrink-0`}):l(m,{className:`h-3.5 w-3.5 text-warning shrink-0`}),l(`span`,{className:`text-xs font-semibold min-w-0 flex-1 basis-full truncate sm:basis-auto`,children:e.name}),r(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:[`PID `,e.pid]}),l(de,{status:it(e.state),label:e.state}),r(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:[e.cpuPercent,`% CPU`]}),l(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:L(e.memoryRss)}),l(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:rt(e.uptimeSeconds)}),!_&&r(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[r(Te,{children:[l(Ee,{className:`text-[9px] px-1.5 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors font-mono`,title:`Set log level`,children:h}),l(Ae,{align:`end`,className:`min-w-[70px] py-0.5`,children:at.map(e=>l(Ne,{onClick:()=>D(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===h?`text-primary font-semibold`:``}`,children:e},e))})]}),l(`button`,{onClick:T,disabled:f===e.name,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart process`,children:l(b,{className:`h-3 w-3 ${f===e.name?`animate-spin`:``}`})})]})]}),u&&o.length>0&&l(`div`,{className:`divide-y divide-border/30`,children:o.map(e=>r(`div`,{children:[r(`div`,{className:`flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors`,children:[l(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`running`?`bg-success`:`bg-muted-foreground/30`}`}),l(`span`,{className:`text-xs font-medium flex-1 min-w-0 truncate`,children:e.addonId}),e.capabilities.length>0&&r(`div`,{className:`flex gap-1 flex-shrink-0`,children:[e.capabilities.slice(0,3).map(e=>l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-info/10 text-info truncate max-w-[80px]`,children:e},e)),e.capabilities.length>3&&r(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.capabilities.length-3]})]}),r(`div`,{className:`flex items-center gap-1 shrink-0`,children:[l(`button`,{onClick:()=>a(e.addonId,`logs`),className:`p-0.5 rounded transition-colors ${i?.addonId===e.addonId&&i.type===`logs`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:`Show logs for ${e.addonId}`,children:l(E,{className:`h-3 w-3`})}),l(`button`,{onClick:()=>a(e.addonId,`events`),className:`p-0.5 rounded transition-colors ${i?.addonId===e.addonId&&i.type===`events`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:`Show events for ${e.addonId}`,children:l(C,{className:`h-3 w-3`})}),l(`button`,{onClick:()=>w(e.addonId),disabled:f===e.addonId,className:`p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart ${e.addonId}`,children:l(b,{className:`h-3 w-3 ${f===e.addonId?`animate-spin`:``}`})})]})]}),i?.addonId===e.addonId&&i.type===`logs`&&l(`div`,{className:`border-t border-border/40 bg-muted/5`,children:l(he,{addonId:e.addonId,agentId:t,maxHeight:`max-h-48`,showFilters:!1,onClose:()=>a(e.addonId,`logs`)})}),i?.addonId===e.addonId&&i.type===`events`&&l(`div`,{className:`border-t border-border/40 bg-muted/5`,children:l(Pe,{addonId:e.addonId,category:`addon.*`,maxHeight:`max-h-48`,onClose:()=>a(e.addonId,`events`)})})]},e.addonId))}),u&&o.length===0&&l(`div`,{className:`px-3 py-2 pl-9 text-[10px] text-muted-foreground`,children:`No services`})]})}function st({nodeId:e,processes:t}){let[n,r]=c(null),i=(e,t)=>{r(n=>n?.addonId===e&&n.type===t?null:{addonId:e,type:t})};return t.length===0?l(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No processes on this node`}):l(`div`,{className:`space-y-2 py-1`,children:t.map((t,r)=>l(ot,{proc:t,nodeId:e,defaultExpanded:r===0,activePanel:n,onTogglePanel:i},t.name))})}var ct={system:0,managed:1,root:2};n();function lt(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:e<86400?`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`:`${Math.floor(e/86400)}d ${Math.floor(e%86400/3600)}h`}function ut(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function dt({nodeId:e}){let t=s(),n=F(`metrics.node-processes-snapshot`,t=>t.nodeId===e),{data:i}=se({nodeId:e}),o=n?.processes??i,c=a(()=>o?[...o]:[],[o]),u=a(()=>[{key:`classification`,header:`Class`,sortValue:e=>ct[e.classification],render:e=>l(`span`,{className:`inline-block rounded-full px-1.5 py-0.5 text-[10px] font-medium ${e.classification===`root`?`bg-info/20 text-info`:e.classification===`system`?`bg-foreground-subtle/20 text-foreground-subtle`:`bg-success/20 text-success`}`,children:e.classification})},{key:`pid`,header:`PID`,align:`right`,sortValue:e=>e.pid,render:e=>l(`span`,{className:`font-mono`,children:e.pid})},{key:`ppid`,header:`PPID`,align:`right`,sortValue:e=>e.ppid,render:e=>l(`span`,{className:`font-mono text-foreground-subtle`,children:e.ppid})},{key:`addonId`,header:`Addon`,sortValue:e=>e.addonId,render:e=>l(`span`,{className:`text-foreground-subtle text-[11px]`,children:e.addonId??`—`})},{key:`command`,header:`Command`,nowrap:!1,render:e=>l(`span`,{className:`font-mono text-[10px] text-foreground-subtle break-all`,children:ut(e.command)})},{key:`cpuPercent`,header:`CPU%`,align:`right`,sortValue:e=>e.cpuPercent,render:e=>e.cpuPercent.toFixed(1)},{key:`memoryRssBytes`,header:`RSS`,align:`right`,sortValue:e=>e.memoryRssBytes,render:e=>L(e.memoryRssBytes)},{key:`uptimeSec`,header:`Uptime`,align:`right`,sortValue:e=>e.uptimeSec,render:e=>l(`span`,{className:`text-foreground-subtle`,children:lt(e.uptimeSec)})}],[]);return r(`div`,{className:`space-y-4`,children:[l(`div`,{className:`flex items-start justify-end gap-4`,children:r(`button`,{type:`button`,onClick:()=>t.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[l(j,{className:`h-3 w-3`}),` Refresh`]})}),l(ce,{columns:u,rows:c,rowKey:e=>e.pid,minWidthPx:880,mobileMode:`cards`,maxBodyHeight:_e,emptyMessage:`Scanning…`})]})}var z={width:320,height:64},B=.8,V=Math.ceil(8*B-3)+1,H=z.width+34,U=z.height+V+1+11,ft=V+z.height+1+3+Math.ceil(8*B),pt=[1,2,5,10],mt=[1,2,4,8,16,32,64,128,256,512,1024],ht=[1,1.5,2,2.5,3,4,5],W=[4,3,5,2],gt=1e-9;function _t(e,t){if(!Number.isFinite(e)||e<=0)return!1;if(t===`bytes`){if(!Number.isInteger(e))return!1;let t=e/1024**Math.floor(Math.log(e)/Math.log(1024));return ht.some(e=>Math.abs(t-e)<gt)}let n=e/10**Math.floor(Math.log10(e));return ht.some(e=>Math.abs(n-e)<gt)}function vt(e,t,n){let r=0;for(let t of e)t!==null&&t>r&&(r=t);if(r<=t)return t;if(n===`bytes`){let e=1024**Math.floor(Math.log(r)/Math.log(1024));for(let t of mt){let n=t*e;if(n>=r)return n}return 1024*e}let i=10**Math.floor(Math.log10(r));for(let e of pt){let t=e*i;if(t>=r)return t}return 10*i}function yt(e,t){if(!Number.isFinite(e)||e<=0)return[];let n=W.find(n=>_t(e/n,t))??W[W.length-1],r=e/n,i=[];for(let e=1;e<=n;e++)i.push(r*e);return i}var bt=2.5;function xt(e){return e*bt}function G(e,t,n,r){if(e.length===0)return[];let i=e[0].atMs,a=e.at(-1).atMs-i,o=n<=0?1:n,s=r!==void 0&&r>0?r:null;return e.map((r,c)=>{let l=a>0?(r.atMs-i)/a*t.width:c/Math.max(1,e.length-1)*t.width,u=c>0?e[c-1]:void 0;return{x:l,y:r.value===null?null:t.height-Math.min(r.value,n)/o*t.height,gapBefore:s!==null&&u!==void 0&&r.atMs-u.atMs>s}})}function St(e){let t=[],n=!1;for(let r of e){if(r.y===null){n=!1;continue}r.gapBefore&&(n=!1),t.push(`${n?`L`:`M`}${r.x.toFixed(1)},${r.y.toFixed(1)}`),n=!0}return t.join(` `)}function Ct(e,t){let n=[],r=[],i=()=>{if(r.length<2){r=[];return}let e=r.map((e,t)=>`${t===0?`M`:`L`}${e.x.toFixed(1)},${e.top.toFixed(1)}`),t=[...r].reverse().map(e=>`L${e.x.toFixed(1)},${e.bottom.toFixed(1)}`);n.push(`${e.join(` `)} ${t.join(` `)} Z`),r=[]};for(let n=0;n<e.length;n++){let a=e[n],o=t[n];if(!a||!o||a.y===null||o.y===null){i();continue}(a.gapBefore||o.gapBefore)&&i(),r.push({x:a.x,top:a.y,bottom:o.y})}return i(),n.join(` `)}function wt(e,t,n=3){if(e.length<2||n<2)return[];let r=e[0].atMs,i=e.at(-1).atMs-r;if(i<=0)return[];let a=[];for(let e=0;e<n;e++){let o=e/(n-1);a.push({atMs:r+i*o,x:o*t.width,anchor:e===0?`start`:e===n-1?`end`:`middle`})}return a}function Tt(e){return e.length<2?0:Math.max(0,e.at(-1).atMs-e[0].atMs)}function Et(e){let t=[];for(let n=1;n<e.length;n++){let r=e[n];r.gapBefore&&t.push({fromX:e[n-1].x,toX:r.x})}return t}function Dt(e,t){if(e.length===0)return null;let n=0,r=1/0;for(let i=0;i<e.length;i++){let a=Math.abs(e[i].x-t);a<r&&(r=a,n=i)}return n}n();var K={main:`var(--color-chart-series-a)`,gc:`var(--color-chart-series-b)`},q=z,Ot={height:U};function kt({title:e,points:n,mainLabel:s,gcLabel:u,formatValue:d,emptyMessage:f,gapMs:p}){let m=i(),h=t(null),[g,_]=c(null),v=a(()=>{let e=n.map(e=>({atMs:e.atMs,value:e.main===null||e.gc===null?null:e.main+e.gc})),t=n.map(e=>({atMs:e.atMs,value:e.main})),r=vt(e.map(e=>e.value),25,`linear`),i=G(e,q,r,p),a=G(t,q,r,p),o=a.map(e=>({x:e.x,y:e.y===null?null:q.height,gapBefore:e.gapBefore}));return{max:r,ticks:yt(r,`linear`),upper:i,middle:a,base:o,gaps:Et(i),times:wt(e,q),spanMs:Tt(e)}},[n,p]),y=n.at(-1),b=g===null?void 0:n[g.index],x=b??y;return n.length===0||v.upper.every(e=>e.y===null)?l(Y,{title:e,children:l(zt,{message:f})}):l(Y,{title:e,legend:r(o,{children:[l(Rt,{color:K.main,label:s}),l(Rt,{color:K.gc,label:u})]}),readout:x&&x.main!==null&&x.gc!==null?r(o,{children:[b!==void 0&&l(Lt,{atMs:b.atMs,spanMs:v.spanMs}),l(X,{color:K.main,text:d(x.main)}),l(X,{color:K.gc,text:d(x.gc)})]}):null,children:r(`svg`,{ref:h,viewBox:`0 0 ${H} ${U}`,preserveAspectRatio:`none`,className:`w-full`,style:Ot,role:`img`,"aria-label":`${e}: ${s} and ${u} over time`,onMouseLeave:()=>_(null),onMouseMove:e=>{let t=e.currentTarget.getBoundingClientRect();if(t.width===0)return;let n=(e.clientX-t.left)/t.width*H-34,r=Dt(v.upper,n);r!==null&&_({index:r,xPx:v.upper[r].x})},children:[l(At,{ticks:v.ticks,max:v.max,formatValue:d}),l(It,{ticks:v.times,spanMs:v.spanMs}),r(`g`,{transform:`translate(34,${V})`,clipPath:`url(#${m})`,children:[l(`clipPath`,{id:m,children:l(`rect`,{x:0,y:0,width:q.width,height:q.height})}),l(jt,{spans:v.gaps}),l(`path`,{d:Ct(v.middle,v.base),fill:K.main,fillOpacity:.85}),l(`path`,{d:Ct(v.upper,v.middle),fill:K.gc,fillOpacity:.85,stroke:`var(--color-surface, transparent)`,strokeWidth:2}),l(`path`,{d:St(v.upper),fill:`none`,stroke:K.gc,strokeWidth:2}),g!==null&&l(`line`,{x1:g.xPx,x2:g.xPx,y1:0,y2:q.height,stroke:`currentColor`,strokeWidth:1,className:`text-foreground-subtle`})]})]})})}function J({title:e,points:n,formatValue:i,emptyMessage:s,axisFloor:u,axisScale:d=`linear`,gapMs:f}){let p=t(null),[m,h]=c(null),g=a(()=>{let e=vt(n.map(e=>e.value),u,d),t=G(n,q,e,f);return{max:e,ticks:yt(e,d),projected:t,gaps:Et(t),times:wt(n,q),spanMs:Tt(n)}},[n,u,d,f]),_=m===null?void 0:n[m.index],v=_??n.at(-1)??void 0;return n.length===0||g.projected.every(e=>e.y===null)?l(Y,{title:e,children:l(zt,{message:s})}):l(Y,{title:e,readout:v&&v.value!==null?r(o,{children:[_!==void 0&&l(Lt,{atMs:_.atMs,spanMs:g.spanMs}),l(X,{color:K.main,text:i(v.value)})]}):null,children:r(`svg`,{ref:p,viewBox:`0 0 ${H} ${U}`,preserveAspectRatio:`none`,className:`w-full`,style:Ot,role:`img`,"aria-label":e,onMouseLeave:()=>h(null),onMouseMove:e=>{let t=e.currentTarget.getBoundingClientRect();if(t.width===0)return;let n=(e.clientX-t.left)/t.width*H-34,r=Dt(g.projected,n);r!==null&&h({index:r,xPx:g.projected[r].x})},children:[l(At,{ticks:g.ticks,max:g.max,formatValue:i}),l(It,{ticks:g.times,spanMs:g.spanMs}),r(`g`,{transform:`translate(34,${V})`,children:[l(jt,{spans:g.gaps}),l(`path`,{d:St(g.projected),fill:`none`,stroke:K.main,strokeWidth:2}),m!==null&&l(`line`,{x1:m.xPx,x2:m.xPx,y1:0,y2:q.height,stroke:`currentColor`,strokeWidth:1,className:`text-foreground-subtle`})]})]})})}function At({ticks:e,max:t,formatValue:n}){let i=t<=0?1:t;return l(`g`,{className:`text-foreground-subtle`,children:e.map(e=>{let t=V+q.height-e/i*q.height;return r(`g`,{children:[l(`line`,{x1:34,x2:34+q.width,y1:t,y2:t,stroke:`currentColor`,strokeWidth:.5,strokeOpacity:.3}),l(`text`,{x:0,y:t+3,fontSize:8,fill:`currentColor`,children:n(e)})]},e)})})}function jt({spans:e}){return e.length===0?null:l(`g`,{className:`text-foreground-subtle`,children:e.map(e=>l(`rect`,{x:e.fromX,y:0,width:Math.max(1,e.toX-e.fromX),height:q.height,fill:`currentColor`,fillOpacity:.12,children:l(`title`,{children:`No samples in this interval — nothing was measured, nothing is drawn.`})},`${e.fromX}-${e.toX}`))})}var Mt=10*6e4,Nt={hour:`2-digit`,minute:`2-digit`},Pt={hour:`2-digit`,minute:`2-digit`,second:`2-digit`};function Ft(e,t){return new Date(e).toLocaleTimeString(void 0,t<Mt?Pt:Nt)}function It({ticks:e,spanMs:t}){return e.length===0?null:l(`g`,{className:`text-foreground-subtle`,children:e.map(e=>l(`text`,{x:34+e.x,y:ft,fontSize:8,textAnchor:e.anchor,fill:`currentColor`,children:Ft(e.atMs,t)},e.atMs))})}function Lt({atMs:e,spanMs:t}){return l(`span`,{className:`text-[10px] tabular-nums text-foreground-subtle`,children:Ft(e,t)})}function Y({title:e,legend:t,readout:n,children:i}){return r(`div`,{className:`min-w-0`,children:[r(`div`,{className:`flex items-baseline justify-between gap-2 mb-1`,children:[l(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:e}),l(`div`,{className:`flex items-center gap-2`,children:n})]}),i,t&&l(`div`,{className:`flex items-center gap-3 mt-1`,children:t})]})}function Rt({color:e,label:t}){return r(`span`,{className:`inline-flex items-center gap-1 text-[9px] text-foreground-subtle`,children:[l(`span`,{className:`inline-block h-2 w-2 rounded-[2px]`,style:{backgroundColor:e}}),t]})}function X({color:e,text:t}){return r(`span`,{className:`inline-flex items-center gap-1 text-[11px] tabular-nums text-foreground`,children:[l(`span`,{className:`inline-block h-2 w-2 rounded-[2px]`,style:{backgroundColor:e}}),t]})}function zt({message:e}){return l(`div`,{className:`h-16 flex items-center justify-center rounded border border-dashed border-border text-[10px] text-foreground-subtle text-center px-2`,children:e})}function Bt(e,t){let n=e.at(-1);return n===void 0?[t]:t.atMs>n.atMs?[...e,t]:e.some(e=>e.atMs===t.atMs)?e:[...e,t].toSorted((e,t)=>e.atMs-t.atMs)}function Vt(e,t,n,r){let i=e.get(t),a=Bt(i?.points??[],r);if(i!==void 0&&a===i.points)return e;let o=new Map(e);return o.set(t,{key:t,kind:n,points:a.slice(Math.max(0,a.length-720))}),o}function Ht(e,t,n){let r=e;for(let e of ie(t,n))r=Vt(r,e.key,e.kind,e.point);return r}function Ut(e,t){let n=e;for(let e of t)for(let t of e.points)n=Vt(n,e.key,e.kind,t);return n}function Wt(e){let t=null;for(let n of e.values()){let e=n.points.at(-1);e!==void 0&&(t===null||e.atMs>t)&&(t=e.atMs)}return t}var Gt=12e4;function Kt(e,t){return e===null?!1:t-e>Gt}function qt(e){let t=e=>{let t=e.points.at(-1);return t===void 0?-1:t.cpuMainPercent!==null&&t.cpuGcPercent!==null?t.cpuMainPercent+t.cpuGcPercent:t.cpuLifetimePercent};return[...e.values()].toSorted((e,n)=>{let r=t(n)-t(e);return r===0?e.key.localeCompare(n.key):r})}function Jt(e){for(let t of e.values()){let e=t.points.at(-1);if(e&&e.cpuMainPercent!==null)return!0}return!1}var Yt={key:`cpu`,dir:`desc`};function Xt(e){let t=e.points.at(-1);return t===void 0?null:t.cpuMainPercent!==null&&t.cpuGcPercent!==null?t.cpuMainPercent+t.cpuGcPercent:t.cpuLifetimePercent}function Zt(e){return e.points.at(-1)?.memoryRssBytes??null}function Qt(e,t,n){let r=n.trim().toLowerCase();return r===``?!0:e.toLowerCase().includes(r)||t.toLowerCase().includes(r)}function $t(e,t){return t===`memory`?Zt(e):Xt(e)}function en(e,t,n){let r=e.filter(e=>t.selectedKeys.size>0&&!t.selectedKeys.has(e.key)?!1:Qt(n(e),e.key,t.search)),i=(e,t)=>e.key.localeCompare(t.key);return[...r].toSorted((e,r)=>{if(t.sort.key===`name`){let a=n(e).localeCompare(n(r)),o=t.sort.dir===`asc`?a:-a;return o===0?i(e,r):o}let a=$t(e,t.sort.key),o=$t(r,t.sort.key);if(a===null&&o===null)return i(e,r);if(a===null)return 1;if(o===null)return-1;let s=t.sort.dir===`desc`?o-a:a-o;return s===0?i(e,r):s})}n();function tn(e,n=720){let r=F(`metrics.node-processes-snapshot`,t=>t.nodeId===e),[i,a]=c(new Map),[o,s]=c(void 0),l=t(null),{data:d,isPending:f}=ye({forNodeId:e,sinceMs:o,maxPoints:n});u(()=>{d!==void 0&&a(e=>{let t=Ut(e,d.series);return l.current=Wt(t),t})},[d]);let p=r?.timestamp;u(()=>{r==null||p===void 0||(Kt(l.current,p)&&s(l.current??0),a(e=>{let t=Ht(e,r.processes,p);return l.current=Wt(t),t}))},[p]),u(()=>{a(new Map),s(void 0),l.current=null},[e]);let m=0;for(let e of i.values())m=Math.max(m,e.points.length);return{series:qt(i),sampleCount:m,threadSplitAvailable:Jt(i),loadingRetained:f,durable:d?.durable??null,bucketMs:d?.bucketMs??null,cadenceMs:d?.cadenceMs??null,retainedSamples:d?.retainedSamples??null}}var nn=`__unclaimed__`;function rn(e,t){return{kind:e,deviceId:t,cpu:0,cpuKnown:!0,rss:0,rssKnown:!0,count:0,roles:new Set}}function an(e,t){return{key:e,kind:t.kind,deviceId:t.deviceId,cpuSeconds:t.cpuKnown?Math.round(t.cpu*100)/100:null,rssBytes:t.rssKnown?t.rss:null,unitCount:t.count,roles:[...t.roles].sort()}}function on(e,t){let n=new Map,r=new Set;for(let t of e){t.pid!==void 0&&r.add(t.pid);let e=t.deviceId!==null&&t.attribution!==`unattributable`,i=e?`device:${t.deviceId}`:`shared:${t.role}`,a=n.get(i)??rn(e?`camera`:`shared`,e?t.deviceId:null);a.count+=1,a.roles.add(t.role),t.cpuSeconds===void 0?a.cpuKnown=!1:a.cpu+=t.cpuSeconds,t.rssBytes===void 0?a.rssKnown=!1:a.rss+=t.rssBytes,n.set(i,a)}let i=[...n.entries()].map(([e,t])=>an(e,t));if(t===void 0)return i;let a=t.filter(e=>!r.has(e.pid));if(a.length===0)return i;let o=rn(`unclaimed`,null);for(let e of a)o.count+=1,o.rss+=e.memoryRssBytes;return o.cpuKnown=!1,[...i,an(nn,o)]}var sn=[{family:`decode`,attribution:`measured`,unit:`one forked decode-worker child per decode SESSION`,perCamera:!0,wiredToday:!0,missingLink:``,evidence:[`packages/addon-pipeline/src/session-decode/fork-decode-worker.ts:118`,`packages/addon-pipeline/src/session-decode/fork-decode-worker.ts:131`,`packages/addon-pipeline/src/pipeline-runner/index.ts:2765`,`packages/types/src/process/child-cost-registry.ts:188`]},{family:`transcode`,attribution:`measured`,unit:`one ffmpeg child per (camera, encode plan)`,perCamera:!0,wiredToday:!0,missingLink:``,evidence:[`packages/addon-pipeline/src/stream-broker/stream-broker/egress-transcode-manager.ts:960`,`packages/addon-pipeline/src/stream-broker/stream-broker/transcode-egress.ts:282`,`packages/addon-pipeline/src/stream-broker/stream-broker/transcode-egress.ts:324`,`packages/types/src/ffmpeg/sharing-key.ts:139`]},{family:`recording`,attribution:`measured`,unit:`one passthrough ffmpeg per (camera, profile)`,perCamera:!0,wiredToday:!0,missingLink:``,evidence:[`packages/addon-pipeline/src/recorder/addon/segment-writer.ts:33`,`packages/addon-pipeline/src/recorder/addon/segment-writer.ts:217`,`packages/addon-pipeline/src/recorder/addon/segment-writer.ts:279`,`packages/addon-pipeline/src/recorder/addon/recording-controller.ts:1710`]},{family:`detection`,attribution:`accounted`,unit:`a SHARED inference pool per (node, runtime, device) — no per-camera process`,perCamera:!1,wiredToday:!0,missingLink:"Nothing is missing for COUNTING — per-camera inference milliseconds, processed/shed frames and bytes-to-pool are already accumulated. What is missing is any basis for CPU seconds: `deviceId` reaches the pool as a diagnostic label and selects nothing, so cost can only ever be apportioned, never measured. Since 2026-08-27 the pool DECLARES this itself, contributing `deviceId: null` + `attribution: unattributable` rather than leaving an observer to infer it — the renunciation is data, and it is still refused by the chart gate.",evidence:[`packages/addon-pipeline/src/detection-pipeline/provider.ts:540`,`packages/addon-pipeline/src/detection-pipeline/engine/shared-inference-pool.ts:413`,`packages/types/src/interfaces/inference-engine.ts:24`,`packages/addon-pipeline/src/pipeline-runner/timing-sampler.ts:63`,`packages/addon-pipeline/src/pipeline-runner/runner.ts:353`,`packages/addon-pipeline/src/pipeline-runner/runner.ts:849`,`packages/addon-pipeline/src/pipeline-runner/frame-lazy-metrics.ts:100`]},{family:`streaming`,attribution:`measured`,unit:"one StreamBroker per `${deviceId}/${camStreamId}`, with an exact RTP ring byte counter",perCamera:!0,wiredToday:!1,missingLink:"The ffmpeg-backed ingest is now reported per camera, but that is the minority path. `rtpRingBytes` — the exact figure for the in-process case — is maintained on every push and drop and is still private and absent from `getStats()`. The three `EncodedRingBuffer`s track packets and duration and have no byte accumulator at all; the only byte figure they offer is `preRollBudgetBytes`, which is a BUDGET, not an occupancy.",evidence:[`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:2895`,`packages/addon-pipeline/src/stream-broker/rtsp/ffmpeg-push-reader.ts:189`,`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:494`,`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:498`,`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:2505`,`packages/addon-pipeline/src/stream-broker/stream-broker/pre-roll.ts:269`]}];function cn(e){return e.attribution===`measured`&&e.wiredToday}function ln(){let e=new Set;for(let t of sn)cn(t)&&e.add(t.family);return e}var un=ln();function dn(e){return!un.has(e.role)||e.deviceId===null?!1:e.attribution===`measured`}function fn(e){return`${e.addonId}${e.role}${e.unit}${e.pid??`-`}`}function pn(){return{cpuSeconds:0,cpuKnown:!0,rssBytes:0,rssKnown:!0,unitCount:0,roles:new Set}}function mn(e,t,n){if(t.cpuSeconds===void 0)return null;if(e===void 0)return t.startedAtMs===void 0||t.startedAtMs<n?null:t.cpuSeconds;if(e.cpuSeconds===void 0||e.startedAtMs===void 0||t.startedAtMs===void 0||e.startedAtMs!==t.startedAtMs)return null;let r=t.cpuSeconds-e.cpuSeconds;return r<0?null:r}function hn(e){return Math.round(e*10)/10}function gn(e,t){let n=t.atMs-e.atMs;if(n<=0)return[];let r=n/1e3,i=new Map;for(let t of e.entries)dn(t)&&i.set(fn(t),t);let a=new Map,o=new Set;for(let n of t.entries){if(!dn(n)||n.deviceId===null)continue;let t=fn(n);o.add(t);let r=a.get(n.deviceId)??pn();r.unitCount+=1,r.roles.add(n.role);let s=mn(i.get(t),n,e.atMs);s===null?r.cpuKnown=!1:r.cpuSeconds+=s,n.rssBytes===void 0?r.rssKnown=!1:r.rssBytes+=n.rssBytes,a.set(n.deviceId,r)}for(let[e,t]of i){if(o.has(e)||t.deviceId===null)continue;let n=a.get(t.deviceId);n!==void 0&&(n.cpuKnown=!1)}return[...a.entries()].map(([e,n])=>({deviceId:e,point:{atMs:t.atMs,cpuPercent:n.cpuKnown?hn(n.cpuSeconds/r*100):null,rssBytes:n.rssKnown?n.rssBytes:null,unitCount:n.unitCount,roles:[...n.roles].toSorted()}}))}function _n(e,t){if(t.length===0)return e;let n=new Map(e);for(let e of t){let t=n.get(e.deviceId),r=t?.points.at(-1);if(r!==void 0&&e.point.atMs<=r.atMs)continue;let i=[...t?.points??[],e.point];n.set(e.deviceId,{deviceId:e.deviceId,points:i.slice(Math.max(0,i.length-720))})}return n}function vn(e){let t=e=>{for(let t=e.points.length-1;t>=0;t--){let n=e.points[t]?.cpuPercent;if(n!=null)return n}return-1};return[...e.values()].toSorted((e,n)=>{let r=t(n)-t(e);return r===0?e.deviceId-n.deviceId:r})}function yn(e){let t=e.indexOf(`@`);return t===-1?{addonId:e,nodeId:null}:{addonId:e.slice(0,t),nodeId:e.slice(t+1)}}function bn(e,t){let n=yn(e);return n.nodeId===null?t.isHub:n.nodeId===t.nodeId}function Z(e,t){return e.filter(e=>bn(e.addonId,t))}n();function xn(e){let n=F(`metrics.node-processes-snapshot`,t=>t.nodeId===e.nodeId),r=ke(void 0,{staleTime:1/0,refetchOnWindowFocus:!1}),[i,a]=c(new Map),o=t(null),s=t(r.refetch);s.current=r.refetch;let l=n?.timestamp;u(()=>{l!==void 0&&s.current()},[l]),u(()=>{a(new Map),o.current=null},[e.nodeId,e.isHub]);let d=r.data,f=r.dataUpdatedAt;u(()=>{if(d===void 0||f===0)return;let t={atMs:f,entries:Z(d,e)},n=o.current;if(o.current=t,n===null)return;let r=gn(n,t);r.length!==0&&a(e=>_n(e,r))},[d,f,e.nodeId,e.isHub]);let p=d===void 0?[]:Z(d,e),m=n?.processes,h=on(p,m);return{series:vn(i),unclaimed:h.find(e=>e.kind===`unclaimed`)??null,loading:r.isPending,error:r.error===null?null:r.error.message}}function Sn(e){let t=new Map;for(let n of e){let e=n.name?.trim();e===void 0||e===``||t.set(n.id,e)}return t}var Cn=25,wn=64*1024*1024,Tn=1e4;function En({scope:e,cadenceMs:t}){let{t:n}=I(),i=xn(e),{data:a=[]}=je({isCamera:!0,projection:`slim`}),o=Sn(a),s=xt(t??Tn);return r(`section`,{className:`space-y-3`,children:[i.error!==null&&r(`div`,{className:`flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[l(p,{className:`h-3 w-3 mt-0.5 shrink-0`}),l(`span`,{children:n(`cameraLoad.readFailed`,`Could not read the load contributions: {{error}}. This is a failed read, NOT an idle cluster.`,{error:i.error})})]}),l(On,{unclaimed:i.unclaimed}),i.series.length===0&&i.error===null&&l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:i.loading?n(`cameraLoad.loading`,`Reading what the addons report…`):n(`cameraLoad.waitingWindow`,`No per-camera window yet.`)}),l(`div`,{className:`space-y-3`,children:i.series.map(e=>r(`div`,{className:`rounded-lg border border-border p-3`,children:[r(`div`,{className:`flex items-baseline justify-between gap-2 mb-2`,children:[l(Dn,{deviceId:e.deviceId,name:o.get(e.deviceId)}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`cameraLoad.unitCount`,`{{count}} unit(s): {{roles}}`,{count:e.points.at(-1)?.unitCount??0,roles:(e.points.at(-1)?.roles??[]).join(`, `)})})]}),r(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[l(J,{title:n(`cameraLoad.cpuTitle`,`CPU % of one core (delta)`),points:e.points.map(e=>({atMs:e.atMs,value:e.cpuPercent})),formatValue:e=>`${e.toFixed(1)}%`,axisFloor:Cn,gapMs:s,emptyMessage:n(`cameraLoad.cpuUnavailable`,`No measurable window yet.`)}),l(J,{title:n(`cameraLoad.memoryTitle`,`Memory RSS`),points:e.points.map(e=>({atMs:e.atMs,value:e.rssBytes})),formatValue:L,axisFloor:wn,axisScale:`bytes`,gapMs:s,emptyMessage:n(`cameraLoad.memoryUnavailable`,`No memory reported.`)})]})]},e.deviceId))})]})}function Dn({deviceId:e,name:t}){let{t:n}=I();return t===void 0?l(`span`,{className:`text-xs font-medium text-foreground`,children:n(`cameraLoad.deviceLabel`,`Camera {{deviceId}}`,{deviceId:e})}):r(`span`,{className:`flex items-baseline gap-1.5 min-w-0`,children:[l(`span`,{className:`text-xs font-medium text-foreground truncate`,children:t}),r(`span`,{className:`shrink-0 text-[10px] font-mono text-foreground-subtle`,children:[`#`,e]})]})}function On({unclaimed:e}){let{t}=I();return e===null||e.unitCount===0?null:l(`div`,{className:`flex items-center gap-2`,children:l(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full bg-warning/10 text-warning font-medium tabular-nums`,children:t(`cameraLoad.unclaimedBadge`,`{{count}} unclaimed · {{rss}}`,{count:e.unitCount,rss:e.rssBytes===null?`—`:L(e.rssBytes)})})})}n();var kn=256*1024*1024,An=1e4;function jn({nodeId:e,isHub:t}){let{t:n}=I(),{series:i,sampleCount:o,threadSplitAvailable:s,loadingRetained:u,bucketMs:d,cadenceMs:f}=tn(e),[m,h]=c(``),[g,_]=c(new Set),[v,y]=c(Yt),b=e=>e.key===`__root__`?n(`clusterLoad.bucketRoot`,`Node supervisor`):e.key===`__unattributed__`?n(`clusterLoad.bucketUnattributed`,`Unattributed processes`):e.key,x=xt(d??f??An),S=a(()=>en(i,{search:m,selectedKeys:g,sort:v},b),[i,m,g,v]),C=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return r(`div`,{className:`space-y-4`,children:[l(Mn,{bucketMs:d,cadenceMs:f}),!s&&o>0&&r(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/40 bg-warning/5 px-3 py-2 text-[11px] text-warning`,children:[l(p,{className:`h-3 w-3 mt-0.5 shrink-0`}),l(`span`,{children:n(`clusterLoad.noThreadSplit`,`No thread-level CPU split on this node — /proc/<pid>/task is Linux-only, and the first sample after a restart has no window to measure. CPU below falls back to the ps lifetime AVERAGE, which is not a rate.`)})]}),o===0&&l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:u?n(`clusterLoad.loadingRetained`,`Reading the retained series from this node…`):n(`clusterLoad.waitingFirstSample`,`No retained samples for this node — waiting for the next snapshot (up to 20s). The chart needs two to draw a rate.`)}),i.length>0&&r(`div`,{className:`space-y-2`,children:[r(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(`label`,{className:`relative flex-1 min-w-[160px]`,children:[l(w,{className:`pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-foreground-subtle`}),l(`input`,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:n(`clusterLoad.searchPlaceholder`,`Find a runner…`),"aria-label":n(`clusterLoad.searchLabel`,`Find a runner`),className:`w-full rounded border border-border bg-background py-1 pl-7 pr-2 text-[11px] text-foreground placeholder:text-foreground-subtle`})]}),l(Nn,{sort:v,onChange:y})]}),r(`div`,{className:`flex flex-wrap items-center gap-1`,children:[i.map(e=>{let t=g.has(e.key);return l(`button`,{type:`button`,"aria-pressed":t,onClick:()=>C(e.key),className:`rounded-full border px-2 py-0.5 text-[10px] transition-colors ${t?`border-primary bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground`}`,children:b(e)},e.key)}),g.size>0&&r(`button`,{type:`button`,onClick:()=>_(new Set),className:`inline-flex items-center gap-1 rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground`,children:[l(T,{className:`h-2.5 w-2.5`}),n(`clusterLoad.clearFilter`,`All runners`)]})]})]}),i.length>0&&S.length===0&&l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:n(`clusterLoad.noMatches`,`No runner matches this search on {{count}} present. The node is reporting — the filter is hiding them.`,{count:i.length})}),l(`div`,{className:`space-y-3`,children:S.map(e=>r(`div`,{className:`rounded-lg border border-border p-3`,children:[r(`div`,{className:`flex items-baseline justify-between gap-2 mb-2`,children:[l(`span`,{className:`text-xs font-medium text-foreground`,children:b(e)}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`clusterLoad.processCount`,`{{count}} process(es)`,{count:e.points.at(-1)?.processCount??0})})]}),r(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[l(kt,{title:s?n(`clusterLoad.cpuTitle`,`CPU % of one core`):n(`clusterLoad.cpuTitleLifetime`,`CPU % (ps lifetime average)`),mainLabel:n(`clusterLoad.seriesMain`,`Main threads`),gcLabel:n(`clusterLoad.seriesGc`,`GC / V8 helpers`),points:e.points.map(e=>({atMs:e.atMs,main:e.cpuMainPercent,gc:e.cpuGcPercent})),formatValue:e=>`${e.toFixed(0)}%`,gapMs:x,emptyMessage:n(`clusterLoad.cpuUnavailable`,`No thread split on this node. Lifetime average: {{avg}}%`,{avg:(e.points.at(-1)?.cpuLifetimePercent??0).toFixed(1)})}),l(J,{title:n(`clusterLoad.memoryTitle`,`Memory RSS`),points:e.points.map(e=>({atMs:e.atMs,value:e.memoryRssBytes})),formatValue:L,axisFloor:kn,axisScale:`bytes`,gapMs:x,emptyMessage:n(`clusterLoad.memoryUnavailable`,`No memory samples yet.`)})]})]},e.key))}),l(En,{scope:{nodeId:e,isHub:t},cadenceMs:f})]})}function Mn({bucketMs:e,cadenceMs:t}){let{t:n}=I();return e===null?null:l(`p`,{className:`text-[10px] text-foreground-subtle`,children:t!==null&&e>t?n(`clusterLoad.captionBucket`,`1 point = {{bucket}}s (bucket MAXIMUM, not a mean)`,{bucket:Math.round(e/1e3)}):n(`clusterLoad.captionRaw`,`1 point = 1 snapshot`)})}function Nn({sort:e,onChange:t}){let{t:n}=I(),i=[{key:`cpu`,label:n(`clusterLoad.sortCpu`,`CPU`)},{key:`memory`,label:n(`clusterLoad.sortMemory`,`Memory`)},{key:`name`,label:n(`clusterLoad.sortName`,`Name`)}];return r(`div`,{className:`flex items-center gap-1`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`clusterLoad.sortBy`,`Sort by`)}),i.map(n=>{let i=e.key===n.key;return r(`button`,{type:`button`,"aria-pressed":i,onClick:()=>t(i?{key:n.key,dir:e.dir===`desc`?`asc`:`desc`}:{key:n.key,dir:n.key===`name`?`asc`:`desc`}),className:`rounded border px-1.5 py-0.5 text-[10px] transition-colors ${i?`border-primary bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground`}`,children:[n.label,i&&(e.dir===`desc`?` ↓`:` ↑`)]},n.key)})]})}var Pn=`No per-node settings on this node. Every other setting these addons expose is one value for the whole cluster — edit those in System → Settings, not here.`;function Fn({nodeId:e,addonIds:t}){return t.length===0?l(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No addons on this node`}):l(`div`,{className:`w-full py-2`,children:l(Re,{nodeId:e,addonIds:t,level:`global`,fieldScope:`perNode`,emptyMessage:Pn,selfTabbed:!0})})}n();function In({nodeId:e,addons:t}){let n=s(),{data:r,isLoading:i}=fe({nodeId:e}),o=a(()=>{let e=new Map;for(let n of t)for(let t of n.capabilities){let r=e.get(t)??[];r.push(n.id),e.set(t,r)}return[...e.entries()].toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({capName:e,providers:t}))},[t]),c=Me({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCapabilityBindings`]]})}});return o.length===0?l(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No capabilities on this node`}):l(ce,{columns:[{key:`capName`,header:`Capability`,width:`w-1/2`,sortValue:e=>e.capName,render:e=>l(`span`,{className:`font-medium`,children:e.capName})},{key:`provider`,header:`Bound provider`,render:t=>{let n=r?.[t.capName]??t.providers[0]??``,a=t.providers.length===1;return l(`select`,{value:n,onChange:n=>c.mutate({nodeId:e,capName:t.capName,addonId:n.target.value}),disabled:a||c.isPending||i,className:`w-full rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-60`,title:a?`Only one provider installed — choice becomes available once a second addon registers this capability`:void 0,children:t.providers.map(e=>l(`option`,{value:e,children:e},e))})}}],rows:o,rowKey:e=>e.capName,minWidthPx:520,mobileMode:`cards`,maxBodyHeight:_e})}n();function Ln(e){if(e==null)return`—`;let t=Math.floor(e/1e3),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60);return n>0?`${n}d ${r}h ${i}m`:r>0?`${r}h ${i}m`:`${i}m`}function Rn(e){let[t,n]=c(!1),[i,a]=c(e.name),o=s(),u=we({onSuccess:()=>{o.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}}),d=(e.localIps??[]).filter(e=>!e.includes(`:`)),f=(e.localIps??[]).filter(e=>e.includes(`:`)),p=async()=>{if(!i.trim()||i===e.name){n(!1);return}try{await u.mutateAsync({nodeId:e.nodeId,name:i.trim()}),n(!1)}catch(e){console.error(`Rename failed:`,e)}},m=[[`Node ID`,l(`span`,{className:`font-mono text-xs`,children:e.nodeId})],[`Display Name`,t?r(`div`,{className:`flex items-center gap-1.5`,children:[l(`input`,{type:`text`,className:`flex-1 px-2 py-0.5 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary`,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&p(),e.key===`Escape`&&n(!1)},disabled:u.isPending,autoFocus:!0}),l(`button`,{onClick:()=>void p(),disabled:u.isPending,className:`p-0.5 text-success hover:bg-success/10 rounded`,title:`Save`,children:l(S,{className:`h-3.5 w-3.5`})}),l(`button`,{onClick:()=>n(!1),className:`p-0.5 text-muted-foreground hover:bg-muted rounded`,title:`Cancel`,children:l(T,{className:`h-3.5 w-3.5`})})]}):r(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-xs`,children:e.name}),!e.isHub&&l(`button`,{onClick:()=>{a(e.name),n(!0)},className:`p-0.5 text-muted-foreground hover:text-primary rounded`,title:`Rename`,children:l(h,{className:`h-3 w-3`})})]})],[`Hostname`,l(`span`,{className:`text-xs`,children:e.hostname})],[`Role`,e.isHub?l(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium`,children:`Hub`}):l(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-medium`,children:`Agent`})],[`Root Package`,e.rootPackage?r(`span`,{className:`font-mono text-xs`,children:[e.rootPackage.name,`@`,e.rootPackage.version]}):l(`span`,{className:`text-xs text-muted-foreground`,children:`—`})],[`Platform`,r(`span`,{className:`text-xs`,children:[e.platform,` / `,e.arch]})],[`CPU`,r(`span`,{className:`text-xs`,children:[e.cpuModel??`—`,` (`,e.cpuCores,` cores)`]})],[`Memory`,l(`span`,{className:`text-xs`,children:e.memoryMB>0?`${(e.memoryMB/1024).toFixed(1)} GB`:`—`})],[`Uptime`,l(`span`,{className:`text-xs`,children:Ln(e.uptime)})],[`Engines`,e.engines.length>0?l(`div`,{className:`flex flex-wrap gap-1`,children:e.engines.map(e=>l(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium`,children:e},e))}):l(`span`,{className:`text-xs text-muted-foreground`,children:`—`})]];return d.length>0&&m.push([`IPv4`,l(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map((e,t)=>l(`span`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:e},`${e}-${t}`))})]),f.length>0&&m.push([`IPv6`,l(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map((e,t)=>l(`span`,{className:`font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted truncate max-w-[280px]`,title:e,children:e},`${e}-${t}`))})]),l(`div`,{className:`py-2`,children:l(`table`,{className:`w-full text-sm`,children:l(`tbody`,{children:m.map(([e,t],n)=>r(`tr`,{className:n%2==0?`bg-muted/20`:``,children:[l(`td`,{className:`py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap`,children:e}),l(`td`,{className:`py-1.5 px-2`,children:t})]},e))})})})}n();function zn({nodeId:e,value:t,detectedHosts:n,status:i,errorMessage:a,onCommit:o}){let[s,d]=c(t??``);u(()=>{d(t??``)},[t]);let f=n[0],p=f===void 0?`auto-detect`:`auto: ${f}`,m=i===`pending`,h=s.trim(),g=h!==(t??``),_=g&&!m,v=()=>{_&&o(e,h.length>0?h:null)};return r(`div`,{className:`flex items-center gap-1.5`,children:[l(be,{"aria-label":`Reachable host for ${e}`,type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:p,value:s,disabled:m,onChange:e=>d(e.target.value),onBlur:v,onKeyDown:e=>{e.key===`Enter`&&v(),e.key===`Escape`&&d(t??``)},className:`w-36`}),r(N,{variant:`outline`,size:`sm`,onClick:v,disabled:!_,"aria-label":`Save reachable host for ${e}`,title:`Save reachable host`,children:[m?l(x,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):l(S,{className:`h-3 w-3`,"aria-hidden":`true`}),`Save`]}),!g&&!m&&i===`success`&&l(S,{className:`h-3.5 w-3.5 shrink-0 text-success`,"aria-label":`Saved`,role:`img`}),i===`error`&&l(`span`,{title:a??`Failed to save reachable host`,children:l(O,{className:`h-3.5 w-3.5 shrink-0 text-danger`,"aria-label":a??`Failed to save reachable host`,role:`img`})})]})}n();function Bn(e){let t=re.safeParse(ze(e,`color`));return t.success?t.data:null}function Vn(e,t){return t.variables?.agentNodeId===e?t.isPending?`pending`:t.isError?`error`:t.isSuccess?`success`:`idle`:`idle`}function Hn({nodeId:e,detectedHosts:t}){let{t:n}=I(),i=s(),o=ve(void 0),c=xe({onSuccess:()=>Be(i)}),u=xe({onSuccess:()=>Be(i)}),d=a(()=>o.data?.find(t=>t.nodeId===e)?.settings,[o.data,e]),f=Bn(d)??(o.isLoading?null:te(e)),p=Ve(d,`reachableHost`),m=Vn(e,c),h=m===`error`?He(c.error):null,g=t.filter(e=>!e.includes(`:`)),_=t=>{t!==f&&u.mutate({agentNodeId:e,color:t})};return r(`div`,{className:`rounded-lg border border-border bg-surface/40 divide-y divide-border px-3`,children:[l(P,{label:n(`nodes.general.nodeColour`,`Node colour`),children:l(`div`,{role:`group`,"aria-label":n(`nodes.general.nodeColourGroup`,`Node colour`),className:`flex flex-wrap gap-2`,children:ne.map(e=>{let t=f===e;return l(N,{type:`button`,role:`radio`,"aria-checked":t,"aria-label":e,variant:`outline`,size:`sm`,disabled:o.isLoading||u.isPending,title:e,onClick:()=>_(e),className:`h-6 w-6 min-w-6 shrink-0 rounded-full border-0 p-0 ${Se(e)} ${t?`ring-2 ring-primary ring-offset-2 ring-offset-background`:`opacity-80 hover:opacity-100`}`,children:l(`span`,{className:`sr-only`,children:e})},e)})})}),l(P,{label:n(`nodes.general.reachableHost`,`Reachable host`),children:l(zn,{nodeId:e,value:p,detectedHosts:g,status:m,errorMessage:h,onCommit:(e,t)=>{c.mutate({agentNodeId:e,reachableHost:t})}})})]})}n();var Un=[[`serverManagement`,`getServerPackageStatus`]];function Wn({label:e,tone:t}){return l(`span`,{className:`inline-flex items-center rounded px-2 py-0.5 text-[11px] font-medium ${{neutral:`bg-surface-muted text-foreground-subtle`,ok:`bg-success/15 text-success`,info:`bg-info/15 text-info`,warn:`bg-warning/15 text-warning`,error:`bg-danger/15 text-danger`}[t]}`,children:e})}function Q({label:e,value:t}){return r(`div`,{className:`flex items-center justify-between gap-4 text-sm`,children:[l(`span`,{className:`text-foreground-subtle`,children:e}),l(`span`,{className:`font-mono text-foreground`,children:t??`—`})]})}function Gn({runningVersion:e,latestVersion:t,seedVersion:n,nodeRuntimeVersion:i,labelRunning:a,labelLatest:o,labelSeed:s,labelRuntime:c}){return l(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-sm`,children:[{key:`running`,label:a,value:e},{key:`latest`,label:o,value:t},{key:`seed`,label:s,value:n},{key:`runtime`,label:c,value:i}].map(({key:e,label:t,value:n})=>r(`span`,{className:`inline-flex items-baseline gap-1`,children:[l(`span`,{className:`text-foreground-subtle`,children:t}),l(`span`,{className:`font-mono text-foreground`,children:n??`—`})]},e))})}var Kn={ok:`border-success/40 bg-success/10 text-success`,warn:`border-warning/40 bg-warning/10 text-warning`,error:`border-danger/40 bg-danger/10 text-danger`};function qn(e){return e.outcome===`failed`?`error`:(e.outcome,e.accepted?`ok`:`warn`)}function Jn(e,t){let n=t instanceof Error?t.message:String(t);return`${e(`serverManagement.outcomeDropped`,`The connection dropped and the result could not be confirmed. The node may be restarting — re-check the version above.`)} — ${n}`}function Yn({node:t}){let{t:n}=I(),i=s(),a=Ce(),[o,u]=c(!1),[d,f]=c(null),p=t.isHub?void 0:{nodeId:t.id},m=le(p,{refetchInterval:1e4,enabled:t.isOnline,retry:1}),h=m.data??null,g=e(()=>{i.invalidateQueries({queryKey:Un})},[i]),_=oe({onSettled:g}),y=pe({onSettled:g}),S=ue({onSettled:g}),C=e(async()=>{if(h?.latestVersion==null){f({tone:`warn`,text:n(`serverManagement.outcomeNoTarget`,`No target version is known for this node — run "Check for update" first.`)});return}if(await a({title:n(`serverManagement.confirmUpdateTitle`,`Update node root package`),message:n(`serverManagement.confirmUpdateBody`,`Install {{pkg}}@{{version}} on "{{node}}" and restart to apply.`,{pkg:h.packageName,version:h.latestVersion,node:t.name}),confirmLabel:n(`serverManagement.confirmUpdateAction`,`Update & restart`)})){f(null);try{let e=await y.mutateAsync({version:h.latestVersion,...p});f({tone:qn(e),text:e.message}),e.restarting&&u(!0)}catch(e){f({tone:`warn`,text:Jn(n,e)})}}},[y,a,t.name,p,h,n]),w=e(async()=>{if(await a({title:n(`serverManagement.confirmRestartTitle`,`Restart node`),message:n(`serverManagement.confirmRestartBody`,`Restart "{{node}}"? In-flight requests to this node are dropped.`,{node:t.name}),confirmLabel:n(`serverManagement.confirmRestartAction`,`Restart`),variant:`warning`})){f(null);try{let e=await S.mutateAsync(p);f({tone:qn(e),text:e.message}),e.restarting&&u(!0)}catch(e){f({tone:`warn`,text:Jn(n,e)})}}},[a,t.name,S,p,n]),T=()=>{switch(h?.bootMode){case`data-root`:return{label:n(`serverManagement.bootDataRoot`,`runtime-updatable`),tone:`ok`};case`workspace`:return{label:n(`serverManagement.bootWorkspace`,`dev workspace`),tone:`info`};default:return{label:n(`serverManagement.bootBaked`,`baked image seed`),tone:`neutral`}}},E=()=>{if(h==null)return null;switch(h.updateState){case`checking`:return{label:n(`serverManagement.stateChecking`,`checking…`),tone:`info`};case`staging`:return{label:n(`serverManagement.stateStaging`,`updating…`),tone:`info`};case`pending-restart`:return{label:n(`serverManagement.statePending`,`restart pending`),tone:`warn`};default:return h.restartRequired===!0?{label:n(`serverManagement.stateRestartRequired`,`restart required`),tone:`warn`}:h.updateAvailable?{label:n(`serverManagement.stateUpdateAvailable`,`update available`),tone:`warn`}:{label:n(`serverManagement.stateUpToDate`,`up to date`),tone:`ok`}}},D=h?.bootMode===`workspace`,O=t.isOnline&&h!=null&&!D&&h.updateAvailable&&h.updateState===`idle`&&!y.isPending,k=t.isOnline&&h!=null&&h.updateState===`idle`&&!S.isPending,A=t.isOnline?E():null;return r(`div`,{className:`space-y-4 py-2`,children:[r(`div`,{className:`flex items-center justify-between gap-3`,children:[r(`div`,{className:`flex items-center gap-2 min-w-0`,children:[l(`span`,{className:`font-mono text-xs text-foreground-subtle truncate`,children:h?.packageName??t.rootPackage?.name??`@camstack/server`}),t.isOnline&&h!=null&&l(Wn,{...T()})]}),A!=null&&l(Wn,{...A})]}),!t.isOnline&&l(Q,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage?.version??null}),t.isOnline&&m.isLoading&&r(`div`,{className:`flex items-center gap-2 text-sm text-foreground-subtle`,children:[l(x,{className:`h-4 w-4 animate-spin`}),n(`common.loading`,`Loading…`)]}),t.isOnline&&m.isError&&r(`div`,{className:`space-y-1.5`,children:[l(`p`,{className:`text-sm text-danger`,children:n(`serverManagement.loadError`,`Could not load the node root-package status.`)}),t.rootPackage!=null&&l(Q,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage.version})]}),t.isOnline&&h!=null&&r(`div`,{className:`space-y-1.5`,children:[l(Gn,{runningVersion:h.runningVersion,latestVersion:h.latestVersion,seedVersion:h.seedVersion,nodeRuntimeVersion:h.nodeRuntimeVersion,labelRunning:n(`serverManagement.runningVersionShort`,`Running`),labelLatest:n(`serverManagement.latestVersionShort`,`Latest`),labelSeed:n(`serverManagement.imageSeedShort`,`Seed`),labelRuntime:n(`serverManagement.nodeRuntimeVersionShort`,`Node.js`)}),h.pendingVersion!=null&&l(Q,{label:n(`serverManagement.pendingVersion`,`Staged (applies on restart)`),value:h.pendingVersion}),h.installedVersion!=null&&h.installedVersion!==h.runningVersion&&l(Q,{label:n(`serverManagement.installedVersion`,`Installed on disk (runs after restart)`),value:h.installedVersion})]}),t.isOnline&&h?.imageContract?.state===`behind-series`&&r(`div`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs leading-relaxed text-danger`,children:[l(`p`,{className:`mb-0.5 font-semibold`,children:n(`serverManagement.imageContractDiverged`,`Container image diverges from the deployment contract`)}),l(`p`,{children:h.imageContract.message})]}),t.isOnline&&D&&l(`p`,{className:`text-xs text-foreground-subtle`,children:n(`serverManagement.workspaceNote`,`Development workspace detected — runtime updates are disabled (the dev loop resolves code from the workspace).`)}),d!=null&&l(`p`,{role:`status`,className:`rounded border px-2 py-1.5 text-xs leading-relaxed ${Kn[d.tone]}`,children:d.text}),o&&r(`div`,{className:`flex items-center gap-2 text-sm text-warning`,children:[l(x,{className:`h-4 w-4 animate-spin`}),n(`serverManagement.nodeRestarting`,`The node is restarting to apply the change…`)]}),t.isOnline&&r(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[r(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:_.isPending||h?.updateState===`staging`,onClick:()=>_.mutate(p),children:[_.isPending?l(x,{className:`h-3.5 w-3.5 animate-spin`}):l(j,{className:`h-3.5 w-3.5`}),n(`serverManagement.checkForUpdate`,`Check for update`)]}),O&&r(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50`,onClick:()=>void C(),children:[y.isPending?l(x,{className:`h-3.5 w-3.5 animate-spin`}):l(v,{className:`h-3.5 w-3.5`}),n(`serverManagement.updateTo`,`Update to {{version}}`,{version:h?.latestVersion??``})]}),r(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:!k,onClick:()=>void w(),children:[S.isPending?l(x,{className:`h-3.5 w-3.5 animate-spin`}):l(b,{className:`h-3.5 w-3.5`}),n(`serverManagement.restart`,`Restart`)]})]}),t.isOnline&&h?.lastCheckedAtMs!=null&&r(`p`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[l(M,{className:`h-3 w-3`}),n(`serverManagement.lastChecked`,`Last checked: {{when}}`,{when:new Date(h.lastCheckedAtMs).toLocaleString()})]})]})}n();function Xn(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=Reflect.get(e,`reachableHost`);return typeof t==`string`&&t.length>0?t:null}function Zn({node:t}){let n=D(),i=s(),[u,p]=c(`info`),[m,h]=c(!1),[g,v]=c(null),y=t.processes??[],b=t.addons.map(e=>e.id),x=ve(void 0),S=a(()=>{let e=x.data?.find(e=>e.nodeId===t.id);return Xn(e?.settings)},[x.data,t.id]),[C,w]=c(!1),[T,E]=c(null),[O,k]=c(null),A=e(async()=>{if(C||t.isHub)return;let e=Qe(t.localIps??[],S);if(e===null){E(`No LAN IPv4 on this node — open its :4444 URL by hand.`),k(null);return}let r=tt();w(!0),E(null),k(null);try{let i=Je(await n.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:t.id,dashboardBaseUrl:$e(e)}})),a=i===null?null:i.dashboardUrl??et(e,i.ticket);if(a===null){r?.close(),E(`Hub did not return an unlock ticket.`);return}nt(r,a)||(k(a),E(`Browser blocked the new tab — click the link below (or allow popups for this site).`))}catch(e){r?.close(),E(e instanceof Error?e.message:String(e))}finally{w(!1)}},[t.id,t.isHub,t.localIps,C,S,n.trpcClient]),j=async()=>{if(!m){h(!0),v(null);try{await n.trpcClient.pipelineOrchestrator.removeAgentSettings.mutate({agentNodeId:t.id}).catch(()=>void 0);let e=await n.trpcClient.clusterNodes.forgetNode.mutate({nodeId:t.id});v({tone:e.stillListed?`warn`:`ok`,text:e.message}),e.stillListed||i.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}catch(e){v({tone:`warn`,text:`Forget failed: ${e instanceof Error?e.message:String(e)}`})}finally{h(!1)}}};return t.isOnline?r(`div`,{className:`border border-border rounded-xl`,children:[r(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 bg-muted/30 border-b border-border rounded-t-xl`,children:[r(`div`,{className:`flex min-w-0 flex-1 basis-full items-center gap-x-2 gap-y-1 sm:basis-auto sm:flex-initial`,children:[l(`div`,{className:`w-2.5 h-2.5 rounded-full bg-success shrink-0`}),l(`span`,{className:`text-sm font-semibold shrink-0`,children:t.name}),r(`span`,{className:`text-xs text-muted-foreground min-w-0 truncate`,children:[t.cpuModel??t.platform,` ·`,` `,t.memoryMB>0?`${Math.round(t.memoryMB/1024)}GB`:``,` · `,t.arch]})]}),t.engines.map(e=>l(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium shrink-0`,children:e},e)),r(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-x-3 gap-y-1 text-xs text-muted-foreground w-full sm:ml-auto sm:w-auto`,children:[!t.isHub&&r(`button`,{type:`button`,onClick:()=>void A(),disabled:C,title:`Open this agent's status dashboard (unlocks with a short-lived hub ticket)`,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[l(_,{className:`h-3 w-3`}),C?`Opening…`:`Open dashboard`]}),r(`span`,{className:`flex items-center gap-1`,children:[l(f,{className:`h-3 w-3`}),` `,t.cpuPercent,`%`]}),r(`span`,{className:`flex items-center gap-1`,children:[l(ee,{className:`h-3 w-3`}),` `,t.memoryPercent,`%`]})]})]}),(T!==null||O!==null)&&r(`p`,{role:`status`,className:`px-4 pt-2 text-xs text-warning`,children:[T,O!==null&&r(o,{children:[` `,l(`a`,{href:O,target:`_blank`,rel:`noreferrer`,className:`underline text-foreground`,children:`Open dashboard`})]})]}),l(`div`,{className:`sticky top-0 z-20 flex border-b border-border px-4 bg-background overflow-x-auto`,children:[`info`,`forks`,`processes`,`load`,`settings`,`capabilities`].map(e=>l(`button`,{onClick:()=>p(e),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${u===e?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:e===`info`?`General`:e===`forks`?`Forks (${y.length})`:e===`processes`?`Processes`:e===`load`?`Load`:e===`settings`?`Settings`:`Capabilities`},e))}),r(`div`,{className:`px-4 py-2`,children:[u===`info`&&r(`div`,{className:`space-y-3`,children:[l(Rn,{nodeId:t.id,name:t.name,hostname:t.hostname,platform:t.platform,arch:t.arch,cpuModel:t.cpuModel,cpuCores:t.cpuCores,memoryMB:t.memoryMB,engines:t.engines,isHub:t.isHub,uptime:t.uptime,localIps:t.localIps,rootPackage:t.rootPackage}),l(Hn,{nodeId:t.id,detectedHosts:t.localIps??[]}),l(`div`,{className:`border-t border-border pt-1`,children:l(Yn,{node:{id:t.id,name:t.name,isHub:t.isHub,isOnline:t.isOnline,rootPackage:t.rootPackage??null}})})]}),u===`forks`&&l(st,{nodeId:t.id,processes:y}),u===`processes`&&l(dt,{nodeId:t.id}),u===`load`&&l(jn,{nodeId:t.id,isHub:t.isHub}),u===`settings`&&l(Fn,{nodeId:t.id,addonIds:b}),u===`capabilities`&&l(In,{nodeId:t.id,addons:t.addons})]})]}):r(`div`,{className:`border border-border rounded-xl overflow-hidden opacity-60`,children:[r(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 bg-muted/30`,children:[l(`div`,{className:`w-2.5 h-2.5 rounded-full bg-destructive shrink-0`}),l(`span`,{className:`text-sm font-semibold shrink-0`,children:t.name}),r(`span`,{className:`text-xs text-muted-foreground min-w-0 truncate`,children:[t.cpuModel??t.platform,` ·`,` `,t.memoryMB>0?`${Math.round(t.memoryMB/1024)}GB`:``,` · `,t.arch]}),t.engines.map(e=>l(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium`,children:e},e)),t.rootPackage&&r(`span`,{className:`text-[10px] font-mono px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:[t.rootPackage.name,`@`,t.rootPackage.version]}),l(`span`,{className:`ml-auto text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`})]}),r(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[r(`span`,{className:`text-xs text-muted-foreground`,children:[t.lastSeen?`Last seen ${new Date(t.lastSeen).toLocaleString()} — `:``,t.addons.length,` addon`,t.addons.length===1?``:`s`,` assigned; will resume when node reconnects`]}),r(`button`,{type:`button`,onClick:()=>void j(),disabled:m,title:`Forget this node — removes its saved history and pipeline assignments`,className:`flex items-center gap-1 text-xs px-2 py-1 rounded-md border border-border text-muted-foreground hover:text-destructive hover:border-destructive/50 disabled:opacity-50 transition-colors`,children:[l(d,{className:`h-3 w-3`}),m?`Forgetting…`:`Forget node`]})]}),g!=null&&l(`p`,{role:`status`,className:`px-4 pb-3 text-xs leading-relaxed ${g.tone===`ok`?`text-success`:`text-warning`}`,children:g.text})]})}var $=3,Qn=7e3;function $n(e){return[...e].sort((e,t)=>e.isHub===t.isHub?0:e.isHub?1:-1)}function er(e){return e.isHub?{}:{nodeId:e.id}}function tr(e){return e.updateState===`staging`||e.updateState===`pending-restart`||e.pendingVersion!==null?!0:!e.updateAvailable}async function nr(e,t){let n=er(e),r=`no answer`;for(let i=1;i<=$;i+=1)try{let r=await t.readStatus(n);return tr(r)?{nodeId:e.id,nodeName:e.name,outcome:`applied`,detail:`Connection dropped, and the node confirms the update landed (state ${r.updateState}, running ${r.runningVersion??`unknown`}).`}:{nodeId:e.id,nodeName:e.name,outcome:`failed`,detail:`Connection dropped and the node came back unchanged (still ${r.runningVersion??`unknown`}, update still available). Nothing was staged.`}}catch(e){r=e instanceof Error?e.message:String(e),i<$&&await t.wait(Qn)}return{nodeId:e.id,nodeName:e.name,outcome:`unconfirmed`,detail:`Connection dropped and the node could not be confirmed after ${$} attempts (${r}). It may be restarting — re-check this node.`}}function rr(e){return e.accepted?`applied`:e.outcome===`failed`?`failed`:`refused`}async function ir(e,t){let n=[];for(let r of $n(e))try{let e=await t.apply(er(r));n.push({nodeId:r.id,nodeName:r.name,outcome:rr(e),detail:e.message})}catch{n.push(await nr(r,t))}return n}n();function ar(){let{nodes:e,isLoading:t}=Oe(),n=a(()=>e??[],[e]);return{nodes:n,isLoading:t&&n.length===0}}var or={applied:`border-success/40 bg-success/10 text-success`,refused:`border-warning/40 bg-warning/10 text-warning`,failed:`border-danger/40 bg-danger/10 text-danger`,unconfirmed:`border-warning/40 bg-warning/10 text-warning`};function sr(){let{t}=I(),n=Ce(),{nodes:i,isLoading:s}=ar(),[d,f]=Ie(),{selection:p,selectNode:m}=We(i),h=p.node,_=a(()=>i.filter(e=>e.isOnline),[i]),y=_.length,b=i.filter(e=>!e.isOnline).length,S=pe(),C=D(),[w,T]=c(!1),[E,O]=c([]),k=d.get(`unlockNode`),A=d.get(`returnTo`),[j,M]=c(null);u(()=>{if(k===null||A===null)return;let e=!1;return(async()=>{try{let t=await C.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:k,dashboardBaseUrl:A}});if(e)return;let n=Je(t),r=n===null?null:n.dashboardUrl??(()=>{let e=new URL(A);return e.searchParams.set(`ticket`,n.ticket),e.toString()})();if(r===null){M(`Could not mint an unlock ticket.`);return}let i=new URLSearchParams(d);i.delete(`unlockNode`),i.delete(`returnTo`),f(i,{replace:!0}),window.location.assign(r)}catch(t){e||M(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[k,A,d,f,C.trpcClient]);let ee=e(async()=>{let e=_.map(e=>({id:e.id,name:e.name,isHub:e.isHub}));if(await n({title:t(`serverManagement.confirmUpdateAllTitle`,`Update all nodes`),message:t(`serverManagement.confirmUpdateAllBody`,`Update and restart every online node, agents first, hub last. Up-to-date nodes are skipped; this page reconnects when the hub comes back.`),confirmLabel:t(`serverManagement.confirmUpdateAllAction`,`Update all & restart`),variant:`warning`})){T(!0),O([]);try{O(await ir(e,{apply:e=>S.mutateAsync(e),readStatus:e=>C.trpcClient.serverManagement.getServerPackageStatus.query(e),wait:e=>new Promise(t=>setTimeout(t,e))}))}finally{T(!1)}}},[S,n,_,C,t]);return r(Le,{icon:g,title:t(`nav.nodes`,`Nodes`),subtitle:t(`cluster.subtitle`,`One node at a time — topology, packages and the cluster secret agents need to join.`),actions:r(o,{children:[y>0&&r(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-xs text-success`,children:[y,` online`]}),b>0&&r(`span`,{className:`rounded-full bg-destructive/10 px-2 py-0.5 text-xs text-destructive`,children:[b,` offline`]}),y>1&&r(N,{type:`button`,size:`sm`,disabled:w,title:t(`serverManagement.updateAllHint`,`Sequenced agents-first, hub-last — up-to-date nodes are skipped.`),onClick:()=>void ee(),children:[w?l(x,{className:`h-3.5 w-3.5 animate-spin`}):l(v,{className:`h-3.5 w-3.5`}),t(`serverManagement.updateAll`,`Update all nodes`)]})]}),children:[E.length>0&&l(`ul`,{"aria-label":`update-all-report`,className:`flex flex-col gap-1 text-xs`,children:E.map(e=>r(`li`,{"data-outcome":e.outcome,className:`rounded border px-2 py-1 ${or[e.outcome]}`,children:[l(`span`,{className:`font-medium`,children:e.nodeName}),l(`span`,{className:`mx-1 uppercase tracking-wide`,children:e.outcome}),l(`span`,{className:`opacity-80`,children:e.detail})]},e.nodeId))}),j!==null&&r(`p`,{role:`alert`,className:`rounded border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:[`Unlock from agent failed: `,j]}),l(Ke,{}),s?l(`div`,{className:`flex items-center justify-center py-12 text-muted-foreground`,children:`Loading cluster topology...`}):h===null?l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-xs text-foreground-subtle`,children:t(`cluster.noNodes`,`No nodes in this cluster yet.`)}):r(`div`,{className:`flex flex-col gap-3`,children:[l(Ue,{staleNodeId:p.staleNodeId,shownNodeName:h.name}),l(ge,{selectedNodeId:h.id,onSelect:m,allowOffline:!0,alwaysShow:!0}),l(Zn,{node:h})]})]})}export{sr as ClusterPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,W as i,a,b as o,o as s,q as c,t 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-DhP-Lgiq.js";import{Ir as f,It as p,On as m,Pn as h,Qt as g,Tt as _,_i as v,ar as y,cn as b,cr as x,dt as S,fi as C,fn as w,nr as T,on as E,ot as D,pr as O,sn as k,yi as A}from"./player-overlays-BOsDheHc.js";import{n as j,r as M,t as N}from"./key-BL3RAip-.js";import{c as P,o as F,u as I}from"./video-c8H5Zs-y.js";import{t as L}from"./history-DQ9vKorT.js";import{t as R}from"./key-round-WrVw9weZ.js";import{t as z}from"./monitor-smartphone-BL4hI9CF.js";import{t as B}from"./unlink-Biu31rTD.js";import{a as V,bi as H,i as ee,o as te,s as U,vi as ne,yi as re}from"./client-CLcJeoH9.js";import{Al as ie,An as W,Bl as ae,Bn as G,Dl as oe,Dn as K,Dr as se,El as ce,En as q,Er as le,Fl as ue,Ft as de,G as fe,Gl as pe,Ht as me,Il as he,Kl as ge,L as _e,Ll as ve,Ln as ye,Ml as be,N as xe,Nl as Se,Ol as Ce,P as we,Pl as Te,Qn as Ee,Rl as De,Rn as Oe,Tl as ke,Tn as Ae,X as je,Xl as Me,Z as Ne,Zn as J,ar as Pe,bn as Fe,en as Ie,gu as Y,jl as Le,jn as Re,kl as ze,kn as Be,ma as Ve,nn as He,on as Ue,rn as We,z as Ge,zl as Ke,zn as qe}from"./src-CCd-7AXY.js";import{t as Je}from"./useTranslation-Bc5yH9V9.js";import{C as Ye,J as Xe,Q as Ze,R as X,X as Qe,Y as $e,c as et,h as tt,p as nt,s as rt}from"./index-Dbcd0nug.js";import{t as it}from"./AdminSectionedPage-Dn3pfXpN.js";import{t as at}from"./AdminPage-BXCcRjRj.js";import{_ as ot,a as st,b as ct,c as lt,d as ut,f as dt,g as ft,h as pt,i as mt,l as ht,m as gt,n as _t,o as vt,p as yt,s as bt,t as xt,u as St,v as Ct,x as wt,y as Tt}from"./SessionsList-BFeOCT72.js";import{i as Et,n as Dt,r as Ot,t as kt}from"./IntegrationHub-nkG_70wF.js";import{n as At,t as jt}from"./addon-display-names-BkwMrExv.js";n();function Mt(){let e=J(),t=Y.useUtils(),n=wt(),{data:r,isLoading:a}=Se(),o=i(()=>r??[],[r]),s=Y.useQueries(e=>o.map(t=>e.userManagement.listExternalIdentities({userId:t.id}))),l=Y.auth.listLoginMethods.useQuery(),[d,f]=c(null),p=Ke({onSuccess:()=>void t.userManagement.listExternalIdentities.invalidate(),onError:e=>f(`Remove failed: ${e.message}`)}),m=i(()=>new Map((l.data??[]).flatMap(e=>e.kind===`redirect`?[[e.id,e.label]]:[])),[l.data]),h=o.flatMap((e,t)=>s[t]?.data??[]),g=h.map(e=>({...dt(e,n),kind:m.get(e.provider)??e.provider})),_=async t=>{let n=h.find(e=>ut(e)===t.id);n!==void 0&&await e({title:`Remove sign-in link`,message:`"${t.ownerName}" will no longer be able to sign in with this ${t.kind} account.`,confirmLabel:`Remove`,variant:`danger`})&&(f(null),p.mutate({userId:n.userId,provider:n.provider,subject:n.subject}))};return u(Tt,{notice:ct(d),onDismissNotice:()=>{f(null)},id:`external-identities`,title:`Sign-in links`,icon:I,description:`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:u(ft,{rows:g,label:`sign-in links`,isLoading:a||s.some(e=>e.isLoading),loadError:s.find(e=>e.isError)?.error?.message??null,emptyText:`No user has linked a sign-in account.`,expiresNone:`—`,action:{label:`Remove`,icon:B,isAvailable:()=>!0,onRun:e=>void _(e),busyId:null,disabled:p.isPending}})})}n();function Nt(){let e=J(),t=s(),n=wt(),r=ie(),[a,o]=c(null),l=ue({onSuccess:()=>void t.invalidateQueries({queryKey:[[`userManagement`,`listApiKeys`]]}),onError:e=>o(`Revoke failed: ${e.message}`)}),d=i(()=>(r.data??[]).map(e=>St(e,n)),[r.data,n]),f=async t=>{await e({title:`Revoke "${t.name}"?`,message:`Any client using this key loses access immediately. This cannot be undone.`,confirmLabel:`Revoke`,variant:`danger`})&&(o(null),l.mutate({id:t.id}))};return u(Tt,{notice:ct(a),onDismissNotice:()=>{o(null)},id:`legacy-api-keys`,title:`Legacy API keys`,icon:L,description:`Keys from before scoped tokens. Nothing creates them any more; revoke them and issue a scoped token instead.`,children:u(ft,{rows:d,label:`legacy API keys`,isLoading:r.isLoading,loadError:r.isError?r.error?.message??`Request failed`:null,emptyText:`No legacy API keys.`,action:{label:`Revoke`,icon:p,isAvailable:()=>!0,onRun:e=>void f(e),busyId:l.isPending?l.variables?.id??null:null,disabled:l.isPending}})})}n();var Pt={one:`linked app`,many:`linked apps`};function Ft(e){if(e.type===`category`){let t=e.target??``;return t===`device`?`all devices`:`all ${t}`}if(e.type===`device`)return`device:[${(e.targets??[]).join(`,`)}]`;let t=e;return`${t.type}:${t.target??``}`}function It(){let e=J(),t=s(),n=be(),[r,a]=c(null),o=()=>void t.invalidateQueries({queryKey:[[`userManagement`,`listOauthSessions`]]}),l=he({onSuccess:o,onError:e=>a(`Revoke failed: ${e.message}`)}),d=ot(`oauth-session`,Pt,o),f=i(()=>(n.data??[]).map(e=>yt(e,e.scopes.map(Ft).join(`, `))),[n.data]),m=async t=>{await e({title:`Revoke the "${t.name}" link?`,message:`${t.name} loses access for ${t.ownerName} on its next call. Linking it again needs the account-link flow from the start.`,confirmLabel:`Revoke`,variant:`danger`})&&(a(null),l.mutate({id:t.id}))},h=l.isPending?l.variables?.id??null:null;return u(Tt,{notice:ct(r,d.outcome),onDismissNotice:()=>{a(null),d.dismiss()},id:`linked-apps`,title:`Linked apps`,icon:x,description:`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:u(ft,{rows:f,label:`linked apps`,isLoading:n.isLoading,loadError:n.isError?n.error?.message??`Request failed`:null,emptyText:`No linked apps — an integration appears here once it completes the account-link flow.`,expiresNone:`—`,action:{label:`Revoke`,icon:p,isAvailable:e=>e.status===`active`||e.status===`revoked`,onRun:e=>void m(e),busyId:h,disabled:l.isPending||d.busy},bulk:{revoke:d,noun:Pt,isSelectable:e=>e.status===`active`||e.status===`revoked`,quickSelect:[{label:`Select revoked`,match:e=>e.status===`revoked`}]}})})}n();var Lt={one:`session`,many:`sessions`};function Rt(){let e=J(),t=Y.useUtils(),n=wt(),r=Y.auth.listSessions.useQuery(),[a,o]=c(null),s=()=>void t.auth.listSessions.invalidate(),l=Y.auth.revokeSessions.useMutation({onSuccess:s,onError:e=>o(`Sign out failed: ${e.message}`)}),d=ot(`login-session`,Lt,s),f=i(()=>(r.data??[]).map(e=>gt(e,n,{client:e=>st(e).label,method:vt})),[r.data,n]),p=async t=>{await e({title:`Sign out this session`,message:`${t.ownerName} on ${t.name} will have to sign in again.`,confirmLabel:`Sign out`,variant:`danger`})&&(o(null),l.mutate({id:t.id}))};return u(Tt,{notice:ct(a,d.outcome),onDismissNotice:()=>{o(null),d.dismiss()},id:`login-sessions`,title:`Login sessions`,icon:z,description:`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:u(ft,{rows:f,label:`sessions`,isLoading:r.isLoading,loadError:r.isError?r.error?.message??`Request failed`:null,emptyText:`No active sessions.`,action:{label:`Sign out`,icon:F,isAvailable:e=>e.status===`active`,onRun:e=>void p(e),busyId:l.isPending&&l.variables!==void 0&&`id`in l.variables?l.variables.id:null,disabled:l.isPending||d.busy},bulk:{revoke:d,noun:Lt,isSelectable:e=>e.status===`active`}})})}function zt({token:e,label:t,onClose:n}){return u(Ae,{open:!0,onOpenChange:e=>!e&&n(),children:r(K,{width:`md`,scroll:`body`,children:[u(W,{children:u(Re,{children:`Token: ${t}`})}),r(q,{className:`space-y-3`,children:[u(`div`,{className:`rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning`,children:`Copy this token now. Once you close this dialog the secret cannot be displayed again.`}),u(`div`,{className:`select-all break-all rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:e})]}),r(Be,{children:[u(de,{value:e,label:`Copy`,srLabel:`token`}),u(G,{type:`button`,variant:`primary`,size:`sm`,onClick:n,children:`Done`})]})]})})}var Bt={token:`newToken`,scoped:`newScoped`,admin:`newAdmin`};n();var Vt=7,Ht=90,Ut=80;function Wt(e){let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=Ht?t:null}function Gt({open:e,users:t,onClose:n,onSubmitScoped:i,onSubmitAdmin:a,submitting:s,formError:l,awaitingProof:f}){let{user:p}=X(),m=p?.isAdmin===!0,h=m?null:p?.scopes??[],[g,_]=c(!1),[v,b]=c(t[0]?.id??``),[x,S]=c(``),[C,w]=c([{type:`capability`,target:``,access:[`view`,`create`]}]),[T,D]=c(``),[O,A]=c(String(Vt));d(()=>{e||(_(!1),b(t[0]?.id??``),S(``),w([{type:`capability`,target:``,access:[`view`,`create`]}]),D(``),A(String(Vt)))},[e,t]);let j=x.trim(),M=we(C),N=Wt(O),P=!g&&v!==``&&j.length>0&&C.length>0&&M===null&&!s,F=g&&m&&j.length>0&&j.length<=Ut&&N!==null&&!s&&!f;return u(Ge,{open:e,onClose:n,title:g?`Create admin token`:`Create token`,icon:g?k:R,error:l,width:`md`,testId:`create-token-dialog`,footer:r(G,{type:`button`,variant:g?`danger`:`primary`,size:`sm`,onClick:()=>{if(g){if(!F||N===null)return;a({name:j,expiresInDays:N});return}if(!P)return;let e=parseInt(T,10),t=Number.isFinite(e)&&e>0?Date.now()+e*864e5:void 0;i({userId:v,name:j,scopes:C,...t===void 0?{}:{expiresAt:t}})},disabled:g?!F:!P,children:[s||f?u(y,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):u(g?k:E,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),g?`Create admin token`:`Issue token`]}),children:r(`div`,{className:`space-y-3`,children:[m?r(`label`,{className:`flex items-start gap-2 text-sm text-foreground`,children:[u(`input`,{type:`checkbox`,className:`mt-0.5`,checked:g,onChange:e=>_(e.target.checked),"data-testid":`token-as-admin`}),r(`span`,{children:[u(`span`,{className:`font-medium`,children:`Administrator`}),u(`span`,{className:`block text-[11px] text-foreground-subtle`,children:`Off = scoped to a surface. On = full admin for scripts (audited, max 90 days).`})]})]}):null,g?u(`div`,{className:`space-y-1 rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px] leading-relaxed text-foreground`,"data-testid":`admin-token-warning`,children:r(`p`,{children:[`An admin token acts as a `,u(`strong`,{children:`full administrator`}),`. Anyone holding it can do anything an admin can. Creating one asks you to confirm it is you.`]})}):null,g?null:r(`div`,{className:`space-y-1`,children:[u(Ue,{htmlFor:`token-user`,children:`On behalf of user`}),u(pe,{id:`token-user`,value:v,onChange:e=>b(e.target.value),options:t.map(e=>({value:e.id,label:e.username}))})]}),u(fe,{label:`Name`,required:!0,children:u(Me,{id:`token-name`,value:x,maxLength:Ut,onChange:e=>S(e.target.value),placeholder:g?`nightly-backup`:`cloudflare-tunnel-route`,autoFocus:!0})}),g?r(`div`,{className:`space-y-1`,children:[u(Ue,{htmlFor:`token-admin-days`,children:`Expires in (days)`}),u(Me,{id:`token-admin-days`,type:`number`,min:1,max:Ht,value:O,onChange:e=>A(e.target.value),state:N===null?`error`:`default`}),N===null?r(`p`,{className:`text-[11px] text-danger`,children:[`Expiry must be a whole number of days, 1 to `,Ht,`.`]}):r(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`Whole number of days, 1 to `,Ht,`.`]})]}):r(o,{children:[r(`div`,{className:`space-y-1`,children:[u(Ue,{children:`Scopes`}),u(xe,{value:C,onChange:w,clampToParent:h}),M&&u(`p`,{className:`text-[10px] text-danger`,children:M}),u(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Each scope picks a (cap or addon) target + one or more access flavours. The token can access ONLY what's listed.`})]}),r(`div`,{className:`space-y-1`,children:[u(Ue,{htmlFor:`token-scoped-days`,children:`Expires in (days)`}),u(Me,{id:`token-scoped-days`,type:`number`,min:1,value:T,onChange:e=>D(e.target.value),placeholder:`30`}),u(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Leave blank for non-expiring.`})]})]})]})})}n();var Kt={one:`token`,many:`tokens`};function qt(e){return e.type===`device`?`device:[${Ne(e.selector)}]`:`${e.type}:${e.target??``}`}function Jt({createRequested:e=!1,onCreateConsumed:t}){let{user:n}=X(),a=J(),o=s(),l=Y.useUtils(),f=wt(),{data:m,isLoading:h}=Se(),g=i(()=>m??[],[m]),_=Y.useQueries(e=>g.map(t=>e.userManagement.listScopedTokens({userId:t.id}))),v=Y.auth.listAdminTokens.useQuery(void 0,{enabled:n?.isAdmin===!0}),{requestProof:y,dialog:b}=mt(`Creating an admin token`),{state:x,openNew:S,close:C}=_e({newKey:Bt.token}),[w,T]=c(null),[E,D]=c(null),[O,k]=c(!1),[A,j]=c(null),[M,N]=c(null);d(()=>{e&&(S(),t?.())},[e,S,t]);let P=()=>{o.invalidateQueries({queryKey:[[`userManagement`,`listScopedTokens`]]}),l.auth.listAdminTokens.invalidate(),l.auth.listAuthAudit.invalidate()},F=ke({onSuccess:({token:e,record:t})=>{P(),C(),D(null),j({token:e,label:t.name})},onError:e=>{T(`Create failed: ${e.message}`),D(`Create failed: ${e.message}`)}}),I=Y.auth.createAdminToken.useMutation({onSuccess:({token:e,record:t})=>{P(),C(),D(null),k(!1),j({token:e,label:t.name})},onError:e=>{T(`Create failed: ${e.message}`),D(`Create failed: ${e.message}`),k(!1)}}),L=ve({onSuccess:()=>{N(null),P()},onError:e=>{N(null),T(`Revoke failed: ${e.message}`)}}),z=Y.auth.revokeAdminToken.useMutation({onSuccess:()=>{N(null),P()},onError:e=>{N(null),T(`Revoke failed: ${e.message}`)}}),B=Ct(Kt,P),V=Date.now(),H=g.flatMap((e,t)=>(_[t]?.data??[]).map(t=>pt(t,e.id,f,t.scopes.map(qt).join(`, `),V))),ee=n?.isAdmin===!0?(v.data??[]).map(e=>ht(e,f,V)):[],te=[...H,...ee],U=_.find(e=>e.isError)?.error?.message??(v.isError?v.error?.message??`Request failed`:null),ne=async e=>{let t=e.kind===lt;await a({title:`Revoke "${e.name}"?`,message:t?`Every script using it loses access immediately. This cannot be undone.`:`${e.ownerName}'s scoped token stops working on its next use. This cannot be undone.`,confirmLabel:`Revoke`,variant:`danger`})&&(T(null),N(e.id),t?z.mutate({id:e.id}):L.mutate({id:e.id}))},re=F.isPending||I.isPending;return r(`div`,{"data-testid":`tokens`,children:[b,u(Tt,{notice:ct(w,B.outcome),onDismissNotice:()=>{T(null),B.dismiss()},id:`tokens`,title:`Tokens`,icon:R,description:`Scoped tokens for a narrow surface, and admin tokens for full-administrator scripts. Revoking one stops it on its next use.`,children:u(ft,{rows:te,label:`tokens`,isLoading:h||_.some(e=>e.isLoading)||n?.isAdmin===!0&&v.isLoading,loadError:U,emptyText:`No tokens.`,action:{label:`Revoke`,icon:p,isAvailable:e=>e.status===`active`,onRun:e=>void ne(e),busyId:M,disabled:B.busy||M!==null},bulk:{revoke:B,noun:Kt,isSelectable:e=>e.status===`active`}})}),u(Gt,{open:x.mode===`new`,users:g.map(e=>({id:e.id,username:e.username})),onClose:()=>{C(),D(null),k(!1)},submitting:re,formError:E,awaitingProof:O,onSubmitScoped:e=>F.mutate({userId:e.userId,name:e.name,scopes:e.scopes,expiresAt:e.expiresAt}),onSubmitAdmin:e=>{(async()=>{T(null),D(null),k(!0);let t=await y();k(!1),t!==null&&I.mutate({...e,reauthToken:t})})()}}),A&&u(zt,{token:A.token,label:A.label,onClose:()=>j(null)})]})}var Yt={"share-link":`share links`,"admin-token":`admin tokens`,"login-session":`login sessions`};function Z(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function Xt(e,t){let n=Z(e,`tokenId`);return Z(e,`name`)??(n===null?void 0:t.get(n))??n??`?`}function Zt(e){return e.filter(e=>e!==null)}function Qt(e){let t=Z(e,`prefix`);return t===null?null:`Prefix ${t}…`}function $t(e,t){let n=e.detail??{};switch(e.action){case`admin-token-created`:{let e=n.expiresAt;return{title:`Admin token "${Xt(n,t)}" created`,details:Zt([Qt(n),typeof e==`number`?`Expires ${bt(e)}`:null])}}case`admin-token-used`:{let e=Z(n,`path`);return{title:`Admin token "${Xt(n,t)}" used`,details:Zt([Qt(n),e===null?null:`Call ${e}`])}}case`admin-token-revoked`:return{title:`Admin token "${Xt(n,t)}" revoked`,details:Zt([Qt(n)])};case`credentials-revoked`:{let e=Z(n,`kind`)??`credential`,t=n.revoked,r=n.skipped,i=Yt[e]??`${e}s`;return{title:`${typeof t==`number`?String(t):`?`} ${i} revoked in bulk`,details:Zt([typeof r==`number`&&r>0?`${String(r)} skipped`:null,Z(n,`ids`)===null?null:`Ids ${Z(n,`ids`)??``}`])}}case`second-factor-skipped`:{let e=Z(n,`method`),t=Z(n,`factors`);return{title:`Second factor skipped on a trusted network`,details:Zt([e===null?null:`Signed in with ${vt(e)}`,t===null?null:`Skipped: ${t.split(`,`).join(`, `)}`])}}default:return{title:e.action,details:Object.entries(n).map(([e,t])=>`${e}: ${String(t)}`)}}}n();var en=100;function tn(){let{user:e}=X();return e?.isAdmin?u(rn,{}):null}function nn(){let{data:e}=Se(),{data:t}=Y.auth.listAdminTokens.useQuery();return i(()=>{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.name);return{userNameById:n,tokenNameById:r}},[e,t])}function rn(){let e=Y.auth.listAuthAudit.useQuery({limit:en}),{userNameById:t,tokenNameById:n}=nn(),i=e.data??[];return r(`div`,{"data-testid":`auth-audit`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[u(w,{className:`h-3.5 w-3.5 text-foreground-subtle`}),u(`div`,{className:`text-xs font-semibold text-foreground`,children:`Authentication audit`}),r(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:[`Latest `,en,`, newest first`]})]}),u(`div`,{className:`p-4`,children:e.isLoading?r(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[u(y,{className:`h-3.5 w-3.5 animate-spin`}),`Loading audit trail…`]}):e.isError?r(`div`,{className:`text-[11px] text-danger`,children:[`Could not load the audit trail: `,e.error?.message??`Request failed`]}):i.length===0?r(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center space-y-1`,children:[u(`div`,{children:`No authentication events recorded yet.`}),u(`div`,{className:`text-[11px] text-foreground-subtle/90`,children:`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.`})]}):u(`ul`,{className:`divide-y divide-border rounded-md border border-border max-h-[420px] overflow-y-auto`,children:i.map(e=>u(an,{record:e,userName:e.userId===void 0?null:t.get(e.userId)??e.userId,tokenNameById:n},e.id))})})]})}function an({record:e,userName:t,tokenNameById:n}){let i=$t(e,n);return r(`li`,{"data-testid":`auth-audit-row`,className:`px-3 py-2 text-xs space-y-0.5`,children:[r(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[u(`span`,{className:`font-medium text-foreground`,children:i.title}),u(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:bt(e.at)})]}),r(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[t!==null&&u(`span`,{className:`text-foreground`,children:t}),e.ip!==void 0&&u(`span`,{className:`font-mono`,children:e.ip}),i.details.map(e=>u(`span`,{className:`font-mono`,children:e},e))]})]})}n();var Q={loginSessions:`login-sessions`,linkedApps:`linked-apps`,tokens:`tokens`,scopedTokens:`scoped-tokens`,adminTokens:`admin-tokens`,shareLinks:`share-links`,legacyApiKeys:`legacy-api-keys`,externalIdentities:`external-identities`,audit:`auth-audit`},on={[Q.scopedTokens]:Q.tokens,[Q.adminTokens]:Q.tokens};function sn(e){return[{id:Q.loginSessions,label:`Login sessions`,icon:z,render:()=>u(Rt,{})},{id:Q.linkedApps,label:`Linked apps`,icon:x,render:()=>u(It,{})},{id:Q.tokens,label:`Tokens`,icon:R,render:({createRequested:e,onCreateConsumed:t})=>u(Jt,{headerOwnsCreate:!0,createRequested:e,onCreateConsumed:t})},{id:Q.shareLinks,label:`Share links`,icon:b,render:()=>u(_t,{})},...e?[{id:Q.legacyApiKeys,label:`Legacy API keys`,icon:L,render:()=>u(Nt,{})}]:[],{id:Q.externalIdentities,label:`Sign-in links`,icon:I,render:()=>u(Mt,{})},{id:Q.audit,label:`Audit`,icon:w,render:()=>u(tn,{})}]}function cn({createRequested:e=!1,onCreateConsumed:t}){let n=ie(),a=(n.data??[]).length>0,o=i(()=>sn(a),[a]),s=Et({ids:i(()=>o.map(e=>e.id),[o]),answered:!n.isLoading}),c=Qe(),[l]=Ze(),d=l.get(`integration`),f=d===null?void 0:on[d];if(f!==void 0){let e=new URLSearchParams(l);return e.set(`integration`,f),u($e,{to:`?${e.toString()}`,replace:!0})}let p=o.find(e=>e.id===s.selectedId)??o[0],m=p?.id??Q.loginSessions;return n.isLoading?u(`div`,{className:`text-sm text-foreground-subtle`,"data-testid":`access-page`,children:`Loading…`}):r(`div`,{className:`flex flex-col gap-3`,"data-testid":`access-page`,children:[u(Ie,{appearance:`pills`,value:m,onValueChange:e=>{c(`?${tt(l,e,null,null).toString()}`)},children:u(He,{"aria-label":`Credential kinds`,children:o.map(e=>r(We,{value:e.id,"data-testid":`access-kind-${e.id}`,children:[u(e.icon,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),e.label]},e.id))})}),p===void 0?null:u(`div`,{role:`region`,"aria-label":p.label,"data-testid":`access-kind-body`,children:p.render({createRequested:e&&p.id===Q.tokens,onCreateConsumed:t??(()=>void 0)})},p.id)]})}function ln(e,t){if(e===Q.tokens)return r(G,{size:`sm`,type:`button`,"data-testid":`access-new-token`,onClick:t,children:[u(R,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`New token`]})}function un(){let[e,t]=c(!1);return{createRequested:e,requestCreate:()=>t(!0),clearCreate:()=>t(!1)}}n();var dn=[`oidcConnections`,`listConnections`],fn=[`oidcConnections`,`connectionFormSchema`],pn={displayName:`OpenID Connect`,icon:`shield-check`,issuerUrl:``,clientId:``,clientSecret:``,redirectUri:``,scopes:`openid profile email`,usernameClaim:`preferred_username`},mn=/^[a-z0-9][a-z0-9-]{0,63}$/;function hn(e){return e instanceof Error?e.message:String(e)}function gn(e,t){if(t)return typeof e==`string`&&e.length>0?e:void 0;if(re(e))return ne;if(typeof e==`string`&&e.length>0)return e;H(e)}function _n(e){return typeof e!=`object`||!e?!1:Array.isArray(Reflect.get(e,`sections`))}function vn({addonId:n}){let f=D(),h=s(),g=J(),_=_e({editKey:`oidcEdit`,newKey:`oidcNew`}),[v,y]=c(!1),[b,x]=c(null),[S,C]=c(``),[w,T]=c({...pn}),O=t(null),k=a({queryKey:[...dn,n],queryFn:async()=>f.trpcClient.oidcConnections.listConnections.query({})}),A=a({queryKey:fn,queryFn:async()=>f.trpcClient.oidcConnections.connectionFormSchema.query({})}),j=k.data??[],M=_n(A.data)?A.data:void 0,N=_.state,P=N.mode===`edit`?j.find(e=>e.id===N.id)??null:null;d(()=>{if(_.state.mode===`edit`&&P!==null){let e=`edit:${P.id}`;if(O.current===e)return;O.current=e,x(null),C(P.id),T(P.formValues===void 0?{...pn}:{...P.formValues});return}if(_.state.mode===`new`){if(O.current===`new`)return;O.current=`new`,x(null),C(``),T({...pn})}},[P,_.state]);let F=e(async()=>{await h.invalidateQueries({queryKey:dn})},[h]),I=l({mutationFn:async e=>f.trpcClient.oidcConnections.deleteConnection.mutate({id:e}),onSuccess:async()=>F()}),L=e(async e=>{await g({title:`Delete OIDC connection?`,message:`Remove “${e.displayName}” (${e.id}). The login button and IdP credentials for this id are dropped.`,confirmLabel:`Delete`,cancelLabel:`Cancel`,variant:`danger`})&&(await I.mutateAsync(e.id),_.state.mode===`edit`&&_.state.id===e.id&&(_.close(),O.current=null))},[g,I,_]),R=e(async()=>{let e=w.displayName,t=typeof e==`string`&&e.trim()!==``?e.trim():``;if(t===``){x(`Display name is required.`);return}let n=_.state.mode===`new`,r=n?S.trim():P?.id??``;if(n&&!mn.test(r)){x(`Instance id must be a lowercase slug (e.g. authentik, google).`);return}if(r===``){x(`That connection is no longer available.`);return}let i=gn(w.clientSecret,n),a=w.icon,o=w.issuerUrl,s=w.clientId,c=w.redirectUri,l=w.scopes,u=w.usernameClaim,d=u===`email`||u===`sub`?u:`preferred_username`;y(!0),x(null);try{n&&await f.trpcClient.oidcConnections.createConnection.mutate({id:r,displayName:t}),await f.trpcClient.oidcConnections.updateConnection.mutate({id:r,displayName:t,icon:typeof a==`string`?a:`shield-check`,issuerUrl:typeof o==`string`?o:``,clientId:typeof s==`string`?s:``,...i===void 0?{}:{clientSecret:i},redirectUri:typeof c==`string`?c:``,scopes:typeof l==`string`?l:`openid profile email`,usernameClaim:d}),await F(),_.close(),O.current=null}catch(e){x(hn(e))}finally{y(!1)}},[S,P?.id,_,w,F,f]),z=i(()=>[{key:`id`,header:`Id`,sortValue:e=>e.id,render:e=>u(`span`,{className:`font-mono text-xs text-foreground`,children:e.id})},{key:`name`,header:`Name`,sortValue:e=>e.displayName,render:e=>u(`span`,{className:`truncate font-medium text-foreground`,children:e.displayName})},{key:`issuer`,header:`Issuer`,sortValue:e=>e.issuerUrl,render:e=>u(`span`,{className:`truncate text-xs text-foreground-muted`,children:e.issuerUrl===``?`—`:e.issuerUrl})},{key:`status`,header:`Status`,notSortableReason:`Badge`,render:e=>u(Pe,{variant:e.configured?`success`:`warning`,children:e.configured?`Configured`:`Not configured`})},{key:`actions`,header:``,align:`right`,notSortableReason:`Row actions`,nowrap:!0,render:e=>r(`div`,{className:`flex justify-end gap-1`,children:[u(G,{type:`button`,size:`sm`,variant:`secondary`,onClick:t=>{t.stopPropagation(),_.openEdit(e.id)},children:`Edit`}),u(G,{type:`button`,size:`sm`,variant:`ghost`,"aria-label":`Delete ${e.displayName}`,title:`Delete`,onClick:t=>{t.stopPropagation(),L(e)},children:u(p,{className:`h-3.5 w-3.5 text-danger`})})]})}],[_,L]),B=_.state.mode===`new`,V=B||P!==null,H=B?`new`:P===null?`closed`:`edit:${P.id}:${P.configured?`cfg`:`empty`}`;return r(`div`,{className:`flex min-h-0 flex-col gap-3`,"data-testid":`oidc-settings-connections`,children:[r(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[r(`p`,{className:`text-sm text-foreground-muted`,children:[`Each row is one IdP. Redirect URI:`,` `,u(`span`,{className:`font-mono text-xs`,children:`/addon/${n}/<id>/callback`})]}),r(G,{type:`button`,size:`sm`,"data-testid":`oidc-connections-add`,onClick:()=>_.openNew(),children:[u(m,{className:`h-3.5 w-3.5`}),`Add connection`]})]}),k.isError?u(`p`,{className:`text-sm text-danger`,children:`Could not load connections.`}):null,k.isPending?u(qe,{className:`h-32 w-full`}):u(me,{columns:z,rows:j,rowKey:e=>e.id,pageSize:25,mobileMode:`scroll`,emptyMessage:`No OIDC connections yet. Add one to register an IdP.`,onRowClick:e=>_.openEdit(e.id),defaultSort:{columnKey:`name`,dir:`asc`}}),u(Ge,{open:V,onClose:()=>{_.close(),x(null),O.current=null},title:B?`Add OIDC connection`:`Edit ${P?.displayName??`connection`}`,icon:E,width:`xl`,testId:`oidc-connection-editor`,error:b,footer:u(G,{type:`button`,size:`sm`,disabled:v||B&&S.trim()===``,onClick:()=>void R(),children:v?`Saving…`:`Save`}),children:V?r(o,{children:[B?r(`div`,{children:[u(Ue,{htmlFor:`oidc-connection-id`,children:`Instance id`}),u(Me,{id:`oidc-connection-id`,value:S,onChange:e=>C(e.target.value),placeholder:`authentik`,autoComplete:`off`}),u(`p`,{className:`mt-1 text-xs text-foreground-muted`,children:`URL slug — appears in /addon/${n}/<id>/callback. Stable; renaming is not supported after save.`})]}):r(`p`,{className:`text-sm text-foreground-muted`,children:[`Instance id: `,u(`span`,{className:`font-mono`,children:P?.id})]}),M===void 0?u(`p`,{className:`text-sm text-foreground-muted`,children:`Loading form…`}):u(Fe,{schema:M,values:w,onChange:T,bare:!0},H)]}):null})]})}n();var yn=3e4,bn=[{capName:`auth-provider`,stageBadge:null},{capName:`user-passkeys`,stageBadge:`Second factor`}],xn={title:`Authentication`,subtitle:`Login providers (local password, OIDC, SAML) and second-factor providers (passkeys / WebAuthn). They run in parallel — enable or disable each independently; disabling one only removes that method, local password login is unaffected.`,emptyTitle:`No authentication providers registered`,emptyDescription:`Local auth should always be available — if this list is empty the local-auth builtin failed to register. Check the Addons page for load errors.`,installLabel:`Add provider`};function Sn(e){return e===`local-auth`?{headline:`Username + password (local).`,icon:j,bullets:[`Users live in the hub’s SQLite database — no IdP roundtrip.`,`TOTP / 2FA is self-enrolled: each user enables it from their own profile page (My access → Two-factor authentication).`,`Scoped tokens, admin tokens and sessions are managed from Identity → Tokens & sessions.`],setupSteps:[`A fresh hub has one account, admin / changeme — the first sign-in asks for a new password. Add users from Users → New user.`,`Hand out either passwords or scoped tokens — both validate through this provider.`]}:e.startsWith(`auth-oidc`)?{headline:`OpenID Connect (Google, Microsoft, Okta, Keycloak, …).`,icon:P,bullets:[`Three-leg redirect flow with PKCE S256 + nonce.`,`id_token is signature-verified against the IdP’s JWKS — no implicit trust.`,`Explicit linking only: an IdP account signs in only the CamStack user who linked it from their profile (My access → Linked sign-in accounts). No auto-created users, no email matching.`,`The linked user’s role, scopes and two-factor authentication apply.`],setupSteps:[`Register a web app at your IdP and copy the client_id + client_secret.`,"Choose a stable instance id (slug). Set the IdP redirect URI to `https://<this-hub>/addon/auth-oidc/<id>/callback`.",`In Settings below, Add connection — enter the id, issuer, and credentials; Save.`,`Each user then links their IdP account from My access → Linked sign-in accounts.`]}:e.startsWith(`auth-saml`)?{headline:`SAML 2.0 — enterprise SSO (Azure AD, Okta, OneLogin).`,icon:P,bullets:[`Heavier handshake than OIDC — exchange metadata XML with your IdP.`,`Group → role mapping via SAML assertions.`]}:e.startsWith(`auth-webauthn`)||e.startsWith(`auth-passkey`)?{headline:`Passkeys / WebAuthn — passwordless second factor.`,icon:g,bullets:[`Enroll a YubiKey, Touch ID, or platform passkey per user.`,`Resistant to phishing — the browser binds the credential to your hub origin.`]}:e.startsWith(`auth-totp`)?{headline:`TOTP — second factor.`,icon:g,bullets:[`Time-based codes from an authenticator app (RFC 6238).`,`Compatible with Google Authenticator, Aegis, 1Password, Bitwarden, etc.`]}:{headline:`Authentication provider.`,icon:E,bullets:[`Generic authentication provider. No additional hints registered.`]}}function Cn(){let e=se({capName:bn[0].capName},{refetchInterval:yn}),t=se({capName:bn[1].capName},{refetchInterval:yn}),n=le(void 0,{refetchInterval:yn}),r=i(()=>jt(n.data??[]),[n.data]),a=i(()=>{let n=[],i=[e.data??[],t.data??[]];for(let[e,t]of bn.entries())for(let a of i[e]??[])n.push({addonId:a.addonId,displayName:r.get(a.addonId)??a.addonId,isActive:a.isActive,capName:t.capName,stageBadge:t.stageBadge});return n},[e.data,t.data,r]),o=[{id:`authentication`,label:`Authentication providers`,install:{capability:bn[0].capName,label:xn.installLabel},entries:a.map(e=>({id:e.addonId,name:e.displayName,fallbackIcon:E,...At(e.isActive),render:()=>u(Dt,{addonId:e.addonId,displayName:e.displayName,capName:e.capName,isActive:e.isActive,badges:e.stageBadge===null?null:u(Pe,{variant:`info`,className:Ot,children:e.stageBadge}),settingsContent:e.addonId.startsWith(`auth-oidc`)?u(vn,{addonId:e.addonId}):void 0,panels:[{id:`about`,title:`About`,icon:Sn(e.addonId).icon,content:u(wn,{addonId:e.addonId})}]})}))}];return u(kt,{embedded:!0,icon:E,title:xn.title,subtitle:xn.subtitle,groups:o,isLoading:e.isLoading||t.isLoading,emptyTitle:xn.emptyTitle,emptyDescription:xn.emptyDescription})}function wn({addonId:e}){let t=Sn(e),n=t.icon;return r(`div`,{className:`space-y-3 rounded-lg border border-border bg-surface p-2 sm:p-4`,children:[r(`div`,{className:`flex items-start gap-2.5`,children:[u(n,{className:`h-4 w-4 mt-0.5 text-primary shrink-0`}),u(`div`,{className:`text-xs text-foreground font-medium`,children:t.headline})]}),u(`ul`,{className:`text-xs text-foreground-subtle space-y-1.5 pl-6 list-disc`,children:t.bullets.map((e,t)=>u(`li`,{children:e},t))}),t.setupSteps&&t.setupSteps.length>0&&r(`div`,{className:`rounded-md border border-border bg-surface-hover/40 px-3 py-2.5 space-y-1.5`,children:[r(`div`,{className:`flex items-center gap-1.5 text-[10px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:[u(M,{className:`h-3 w-3`}),`Setup steps`]}),u(`ol`,{className:`text-xs text-foreground space-y-0.5 pl-4 list-decimal`,children:t.setupSteps.map((e,t)=>u(`li`,{children:e},t))})]}),e===`local-auth`&&r(`div`,{className:`rounded-md border border-info/30 bg-info/5 px-3 py-2 flex items-start gap-2 text-[11px] text-foreground`,children:[u(O,{className:`h-3.5 w-3.5 mt-0.5 text-info shrink-0`}),r(`span`,{children:[`TOTP / 2FA is self-service: each user enrols from their own profile page —`,` `,u(Xe,{to:`/system/my-access`,className:`underline text-primary`,children:`My access`}),` `,`→ “Two-factor authentication” → Enable 2FA. Admins can only remove a user’s active enrollment (lost device) from the`,` `,u(Xe,{to:`/system/identity?tab=users`,className:`underline text-primary`,children:`Users`}),` `,`page via Actions → “Remove 2FA”.`]})]})]})}function Tn({userId:e,username:t,onClose:n}){let i=J(),a=Y.useUtils(),o=Le({userId:e}),s=Y.auth.listLoginMethods.useQuery(),c=Ke({onSuccess:()=>void a.userManagement.listExternalIdentities.invalidate()}),l=new Map((s.data??[]).flatMap(e=>e.kind===`redirect`?[[e.id,e.label]]:[])),d=o.data??[],f=async(n,r)=>{await i({title:`Remove sign-in link`,message:`"${t}" will no longer be able to sign in with this ${r} account.`,confirmLabel:`Remove`,variant:`danger`})&&c.mutate({userId:e,provider:n.provider,subject:n.subject})};return u(Ae,{open:!0,onOpenChange:e=>!e&&n(),children:r(K,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,"data-testid":`external-identities-modal`,children:[u(W,{children:r(Re,{className:`flex items-center gap-2`,children:[u(x,{className:`h-4 w-4 text-primary`}),r(`span`,{children:[`Linked sign-in accounts`,r(`span`,{className:`mt-0.5 block text-[11px] font-normal text-foreground-subtle`,children:[`User: `,u(`span`,{className:`font-mono`,children:t})]})]})]})}),u(q,{className:`space-y-3`,children:o.isLoading?r(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[u(y,{className:`h-3.5 w-3.5 animate-spin`}),`Loading…`]}):d.length===0?u(`p`,{className:`text-xs text-foreground-subtle`,children:`No linked accounts. Only the user can link one, from their own profile page.`}):u(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:d.map(e=>{let t=l.get(e.provider),n=t??e.provider;return r(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[r(`div`,{className:`flex-1 min-w-0`,children:[r(`div`,{className:`font-medium text-foreground truncate`,children:[n,t===void 0&&u(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:`provider unavailable`})]}),r(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:[e.label??e.subject,` ·`,` `,new Date(e.linkedAt).toLocaleDateString()]})]}),r(`button`,{onClick:()=>void f(e,n),disabled:c.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:[u(B,{className:`h-3 w-3`}),`Remove`]})]},`${e.provider}|${e.subject}`)})})}),u(Be,{children:u(G,{onClick:n,variant:`secondary`,children:`Close`})})]})})}function En({userId:e,username:t,onClose:n}){let i=s(),a=J(),c=ze({userId:e}),l=c.data,d=()=>i.invalidateQueries({queryKey:[[`userManagement`,`getTotpStatus`]]}),f=Ce({onSuccess:()=>{d(),n()}}),p=c.isLoading?`loading`:l?.enabled?`enrolled`:`not_enrolled`;return u(Ae,{open:!0,onOpenChange:e=>!e&&n(),children:r(K,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[u(W,{children:r(Re,{className:`flex items-center gap-2`,children:[u(g,{className:`h-4 w-4 text-primary`}),r(`span`,{children:[`Two-factor authentication`,r(`span`,{className:`mt-0.5 block text-[11px] font-normal text-foreground-subtle`,children:[`User: `,u(`span`,{className:`font-mono`,children:t})]})]})]})}),r(q,{className:`space-y-4`,children:[p===`loading`&&r(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[u(y,{className:`h-3.5 w-3.5 animate-spin`}),`Checking status…`]}),p===`not_enrolled`&&r(`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:[u(O,{className:`h-4 w-4 mt-0.5 shrink-0`}),r(`div`,{children:[u(`div`,{className:`font-medium text-foreground`,children:`2FA not enrolled`}),u(`p`,{className:`mt-0.5`,children:`Only the user themselves can enable 2FA, from their own profile page.`})]})]}),p===`enrolled`&&l&&r(o,{children:[r(`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:[u(C,{className:`h-4 w-4 mt-0.5 text-emerald-500 shrink-0`}),r(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[u(`div`,{className:`font-medium`,children:`2FA is active`}),r(`div`,{className:`text-foreground-subtle`,children:[`Enrolled on`,` `,l.confirmedAt?new Date(l.confirmedAt).toLocaleString():`—`]})]})]}),u(`div`,{className:`text-[11px] text-foreground-subtle`,children:`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.`}),r(`div`,{className:`flex justify-end gap-2`,children:[u(G,{onClick:n,variant:`secondary`,children:`Close`}),r(`button`,{onClick:async()=>{await a({title:`Remove 2FA`,message:`Remove two-factor authentication for "${t}"? They'll be able to log in with just their password until they re-enroll from their own profile page.`,confirmLabel:`Remove`,variant:`danger`})&&f.mutate({userId:e})},disabled:f.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:[f.isPending?u(y,{className:`h-3 w-3 animate-spin`}):u(S,{className:`h-3 w-3`}),`Remove 2FA`]})]})]})]})]})})}n();function Dn({userId:e,username:t,onClose:n}){let{user:i,logout:a}=X(),o=i?.id===e,s=J(),l=Y.useUtils(),d=Y.auth.listSessions.useQuery({userId:e}),[f,p]=c(null),m=Y.auth.revokeSessions.useMutation({onSuccess:(e,t)=>{if(o&&`userId`in t){a();return}l.auth.listSessions.invalidate()},onError:e=>p(`Sign out failed: ${e.message}`)}),h=async e=>{await s({title:`Sign out this session`,message:`"${t}" on ${st(e.client).label} will have to sign in again.`,confirmLabel:`Sign out`,variant:`danger`})&&(p(null),m.mutate({id:e.id}))},g=async()=>{await s({title:`Sign out everywhere`,message:o?`Every session of your own account ends, this browser included: you will be signed out here too.`:`Every session of "${t}" ends at once; each device has to sign in again.`,confirmLabel:`Sign out everywhere`,variant:`danger`})&&(p(null),m.mutate({userId:e}))},_=m.isPending&&m.variables!==void 0&&`id`in m.variables?m.variables.id:null;return u(Ae,{open:!0,onOpenChange:e=>!e&&n(),children:r(K,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,"data-testid":`user-sessions-modal`,children:[u(W,{children:r(Re,{className:`flex items-center gap-2`,children:[u(z,{className:`h-4 w-4 text-primary`}),r(`span`,{children:[`Active sessions`,r(`span`,{className:`mt-0.5 block text-[11px] font-normal text-foreground-subtle`,children:[`User: `,u(`span`,{className:`font-mono`,children:t})]})]})]})}),r(q,{className:`space-y-3`,children:[f!==null&&u(`div`,{className:`text-[11px] text-danger`,children:f}),u(xt,{sessions:d.data??[],isLoading:d.isLoading,loadError:d.isError?d.error?.message??`Request failed`:null,emptyText:`No active sessions.`,onRevoke:e=>void h(e),revokingId:_})]}),r(Be,{className:`justify-between`,children:[r(`button`,{onClick:()=>void g(),disabled:m.isPending||(d.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:[m.isPending&&_===null?u(y,{className:`h-3 w-3 animate-spin`}):u(F,{className:`h-3 w-3`}),`Sign out everywhere`]}),u(G,{onClick:n,variant:`secondary`,children:`Close`})]})]})})}function On({icon:e,label:t,count:n,all:i,total:a}){return r(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[u(e,{className:`h-3 w-3 shrink-0 text-foreground-subtle`}),u(`span`,{className:`min-w-0 flex-1 text-foreground-subtle`,children:t}),u(`span`,{className:n===0?`text-foreground-subtle`:`font-medium text-foreground`,children:n===0?`none`:i?`all ${a}`:`${n} of ${a}`})]})}function kn({scopes:e,isAdmin:t,invalidReason:n}){let i=D(),s=a({queryKey:[`auth`,`previewScope`,e,t],enabled:n===null,queryFn:()=>i.trpcClient.auth.previewScope.query({scopes:[...e],isAdmin:t})}),{data:c}=Ve({projection:`slim`}),l=c?.length??0;if(n!==null)return u(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:r(`p`,{className:`flex items-center gap-1.5 text-[11px] text-warning`,children:[u(k,{className:`h-3 w-3 shrink-0`}),n]})});if(s.isLoading)return r(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface p-3 text-[11px] text-foreground-subtle`,children:[u(y,{className:`h-3 w-3 animate-spin`}),`Resolving…`]});if(s.isError||!s.data)return u(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:u(`p`,{className:`text-[11px] text-danger`,children:`Could not resolve this grant set. Saving is still allowed — the server enforces the same rules either way.`})});let d=s.data;return u(`div`,{className:`space-y-2 rounded-lg border border-border bg-surface p-3`,children:d.isAdmin?r(`p`,{className:`text-[11px] text-foreground`,children:[u(`span`,{className:`font-medium`,children:`Administrator`}),` — unrestricted. Grants are ignored for an admin.`]}):r(o,{children:[u(On,{icon:f,label:`Devices they can see`,count:d.device.view.deviceCount,all:d.device.view.all,total:l}),u(On,{icon:h,label:`Devices they can operate`,count:d.device.create.deviceCount,all:d.device.create.all,total:l}),u(On,{icon:p,label:`Devices they can delete`,count:d.device.delete.deviceCount,all:d.device.delete.all,total:l}),r(`div`,{className:`border-t border-border pt-2 text-[10px] text-foreground-subtle`,children:[`System access: `,d.system.length===0?`none`:d.system.join(`, `),d.capabilities.length>0&&r(o,{children:[` · Extra capabilities: `,d.capabilities.map(e=>e.name).join(`, `)]}),d.addons.length>0&&r(o,{children:[` · Addons: `,d.addons.map(e=>e.name).join(`, `)]})]}),d.device.view.deviceCount===0&&u(`p`,{className:`text-[10px] text-warning`,children:`This user will not be able to see any device.`})]})})}n();function An(e){let t=te(e);return t===null?{mode:e.length===0?`role`:`advanced`,roleId:null,selector:{kind:`all`},includeLinked:!0,advancedScopes:e}:{mode:`role`,roleId:t.roleId,selector:t.selector,includeLinked:t.includeLinked,advancedScopes:e}}function jn(e){return e.mode===`advanced`?e.advancedScopes:e.roleId===null?[]:V({roleId:e.roleId,selector:e.selector,includeLinked:e.includeLinked})}function Mn({user:e,onClose:t,onSubmit:n,submitting:a,callerScopes:s}){let l=i(()=>An(e.scopes??[]),[e.scopes]),[d,f]=c(l),[p,m]=c(l.mode===`advanced`),h=i(()=>jn(d),[d]),g=!e.isAdmin&&d.mode===`role`&&d.roleId===null,_=i(()=>e.isAdmin?null:d.mode===`role`&&d.roleId===null?`Pick what this user can do to see the result.`:we(h),[e.isAdmin,d.mode,d.roleId,h]),b=e=>f({...d,...e});return u(Ae,{open:!0,onOpenChange:e=>!e&&t(),children:r(K,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-2xl`,children:[r(W,{children:[r(Re,{children:[`Access — `,e.username]}),u(`p`,{className:`text-[10px] text-foreground-subtle`,children:e.isAdmin?`This user is an administrator — they can do everything, and the settings below are ignored.`:`Choose what they can do, then which devices it applies to.`})]}),r(q,{className:`space-y-4`,children:[g&&r(`div`,{className:`flex items-start gap-2 rounded-lg border border-warning/40 bg-warning/10 p-3`,children:[u(k,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`}),r(`p`,{className:`text-[11px] text-foreground`,children:[u(`span`,{className:`font-medium`,children:`No access.`}),` `,r(`span`,{className:`text-foreground-subtle`,children:[e.username,` cannot see or do anything yet. Configure it below.`]})]})]}),r(`section`,{className:`space-y-2`,children:[u(`h3`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:`1 · What can they do`}),u(`div`,{className:`space-y-1.5`,children:ee.map(e=>{let t=d.mode===`role`&&d.roleId===e.id;return r(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-lg border p-2.5 transition-colors ${t?`border-primary bg-primary/5`:`border-border hover:bg-foreground-subtle/5`}`,children:[u(`input`,{type:`radio`,name:`access-role`,checked:t,onChange:()=>b({mode:`role`,roleId:e.id}),className:`mt-0.5 border-border focus:ring-primary`}),r(`span`,{className:`min-w-0`,children:[u(`span`,{className:`block text-[12px] font-medium text-foreground`,children:e.label}),u(`span`,{className:`mt-0.5 block text-[10px] text-foreground-subtle`,children:e.description})]})]},e.id)})}),r(`button`,{type:`button`,onClick:()=>{if(!p){f({...d,mode:`advanced`,advancedScopes:h}),m(!0);return}m(!1),f(An(d.advancedScopes))},className:`inline-flex items-center gap-1 rounded px-1.5 py-1 text-[10px] text-foreground-subtle transition-colors hover:bg-foreground-subtle/10 hover:text-foreground`,children:[u(p?A:v,{className:`h-3 w-3`}),`Advanced — edit raw grants`]}),p&&r(`div`,{className:`rounded-lg border border-border p-2`,children:[u(`p`,{className:`mb-2 text-[10px] text-foreground-subtle`,children:`One row per grant. Anything expressible here overrides the three roles above; close this section to go back to them.`}),u(xe,{value:d.advancedScopes,onChange:e=>b({mode:`advanced`,advancedScopes:e}),clampToParent:s,emptyHint:r(o,{children:[`No grants.`,` `,u(`span`,{className:`font-medium text-foreground`,children:e.username}),` cannot call any protected endpoint until one is added.`]})})]})]}),d.mode===`role`&&r(`section`,{className:`space-y-2`,children:[u(`h3`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:`2 · On which devices`}),u(je,{value:d.selector,onChange:e=>b({selector:e}),includeLinked:d.includeLinked,onIncludeLinkedChange:e=>b({includeLinked:e}),clampToDeviceIds:null})]}),r(`section`,{className:`space-y-2`,children:[u(`h3`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:d.mode===`role`?`3 · Result`:`2 · Result`}),u(kn,{scopes:h,isAdmin:e.isAdmin,invalidReason:_})]})]}),r(Be,{children:[u(G,{variant:`outline`,size:`sm`,onClick:t,children:`Cancel`}),u(G,{size:`sm`,onClick:()=>n([...h]),disabled:a||_!==null,children:a?u(y,{className:`h-3 w-3 animate-spin`}):`Save access`})]})]})})}n();var $=8;function Nn(){return{username:``,password:``,isAdmin:!1}}function Pn(e){return{id:e.id,username:e.username,password:``,isAdmin:e.isAdmin}}function Fn(e){return e instanceof Error?e.message:`Something went wrong`}function In(){let e=s(),{user:t}=X(),{state:n,openNew:i,openEdit:a,close:l}=_e(),[f,v]=c(null),[b,S]=c(null),[C,w]=c(!1),{data:T,isLoading:D,isError:O,error:k,refetch:A}=Se(),j=J(),M=Ee(),P=()=>e.invalidateQueries({queryKey:[[`userManagement`,`listUsers`]]}),F=ce(),I=oe({onSuccess:P}),L=ae({onSuccess:P}),R=Te({onSuccess:P}),B=De({onSuccess:()=>{P(),H(null)}}),[V,H]=c(null),[ee,te]=c(null),[U,ne]=c(null),[re,ie]=c(null),W=T??[],K=n.mode===`edit`?W.find(e=>e.id===n.id)??null:null,se=()=>{v(null),S(null),w(!1),F.reset(),L.reset(),l()};d(()=>{if(n.mode===`closed`){v(null),S(null),w(!1);return}if(n.mode===`new`){v(e=>e!==null&&e.id===void 0?e:Nn());return}if(K===null){D||l();return}v(e=>e?.id===K.id?e:Pn(K))},[n,K,D,l]);let q=n.mode===`new`&&f!==null&&f.id===void 0||n.mode===`edit`&&f!==null&&K!==null;async function le(e){await j({title:`Delete user`,message:`Permanently delete user "${e.username}"? This cannot be undone — any active sessions will be revoked on next request.`,confirmLabel:`Delete`,variant:`danger`})&&(I.mutate({id:e.id}),n.mode===`edit`&&n.id===e.id&&se())}async function ue(e){let t=await M({title:`Reset password`,message:`Set a new password for "${e.username}".`,label:`New password`,inputType:`password`,placeholder:`At least 8 characters`,confirmLabel:`Continue`,validate:e=>e.length<$?`Password must be at least ${String($)} characters.`:null});t===null||t.length===0||await j({title:`Reset password`,message:`Reset the password for "${e.username}"? They will need to use the new password on their next login.`,confirmLabel:`Reset`})&&R.mutate({id:e.id,newPassword:t})}function de(e,t){t!==e.isAdmin&&L.mutate({id:e.id,isAdmin:t})}async function pe(){if(f!==null){S(null);try{if(f.id===void 0){let e=f.username.trim();if(e===``||f.password.length<$)return;await F.mutateAsync({username:e,password:f.password,isAdmin:f.isAdmin})}else await L.mutateAsync({id:f.id,isAdmin:f.isAdmin});P(),se()}catch(e){S(Fn(e))}}}function he(e){return e?new Date(typeof e==`number`?e:String(e)).toLocaleDateString(`en-GB`,{day:`2-digit`,month:`short`,year:`numeric`}):`—`}let ve=F.isPending||L.isPending,be=f!==null&&f.id===void 0&&f.username.trim()!==``&&f.password.length>=$,xe=f!==null&&f.id!==void 0,Ce=ve||(f?.id===void 0?!be:!xe),we=e=>I.isPending&&I.variables?.id===e.id||L.isPending&&L.variables?.id===e.id||R.isPending&&R.variables?.id===e.id;return r(at,{embedded:!0,icon:_,title:`Users`,subtitle:`Hub accounts, admin flag, access scopes, sessions and sign-in links.`,actions:r(G,{size:`sm`,type:`button`,onClick:()=>{S(null),i()},children:[u(m,{className:`h-3.5 w-3.5`}),`Create User`]}),children:[O&&u(ye,{title:`Could not load users`,message:Fn(k),onRetry:()=>void A()}),D&&r(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[u(y,{className:`h-3.5 w-3.5 animate-spin`}),`Loading…`]}),!D&&!O&&W.length===0&&u(Oe,{icon:_,title:`No users yet`,description:`Create a user to grant hub access.`}),!D&&!O&&W.length>0&&u(me,{columns:[{key:`username`,header:`Username`,sortValue:e=>e.username,render:e=>u(`span`,{className:`font-medium text-foreground`,"data-testid":`user-open-${e.id}`,children:e.username})},{key:`isAdmin`,header:`Admin`,nowrap:!0,sortValue:e=>+!!e.isAdmin,render:e=>u(`span`,{onClick:e=>e.stopPropagation(),children:r(`label`,{className:`inline-flex items-center gap-1.5 text-xs cursor-pointer`,children:[u(`input`,{type:`checkbox`,checked:e.isAdmin,onChange:t=>de(e,t.target.checked),disabled:we(e),className:`rounded border-border focus:ring-primary disabled:opacity-50`}),u(`span`,{className:e.isAdmin?`text-primary font-medium`:`text-foreground-subtle`,children:e.isAdmin?`Admin`:`Regular`})]})})},{key:`scopes`,header:`Access`,render:e=>e.isAdmin?u(`span`,{className:`text-[10px] italic text-foreground-subtle`,children:`everything (admin)`}):u(`span`,{onClick:e=>e.stopPropagation(),children:r(G,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>H(e),title:`Configure access`,children:[u(E,{className:`h-3 w-3 shrink-0 text-foreground-subtle`}),u(Ln,{scopes:e.scopes??[]})]})})},{key:`createdAt`,header:`Created`,nowrap:!0,sortValue:e=>e.createdAt,render:e=>u(`span`,{className:`text-foreground-subtle`,children:he(e.createdAt)})},{key:`actions`,header:`Actions`,align:`right`,nowrap:!0,notSortableReason:`Row actions`,render:e=>{let n=we(e),i=e.id!==t?.id&&e.totpEnabled;return r(`div`,{className:`flex items-center justify-end gap-1`,onClick:e=>e.stopPropagation(),children:[r(G,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>a(e.id),disabled:n,title:`Edit user`,children:[u(h,{className:`h-3 w-3`}),`Edit`]}),i&&r(G,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>te(e),disabled:n,title:`Remove two-factor authentication`,children:[u(g,{className:`h-3 w-3`}),`Remove 2FA`]}),r(G,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>ne(e),disabled:n,title:`Linked sign-in accounts`,children:[u(x,{className:`h-3 w-3`}),`Sign-in links`]}),r(G,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>ie(e),disabled:n,title:`Active sessions`,children:[u(z,{className:`h-3 w-3`}),`Sessions`]}),r(G,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>void ue(e),disabled:n,title:`Reset password`,children:[u(N,{className:`h-3 w-3`}),`Reset password`]}),r(G,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>void le(e),disabled:n,title:`Delete user`,className:`text-danger hover:bg-danger/10`,children:[n?u(y,{className:`h-3 w-3 animate-spin`}):u(p,{className:`h-3 w-3`}),`Delete`]})]})}}],rows:W,rowKey:e=>e.id,minWidthPx:560,maxBodyHeight:`max-h-[60vh]`,mobileMode:`scroll`,onRowClick:e=>a(e.id)}),u(Ge,{open:q,onClose:se,title:f?.id===void 0?`Create User`:`Edit ${f.username||`user`}`,icon:_,error:b,testId:`user-form-dialog`,footer:u(G,{size:`sm`,type:`button`,disabled:Ce,onClick:()=>void pe(),children:ve?r(o,{children:[u(y,{className:`h-3.5 w-3.5 animate-spin`}),`Saving…`]}):f?.id===void 0?`Create`:`Save`}),children:f!==null&&r(`div`,{className:`space-y-3`,children:[u(fe,{label:`Username`,required:f.id===void 0,children:u(Me,{value:f.username,onChange:e=>v({...f,username:e.target.value}),placeholder:`john`,autoFocus:f.id===void 0,disabled:f.id!==void 0,"data-testid":`user-form-username`})}),f.id===void 0&&u(fe,{label:`Password`,required:!0,description:`At least ${String($)} characters.`,children:u(ge,{value:f.password,onValueChange:e=>v({...f,password:e}),shown:C,onToggleShown:()=>w(e=>!e),placeholder:`••••••••`,"data-testid":`user-form-password`})}),u(fe,{label:`Admin`,description:`Unrestricted access to every capability and device.`,children:r(`label`,{className:`inline-flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[u(`input`,{type:`checkbox`,checked:f.isAdmin,onChange:e=>v({...f,isAdmin:e.target.checked}),className:`rounded border-border focus:ring-primary`,"data-testid":`user-form-admin`}),u(`span`,{children:`Admin`})]})}),f.id!==void 0&&u(`p`,{className:`text-[11px] text-foreground-subtle`,children:`To change the password, use Reset password on the user's row. Access scopes are configured from the Access column.`})]})}),ee&&u(En,{userId:ee.id,username:ee.username,onClose:()=>te(null)}),U&&u(Tn,{userId:U.id,username:U.username,onClose:()=>ne(null)}),re&&u(Dn,{userId:re.id,username:re.username,onClose:()=>ie(null)}),V&&u(Rn,{user:V,onClose:()=>H(null),onSubmit:e=>B.mutate({userId:V.id,scopes:e}),submitting:B.isPending})]})}function Ln({scopes:e}){if(e.length===0)return u(`span`,{className:`font-medium text-warning`,children:`No access`});let t=te(e);return t===null?r(`span`,{className:`text-foreground-subtle`,children:[`Custom · `,e.length,` grant`,e.length===1?``:`s`]}):r(`span`,{className:`text-foreground-subtle`,children:[u(`span`,{className:`font-medium text-foreground`,children:U(t.roleId).label}),` ·`,` `,Ne(t.selector)]})}function Rn(e){let{user:t}=X(),n=t?.isAdmin===!0;return u(Mn,{...e,callerScopes:n?null:t?.scopes??[]})}var zn={"api-keys":Q.tokens,"linked-sessions":Q.linkedApps};function Bn(){let{t:e}=Je(),[t]=Ze(),n=un(),r=zn[t.get(`tab`)??``];if(r!==void 0)return u($e,{to:nt(`access`,{integration:r}),replace:!0});let i=Ye(`/system/identity`,{t:e,isAdmin:!0})??{icon:T,title:e(`system.identity`,`Identity & Access`)},a=t.get(`tab`)??`users`,o=t.get(`integration`),s=a===et.access.tab?ln(o,n.requestCreate):void 0;return u(it,{icon:i.icon,title:i.title,defaultSection:`users`,sectionsLabel:`${i.title} sections`,actions:s,sections:[{id:`users`,label:`Users`,content:u(In,{})},{id:et.access.tab,label:`Tokens & sessions`,content:u(cn,{createRequested:n.createRequested,onCreateConsumed:n.clearCreate}),ownedParams:rt.concat([Bt.token,Bt.scoped,Bt.admin])},{id:et.authentication.tab,label:`Authentication`,content:u(Cn,{}),ownedParams:rt}]})}export{Bn as IdentityPage};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{Q as e,S as t,W as n,b as r,o as i,q as a,x as o,z as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{$t as c,Br as l,Fi as u,Fr as d,Hi as f,It as p,Mr as m,On as h,Pn as g,Qi as _,Qr as v,Rt as y,Vr as b,Vt as x,Xi as S,Zi as C,_i as w,dt as T,er as E,fn as D,hr as O,ji as k,ki as A,lr as j,nn as M,nr as N,pt as P,sn as F,ui as I,ut as L,wi as R,yi as ee,yn as z,zt as B}from"./player-overlays-BOsDheHc.js";import{t as te}from"./boxes-F2kcHJh3.js";import{n as ne,r as re,t as V}from"./speaker-nmF_x7US.js";import{t as H}from"./user-round-C2xetSEU.js";import{Qn as U,Xt as W,er as G,rr as K}from"./client-CLcJeoH9.js";import{Aa as ie,Bn as q,Da as ae,Ea as oe,Gi as se,Ht as J,Ma as ce,Na as le,Nt as ue,Pt as de,Ql as fe,Ra as pe,Ta as me,W as he,Wi as ge,Xl as _e,Zn as ve,_a as ye,an as be,au as xe,en as Se,ga as Ce,ja as we,ma as Te,nn as Ee,ou as De,rn as Oe,va as ke,wa as Ae,ya as je}from"./src-CCd-7AXY.js";import{t as Me}from"./useTranslation-Bc5yH9V9.js";import{J as Y,Q as Ne}from"./index-Dbcd0nug.js";import{t as Pe}from"./AdminSectionedPage-Dn3pfXpN.js";e();var Fe={camera:R,hub:ne,container:te,light:j,siren:M,switch:B,sensor:_,thermostat:x,climate:C,button:I,"event-emitter":L,update:re,notifier:u,script:D,automation:P,lock:N,cover:k,valve:b,humidifier:l,"water-heater":m,fan:d,"media-player":V,"alarm-panel":F,control:c,presence:H,weather:v,vacuum:A,"lawn-mower":y,image:O,smoke:S};function X({type:e,className:t}){return o(Fe[e]??I,{"aria-hidden":`true`,className:t??`h-3.5 w-3.5 shrink-0 text-foreground-subtle`})}function Ie({online:e,deviceName:t}){return o(`span`,{className:e?`inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500`:`inline-block h-1.5 w-1.5 shrink-0 rounded-full border border-foreground-subtle`,role:`img`,"aria-label":`${t}: ${e?`online`:`offline`}`,title:e?`online`:`offline`})}function Le({name:e,description:n,busy:r,onSave:i}){let[c,l]=a(n??``);return s(()=>{l(n??``)},[n]),t(`div`,{className:`border-t border-border px-3 py-2`,children:[o(`label`,{htmlFor:`location-description-${e}`,className:`block text-[10px] font-medium uppercase tracking-wide text-foreground-subtle`,children:`What is there`}),o(`textarea`,{id:`location-description-${e}`,value:c,onChange:e=>l(e.target.value),onBlur:()=>{let e=c.trim();e!==(n??``)&&i(e.length===0?null:e)},disabled:r,rows:2,maxLength:400,placeholder:`Surfaces, boundaries, what is normally parked or stored here.`,className:`mt-1 w-full resize-y rounded border border-border bg-background px-1.5 py-1 text-[11px] text-foreground placeholder:text-foreground-subtle disabled:opacity-50`}),o(`p`,{className:`mt-0.5 text-[10px] text-foreground-subtle`,children:`Given to the AI with the pictures, so it knows what it is looking at. Describe the PLACE, not what happens in it — events change, the ground does not.`})]})}function Re(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0||n.description.length===0?null:n.description}var Z=` none`;function ze({name:e,zones:n,zoneKey:r,busy:i,onChange:a}){return n.length===0?null:t(`div`,{className:`flex items-center gap-2 border-t border-border px-3 py-1.5`,children:[o(`label`,{htmlFor:`location-zone-${e}`,className:`text-[10px] font-medium uppercase tracking-wide text-foreground-subtle`,children:`Zone`}),t(`select`,{id:`location-zone-${e}`,value:r??Z,disabled:i,onChange:e=>{let t=e.target.value;if(t===Z){a(null);return}let r=n.find(e=>e.zoneKey===t);r!==void 0&&a(r.label)},className:`min-w-0 flex-1 rounded border border-border bg-background px-1.5 py-0.5 text-[11px] text-foreground disabled:opacity-50`,children:[o(`option`,{value:Z,children:`— none —`}),n.map(e=>o(`option`,{value:e.zoneKey,children:e.label},e.zoneKey))]})]})}function Be(e,t){return e.find(e=>e.locationKeys.includes(t))?.zoneKey??null}function Ve({name:e,icon:t,busy:n,onPick:r}){return o(fe,{value:t,onPick:r,fallbackGlyph:E,clearGlyph:f,labels:{trigger:`Change the icon of ${e}`,panel:`Icon for ${e}`,searchPlaceholder:`Search icons`,clear:`No icon`,noMatches:`No icon matches that`},disabled:n})}function He(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0?null:G(n.icon)??`map-pin`}function Q(e){if(e==null)return null;let t=e.trim();return t.length===0?null:t.toLowerCase()}function Ue(e,t){let n=Q(t);return n===null?[]:e.filter(e=>Q(e.location)===n)}function We(e,t){let n=Ue(e,t),r=new Set(n.map(e=>e.id));return n.filter(e=>e.parentDeviceId===null||!r.has(e.parentDeviceId))}function Ge(e,t){let n=Q(e.location);return n===null||new Set(t.map(e=>Q(e))).has(n)?null:e.location?.trim()??null}function Ke(e,t){let n=Q(e.location);return n!==null&&t.has(n)}function qe(e,t){let n=new Set(t.map(e=>Q(e))),r=new Set(e.filter(e=>Ke(e,n)).map(e=>e.id));return e.filter(e=>!(Ke(e,n)||e.parentDeviceId!==null&&r.has(e.parentDeviceId)))}function Je(e,t){return qe(e,t).filter(e=>e.parentDeviceId===null)}function Ye(e,t){let n=new Map;for(let t of e){if(t.parentDeviceId===null)continue;let e=n.get(t.parentDeviceId);e?e.push(t):n.set(t.parentDeviceId,[t])}let r=[],i=new Set([t]),a=[t];for(;a.length>0;){let e=[];for(let t of a)for(let a of n.get(t)??[])i.has(a.id)||(i.add(a.id),r.push(a),e.push(a.id));a=e}return r}function Xe(e,t){return Ye(e,t).length}function Ze(e,t){return e.filter(e=>!e.isCamera&&e.parentDeviceId===t)}function Qe(e,t){return t.map(t=>({name:t,members:We(e,t)}))}function $e(e){return`${e.kind}:${String(e.device.id)}`}function et(e,t,n){return e.flatMap(e=>{let r=Ze(t,e.id),i=n.has(e.id),a={kind:`member`,device:e,accessories:r,open:i};return!i||r.length===0?[a]:[a,...r.map(t=>({kind:`accessory`,device:t,parent:e}))]})}e();function tt({name:e,members:i,devices:s,busy:c,icon:l,description:u,onRename:d,onDelete:f,onRebuildLinks:m,onPickIcon:h,onSaveDescription:_,zones:v,zoneKey:y,onChangeZone:b}){let{t:x}=Me(),[S,C]=a(!1),[w,E]=a(e),D=ue(i,n(()=>({searchText:e=>[e.name,...Ze(s,e.id).map(e=>e.name)],facetValue:e=>e.type}),[s])),[O,k]=a(()=>new Set),A=e=>k(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),j=n(()=>et(D.rows,s,O),[D.rows,s,O]),M=[{key:`name`,header:x(`locations.columns.device`),notSortableReason:x(`locations.columns.noSort`),render:e=>e.kind===`member`?o(nt,{row:e,onToggle:()=>A(e.device.id)}):o(rt,{row:e})},{key:`type`,header:x(`locations.columns.type`),notSortableReason:x(`locations.columns.noSort`),render:e=>o(`span`,{className:`text-[11px] text-foreground-muted`,children:e.device.type})},{key:`status`,header:x(`locations.columns.status`),notSortableReason:x(`locations.columns.noSort`),render:e=>t(`span`,{className:`flex items-center gap-1.5`,children:[o(Ie,{online:e.device.online,deviceName:e.device.name}),o(`span`,{className:`text-[11px] text-foreground-muted`,children:e.device.online?`online`:`offline`})]})}],N=()=>{E(e),C(!1)},P=async()=>{let t=w.trim();if(t.length===0||t===e){N();return}await d(t),C(!1)};return t(`section`,{className:`min-w-0 rounded-md border border-border bg-surface`,children:[t(`header`,{className:`flex items-center gap-1.5 border-b border-border px-3 py-1.5`,children:[o(Ve,{name:e,icon:l,busy:c,onPick:h}),S?t(r,{children:[o(`input`,{value:w,onChange:e=>E(e.target.value),onKeyDown:e=>{e.key===`Enter`&&P(),e.key===`Escape`&&N()},"aria-label":`Rename ${e}`,className:`min-w-0 flex-1 rounded border border-border bg-background px-1.5 py-0.5 text-sm font-semibold text-foreground`,autoFocus:!0}),o(`button`,{type:`button`,onClick:()=>void P(),className:`text-[11px] text-foreground-subtle hover:text-foreground`,children:`Save`}),o(`button`,{type:`button`,onClick:N,"aria-label":`Cancel rename`,className:`p-0.5 text-foreground-subtle hover:text-foreground`,children:o(T,{className:`h-3.5 w-3.5`})})]}):t(r,{children:[o(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:e}),o(he,{items:[{id:`rename`,label:`Rename`,icon:g,disabled:c,onClick:()=>{E(e),C(!0)}},{id:`rebuild-links`,label:`Rebuild linked devices`,icon:z,separatorBefore:!0,disabled:c,onClick:()=>void m()},{id:`delete`,label:`Delete`,icon:p,danger:!0,separatorBefore:!0,disabled:c,onClick:()=>void f()}],title:`Actions for ${e}`,triggerClassName:`p-1`})]})]}),o(ze,{name:e,zones:v,zoneKey:y,busy:c,onChange:b}),o(Le,{name:e,description:u,busy:c,onSave:_}),i.length>0&&o(`div`,{className:`border-b border-border px-3 py-1.5`,children:o(de,{state:D.state,facets:D.facets,labels:{searchPlaceholder:x(`locations.filter.searchPlaceholder`),searchLabel:x(`locations.room.searchLabel`,{room:e}),facetsLabel:x(`locations.filter.typesLabel`),clearLabel:x(`locations.filter.clear`)},onSearch:D.setSearch,onToggleFacet:D.toggleFacet,onClear:D.clear})}),i.length===0?o(`p`,{className:`px-3 py-3 text-[11px] text-foreground-subtle`,children:`Nothing here yet — assign a device from the table below.`}):o(J,{columns:M,rows:j,rowKey:$e,bordered:!1,minWidthPx:360,mobileMode:`scroll`,emptyMessage:x(`locations.filter.noMatch`)})]})}function nt({row:e,onToggle:n}){let{device:r,accessories:i,open:a}=e,s=a?ee:w;return t(`span`,{className:`flex items-center gap-1.5`,children:[i.length>0?t(`button`,{type:`button`,onClick:n,"aria-expanded":a,"aria-label":`${a?`Collapse`:`Expand`} ${String(i.length)} companion device(s) of ${r.name}`,className:`flex shrink-0 items-center gap-0.5 rounded p-0.5 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:[o(s,{className:`h-3 w-3`}),o(`span`,{className:`text-[10px] tabular-nums`,children:i.length})]}):o(`span`,{"aria-hidden":`true`,className:`w-[1.35rem] shrink-0`}),o(X,{type:r.type}),o(Y,{to:`/devices/${String(r.id)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:r.name})]})}function rt({row:e}){let{device:n}=e;return t(`span`,{className:`flex items-center gap-1.5 pl-6`,children:[o(`span`,{"aria-hidden":`true`,className:`text-[10px] text-foreground-subtle`,children:`└`}),o(X,{type:n.type,className:`h-3 w-3 shrink-0 text-foreground-subtle`}),o(Y,{to:`/devices/${String(n.id)}`,className:`min-w-0 truncate text-[11px] text-foreground-muted hover:underline`,children:n.name})]})}e();function it({zones:e,busy:t,onRename:n,onDelete:r,onPickIcon:i}){let[s,c]=a(null),[l,u]=a(``),d=async e=>{let t=l.trim();c(null),!(t.length===0||t===e)&&await n(e,t)};return o(J,{columns:[{key:`icon`,header:`Icon`,width:`w-12`,notSortableReason:`An icon has no order`,render:e=>o(Ve,{name:e.label,icon:e.icon,busy:t,onPick:t=>i(e.label,t)})},{key:`name`,header:`Zone`,sortValue:e=>e.label.toLowerCase(),render:e=>s===e.label?o(_e,{value:l,onChange:e=>u(e.target.value),onKeyDown:t=>{t.key===`Enter`&&d(e.label),t.key===`Escape`&&c(null)},onBlur:()=>void d(e.label),"aria-label":`Rename ${e.label}`,autoFocus:!0}):o(q,{type:`button`,variant:`ghost`,size:`sm`,className:`px-0`,onClick:()=>{u(e.label),c(e.label)},disabled:t,title:`Rename the zone`,children:e.label})},{key:`rooms`,header:`Rooms`,align:`right`,sortValue:e=>e.locationKeys.length,render:e=>o(`span`,{className:`tabular-nums text-foreground-subtle`,children:e.locationKeys.length===0?`empty`:`${String(e.locationKeys.length)} ${e.locationKeys.length===1?`room`:`rooms`}`})},{key:`actions`,header:`Actions`,align:`right`,notSortableReason:`Actions have no order`,render:e=>o(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void r(e.label),disabled:t,"aria-label":`Delete ${e.label}`,title:`Delete the zone — the rooms in it are kept`,children:o(p,{className:`h-3.5 w-3.5`})})}],rows:e,rowKey:e=>e.zoneKey,mobileMode:`cards`,emptyMessage:`No zones yet. A zone groups rooms — “Zona notte” for the bedrooms — and shows up before them in the app’s camera filter.`})}function at(){return De(),e=>xe(K(e,`map-pin`))??E}e();function ot({busy:e,onCreate:n}){let[r,i]=a(!1),[s,c]=a(``),l=()=>{c(``),i(!1)},u=async()=>{let e=s.trim();e.length!==0&&(await n(e),l())};return r?t(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),u()},children:[o(`input`,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Escape`&&l()},placeholder:`Ingresso, Salone, Cucina…`,"aria-label":`New location name`,className:`min-w-[16rem] flex-1 rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,autoFocus:!0}),t(`button`,{type:`submit`,disabled:s.trim().length===0||e,className:`inline-flex items-center gap-1 rounded border border-border bg-surface px-2 py-1.5 text-xs font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[o(h,{className:`h-3.5 w-3.5`}),`Add`]}),o(`button`,{type:`button`,onClick:l,"aria-label":`Cancel new location`,className:`p-1 text-foreground-subtle hover:text-foreground`,children:o(T,{className:`h-3.5 w-3.5`})})]}):t(`button`,{type:`button`,onClick:()=>i(!0),className:`inline-flex w-fit items-center gap-1 rounded border border-border bg-surface px-2 py-1.5 text-xs font-medium text-foreground hover:bg-surface-hover`,children:[o(h,{className:`h-3.5 w-3.5`}),`New location`]})}e();function st({busy:e,onCreate:n}){let[r,i]=a(!1),[s,c]=a(``),l=()=>{c(``),i(!1)},u=async()=>{let e=s.trim();e.length!==0&&(await n(e),l())};return r?t(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),u()},children:[o(_e,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Escape`&&l()},placeholder:`Zona giorno, Zona notte…`,"aria-label":`New zone name`,className:`min-w-[12rem] flex-1`,autoFocus:!0}),t(q,{size:`sm`,type:`submit`,disabled:s.trim().length===0||e,children:[o(h,{className:`h-3.5 w-3.5`}),`Add`]}),o(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:l,"aria-label":`Cancel new zone`,children:o(T,{className:`h-3.5 w-3.5`})})]}):t(q,{size:`sm`,type:`button`,onClick:()=>i(!0),"data-testid":`new-zone-button`,children:[o(h,{className:`h-3.5 w-3.5`}),`New zone`]})}e();var ct={searchText:e=>[e.name],facetValue:e=>e.type};function lt({rows:e,fleet:r,locations:i,busy:s,emptyMessage:c,onAssign:l}){let{t:u}=Me(),[d,f]=a([]),[p,m]=a(``),h=ue(e,ct),g=h.rows,_=n(()=>g.map(e=>e.id),[g]),v=n(()=>d.filter(e=>_.includes(e)),[d,_]),y=g.length>0&&v.length===g.length,b=n(()=>{let t=new Map;for(let n of e)t.set(n.id,Xe(r,n.id));return t},[e,r]),x=v.reduce((e,t)=>e+(b.get(t)??0),0),S=e=>f(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),C=()=>f(y?[]:_);return t(`section`,{className:`space-y-2`,children:[t(`header`,{className:`flex flex-wrap items-baseline gap-2`,children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Not in a room`}),o(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Top-level devices only — accessories move with their parent.`})]}),e.length>0&&o(de,{state:h.state,facets:h.facets,labels:{searchPlaceholder:u(`locations.filter.searchPlaceholder`),searchLabel:u(`locations.unassigned.searchLabel`),facetsLabel:u(`locations.filter.typesLabel`),clearLabel:u(`locations.filter.clear`)},onSearch:h.setSearch,onToggleFacet:h.toggleFacet,onClear:h.clear}),v.length>0&&t(`div`,{role:`group`,"aria-label":`Bulk assignment`,className:`flex flex-wrap items-center gap-2 rounded border border-primary/40 bg-primary/5 px-2 py-1.5`,children:[t(`span`,{className:`text-[11px] text-foreground`,children:[v.length,` selected`,x>0&&` · ${String(x)} accessories in tow`]}),t(`select`,{"aria-label":`Assign selected devices to`,value:p,onChange:e=>m(e.target.value),className:`rounded border border-border bg-background px-1.5 py-0.5 text-[11px] text-foreground`,children:[o(`option`,{value:``,children:`Assign to…`}),i.map(e=>o(`option`,{value:e,children:e},e))]}),o(`button`,{type:`button`,onClick:()=>{p.length===0||v.length===0||(l(v,p),f([]),m(``))},disabled:s||p.length===0,className:`rounded border border-border bg-surface px-2 py-0.5 text-[11px] font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:`Assign`}),o(`button`,{type:`button`,onClick:()=>f([]),className:`text-[11px] text-foreground-subtle hover:text-foreground`,children:`Clear`})]}),o(J,{columns:[{key:`select`,width:`w-8`,headerRender:()=>o(be,{checked:y,onChange:C,"aria-label":y?`Clear selection`:`Select all unassigned devices`}),render:e=>o(be,{checked:v.includes(e.id),onChange:()=>S(e.id),"aria-label":`Select ${e.name}`})},{key:`name`,header:`Device`,sortValue:e=>e.name.toLowerCase(),render:e=>{let n=Ge(e,i);return t(`span`,{className:`flex items-center gap-1.5`,children:[o(X,{type:e.type}),o(Y,{to:`/devices/${String(e.id)}`,className:`truncate text-xs text-foreground hover:underline`,children:e.name}),n!==null&&t(`span`,{className:`rounded-full border border-warning/40 px-1.5 py-px text-[10px] text-warning`,children:[`unknown room “`,n,`”`]})]})}},{key:`type`,header:`Type`,sortValue:e=>e.type,render:e=>o(`span`,{className:`text-[11px] text-foreground-muted`,children:e.type})},{key:`status`,header:`Status`,sortValue:e=>+!!e.online,render:e=>t(`span`,{className:`flex items-center gap-1.5`,children:[o(Ie,{online:e.online,deviceName:e.name}),o(`span`,{className:`text-[11px] text-foreground-muted`,children:e.online?`online`:`offline`})]})},{key:`followers`,header:`Accessories in tow`,align:`right`,sortValue:e=>b.get(e.id)??0,render:e=>o(`span`,{className:`tabular-nums text-[11px] text-foreground-muted`,children:b.get(e.id)??0})},{key:`assign`,header:`Assign to`,align:`right`,notSortableReason:`This column is a control, not a value.`,render:e=>t(`select`,{"aria-label":`Location for ${e.name}`,value:``,disabled:s||i.length===0,onChange:t=>{let n=t.target.value;n.length!==0&&l([e.id],n)},className:`max-w-[11rem] rounded border border-border bg-background px-1.5 py-0.5 text-[11px] text-foreground disabled:opacity-50`,children:[o(`option`,{value:``,children:`—`}),i.map(e=>o(`option`,{value:e,children:e},e))]})}],rows:g,rowKey:e=>e.id,minWidthPx:720,mobileMode:`scroll`,emptyMessage:h.active?u(`locations.filter.noMatch`):c})]})}function ut(e){return{id:e.id,parentDeviceId:e.parentDeviceId,location:e.location,type:e.type,stableId:e.stableId??``,...e.primaryChildEntityId===void 0?{}:{primaryChildEntityId:e.primaryChildEntityId},...e.role!==void 0&&e.role!==null?{role:e.role}:{},name:e.name}}function dt(e,t){let n=t.map(ut),r=[];for(let i of t)i.isCamera&&i.location===e&&r.push({deviceId:i.id,name:i.name,ids:W({selfId:i.id,selfLocation:i.location,candidates:n})});return{entries:r}}var ft=`device-manager:linked-devices`;function pt(e){return{deviceId:e.deviceId,slotRef:ft,value:{slot:`linked-devices`,deviceIds:[...e.ids]}}}e();var $=`__unassigned__`;function mt(){let e=i(),r=ve(),a=at(),{data:s,isLoading:c}=ke(),{data:l}=ye(),{data:u}=Ce(),{data:d}=je(),{data:f,isLoading:p}=Te({projection:`slim`}),m=()=>{e.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]}),e.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),e.invalidateQueries({queryKey:[[`deviceManager`,`listLocationIcons`]]}),e.invalidateQueries({queryKey:[[`deviceManager`,`listLocationDescriptions`]]}),e.invalidateQueries({queryKey:[[`deviceManager`,`listSiteZones`]]})},h=se({onSuccess:m}),g=Ae({onSuccess:m}),_=ie({onSuccess:m}),v=oe({onSuccess:m}),y=ce({onSuccess:m}),b=we({onSuccess:m}),x=pe({onSuccess:m}),S=me({onSuccess:m}),C=ae({onSuccess:m}),w=le({onSuccess:m}),T=ge(),D=n(()=>(f??[]).map(e=>({id:e.id,name:e.name,location:e.location??null,type:String(e.type),isCamera:e.isCamera,parentDeviceId:e.parentDeviceId,online:e.online,role:e.role??null,stableId:e.stableId,primaryChildEntityId:e.primaryChildEntityId??null})),[f]),O=s??[],k=n(()=>Qe(D,O),[D,O]),[A,j]=Ne(),M=A.get(`tab`)===`zones`?`zones`:`locations`,N=A.get(`room`),P=n(()=>Je(D,O),[D,O]),F=N===$,I=F?null:N!==null&&k.some(e=>e.name===N)?N:k[0]?.name??null,L=I===null?null:k.find(e=>e.name===I)??null,R=F?$:I??k[0]?.name??`__unassigned__`,ee=e=>{j(t=>{let n=new URLSearchParams(t);return n.set(`room`,e),n},{replace:!0})},z=c||p,B=_.isPending||g.isPending||h.isPending||y.isPending,te=async e=>{await h.mutateAsync({name:e})},ne=async(e,t)=>{let n=t.trim();n.length===0||n===e||await v.mutateAsync({from:e,to:n})},re=async e=>{let t=dt(e,D);if(t.entries.length===0){await r({title:`Rebuild linked devices`,message:`No camera is assigned to “${e}”.`,confirmLabel:`OK`});return}if(!await r({title:`Rebuild linked devices`,message:`Replace the linked-device list of every camera in “${e}” with what the room contains?\n\n${t.entries.map(e=>`• ${e.name}: ${String(e.ids.length)} device(s)`).join(`
|
|
2
|
-
`)}\n\nAnything linked by hand that is not in this room is lost.`,confirmLabel:`Rebuild`,variant:`danger`}))return;let n=[];for(let e of t.entries)try{await T.mutateAsync(pt(e))}catch(t){n.push(`• ${e.name}: ${t instanceof Error?t.message:String(t)}`)}m(),n.length>0&&await r({title:`Rebuild linked devices`,message:`Not rebuilt:\n\n${n.join(`
|
|
3
|
-
`)}`,confirmLabel:`OK`})},V=async(e,t)=>{await r({title:`Delete location`,message:`Delete the location “${e}”?${t>0?` ${String(t)} device(s) will become unassigned.`:``}`,confirmLabel:`Delete`,variant:`danger`})&&await g.mutateAsync({name:e,cascade:!0})},H=async e=>{await r({title:`Delete zone`,message:`Delete the zone “${e}”? The rooms in it are kept.`,confirmLabel:`Delete`,variant:`danger`})&&await S.mutateAsync({name:e})},W=async(e,t)=>{await y.mutateAsync({location:e,icon:t})},G=async(e,t)=>{await b.mutateAsync({location:e,description:t})},K=d??[],q=async(e,t)=>{await w.mutateAsync({location:e,zone:t})},J=t(`div`,{className:`flex flex-col gap-3`,"data-testid":`locations-section`,children:[z&&o(`p`,{className:`text-xs text-foreground-subtle`,children:`Loading locations and devices…`}),o(Se,{appearance:`pills`,value:R,onValueChange:ee,children:t(Ee,{"aria-label":`Locations`,children:[k.map(e=>{let n=a(He(l,U(e.name)));return t(Oe,{value:e.name,"data-testid":`location-kind-${e.name}`,children:[o(n,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),e.name,o(`span`,{className:`text-foreground-subtle tabular-nums`,children:e.members.length})]},e.name)}),t(Oe,{value:$,"data-testid":`location-kind-unassigned`,children:[`Unassigned`,o(`span`,{className:`text-foreground-subtle tabular-nums`,children:P.length})]})]})}),F||L===null?o(lt,{rows:P,fleet:D,locations:O,busy:B,emptyMessage:z?`Loading…`:`Every top-level device has a room.`,onAssign:(e,t)=>{for(let n of e)_.mutate({deviceId:n,location:t})}}):o(tt,{name:L.name,members:L.members,devices:D,busy:B,icon:He(l,U(L.name)),onPickIcon:e=>W(L.name,e),description:Re(u,U(L.name)),onSaveDescription:e=>G(L.name,e),zones:K,zoneKey:Be(K,U(L.name)),onChangeZone:e=>q(L.name,e),onRename:e=>ne(L.name,e),onDelete:()=>V(L.name,Ue(D,L.name).length),onRebuildLinks:()=>re(L.name)},L.name),O.length===0&&!z&&o(`p`,{className:`text-xs text-foreground-subtle`,children:`No locations yet. Add Ingresso, Salone, Cucina…`})]});return o(Pe,{icon:E,title:`Locations`,subtitle:`Rooms and areas of the site. Assign any device here — storage disks are under Data → Storage.`,defaultSection:`locations`,sectionsLabel:`Locations sections`,actions:M===`zones`?o(st,{busy:x.isPending,onCreate:e=>x.mutateAsync({name:e})}):o(ot,{busy:h.isPending,onCreate:te}),sections:[{id:`locations`,label:`Locations`,ownedParams:[`room`],content:J},{id:`zones`,label:`Zones`,content:o(it,{zones:K,busy:B,onRename:(e,t)=>C.mutateAsync({from:e,to:t}),onDelete:H,onPickIcon:(e,t)=>x.mutateAsync({name:e,icon:t})})}]})}export{mt as LocationsPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./browser-BHo8W_uH.js","./rolldown-runtime-Cyuzqnbw.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{t}from"./vite-preload-helper-kNaey6uv.js";import{K as n,Q as r,S as i,W as a,a as o,b as s,q as c,t 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-DhP-Lgiq.js";import{Ir as f,It as p,Nt as m,Pn as h,Q as g,Qt as _,Yr as v,ar as y,cr as b,fi as x,nr as S,ot as C,pi as w,pr as T}from"./player-overlays-BOsDheHc.js";import{o as E}from"./video-c8H5Zs-y.js";import{t as D}from"./key-round-WrVw9weZ.js";import{t as O}from"./monitor-smartphone-BL4hI9CF.js";import{t as k}from"./unlink-Biu31rTD.js";import{Kn as A,qn as j}from"./client-CLcJeoH9.js";import{Bn as ee,Cn as te,Do as ne,Ft as M,Gl as re,Wn as ie,Z as ae,Zn as N,gu as P,ko as F,wn as I}from"./src-CCd-7AXY.js";import{t as L}from"./useTranslation-Bc5yH9V9.js";import"./mount-BmKHpH-F.js";import{R,i as z,n as oe,r as B,t as V}from"./index-Dbcd0nug.js";import{t as H}from"./AdminPage-BXCcRjRj.js";import{a as U,i as W,r as G,t as K}from"./SessionsList-BFeOCT72.js";r();function q({value:n,size:r=192}){let[a,o]=c(null),[s,l]=c(null);if(d(()=>{let r=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(r)return;let t=e.create;if(typeof t!=`function`){l(`qrcode.create() unavailable in installed version`);return}try{let e=t(n,{errorCorrectionLevel:`M`});r||o(e)}catch(e){r||l(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{r||l(`qrcode library not installed`)}),()=>{r=!0}},[n]),s)return u(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:r,height:r},children:`QR rendering unavailable — use the secret below.`});if(!a)return u(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:r,height:r},children:`Generating…`});let f=a.modules.size,p=r/f,m=[];for(let e=0;e<f;e++)for(let t=0;t<f;t++)a.modules.data[e*f+t]&&m.push(u(`rect`,{x:t*p,y:e*p,width:p,height:p,fill:`currentColor`},`${t}-${e}`));return i(`svg`,{width:r,height:r,viewBox:`0 0 ${r} ${r}`,className:`text-black`,children:[u(`rect`,{x:0,y:0,width:r,height:r,fill:`white`}),m]})}var se=`${A}/connect`,J={public:0,mesh:1,lan:2,"lan-ipv6":3};function ce(e){switch(e.kind){case`public`:return e.interfaceKind===`vpn`?`mesh`:`public`;case`lan-ipv4`:return`lan`;case`lan-ipv6`:return`lan-ipv6`;case`custom`:return`public`;case`loopback`:case`app-link`:return null}}function Y(e){return j(e)}function le(e){return e.startsWith(`https://`)}function ue(e){let t=e.flatMap(e=>{let t=ce(e),n=Y(e.baseUrl);return t===null||n===null?[]:[{endpoint:e,tier:t,origin:n}]}).toSorted((e,t)=>J[e.tier]-J[t.tier]||Number(t.endpoint.plausible)-Number(e.endpoint.plausible)||e.endpoint.priority-t.endpoint.priority),n=new Set;return t.flatMap(({endpoint:e,tier:t,origin:r})=>n.has(r)?[]:(n.add(r),[{origin:r,label:e.label,tier:t,secure:le(r),plausible:e.plausible}]))}function de(e,t,n=null){for(let r of[t,n]){if(r===null)continue;let t=Y(r),n=e.find(e=>e.origin===t);if(n!==void 0)return n}return e[0]??null}function fe(e){let t=new URL(se);return t.searchParams.set(`hub`,e),t.toString()}r();var pe=176,X={scheme:`https`};function me(){let{t:e}=L(),t=F(X),n=ne(X).data?.roles.publicEndpoint.resolved??null;return i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[i(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[u(_,{className:`h-3.5 w-3.5 text-foreground-subtle`}),u(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`connectPhone.title`)})]}),i(`div`,{className:`p-4 space-y-3`,children:[u(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`connectPhone.description`)}),t.isPending?i(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[u(y,{className:`h-3.5 w-3.5 animate-spin`}),e(`connectPhone.loading`)]}):t.isError?i(`div`,{className:`flex items-start gap-2 text-[11px] text-danger`,children:[u(m,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),i(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[u(`div`,{className:`break-words`,children:e(`connectPhone.error`,{message:t.error.message})}),u(ee,{size:`sm`,variant:`ghost`,onClick:()=>void t.refetch(),children:e(`connectPhone.retry`)})]})]}):u(he,{candidates:ue(t.data.endpoints),preferredOrigin:n})]})]})}function he({candidates:e,preferredOrigin:t}){let{t:n}=L(),[r,o]=c(null),s=de(e,r,t),l=a(()=>s?fe(s.origin):null,[s]);if(s===null||l===null)return u(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`connectPhone.empty`)});let d=e=>n(`connectPhone.tier.${e}`),f=e.map(e=>({value:e.origin,label:`${d(e.tier)} — ${e.origin}`}));return i(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:[u(te,{value:l,size:pe,alt:n(`connectPhone.qrAlt`),className:`self-start`}),i(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[i(`label`,{className:`block space-y-1`,children:[u(`span`,{className:`text-[11px] font-medium text-foreground`,children:n(`connectPhone.addressLabel`)}),u(re,{value:s.origin,options:f,onChange:e=>o(e.target.value)}),i(`span`,{className:`block text-[10px] text-foreground-subtle`,children:[d(s.tier),` · `,s.label]})]}),!s.secure&&u(Z,{text:n(`connectPhone.insecure`)}),!s.plausible&&u(Z,{text:n(`connectPhone.implausible`)}),i(`div`,{className:`space-y-1`,children:[u(`span`,{className:`text-[11px] font-medium text-foreground`,children:n(`connectPhone.linkLabel`)}),i(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[u(`code`,{className:`flex-1 min-w-0 font-mono text-[11px] text-foreground break-all select-all`,children:l}),u(M,{value:l,srLabel:n(`connectPhone.linkLabel`)})]})]}),u(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`connectPhone.signInHint`)})]})]})}function Z({text:e}){return i(`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:[u(m,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),u(`span`,{children:e})]})}r();function ge(e){return new Date(e).toLocaleDateString()}function _e(){let e=N(),t=P.useUtils(),r=P.auth.listLinkableProviders.useQuery(),a=P.auth.listOwnExternalIdentities.useQuery(),[o,s]=c(null),[l,f]=c(()=>z(window.location.search)),p=n(null),m=W(`Linking a sign-in account`),h=n(null);d(()=>()=>h.current?.(),[]);let[_,v]=c(null);d(()=>{if(l===null)return;let e=new URL(window.location.href);e.searchParams.delete(`linked`),e.searchParams.delete(`linkError`),window.history.replaceState({},``,e.pathname+e.search+e.hash)},[l]);let S=P.auth.beginExternalLink.useMutation({onSuccess:({url:e})=>{let n=p.current;if(p.current=null,n===null||n.closed){window.location.assign(e);return}let r=e=>{v(null),f(z(`?${e}`)),t.auth.listOwnExternalIdentities.invalidate()};h.current?.(),h.current=oe(n,{onReturn:e=>{e.target===`profile`&&r(e.query)},onDone:e=>{e.target===`profile`&&r(e.query)},onClosed:()=>{h.current?.(),h.current=null,t.auth.listOwnExternalIdentities.invalidate()}}),n.location.href=g(B(e))},onError:e=>{p.current?.close(),p.current=null,v(null),s(e.message)}}),C=P.auth.unlinkOwnExternalIdentity.useMutation({onSuccess:()=>void t.auth.listOwnExternalIdentities.invalidate(),onError:e=>s(e.message)}),T=r.data??[],E=a.data??[],D=_!==null&&E.some(e=>e.provider===_);if(d(()=>{!D||_===null||(v(null),f({kind:`linked`,provider:_}))},[D,_]),T.length===0&&E.length===0)return null;let O=new Set(E.map(e=>e.provider)),A=e=>T.find(t=>t.provider===e)?.label??e,j=async(t,n)=>{await e({title:`Unlink sign-in account`,message:`Stop signing in with this ${n} account?`,confirmLabel:`Unlink`,variant:`danger`})&&(s(null),C.mutate({provider:t.provider,subject:t.subject}))};return i(`div`,{"data-testid":`linked-sign-ins`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[m.dialog,i(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[u(b,{className:`h-3.5 w-3.5 text-foreground-subtle`}),u(`div`,{className:`text-xs font-semibold text-foreground`,children:`Linked sign-in accounts`})]}),i(`div`,{className:`p-4 space-y-3`,children:[u(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Sign in with an external account instead of your password. Only accounts you link here can sign you in; your two-factor authentication still applies.`}),l?.kind===`linked`&&i(`div`,{className:`flex items-center gap-2 rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2 text-xs text-foreground`,children:[u(x,{className:`h-3.5 w-3.5 text-emerald-500 shrink-0`}),`Linked your `,A(l.provider),` account.`]}),(l?.kind===`error`||o)&&i(`div`,{className:`flex items-center gap-2 rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[u(w,{className:`h-3.5 w-3.5 shrink-0`}),o??(l?.kind===`error`?l.message:``)]}),E.length>0&&u(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:E.map(e=>{let t=e.providerLabel??e.provider;return i(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`font-medium text-foreground truncate`,children:[t,!e.available&&u(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:`provider unavailable`})]}),i(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:[e.label??e.subject,` · linked `,ge(e.linkedAt)]})]}),i(`button`,{onClick:()=>void j(e,t),disabled:C.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:[u(k,{className:`h-3 w-3`}),`Unlink`]})]},`${e.provider}|${e.subject}`)})}),u(`div`,{className:`flex flex-wrap gap-2`,children:T.filter(e=>!O.has(e.provider)).map(e=>i(`button`,{onClick:()=>{s(null),f(null),m.requestProof().then(t=>{t!==null&&(p.current=V(null),v(p.current===null?null:e.provider),S.mutate({provider:e.provider,reauthToken:t}))})},disabled:S.isPending,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[S.isPending&&S.variables?.provider===e.provider?u(y,{className:`h-3 w-3 animate-spin`}):u(b,{className:`h-3 w-3`}),`Link `,e.label]},e.provider))})]})]})}r();function Q(e){return e.message.length>0?e.message:`Request failed`}function ve(){let{logout:e}=R(),t=N(),n=P.useUtils(),r=P.auth.listOwnSessions.useQuery(),[a,o]=c(null),s=P.auth.revokeOwnSession.useMutation({onSuccess:()=>void n.auth.listOwnSessions.invalidate(),onError:e=>o(`Sign out failed: ${Q(e)}`)}),l=P.auth.logout.useMutation({onSuccess:()=>e(),onError:e=>o(`Sign out failed: ${Q(e)}`)}),d=async e=>{await t({title:`Sign out this session`,message:`${U(e.client).label} will have to sign in again.`,confirmLabel:`Sign out`,variant:`danger`})&&(o(null),s.mutate({id:e.id}))},f=async()=>{await t({title:`Sign out everywhere`,message:`Every session of your account ends, this browser included: you will be signed out here too and every device has to sign in again.`,confirmLabel:`Sign out everywhere`,variant:`danger`})&&(o(null),l.mutate({everywhere:!0}))};return i(`div`,{"data-testid":`my-sessions`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[i(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[u(O,{className:`h-3.5 w-3.5 text-foreground-subtle`}),u(`div`,{className:`text-xs font-semibold text-foreground`,children:`Active sessions`})]}),i(`div`,{className:`p-4 space-y-3`,children:[u(`p`,{className:`text-[11px] text-foreground-subtle`,children:`The browsers and apps signed in to your account. Signing one out ends it at once.`}),a!==null&&u(`div`,{className:`text-[11px] text-danger`,children:a}),u(K,{sessions:r.data??[],isLoading:r.isLoading,loadError:r.isError?r.error?.message??`Request failed`:null,emptyText:`No active sessions.`,onRevoke:e=>void d(e),revokingId:s.isPending?s.variables?.id??null:null}),u(`div`,{className:`flex justify-end`,children:i(`button`,{onClick:()=>void f(),disabled:l.isPending,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:[l.isPending?u(y,{className:`h-3 w-3 animate-spin`}):u(E,{className:`h-3 w-3`}),`Sign out everywhere`]})})]})]})}r();var ye={view:{icon:f,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:h,cls:`bg-primary/15 text-primary`},delete:{icon:p,cls:`bg-danger/15 text-danger`}};function be(){let{user:e,logout:t}=R();if(!e)return u(H,{children:u(`div`,{className:`text-xs text-foreground-subtle`,children:`Not signed in.`})});let n=e.isAdmin,r=e.scopes??[];return i(H,{children:[i(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[u(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:e.username.slice(0,1).toUpperCase()}),i(`div`,{className:`flex-1 min-w-0`,children:[u(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),i(`div`,{className:`text-[11px] text-foreground-subtle`,children:[n?`Administrator`:`User`,` · session id`,` `,i(`span`,{className:`font-mono`,children:[e.id.slice(0,8),`…`]})]})]})]}),n&&i(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5`,children:[u(T,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),i(`div`,{children:[u(`div`,{className:`font-semibold text-foreground`,children:`Unrestricted access`}),u(`p`,{className:`text-foreground-subtle mt-0.5`,children:`Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below.`})]})]}),u(xe,{}),u(Se,{username:e.username}),u(Ce,{}),u(_e,{}),u(G,{}),u(ve,{}),u(me,{}),r.length>0&&i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[i(`div`,{className:`px-4 py-2 border-b border-border`,children:[u(`div`,{className:`text-xs font-semibold text-foreground`,children:`Granted scopes`}),u(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Baked into your session token at login; sign out + back in to refresh after changes.`})]}),i(`div`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[u(`div`,{children:`Type`}),u(`div`,{children:`Target`}),u(`div`,{children:`Access`})]}),u(`ul`,{className:`divide-y divide-border`,children:r.map((e,t)=>i(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[u(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),u(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?ae(e.selector):e.target}),u(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(t=>{let n=e.access.includes(t),{icon:r,cls:a}=ye[t];return i(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${n?a:`bg-transparent text-foreground-subtle/40 line-through`}`,title:n?`Can ${t}`:`Cannot ${t}`,children:[u(r,{className:`h-3 w-3`}),t]},t)})})]},t))})]}),u(`div`,{className:`flex justify-end`,children:i(`button`,{onClick:t,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground transition-colors`,children:[u(E,{className:`h-3 w-3`}),`Sign out`]})})]})}function xe(){let e=C(),[t,n]=c(``),[r,a]=c(``),[o,s]=c(``),[d,f]=c(null),p=l({mutationFn:t=>e.changeOwnPassword(t),onSuccess:()=>{f({kind:`success`,msg:`Password updated.`}),n(``),a(``),s(``)},onError:e=>{f({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),m=r.length>0&&o.length>0&&r!==o,h=r.length>0&&r.length<8,g=t.length>=1&&r.length>=8&&r===o;return i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[i(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[u(D,{className:`h-3.5 w-3.5 text-foreground-subtle`}),u(`div`,{className:`text-xs font-semibold text-foreground`,children:`Change password`})]}),i(`div`,{className:`p-4 space-y-3`,children:[u($,{label:`Current password`,value:t,onChange:n,autoComplete:`current-password`}),u($,{label:`New password`,value:r,onChange:a,autoComplete:`new-password`,hint:`At least 8 characters.`}),u($,{label:`Confirm new password`,value:o,onChange:s,autoComplete:`new-password`}),(m||h)&&u(`div`,{className:`text-[11px] text-danger`,children:m?`Passwords do not match.`:`New password must be at least 8 characters.`}),d&&i(`div`,{className:`text-[11px] flex items-center gap-1 ${d.kind===`success`?`text-emerald-500`:`text-danger`}`,children:[d.kind===`success`?u(x,{className:`h-3 w-3`}):u(w,{className:`h-3 w-3`}),d.msg]}),u(`div`,{className:`flex justify-end`,children:i(`button`,{onClick:()=>{f(null),p.mutate({currentPassword:t,newPassword:r})},disabled:!g||p.isPending,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[p.isPending?u(y,{className:`h-3 w-3 animate-spin`}):u(S,{className:`h-3 w-3`}),`Update password`]})})]})]})}function $({label:e,value:t,onChange:n,autoComplete:r,hint:a}){return i(`div`,{className:`space-y-1`,children:[u(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),u(`input`,{type:`password`,value:t,onChange:e=>n(e.target.value),autoComplete:r,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),a&&u(`div`,{className:`text-[10px] text-foreground-subtle`,children:a})]})}function Se({username:e}){let t=C(),n=o({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>t.getOwnTotpStatus()}),r=n.data,[f,p]=c(null),[m,h]=c(``),[g,b]=c(null),[S,T]=c(!1),E=l({mutationFn:()=>t.setupOwnTotp(),onSuccess:e=>{p({secret:e.secret,otpauthUrl:e.otpauthUrl}),h(``),b(null)},onError:e=>b(e instanceof Error?e.message:`Setup failed`)}),D=l({mutationFn:e=>t.confirmOwnTotp(e),onSuccess:()=>{p(null),h(``),b(null),n.refetch()},onError:e=>b(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),O=W(`Turning off two-factor authentication`),k=l({mutationFn:async()=>{let e=await O.requestProof();return e===null?null:t.disableOwnTotp({reauthToken:e})},onSuccess:()=>{b(null),n.refetch()},onError:e=>b(e instanceof Error?e.message:`Disable failed`)});d(()=>{if(!S)return;let e=setTimeout(()=>T(!1),1500);return()=>clearTimeout(e)},[S]);let A=a(()=>n.isLoading?`loading`:f?`setup_in_progress`:r?.enabled?`enrolled`:`not_enrolled`,[n.isLoading,r?.enabled,f]);return i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[O.dialog,i(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[u(_,{className:`h-3.5 w-3.5 text-foreground-subtle`}),u(`div`,{className:`text-xs font-semibold text-foreground`,children:`Two-factor authentication`})]}),i(`div`,{className:`p-4 space-y-3`,children:[A===`loading`&&i(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[u(y,{className:`h-3.5 w-3.5 animate-spin`}),`Checking status…`]}),A===`not_enrolled`&&i(s,{children:[u(`div`,{className:`text-xs text-foreground-subtle`,children:`2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login.`}),u(`div`,{className:`flex justify-end`,children:i(`button`,{onClick:()=>{b(null),E.mutate()},disabled:E.isPending,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[E.isPending?u(y,{className:`h-3 w-3 animate-spin`}):u(_,{className:`h-3 w-3`}),`Enable 2FA`]})})]}),A===`setup_in_progress`&&f&&i(s,{children:[i(`div`,{className:`text-[11px] text-foreground-subtle`,children:[`Scan the QR code (or enter the secret manually) into your authenticator app for`,` `,u(`span`,{className:`font-mono`,children:e}),`, then enter the 6-digit code below to confirm.`]}),i(`div`,{className:`flex flex-col items-center gap-3`,children:[u(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:u(q,{value:f.otpauthUrl,size:180})}),i(`div`,{className:`w-full`,children:[u(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:`Secret (manual entry)`}),i(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[u(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:f.secret}),i(`button`,{onClick:()=>{f&&navigator.clipboard.writeText(f.secret).then(()=>T(!0))},className:`inline-flex items-center gap-1 text-[10px] text-foreground-subtle hover:text-foreground`,children:[S?u(x,{className:`h-3 w-3 text-emerald-500`}):u(v,{className:`h-3 w-3`}),S?`Copied`:`Copy`]})]})]})]}),i(`div`,{className:`space-y-1`,children:[u(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),u(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:m,onChange:e=>h(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary`})]}),g&&i(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[u(w,{className:`h-3 w-3`}),g]}),i(`div`,{className:`flex justify-end gap-2`,children:[u(`button`,{onClick:()=>{p(null),b(null),h(``)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),i(`button`,{onClick:()=>{b(null),D.mutate({code:m})},disabled:D.isPending||m.length!==6,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[D.isPending?u(y,{className:`h-3 w-3 animate-spin`}):u(x,{className:`h-3 w-3`}),`Confirm`]})]})]}),A===`enrolled`&&r&&i(s,{children:[i(`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:[u(x,{className:`h-4 w-4 mt-0.5 text-emerald-500 shrink-0`}),i(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[u(`div`,{className:`font-medium`,children:`2FA is active`}),i(`div`,{className:`text-foreground-subtle`,children:[`Enrolled on`,` `,r.confirmedAt?new Date(r.confirmedAt).toLocaleString():`—`]})]})]}),g&&i(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[u(w,{className:`h-3 w-3`}),g]}),u(`div`,{className:`flex justify-end`,children:i(`button`,{onClick:()=>{b(null),k.mutate()},disabled:k.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:[k.isPending?u(y,{className:`h-3 w-3 animate-spin`}):u(_,{className:`h-3 w-3`}),`Disable 2FA`]})})]})]})]})}function Ce(){return ie(`auth-webauthn/passkey-enrollment`)?u(I,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}export{be as MyAccessPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,W as i,q 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-DhP-Lgiq.js";import{D as s,It as c,ar as l,cn as u,di as d,dt as f,ot as p}from"./player-overlays-BOsDheHc.js";import{i as m,o as h}from"./video-c8H5Zs-y.js";import{t as g}from"./key-round-WrVw9weZ.js";import{t as _}from"./octagon-alert-jd1vv87l.js";import{An as v,Bn as y,Dn as b,Ht as x,Ln as S,Nl as C,Nt as w,On as ee,Pt as T,Qn as E,Tn as te,Ut as ne,Vt as re,Xl as ie,Zl as ae,Zn as oe,ar as D,gu as O,iu as k,jn as se,kn as ce,ma as le}from"./src-CCd-7AXY.js";import{R as ue,a as de}from"./index-Dbcd0nug.js";n();function A({id:e,title:t,icon:n,description:i,actions:a,tone:c=`default`,notice:l=null,onDismissNotice:u,children:d}){return o(re,{headingId:`access-${e}`,title:t,icon:n,actions:a,testId:`access-${e}`,children:r(`div`,{className:`${s} space-y-3`,children:[o(`div`,{className:k(`text-[11px] leading-relaxed`,c===`danger`?`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-foreground`:`text-foreground-subtle`),children:i}),l!==null&&o(pe,{notice:l,onDismiss:u}),d]})})}var fe={success:{icon:d,line:`border-success/30 text-foreground`,mark:`text-success`},danger:{icon:_,line:`border-danger/40 text-danger`,mark:`text-danger`}};function pe({notice:e,onDismiss:t}){let n=fe[e.tone],i=n.icon;return r(`div`,{role:e.tone===`danger`?`alert`:`status`,className:k(`flex items-start gap-2 rounded-md border bg-surface px-3 py-2 text-[11px]`,n.line),children:[o(i,{className:k(`mt-0.5 h-3.5 w-3.5 shrink-0`,n.mark),"aria-hidden":!0}),o(`span`,{className:`min-w-0 flex-1`,children:e.message}),t!==void 0&&o(ae,{type:`button`,variant:`ghost`,size:`sm`,icon:f,"aria-label":`Dismiss`,onClick:t,className:`-my-1 h-5 w-5`})]})}function j(){let{data:e}=C();return i(()=>{let t=new Map;for(let n of e??[])t.set(n.id,n.username);return t},[e])}function M(e,t=null){return e===null?t:{tone:`danger`,message:e}}var N={active:`Active`,expired:`Expired`,revoked:`Revoked`,current:`This session`},me={active:`success`,expired:`warning`,revoked:`default`,current:`info`},he={current:0,active:1,expired:2,revoked:3};function P(e,t){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?`—`:n.toLocaleString()}function ge({status:e}){return o(D,{variant:me[e],className:`text-[10px]`,children:N[e]})}function _e({row:e,action:t}){if(!t.isAvailable(e))return null;let n=t.icon,i=t.busyId===e.id;return r(y,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>t.onRun(e),disabled:t.disabled,"aria-label":`${t.label} ${e.name}`,className:`text-danger hover:bg-danger/10`,children:[i?o(l,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):o(n,{className:`h-3 w-3`,"aria-hidden":!0}),t.label]})}function ve(e){return[{key:`name`,header:`Name`,sortValue:e=>e.name.toLowerCase(),render:e=>r(`div`,{className:`min-w-0 max-w-[18rem]`,children:[o(`div`,{className:`truncate font-medium text-foreground`,title:e.name,children:e.name}),e.detail!==null&&o(`div`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,title:e.detail,children:e.detail})]})},e.hideOwner?null:{key:`owner`,header:`Owner`,sortValue:e=>e.ownerName.toLowerCase(),render:e=>e.ownerName},{key:`kind`,header:`Kind / scope`,sortValue:e=>e.kind.toLowerCase(),nowrap:!1,render:e=>r(`div`,{className:`min-w-[8rem] max-w-[16rem]`,children:[o(`div`,{className:`text-foreground`,children:e.kind}),e.scope!==null&&o(`div`,{className:`line-clamp-2 text-[10px] text-foreground-subtle`,title:e.scope,children:e.scope})]})},{key:`status`,header:`Status`,sortValue:e=>he[e.status],render:e=>o(ge,{status:e.status})},{key:`created`,header:`Created`,sortValue:e=>e.createdAt,render:e=>o(`span`,{className:`text-foreground-subtle`,children:P(e.createdAt,`—`)})},{key:`lastUsed`,header:`Last used`,sortValue:e=>e.lastUsedAt,render:e=>o(`span`,{className:`text-foreground-subtle`,children:P(e.lastUsedAt,`Never`)})},{key:`expires`,header:`Expires`,sortValue:e=>e.expiresAt,render:t=>o(`span`,{className:`text-foreground-subtle`,children:P(t.expiresAt,e.expiresNone)})},e.action===null?null:{key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:t=>e.action===null?null:o(_e,{row:t,action:e.action})}].filter(e=>e!==null)}n();var F=6,I={"current-session":`your current session`,"not-active":`already gone`};function L(e,t){return`${String(e)} ${e===1?t.one:t.many}`}function ye(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return[...t.entries()].map(([e,t])=>`${String(t)} ${N[e].toLowerCase()}`).join(`, `)}function R(e,t){let n=e.slice(0,F).map(e=>`• ${e.name} — ${e.ownerName}`),r=e.length>F?[`…and ${String(e.length-F)} more`]:[];return[`${L(e.length,t)} (${ye(e)}) stop working at once. This cannot be undone.`,``,...n,...r].join(`
|
|
2
|
-
`)}function z(e,t,n){let r=E(),i=O.auth.revokeCredentials.useMutation(),[o,s]=a(null);return{run:async a=>{if(a.length===0)return!1;let o=String(a.length),c=await r({title:`Revoke ${L(a.length,t)}?`,message:R(a,t),label:`Type ${o} to confirm`,placeholder:o,confirmLabel:`Revoke ${o}`,variant:`danger`,validate:e=>e.trim()===o?null:`Type ${o} — the number of ${t.many} selected`});if(c===null||c.trim()!==o)return!1;s(null);try{let n=await i.mutateAsync({kind:e,ids:a.map(e=>e.id),confirmCount:a.length}),r=n.skipped.map(e=>I[e.reason]??e.reason);return s({tone:`success`,message:`Revoked ${L(n.revoked.length,t)}.`+(r.length>0?` Skipped ${String(r.length)}: ${[...new Set(r)].join(`, `)}.`:``)}),!0}catch(e){return s({tone:`danger`,message:`The revoke failed: ${e instanceof Error?e.message:`request failed`}. The list below is reloaded — check what is left.`}),!1}finally{n()}},busy:i.isPending,outcome:o,dismiss:()=>s(null)}}function be(e,t){let n=E(),r=O.auth.revokeCredentials.useMutation(),[i,o]=a(null);return{run:async i=>{if(i.length===0)return!1;let a=String(i.length),s=await n({title:`Revoke ${L(i.length,e)}?`,message:R(i,e),label:`Type ${a} to confirm`,placeholder:a,confirmLabel:`Revoke ${a}`,variant:`danger`,validate:t=>t.trim()===a?null:`Type ${a} — the number of ${e.many} selected`});if(s===null||s.trim()!==a)return!1;o(null);let c=i.filter(e=>e.kind===`Scoped`).map(e=>e.id),l=i.filter(e=>e.kind===`Admin`).map(e=>e.id);try{let t=[],n=[];if(c.length>0){let e=await r.mutateAsync({kind:`scoped-token`,ids:c,confirmCount:c.length});t.push(...e.revoked),n.push(...e.skipped)}if(l.length>0){let e=await r.mutateAsync({kind:`admin-token`,ids:l,confirmCount:l.length});t.push(...e.revoked),n.push(...e.skipped)}let i=n.map(e=>I[e.reason]??e.reason);return o({tone:`success`,message:`Revoked ${L(t.length,e)}.`+(i.length>0?` Skipped ${String(i.length)}: ${[...new Set(i)].join(`, `)}.`:``)}),!0}catch(e){return o({tone:`danger`,message:`The revoke failed: ${e instanceof Error?e.message:`request failed`}. The list below is reloaded — check what is left.`}),!1}finally{t()}},busy:r.isPending,outcome:i,dismiss:()=>o(null)}}n();var xe={searchText:e=>[e.name,e.detail??``,e.ownerName,e.kind,e.scope??``],facetGroups:[{id:`status`,value:e=>e.status},{id:`owner`,value:e=>e.ownerName},{id:`kind`,value:e=>e.kind}]},Se={status:`Status`,owner:`Owner`,kind:`Kind`},Ce=e=>e.status!==`current`,we=[`active`,`current`];function B({rows:e,label:t,isLoading:n,loadError:s,emptyText:c,hideOwner:u=!1,expiresNone:d=`Never`,action:f,bulk:p,defaultStatus:m=we}){let[h]=a(()=>m.length===0?{search:``,facets:[]}:{search:``,facets:[],groups:{status:[...m]}}),g=w(e,xe,h),[_,v]=a(()=>new Set),y=i(()=>ve({hideOwner:u,expiresNone:d,action:f??null}),[u,d,f]),b=i(()=>p===void 0?()=>!1:e=>Ce(e)&&p.isSelectable(e),[p]),C=i(()=>g.rows.filter(e=>_.has(e.id)&&b(e)),[g.rows,_,b]);return n?r(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[o(l,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),`Loading `,t,`…`]}):s===null?r(`div`,{className:`space-y-3`,children:[o(T,{state:g.state,facets:g.facets,groups:g.groups.filter(e=>!(u&&e.id===`owner`)).map(e=>({...e,label:Se[e.id]??e.id,...e.id===`status`?{facetLabel:e=>N[e]??e}:{}})),labels:{searchPlaceholder:`Search ${t}…`,searchLabel:`Search ${t}`,facetsLabel:`Filter ${t}`,clearLabel:`Clear filters`},onSearch:g.setSearch,onToggleFacet:g.toggleFacet,onToggleGroupFacet:g.toggleGroupFacet,onClear:g.clear}),p!==void 0&&o(Te,{bulk:p,shown:g.rows.filter(b),targets:C,onSelect:v}),o(x,{columns:y,rows:g.rows,rowKey:e=>e.id,minWidthPx:u?760:860,mobileMode:`scroll`,maxBodyHeight:ne,defaultSort:{columnKey:`created`,dir:`desc`},pageSize:25,paginationLabels:{navLabel:`${t} pages`,previous:`Previous page`,next:`Next page`,range:(e,t,n)=>`${e}–${t} of ${n}`},emptyMessage:g.active?`No ${t} match the filters.`:c,rowClassName:e=>e.status===`revoked`||e.status===`expired`?`opacity-70`:void 0,...p===void 0?{}:{selection:{selected:_,onChange:v,isSelectable:b,rowLabel:e=>`Select ${e.name} (${e.ownerName})`,pageLabel:`Select every ${p.noun.one} on this page`}}})]}):o(S,{title:`Could not load ${t}`,message:s})}function Te({bulk:e,shown:t,targets:n,onSelect:i}){let{revoke:a,noun:s}=e,u=(e.quickSelect??[]).map(e=>({...e,rows:t.filter(e.match)})).filter(e=>e.rows.length>0),d=async()=>{await a.run(n)&&i(new Set)};return r(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`bulk-bar`,children:[t.length>0&&r(y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(new Set(t.map(e=>e.id))),children:[`Select all `,String(t.length),` shown`]}),u.map(e=>r(y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(new Set(e.rows.map(e=>e.id))),children:[e.label,` (`,String(e.rows.length),`)`]},e.label)),n.length>0&&r(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[r(`span`,{className:`text-[11px] tabular-nums text-foreground`,"aria-live":`polite`,children:[L(n.length,s),` selected`]}),r(y,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>i(new Set),children:[o(f,{className:`h-3 w-3`,"aria-hidden":!0}),`Clear selection`]}),r(y,{type:`button`,variant:`danger`,size:`sm`,disabled:a.busy,onClick:()=>void d(),children:[a.busy?o(l,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):o(c,{className:`h-3 w-3`,"aria-hidden":!0}),`Revoke `,L(n.length,s),`…`]})]})]})}var V=(e,t)=>t===null?`—`:e.get(t)??t;function H(e,t){return e!=null&&e<=t?`expired`:`active`}function Ee(e,t,n){return{id:e.id,name:n.client(e.client),detail:e.ip,ownerId:e.userId,ownerName:V(t,e.userId),kind:n.method(e.method),scope:null,status:e.current?`current`:`active`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function De(e,t){return{id:e.id,name:e.integrationId,detail:null,ownerId:e.userId,ownerName:e.username,kind:e.integrationId,scope:t,status:e.revokedAt===null?`active`:`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:null}}var Oe=`Scoped`,U=`Admin`;function ke(e,t,n,r,i){return{id:e.id,name:e.name,detail:`${e.tokenPrefix}…`,ownerId:t,ownerName:V(n,t),kind:Oe,scope:r,status:H(e.expiresAt,i),createdAt:e.createdAt,lastUsedAt:e.lastUsedAt??null,expiresAt:e.expiresAt??null}}function Ae(e,t,n){return{id:e.id,name:e.name,detail:`${e.tokenPrefix}…`,ownerId:e.createdBy,ownerName:V(t,e.createdBy),kind:U,scope:`Full administrator`,status:e.revokedAt===null?H(e.expiresAt,n):`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}var je={"grid-view":`Grid`,"events-view":`Events`};function Me(e,t){return e.map(e=>t.get(e)??`#${String(e)}`).join(`, `)}function Ne(e,t,n,r){let i=je[e.scope.kind];return{id:e.id,name:`${i} · ${String(e.scope.deviceIds.length)} camera${e.scope.deviceIds.length===1?``:`s`}`,detail:`${e.tokenPrefix}…`,ownerId:e.userId,ownerName:V(t,e.userId),kind:e.scope.talk===!0?`${i} + talk`:i,scope:Me(e.scope.deviceIds,n),status:H(e.expiresAt,r),createdAt:e.createdAt,lastUsedAt:e.lastUsedAt??null,expiresAt:e.expiresAt}}function W(e){return`${e.provider}\u0000${e.subject}`}function Pe(e,t){return{id:W(e),name:e.label??e.subject,detail:e.issuer,ownerId:e.userId,ownerName:V(t,e.userId),kind:e.provider,scope:null,status:`active`,createdAt:e.linkedAt,lastUsedAt:null,expiresAt:null}}function Fe(e,t){let n=e.allowedProviders;return{id:e.id,name:e.label,detail:`${e.tokenPrefix}…`,ownerId:e.userId??null,ownerName:V(t,e.userId??null),kind:e.isAdmin===!0?`Admin`:`Regular`,scope:n===void 0||n===`*`?`All providers`:n.join(`, `)||`All providers`,status:`active`,createdAt:e.createdAt??null,lastUsedAt:e.lastUsedAt??null,expiresAt:null}}var G=40,Ie=[{test:/Electron\//,name:`CamStack desktop`},{test:/Edg(e|A|iOS)?\//,name:`Edge`},{test:/OPR\/|Opera/,name:`Opera`},{test:/Firefox\/|FxiOS\//,name:`Firefox`},{test:/Chrome\/|CriOS\//,name:`Chrome`},{test:/Version\/[\d.]+.*Safari\//,name:`Safari`}],Le=[{test:/iPhone/,name:`iPhone`},{test:/iPad/,name:`iPad`},{test:/Android/,name:`Android`},{test:/Mac OS X|Macintosh/,name:`macOS`},{test:/Windows/,name:`Windows`},{test:/CrOS/,name:`ChromeOS`},{test:/Linux/,name:`Linux`}],Re=[{test:/CFNetwork\/.*Darwin\//,name:`CamStack app on iOS`},{test:/^okhttp\//i,name:`CamStack app on Android`},{test:/^(node|undici)\b/i,name:`Script (Node.js)`},{test:/^curl\//i,name:`curl`}];function K(e,t){return e.find(e=>e.test.test(t))?.name??null}function ze(e){return e.length<=G?e:`${e.slice(0,G)}…`}function q(e){if(e===null||e.trim().length===0)return{label:`Unknown device`,raw:null};let t=e.trim(),n=K(Re,t);if(n!==null)return{label:n,raw:t};let r=K(Ie,t),i=K(Le,t);return r!==null&&i!==null?{label:`${r} on ${i}`,raw:t}:r===null?{label:ze(t),raw:t}:{label:r,raw:t}}var J={password:`Password`,passkey:`Passkey`,sso:`Single sign-on`,handoff:`App hand-off`,exchange:`Session exchange`};function Y(e){return J[e]??e}function X(e){if(e==null)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}n();function Z(e,t){return e instanceof Error&&e.message.length>0?e.message:t}function Be(n){let i=p(),[s,c]=a(!1),[u,d]=a(``),[f,m]=a(null),[h,_]=a(null),x=t(null),S=e(e=>{x.current?.(e),x.current=null,c(!1),d(``),m(null),_(null)},[]),C=e(()=>new Promise(e=>{x.current?.(null),x.current=e,_(null),c(!0)}),[]),w=async()=>{m(`password`),_(null);try{let{reauthToken:e}=await i.reauthenticate({password:u});S(e)}catch(e){_(Z(e,`Password is incorrect`)),m(null)}},T=async()=>{m(`passkey`),_(null);try{let{optionsJSON:e}=await i.reauthBeginPasskey(),t=await de({optionsJSON:e}),{reauthToken:n}=await i.reauthenticate({passkeyResponse:Object.fromEntries(Object.entries(t))});S(n)}catch(e){_(Z(e,`Passkey verification failed`)),m(null)}};return{requestProof:C,dialog:o(te,{open:s,onOpenChange:e=>!e&&S(null),children:r(b,{children:[r(v,{children:[o(se,{children:`Confirm it’s you`}),r(ee,{children:[n,` needs your password or a passkey, even though you are signed in.`]})]}),r(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),u.length>0&&f===null&&w()},children:[o(ie,{type:`password`,autoComplete:`current-password`,placeholder:`Current password`,value:u,onChange:e=>d(e.target.value),"aria-label":`Current password`}),h!==null&&o(`p`,{role:`alert`,className:`text-xs text-danger`,children:h}),r(ce,{className:`flex flex-wrap gap-2`,children:[r(y,{type:`button`,variant:`outline`,disabled:f!==null,onClick:()=>void T(),children:[f===`passkey`?o(l,{className:`h-4 w-4 animate-spin`}):o(g,{className:`h-4 w-4`}),`Use a passkey`]}),r(y,{type:`submit`,disabled:u.length===0||f!==null,children:[f===`password`&&o(l,{className:`h-4 w-4 animate-spin`}),`Confirm`]})]})]})]})})}}n();var Q={one:`share link`,many:`share links`};function $(e){let t=oe(),n=O.useUtils(),r=O.auth.listShareTokens.useQuery({owner:e}),o=j(),{data:s}=le({isCamera:!0,projection:`slim`}),[l,u]=a(null),d=()=>void n.auth.listShareTokens.invalidate(),f=O.auth.revokeShareToken.useMutation({onSuccess:d,onError:e=>u(`Revoke failed: ${e.message}`)}),p=i(()=>{let e=new Map;for(let t of s??[])e.set(t.id,t.name);return e},[s]),m=Date.now(),h=(r.data??[]).map(e=>Ne(e,o,p,m)),g=async e=>{await t({title:`Revoke share link`,message:`Anyone holding this link to ${e.scope??e.name} loses access immediately. This cannot be undone.`,confirmLabel:`Revoke`,variant:`danger`})&&(u(null),f.mutate({id:e.id}))};return{rows:h,refresh:d,error:l,clearError:()=>u(null),isLoading:r.isLoading,loadError:r.isError?r.error?.message??`Request failed`:null,action:{label:`Revoke`,icon:c,isAvailable:()=>!0,onRun:e=>void g(e),busyId:f.isPending?f.variables?.id??null:null,disabled:f.isPending}}}function Ve(){let e=$(`self`);return o(A,{notice:M(e.error),onDismissNotice:e.clearError,id:`my-share-links`,title:`Share links`,icon:u,description:`View-only links you created in the viewer app to share a grid or the events of some cameras. Revoking a link stops it working everywhere it was sent.`,children:o(B,{rows:e.rows,label:`share links`,isLoading:e.isLoading,loadError:e.loadError,emptyText:`You have no share links.`,hideOwner:!0,action:e.action})})}function He(){let{user:e}=ue();return e?.isAdmin?o(Ue,{}):null}function Ue(){let e=$(`all`),t=z(`share-link`,Q,e.refresh);return o(A,{notice:M(e.error,t.outcome),onDismissNotice:()=>{e.clearError(),t.dismiss()},id:`share-links`,title:`Share links`,icon:u,description:`Every user's view-only share links. Revoking one stops it working for whoever it was sent to — a revoked link is deleted and cannot be restored.`,children:o(B,{rows:e.rows,label:`share links`,isLoading:e.isLoading,loadError:e.loadError,emptyText:`No user has any share links.`,action:{...e.action,disabled:e.action.disabled||t.busy},bulk:{revoke:t,noun:Q,isSelectable:()=>!0,quickSelect:[{label:`Select expired`,match:e=>e.status===`expired`}]}})})}function We({sessions:e,isLoading:t,loadError:n,emptyText:i,onRevoke:a,revokingId:s}){return t?r(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[o(l,{className:`h-3.5 w-3.5 animate-spin`}),`Loading sessions…`]}):n===null?e.length===0?o(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center`,children:i}):o(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:e.map(e=>o(Ge,{session:e,revoking:s===e.id,onRevoke:()=>a(e)},e.id))}):r(`div`,{className:`text-[11px] text-danger`,children:[`Could not load sessions: `,n]})}function Ge({session:e,revoking:t,onRevoke:n}){let i=q(e.client);return r(`li`,{"data-testid":`session-row`,className:`flex items-start gap-3 px-3 py-2 text-xs`,children:[o(m,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-foreground-subtle`}),r(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[r(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[o(`span`,{className:`font-medium text-foreground truncate`,title:i.raw??void 0,children:i.label}),e.current&&o(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:`This device`})]}),r(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[o(`span`,{children:Y(e.method)}),o(`span`,{className:`font-mono`,children:e.ip??`IP unknown`}),r(`span`,{children:[`Last active `,X(e.lastUsedAt)]}),r(`span`,{children:[`Expires `,X(e.expiresAt)]})]})]}),!e.current&&r(`button`,{onClick:n,disabled:t,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[t?o(l,{className:`h-3 w-3 animate-spin`}):o(h,{className:`h-3 w-3`}),`Sign out`]})]})}export{z as _,q as a,M as b,U as c,W as d,Pe as f,B as g,ke as h,Be as i,Ae as l,Ee as m,He as n,Y as o,De as p,Ve as r,X as s,We as t,Fe as u,be as v,j as x,A as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$i as e}from"./player-overlays-BOsDheHc.js";var t=e(`circle-slash`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]);export{t};
|