@camstack/addon-admin-ui 1.2.18 → 1.2.20
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/{AddLocationWizard-BowIG3iq.js → AddLocationWizard-CXk6-CfE.js} +1 -1
- package/dist/assets/{AddonCollectionPage-DzUEOYUV.js → AddonCollectionPage-0nLq2rl-.js} +1 -1
- package/dist/assets/{Addons-B5DucodR.js → Addons-xRdQceXr.js} +1 -1
- package/dist/assets/{AdminTabs-C-SMNF-6.js → AdminTabs-DTfYeQEd.js} +1 -1
- package/dist/assets/{AiProfiles-D65CezzL.js → AiProfiles-B_8O9pbH.js} +1 -1
- package/dist/assets/{BrokerForm-ENHOk64X.js → BrokerForm-gZgHMFYN.js} +1 -1
- package/dist/assets/{Capabilities-dtlaxRnV.js → Capabilities-BEoS40Pf.js} +1 -1
- package/dist/assets/{CapabilityBadges-QVudw7lC.js → CapabilityBadges-Ce2XZ8Yv.js} +1 -1
- package/dist/assets/{Cluster-9-Ysfuh5.js → Cluster-BM6fgtNM.js} +1 -1
- package/dist/assets/{ClusterRecordingTab-CvimJgTY.js → ClusterRecordingTab-DVJK3FbW.js} +1 -1
- package/dist/assets/{Dashboard-CXFEM2IR.js → Dashboard-C91fHfra.js} +1 -1
- package/dist/assets/{Data-DPmsq4Rb.js → Data-BZs57foL.js} +1 -1
- package/dist/assets/{DetectionIntelligence-CsY0BCKS.js → DetectionIntelligence-qa-cfx58.js} +1 -1
- package/dist/assets/{DeviceAggregateSection-CzThj0Vt.js → DeviceAggregateSection-Bp8H5WE3.js} +1 -1
- package/dist/assets/{DeviceDetail-BWX7NeMm.js → DeviceDetail-BtcySLrm.js} +2 -2
- package/dist/assets/{Devices-CdMd1Rxe.js → Devices-APrmNzXl.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-BPMSAjgX.js → EmbedPlayerPage-Dtfqm4Ev.js} +1 -1
- package/dist/assets/{Events-DlSc5xWS.js → Events-D1lXImuv.js} +1 -1
- package/dist/assets/{FormBuilder-BTBth7Mm.js → FormBuilder-Dp8vzn5o.js} +1 -1
- package/dist/assets/{Identity-BkJfHHax.js → Identity-CZ3RR-b2.js} +1 -1
- package/dist/assets/{IntegrationDetail-DjcVm32z.js → IntegrationDetail-DO1tYdpz.js} +1 -1
- package/dist/assets/{Integrations-CCkqm_Su.js → Integrations-BknAxqyl.js} +1 -1
- package/dist/assets/{Integrations-BstWDI9y.js → Integrations-C7kceJN5.js} +1 -1
- package/dist/assets/{Logs-BKvPV_wj.js → Logs-DT4DSUdh.js} +1 -1
- package/dist/assets/{MotionZonesSettings-C3F5tNrn.js → MotionZonesSettings-CB7gr8F6.js} +1 -1
- package/dist/assets/{MyAccess-D94hQDyr.js → MyAccess-ClfB0G32.js} +1 -1
- package/dist/assets/{Network-DRjrjeQG.js → Network-UCY4Ovp0.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-CL75zTHK.js → NodeAddonsSettingsPanel-DDb1owhe.js} +1 -1
- package/dist/assets/{NodeInferenceDevices-gVLIWG74.js → NodeInferenceDevices-Diun1VPA.js} +1 -1
- package/dist/assets/{Notifications-7spoN22j.js → Notifications-Bsuv6pTz.js} +1 -1
- package/dist/assets/Pipeline-Cfrd99ss.js +1 -0
- package/dist/assets/{Plates-0nXxdKJX.js → Plates-5PCbiCO-.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-BC6o9lqJ.js → PrivacyMaskSettings-DHT_sOZh.js} +1 -1
- package/dist/assets/{ProviderIcon-tK6tKDtF.js → ProviderIcon-Bixvrf-U.js} +1 -1
- package/dist/assets/{Recordings-BtjWTugI.js → Recordings-BgcFcGBb.js} +1 -1
- package/dist/assets/{ScanNetworkModal-CwPUWLnW.js → ScanNetworkModal-VBimddP_.js} +1 -1
- package/dist/assets/{Settings-CmklSlYL.js → Settings-Ds1TzmIm.js} +1 -1
- package/dist/assets/{Showroom-fSzPo12F.js → Showroom-BWjkTtos.js} +1 -1
- package/dist/assets/{Terminal-DLULQ5yw.js → Terminal-CiFCjStA.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C8V797Ba.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BVyOxZsK.js} +1 -1
- package/dist/assets/{build-cluster-graph-DIGI0NJ3.js → build-cluster-graph-66EvPJQe.js} +1 -1
- package/dist/assets/circle-check-big-B8cSnx1-.js +1 -0
- package/dist/assets/clock-C0NK5ysx.js +1 -0
- package/dist/assets/{copy-D4StuZzs.js → copy-BSYcBBsL.js} +1 -1
- package/dist/assets/{debounced-invalidate-CXo5TVm0.js → debounced-invalidate-BEmlrczS.js} +1 -1
- package/dist/assets/{dist-B1ZcDDOx.js → dist-CRhdFszz.js} +1 -1
- package/dist/assets/dist-C_8TUMdk.js +7 -0
- package/dist/assets/{download-Dq6V-5xf.js → download-DyeMq3Lq.js} +1 -1
- package/dist/assets/{face-bbox-CnD55hf6.js → face-bbox-Dx9MzEeC.js} +1 -1
- package/dist/assets/{hostInit-DyHdo8Gk.js → hostInit-DywvHrr8.js} +1 -1
- package/dist/assets/{index-BsmimqzB.js → index-0lydznr9.js} +3 -3
- package/dist/assets/{key-round-BC8uv06u.js → key-round-Cd9PCaA-.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-278ef480.js → mf-entry-bootstrap-0-a8d721bd.js} +2 -2
- package/dist/assets/{pencil-BuY8CueB.js → pencil-D6dSTO0H.js} +1 -1
- package/dist/assets/{player-overlays-CNHQKrHd.js → player-overlays-JTC60qWR.js} +1 -1
- package/dist/assets/plus-Cr4EV11F.js +1 -0
- package/dist/assets/{radio-CQ2Qddgd.js → radio-CHvRdx84.js} +1 -1
- package/dist/assets/{refresh-cw-BwbLLVV6.js → refresh-cw-Dlut6_E1.js} +1 -1
- package/dist/assets/remoteEntry-BcGEvXy4.js +1 -0
- package/dist/assets/{rotate-ccw-D9ag3NNh.js → rotate-ccw-Cefzi_mN.js} +1 -1
- package/dist/assets/rotate-cw-C56kS1wc.js +1 -0
- package/dist/assets/search-BAWX-QY8.js +1 -0
- package/dist/assets/{send-CrQGjBpn.js → send-NA1T1QRW.js} +1 -1
- package/dist/assets/{server-C-ApRIN8.js → server-BL0e6Knz.js} +1 -1
- package/dist/assets/square-Bmp4_YRa.js +1 -0
- package/dist/assets/{square-check-big-D0Ns-qwF.js → square-check-big-BohYY9OW.js} +1 -1
- package/dist/assets/{src-BDNLbHXL.js → src-8VwlAVGW.js} +4 -4
- package/dist/assets/src-CzRzcy_1.js +7 -0
- package/dist/assets/{upload-OKC5mQ8W.js → upload-KpRtHJwO.js} +1 -1
- package/dist/assets/{useEventInvalidation-BHTo3YFv.js → useEventInvalidation-B--QrmGH.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CkMK9IKI.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Du9pM5hd.js} +2 -2
- package/dist/assets/{wifi-xQgrxKer.js → wifi-BBklsNZz.js} +1 -1
- package/dist/assets/{zap-B6f_Rmgy.js → zap-BYm4JZyK.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/server/addon.js +1 -1
- package/package.json +2 -2
- package/dist/assets/Pipeline-Dmgt7OdK.js +0 -1
- package/dist/assets/circle-check-big-DifLR11P.js +0 -1
- package/dist/assets/clock-BXw5TTp6.js +0 -1
- package/dist/assets/dist-BqHHqLgd.js +0 -7
- package/dist/assets/plus-DyBHOfPx.js +0 -1
- package/dist/assets/remoteEntry-BQiHtOSG.js +0 -1
- package/dist/assets/rotate-cw-J5QBXynE.js +0 -1
- package/dist/assets/search-BLl1nrAm.js +0 -1
- package/dist/assets/square-D5oi0WlG.js +0 -1
- package/dist/assets/src-SFNx0Juf.js +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Br as e,Ga as t,Gr as n,Hr as r,Mr as i,Ni as a,Nr as o,Qa as s,Ur as c,Vr as l,Wr as u,Xa as d,_o as f,ca as p,da as m,g as h,gi as g,go as _,ho as v,la as y,m as b,ua as x,vo as S,zr as C}from"./src-BDNLbHXL.js";import{I as w,K as T,Q as E,S as D,W as O,o as k,q as A,x as j,z as M}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{p as N}from"./player-overlays-CNHQKrHd.js";import{t as P}from"./pencil-BuY8CueB.js";import{t as ee}from"./radio-CQ2Qddgd.js";import{t as F}from"./refresh-cw-BwbLLVV6.js";import{t as I}from"./rotate-cw-J5QBXynE.js";import{t as te}from"./server-C-ApRIN8.js";import{t as L}from"./upload-OKC5mQ8W.js";import{B as R,I as z,L as ne,P as re,S as B,W as V,i as ie,j as ae,m as H,o as U,s as W,t as G}from"./index-BsmimqzB.js";import{n as K,t as q}from"./build-cluster-graph-DIGI0NJ3.js";import{t as J}from"./format-size-CO9d3C3-.js";import{t as oe}from"./NodeAddonsSettingsPanel-CL75zTHK.js";var Y=V(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),se=V(`git-fork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),ce=V(`hard-drive-download`,[[`path`,{d:`M12 2v8`,key:`1q4o3n`}],[`path`,{d:`m16 6-4 4-4-4`,key:`6wukr`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,key:`w68u3i`}],[`path`,{d:`M6 18h.01`,key:`uhywen`}],[`path`,{d:`M10 18h.01`,key:`h775k`}]]),le=V(`memory-stick`,[[`path`,{d:`M6 19v-3`,key:`1nvgqn`}],[`path`,{d:`M10 19v-3`,key:`iu8nkm`}],[`path`,{d:`M14 19v-3`,key:`kcehxu`}],[`path`,{d:`M18 19v-3`,key:`1vh91z`}],[`path`,{d:`M8 11V9`,key:`63erz4`}],[`path`,{d:`M16 11V9`,key:`fru6f3`}],[`path`,{d:`M12 11V9`,key:`ha00sb`}],[`path`,{d:`M2 15h20`,key:`16ne18`}],[`path`,{d:`M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z`,key:`lhddv3`}]]),X=V(`skull`,[[`path`,{d:`m12.5 17-.5-1-.5 1h1z`,key:`3me087`}],[`path`,{d:`M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z`,key:`1o5pge`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}]]),ue=V(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]);E();function de(e){let t=new FormData;return t.append(`file`,e.file,e.file.name),t.append(`nodeId`,e.nodeId),e.addonId&&t.append(`addonId`,e.addonId),new Promise((n,r)=>{let i=new XMLHttpRequest;i.open(`POST`,`/api/addons/upload`),e.token&&i.setRequestHeader(`Authorization`,`Bearer ${e.token}`),i.upload.addEventListener(`progress`,t=>{t.lengthComputable&&e.onProgress(Math.round(t.loaded/t.total*100))}),i.addEventListener(`load`,()=>{let e;try{e=JSON.parse(i.responseText)}catch{r(Error(`HTTP ${i.status}`));return}i.status>=200&&i.status<300?n(e):r(Error(e.error??`HTTP ${i.status}`))}),i.addEventListener(`error`,()=>r(Error(`Network error during upload`))),i.addEventListener(`abort`,()=>r(Error(`Upload aborted`))),i.send(t)})}function fe({nodeId:e,addons:r,isHub:i}){let a=k(),o=t(),[s,c]=A(null),[u,d]=A(null),[f,p]=A(!1),[m,h]=A(null),[g,_]=A(0),v=T(null),y=l(),b=n(),x=C({nodeId:e}),S=x.data??[],w=new Map(r.map(e=>[e.id,e.capabilities])),E=S.length>0?S.map(e=>({id:e.id,status:e.status,capabilities:w.get(e.id)??[],version:e.version,packageName:e.packageName})):r.map(e=>({id:e.id,status:e.status,capabilities:e.capabilities,version:void 0,packageName:void 0})),O=()=>{a.invalidateQueries({queryKey:[[`nodes`,`topology`]]}),x.refetch()},M=async t=>{c(t);try{await y.mutateAsync({nodeId:e,addonId:t}),O()}catch(e){console.error(`Failed to restart addon:`,e)}finally{c(null)}},N=async t=>{if(await o({title:`Uninstall addon`,message:`Remove "${t}" from ${e}? The addon directory will be deleted on disk.`,confirmLabel:`Uninstall`,variant:`danger`})){d(t);try{await b.mutateAsync({nodeId:e,addonId:t}),O()}catch(e){console.error(`Failed to uninstall addon:`,e)}finally{d(null)}}},P=D(`div`,{className:`flex items-center gap-2 mb-2`,children:[j(`input`,{ref:v,type:`file`,accept:`.tgz,.tar.gz`,className:`hidden`,onChange:async t=>{let n=t.target.files?.[0];if(n){t.target.value=``,h(null),p(!0),_(0);try{await de({file:n,nodeId:e,token:localStorage.getItem(`camstack_admin_token`),onProgress:_}),O()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1),_(0)}}}}),D(`button`,{onClick:()=>v.current?.click(),disabled:f,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[f?j(B,{className:`h-3 w-3 animate-spin`}):j(L,{className:`h-3 w-3`}),f?`Uploading… ${g}%`:`Upload addon (.tgz)`]}),f&&j(`div`,{className:`flex-1 h-1 rounded-full bg-muted overflow-hidden max-w-[140px]`,children:j(`div`,{className:`h-full bg-primary transition-all`,style:{width:`${g}%`}})}),m&&j(`span`,{className:`text-[10px] text-destructive`,children:m})]});return E.length===0?D(`div`,{children:[P,j(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:x.isLoading?`Loading addons…`:`No addons on this node`})]}):D(`div`,{children:[P,j(`div`,{className:`rounded-lg border border-border max-h-[60vh] overflow-auto`,children:D(`table`,{className:`w-full text-xs`,children:[j(`thead`,{className:`sticky top-0 z-10 bg-surface`,children:D(`tr`,{className:`text-muted-foreground text-left`,children:[j(`th`,{className:`px-3 py-2 font-medium`,children:`Addon`}),j(`th`,{className:`px-3 py-2 font-medium`,children:`Version`}),j(`th`,{className:`px-3 py-2 font-medium`,children:`Capabilities`}),j(`th`,{className:`px-3 py-2 font-medium`,children:`Status`}),j(`th`,{className:`px-3 py-2 font-medium w-16`})]})}),j(`tbody`,{children:E.map(e=>D(`tr`,{className:`border-t border-border/50`,children:[D(`td`,{className:`px-3 py-2 font-medium`,children:[j(`div`,{children:e.id}),e.packageName&&j(`div`,{className:`text-[9px] text-muted-foreground`,children:e.packageName})]}),j(`td`,{className:`px-3 py-2 text-muted-foreground`,children:e.version??`—`}),j(`td`,{className:`px-3 py-2`,children:j(`div`,{className:`flex flex-wrap gap-1`,children:e.capabilities.length>0?e.capabilities.map(e=>j(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400`,children:e},e)):j(`span`,{className:`text-muted-foreground`,children:`—`})})}),j(`td`,{className:`px-3 py-2`,children:j(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full ${e.status===`running`?`bg-success/10 text-success`:e.status===`error`?`bg-destructive/10 text-destructive`:`bg-muted text-muted-foreground`}`,children:e.status})}),j(`td`,{className:`px-3 py-2`,children:D(`div`,{className:`flex items-center gap-1 justify-end`,children:[j(`button`,{onClick:()=>M(e.id),disabled:s===e.id||u===e.id,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart ${e.id}`,children:j(I,{className:`h-3 w-3 ${s===e.id?`animate-spin`:``}`})}),j(`button`,{onClick:()=>N(e.id),disabled:s===e.id||u===e.id,className:`p-1 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50`,title:`Uninstall ${e.id}`,children:u===e.id?j(B,{className:`h-3 w-3 animate-spin`}):j(W,{className:`h-3 w-3`})})]})})]},e.id))})]})})]})}E();function pe(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 me({state:e}){return j(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full ${e===`running`?`bg-success/10 text-success`:e===`crashed`||e===`failed`?`bg-destructive/10 text-destructive`:`bg-muted text-muted-foreground`}`,children:e})}var he=[`trace`,`debug`,`info`,`warn`,`error`];function ge({proc:e,nodeId:t,defaultExpanded:n,activePanel:i,onTogglePanel:a}){let o=e.services??[],s=o.length===1,[u,d]=A(s||n),[p,m]=A(null),[g,y]=A(`info`),x=e.name.includes(`(core)`),C=l(),w=r(),T=c(),E=async e=>{m(e);try{await C.mutateAsync({nodeId:t,addonId:e})}catch(e){console.error(`Failed to restart addon:`,e)}finally{m(null)}},O=async()=>{m(e.name);try{await w.mutateAsync({nodeId:t,processName:e.name})}catch(e){console.error(`Failed to restart process:`,e)}finally{m(null)}},k=async n=>{let r=`${t}/${e.name}`;try{await T.mutateAsync({nodeId:r,level:n}),y(n)}catch(e){console.error(`Failed to set log level:`,e)}};return D(`div`,{className:`border border-border/50 rounded-lg overflow-hidden`,children:[D(`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 items-center gap-2 w-full px-3 py-2 bg-muted/20 transition-colors text-left select-none ${s?``:`hover:bg-muted/40 cursor-pointer`}`,children:[s?j(`span`,{className:`h-3 w-3 shrink-0`}):j(u?z:re,{className:`h-3 w-3 text-muted-foreground shrink-0`}),x?j(te,{className:`h-3.5 w-3.5 text-primary shrink-0`}):j(R,{className:`h-3.5 w-3.5 text-amber-500 shrink-0`}),j(`span`,{className:`text-xs font-semibold flex-1`,children:e.name}),D(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`PID `,e.pid]}),j(me,{state:e.state}),D(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[e.cpuPercent,`% CPU`]}),j(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:J(e.memoryRss)}),j(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:pe(e.uptimeSeconds)}),!x&&D(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[D(v,{children:[j(S,{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:g}),j(_,{align:`end`,className:`min-w-[70px] py-0.5`,children:he.map(e=>j(f,{onClick:()=>k(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===g?`text-primary font-semibold`:``}`,children:e},e))})]}),j(`button`,{onClick:O,disabled:p===e.name,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart process`,children:j(I,{className:`h-3 w-3 ${p===e.name?`animate-spin`:``}`})})]})]}),u&&o.length>0&&j(`div`,{className:`divide-y divide-border/30`,children:o.map(e=>D(`div`,{children:[D(`div`,{className:`flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors`,children:[j(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`running`?`bg-success`:`bg-muted-foreground/30`}`}),j(`span`,{className:`text-xs font-medium flex-1 min-w-0 truncate`,children:e.addonId}),e.capabilities.length>0&&D(`div`,{className:`flex gap-1 flex-shrink-0`,children:[e.capabilities.slice(0,3).map(e=>j(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400 truncate max-w-[80px]`,children:e},e)),e.capabilities.length>3&&D(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.capabilities.length-3]})]}),D(`div`,{className:`flex items-center gap-1 shrink-0`,children:[j(`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:j(H,{className:`h-3 w-3`})}),j(`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:j(ee,{className:`h-3 w-3`})}),j(`button`,{onClick:()=>E(e.addonId),disabled:p===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:j(I,{className:`h-3 w-3 ${p===e.addonId?`animate-spin`:``}`})})]})]}),i?.addonId===e.addonId&&i.type===`logs`&&j(`div`,{className:`border-t border-border/40 bg-muted/5`,children:j(h,{addonId:e.addonId,agentId:t,maxHeight:`max-h-48`,showFilters:!1,onClose:()=>a(e.addonId,`logs`)})}),i?.addonId===e.addonId&&i.type===`events`&&j(`div`,{className:`border-t border-border/40 bg-muted/5`,children:j(b,{addonId:e.addonId,category:`addon.*`,maxHeight:`max-h-48`,onClose:()=>a(e.addonId,`events`)})})]},e.addonId))}),u&&o.length===0&&j(`div`,{className:`px-3 py-2 pl-9 text-[10px] text-muted-foreground`,children:`No services`})]})}function _e({nodeId:e,processes:t}){let[n,r]=A(null),i=(e,t)=>{r(n=>n?.addonId===e&&n.type===t?null:{addonId:e,type:t})};return t.length===0?j(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No processes on this node`}):j(`div`,{className:`space-y-2 py-1`,children:t.map((t,r)=>j(ge,{proc:t,nodeId:e,defaultExpanded:r===0,activePanel:n,onTogglePanel:i},t.name))})}E();function ve(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 ye(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function be({nodeId:e}){let n=k(),r=t(),[a,s]=A(`all`),c=d(`metrics.node-processes-snapshot`,t=>t.nodeId===e),{data:l}=o({nodeId:e}),u=c?.processes??l,f=O(()=>u?[...u]:[],[u]),p=O(()=>a===`ghost`?f.filter(e=>e.classification===`ghost`):f,[f,a]),m=O(()=>{let e=f.filter(e=>e.classification===`ghost`),t=new Map;for(let n of e)t.has(n.ppid)||t.set(n.ppid,[]),t.get(n.ppid).push(n);return[...t.entries()].filter(([,e])=>e.length>1).map(([e,t])=>({ppid:e,children:t})).toSorted((e,t)=>t.children.length-e.children.length)},[f]),h=i({onSettled:()=>{n.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]})}}),g=O(()=>{let e=new Map;for(let t of f)e.set(t.pid,t.classification);return e},[f]),_=async(t,n)=>{if(t.classification===`root`||t.classification===`system`)return;let i=t.classification===`ghost`?`ghost`:t.addonId??`process`,a=n?`SIGKILL`:`SIGTERM`;await r({title:`Send ${a}?`,message:`Target pid ${t.pid} (${i}) on node ${e}.`,confirmLabel:`Send ${a}`,variant:`danger`})&&h.mutate({nodeId:e,pid:t.pid,force:n})},v=async(t,n)=>{try{await h.mutateAsync({nodeId:e,pid:t,force:n})}catch{}},y=async t=>{let i=g.get(t.ppid);if(i===`root`||i===`system`){await r({title:`Cannot kill protected ancestor`,message:i===`root`?`pid ${t.ppid} is the current node supervisor. Restart the node via the cluster page instead.`:`pid ${t.ppid} is a system ancestor (concurrently / vite / npm wrapper). Killing it would tear down the dev tree.`,confirmLabel:`OK`,cancelLabel:`Close`,variant:`warning`});return}await r({title:`Kill ghost parent + ${t.children.length} child(ren)?`,message:`SIGKILL parent pid ${t.ppid} and SIGTERM ${t.children.length} ghost child(ren) on node ${e}.`,confirmLabel:`Kill all`,variant:`danger`})&&(await Promise.all([v(t.ppid,!0),...t.children.map(e=>v(e.pid,!1))]),n.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}))},b=async()=>{let t=f.filter(e=>e.classification===`ghost`);t.length!==0&&await r({title:`Kill all ${t.length} ghost process(es)?`,message:`SIGKILL ${t.length} ghost process(es) on node ${e}. This is irreversible.`,confirmLabel:`Kill all`,variant:`danger`})&&(await Promise.all(t.map(e=>v(e.pid,!0))),n.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}))},x=f.filter(e=>e.classification===`ghost`).length,S=f.filter(e=>e.classification===`managed`).length,C=f.filter(e=>e.classification===`root`).length,w=f.filter(e=>e.classification===`system`).length;return D(`div`,{className:`space-y-4`,children:[D(`div`,{className:`flex items-start justify-between gap-4`,children:[D(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`ps`," scan + kernel `$process.list` cross-reference. Ghosts = camstack-shaped commands with no managed binding (usually orphaned to ppid=1). Refreshes every 10s."]}),D(`button`,{type:`button`,onClick:()=>n.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:[j(F,{className:`h-3 w-3`}),` Refresh`]})]}),D(`div`,{className:`grid grid-cols-4 gap-3`,children:[D(`div`,{className:`rounded-lg border border-border p-3`,children:[j(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`Root`}),j(`div`,{className:`text-xl font-semibold text-foreground`,children:C})]}),D(`div`,{className:`rounded-lg border border-border p-3`,children:[j(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`Managed`}),j(`div`,{className:`text-xl font-semibold text-foreground`,children:S})]}),D(`div`,{className:`rounded-lg border border-border p-3`,children:[j(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`System`}),j(`div`,{className:`text-xl font-semibold text-foreground`,children:w})]}),D(`div`,{className:`rounded-lg border p-3 ${x>0?`border-destructive/40 bg-destructive/5`:`border-border`}`,children:[D(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle flex items-center gap-1`,children:[x>0&&j(X,{className:`h-3 w-3 text-destructive`}),` Ghosts`]}),j(`div`,{className:`text-xl font-semibold ${x>0?`text-destructive`:`text-foreground`}`,children:x})]})]}),m.length>0&&D(`div`,{className:`rounded-lg border border-amber-500/40 bg-amber-500/5 p-3`,children:[D(`div`,{className:`flex items-center gap-1 text-[11px] font-semibold text-amber-400 mb-2`,children:[j(U,{className:`h-3 w-3`}),` Recurring ghost parents (`,m.length,`)`]}),j(`div`,{className:`space-y-1.5`,children:m.map(e=>D(`div`,{className:`text-[11px] text-foreground flex items-center justify-between gap-2`,children:[D(`div`,{className:`flex items-center gap-2`,children:[D(`span`,{className:`font-mono text-foreground-subtle`,children:[`ppid `,e.ppid]}),D(`span`,{children:[`→ `,e.children.length,` ghost(s)`]})]}),D(`button`,{type:`button`,disabled:h.isPending,onClick:()=>{y(e)},className:`inline-flex items-center gap-1 rounded border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] text-amber-400 hover:bg-amber-500/20 disabled:opacity-30`,children:[j(X,{className:`h-3 w-3`}),` Kill parent + `,e.children.length]})]},e.ppid))})]}),D(`div`,{className:`flex items-center justify-between gap-2 text-[11px]`,children:[D(`div`,{className:`flex items-center gap-2`,children:[j(`span`,{className:`text-foreground-subtle`,children:`Filter:`}),D(`button`,{type:`button`,className:`px-2 py-0.5 rounded ${a===`all`?`bg-primary text-primary-foreground`:`border border-border text-foreground hover:bg-surface-hover`}`,onClick:()=>s(`all`),children:[`All (`,f.length,`)`]}),D(`button`,{type:`button`,className:`px-2 py-0.5 rounded ${a===`ghost`?`bg-destructive text-destructive-foreground`:`border border-border text-foreground hover:bg-surface-hover`}`,onClick:()=>s(`ghost`),children:[`Ghost only (`,x,`)`]})]}),x>0&&D(`button`,{type:`button`,disabled:h.isPending,onClick:()=>{b()},className:`inline-flex items-center gap-1 rounded border border-destructive/40 bg-destructive/10 px-2 py-1 text-[11px] font-medium text-destructive hover:bg-destructive/20 disabled:opacity-30`,children:[j(X,{className:`h-3 w-3`}),` Kill all `,x,` ghost(s)`]})]}),j(`div`,{className:`rounded-lg border border-border max-h-[60vh] overflow-auto`,children:D(`table`,{className:`w-full text-xs`,children:[j(`thead`,{className:`sticky top-0 z-10 bg-surface`,children:D(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[j(`th`,{className:`text-left px-3 py-2`,children:`Class`}),j(`th`,{className:`text-right px-3 py-2`,children:`PID`}),j(`th`,{className:`text-right px-3 py-2`,children:`PPID`}),j(`th`,{className:`text-left px-3 py-2`,children:`Addon`}),j(`th`,{className:`text-left px-3 py-2`,children:`Command`}),j(`th`,{className:`text-right px-3 py-2`,children:`CPU%`}),j(`th`,{className:`text-right px-3 py-2`,children:`RSS`}),j(`th`,{className:`text-right px-3 py-2`,children:`Uptime`}),j(`th`,{className:`w-44`})]})}),D(`tbody`,{children:[p.length===0&&j(`tr`,{children:j(`td`,{colSpan:9,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:a===`ghost`?`No ghost processes detected.`:`Scanning…`})}),p.map(e=>D(`tr`,{className:`border-t border-border ${e.classification===`ghost`?`bg-destructive/5`:``}`,children:[j(`td`,{className:`px-3 py-2`,children:j(`span`,{className:`inline-block rounded-full px-1.5 py-0.5 text-[10px] font-medium ${e.classification===`ghost`?`bg-destructive/20 text-destructive`:e.classification===`root`?`bg-sky-500/20 text-sky-400`:e.classification===`system`?`bg-foreground-subtle/20 text-foreground-subtle`:`bg-success/20 text-success`}`,children:e.classification})}),j(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.pid}),D(`td`,{className:`px-3 py-2 text-right font-mono text-foreground-subtle`,children:[e.ppid,e.orphaned?` ⚠`:``]}),j(`td`,{className:`px-3 py-2 text-foreground-subtle text-[11px]`,children:e.addonId??`—`}),j(`td`,{className:`px-3 py-2 font-mono text-[10px] text-foreground-subtle break-all`,children:ye(e.command)}),j(`td`,{className:`px-3 py-2 text-right text-foreground`,children:e.cpuPercent.toFixed(1)}),j(`td`,{className:`px-3 py-2 text-right text-foreground`,children:J(e.memoryRssBytes)}),j(`td`,{className:`px-3 py-2 text-right text-foreground-subtle`,children:ve(e.uptimeSec)}),j(`td`,{className:`px-3 py-2 text-right`,children:D(`div`,{className:`inline-flex gap-1`,children:[D(`button`,{type:`button`,disabled:h.isPending||e.classification===`root`||e.classification===`system`,onClick:()=>{_(e,!1)},title:`SIGTERM`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-border text-[10px] text-foreground hover:bg-surface-hover disabled:opacity-30`,children:[j(W,{className:`h-3 w-3`}),` Term`]}),D(`button`,{type:`button`,disabled:h.isPending||e.classification===`root`||e.classification===`system`,onClick:()=>{_(e,!0)},title:`SIGKILL`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-destructive/30 text-[10px] text-destructive hover:bg-destructive/10 disabled:opacity-30`,children:[j(X,{className:`h-3 w-3`}),` Kill`]})]})})]},e.pid))]})]})}),h.isError&&D(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[`Kill failed:`,` `,h.error instanceof Error?h.error.message:`unknown`]})]})}function xe({nodeId:e,addonIds:t}){return t.length===0?j(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No addons on this node`}):j(`div`,{className:`w-full py-2`,children:j(oe,{nodeId:e,addonIds:t,level:`global`,selfTabbed:!0})})}E();function Se({nodeId:e,addons:t}){let n=k(),{data:r,isLoading:i}=g({nodeId:e}),o=O(()=>{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]),s=a({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCapabilityBindings`]]})}});return o.length===0?j(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No capabilities on this node`}):j(`div`,{className:`rounded-lg border border-border max-h-[60vh] overflow-auto`,children:D(`table`,{className:`w-full text-xs`,children:[j(`thead`,{className:`sticky top-0 z-10 bg-surface`,children:D(`tr`,{className:`text-muted-foreground text-left`,children:[j(`th`,{className:`px-3 py-2 font-medium w-1/2`,children:`Capability`}),j(`th`,{className:`px-3 py-2 font-medium`,children:`Bound provider`})]})}),j(`tbody`,{children:o.map(({capName:t,providers:n})=>{let a=r?.[t]??n[0]??``,o=n.length===1;return D(`tr`,{className:`border-t border-border/50`,children:[j(`td`,{className:`px-3 py-2 font-medium`,children:t}),j(`td`,{className:`px-3 py-2`,children:j(`select`,{value:a,onChange:n=>s.mutate({nodeId:e,capName:t,addonId:n.target.value}),disabled:o||s.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:o?`Only one provider installed — choice becomes available once a second addon registers this capability`:void 0,children:n.map(e=>j(`option`,{value:e,children:e},e))})})]},t)})})]})})}E();function Z(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 Ce(t){let[n,r]=A(!1),[i,a]=A(t.name),o=k(),s=e({onSuccess:()=>{o.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}}),c=(t.localIps??[]).filter(e=>!e.includes(`:`)),l=(t.localIps??[]).filter(e=>e.includes(`:`)),u=async()=>{if(!i.trim()||i===t.name){r(!1);return}try{await s.mutateAsync({nodeId:t.nodeId,name:i.trim()}),r(!1)}catch(e){console.error(`Rename failed:`,e)}},d=[[`Node ID`,j(`span`,{className:`font-mono text-xs`,children:t.nodeId})],[`Display Name`,n?D(`div`,{className:`flex items-center gap-1.5`,children:[j(`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`&&u(),e.key===`Escape`&&r(!1)},disabled:s.isPending,autoFocus:!0}),j(`button`,{onClick:()=>void u(),disabled:s.isPending,className:`p-0.5 text-success hover:bg-success/10 rounded`,title:`Save`,children:j(ne,{className:`h-3.5 w-3.5`})}),j(`button`,{onClick:()=>r(!1),className:`p-0.5 text-muted-foreground hover:bg-muted rounded`,title:`Cancel`,children:j(ie,{className:`h-3.5 w-3.5`})})]}):D(`div`,{className:`flex items-center gap-1.5`,children:[j(`span`,{className:`text-xs`,children:t.name}),!t.isHub&&j(`button`,{onClick:()=>{a(t.name),r(!0)},className:`p-0.5 text-muted-foreground hover:text-primary rounded`,title:`Rename`,children:j(P,{className:`h-3 w-3`})})]})],[`Hostname`,j(`span`,{className:`text-xs`,children:t.hostname})],[`Role`,t.isHub?j(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium`,children:`Hub`}):j(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-medium`,children:`Agent`})],[`Root Package`,t.rootPackage?D(`span`,{className:`font-mono text-xs`,children:[t.rootPackage.name,`@`,t.rootPackage.version]}):j(`span`,{className:`text-xs text-muted-foreground`,children:`—`})],[`Platform`,D(`span`,{className:`text-xs`,children:[t.platform,` / `,t.arch]})],[`CPU`,D(`span`,{className:`text-xs`,children:[t.cpuModel??`—`,` (`,t.cpuCores,` cores)`]})],[`Memory`,j(`span`,{className:`text-xs`,children:t.memoryMB>0?`${(t.memoryMB/1024).toFixed(1)} GB`:`—`})],[`Uptime`,j(`span`,{className:`text-xs`,children:Z(t.uptime)})],[`Engines`,t.engines.length>0?j(`div`,{className:`flex flex-wrap gap-1`,children:t.engines.map(e=>j(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium`,children:e},e))}):j(`span`,{className:`text-xs text-muted-foreground`,children:`—`})]];return c.length>0&&d.push([`IPv4`,j(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map((e,t)=>j(`span`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:e},`${e}-${t}`))})]),l.length>0&&d.push([`IPv6`,j(`div`,{className:`flex flex-wrap gap-1.5`,children:l.map((e,t)=>j(`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}`))})]),j(`div`,{className:`py-2`,children:j(`table`,{className:`w-full text-sm`,children:j(`tbody`,{children:d.map(([e,t],n)=>D(`tr`,{className:n%2==0?`bg-muted/20`:``,children:[j(`td`,{className:`py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap`,children:e}),j(`td`,{className:`py-1.5 px-2`,children:t})]},e))})})})}E();var we=[[`serverManagement`,`getServerPackageStatus`]];function Q({label:e,tone:t}){return j(`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-emerald-500/15 text-emerald-500`,info:`bg-sky-500/15 text-sky-500`,warn:`bg-amber-500/15 text-amber-500`,error:`bg-red-500/15 text-red-500`}[t]}`,children:e})}function $({label:e,value:t}){return D(`div`,{className:`flex items-center justify-between gap-4 text-sm`,children:[j(`span`,{className:`text-foreground-subtle`,children:e}),j(`span`,{className:`font-mono text-foreground`,children:t??`—`})]})}function Te({node:e}){let{t:n}=G(),r=k(),i=t(),[a,o]=A(!1),s=e.isHub?void 0:{nodeId:e.id},c=x(s,{refetchInterval:1e4,enabled:e.isOnline,retry:1}),l=c.data??null,u=w(()=>{r.invalidateQueries({queryKey:we})},[r]),d=y({onSettled:u}),f=p({onSettled:u}),h=m({onSettled:u}),g=w(async()=>{l?.latestVersion!=null&&await i({title:n(`serverManagement.confirmUpdateTitle`,`Update node root package`),message:n(`serverManagement.confirmUpdateBody`,`Install {{pkg}}@{{version}} on "{{node}}" and restart to apply.`,{pkg:l.packageName,version:l.latestVersion,node:e.name}),confirmLabel:n(`serverManagement.confirmUpdateAction`,`Update & restart`)})&&(await f.mutateAsync({version:l.latestVersion,...s})).restarting&&o(!0)},[f,i,e.name,s,l,n]),_=w(async()=>{await i({title:n(`serverManagement.confirmRestartTitle`,`Restart node`),message:n(`serverManagement.confirmRestartBody`,`Restart "{{node}}"? In-flight requests to this node are dropped.`,{node:e.name}),confirmLabel:n(`serverManagement.confirmRestartAction`,`Restart`),variant:`warning`})&&(await h.mutateAsync(s)).restarting&&o(!0)},[i,e.name,h,s,n]),v=()=>{switch(l?.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`}}},b=()=>{if(l==null)return null;switch(l.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 l.updateAvailable?{label:n(`serverManagement.stateUpdateAvailable`,`update available`),tone:`warn`}:{label:n(`serverManagement.stateUpToDate`,`up to date`),tone:`ok`}}},S=l?.bootMode===`workspace`,C=e.isOnline&&l!=null&&!S&&l.updateAvailable&&l.updateState===`idle`&&!f.isPending,T=e.isOnline&&l!=null&&l.updateState===`idle`&&!h.isPending,E=e.isOnline?b():null;return D(`div`,{className:`space-y-4 py-2`,children:[D(`div`,{className:`flex items-center justify-between gap-3`,children:[D(`div`,{className:`flex items-center gap-2 min-w-0`,children:[j(`span`,{className:`font-mono text-xs text-foreground-subtle truncate`,children:l?.packageName??e.rootPackage?.name??`@camstack/server`}),e.isOnline&&l!=null&&j(Q,{...v()})]}),E!=null&&j(Q,{...E})]}),!e.isOnline&&j($,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:e.rootPackage?.version??null}),e.isOnline&&c.isLoading&&D(`div`,{className:`flex items-center gap-2 text-sm text-foreground-subtle`,children:[j(B,{className:`h-4 w-4 animate-spin`}),n(`common.loading`,`Loading…`)]}),e.isOnline&&c.isError&&D(`div`,{className:`space-y-1.5`,children:[j(`p`,{className:`text-sm text-red-500`,children:n(`serverManagement.loadError`,`Could not load the node root-package status.`)}),e.rootPackage!=null&&j($,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:e.rootPackage.version})]}),e.isOnline&&l!=null&&D(`div`,{className:`space-y-1.5`,children:[j($,{label:n(`serverManagement.runningVersion`,`Running version`),value:l.runningVersion}),j($,{label:n(`serverManagement.latestVersion`,`Latest on registry`),value:l.latestVersion}),j($,{label:n(`serverManagement.nodeRuntimeVersion`,`Node.js runtime`),value:l.nodeRuntimeVersion}),l.pendingVersion!=null&&j($,{label:n(`serverManagement.pendingVersion`,`Staged (applies on restart)`),value:l.pendingVersion})]}),e.isOnline&&S&&j(`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).`)}),a&&D(`div`,{className:`flex items-center gap-2 text-sm text-amber-500`,children:[j(B,{className:`h-4 w-4 animate-spin`}),n(`serverManagement.nodeRestarting`,`The node is restarting to apply the change…`)]}),e.isOnline&&D(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[D(`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:d.isPending||l?.updateState===`staging`,onClick:()=>d.mutate(s),children:[d.isPending?j(B,{className:`h-3.5 w-3.5 animate-spin`}):j(F,{className:`h-3.5 w-3.5`}),n(`serverManagement.checkForUpdate`,`Check for update`)]}),C&&D(`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 g(),children:[f.isPending?j(B,{className:`h-3.5 w-3.5 animate-spin`}):j(Y,{className:`h-3.5 w-3.5`}),n(`serverManagement.updateTo`,`Update to {{version}}`,{version:l?.latestVersion??``})]}),D(`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:!T,onClick:()=>void _(),children:[h.isPending?j(B,{className:`h-3.5 w-3.5 animate-spin`}):j(I,{className:`h-3.5 w-3.5`}),n(`serverManagement.restart`,`Restart`)]})]}),e.isOnline&&l?.lastCheckedAtMs!=null&&D(`p`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[j(ce,{className:`h-3 w-3`}),n(`serverManagement.lastChecked`,`Last checked: {{when}}`,{when:new Date(l.lastCheckedAtMs).toLocaleString()})]})]})}E();function Ee({node:e}){let t=N(),[n,r]=A(`info`),[i,a]=A(!1),o=e.processes??[],s=e.addons.map(e=>e.id),c=async()=>{if(!i){a(!0);try{await Promise.allSettled([t.trpcClient.pipelineOrchestrator.removeAgentSettings.mutate({agentNodeId:e.id}),t.trpcClient.clusterNodes.forgetNode.mutate({nodeId:e.id})])}finally{a(!1)}}};return e.isOnline?D(`div`,{className:`border border-border rounded-xl`,children:[D(`div`,{className:`flex items-center gap-3 px-4 py-3 bg-muted/30 border-b border-border rounded-t-xl`,children:[j(`div`,{className:`w-2.5 h-2.5 rounded-full bg-success`}),j(`span`,{className:`text-sm font-semibold`,children:e.name}),D(`span`,{className:`text-xs text-muted-foreground`,children:[e.cpuModel??e.platform,` ·`,` `,e.memoryMB>0?`${Math.round(e.memoryMB/1024)}GB`:``,` · `,e.arch]}),e.engines.map(e=>j(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium`,children:e},e)),D(`div`,{className:`ml-auto flex gap-3 text-xs text-muted-foreground`,children:[D(`span`,{className:`flex items-center gap-1`,children:[j(ae,{className:`h-3 w-3`}),` `,e.cpuPercent,`%`]}),D(`span`,{className:`flex items-center gap-1`,children:[j(le,{className:`h-3 w-3`}),` `,e.memoryPercent,`%`]})]})]}),j(`div`,{className:`sticky top-0 z-20 flex border-b border-border px-4 bg-background overflow-x-auto`,children:[`info`,`addons`,`forks`,`processes`,`settings`,`capabilities`].map(t=>j(`button`,{onClick:()=>r(t),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${n===t?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:t===`info`?`General`:t===`addons`?`Addons (${e.addons.length})`:t===`forks`?`Forks (${o.length})`:t===`processes`?`Processes`:t===`settings`?`Settings`:`Capabilities`},t))}),D(`div`,{className:`px-4 py-2`,children:[n===`info`&&D(`div`,{className:`space-y-3`,children:[j(Ce,{nodeId:e.id,name:e.name,hostname:e.hostname,platform:e.platform,arch:e.arch,cpuModel:e.cpuModel,cpuCores:e.cpuCores,memoryMB:e.memoryMB,engines:e.engines,isHub:e.isHub,uptime:e.uptime,localIps:e.localIps,rootPackage:e.rootPackage}),j(`div`,{className:`border-t border-border pt-1`,children:j(Te,{node:{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,rootPackage:e.rootPackage??null}})})]}),n===`addons`&&j(fe,{nodeId:e.id,addons:e.addons,isHub:e.isHub}),n===`forks`&&j(_e,{nodeId:e.id,processes:o}),n===`processes`&&j(be,{nodeId:e.id}),n===`settings`&&j(xe,{nodeId:e.id,addonIds:s}),n===`capabilities`&&j(Se,{nodeId:e.id,addons:e.addons})]})]}):D(`div`,{className:`border border-border rounded-xl overflow-hidden opacity-60`,children:[D(`div`,{className:`flex items-center gap-3 px-4 py-3 bg-muted/30`,children:[j(`div`,{className:`w-2.5 h-2.5 rounded-full bg-destructive`}),j(`span`,{className:`text-sm font-semibold`,children:e.name}),D(`span`,{className:`text-xs text-muted-foreground`,children:[e.cpuModel??e.platform,` ·`,` `,e.memoryMB>0?`${Math.round(e.memoryMB/1024)}GB`:``,` · `,e.arch]}),e.engines.map(e=>j(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium`,children:e},e)),e.rootPackage&&D(`span`,{className:`text-[10px] font-mono px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:[e.rootPackage.name,`@`,e.rootPackage.version]}),j(`span`,{className:`ml-auto text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`})]}),D(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[D(`span`,{className:`text-xs text-muted-foreground`,children:[e.lastSeen?`Last seen ${new Date(e.lastSeen).toLocaleString()} — `:``,e.addons.length,` addon`,e.addons.length===1?``:`s`,` assigned; will resume when node reconnects`]}),D(`button`,{type:`button`,onClick:()=>void c(),disabled:i,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:[j(W,{className:`h-3 w-3`}),i?`Forgetting…`:`Forget node`]})]})]})}E();function De({nodes:e,focusNodeId:t,focusNonce:n}){let r=[...e].toSorted((e,t)=>e.isHub?-1:t.isHub?1:e.isOnline&&!t.isOnline?-1:!e.isOnline&&t.isOnline?1:e.name.localeCompare(t.name)),i=T(null);return M(()=>{if(!t)return;let e=i.current?.querySelector(`#node-card-${CSS.escape(t)}`);e&&e.scrollIntoView({behavior:`smooth`,block:`start`})},[t,n]),j(`div`,{ref:i,className:`flex flex-col gap-4`,children:r.map(e=>j(`div`,{id:`node-card-${e.id}`,children:j(Ee,{node:e})},e.id))})}E();function Oe(e){let[t,n]=A(()=>typeof window<`u`?window.matchMedia(e).matches:!1);return M(()=>{let t=window.matchMedia(e),r=e=>n(e.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}function ke(){let{data:e,isLoading:t}=u(void 0,{staleTime:1/0}),[n,r]=A(null);return s(`cluster.topology-snapshot`,e=>{let t=e.data?.nodes;Array.isArray(t)&&r(t)}),{nodes:O(()=>n??e??[],[n,e]),isLoading:t&&!n}}function Ae(){let{t:e}=G(),n=t(),[r,i]=A(`table`),[a,o]=A(void 0),[s,c]=A(0),l=Oe(`(max-width: 767px)`),u=l&&r===`graph`?`table`:r,{nodes:d,isLoading:f}=ke(),m=O(()=>q(d),[d]),h=O(()=>d.filter(e=>e.isOnline),[d]),g=h.length,_=d.filter(e=>!e.isOnline).length,v=p(),[y,b]=A(!1),x=w(async()=>{let t=[...h].sort((e,t)=>e.isHub===t.isHub?0:e.isHub?1:-1);if(await n({title:e(`serverManagement.confirmUpdateAllTitle`,`Update all nodes`),message:e(`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:e(`serverManagement.confirmUpdateAllAction`,`Update all & restart`),variant:`warning`})){b(!0);try{for(let e of t)try{await v.mutateAsync(e.isHub?{}:{nodeId:e.id})}catch{}}finally{b(!1)}}},[v,n,h,e]),S=w(e=>{i(`table`),o(e),c(e=>e+1)},[]),C=(e,t,n)=>D(`button`,{onClick:()=>i(e),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${r===e?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[j(n,{className:`h-3.5 w-3.5`}),t]});return D(`div`,{className:`flex flex-col h-full gap-4 p-4`,children:[D(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[D(`div`,{className:`flex items-center gap-2`,children:[g>0&&D(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-success/10 text-success`,children:[g,` online`]}),_>0&&D(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:[_,` offline`]})]}),D(`div`,{className:`flex items-center gap-2`,children:[g>1&&D(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50`,disabled:y,title:e(`serverManagement.updateAllHint`,`Sequenced agents-first, hub-last — up-to-date nodes are skipped.`),onClick:()=>void x(),children:[y?j(B,{className:`h-3.5 w-3.5 animate-spin`}):j(Y,{className:`h-3.5 w-3.5`}),e(`serverManagement.updateAll`,`Update all nodes`)]}),D(`div`,{className:`flex gap-0.5 p-1 rounded-lg bg-muted`,children:[C(`table`,`Table`,ue),!l&&C(`graph`,`Graph`,se)]})]})]}),f?j(`div`,{className:`flex items-center justify-center flex-1 text-muted-foreground`,children:`Loading cluster topology...`}):u===`graph`?j(K,{graph:m,onOpenNodeDetail:S}):j(`div`,{className:`flex-1 overflow-auto`,children:j(De,{nodes:d,focusNodeId:a,focusNonce:s})})]})}export{Ae as ClusterPage};
|
|
1
|
+
import{Br as e,Ga as t,Gr as n,Hr as r,Mr as i,Ni as a,Nr as o,Qa as s,Ur as c,Vr as l,Wr as u,Xa as d,_o as f,ca as p,da as m,g as h,gi as g,go as _,ho as v,la as y,m as b,ua as x,vo as S,zr as C}from"./src-8VwlAVGW.js";import{I as w,K as T,Q as E,S as D,W as O,o as k,q as A,x as j,z as M}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{p as N}from"./player-overlays-JTC60qWR.js";import{t as P}from"./pencil-D6dSTO0H.js";import{t as ee}from"./radio-CHvRdx84.js";import{t as F}from"./refresh-cw-Dlut6_E1.js";import{t as I}from"./rotate-cw-C56kS1wc.js";import{t as te}from"./server-BL0e6Knz.js";import{t as L}from"./upload-KpRtHJwO.js";import{B as R,I as z,L as ne,P as re,S as B,W as V,i as ie,j as ae,m as H,o as U,s as W,t as G}from"./index-0lydznr9.js";import{n as K,t as q}from"./build-cluster-graph-66EvPJQe.js";import{t as J}from"./format-size-CO9d3C3-.js";import{t as oe}from"./NodeAddonsSettingsPanel-DDb1owhe.js";var Y=V(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),se=V(`git-fork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),ce=V(`hard-drive-download`,[[`path`,{d:`M12 2v8`,key:`1q4o3n`}],[`path`,{d:`m16 6-4 4-4-4`,key:`6wukr`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,key:`w68u3i`}],[`path`,{d:`M6 18h.01`,key:`uhywen`}],[`path`,{d:`M10 18h.01`,key:`h775k`}]]),le=V(`memory-stick`,[[`path`,{d:`M6 19v-3`,key:`1nvgqn`}],[`path`,{d:`M10 19v-3`,key:`iu8nkm`}],[`path`,{d:`M14 19v-3`,key:`kcehxu`}],[`path`,{d:`M18 19v-3`,key:`1vh91z`}],[`path`,{d:`M8 11V9`,key:`63erz4`}],[`path`,{d:`M16 11V9`,key:`fru6f3`}],[`path`,{d:`M12 11V9`,key:`ha00sb`}],[`path`,{d:`M2 15h20`,key:`16ne18`}],[`path`,{d:`M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z`,key:`lhddv3`}]]),X=V(`skull`,[[`path`,{d:`m12.5 17-.5-1-.5 1h1z`,key:`3me087`}],[`path`,{d:`M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z`,key:`1o5pge`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}]]),ue=V(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]);E();function de(e){let t=new FormData;return t.append(`file`,e.file,e.file.name),t.append(`nodeId`,e.nodeId),e.addonId&&t.append(`addonId`,e.addonId),new Promise((n,r)=>{let i=new XMLHttpRequest;i.open(`POST`,`/api/addons/upload`),e.token&&i.setRequestHeader(`Authorization`,`Bearer ${e.token}`),i.upload.addEventListener(`progress`,t=>{t.lengthComputable&&e.onProgress(Math.round(t.loaded/t.total*100))}),i.addEventListener(`load`,()=>{let e;try{e=JSON.parse(i.responseText)}catch{r(Error(`HTTP ${i.status}`));return}i.status>=200&&i.status<300?n(e):r(Error(e.error??`HTTP ${i.status}`))}),i.addEventListener(`error`,()=>r(Error(`Network error during upload`))),i.addEventListener(`abort`,()=>r(Error(`Upload aborted`))),i.send(t)})}function fe({nodeId:e,addons:r,isHub:i}){let a=k(),o=t(),[s,c]=A(null),[u,d]=A(null),[f,p]=A(!1),[m,h]=A(null),[g,_]=A(0),v=T(null),y=l(),b=n(),x=C({nodeId:e}),S=x.data??[],w=new Map(r.map(e=>[e.id,e.capabilities])),E=S.length>0?S.map(e=>({id:e.id,status:e.status,capabilities:w.get(e.id)??[],version:e.version,packageName:e.packageName})):r.map(e=>({id:e.id,status:e.status,capabilities:e.capabilities,version:void 0,packageName:void 0})),O=()=>{a.invalidateQueries({queryKey:[[`nodes`,`topology`]]}),x.refetch()},M=async t=>{c(t);try{await y.mutateAsync({nodeId:e,addonId:t}),O()}catch(e){console.error(`Failed to restart addon:`,e)}finally{c(null)}},N=async t=>{if(await o({title:`Uninstall addon`,message:`Remove "${t}" from ${e}? The addon directory will be deleted on disk.`,confirmLabel:`Uninstall`,variant:`danger`})){d(t);try{await b.mutateAsync({nodeId:e,addonId:t}),O()}catch(e){console.error(`Failed to uninstall addon:`,e)}finally{d(null)}}},P=D(`div`,{className:`flex items-center gap-2 mb-2`,children:[j(`input`,{ref:v,type:`file`,accept:`.tgz,.tar.gz`,className:`hidden`,onChange:async t=>{let n=t.target.files?.[0];if(n){t.target.value=``,h(null),p(!0),_(0);try{await de({file:n,nodeId:e,token:localStorage.getItem(`camstack_admin_token`),onProgress:_}),O()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1),_(0)}}}}),D(`button`,{onClick:()=>v.current?.click(),disabled:f,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[f?j(B,{className:`h-3 w-3 animate-spin`}):j(L,{className:`h-3 w-3`}),f?`Uploading… ${g}%`:`Upload addon (.tgz)`]}),f&&j(`div`,{className:`flex-1 h-1 rounded-full bg-muted overflow-hidden max-w-[140px]`,children:j(`div`,{className:`h-full bg-primary transition-all`,style:{width:`${g}%`}})}),m&&j(`span`,{className:`text-[10px] text-destructive`,children:m})]});return E.length===0?D(`div`,{children:[P,j(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:x.isLoading?`Loading addons…`:`No addons on this node`})]}):D(`div`,{children:[P,j(`div`,{className:`rounded-lg border border-border max-h-[60vh] overflow-auto`,children:D(`table`,{className:`w-full text-xs`,children:[j(`thead`,{className:`sticky top-0 z-10 bg-surface`,children:D(`tr`,{className:`text-muted-foreground text-left`,children:[j(`th`,{className:`px-3 py-2 font-medium`,children:`Addon`}),j(`th`,{className:`px-3 py-2 font-medium`,children:`Version`}),j(`th`,{className:`px-3 py-2 font-medium`,children:`Capabilities`}),j(`th`,{className:`px-3 py-2 font-medium`,children:`Status`}),j(`th`,{className:`px-3 py-2 font-medium w-16`})]})}),j(`tbody`,{children:E.map(e=>D(`tr`,{className:`border-t border-border/50`,children:[D(`td`,{className:`px-3 py-2 font-medium`,children:[j(`div`,{children:e.id}),e.packageName&&j(`div`,{className:`text-[9px] text-muted-foreground`,children:e.packageName})]}),j(`td`,{className:`px-3 py-2 text-muted-foreground`,children:e.version??`—`}),j(`td`,{className:`px-3 py-2`,children:j(`div`,{className:`flex flex-wrap gap-1`,children:e.capabilities.length>0?e.capabilities.map(e=>j(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400`,children:e},e)):j(`span`,{className:`text-muted-foreground`,children:`—`})})}),j(`td`,{className:`px-3 py-2`,children:j(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full ${e.status===`running`?`bg-success/10 text-success`:e.status===`error`?`bg-destructive/10 text-destructive`:`bg-muted text-muted-foreground`}`,children:e.status})}),j(`td`,{className:`px-3 py-2`,children:D(`div`,{className:`flex items-center gap-1 justify-end`,children:[j(`button`,{onClick:()=>M(e.id),disabled:s===e.id||u===e.id,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart ${e.id}`,children:j(I,{className:`h-3 w-3 ${s===e.id?`animate-spin`:``}`})}),j(`button`,{onClick:()=>N(e.id),disabled:s===e.id||u===e.id,className:`p-1 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50`,title:`Uninstall ${e.id}`,children:u===e.id?j(B,{className:`h-3 w-3 animate-spin`}):j(W,{className:`h-3 w-3`})})]})})]},e.id))})]})})]})}E();function pe(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 me({state:e}){return j(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full ${e===`running`?`bg-success/10 text-success`:e===`crashed`||e===`failed`?`bg-destructive/10 text-destructive`:`bg-muted text-muted-foreground`}`,children:e})}var he=[`trace`,`debug`,`info`,`warn`,`error`];function ge({proc:e,nodeId:t,defaultExpanded:n,activePanel:i,onTogglePanel:a}){let o=e.services??[],s=o.length===1,[u,d]=A(s||n),[p,m]=A(null),[g,y]=A(`info`),x=e.name.includes(`(core)`),C=l(),w=r(),T=c(),E=async e=>{m(e);try{await C.mutateAsync({nodeId:t,addonId:e})}catch(e){console.error(`Failed to restart addon:`,e)}finally{m(null)}},O=async()=>{m(e.name);try{await w.mutateAsync({nodeId:t,processName:e.name})}catch(e){console.error(`Failed to restart process:`,e)}finally{m(null)}},k=async n=>{let r=`${t}/${e.name}`;try{await T.mutateAsync({nodeId:r,level:n}),y(n)}catch(e){console.error(`Failed to set log level:`,e)}};return D(`div`,{className:`border border-border/50 rounded-lg overflow-hidden`,children:[D(`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 items-center gap-2 w-full px-3 py-2 bg-muted/20 transition-colors text-left select-none ${s?``:`hover:bg-muted/40 cursor-pointer`}`,children:[s?j(`span`,{className:`h-3 w-3 shrink-0`}):j(u?z:re,{className:`h-3 w-3 text-muted-foreground shrink-0`}),x?j(te,{className:`h-3.5 w-3.5 text-primary shrink-0`}):j(R,{className:`h-3.5 w-3.5 text-amber-500 shrink-0`}),j(`span`,{className:`text-xs font-semibold flex-1`,children:e.name}),D(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`PID `,e.pid]}),j(me,{state:e.state}),D(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[e.cpuPercent,`% CPU`]}),j(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:J(e.memoryRss)}),j(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:pe(e.uptimeSeconds)}),!x&&D(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[D(v,{children:[j(S,{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:g}),j(_,{align:`end`,className:`min-w-[70px] py-0.5`,children:he.map(e=>j(f,{onClick:()=>k(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===g?`text-primary font-semibold`:``}`,children:e},e))})]}),j(`button`,{onClick:O,disabled:p===e.name,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart process`,children:j(I,{className:`h-3 w-3 ${p===e.name?`animate-spin`:``}`})})]})]}),u&&o.length>0&&j(`div`,{className:`divide-y divide-border/30`,children:o.map(e=>D(`div`,{children:[D(`div`,{className:`flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors`,children:[j(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`running`?`bg-success`:`bg-muted-foreground/30`}`}),j(`span`,{className:`text-xs font-medium flex-1 min-w-0 truncate`,children:e.addonId}),e.capabilities.length>0&&D(`div`,{className:`flex gap-1 flex-shrink-0`,children:[e.capabilities.slice(0,3).map(e=>j(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400 truncate max-w-[80px]`,children:e},e)),e.capabilities.length>3&&D(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.capabilities.length-3]})]}),D(`div`,{className:`flex items-center gap-1 shrink-0`,children:[j(`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:j(H,{className:`h-3 w-3`})}),j(`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:j(ee,{className:`h-3 w-3`})}),j(`button`,{onClick:()=>E(e.addonId),disabled:p===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:j(I,{className:`h-3 w-3 ${p===e.addonId?`animate-spin`:``}`})})]})]}),i?.addonId===e.addonId&&i.type===`logs`&&j(`div`,{className:`border-t border-border/40 bg-muted/5`,children:j(h,{addonId:e.addonId,agentId:t,maxHeight:`max-h-48`,showFilters:!1,onClose:()=>a(e.addonId,`logs`)})}),i?.addonId===e.addonId&&i.type===`events`&&j(`div`,{className:`border-t border-border/40 bg-muted/5`,children:j(b,{addonId:e.addonId,category:`addon.*`,maxHeight:`max-h-48`,onClose:()=>a(e.addonId,`events`)})})]},e.addonId))}),u&&o.length===0&&j(`div`,{className:`px-3 py-2 pl-9 text-[10px] text-muted-foreground`,children:`No services`})]})}function _e({nodeId:e,processes:t}){let[n,r]=A(null),i=(e,t)=>{r(n=>n?.addonId===e&&n.type===t?null:{addonId:e,type:t})};return t.length===0?j(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No processes on this node`}):j(`div`,{className:`space-y-2 py-1`,children:t.map((t,r)=>j(ge,{proc:t,nodeId:e,defaultExpanded:r===0,activePanel:n,onTogglePanel:i},t.name))})}E();function ve(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 ye(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function be({nodeId:e}){let n=k(),r=t(),[a,s]=A(`all`),c=d(`metrics.node-processes-snapshot`,t=>t.nodeId===e),{data:l}=o({nodeId:e}),u=c?.processes??l,f=O(()=>u?[...u]:[],[u]),p=O(()=>a===`ghost`?f.filter(e=>e.classification===`ghost`):f,[f,a]),m=O(()=>{let e=f.filter(e=>e.classification===`ghost`),t=new Map;for(let n of e)t.has(n.ppid)||t.set(n.ppid,[]),t.get(n.ppid).push(n);return[...t.entries()].filter(([,e])=>e.length>1).map(([e,t])=>({ppid:e,children:t})).toSorted((e,t)=>t.children.length-e.children.length)},[f]),h=i({onSettled:()=>{n.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]})}}),g=O(()=>{let e=new Map;for(let t of f)e.set(t.pid,t.classification);return e},[f]),_=async(t,n)=>{if(t.classification===`root`||t.classification===`system`)return;let i=t.classification===`ghost`?`ghost`:t.addonId??`process`,a=n?`SIGKILL`:`SIGTERM`;await r({title:`Send ${a}?`,message:`Target pid ${t.pid} (${i}) on node ${e}.`,confirmLabel:`Send ${a}`,variant:`danger`})&&h.mutate({nodeId:e,pid:t.pid,force:n})},v=async(t,n)=>{try{await h.mutateAsync({nodeId:e,pid:t,force:n})}catch{}},y=async t=>{let i=g.get(t.ppid);if(i===`root`||i===`system`){await r({title:`Cannot kill protected ancestor`,message:i===`root`?`pid ${t.ppid} is the current node supervisor. Restart the node via the cluster page instead.`:`pid ${t.ppid} is a system ancestor (concurrently / vite / npm wrapper). Killing it would tear down the dev tree.`,confirmLabel:`OK`,cancelLabel:`Close`,variant:`warning`});return}await r({title:`Kill ghost parent + ${t.children.length} child(ren)?`,message:`SIGKILL parent pid ${t.ppid} and SIGTERM ${t.children.length} ghost child(ren) on node ${e}.`,confirmLabel:`Kill all`,variant:`danger`})&&(await Promise.all([v(t.ppid,!0),...t.children.map(e=>v(e.pid,!1))]),n.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}))},b=async()=>{let t=f.filter(e=>e.classification===`ghost`);t.length!==0&&await r({title:`Kill all ${t.length} ghost process(es)?`,message:`SIGKILL ${t.length} ghost process(es) on node ${e}. This is irreversible.`,confirmLabel:`Kill all`,variant:`danger`})&&(await Promise.all(t.map(e=>v(e.pid,!0))),n.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}))},x=f.filter(e=>e.classification===`ghost`).length,S=f.filter(e=>e.classification===`managed`).length,C=f.filter(e=>e.classification===`root`).length,w=f.filter(e=>e.classification===`system`).length;return D(`div`,{className:`space-y-4`,children:[D(`div`,{className:`flex items-start justify-between gap-4`,children:[D(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`ps`," scan + kernel `$process.list` cross-reference. Ghosts = camstack-shaped commands with no managed binding (usually orphaned to ppid=1). Refreshes every 10s."]}),D(`button`,{type:`button`,onClick:()=>n.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:[j(F,{className:`h-3 w-3`}),` Refresh`]})]}),D(`div`,{className:`grid grid-cols-4 gap-3`,children:[D(`div`,{className:`rounded-lg border border-border p-3`,children:[j(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`Root`}),j(`div`,{className:`text-xl font-semibold text-foreground`,children:C})]}),D(`div`,{className:`rounded-lg border border-border p-3`,children:[j(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`Managed`}),j(`div`,{className:`text-xl font-semibold text-foreground`,children:S})]}),D(`div`,{className:`rounded-lg border border-border p-3`,children:[j(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`System`}),j(`div`,{className:`text-xl font-semibold text-foreground`,children:w})]}),D(`div`,{className:`rounded-lg border p-3 ${x>0?`border-destructive/40 bg-destructive/5`:`border-border`}`,children:[D(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle flex items-center gap-1`,children:[x>0&&j(X,{className:`h-3 w-3 text-destructive`}),` Ghosts`]}),j(`div`,{className:`text-xl font-semibold ${x>0?`text-destructive`:`text-foreground`}`,children:x})]})]}),m.length>0&&D(`div`,{className:`rounded-lg border border-amber-500/40 bg-amber-500/5 p-3`,children:[D(`div`,{className:`flex items-center gap-1 text-[11px] font-semibold text-amber-400 mb-2`,children:[j(U,{className:`h-3 w-3`}),` Recurring ghost parents (`,m.length,`)`]}),j(`div`,{className:`space-y-1.5`,children:m.map(e=>D(`div`,{className:`text-[11px] text-foreground flex items-center justify-between gap-2`,children:[D(`div`,{className:`flex items-center gap-2`,children:[D(`span`,{className:`font-mono text-foreground-subtle`,children:[`ppid `,e.ppid]}),D(`span`,{children:[`→ `,e.children.length,` ghost(s)`]})]}),D(`button`,{type:`button`,disabled:h.isPending,onClick:()=>{y(e)},className:`inline-flex items-center gap-1 rounded border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] text-amber-400 hover:bg-amber-500/20 disabled:opacity-30`,children:[j(X,{className:`h-3 w-3`}),` Kill parent + `,e.children.length]})]},e.ppid))})]}),D(`div`,{className:`flex items-center justify-between gap-2 text-[11px]`,children:[D(`div`,{className:`flex items-center gap-2`,children:[j(`span`,{className:`text-foreground-subtle`,children:`Filter:`}),D(`button`,{type:`button`,className:`px-2 py-0.5 rounded ${a===`all`?`bg-primary text-primary-foreground`:`border border-border text-foreground hover:bg-surface-hover`}`,onClick:()=>s(`all`),children:[`All (`,f.length,`)`]}),D(`button`,{type:`button`,className:`px-2 py-0.5 rounded ${a===`ghost`?`bg-destructive text-destructive-foreground`:`border border-border text-foreground hover:bg-surface-hover`}`,onClick:()=>s(`ghost`),children:[`Ghost only (`,x,`)`]})]}),x>0&&D(`button`,{type:`button`,disabled:h.isPending,onClick:()=>{b()},className:`inline-flex items-center gap-1 rounded border border-destructive/40 bg-destructive/10 px-2 py-1 text-[11px] font-medium text-destructive hover:bg-destructive/20 disabled:opacity-30`,children:[j(X,{className:`h-3 w-3`}),` Kill all `,x,` ghost(s)`]})]}),j(`div`,{className:`rounded-lg border border-border max-h-[60vh] overflow-auto`,children:D(`table`,{className:`w-full text-xs`,children:[j(`thead`,{className:`sticky top-0 z-10 bg-surface`,children:D(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[j(`th`,{className:`text-left px-3 py-2`,children:`Class`}),j(`th`,{className:`text-right px-3 py-2`,children:`PID`}),j(`th`,{className:`text-right px-3 py-2`,children:`PPID`}),j(`th`,{className:`text-left px-3 py-2`,children:`Addon`}),j(`th`,{className:`text-left px-3 py-2`,children:`Command`}),j(`th`,{className:`text-right px-3 py-2`,children:`CPU%`}),j(`th`,{className:`text-right px-3 py-2`,children:`RSS`}),j(`th`,{className:`text-right px-3 py-2`,children:`Uptime`}),j(`th`,{className:`w-44`})]})}),D(`tbody`,{children:[p.length===0&&j(`tr`,{children:j(`td`,{colSpan:9,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:a===`ghost`?`No ghost processes detected.`:`Scanning…`})}),p.map(e=>D(`tr`,{className:`border-t border-border ${e.classification===`ghost`?`bg-destructive/5`:``}`,children:[j(`td`,{className:`px-3 py-2`,children:j(`span`,{className:`inline-block rounded-full px-1.5 py-0.5 text-[10px] font-medium ${e.classification===`ghost`?`bg-destructive/20 text-destructive`:e.classification===`root`?`bg-sky-500/20 text-sky-400`:e.classification===`system`?`bg-foreground-subtle/20 text-foreground-subtle`:`bg-success/20 text-success`}`,children:e.classification})}),j(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.pid}),D(`td`,{className:`px-3 py-2 text-right font-mono text-foreground-subtle`,children:[e.ppid,e.orphaned?` ⚠`:``]}),j(`td`,{className:`px-3 py-2 text-foreground-subtle text-[11px]`,children:e.addonId??`—`}),j(`td`,{className:`px-3 py-2 font-mono text-[10px] text-foreground-subtle break-all`,children:ye(e.command)}),j(`td`,{className:`px-3 py-2 text-right text-foreground`,children:e.cpuPercent.toFixed(1)}),j(`td`,{className:`px-3 py-2 text-right text-foreground`,children:J(e.memoryRssBytes)}),j(`td`,{className:`px-3 py-2 text-right text-foreground-subtle`,children:ve(e.uptimeSec)}),j(`td`,{className:`px-3 py-2 text-right`,children:D(`div`,{className:`inline-flex gap-1`,children:[D(`button`,{type:`button`,disabled:h.isPending||e.classification===`root`||e.classification===`system`,onClick:()=>{_(e,!1)},title:`SIGTERM`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-border text-[10px] text-foreground hover:bg-surface-hover disabled:opacity-30`,children:[j(W,{className:`h-3 w-3`}),` Term`]}),D(`button`,{type:`button`,disabled:h.isPending||e.classification===`root`||e.classification===`system`,onClick:()=>{_(e,!0)},title:`SIGKILL`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-destructive/30 text-[10px] text-destructive hover:bg-destructive/10 disabled:opacity-30`,children:[j(X,{className:`h-3 w-3`}),` Kill`]})]})})]},e.pid))]})]})}),h.isError&&D(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[`Kill failed:`,` `,h.error instanceof Error?h.error.message:`unknown`]})]})}function xe({nodeId:e,addonIds:t}){return t.length===0?j(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No addons on this node`}):j(`div`,{className:`w-full py-2`,children:j(oe,{nodeId:e,addonIds:t,level:`global`,selfTabbed:!0})})}E();function Se({nodeId:e,addons:t}){let n=k(),{data:r,isLoading:i}=g({nodeId:e}),o=O(()=>{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]),s=a({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCapabilityBindings`]]})}});return o.length===0?j(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No capabilities on this node`}):j(`div`,{className:`rounded-lg border border-border max-h-[60vh] overflow-auto`,children:D(`table`,{className:`w-full text-xs`,children:[j(`thead`,{className:`sticky top-0 z-10 bg-surface`,children:D(`tr`,{className:`text-muted-foreground text-left`,children:[j(`th`,{className:`px-3 py-2 font-medium w-1/2`,children:`Capability`}),j(`th`,{className:`px-3 py-2 font-medium`,children:`Bound provider`})]})}),j(`tbody`,{children:o.map(({capName:t,providers:n})=>{let a=r?.[t]??n[0]??``,o=n.length===1;return D(`tr`,{className:`border-t border-border/50`,children:[j(`td`,{className:`px-3 py-2 font-medium`,children:t}),j(`td`,{className:`px-3 py-2`,children:j(`select`,{value:a,onChange:n=>s.mutate({nodeId:e,capName:t,addonId:n.target.value}),disabled:o||s.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:o?`Only one provider installed — choice becomes available once a second addon registers this capability`:void 0,children:n.map(e=>j(`option`,{value:e,children:e},e))})})]},t)})})]})})}E();function Z(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 Ce(t){let[n,r]=A(!1),[i,a]=A(t.name),o=k(),s=e({onSuccess:()=>{o.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}}),c=(t.localIps??[]).filter(e=>!e.includes(`:`)),l=(t.localIps??[]).filter(e=>e.includes(`:`)),u=async()=>{if(!i.trim()||i===t.name){r(!1);return}try{await s.mutateAsync({nodeId:t.nodeId,name:i.trim()}),r(!1)}catch(e){console.error(`Rename failed:`,e)}},d=[[`Node ID`,j(`span`,{className:`font-mono text-xs`,children:t.nodeId})],[`Display Name`,n?D(`div`,{className:`flex items-center gap-1.5`,children:[j(`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`&&u(),e.key===`Escape`&&r(!1)},disabled:s.isPending,autoFocus:!0}),j(`button`,{onClick:()=>void u(),disabled:s.isPending,className:`p-0.5 text-success hover:bg-success/10 rounded`,title:`Save`,children:j(ne,{className:`h-3.5 w-3.5`})}),j(`button`,{onClick:()=>r(!1),className:`p-0.5 text-muted-foreground hover:bg-muted rounded`,title:`Cancel`,children:j(ie,{className:`h-3.5 w-3.5`})})]}):D(`div`,{className:`flex items-center gap-1.5`,children:[j(`span`,{className:`text-xs`,children:t.name}),!t.isHub&&j(`button`,{onClick:()=>{a(t.name),r(!0)},className:`p-0.5 text-muted-foreground hover:text-primary rounded`,title:`Rename`,children:j(P,{className:`h-3 w-3`})})]})],[`Hostname`,j(`span`,{className:`text-xs`,children:t.hostname})],[`Role`,t.isHub?j(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium`,children:`Hub`}):j(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-medium`,children:`Agent`})],[`Root Package`,t.rootPackage?D(`span`,{className:`font-mono text-xs`,children:[t.rootPackage.name,`@`,t.rootPackage.version]}):j(`span`,{className:`text-xs text-muted-foreground`,children:`—`})],[`Platform`,D(`span`,{className:`text-xs`,children:[t.platform,` / `,t.arch]})],[`CPU`,D(`span`,{className:`text-xs`,children:[t.cpuModel??`—`,` (`,t.cpuCores,` cores)`]})],[`Memory`,j(`span`,{className:`text-xs`,children:t.memoryMB>0?`${(t.memoryMB/1024).toFixed(1)} GB`:`—`})],[`Uptime`,j(`span`,{className:`text-xs`,children:Z(t.uptime)})],[`Engines`,t.engines.length>0?j(`div`,{className:`flex flex-wrap gap-1`,children:t.engines.map(e=>j(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium`,children:e},e))}):j(`span`,{className:`text-xs text-muted-foreground`,children:`—`})]];return c.length>0&&d.push([`IPv4`,j(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map((e,t)=>j(`span`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:e},`${e}-${t}`))})]),l.length>0&&d.push([`IPv6`,j(`div`,{className:`flex flex-wrap gap-1.5`,children:l.map((e,t)=>j(`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}`))})]),j(`div`,{className:`py-2`,children:j(`table`,{className:`w-full text-sm`,children:j(`tbody`,{children:d.map(([e,t],n)=>D(`tr`,{className:n%2==0?`bg-muted/20`:``,children:[j(`td`,{className:`py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap`,children:e}),j(`td`,{className:`py-1.5 px-2`,children:t})]},e))})})})}E();var we=[[`serverManagement`,`getServerPackageStatus`]];function Q({label:e,tone:t}){return j(`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-emerald-500/15 text-emerald-500`,info:`bg-sky-500/15 text-sky-500`,warn:`bg-amber-500/15 text-amber-500`,error:`bg-red-500/15 text-red-500`}[t]}`,children:e})}function $({label:e,value:t}){return D(`div`,{className:`flex items-center justify-between gap-4 text-sm`,children:[j(`span`,{className:`text-foreground-subtle`,children:e}),j(`span`,{className:`font-mono text-foreground`,children:t??`—`})]})}function Te({node:e}){let{t:n}=G(),r=k(),i=t(),[a,o]=A(!1),s=e.isHub?void 0:{nodeId:e.id},c=x(s,{refetchInterval:1e4,enabled:e.isOnline,retry:1}),l=c.data??null,u=w(()=>{r.invalidateQueries({queryKey:we})},[r]),d=y({onSettled:u}),f=p({onSettled:u}),h=m({onSettled:u}),g=w(async()=>{l?.latestVersion!=null&&await i({title:n(`serverManagement.confirmUpdateTitle`,`Update node root package`),message:n(`serverManagement.confirmUpdateBody`,`Install {{pkg}}@{{version}} on "{{node}}" and restart to apply.`,{pkg:l.packageName,version:l.latestVersion,node:e.name}),confirmLabel:n(`serverManagement.confirmUpdateAction`,`Update & restart`)})&&(await f.mutateAsync({version:l.latestVersion,...s})).restarting&&o(!0)},[f,i,e.name,s,l,n]),_=w(async()=>{await i({title:n(`serverManagement.confirmRestartTitle`,`Restart node`),message:n(`serverManagement.confirmRestartBody`,`Restart "{{node}}"? In-flight requests to this node are dropped.`,{node:e.name}),confirmLabel:n(`serverManagement.confirmRestartAction`,`Restart`),variant:`warning`})&&(await h.mutateAsync(s)).restarting&&o(!0)},[i,e.name,h,s,n]),v=()=>{switch(l?.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`}}},b=()=>{if(l==null)return null;switch(l.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 l.updateAvailable?{label:n(`serverManagement.stateUpdateAvailable`,`update available`),tone:`warn`}:{label:n(`serverManagement.stateUpToDate`,`up to date`),tone:`ok`}}},S=l?.bootMode===`workspace`,C=e.isOnline&&l!=null&&!S&&l.updateAvailable&&l.updateState===`idle`&&!f.isPending,T=e.isOnline&&l!=null&&l.updateState===`idle`&&!h.isPending,E=e.isOnline?b():null;return D(`div`,{className:`space-y-4 py-2`,children:[D(`div`,{className:`flex items-center justify-between gap-3`,children:[D(`div`,{className:`flex items-center gap-2 min-w-0`,children:[j(`span`,{className:`font-mono text-xs text-foreground-subtle truncate`,children:l?.packageName??e.rootPackage?.name??`@camstack/server`}),e.isOnline&&l!=null&&j(Q,{...v()})]}),E!=null&&j(Q,{...E})]}),!e.isOnline&&j($,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:e.rootPackage?.version??null}),e.isOnline&&c.isLoading&&D(`div`,{className:`flex items-center gap-2 text-sm text-foreground-subtle`,children:[j(B,{className:`h-4 w-4 animate-spin`}),n(`common.loading`,`Loading…`)]}),e.isOnline&&c.isError&&D(`div`,{className:`space-y-1.5`,children:[j(`p`,{className:`text-sm text-red-500`,children:n(`serverManagement.loadError`,`Could not load the node root-package status.`)}),e.rootPackage!=null&&j($,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:e.rootPackage.version})]}),e.isOnline&&l!=null&&D(`div`,{className:`space-y-1.5`,children:[j($,{label:n(`serverManagement.runningVersion`,`Running version`),value:l.runningVersion}),j($,{label:n(`serverManagement.latestVersion`,`Latest on registry`),value:l.latestVersion}),j($,{label:n(`serverManagement.nodeRuntimeVersion`,`Node.js runtime`),value:l.nodeRuntimeVersion}),l.pendingVersion!=null&&j($,{label:n(`serverManagement.pendingVersion`,`Staged (applies on restart)`),value:l.pendingVersion})]}),e.isOnline&&S&&j(`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).`)}),a&&D(`div`,{className:`flex items-center gap-2 text-sm text-amber-500`,children:[j(B,{className:`h-4 w-4 animate-spin`}),n(`serverManagement.nodeRestarting`,`The node is restarting to apply the change…`)]}),e.isOnline&&D(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[D(`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:d.isPending||l?.updateState===`staging`,onClick:()=>d.mutate(s),children:[d.isPending?j(B,{className:`h-3.5 w-3.5 animate-spin`}):j(F,{className:`h-3.5 w-3.5`}),n(`serverManagement.checkForUpdate`,`Check for update`)]}),C&&D(`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 g(),children:[f.isPending?j(B,{className:`h-3.5 w-3.5 animate-spin`}):j(Y,{className:`h-3.5 w-3.5`}),n(`serverManagement.updateTo`,`Update to {{version}}`,{version:l?.latestVersion??``})]}),D(`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:!T,onClick:()=>void _(),children:[h.isPending?j(B,{className:`h-3.5 w-3.5 animate-spin`}):j(I,{className:`h-3.5 w-3.5`}),n(`serverManagement.restart`,`Restart`)]})]}),e.isOnline&&l?.lastCheckedAtMs!=null&&D(`p`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[j(ce,{className:`h-3 w-3`}),n(`serverManagement.lastChecked`,`Last checked: {{when}}`,{when:new Date(l.lastCheckedAtMs).toLocaleString()})]})]})}E();function Ee({node:e}){let t=N(),[n,r]=A(`info`),[i,a]=A(!1),o=e.processes??[],s=e.addons.map(e=>e.id),c=async()=>{if(!i){a(!0);try{await Promise.allSettled([t.trpcClient.pipelineOrchestrator.removeAgentSettings.mutate({agentNodeId:e.id}),t.trpcClient.clusterNodes.forgetNode.mutate({nodeId:e.id})])}finally{a(!1)}}};return e.isOnline?D(`div`,{className:`border border-border rounded-xl`,children:[D(`div`,{className:`flex items-center gap-3 px-4 py-3 bg-muted/30 border-b border-border rounded-t-xl`,children:[j(`div`,{className:`w-2.5 h-2.5 rounded-full bg-success`}),j(`span`,{className:`text-sm font-semibold`,children:e.name}),D(`span`,{className:`text-xs text-muted-foreground`,children:[e.cpuModel??e.platform,` ·`,` `,e.memoryMB>0?`${Math.round(e.memoryMB/1024)}GB`:``,` · `,e.arch]}),e.engines.map(e=>j(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium`,children:e},e)),D(`div`,{className:`ml-auto flex gap-3 text-xs text-muted-foreground`,children:[D(`span`,{className:`flex items-center gap-1`,children:[j(ae,{className:`h-3 w-3`}),` `,e.cpuPercent,`%`]}),D(`span`,{className:`flex items-center gap-1`,children:[j(le,{className:`h-3 w-3`}),` `,e.memoryPercent,`%`]})]})]}),j(`div`,{className:`sticky top-0 z-20 flex border-b border-border px-4 bg-background overflow-x-auto`,children:[`info`,`addons`,`forks`,`processes`,`settings`,`capabilities`].map(t=>j(`button`,{onClick:()=>r(t),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${n===t?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:t===`info`?`General`:t===`addons`?`Addons (${e.addons.length})`:t===`forks`?`Forks (${o.length})`:t===`processes`?`Processes`:t===`settings`?`Settings`:`Capabilities`},t))}),D(`div`,{className:`px-4 py-2`,children:[n===`info`&&D(`div`,{className:`space-y-3`,children:[j(Ce,{nodeId:e.id,name:e.name,hostname:e.hostname,platform:e.platform,arch:e.arch,cpuModel:e.cpuModel,cpuCores:e.cpuCores,memoryMB:e.memoryMB,engines:e.engines,isHub:e.isHub,uptime:e.uptime,localIps:e.localIps,rootPackage:e.rootPackage}),j(`div`,{className:`border-t border-border pt-1`,children:j(Te,{node:{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,rootPackage:e.rootPackage??null}})})]}),n===`addons`&&j(fe,{nodeId:e.id,addons:e.addons,isHub:e.isHub}),n===`forks`&&j(_e,{nodeId:e.id,processes:o}),n===`processes`&&j(be,{nodeId:e.id}),n===`settings`&&j(xe,{nodeId:e.id,addonIds:s}),n===`capabilities`&&j(Se,{nodeId:e.id,addons:e.addons})]})]}):D(`div`,{className:`border border-border rounded-xl overflow-hidden opacity-60`,children:[D(`div`,{className:`flex items-center gap-3 px-4 py-3 bg-muted/30`,children:[j(`div`,{className:`w-2.5 h-2.5 rounded-full bg-destructive`}),j(`span`,{className:`text-sm font-semibold`,children:e.name}),D(`span`,{className:`text-xs text-muted-foreground`,children:[e.cpuModel??e.platform,` ·`,` `,e.memoryMB>0?`${Math.round(e.memoryMB/1024)}GB`:``,` · `,e.arch]}),e.engines.map(e=>j(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium`,children:e},e)),e.rootPackage&&D(`span`,{className:`text-[10px] font-mono px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:[e.rootPackage.name,`@`,e.rootPackage.version]}),j(`span`,{className:`ml-auto text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`})]}),D(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[D(`span`,{className:`text-xs text-muted-foreground`,children:[e.lastSeen?`Last seen ${new Date(e.lastSeen).toLocaleString()} — `:``,e.addons.length,` addon`,e.addons.length===1?``:`s`,` assigned; will resume when node reconnects`]}),D(`button`,{type:`button`,onClick:()=>void c(),disabled:i,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:[j(W,{className:`h-3 w-3`}),i?`Forgetting…`:`Forget node`]})]})]})}E();function De({nodes:e,focusNodeId:t,focusNonce:n}){let r=[...e].toSorted((e,t)=>e.isHub?-1:t.isHub?1:e.isOnline&&!t.isOnline?-1:!e.isOnline&&t.isOnline?1:e.name.localeCompare(t.name)),i=T(null);return M(()=>{if(!t)return;let e=i.current?.querySelector(`#node-card-${CSS.escape(t)}`);e&&e.scrollIntoView({behavior:`smooth`,block:`start`})},[t,n]),j(`div`,{ref:i,className:`flex flex-col gap-4`,children:r.map(e=>j(`div`,{id:`node-card-${e.id}`,children:j(Ee,{node:e})},e.id))})}E();function Oe(e){let[t,n]=A(()=>typeof window<`u`?window.matchMedia(e).matches:!1);return M(()=>{let t=window.matchMedia(e),r=e=>n(e.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}function ke(){let{data:e,isLoading:t}=u(void 0,{staleTime:1/0}),[n,r]=A(null);return s(`cluster.topology-snapshot`,e=>{let t=e.data?.nodes;Array.isArray(t)&&r(t)}),{nodes:O(()=>n??e??[],[n,e]),isLoading:t&&!n}}function Ae(){let{t:e}=G(),n=t(),[r,i]=A(`table`),[a,o]=A(void 0),[s,c]=A(0),l=Oe(`(max-width: 767px)`),u=l&&r===`graph`?`table`:r,{nodes:d,isLoading:f}=ke(),m=O(()=>q(d),[d]),h=O(()=>d.filter(e=>e.isOnline),[d]),g=h.length,_=d.filter(e=>!e.isOnline).length,v=p(),[y,b]=A(!1),x=w(async()=>{let t=[...h].sort((e,t)=>e.isHub===t.isHub?0:e.isHub?1:-1);if(await n({title:e(`serverManagement.confirmUpdateAllTitle`,`Update all nodes`),message:e(`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:e(`serverManagement.confirmUpdateAllAction`,`Update all & restart`),variant:`warning`})){b(!0);try{for(let e of t)try{await v.mutateAsync(e.isHub?{}:{nodeId:e.id})}catch{}}finally{b(!1)}}},[v,n,h,e]),S=w(e=>{i(`table`),o(e),c(e=>e+1)},[]),C=(e,t,n)=>D(`button`,{onClick:()=>i(e),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${r===e?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[j(n,{className:`h-3.5 w-3.5`}),t]});return D(`div`,{className:`flex flex-col h-full gap-4 p-4`,children:[D(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[D(`div`,{className:`flex items-center gap-2`,children:[g>0&&D(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-success/10 text-success`,children:[g,` online`]}),_>0&&D(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:[_,` offline`]})]}),D(`div`,{className:`flex items-center gap-2`,children:[g>1&&D(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50`,disabled:y,title:e(`serverManagement.updateAllHint`,`Sequenced agents-first, hub-last — up-to-date nodes are skipped.`),onClick:()=>void x(),children:[y?j(B,{className:`h-3.5 w-3.5 animate-spin`}):j(Y,{className:`h-3.5 w-3.5`}),e(`serverManagement.updateAll`,`Update all nodes`)]}),D(`div`,{className:`flex gap-0.5 p-1 rounded-lg bg-muted`,children:[C(`table`,`Table`,ue),!l&&C(`graph`,`Graph`,se)]})]})]}),f?j(`div`,{className:`flex items-center justify-center flex-1 text-muted-foreground`,children:`Loading cluster topology...`}):u===`graph`?j(K,{graph:m,onOpenNodeDetail:S}):j(`div`,{className:`flex-1 overflow-auto`,children:j(De,{nodes:d,focusNodeId:a,focusNonce:s})})]})}export{Ae as ClusterPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ga as e,Wr as t,fa as n,ft as r,ga as i,ma as a,pa as o,ut as s}from"./src-
|
|
1
|
+
import{Ga as e,Wr as t,fa as n,ft as r,ga as i,ma as a,pa as o,ut as s}from"./src-8VwlAVGW.js";import{Q as c,S as l,W as u,o as d,q as f,x as p}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{n as m,r as h,t as g}from"./AddLocationWizard-CXk6-CfE.js";import{S as _}from"./index-0lydznr9.js";c();function v({types:t}){let r=d(),s=e(),{data:c}=a({}),_=o(),v=u(()=>_.data??[],[_.data]),[y,b]=f(null),[x,S]=f(null),C=()=>{r.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})},w=i({onSuccess:C}),T=n({onSuccess:C}),E=u(()=>{let e=new Map;for(let t of c??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[c]),D=e=>{e.isDefault||w.mutate({id:e.id,type:e.type,providerId:e.providerId,displayName:e.displayName,config:e.config,isDefault:!0})},O=async e=>{if(e.isDefault){await s({title:`Cannot delete default location`,message:`"${e.displayName}" is the default for type "${e.type}". Mark another as default first.`,confirmLabel:`OK`,variant:`warning`});return}await s({title:`Delete location "${e.displayName}"?`,message:`Removes the record; files on disk are untouched.`,confirmLabel:`Delete`,variant:`danger`})&&T.mutate({id:e.id})},k=t.map(e=>v.find(t=>t.id===e)).filter(e=>e!==void 0);return l(`div`,{className:`space-y-3`,children:[k.length===0?p(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:`No storage locations declared for this purpose.`}):k.map(e=>p(h,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:E.get(e.id)??[],onAdd:e=>b(e),onEdit:e=>S(e),onDelete:e=>{O(e)},onSetDefault:e=>D(e)},e.id)),y!==null&&p(g,{initialType:y,onClose:()=>b(null),onCreated:()=>{C(),b(null)}}),x!==null&&p(m,{location:x,onClose:()=>S(null),onSaved:()=>{C(),S(null)}})]})}c();var y=`recorder`;function b(e,t,n){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t&&typeof e.value==`string`)return e.value;return n}function x(){let e=d(),{data:n}=t(void 0),{data:i,isLoading:a}=s({addonId:y}),o=b(i,`recordingNodeId`,`hub`),c=r({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),f=u(()=>{let e=(n??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,o,...e])].filter(Boolean)},[n,o]);return l(`div`,{className:`flex flex-col gap-6`,children:[l(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[p(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Recording node`}),p(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that records (continuous & events) and serves playback. Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),l(`div`,{className:`mt-3 flex items-center gap-2`,children:[a?p(_,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):p(`select`,{value:o,onChange:e=>{e.target.value!==o&&c.mutate({addonId:y,patch:{recordingNodeId:e.target.value}})},disabled:c.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:f.map(e=>p(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),c.isPending&&p(_,{className:`h-4 w-4 animate-spin text-primary`})]}),o!==`hub`&&l(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:[`The stream-broker is hub-only — an agent recorder pulls streams from the hub over the network. The hub's RTSP restream port must be reachable from`,` `,p(`span`,{className:`font-medium`,children:o}),`. If the auto-derived host doesn't work, set the recorder's`,p(`span`,{className:`font-medium`,children:` recordingHubHostname`}),` global setting.`]})]}),l(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[p(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Recordings folders`}),p(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where recordings are stored. Multi-location collections — segments are split across the locations of a type. Add a location to grow capacity; mark one default per type.`}),p(v,{types:[`recordings`,`recordingsLow`]})]})]})}export{v as n,x as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,Mn as t,T as n}from"./src-
|
|
1
|
+
import{A as e,Mn as t,T as n}from"./src-8VwlAVGW.js";import{I as r,Q as i,S as a,W as o,q as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{t as l}from"./plus-Cr4EV11F.js";import{C as u,i as d}from"./index-0lydznr9.js";i();var f=`camstack:dashboard-layout`,p={version:1,widgets:[]};function m(){try{let e=localStorage.getItem(f);if(!e)return p;let t=JSON.parse(e);return t&&t.version===1&&Array.isArray(t.widgets)?{version:1,widgets:t.widgets}:p}catch{return p}}function h(e){try{localStorage.setItem(f,JSON.stringify(e))}catch{}}function g(){let e=typeof crypto<`u`?crypto:void 0;return e?.randomUUID?e.randomUUID():`widget-${Date.now().toString(36)}-${Math.floor(Math.random()*1e6).toString(36)}`}function _(){let[t,n]=s(m),[i,u]=s(!1),d=e(),f=o(()=>d.filter(e=>e.hosts.includes(`dashboard`)),[d]),p=r(e=>{n(e),h(e)},[]),g=r(e=>{p({version:1,widgets:[...t.widgets,e]})},[t,p]),_=r(e=>{p({version:1,widgets:t.widgets.filter(t=>t.instanceId!==e)})},[t,p]);return a(`div`,{className:`p-4`,children:[a(`div`,{className:`flex items-center justify-between mb-4`,children:[c(`h1`,{className:`text-lg font-semibold text-foreground`,children:`Dashboard`}),a(`button`,{onClick:()=>u(!0),className:`flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:[c(l,{className:`h-3.5 w-3.5`}),`Add widget`]})]}),t.widgets.length===0?c(v,{onAdd:()=>u(!0)}):c(`div`,{className:`grid grid-cols-12 gap-3 auto-rows-[minmax(80px,_auto)]`,children:t.widgets.map(e=>c(y,{entry:e,onRemove:()=>_(e.instanceId)},e.instanceId))}),i&&c(x,{widgets:f,onClose:()=>u(!1),onAdd:e=>{g(e),u(!1)}})]})}function v({onAdd:e}){return a(`div`,{className:`flex flex-col items-center justify-center py-24 text-foreground-subtle`,children:[c(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-2xl bg-surface border border-border mb-4`,children:c(u,{className:`h-8 w-8 text-foreground-subtle/40`})}),c(`p`,{className:`text-sm font-medium text-foreground/70`,children:`Your dashboard is empty`}),c(`p`,{className:`text-xs text-foreground-subtle mt-1 mb-4`,children:`Add widgets to monitor your cameras and system`}),a(`button`,{onClick:e,className:`flex items-center gap-1.5 rounded-lg bg-primary px-4 py-2 text-xs font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg transition-all`,children:[c(l,{className:`h-3.5 w-3.5`}),`Add your first widget`]})]})}function y({entry:e,onRemove:t}){let r=b(e.columns),i=Math.max(1,Math.min(12,e.rows));return a(`div`,{className:`relative group rounded-lg border border-border bg-surface overflow-hidden flex flex-col`,style:{gridColumn:`span ${r} / span ${r}`,gridRow:`span ${i} / span ${i}`},children:[c(`button`,{type:`button`,onClick:t,title:`Remove widget`,className:`absolute right-1.5 top-1.5 z-10 inline-flex h-5 w-5 items-center justify-center rounded-md border border-border/60 bg-surface/80 text-foreground-subtle opacity-0 group-hover:opacity-100 hover:bg-danger/10 hover:text-danger hover:border-danger/40 transition-all`,children:c(d,{className:`h-3 w-3`})}),c(`div`,{className:`flex-1 min-h-0 overflow-auto p-2`,children:c(n,{widgetId:e.widgetId,host:`dashboard`,instanceId:e.instanceId,config:e.config,deviceId:e.deviceId,size:e.size,columns:e.columns,rows:e.rows})})]})}function b(e){return!Number.isFinite(e)||e<1?6:Math.min(12,Math.floor(e))}function x({widgets:e,onClose:t,onAdd:n}){let[r,i]=s(null);return c(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:t,children:a(`div`,{className:`w-full max-w-2xl rounded-xl border border-border bg-surface p-5 shadow-2xl shadow-black/20`,onClick:e=>e.stopPropagation(),children:[a(`div`,{className:`flex items-center justify-between mb-4`,children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:r?`Configure: ${r.label}`:`Add widget`}),c(`button`,{onClick:t,className:`p-1 rounded-md hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors`,children:c(d,{className:`h-4 w-4`})})]}),r===null?c(S,{widgets:e,onSelect:i}):c(C,{widget:r,onCancel:()=>i(null),onAdd:n})]})})}function S({widgets:e,onSelect:t}){return e.length===0?c(`div`,{className:`text-center py-8 text-xs text-foreground-subtle italic`,children:`No dashboard-host widgets registered. Make sure the contributing addons are enabled and have rebuilt their widget bundles.`}):c(`div`,{className:`grid grid-cols-2 gap-2 max-h-96 overflow-auto`,children:e.map(e=>a(`button`,{onClick:()=>t(e),className:`flex flex-col rounded-lg border border-border p-3 text-left hover:bg-surface-hover hover:border-primary/30 transition-all group`,children:[c(`span`,{className:`text-xs font-medium text-foreground block`,children:e.label}),c(`span`,{className:`text-[10px] text-foreground-subtle truncate`,title:e.widgetId,children:e.widgetId}),e.description&&c(`span`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-2`,children:e.description})]},e.widgetId))})}function C({widget:e,onCancel:n,onAdd:r}){let[i,o]=s(e.defaultSize),[l,u]=s(e.defaultColumns),[d,f]=s(e.defaultRows),[p,m]=s(null),{data:h}=t({},{enabled:e.requires.deviceContext}),_=!e.requires.deviceContext||p!==null&&p>0;return a(`div`,{className:`space-y-3`,children:[a(`div`,{children:[c(`label`,{className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Size`}),c(`div`,{className:`flex items-center gap-1`,children:e.allowedSizes.map(e=>c(`button`,{onClick:()=>o(e),className:`px-3 py-1 rounded-md text-[11px] font-medium border transition-colors ${i===e?`bg-primary/10 text-primary border-primary/30`:`border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.toUpperCase()},e))})]}),a(`div`,{className:`grid grid-cols-2 gap-3`,children:[c(w,{label:`Columns (1-12)`,value:l,min:1,max:12,onChange:u}),c(w,{label:`Rows (1-12)`,value:d,min:1,max:12,onChange:f})]}),e.requires.deviceContext&&a(`div`,{children:[c(`label`,{className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Device`}),a(`select`,{value:p??``,onChange:e=>m(e.target.value===``?null:Number(e.target.value)),className:`w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none`,children:[c(`option`,{value:``,children:`— select a device —`}),(h??[]).map(e=>a(`option`,{value:e.id,children:[e.name??e.stableId,` (#`,e.id,`)`]},e.id))]})]}),a(`div`,{className:`flex items-center justify-end gap-2 pt-2 border-t border-border`,children:[c(`button`,{onClick:n,className:`px-3 py-1.5 rounded-md text-xs font-medium border border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors`,children:`Back`}),c(`button`,{disabled:!_,onClick:()=>{_&&r({instanceId:g(),widgetId:e.widgetId,size:i,columns:l,rows:d,...e.requires.deviceContext&&p!==null?{deviceId:p}:{}})},className:`px-3 py-1.5 rounded-md text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:`Add to dashboard`})]})]})}function w({label:e,value:t,min:n,max:r,onChange:i}){return a(`div`,{children:[c(`label`,{className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:e}),c(`input`,{type:`number`,min:n,max:r,value:t,onChange:e=>{let t=Number(e.target.value);Number.isFinite(t)&&i(Math.max(n,Math.min(r,Math.floor(t))))},className:`w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none`})]})}function T(){return c(_,{})}export{T as DashboardPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Et as e,Ga as t,Gt as n,Ht as r,Jt as i,Kt as a,Ut as o,Vt as s,Wt as c,Xt as l,Yt as u,bt as d,fa as f,ga as p,ma as m,pa as h,qt as g,xt as _}from"./src-BDNLbHXL.js";import{I as v,Q as y,S as b,W as x,a as S,b as C,o as w,q as T,x as E,z as D}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{p as O}from"./player-overlays-CNHQKrHd.js";import{a as k,i as A,n as j,r as M,t as N}from"./AddLocationWizard-BowIG3iq.js";import{t as P}from"./download-Dq6V-5xf.js";import{t as F}from"./pencil-BuY8CueB.js";import{n as I,t as ee}from"./AddonCollectionPage-DzUEOYUV.js";import{t as te}from"./plus-DyBHOfPx.js";import{t as L}from"./rotate-cw-J5QBXynE.js";import{H as ne,I as re,P as ie,S as R,W as z,i as B,m as V,s as H}from"./index-BsmimqzB.js";import{t as U}from"./AdminPage-Dq33XE9j.js";import{n as ae}from"./authed-media-XfBD4Ma-.js";import{t as W}from"./format-size-CO9d3C3-.js";import{t as G}from"./AdminTabs-C-SMNF-6.js";import{t as K}from"./addon-display-names-DvSEQty-.js";var q=z(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),J=z(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),oe=z(`calendar-clock`,[[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M17.5 17.5 16 16.3V14`,key:`akvzfd`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),se=z(`file-text`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]);y();var ce=new Set([`recordings`,`recordingsLow`]);function le(e){let t=e.filesTotal===null?``:`/${e.filesTotal}`,n=Math.round(e.bytesMoved/(1024*1024)),r=`${e.entities.join(`+`)}: ${e.filesMoved}${t} files, ${n} MB — ${e.state}`;return e.error?`${r} (${e.error})`:r}function ue({location:e,onClose:t}){let n=O().trpcClient,[r,i]=T(``),[a,o]=T(!0),[s,c]=T(!0),[l,u]=T(null),[d,f]=T(!1),p=S({queryKey:[`storage`,`listLocations`,`relocate`],queryFn:()=>n.storage.listLocations.query({})}),m=x(()=>(p.data??[]).filter(t=>t.id!==e.id&&ce.has(t.type)&&t.config.readOnly!==!0&&t.config.basePath!==e.config.basePath),[p.data,e]),h=S({queryKey:[`relocate`,`jobs`],queryFn:async()=>{let[e,t]=await Promise.all([n.recording.getRelocateStatus.query({}).catch(()=>[]),n.pipelineAnalytics.getMediaRelocateStatus.query({}).catch(()=>[])]);return[...e,...t].sort((e,t)=>t.startedAt-e.startedAt)},refetchInterval:2e3}),g=h.data??[],_=g.some(e=>e.state===`running`);D(()=>{r===``&&m.length>0&&i(m[0].id)},[m,r]);let v=async()=>{if(r!==``){u(null),f(!0);try{a&&await n.recording.relocateFootage.mutate({fromLocationId:e.id,toLocationId:r}),s&&await n.pipelineAnalytics.relocateMedia.mutate({toLocationId:r}),await h.refetch()}catch(e){u(e instanceof Error?e.message:String(e))}finally{f(!1)}}},y=async e=>{try{e.entities.includes(`media`)?await n.pipelineAnalytics.cancelMediaRelocate.mutate({jobId:e.jobId}):await n.recording.cancelRelocate.mutate({jobId:e.jobId}),await h.refetch()}catch{}};return E(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:t,children:b(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[b(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[b(`div`,{className:`space-y-0.5`,children:[b(`h2`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[E(k,{className:`h-3.5 w-3.5`}),`Relocate from `,e.displayName]}),E(`p`,{className:`text-xs text-foreground-subtle`,children:`Throttled background move; safe to re-run — it resumes where it stopped. Mark this location read-only first so nothing new lands here.`})]}),E(`button`,{onClick:t,className:`text-foreground-subtle hover:text-foreground`,children:E(B,{className:`h-4 w-4`})})]}),b(`div`,{className:`p-4 space-y-3`,children:[b(`div`,{className:`space-y-1`,children:[E(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Target location`}),m.length===0?E(`p`,{className:`text-[11px] text-foreground-subtle`,children:`No writable recordings location on a different root to move to.`}):E(`select`,{value:r,onChange:e=>i(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:m.map(e=>b(`option`,{value:e.id,children:[e.displayName,` (`,String(e.config.basePath??e.id),`)`]},e.id))})]}),b(`div`,{className:`space-y-1`,children:[b(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[E(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),className:`accent-primary`}),`Footage (segments + strips)`]}),b(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[E(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked),className:`accent-primary`}),`Event media (crops, thumbnails, snapshots)`]})]}),l&&E(`p`,{className:`text-[11px] text-danger`,children:l}),g.length>0&&E(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:g.slice(0,4).map(e=>b(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5`,children:[E(`span`,{className:`flex-1 truncate text-[11px] text-foreground`,children:le(e)}),e.state===`running`&&E(`button`,{onClick:()=>void y(e),className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground`,children:`Cancel`})]},e.jobId))})]}),b(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3`,children:[E(`button`,{onClick:t,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground`,children:`Close`}),E(`button`,{onClick:()=>void v(),disabled:r===``||d||_||!a&&!s,className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:_?`Running…`:`Start relocation`})]})]})})}y();function de(){let e=w(),n=t(),{data:r,isLoading:i,isError:a}=m({}),o=h(),s=x(()=>o.data??[],[o.data]),[c,l]=T(null),[u,d]=T(null),[g,_]=T(null),v=f({onSuccess:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),y=p({onSuccess:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),S=e=>{e.isDefault||y.mutate({id:e.id,type:e.type,providerId:e.providerId,displayName:e.displayName,config:e.config,isDefault:!0})},C=async e=>{if(e.isDefault){await n({title:`Cannot delete default location`,message:`"${e.displayName}" is the default for type "${e.type}". Mark another location as default first, then delete this one.`,confirmLabel:`OK`,variant:`warning`});return}await n({title:`Delete location "${e.displayName}"?`,message:`This removes the location record. Files on disk are not deleted; the underlying directory or remote path stays untouched.`,confirmLabel:`Delete`,variant:`danger`})&&v.mutate({id:e.id})},D=x(()=>{let e=new Map;for(let t of r??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[r]),O=i||o.isLoading,k=a||o.isError;return b(U,{children:[O&&E(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading locations…`}),k&&E(`div`,{className:`text-xs text-danger`,children:`Failed to load storage locations.`}),!O&&!k&&b(`div`,{className:`space-y-3`,children:[s.length===0&&E(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-[11px] text-foreground-subtle italic`,children:`No storage locations declared by any installed addon.`}),s.map(e=>E(M,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:D.get(e.id)??[],onAdd:e=>l(e),onEdit:e=>d(e),onDelete:e=>{C(e)},onSetDefault:e=>S(e),...e.id===`recordings`||e.id===`recordingsLow`?{onRelocate:e=>_(e)}:{}},e.id))]}),c!==null&&E(N,{initialType:c,onClose:()=>l(null),onCreated:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),l(null)}}),u!==null&&E(j,{location:u,onClose:()=>d(null),onSaved:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),d(null)}}),g&&E(ue,{location:g,onClose:()=>_(null)})]})}y();var fe=[[`backup`,`listDestinations`]],pe=[`backup`,`listArchives`];function me({destinationId:e,restoreSupported:n,onOpenRestoreWizard:r}){let i=w(),a=t(),{data:o,isLoading:l,isError:u}=c({destinationId:e}),d=o??[],f=s({onSuccess:()=>{i.invalidateQueries({queryKey:[[...pe]]}),i.invalidateQueries({queryKey:fe})}}),p=v(async t=>{await a({title:`Delete this archive?`,message:`Permanently deletes "${t.label??t.id}" and frees ${W(t.sizeBytes)}.`,confirmLabel:`Delete`,variant:`danger`})&&f.mutate({destinationId:e,backupId:t.id})},[a,e,f]),[m,h]=T(null),g=v(async t=>{h(t.id);try{let n=await ae(he(e,t.id)),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${t.label??t.id}.tar.gz`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}finally{h(null)}},[e]),_=x(()=>[...d].toSorted((e,t)=>t.createdAt-e.createdAt),[d]);return l?E(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:`Loading archives…`}):u?E(`div`,{className:`text-xs text-danger py-2`,children:`Failed to read manifest for this destination`}):_.length===0?E(`div`,{className:`text-xs text-foreground-subtle italic py-2`,children:`No archives at this destination yet.`}):E(`div`,{className:`rounded border border-border bg-surface overflow-x-auto`,children:b(`table`,{className:`w-full text-xs min-w-[640px]`,children:[E(`thead`,{children:b(`tr`,{className:`text-foreground-subtle bg-background/30`,children:[E(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`When`}),E(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Label`}),E(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Includes`}),E(`th`,{className:`text-right px-3 py-1.5 font-medium`,children:`Size`}),E(`th`,{className:`text-right px-3 py-1.5 font-medium w-52`,children:`Actions`})]})}),E(`tbody`,{children:_.map(t=>b(`tr`,{className:`border-t border-border hover:bg-primary/5`,children:[E(`td`,{className:`px-3 py-1.5 text-foreground tabular-nums`,children:Y(t.createdAt)}),E(`td`,{className:`px-3 py-1.5 text-foreground`,children:t.label??E(`span`,{className:`text-foreground-subtle italic`,children:`—`})}),E(`td`,{className:`px-3 py-1.5 text-foreground-subtle`,children:t.locations.join(`, `)}),E(`td`,{className:`px-3 py-1.5 text-foreground text-right tabular-nums`,children:W(t.sizeBytes)}),E(`td`,{className:`px-3 py-1.5`,children:b(`div`,{className:`flex items-center justify-end gap-1`,children:[b(`button`,{onClick:()=>{g(t)},disabled:m===t.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:text-foreground hover:bg-primary/10 disabled:opacity-50`,title:`Download archive`,children:[m===t.id?E(R,{className:`h-3 w-3 animate-spin`}):E(P,{className:`h-3 w-3`}),`Download`]}),n&&r&&b(`button`,{onClick:()=>r({destinationId:e,archiveId:t.id}),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-primary hover:bg-primary/10`,title:`Restore from this archive`,children:[E(L,{className:`h-3 w-3`}),`Restore`]}),E(`button`,{onClick:()=>{p(t)},disabled:f.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete archive`,children:f.isPending?E(R,{className:`h-3 w-3 animate-spin`}):E(H,{className:`h-3 w-3`})})]})})]},t.id))})]})})}function he(e,t){return`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function Y(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}y();var X=[[`backup`,`listSchedules`]];function ge({onEdit:e,onOpenRestoreWizard:t}){let{data:r,isLoading:i,isError:o}=a(),s=r??[],c=n().data??[],l=x(()=>{let e=new Map;for(let t of c)e.set(t.id,t);return e},[c]),[u,d]=T(null),f=e=>{d(t=>t===e?null:e)};return i?E(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading backup entries…`}):o?E(`div`,{className:`text-xs text-danger`,children:`Failed to load backup entries`}):s.length===0?E(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-8 text-center`,children:E(`p`,{className:`text-xs text-foreground-subtle`,children:`No backup entries yet. Create one to schedule backups across one or more storage locations.`})}):E(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:b(`table`,{className:`w-full text-xs min-w-[820px]`,children:[E(`thead`,{children:b(`tr`,{className:`text-foreground-subtle border-b border-border bg-background/40`,children:[E(`th`,{className:`text-left px-3 py-2 font-medium w-6`}),E(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Entry`}),E(`th`,{className:`text-left px-3 py-2 font-medium w-20`,children:`Enabled`}),E(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Locations`}),E(`th`,{className:`text-left px-3 py-2 font-medium w-24`,children:`Retention`}),E(`th`,{className:`text-left px-3 py-2 font-medium w-48`,children:`Schedule`}),E(`th`,{className:`text-right px-3 py-2 font-medium w-52`,children:`Actions`})]})}),E(`tbody`,{children:s.map(n=>E(_e,{row:n,destById:l,isOpen:u===n.id,onToggle:()=>f(n.id),onEdit:()=>e(n),...t?{onOpenRestoreWizard:t}:{}},n.id))})]})})}function _e({row:e,destById:n,isOpen:i,onToggle:a,onEdit:o,onOpenRestoreWizard:s}){let c=w(),d=t(),f=l({onSuccess:()=>{c.invalidateQueries({queryKey:X})}}),p=r({onSuccess:()=>{c.invalidateQueries({queryKey:X})}}),m=u({onSuccess:()=>{c.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),c.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]})}}),[h,g]=T(String(e.retentionCount));D(()=>{g(String(e.retentionCount))},[e.retentionCount]);let _=x(()=>({id:e.id,label:e.label,cron:e.cron,locationIds:[...e.locationIds],retentionCount:e.retentionCount,...e.dataSources?{dataSources:[...e.dataSources]}:{}}),[e]),y=v(e=>{f.mutate({..._,enabled:e})},[f,_]),S=v(()=>{let t=Number.parseInt(h,10);if(Number.isNaN(t)||t<1){g(String(e.retentionCount));return}t!==e.retentionCount&&f.mutate({..._,enabled:e.enabled,retentionCount:t})},[f,_,h,e.retentionCount,e.enabled]),O=v(()=>{e.locationIds.length!==0&&m.mutate({destinations:[...e.locationIds],...e.dataSources&&e.dataSources.length>0?{locations:[...e.dataSources]}:{},label:e.label,retentionCount:e.retentionCount})},[m,e]),k=v(async()=>{await d({title:`Delete backup entry?`,message:`"${e.label||e.id}" will stop running. Existing archives are kept.`,confirmLabel:`Delete`,variant:`warning`})&&p.mutate({id:e.id})},[d,p,e.id,e.label]),A=e.cron.trim().length>0,j=f.isPending||p.isPending;return b(C,{children:[b(`tr`,{className:`border-t border-border first:border-t-0 hover:bg-primary/5`,children:[E(`td`,{className:`px-2 py-2`,children:E(`button`,{onClick:a,className:`inline-flex items-center justify-center rounded p-1 text-foreground-subtle hover:bg-primary/10 hover:text-foreground`,title:i?`Hide archives`:`Show archives`,children:E(i?re:ie,{className:`h-3.5 w-3.5`})})}),E(`td`,{className:`px-3 py-2`,children:b(`button`,{onClick:o,className:`text-left hover:underline focus:outline-none`,children:[E(`div`,{className:`text-foreground font-medium`,children:e.label||`(unnamed)`}),e.lastRunAt!==void 0&&b(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:[`last run `,new Date(e.lastRunAt).toLocaleString()]})]})}),E(`td`,{className:`px-3 py-2`,children:E(`label`,{className:`inline-flex items-center cursor-pointer`,children:E(`input`,{type:`checkbox`,className:`accent-primary`,checked:e.enabled,disabled:j,onChange:e=>y(e.target.checked)})})}),E(`td`,{className:`px-3 py-2`,children:b(`div`,{className:`flex flex-wrap gap-1`,children:[e.locationIds.length===0&&E(`span`,{className:`text-[11px] text-danger italic`,children:`No locations`}),e.locationIds.map(e=>E(`span`,{className:`inline-flex items-center rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-foreground`,title:e,children:n.get(e)?.displayName??e},e))]})}),E(`td`,{className:`px-3 py-2`,children:E(`input`,{type:`number`,min:1,max:1e3,value:h,disabled:j,onChange:e=>g(e.target.value),onBlur:S,onKeyDown:t=>{t.key===`Enter`&&t.target.blur(),t.key===`Escape`&&g(String(e.retentionCount))},className:`w-16 rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})}),E(`td`,{className:`px-3 py-2`,children:b(`button`,{onClick:o,className:`group flex flex-col items-start gap-0.5 text-left`,title:`Edit schedule`,children:[b(`span`,{className:`inline-flex items-center gap-1`,children:[E(oe,{className:`h-3 w-3 text-foreground-subtle group-hover:text-foreground`}),E(`span`,{className:`font-mono text-[11px] text-foreground`,children:A?e.cron:`Manual`})]}),A&&e.nextRunAt!==void 0&&b(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`next `,new Date(e.nextRunAt).toLocaleString()]})]})}),E(`td`,{className:`px-3 py-2`,children:b(`div`,{className:`flex items-center justify-end gap-1.5`,children:[b(`button`,{onClick:O,disabled:m.isPending||e.locationIds.length===0,className:`inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,title:`Run this entry now`,children:[m.isPending?E(R,{className:`h-3 w-3 animate-spin`}):E(I,{className:`h-3 w-3`}),`Run now`]}),E(`button`,{onClick:o,className:`inline-flex items-center justify-center rounded border border-border p-1 text-foreground-subtle hover:text-foreground hover:bg-primary/5`,title:`Edit entry`,children:E(F,{className:`h-3 w-3`})}),E(`button`,{onClick:()=>{k()},disabled:j,className:`inline-flex items-center justify-center rounded border border-border p-1 text-foreground-subtle hover:text-danger hover:border-danger/40 disabled:opacity-50`,title:`Delete entry`,children:E(H,{className:`h-3 w-3`})})]})})]}),i&&E(`tr`,{className:`border-t border-border bg-background/30`,children:b(`td`,{colSpan:7,className:`px-4 py-3 space-y-4`,children:[e.locationIds.length===0&&E(`p`,{className:`text-xs text-foreground-subtle italic`,children:`This entry has no locations selected.`}),e.locationIds.map(e=>b(`div`,{className:`space-y-1.5`,children:[E(`div`,{className:`text-[11px] font-medium text-foreground-subtle`,children:n.get(e)?.displayName??e}),E(me,{destinationId:e,restoreSupported:n.get(e)?.restoreSupported??!0,...s?{onOpenRestoreWizard:s}:{}})]},e))]})})]})}y();var Z=[{id:`manual`,label:`Manual only`,cron:``},{id:`hourly`,label:`Every hour`,cron:`0 * * * *`,description:`On the hour`},{id:`every-3h`,label:`Every 3 hours`,cron:`0 */3 * * *`,description:`00:00, 03:00, 06:00, 09:00 …`},{id:`every-6h`,label:`Every 6 hours`,cron:`0 */6 * * *`,description:`00:00, 06:00, 12:00, 18:00`},{id:`daily-3am`,label:`Daily at 03:00`,cron:`0 3 * * *`,description:`Every night at 3 AM`},{id:`weekly-sun`,label:`Weekly Sunday 03:00`,cron:`0 3 * * 0`,description:`Sunday morning at 3 AM`}];function ve(e){let t=e.trim();for(let e of Z)if(e.cron===t)return e.id;return`custom`}function ye({value:e,onChange:t,previewCount:n=5,disabled:r=!1}){let i=ve(e),[a,o]=T(i===`custom`);D(()=>{i!==`custom`&&o(!1)},[i]);let s=Se(e,250),c=g({cron:s,count:n},{enabled:s.trim().length>0}),l=c.data??null,u=e=>{o(!1),t(e.cron)},d=a||i===`custom`;return b(`div`,{className:`space-y-3`,children:[b(`div`,{className:`space-y-1`,children:[E(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Schedule preset`}),b(`div`,{className:`flex flex-wrap gap-1.5`,children:[Z.map(e=>E(`button`,{type:`button`,onClick:()=>u(e),disabled:r,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(!a&&i===e.id?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),title:e.description??e.label,children:e.label},e.id)),E(`button`,{type:`button`,onClick:()=>{o(!0),e.trim().length===0&&t(`0 3 * * *`)},disabled:r,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(d?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),children:`Custom…`})]})]}),d&&b(`div`,{className:`space-y-1`,children:[E(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Cron expression (5-field POSIX)`}),E(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),disabled:r,placeholder:`0 3 * * *`,spellCheck:!1,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`}),b(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Format: `,E(`span`,{className:`font-mono`,children:`minute hour day-of-month month day-of-week`}),` · all times server-local`]})]}),E(be,{cron:s,preview:l,loading:c.isFetching})]})}function be({cron:e,preview:t,loading:n}){return n&&t===null?b(`div`,{className:`flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:[E(R,{className:`h-3 w-3 animate-spin`}),`Validating…`]}):t===null?null:t.ok?t.nextRuns.length===0?E(`div`,{className:`rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:`No future runs match this expression.`}):b(`div`,{className:`space-y-1`,children:[E(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Next runs`}),E(`ul`,{className:`rounded border border-border bg-background/40 divide-y divide-border`,children:t.nextRuns.map((e,t)=>b(`li`,{className:`flex items-center justify-between px-3 py-1.5 text-[11px]`,children:[E(`span`,{className:`text-foreground tabular-nums`,children:new Date(e).toLocaleString()}),E(`span`,{className:`text-foreground-subtle text-[10px] tabular-nums`,children:xe(e)})]},`${e}-${t}`))})]}):E(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:t.error??`Invalid cron expression`})}function xe(e){let t=e-Date.now();if(t<=0)return`now`;let n=Math.floor(t/1e3);if(n<60)return`in ${n}s`;let r=Math.floor(n/60);if(r<60)return`in ${r}m`;let i=Math.floor(r/60);return i<24?`in ${i}h`:`in ${Math.floor(i/24)}d`}function Se(e,t){let[n,r]=T(e),i=x(()=>e,[e]);return D(()=>{let e=setTimeout(()=>r(i),t);return()=>clearTimeout(e)},[i,t]),n}y();var Ce=[[`backup`,`listSchedules`]];function we({entry:e,onClose:t,onSaved:r}){let i=w(),a=n(),o=a.data??[],[s,c]=T(e?.label??``),[u,d]=T(e?.cron??`0 3 * * *`),[f,p]=T(e?.enabled??!0),[m,h]=T(String(e?.retentionCount??7)),[g,_]=T(new Set(e?.locationIds??[])),v=l({onSuccess:()=>{i.invalidateQueries({queryKey:Ce}),r()}}),y=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},S=Number.parseInt(m,10),C=x(()=>s.trim().length>0&&g.size>0&&!Number.isNaN(S)&&S>=1&&S<=1e3,[s,g,S]),D=()=>{C&&v.mutate({...e?{id:e.id}:{},label:s.trim(),cron:u.trim(),enabled:f,locationIds:Array.from(g),retentionCount:S})},O=v.error instanceof Error?v.error.message:null;return E(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:t,children:b(`div`,{className:`w-full max-w-lg rounded-xl border border-border bg-surface shadow-2xl max-h-[90vh] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:[b(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3 sticky top-0 bg-surface`,children:[E(`h2`,{className:`text-sm font-semibold text-foreground`,children:e?`Edit backup entry`:`New backup entry`}),E(`button`,{onClick:t,className:`text-foreground-subtle hover:text-foreground`,children:E(B,{className:`h-4 w-4`})})]}),b(`div`,{className:`p-4 space-y-4`,children:[b(`div`,{className:`space-y-1`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Name`}),E(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`Nightly offsite`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`})]}),b(`div`,{className:`space-y-1.5`,children:[b(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:[`Locations (`,g.size,` selected)`]}),a.isLoading&&b(`div`,{className:`flex items-center gap-2 px-1 py-2 text-xs text-foreground-subtle`,children:[E(R,{className:`h-3.5 w-3.5 animate-spin`}),`Loading locations…`]}),!a.isLoading&&o.length===0&&E(`div`,{className:`rounded border border-border bg-background px-3 py-2 text-xs text-foreground-subtle italic`,children:"No `backups` storage locations configured. Add one in Settings → Storage first."}),o.length>0&&E(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-52 overflow-y-auto`,children:o.map(e=>b(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[b(`div`,{className:`flex items-center gap-2`,children:[E(`input`,{type:`checkbox`,checked:g.has(e.id),onChange:()=>y(e.id),className:`accent-primary`}),E(`span`,{className:`text-foreground`,children:e.displayName})]}),b(`div`,{className:`flex items-center gap-1.5`,children:[E(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-surface border border-border rounded px-1.5 py-0.5`,children:e.kind}),E(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.id})]})]},e.id))})]}),b(`div`,{className:`grid grid-cols-2 gap-3`,children:[b(`div`,{className:`space-y-1`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Retention (archives kept)`}),E(`input`,{type:`number`,min:1,max:1e3,value:m,onChange:e=>h(e.target.value),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`})]}),b(`div`,{className:`space-y-1`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Enabled`}),b(`label`,{className:`inline-flex items-center gap-2 py-1.5 cursor-pointer`,children:[E(`input`,{type:`checkbox`,checked:f,onChange:e=>p(e.target.checked),className:`accent-primary`}),E(`span`,{className:`text-xs text-foreground-subtle`,children:`Run on schedule`})]})]})]}),b(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Schedule`}),E(ye,{value:u,onChange:d,disabled:v.isPending})]}),O&&E(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:O})]}),b(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3 sticky bottom-0 bg-surface`,children:[E(`button`,{onClick:t,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),b(`button`,{onClick:D,disabled:!C||v.isPending,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[v.isPending&&E(R,{className:`h-3.5 w-3.5 animate-spin`}),e?`Save`:`Create entry`]})]})]})})}y();var Te=[[`backup`,`list`]];function Ee({initialDestinationId:e,initialArchiveId:t,onClose:r,onScheduled:a}){let s=w(),[l,u]=T(e&&t?2:1),[d,f]=T(e),[p,m]=T(t),[h,g]=T(new Set),{data:_}=n(),v=_??[],{data:y,isLoading:S}=c({destinationId:d??``},{enabled:!!d}),C=y??[];D(()=>{if(d!==void 0)return;let e=v.filter(e=>e.restoreSupported);e.length===1&&f(e[0].id)},[d,v]);let{data:O}=o({destinationId:d??``,backupId:p??``},{enabled:!!d&&!!p}),k=x(()=>O?.locations??[],[O]);D(()=>{k.length!==0&&g(e=>e.size===0?new Set(k):e)},[k]);let A=i({onSuccess:()=>{s.invalidateQueries({queryKey:Te}),a(),r()}}),j=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},M=!!d&&!!p,N=h.size>0,P=M&&N&&!A.isPending,F=()=>{!d||!p||A.mutate({destinationId:d,backupId:p,locations:[...h]})};return E(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:r,children:b(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[b(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[b(`div`,{className:`space-y-0.5`,children:[E(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Restore Backup`}),b(`p`,{className:`text-xs text-foreground-subtle`,children:[`Step `,l,` of 3 —`,` `,l===1?`pick source`:l===2?`pick locations`:`confirm`]})]}),E(`button`,{onClick:r,className:`text-foreground-subtle hover:text-foreground`,children:E(B,{className:`h-4 w-4`})})]}),l===1&&E(De,{destinations:v,destinationId:d,onPickDestination:e=>{f(e),m(void 0),g(new Set)},archives:C,archivesLoading:S,archiveId:p,onPickArchive:m}),l===2&&E(Oe,{locations:k,picked:h,onToggle:j}),l===3&&E(ke,{destinationName:v.find(e=>e.id===d)?.displayName??d??``,archive:C.find(e=>e.id===p),picked:[...h]}),b(`div`,{className:`flex justify-between gap-2 border-t border-border px-4 py-3`,children:[E(`div`,{children:l>1&&b(`button`,{onClick:()=>u(e=>e===3?2:1),className:`inline-flex items-center gap-1 rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:[E(ne,{className:`h-3 w-3`}),`Back`]})}),b(`div`,{className:`flex items-center gap-2`,children:[E(`button`,{onClick:r,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),l<3?b(`button`,{disabled:l===1&&!M||l===2&&!N,onClick:()=>u(e=>e===1?2:3),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:[`Next`,E(J,{className:`h-3 w-3`})]}):b(`button`,{onClick:F,disabled:!P,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[A.isPending?E(R,{className:`h-3.5 w-3.5 animate-spin`}):E(L,{className:`h-3.5 w-3.5`}),`Schedule Restore`]})]})]})]})})}function De({destinations:e,destinationId:t,onPickDestination:n,archives:r,archivesLoading:i,archiveId:a,onPickArchive:o}){let s=e.filter(e=>e.restoreSupported);return b(`div`,{className:`p-4 space-y-3`,children:[b(`div`,{className:`space-y-1.5`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Destination`}),b(`select`,{value:t??``,onChange:e=>n(e.target.value),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`,children:[E(`option`,{value:``,disabled:!0,children:`Select destination…`}),s.map(e=>b(`option`,{value:e.id,children:[e.displayName,` (`,e.kind,`)`]},e.id))]})]}),b(`div`,{className:`space-y-1.5`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Archive`}),!t&&E(`div`,{className:`text-xs text-foreground-subtle italic`,children:`Pick a destination first.`}),t&&i&&E(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Reading archives…`}),t&&!i&&r.length===0&&E(`div`,{className:`text-xs text-foreground-subtle italic`,children:`No archives available at this destination.`}),t&&r.length>0&&E(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:r.map(e=>{let t=a===e.id;return b(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${t?`bg-primary/10`:`hover:bg-primary/5`}`,children:[b(`div`,{className:`flex items-center gap-2`,children:[E(`input`,{type:`radio`,name:`archive`,checked:t,onChange:()=>o(e.id),className:`accent-primary`}),b(`div`,{children:[E(`div`,{className:`font-medium text-foreground`,children:e.label??e.id}),E(`div`,{className:`text-[10px] text-foreground-subtle`,children:new Date(e.createdAt).toLocaleString()})]})]}),E(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:W(e.sizeBytes)})]},e.id)})})]})]})}function Oe({locations:e,picked:t,onToggle:n}){return e.length===0?E(`div`,{className:`p-4`,children:E(`div`,{className:`text-xs text-foreground-subtle`,children:`Loading archive manifest… If this persists, the archive may predate manifests — restoring will apply everything in the tarball.`})}):b(`div`,{className:`p-4 space-y-3`,children:[E(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:`Selected entries will overwrite live data on the next server restart. Unchecked entries stay current.`}),b(`div`,{className:`space-y-1.5`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Apply`}),E(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:e.map(e=>b(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[E(`input`,{type:`checkbox`,checked:t.has(e),onChange:()=>n(e),className:`accent-primary`}),E(`span`,{className:`font-mono text-foreground`,children:e}),E(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:je(e)})]},e))})]})]})}function ke({destinationName:e,archive:t,picked:n}){return b(`div`,{className:`p-4 space-y-3 text-xs`,children:[E(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-amber-700 dark:text-amber-300`,children:`Restore is applied at next server boot. Active connections will drop when you restart.`}),b(`dl`,{className:`space-y-1.5`,children:[E(Q,{term:`Destination`,value:e}),E(Q,{term:`Archive`,value:t?.label??t?.id??`—`}),t&&E(Q,{term:`Created`,value:`${new Date(t.createdAt).toLocaleString()} · ${W(t.sizeBytes)}`}),E(Q,{term:`Locations`,value:n.length>0?n.join(`, `):`— (full archive)`})]})]})}function Q({term:e,value:t}){return b(`div`,{className:`flex justify-between gap-3`,children:[E(`dt`,{className:`text-foreground-subtle`,children:e}),E(`dd`,{className:`text-foreground font-mono text-right truncate`,children:t})]})}var Ae={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function je(e){return Ae[e]??``}y();function Me(){let n=t(),r=e(),[i,a]=T(null),[o,s]=T(!1),[c,l]=T(!1),[u,d]=T(void 0),f=async()=>{await n({title:`Restart server now?`,message:`Active connections will drop and the apply-backup hook will run before boot.`,confirmLabel:`Restart`,variant:`warning`})&&r.mutate({confirm:!0})};return b(U,{children:[b(`div`,{className:`flex items-center justify-end gap-2 flex-wrap`,children:[b(`button`,{onClick:()=>s(!0),className:`inline-flex items-center gap-1.5 rounded-lg bg-surface border border-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5 hover:border-primary/30`,children:[E(L,{className:`h-3.5 w-3.5`}),`Restore…`]}),b(`button`,{onClick:()=>d(null),className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:[E(te,{className:`h-3.5 w-3.5`}),`New entry`]})]}),c&&E(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs text-amber-700 dark:text-amber-300`,children:b(`div`,{className:`flex items-center justify-between gap-3`,children:[b(`div`,{className:`flex items-center gap-2`,children:[E(L,{className:`h-3.5 w-3.5`}),E(`span`,{children:`Restore scheduled. Restart the server to apply.`})]}),b(`button`,{onClick:()=>{f()},disabled:r.isPending,className:`inline-flex items-center gap-1.5 rounded bg-amber-500/20 px-2 py-1 font-medium text-amber-800 dark:text-amber-200 hover:bg-amber-500/30 disabled:opacity-50`,children:[r.isPending?E(R,{className:`h-3.5 w-3.5 animate-spin`}):E(L,{className:`h-3.5 w-3.5`}),`Restart Now`]})]})}),E(ge,{onEdit:e=>d(e),onOpenRestoreWizard:e=>a(e)}),u!==void 0&&E(we,{entry:u,onClose:()=>d(void 0),onSaved:()=>d(void 0)}),(i||o)&&E(Ee,{...i?{initialDestinationId:i.destinationId,initialArchiveId:i.archiveId}:{},onClose:()=>{a(null),s(!1)},onScheduled:()=>l(!0)})]})}y();var $=5e3,Ne={"winston-logging":`Rotated log files on this node’s disk.`,"console-logging":`stdout / stderr of the node process.`,"loki-logging":`Pushes to a Grafana Loki instance. Off until enabled with a URL.`,"hub-forwarder":`Agent-only — forwards this node’s entries to the hub.`};function Pe(){let e=_({capName:`log-destination`},{refetchInterval:$}),t=d(void 0,{refetchInterval:$}),n=x(()=>K(t.data??[]),[t.data]),r=x(()=>{let e=new Map;for(let n of t.data??[]){let t=n.description,r=n.id;typeof r==`string`&&typeof t==`string`&&t.length>0&&e.set(r,t)}return e},[t.data]);return E(ee,{title:`Logging`,subtitle:`Every registered log destination. Entries are fanned to all enabled destinations at once — enabling one does not disable another. Each destination's own configuration is docked under it.`,pageIcon:V,itemIcon:se,capability:`log-destination`,installButtonLabel:`Add destination`,items:x(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:n.get(e.addonId)??e.addonId,isActive:e.isActive,caption:r.get(e.addonId)??Ne[e.addonId]??``})),[e.data,n,r]),isLoading:e.isLoading,emptyTitle:`No log destinations registered`,emptyDescription:`This should not happen — the console and rotated-file destinations are builtins. If the list is empty, the node is still booting.`,renderStatusBadges:e=>e.caption.length>0?E(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.caption}):null})}function Fe(){return E(`div`,{className:`flex flex-col p-4`,children:E(G,{tabs:[{id:`storage`,label:`Storage`,icon:A,content:E(de,{})},{id:`backup`,label:`Backup`,icon:q,content:E(Me,{})},{id:`logging`,label:`Logging`,icon:V,content:E(Pe,{})}]})})}export{Fe as DataPage};
|
|
1
|
+
import{Et as e,Ga as t,Gt as n,Ht as r,Jt as i,Kt as a,Ut as o,Vt as s,Wt as c,Xt as l,Yt as u,bt as d,fa as f,ga as p,ma as m,pa as h,qt as g,xt as _}from"./src-8VwlAVGW.js";import{I as v,Q as y,S as b,W as x,a as S,b as C,o as w,q as T,x as E,z as D}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{p as O}from"./player-overlays-JTC60qWR.js";import{a as k,i as A,n as j,r as M,t as N}from"./AddLocationWizard-CXk6-CfE.js";import{t as P}from"./download-DyeMq3Lq.js";import{t as F}from"./pencil-D6dSTO0H.js";import{n as I,t as ee}from"./AddonCollectionPage-0nLq2rl-.js";import{t as te}from"./plus-Cr4EV11F.js";import{t as L}from"./rotate-cw-C56kS1wc.js";import{H as ne,I as re,P as ie,S as R,W as z,i as B,m as V,s as H}from"./index-0lydznr9.js";import{t as U}from"./AdminPage-Dq33XE9j.js";import{n as ae}from"./authed-media-XfBD4Ma-.js";import{t as W}from"./format-size-CO9d3C3-.js";import{t as G}from"./AdminTabs-DTfYeQEd.js";import{t as K}from"./addon-display-names-DvSEQty-.js";var q=z(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),J=z(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),oe=z(`calendar-clock`,[[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M17.5 17.5 16 16.3V14`,key:`akvzfd`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),se=z(`file-text`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]);y();var ce=new Set([`recordings`,`recordingsLow`]);function le(e){let t=e.filesTotal===null?``:`/${e.filesTotal}`,n=Math.round(e.bytesMoved/(1024*1024)),r=`${e.entities.join(`+`)}: ${e.filesMoved}${t} files, ${n} MB — ${e.state}`;return e.error?`${r} (${e.error})`:r}function ue({location:e,onClose:t}){let n=O().trpcClient,[r,i]=T(``),[a,o]=T(!0),[s,c]=T(!0),[l,u]=T(null),[d,f]=T(!1),p=S({queryKey:[`storage`,`listLocations`,`relocate`],queryFn:()=>n.storage.listLocations.query({})}),m=x(()=>(p.data??[]).filter(t=>t.id!==e.id&&ce.has(t.type)&&t.config.readOnly!==!0&&t.config.basePath!==e.config.basePath),[p.data,e]),h=S({queryKey:[`relocate`,`jobs`],queryFn:async()=>{let[e,t]=await Promise.all([n.recording.getRelocateStatus.query({}).catch(()=>[]),n.pipelineAnalytics.getMediaRelocateStatus.query({}).catch(()=>[])]);return[...e,...t].sort((e,t)=>t.startedAt-e.startedAt)},refetchInterval:2e3}),g=h.data??[],_=g.some(e=>e.state===`running`);D(()=>{r===``&&m.length>0&&i(m[0].id)},[m,r]);let v=async()=>{if(r!==``){u(null),f(!0);try{a&&await n.recording.relocateFootage.mutate({fromLocationId:e.id,toLocationId:r}),s&&await n.pipelineAnalytics.relocateMedia.mutate({toLocationId:r}),await h.refetch()}catch(e){u(e instanceof Error?e.message:String(e))}finally{f(!1)}}},y=async e=>{try{e.entities.includes(`media`)?await n.pipelineAnalytics.cancelMediaRelocate.mutate({jobId:e.jobId}):await n.recording.cancelRelocate.mutate({jobId:e.jobId}),await h.refetch()}catch{}};return E(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:t,children:b(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[b(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[b(`div`,{className:`space-y-0.5`,children:[b(`h2`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[E(k,{className:`h-3.5 w-3.5`}),`Relocate from `,e.displayName]}),E(`p`,{className:`text-xs text-foreground-subtle`,children:`Throttled background move; safe to re-run — it resumes where it stopped. Mark this location read-only first so nothing new lands here.`})]}),E(`button`,{onClick:t,className:`text-foreground-subtle hover:text-foreground`,children:E(B,{className:`h-4 w-4`})})]}),b(`div`,{className:`p-4 space-y-3`,children:[b(`div`,{className:`space-y-1`,children:[E(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Target location`}),m.length===0?E(`p`,{className:`text-[11px] text-foreground-subtle`,children:`No writable recordings location on a different root to move to.`}):E(`select`,{value:r,onChange:e=>i(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:m.map(e=>b(`option`,{value:e.id,children:[e.displayName,` (`,String(e.config.basePath??e.id),`)`]},e.id))})]}),b(`div`,{className:`space-y-1`,children:[b(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[E(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),className:`accent-primary`}),`Footage (segments + strips)`]}),b(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[E(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked),className:`accent-primary`}),`Event media (crops, thumbnails, snapshots)`]})]}),l&&E(`p`,{className:`text-[11px] text-danger`,children:l}),g.length>0&&E(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:g.slice(0,4).map(e=>b(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5`,children:[E(`span`,{className:`flex-1 truncate text-[11px] text-foreground`,children:le(e)}),e.state===`running`&&E(`button`,{onClick:()=>void y(e),className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground`,children:`Cancel`})]},e.jobId))})]}),b(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3`,children:[E(`button`,{onClick:t,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground`,children:`Close`}),E(`button`,{onClick:()=>void v(),disabled:r===``||d||_||!a&&!s,className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:_?`Running…`:`Start relocation`})]})]})})}y();function de(){let e=w(),n=t(),{data:r,isLoading:i,isError:a}=m({}),o=h(),s=x(()=>o.data??[],[o.data]),[c,l]=T(null),[u,d]=T(null),[g,_]=T(null),v=f({onSuccess:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),y=p({onSuccess:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),S=e=>{e.isDefault||y.mutate({id:e.id,type:e.type,providerId:e.providerId,displayName:e.displayName,config:e.config,isDefault:!0})},C=async e=>{if(e.isDefault){await n({title:`Cannot delete default location`,message:`"${e.displayName}" is the default for type "${e.type}". Mark another location as default first, then delete this one.`,confirmLabel:`OK`,variant:`warning`});return}await n({title:`Delete location "${e.displayName}"?`,message:`This removes the location record. Files on disk are not deleted; the underlying directory or remote path stays untouched.`,confirmLabel:`Delete`,variant:`danger`})&&v.mutate({id:e.id})},D=x(()=>{let e=new Map;for(let t of r??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[r]),O=i||o.isLoading,k=a||o.isError;return b(U,{children:[O&&E(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading locations…`}),k&&E(`div`,{className:`text-xs text-danger`,children:`Failed to load storage locations.`}),!O&&!k&&b(`div`,{className:`space-y-3`,children:[s.length===0&&E(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-[11px] text-foreground-subtle italic`,children:`No storage locations declared by any installed addon.`}),s.map(e=>E(M,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:D.get(e.id)??[],onAdd:e=>l(e),onEdit:e=>d(e),onDelete:e=>{C(e)},onSetDefault:e=>S(e),...e.id===`recordings`||e.id===`recordingsLow`?{onRelocate:e=>_(e)}:{}},e.id))]}),c!==null&&E(N,{initialType:c,onClose:()=>l(null),onCreated:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),l(null)}}),u!==null&&E(j,{location:u,onClose:()=>d(null),onSaved:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),d(null)}}),g&&E(ue,{location:g,onClose:()=>_(null)})]})}y();var fe=[[`backup`,`listDestinations`]],pe=[`backup`,`listArchives`];function me({destinationId:e,restoreSupported:n,onOpenRestoreWizard:r}){let i=w(),a=t(),{data:o,isLoading:l,isError:u}=c({destinationId:e}),d=o??[],f=s({onSuccess:()=>{i.invalidateQueries({queryKey:[[...pe]]}),i.invalidateQueries({queryKey:fe})}}),p=v(async t=>{await a({title:`Delete this archive?`,message:`Permanently deletes "${t.label??t.id}" and frees ${W(t.sizeBytes)}.`,confirmLabel:`Delete`,variant:`danger`})&&f.mutate({destinationId:e,backupId:t.id})},[a,e,f]),[m,h]=T(null),g=v(async t=>{h(t.id);try{let n=await ae(he(e,t.id)),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${t.label??t.id}.tar.gz`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}finally{h(null)}},[e]),_=x(()=>[...d].toSorted((e,t)=>t.createdAt-e.createdAt),[d]);return l?E(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:`Loading archives…`}):u?E(`div`,{className:`text-xs text-danger py-2`,children:`Failed to read manifest for this destination`}):_.length===0?E(`div`,{className:`text-xs text-foreground-subtle italic py-2`,children:`No archives at this destination yet.`}):E(`div`,{className:`rounded border border-border bg-surface overflow-x-auto`,children:b(`table`,{className:`w-full text-xs min-w-[640px]`,children:[E(`thead`,{children:b(`tr`,{className:`text-foreground-subtle bg-background/30`,children:[E(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`When`}),E(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Label`}),E(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Includes`}),E(`th`,{className:`text-right px-3 py-1.5 font-medium`,children:`Size`}),E(`th`,{className:`text-right px-3 py-1.5 font-medium w-52`,children:`Actions`})]})}),E(`tbody`,{children:_.map(t=>b(`tr`,{className:`border-t border-border hover:bg-primary/5`,children:[E(`td`,{className:`px-3 py-1.5 text-foreground tabular-nums`,children:Y(t.createdAt)}),E(`td`,{className:`px-3 py-1.5 text-foreground`,children:t.label??E(`span`,{className:`text-foreground-subtle italic`,children:`—`})}),E(`td`,{className:`px-3 py-1.5 text-foreground-subtle`,children:t.locations.join(`, `)}),E(`td`,{className:`px-3 py-1.5 text-foreground text-right tabular-nums`,children:W(t.sizeBytes)}),E(`td`,{className:`px-3 py-1.5`,children:b(`div`,{className:`flex items-center justify-end gap-1`,children:[b(`button`,{onClick:()=>{g(t)},disabled:m===t.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:text-foreground hover:bg-primary/10 disabled:opacity-50`,title:`Download archive`,children:[m===t.id?E(R,{className:`h-3 w-3 animate-spin`}):E(P,{className:`h-3 w-3`}),`Download`]}),n&&r&&b(`button`,{onClick:()=>r({destinationId:e,archiveId:t.id}),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-primary hover:bg-primary/10`,title:`Restore from this archive`,children:[E(L,{className:`h-3 w-3`}),`Restore`]}),E(`button`,{onClick:()=>{p(t)},disabled:f.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete archive`,children:f.isPending?E(R,{className:`h-3 w-3 animate-spin`}):E(H,{className:`h-3 w-3`})})]})})]},t.id))})]})})}function he(e,t){return`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function Y(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}y();var X=[[`backup`,`listSchedules`]];function ge({onEdit:e,onOpenRestoreWizard:t}){let{data:r,isLoading:i,isError:o}=a(),s=r??[],c=n().data??[],l=x(()=>{let e=new Map;for(let t of c)e.set(t.id,t);return e},[c]),[u,d]=T(null),f=e=>{d(t=>t===e?null:e)};return i?E(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading backup entries…`}):o?E(`div`,{className:`text-xs text-danger`,children:`Failed to load backup entries`}):s.length===0?E(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-8 text-center`,children:E(`p`,{className:`text-xs text-foreground-subtle`,children:`No backup entries yet. Create one to schedule backups across one or more storage locations.`})}):E(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:b(`table`,{className:`w-full text-xs min-w-[820px]`,children:[E(`thead`,{children:b(`tr`,{className:`text-foreground-subtle border-b border-border bg-background/40`,children:[E(`th`,{className:`text-left px-3 py-2 font-medium w-6`}),E(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Entry`}),E(`th`,{className:`text-left px-3 py-2 font-medium w-20`,children:`Enabled`}),E(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Locations`}),E(`th`,{className:`text-left px-3 py-2 font-medium w-24`,children:`Retention`}),E(`th`,{className:`text-left px-3 py-2 font-medium w-48`,children:`Schedule`}),E(`th`,{className:`text-right px-3 py-2 font-medium w-52`,children:`Actions`})]})}),E(`tbody`,{children:s.map(n=>E(_e,{row:n,destById:l,isOpen:u===n.id,onToggle:()=>f(n.id),onEdit:()=>e(n),...t?{onOpenRestoreWizard:t}:{}},n.id))})]})})}function _e({row:e,destById:n,isOpen:i,onToggle:a,onEdit:o,onOpenRestoreWizard:s}){let c=w(),d=t(),f=l({onSuccess:()=>{c.invalidateQueries({queryKey:X})}}),p=r({onSuccess:()=>{c.invalidateQueries({queryKey:X})}}),m=u({onSuccess:()=>{c.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),c.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]})}}),[h,g]=T(String(e.retentionCount));D(()=>{g(String(e.retentionCount))},[e.retentionCount]);let _=x(()=>({id:e.id,label:e.label,cron:e.cron,locationIds:[...e.locationIds],retentionCount:e.retentionCount,...e.dataSources?{dataSources:[...e.dataSources]}:{}}),[e]),y=v(e=>{f.mutate({..._,enabled:e})},[f,_]),S=v(()=>{let t=Number.parseInt(h,10);if(Number.isNaN(t)||t<1){g(String(e.retentionCount));return}t!==e.retentionCount&&f.mutate({..._,enabled:e.enabled,retentionCount:t})},[f,_,h,e.retentionCount,e.enabled]),O=v(()=>{e.locationIds.length!==0&&m.mutate({destinations:[...e.locationIds],...e.dataSources&&e.dataSources.length>0?{locations:[...e.dataSources]}:{},label:e.label,retentionCount:e.retentionCount})},[m,e]),k=v(async()=>{await d({title:`Delete backup entry?`,message:`"${e.label||e.id}" will stop running. Existing archives are kept.`,confirmLabel:`Delete`,variant:`warning`})&&p.mutate({id:e.id})},[d,p,e.id,e.label]),A=e.cron.trim().length>0,j=f.isPending||p.isPending;return b(C,{children:[b(`tr`,{className:`border-t border-border first:border-t-0 hover:bg-primary/5`,children:[E(`td`,{className:`px-2 py-2`,children:E(`button`,{onClick:a,className:`inline-flex items-center justify-center rounded p-1 text-foreground-subtle hover:bg-primary/10 hover:text-foreground`,title:i?`Hide archives`:`Show archives`,children:E(i?re:ie,{className:`h-3.5 w-3.5`})})}),E(`td`,{className:`px-3 py-2`,children:b(`button`,{onClick:o,className:`text-left hover:underline focus:outline-none`,children:[E(`div`,{className:`text-foreground font-medium`,children:e.label||`(unnamed)`}),e.lastRunAt!==void 0&&b(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:[`last run `,new Date(e.lastRunAt).toLocaleString()]})]})}),E(`td`,{className:`px-3 py-2`,children:E(`label`,{className:`inline-flex items-center cursor-pointer`,children:E(`input`,{type:`checkbox`,className:`accent-primary`,checked:e.enabled,disabled:j,onChange:e=>y(e.target.checked)})})}),E(`td`,{className:`px-3 py-2`,children:b(`div`,{className:`flex flex-wrap gap-1`,children:[e.locationIds.length===0&&E(`span`,{className:`text-[11px] text-danger italic`,children:`No locations`}),e.locationIds.map(e=>E(`span`,{className:`inline-flex items-center rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-foreground`,title:e,children:n.get(e)?.displayName??e},e))]})}),E(`td`,{className:`px-3 py-2`,children:E(`input`,{type:`number`,min:1,max:1e3,value:h,disabled:j,onChange:e=>g(e.target.value),onBlur:S,onKeyDown:t=>{t.key===`Enter`&&t.target.blur(),t.key===`Escape`&&g(String(e.retentionCount))},className:`w-16 rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})}),E(`td`,{className:`px-3 py-2`,children:b(`button`,{onClick:o,className:`group flex flex-col items-start gap-0.5 text-left`,title:`Edit schedule`,children:[b(`span`,{className:`inline-flex items-center gap-1`,children:[E(oe,{className:`h-3 w-3 text-foreground-subtle group-hover:text-foreground`}),E(`span`,{className:`font-mono text-[11px] text-foreground`,children:A?e.cron:`Manual`})]}),A&&e.nextRunAt!==void 0&&b(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`next `,new Date(e.nextRunAt).toLocaleString()]})]})}),E(`td`,{className:`px-3 py-2`,children:b(`div`,{className:`flex items-center justify-end gap-1.5`,children:[b(`button`,{onClick:O,disabled:m.isPending||e.locationIds.length===0,className:`inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,title:`Run this entry now`,children:[m.isPending?E(R,{className:`h-3 w-3 animate-spin`}):E(I,{className:`h-3 w-3`}),`Run now`]}),E(`button`,{onClick:o,className:`inline-flex items-center justify-center rounded border border-border p-1 text-foreground-subtle hover:text-foreground hover:bg-primary/5`,title:`Edit entry`,children:E(F,{className:`h-3 w-3`})}),E(`button`,{onClick:()=>{k()},disabled:j,className:`inline-flex items-center justify-center rounded border border-border p-1 text-foreground-subtle hover:text-danger hover:border-danger/40 disabled:opacity-50`,title:`Delete entry`,children:E(H,{className:`h-3 w-3`})})]})})]}),i&&E(`tr`,{className:`border-t border-border bg-background/30`,children:b(`td`,{colSpan:7,className:`px-4 py-3 space-y-4`,children:[e.locationIds.length===0&&E(`p`,{className:`text-xs text-foreground-subtle italic`,children:`This entry has no locations selected.`}),e.locationIds.map(e=>b(`div`,{className:`space-y-1.5`,children:[E(`div`,{className:`text-[11px] font-medium text-foreground-subtle`,children:n.get(e)?.displayName??e}),E(me,{destinationId:e,restoreSupported:n.get(e)?.restoreSupported??!0,...s?{onOpenRestoreWizard:s}:{}})]},e))]})})]})}y();var Z=[{id:`manual`,label:`Manual only`,cron:``},{id:`hourly`,label:`Every hour`,cron:`0 * * * *`,description:`On the hour`},{id:`every-3h`,label:`Every 3 hours`,cron:`0 */3 * * *`,description:`00:00, 03:00, 06:00, 09:00 …`},{id:`every-6h`,label:`Every 6 hours`,cron:`0 */6 * * *`,description:`00:00, 06:00, 12:00, 18:00`},{id:`daily-3am`,label:`Daily at 03:00`,cron:`0 3 * * *`,description:`Every night at 3 AM`},{id:`weekly-sun`,label:`Weekly Sunday 03:00`,cron:`0 3 * * 0`,description:`Sunday morning at 3 AM`}];function ve(e){let t=e.trim();for(let e of Z)if(e.cron===t)return e.id;return`custom`}function ye({value:e,onChange:t,previewCount:n=5,disabled:r=!1}){let i=ve(e),[a,o]=T(i===`custom`);D(()=>{i!==`custom`&&o(!1)},[i]);let s=Se(e,250),c=g({cron:s,count:n},{enabled:s.trim().length>0}),l=c.data??null,u=e=>{o(!1),t(e.cron)},d=a||i===`custom`;return b(`div`,{className:`space-y-3`,children:[b(`div`,{className:`space-y-1`,children:[E(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Schedule preset`}),b(`div`,{className:`flex flex-wrap gap-1.5`,children:[Z.map(e=>E(`button`,{type:`button`,onClick:()=>u(e),disabled:r,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(!a&&i===e.id?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),title:e.description??e.label,children:e.label},e.id)),E(`button`,{type:`button`,onClick:()=>{o(!0),e.trim().length===0&&t(`0 3 * * *`)},disabled:r,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(d?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),children:`Custom…`})]})]}),d&&b(`div`,{className:`space-y-1`,children:[E(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Cron expression (5-field POSIX)`}),E(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),disabled:r,placeholder:`0 3 * * *`,spellCheck:!1,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`}),b(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Format: `,E(`span`,{className:`font-mono`,children:`minute hour day-of-month month day-of-week`}),` · all times server-local`]})]}),E(be,{cron:s,preview:l,loading:c.isFetching})]})}function be({cron:e,preview:t,loading:n}){return n&&t===null?b(`div`,{className:`flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:[E(R,{className:`h-3 w-3 animate-spin`}),`Validating…`]}):t===null?null:t.ok?t.nextRuns.length===0?E(`div`,{className:`rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:`No future runs match this expression.`}):b(`div`,{className:`space-y-1`,children:[E(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Next runs`}),E(`ul`,{className:`rounded border border-border bg-background/40 divide-y divide-border`,children:t.nextRuns.map((e,t)=>b(`li`,{className:`flex items-center justify-between px-3 py-1.5 text-[11px]`,children:[E(`span`,{className:`text-foreground tabular-nums`,children:new Date(e).toLocaleString()}),E(`span`,{className:`text-foreground-subtle text-[10px] tabular-nums`,children:xe(e)})]},`${e}-${t}`))})]}):E(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:t.error??`Invalid cron expression`})}function xe(e){let t=e-Date.now();if(t<=0)return`now`;let n=Math.floor(t/1e3);if(n<60)return`in ${n}s`;let r=Math.floor(n/60);if(r<60)return`in ${r}m`;let i=Math.floor(r/60);return i<24?`in ${i}h`:`in ${Math.floor(i/24)}d`}function Se(e,t){let[n,r]=T(e),i=x(()=>e,[e]);return D(()=>{let e=setTimeout(()=>r(i),t);return()=>clearTimeout(e)},[i,t]),n}y();var Ce=[[`backup`,`listSchedules`]];function we({entry:e,onClose:t,onSaved:r}){let i=w(),a=n(),o=a.data??[],[s,c]=T(e?.label??``),[u,d]=T(e?.cron??`0 3 * * *`),[f,p]=T(e?.enabled??!0),[m,h]=T(String(e?.retentionCount??7)),[g,_]=T(new Set(e?.locationIds??[])),v=l({onSuccess:()=>{i.invalidateQueries({queryKey:Ce}),r()}}),y=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},S=Number.parseInt(m,10),C=x(()=>s.trim().length>0&&g.size>0&&!Number.isNaN(S)&&S>=1&&S<=1e3,[s,g,S]),D=()=>{C&&v.mutate({...e?{id:e.id}:{},label:s.trim(),cron:u.trim(),enabled:f,locationIds:Array.from(g),retentionCount:S})},O=v.error instanceof Error?v.error.message:null;return E(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:t,children:b(`div`,{className:`w-full max-w-lg rounded-xl border border-border bg-surface shadow-2xl max-h-[90vh] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:[b(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3 sticky top-0 bg-surface`,children:[E(`h2`,{className:`text-sm font-semibold text-foreground`,children:e?`Edit backup entry`:`New backup entry`}),E(`button`,{onClick:t,className:`text-foreground-subtle hover:text-foreground`,children:E(B,{className:`h-4 w-4`})})]}),b(`div`,{className:`p-4 space-y-4`,children:[b(`div`,{className:`space-y-1`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Name`}),E(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`Nightly offsite`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`})]}),b(`div`,{className:`space-y-1.5`,children:[b(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:[`Locations (`,g.size,` selected)`]}),a.isLoading&&b(`div`,{className:`flex items-center gap-2 px-1 py-2 text-xs text-foreground-subtle`,children:[E(R,{className:`h-3.5 w-3.5 animate-spin`}),`Loading locations…`]}),!a.isLoading&&o.length===0&&E(`div`,{className:`rounded border border-border bg-background px-3 py-2 text-xs text-foreground-subtle italic`,children:"No `backups` storage locations configured. Add one in Settings → Storage first."}),o.length>0&&E(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-52 overflow-y-auto`,children:o.map(e=>b(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[b(`div`,{className:`flex items-center gap-2`,children:[E(`input`,{type:`checkbox`,checked:g.has(e.id),onChange:()=>y(e.id),className:`accent-primary`}),E(`span`,{className:`text-foreground`,children:e.displayName})]}),b(`div`,{className:`flex items-center gap-1.5`,children:[E(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-surface border border-border rounded px-1.5 py-0.5`,children:e.kind}),E(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.id})]})]},e.id))})]}),b(`div`,{className:`grid grid-cols-2 gap-3`,children:[b(`div`,{className:`space-y-1`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Retention (archives kept)`}),E(`input`,{type:`number`,min:1,max:1e3,value:m,onChange:e=>h(e.target.value),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`})]}),b(`div`,{className:`space-y-1`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Enabled`}),b(`label`,{className:`inline-flex items-center gap-2 py-1.5 cursor-pointer`,children:[E(`input`,{type:`checkbox`,checked:f,onChange:e=>p(e.target.checked),className:`accent-primary`}),E(`span`,{className:`text-xs text-foreground-subtle`,children:`Run on schedule`})]})]})]}),b(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Schedule`}),E(ye,{value:u,onChange:d,disabled:v.isPending})]}),O&&E(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:O})]}),b(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3 sticky bottom-0 bg-surface`,children:[E(`button`,{onClick:t,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),b(`button`,{onClick:D,disabled:!C||v.isPending,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[v.isPending&&E(R,{className:`h-3.5 w-3.5 animate-spin`}),e?`Save`:`Create entry`]})]})]})})}y();var Te=[[`backup`,`list`]];function Ee({initialDestinationId:e,initialArchiveId:t,onClose:r,onScheduled:a}){let s=w(),[l,u]=T(e&&t?2:1),[d,f]=T(e),[p,m]=T(t),[h,g]=T(new Set),{data:_}=n(),v=_??[],{data:y,isLoading:S}=c({destinationId:d??``},{enabled:!!d}),C=y??[];D(()=>{if(d!==void 0)return;let e=v.filter(e=>e.restoreSupported);e.length===1&&f(e[0].id)},[d,v]);let{data:O}=o({destinationId:d??``,backupId:p??``},{enabled:!!d&&!!p}),k=x(()=>O?.locations??[],[O]);D(()=>{k.length!==0&&g(e=>e.size===0?new Set(k):e)},[k]);let A=i({onSuccess:()=>{s.invalidateQueries({queryKey:Te}),a(),r()}}),j=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},M=!!d&&!!p,N=h.size>0,P=M&&N&&!A.isPending,F=()=>{!d||!p||A.mutate({destinationId:d,backupId:p,locations:[...h]})};return E(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:r,children:b(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[b(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[b(`div`,{className:`space-y-0.5`,children:[E(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Restore Backup`}),b(`p`,{className:`text-xs text-foreground-subtle`,children:[`Step `,l,` of 3 —`,` `,l===1?`pick source`:l===2?`pick locations`:`confirm`]})]}),E(`button`,{onClick:r,className:`text-foreground-subtle hover:text-foreground`,children:E(B,{className:`h-4 w-4`})})]}),l===1&&E(De,{destinations:v,destinationId:d,onPickDestination:e=>{f(e),m(void 0),g(new Set)},archives:C,archivesLoading:S,archiveId:p,onPickArchive:m}),l===2&&E(Oe,{locations:k,picked:h,onToggle:j}),l===3&&E(ke,{destinationName:v.find(e=>e.id===d)?.displayName??d??``,archive:C.find(e=>e.id===p),picked:[...h]}),b(`div`,{className:`flex justify-between gap-2 border-t border-border px-4 py-3`,children:[E(`div`,{children:l>1&&b(`button`,{onClick:()=>u(e=>e===3?2:1),className:`inline-flex items-center gap-1 rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:[E(ne,{className:`h-3 w-3`}),`Back`]})}),b(`div`,{className:`flex items-center gap-2`,children:[E(`button`,{onClick:r,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),l<3?b(`button`,{disabled:l===1&&!M||l===2&&!N,onClick:()=>u(e=>e===1?2:3),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:[`Next`,E(J,{className:`h-3 w-3`})]}):b(`button`,{onClick:F,disabled:!P,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[A.isPending?E(R,{className:`h-3.5 w-3.5 animate-spin`}):E(L,{className:`h-3.5 w-3.5`}),`Schedule Restore`]})]})]})]})})}function De({destinations:e,destinationId:t,onPickDestination:n,archives:r,archivesLoading:i,archiveId:a,onPickArchive:o}){let s=e.filter(e=>e.restoreSupported);return b(`div`,{className:`p-4 space-y-3`,children:[b(`div`,{className:`space-y-1.5`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Destination`}),b(`select`,{value:t??``,onChange:e=>n(e.target.value),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`,children:[E(`option`,{value:``,disabled:!0,children:`Select destination…`}),s.map(e=>b(`option`,{value:e.id,children:[e.displayName,` (`,e.kind,`)`]},e.id))]})]}),b(`div`,{className:`space-y-1.5`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Archive`}),!t&&E(`div`,{className:`text-xs text-foreground-subtle italic`,children:`Pick a destination first.`}),t&&i&&E(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Reading archives…`}),t&&!i&&r.length===0&&E(`div`,{className:`text-xs text-foreground-subtle italic`,children:`No archives available at this destination.`}),t&&r.length>0&&E(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:r.map(e=>{let t=a===e.id;return b(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${t?`bg-primary/10`:`hover:bg-primary/5`}`,children:[b(`div`,{className:`flex items-center gap-2`,children:[E(`input`,{type:`radio`,name:`archive`,checked:t,onChange:()=>o(e.id),className:`accent-primary`}),b(`div`,{children:[E(`div`,{className:`font-medium text-foreground`,children:e.label??e.id}),E(`div`,{className:`text-[10px] text-foreground-subtle`,children:new Date(e.createdAt).toLocaleString()})]})]}),E(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:W(e.sizeBytes)})]},e.id)})})]})]})}function Oe({locations:e,picked:t,onToggle:n}){return e.length===0?E(`div`,{className:`p-4`,children:E(`div`,{className:`text-xs text-foreground-subtle`,children:`Loading archive manifest… If this persists, the archive may predate manifests — restoring will apply everything in the tarball.`})}):b(`div`,{className:`p-4 space-y-3`,children:[E(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:`Selected entries will overwrite live data on the next server restart. Unchecked entries stay current.`}),b(`div`,{className:`space-y-1.5`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Apply`}),E(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:e.map(e=>b(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[E(`input`,{type:`checkbox`,checked:t.has(e),onChange:()=>n(e),className:`accent-primary`}),E(`span`,{className:`font-mono text-foreground`,children:e}),E(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:je(e)})]},e))})]})]})}function ke({destinationName:e,archive:t,picked:n}){return b(`div`,{className:`p-4 space-y-3 text-xs`,children:[E(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-amber-700 dark:text-amber-300`,children:`Restore is applied at next server boot. Active connections will drop when you restart.`}),b(`dl`,{className:`space-y-1.5`,children:[E(Q,{term:`Destination`,value:e}),E(Q,{term:`Archive`,value:t?.label??t?.id??`—`}),t&&E(Q,{term:`Created`,value:`${new Date(t.createdAt).toLocaleString()} · ${W(t.sizeBytes)}`}),E(Q,{term:`Locations`,value:n.length>0?n.join(`, `):`— (full archive)`})]})]})}function Q({term:e,value:t}){return b(`div`,{className:`flex justify-between gap-3`,children:[E(`dt`,{className:`text-foreground-subtle`,children:e}),E(`dd`,{className:`text-foreground font-mono text-right truncate`,children:t})]})}var Ae={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function je(e){return Ae[e]??``}y();function Me(){let n=t(),r=e(),[i,a]=T(null),[o,s]=T(!1),[c,l]=T(!1),[u,d]=T(void 0),f=async()=>{await n({title:`Restart server now?`,message:`Active connections will drop and the apply-backup hook will run before boot.`,confirmLabel:`Restart`,variant:`warning`})&&r.mutate({confirm:!0})};return b(U,{children:[b(`div`,{className:`flex items-center justify-end gap-2 flex-wrap`,children:[b(`button`,{onClick:()=>s(!0),className:`inline-flex items-center gap-1.5 rounded-lg bg-surface border border-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5 hover:border-primary/30`,children:[E(L,{className:`h-3.5 w-3.5`}),`Restore…`]}),b(`button`,{onClick:()=>d(null),className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:[E(te,{className:`h-3.5 w-3.5`}),`New entry`]})]}),c&&E(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs text-amber-700 dark:text-amber-300`,children:b(`div`,{className:`flex items-center justify-between gap-3`,children:[b(`div`,{className:`flex items-center gap-2`,children:[E(L,{className:`h-3.5 w-3.5`}),E(`span`,{children:`Restore scheduled. Restart the server to apply.`})]}),b(`button`,{onClick:()=>{f()},disabled:r.isPending,className:`inline-flex items-center gap-1.5 rounded bg-amber-500/20 px-2 py-1 font-medium text-amber-800 dark:text-amber-200 hover:bg-amber-500/30 disabled:opacity-50`,children:[r.isPending?E(R,{className:`h-3.5 w-3.5 animate-spin`}):E(L,{className:`h-3.5 w-3.5`}),`Restart Now`]})]})}),E(ge,{onEdit:e=>d(e),onOpenRestoreWizard:e=>a(e)}),u!==void 0&&E(we,{entry:u,onClose:()=>d(void 0),onSaved:()=>d(void 0)}),(i||o)&&E(Ee,{...i?{initialDestinationId:i.destinationId,initialArchiveId:i.archiveId}:{},onClose:()=>{a(null),s(!1)},onScheduled:()=>l(!0)})]})}y();var $=5e3,Ne={"winston-logging":`Rotated log files on this node’s disk.`,"console-logging":`stdout / stderr of the node process.`,"loki-logging":`Pushes to a Grafana Loki instance. Off until enabled with a URL.`,"hub-forwarder":`Agent-only — forwards this node’s entries to the hub.`};function Pe(){let e=_({capName:`log-destination`},{refetchInterval:$}),t=d(void 0,{refetchInterval:$}),n=x(()=>K(t.data??[]),[t.data]),r=x(()=>{let e=new Map;for(let n of t.data??[]){let t=n.description,r=n.id;typeof r==`string`&&typeof t==`string`&&t.length>0&&e.set(r,t)}return e},[t.data]);return E(ee,{title:`Logging`,subtitle:`Every registered log destination. Entries are fanned to all enabled destinations at once — enabling one does not disable another. Each destination's own configuration is docked under it.`,pageIcon:V,itemIcon:se,capability:`log-destination`,installButtonLabel:`Add destination`,items:x(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:n.get(e.addonId)??e.addonId,isActive:e.isActive,caption:r.get(e.addonId)??Ne[e.addonId]??``})),[e.data,n,r]),isLoading:e.isLoading,emptyTitle:`No log destinations registered`,emptyDescription:`This should not happen — the console and rotated-file destinations are builtins. If the list is empty, the node is still booting.`,renderStatusBadges:e=>e.caption.length>0?E(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.caption}):null})}function Fe(){return E(`div`,{className:`flex flex-col p-4`,children:E(G,{tabs:[{id:`storage`,label:`Storage`,icon:A,content:E(de,{})},{id:`backup`,label:`Backup`,icon:q,content:E(Me,{})},{id:`logging`,label:`Logging`,icon:V,content:E(Pe,{})}]})})}export{Fe as DataPage};
|