@camstack/addon-admin-ui 1.1.50 → 1.1.51
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-CIqEDdCn.js → AddLocationWizard-C5_TbCTT.js} +1 -1
- package/dist/assets/{AddonCollectionPage-oYV5gLkL.js → AddonCollectionPage-DdcqJdFw.js} +1 -1
- package/dist/assets/Addons-DENvhGXs.js +1 -0
- package/dist/assets/{AdminTabs-BeF-jlOp.js → AdminTabs-rrSAZD3O.js} +1 -1
- package/dist/assets/AiProfiles-I6sx_kzO.js +1 -0
- package/dist/assets/{BrokerForm-CKF91l2P.js → BrokerForm-DL1TXr2B.js} +1 -1
- package/dist/assets/{Capabilities-DjYa3mVl.js → Capabilities-G9KINvPO.js} +1 -1
- package/dist/assets/CapabilityBadges-Q2qm_QNP.js +1 -0
- package/dist/assets/Cluster-D5fOIpSM.js +1 -0
- package/dist/assets/{Dashboard-B7W-1CPO.js → Dashboard-B9Qq3GKN.js} +1 -1
- package/dist/assets/Data-F4Z7wulI.js +1 -0
- package/dist/assets/DetectionIntelligence-DysJUSVa.js +1 -0
- package/dist/assets/DeviceDetail-DnOzyoSG.js +2 -0
- package/dist/assets/{Devices-DY58j8Im.js → Devices-BbPVwY-D.js} +1 -1
- package/dist/assets/EmbedPlayerPage-DDKRlZMR.js +1 -0
- package/dist/assets/Events-CdArV4tl.js +1 -0
- package/dist/assets/{FormBuilder-DF9HdVVE.js → FormBuilder-vCzPEjPM.js} +1 -1
- package/dist/assets/Identity-Dmu7k7pC.js +1 -0
- package/dist/assets/IntegrationDetail-CXnSPpKp.js +1 -0
- package/dist/assets/{Integrations-Cwy28tRf.js → Integrations-AlnqolAL.js} +1 -1
- package/dist/assets/Integrations-BIx0NuFX.js +1 -0
- package/dist/assets/{Logs-CH6InwRa.js → Logs-CBDPfk6Z.js} +1 -1
- package/dist/assets/{MotionZonesSettings-wgT8qNCk.js → MotionZonesSettings-CFYI6s-_.js} +1 -1
- package/dist/assets/{MyAccess-pia6abG8.js → MyAccess-6qmJkzue.js} +1 -1
- package/dist/assets/Network-CX6T3X7F.js +1 -0
- package/dist/assets/{NodeAddonsSettingsPanel-21ajRiKU.js → NodeAddonsSettingsPanel-CynxbOEk.js} +1 -1
- package/dist/assets/NotificationTargets-DFmIRZfI.js +1 -0
- package/dist/assets/Pipeline-HtfEITUn.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-aoGQ9CVn.js → PrivacyMaskSettings-CbVO58Pz.js} +1 -1
- package/dist/assets/{ProviderIcon-B00C6yVI.js → ProviderIcon-Bc8wWWqT.js} +1 -1
- package/dist/assets/{ScanNetworkModal-DTAMAK8z.js → ScanNetworkModal-Bxjqv5aL.js} +1 -1
- package/dist/assets/{ServerManagement-B0UENejd.js → ServerManagement-QTJJqUUL.js} +1 -1
- package/dist/assets/{Settings-CyUdtPyP.js → Settings-DdHS4and.js} +1 -1
- package/dist/assets/{Showroom-DqNnYNbB.js → Showroom-BPudQyp1.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DcgCF70N.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DzuuqQDr.js} +1 -1
- package/dist/assets/authed-media-XfBD4Ma-.js +1 -0
- package/dist/assets/{build-cluster-graph-DLb-k44M.js → build-cluster-graph-C8acdV1N.js} +2 -2
- package/dist/assets/circle-check-big-Ci2qKS9O.js +1 -0
- package/dist/assets/clock-DvPVZaz2.js +1 -0
- package/dist/assets/{copy-PDaNKoDE.js → copy-jHaoig1Z.js} +1 -1
- package/dist/assets/debounced-invalidate-BtUOLpbU.js +1 -0
- package/dist/assets/dist-BpbjPYkI.js +7 -0
- package/dist/assets/{dist-D248MGg1.js → dist-D9oUwgkq.js} +1 -1
- package/dist/assets/{download-iZu8ddva.js → download-B8Uv2BOb.js} +1 -1
- package/dist/assets/film-CzfyiWOL.js +1 -0
- package/dist/assets/{hostInit-DT-Sx4uZ.js → hostInit-DY1mt8Vv.js} +1 -1
- package/dist/assets/index-CRBZZNxE.css +2 -0
- package/dist/assets/index-msAq9OfF.js +4 -0
- package/dist/assets/{key-round-xzAl99gK.js → key-round-B1u42XSy.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-c91235d9.js → mf-entry-bootstrap-0-3bf5f308.js} +2 -2
- package/dist/assets/{pencil-DL1TJsTc.js → pencil-BEjUgvtJ.js} +1 -1
- package/dist/assets/{player-overlays-D3fMTMSy.js → player-overlays-DzoWZHnz.js} +1 -1
- package/dist/assets/plus-CDCmEkS2.js +1 -0
- package/dist/assets/{radio-Cidrh6lI.js → radio-CvK77vEM.js} +1 -1
- package/dist/assets/{refresh-cw-CQ8ZPCKP.js → refresh-cw-BoM3__QD.js} +1 -1
- package/dist/assets/remoteEntry-Bm4uDKFt.js +1 -0
- package/dist/assets/{rotate-ccw-CdNSKqrT.js → rotate-ccw-CG8Dl-0A.js} +1 -1
- package/dist/assets/rotate-cw-BcZwqoT5.js +1 -0
- package/dist/assets/{schemas-CuE8EXQ7.js → schemas-DSTjX9zr.js} +4 -4
- package/dist/assets/search-Dh7U_-43.js +1 -0
- package/dist/assets/send-DdbXLRkn.js +1 -0
- package/dist/assets/square-Mc9QW6dp.js +1 -0
- package/dist/assets/{square-check-big-DHo5VpxB.js → square-check-big-BIo_99Ss.js} +1 -1
- package/dist/assets/src-B_-PRq3y.js +67 -0
- package/dist/assets/src-DYmw2iAG.js +7 -0
- package/dist/assets/{upload-CbQEsRc1.js → upload-DUlWrtL9.js} +1 -1
- package/dist/assets/{useDevice-BIRPCUj3.js → useDevice-CDxSSKpG.js} +1 -1
- package/dist/assets/{useEventInvalidation-dY_jfjb6.js → useEventInvalidation-Bwynn5Fd.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-B65PZoVz.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CmeeGMkM.js} +2 -2
- package/dist/assets/{wifi-CXcT5hFl.js → wifi-CW0cSDNa.js} +1 -1
- package/dist/assets/{zap-IxXrBEjL.js → zap-CPf6Bdf3.js} +1 -1
- package/dist/index.html +7 -7
- package/dist/server/addon.js +943 -39
- package/package.json +2 -1
- package/dist/assets/Addons-DXHAaRyv.js +0 -1
- package/dist/assets/CapabilityBadges-Ch3OxAx_.js +0 -1
- package/dist/assets/Cluster-B0VcGezF.js +0 -1
- package/dist/assets/Data-DTdFNsIK.js +0 -1
- package/dist/assets/DetectionIntelligence-Dlqt7Nfw.js +0 -1
- package/dist/assets/DeviceDetail-BoyqcoSb.js +0 -2
- package/dist/assets/EmbedPlayerPage-7fAe8VOM.js +0 -1
- package/dist/assets/Identity-CcxXGRs-.js +0 -1
- package/dist/assets/IntegrationDetail-3unRfrYT.js +0 -1
- package/dist/assets/Integrations-VffZ4PwO.js +0 -1
- package/dist/assets/Network-Cs7w2ldQ.js +0 -1
- package/dist/assets/NotificationTargets-BPToXpbO.js +0 -1
- package/dist/assets/Pipeline-D9UHFkhz.js +0 -1
- package/dist/assets/circle-check-big-B3D63yK2.js +0 -1
- package/dist/assets/dist-DK5byzu0.js +0 -7
- package/dist/assets/index-BFJ6KO0x.css +0 -2
- package/dist/assets/index-pSZYK5ny.js +0 -4
- package/dist/assets/plus-CRDyDYzj.js +0 -1
- package/dist/assets/remoteEntry-CMix6vvq.js +0 -1
- package/dist/assets/rotate-cw-DR-mTm0L.js +0 -1
- package/dist/assets/search-M9sg9sgJ.js +0 -1
- package/dist/assets/sparkles-Uqh90jkF.js +0 -1
- package/dist/assets/square-DeI3vDTo.js +0 -1
- package/dist/assets/src-B45-uhaF.js +0 -7
- package/dist/assets/src-DUz15ij3.js +0 -67
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-admin-ui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.51",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "CamStack Admin UI — Vite frontend build and server-side addon",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"@camstack/sdk": "*",
|
|
49
49
|
"@camstack/ui-library": "*",
|
|
50
50
|
"@module-federation/runtime": "^2.4.0",
|
|
51
|
+
"@simplewebauthn/browser": "11.0.0",
|
|
51
52
|
"@tanstack/react-query": "^5.90.0",
|
|
52
53
|
"@trpc/client": "^11.16.0",
|
|
53
54
|
"@trpc/react-query": "^11.16.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{At as e,Et as t,Lr as n,Ot as r,St as i,Tt as a,_t as o,bt as s,dt as c,ft as l,g as u,gt as ee,ht as d,ia as f,jr as p,kt as m,m as h,mt as g,pt as _,sa as v,ta as y,ut as te,v as ne,wt as re,xt as ie,yt as b}from"./src-DUz15ij3.js";import{I as x,K as S,Q as C,R as ae,S as w,W as T,b as E,o as D,q as O,x as k,z as A}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{R as oe}from"./src-B45-uhaF.js";import{p as se}from"./player-overlays-D3fMTMSy.js";import{t as j}from"./download-iZu8ddva.js";import{t as ce}from"./plus-CRDyDYzj.js";import{t as M}from"./refresh-cw-CQ8ZPCKP.js";import{t as N}from"./search-M9sg9sgJ.js";import{t as P}from"./upload-CbQEsRc1.js";import{F,H as I,I as L,K as le,S as R,W as ue,f as de,g as z,i as B,j as V,m as fe,s as H}from"./index-pSZYK5ny.js";import{t as U}from"./AdminPage-BwmGKnRf.js";import{t as pe}from"./NodeAddonsSettingsPanel-21ajRiKU.js";var me=I(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),W=I(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]),he=I(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),ge=I(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),G=I(`skip-forward`,[[`polygon`,{points:`5 4 15 12 5 20 5 4`,key:`16p6eg`}],[`line`,{x1:`19`,x2:`19`,y1:`5`,y2:`19`,key:`futhcm`}]]);C();var K=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),q=new Set([`done`,`failed`,`skipped`]);function J(e){return!q.has(e.phase)&&!K.has(e.jobState)}function _e(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=K.has(e.state);for(let i of e.tasks)r&&i.finishedAtMs!==null&&t-i.finishedAtMs>6e4||n.set(i.packageName,{jobId:e.jobId,packageName:i.packageName,phase:i.phase,fromVersion:i.fromVersion,toVersion:i.toVersion,error:i.error,jobState:e.state,finishedAtMs:i.finishedAtMs})}return n}function ve(){let{data:e}=b({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=v(oe.AddonsJobProgress,e=>e.job.jobId);return T(()=>{let n=new Map;for(let t of e??[])n.set(t.jobId,t);for(let[e,r]of t)n.set(e,r.job);return _e([...n.values()],Date.now())},[e,t])}var Y={queued:{icon:W,cls:`bg-muted text-foreground-subtle`,label:`queued`},fetching:{icon:R,cls:`bg-primary/10 text-primary`,label:`fetching`,spin:!0},staged:{icon:R,cls:`bg-primary/10 text-primary`,label:`staged`,spin:!0},validating:{icon:R,cls:`bg-primary/10 text-primary`,label:`validating`,spin:!0},applying:{icon:R,cls:`bg-primary/10 text-primary`,label:`applying`,spin:!0},restarting:{icon:R,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,label:`restarting`,spin:!0},applied:{icon:R,cls:`bg-primary/10 text-primary`,label:`finalizing`,spin:!0},done:{icon:L,cls:`bg-success/10 text-success`,label:`updated`},failed:{icon:he,cls:`bg-danger/10 text-danger`,label:`failed`},skipped:{icon:G,cls:`bg-muted text-foreground-subtle`,label:`skipped`}};function ye({progress:e}){let t=Y[e.phase],n=t.icon,r=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return w(`span`,{"data-testid":`addon-job-progress`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded shrink-0 ${t.cls}`,title:r,children:[k(n,{className:`w-2.5 h-2.5 ${t.spin?`animate-spin`:``}`}),t.label,w(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function be({packageName:e,currentVersion:t,installSource:n,onInstall:r,onClose:i,onSelect:a,selectedVersion:o}){let s=n===`upload`||n===`local`,{data:c,isLoading:l}=d({name:e});return w(`div`,{className:`fixed z-50 w-72 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,style:{top:`auto`,bottom:`auto`},ref:e=>{if(!e)return;let t=e.parentElement?.getBoundingClientRect();if(!t)return;let n=window.innerHeight-t.bottom,r=t.top;n<280&&r>n?(e.style.bottom=`${window.innerHeight-t.top+4}px`,e.style.top=`auto`):(e.style.top=`${t.bottom+4}px`,e.style.bottom=`auto`),e.style.right=`${window.innerWidth-t.right}px`},onClick:e=>e.stopPropagation(),children:[w(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[k(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:`Versions`}),k(`button`,{type:`button`,onClick:i,className:`text-foreground-subtle hover:text-foreground`,children:k(B,{className:`h-3 w-3`})})]}),s&&w(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[k(P,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),w(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[w(`span`,{className:`font-semibold`,children:[n===`upload`?`Uploaded copy`:`Local copy`,` in place.`]}),` `,`Re-install `,k(`span`,{className:`font-mono`,children:t}),` from npm to track upstream releases again.`]})]}),l&&w(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[k(R,{className:`h-3.5 w-3.5 animate-spin`}),`Loading versions...`]}),c&&k(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:c.map(e=>{let n=e.version===t,i=a!==void 0&&e.version===o,c=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),l=w(E,{children:[k(`span`,{className:`font-mono flex-1 text-left ${n?`text-primary font-semibold`:c?`text-amber-400`:`text-foreground`}`,children:e.version}),n&&k(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:`current`}),e.distTags.map(e=>k(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e===`latest`?`bg-emerald-500/15 text-emerald-400`:e===`beta`?`bg-amber-500/15 text-amber-400`:`bg-gray-500/15 text-gray-400`}`,children:e},e)),e.deprecated&&k(`span`,{className:`text-[9px] text-red-400 line-through`,children:`deprecated`}),k(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return a?w(`button`,{type:`button`,"aria-label":`Select ${e.version}`,onClick:()=>a(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${i?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[l,i?k(L,{className:`h-3 w-3 text-primary shrink-0`}):k(`span`,{className:`w-3 shrink-0`})]},e.version):w(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${n?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[l,n&&!s?k(L,{className:`h-3 w-3 text-primary shrink-0`}):k(`button`,{type:`button`,onClick:()=>r(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:n?`Re-install ${e.version} from npm`:`Install ${e.version}`,children:k(j,{className:`h-3 w-3`})})]},e.version)})}),c&&c.length===0&&k(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:`No versions found`})]})}var xe={queued:{icon:W,bg:`bg-muted text-foreground-subtle`,label:`queued`},updating:{icon:R,bg:`bg-primary/10 text-primary`,label:`updating`,spin:!0},"done-pending-restart":{icon:M,bg:`bg-amber-500/10 text-amber-700`,label:`pending restart`},done:{icon:L,bg:`bg-success/10 text-success`,label:`done`},failed:{icon:he,bg:`bg-danger/10 text-danger`,label:`failed`}};function Se({item:e}){let t=xe[e.status],n=t.icon;return w(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${t.bg}`,title:e.error,children:[k(n,{className:`w-2.5 h-2.5 ${t.spin?`animate-spin`:``}`}),t.label]})}C();var X=`device-export`;function Ce(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===X)}function we({isBundle:e,installSource:t,addonId:n,iconPath:r,color:i}){let[a,o]=O(!1),s=i?{backgroundColor:`${i.startsWith(`#`)?i:`#${i}`}26`}:void 0,c=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,l=n&&r?`/api/addon-assets/${n}/${r}`:null,u=!!l&&!a;return w(`div`,{className:`relative flex-shrink-0`,children:[k(`div`,{className:`h-9 w-9 rounded-lg flex items-center justify-center ${s?``:c}`,style:s,children:u?k(`img`,{src:l,alt:n,className:`h-5 w-5`,onError:()=>o(!0)}):k(e?ge:z,{className:`h-4 w-4`})}),t===`local`&&k(`span`,{className:`absolute -top-1.5 -left-1.5 text-[7px] font-bold leading-none bg-orange-500 text-white px-1 py-0.5 rounded -rotate-12 shadow-sm`,children:`DEV`}),t===`npm`&&k(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:k(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:k(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),t===`upload`&&k(`span`,{className:`absolute -top-1.5 -left-1.5 flex items-center justify-center h-4 w-4 rounded bg-cyan-500 -rotate-12 shadow-sm`,children:k(P,{className:`h-2.5 w-2.5 text-white`})})]})}function Te({version:e,availableUpdate:t,selectedVersion:n,isUpdating:r,installSource:i,disabled:a,onUpdate:o,onOpenPicker:s,children:c}){if(r)return w(`span`,{className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400 shrink-0`,children:[k(R,{className:`h-3 w-3 animate-spin`}),`Updating…`]});if(t){let r=n??t;return w(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[o&&w(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o()},disabled:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-semibold border border-blue-500/30 bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,title:`Update to ${r}`,children:[k(j,{className:`h-3 w-3`}),`Update`]}),w(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},disabled:a,"aria-label":`Select version to install`,title:`Installed ${e} — update available. Selected ${r}; tap to choose another version.`,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-bold font-mono border border-amber-500/40 bg-amber-500/15 text-amber-500 hover:bg-amber-500/25 animate-pulse disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[k(`span`,{className:`font-normal opacity-70`,children:e}),k(`span`,{className:`font-normal opacity-70`,children:`→`}),r,k(F,{className:`h-3 w-3`})]}),c]})}return w(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[w(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},disabled:a,className:[`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-bold font-mono border transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,i===`local`?`border-orange-500/30 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20`:`border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20`].join(` `),title:`Version ${e} — tap to view all versions`,children:[e,k(F,{className:`h-3 w-3 opacity-50`})]}),c]})}function Ee({addonId:e}){let n=D(),{data:r=`inherit`}=l({addonId:e}),i=t({onSuccess:()=>{n.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return k(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>k(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),i.mutate({addonId:e,channel:t})},disabled:i.isPending,className:`px-2.5 py-1 transition-colors capitalize ${r===t?t===`inherit`?`bg-gray-700/50 text-gray-700 dark:text-gray-300`:t===`off`?`bg-gray-700 text-gray-700 dark:text-gray-300`:t===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${t===`inherit`?``:`border-l border-border`}`,children:t},t))})}function De({addon:e,agents:t=[],clusterStatus:n,hideVersion:r,availableUpdate:a,onUpdate:o,isUpdating:s,jobProgress:c,bundle:l,bulkItem:d,disabledByBulk:f,isSystem:p}){let[g,_]=O(!1),[v,te]=O(!1),[ie,b]=O(!1),[x,S]=O(null);A(()=>{S(null)},[a]);let C=x??a,[ae,T]=O(!1),[oe,j]=O(!1),[N,P]=O(`logs`),I=D(),L=se(),le=ue(),R=y(),{manifest:z}=e,V=e.installedOn??[],U=!l&&!z.protected&&z.removable!==!1,W=!!l,G=l?.displayName??z.name,K=l?.packageName??z.packageName,q=l?.version??z.packageVersion??z.version,J=l?.installSource??e.installSource,_e=l?l.bundle?.description??l.addons[0]?.manifest.description:z.description,ve=m({onSuccess:()=>{I.invalidateQueries({queryKey:[[`addons`]]}),I.invalidateQueries({queryKey:[[`addonPages`]]}),I.invalidateQueries({queryKey:[[`capabilities`]]})}}),Y=i({onSuccess:()=>{I.invalidateQueries({queryKey:[[`addons`]]})}}),xe=ee({onSuccess:()=>{I.invalidateQueries({queryKey:[[`addons`]]}),I.invalidateQueries({queryKey:[[`addonPages`]]}),I.invalidateQueries({queryKey:[[`capabilities`]]}),I.invalidateQueries({queryKey:[[`integrations`]]})}}),X=re({onSuccess:()=>{I.invalidateQueries({queryKey:[[`addons`]]}),I.invalidateQueries({queryKey:[[`alerts`]]})}}),Z=e.health,Q=Z?.phase===`failed`&&!Z.inGracePeriod,Oe=Q&&Z?.nextRetryAt&&!Z.retrying;return w(`div`,{className:`rounded-lg border bg-surface overflow-hidden ${Q?`border-red-500/50`:`border-border`}`,children:[Q&&Z&&w(`div`,{className:`bg-danger/10 border-b border-danger/30 px-4 py-2.5 flex items-start gap-2.5`,children:[k(he,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),w(`div`,{className:`flex-1 min-w-0`,children:[w(`div`,{className:`text-xs font-semibold text-danger`,children:[`Failed to load (attempt #`,Z.retryCount,`)`]}),k(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:Z.lastError?.message??`Unknown error`}),Oe&&Z.nextRetryAt&&w(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:[`Auto-retry at `,new Date(Z.nextRetryAt).toLocaleTimeString()]})]}),w(`button`,{type:`button`,disabled:X.isPending||Z.retrying,onClick:e=>{e.stopPropagation(),X.mutate({packageName:K})},className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-semibold border border-red-400/40 bg-red-400/10 text-red-700 dark:text-red-300 hover:bg-red-400/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0`,title:`Reset retry counter and force immediate reload`,children:[k(M,{className:`h-3 w-3 ${X.isPending||Z.retrying?`animate-spin`:``}`}),`Retry now`]})]}),w(`div`,{className:`flex items-start gap-3 px-4 py-3`,children:[k(we,{isBundle:W||!!z.components&&z.components.length>1,installSource:J,addonId:W?l.addons[0]?.manifest.id:z.id,iconPath:W?l.bundle?.icon??l.addons[0]?.manifest.icon:z.icon,color:W?l.addons[0]?.manifest.color:z.color}),w(`div`,{className:`flex-1 min-w-0`,children:[w(`div`,{className:`flex items-start justify-between gap-2`,children:[k(`span`,{className:`text-sm font-semibold text-foreground truncate min-w-0`,children:G}),!r&&k(Te,{version:q,availableUpdate:a,...C===void 0?{}:{selectedVersion:C},isUpdating:s,installSource:J,disabled:f,...o&&C!==void 0?{onUpdate:()=>o(C)}:{},onOpenPicker:()=>b(e=>!e),children:ie&&k(be,{packageName:K,currentVersion:q,...J?{installSource:J}:{},...a!==void 0&&C!==void 0?{selectedVersion:C,onSelect:e=>{S(e),b(!1)}}:{},onInstall:e=>{b(!1),xe.mutate({packageName:K,version:e})},onClose:()=>b(!1)})})]}),w(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[K!==G&&k(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:K}),W&&w(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,children:[k(ge,{className:`h-3 w-3`}),l.addons.length]}),p&&w(`span`,{className:`text-[10px] rounded-full bg-amber-500/15 text-amber-700 dark:text-amber-300 px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,title:`System package — updating restarts the hub`,children:[k(M,{className:`h-3 w-3`}),`System`]}),d!=null&&k(Se,{item:d}),c!=null&&k(ye,{progress:c})]}),_e&&k(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:_e}),!W&&e.process&&w(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[k(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.mode===`forked`?`bg-blue-500/15 text-blue-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.mode===`forked`?`forked`:`in-process`}),e.process.pid!=null&&w(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),k(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state===`running`?`bg-emerald-500/15 text-emerald-400`:e.process.state===`crashed`||e.process.state===`failed`?`bg-red-500/15 text-red-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.state})]})]})]}),!W&&w(`div`,{className:`flex items-center gap-1 px-4 py-1.5 border-t border-border/50 bg-surface-hover/20`,children:[w(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Y.mutate({addonId:z.id})},disabled:Y.isPending||f,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors`,children:[k(M,{className:`h-3 w-3 ${Y.isPending?`animate-spin`:``}`}),`Restart`]}),w(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),T(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${ae?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[k(fe,{className:`h-3 w-3`}),`Logs`]}),!W&&w(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),j(!0)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${oe?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[k(de,{className:`h-3 w-3`}),`Settings`]}),k(`div`,{className:`flex-1`}),U&&w(`button`,{type:`button`,onClick:async e=>{e.stopPropagation(),await R({title:`Uninstall ${z.name}?`,message:`This will remove the addon package and all its data. This action cannot be undone.`,confirmLabel:`Uninstall`,variant:`danger`})&&ve.mutate({packageName:z.packageName})},disabled:ve.isPending||f,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-red-400 hover:border-red-500/30 hover:bg-red-500/10 disabled:opacity-50 transition-colors`,children:[k(H,{className:`h-3 w-3`}),ve.isPending?`Removing...`:`Uninstall`]})]}),n&&n.nodes.length>1&&!W&&w(`div`,{className:`border-t border-border px-4 py-2 bg-muted/10`,children:[k(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:`Cluster Deployment`}),k(`div`,{className:`space-y-1`,children:n.nodes.map(e=>w(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[k(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`offline`?`bg-muted-foreground/30`:e.synced?`bg-success`:`bg-amber-500`}`}),k(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),k(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&k(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:`outdated`}),e.status===`offline`&&k(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:`offline`}),e.synced&&e.status!==`offline`&&k(`span`,{className:`text-[9px] text-success`,children:`synced`})]},e.nodeId))})]}),ae&&!W&&w(`div`,{className:`border-t border-border`,children:[w(`div`,{className:`flex items-center px-4 py-1 bg-surface-hover/20 border-b border-border/50`,children:[w(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[k(`button`,{type:`button`,onClick:()=>P(`logs`),className:`px-2 py-0.5 transition-colors ${N===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Logs`}),k(`button`,{type:`button`,onClick:()=>P(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${N===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Events`})]}),k(`div`,{className:`flex-1`}),k(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),T(!1)},className:`text-foreground-subtle hover:text-foreground`,children:k(B,{className:`h-3.5 w-3.5`})})]}),N===`logs`&&k(u,{addonId:z.id,maxHeight:`max-h-64`,showFilters:!1}),N===`events`&&k(h,{addonId:z.id,category:`addon.*`,maxHeight:`max-h-64`})]}),W&&w(E,{children:[k(`button`,{type:`button`,onClick:()=>_(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:k(g?me:F,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),g&&k(`div`,{className:`border-t border-border px-3 py-2 space-y-2`,children:l.addons.map(e=>k(De,{addon:e,agents:t,hideVersion:!0},e.manifest.id))})]}),oe&&!W&&k(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4`,onClick:()=>j(!1),children:w(`div`,{className:`w-full max-w-lg max-h-[80vh] rounded-xl border border-border bg-surface shadow-2xl flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[w(`div`,{className:`flex items-center justify-between px-5 py-3 border-b border-border flex-shrink-0`,children:[w(`div`,{className:`flex items-center gap-2`,children:[k(de,{className:`h-4 w-4 text-primary`}),w(`h2`,{className:`text-sm font-semibold text-foreground`,children:[G,` Settings`]})]}),k(`button`,{onClick:()=>j(!1),className:`text-foreground-subtle hover:text-foreground transition-colors p-1 rounded`,children:k(B,{className:`h-4 w-4`})})]}),w(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[k(pe,{nodeId:`hub`,addonIds:[z.id],level:`global`}),Ce(z)&&w(`div`,{children:[k(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Device export`}),k(ne,{addonId:z.id,trpc:L.trpcClient,onOpenDevice:e=>le(`/devices/${e}`)})]}),J===`npm`&&w(`div`,{children:[k(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Auto-Update`}),k(Ee,{addonId:z.id})]}),z.components&&z.components.length>0&&w(`div`,{children:[w(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Components (`,z.components.length,`)`]}),k(`div`,{className:`flex flex-wrap gap-1`,children:z.components.map(e=>k(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]}),t.length>=2&&w(`div`,{children:[k(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Installed on`}),w(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[V.length===0&&k(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Hub (local)`}),V.map(e=>k(`span`,{className:`rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle`,children:e},e)),w(`div`,{className:`relative`,children:[w(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),te(e=>!e)},className:`inline-flex items-center gap-1 rounded-full border border-dashed border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground hover:border-primary transition-colors`,title:`Install on more agents`,children:[k(ce,{className:`h-3 w-3`}),`Add agent`]}),v&&w(`div`,{className:`absolute left-0 top-full mt-1 z-10 min-w-[160px] rounded-md border border-border bg-surface shadow-lg overflow-hidden`,children:[t.filter(e=>!e.isHub&&!V.includes(e.name)).map(e=>k(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),te(!1)},className:`w-full text-left px-3 py-1.5 text-[10px] text-foreground hover:bg-surface-hover transition-colors`,children:e.name},e.id)),t.filter(e=>!e.isHub&&!V.includes(e.name)).length===0&&k(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle`,children:`No available agents`})]})]})]})]})]}),k(`div`,{className:`flex items-center justify-end px-5 py-3 border-t border-border flex-shrink-0`,children:k(`button`,{type:`button`,onClick:()=>j(!1),className:`rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:`Close`})})]})})]})}C();var Z=`.tgz,.tar.gz,.zip`;function Q({onUploadSuccess:e}){let[t,n]=O(!1),r=S(null),i=x(async t=>{n(!0);let r=new FormData;r.append(`file`,t);let i=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(`/api/addons/upload`,{method:`POST`,headers:{Authorization:`Bearer ${i}`},body:r})).json()).success&&e()}finally{n(!1)}},[e]);return w(E,{children:[k(`input`,{ref:r,type:`file`,accept:Z,onChange:x(e=>{let t=e.target.files?.[0];t&&i(t),e.target.value=``},[i]),className:`hidden`}),w(`button`,{type:`button`,onClick:()=>r.current?.click(),disabled:t,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[t?k(R,{className:`w-3.5 h-3.5 animate-spin`}):k(P,{className:`w-3.5 h-3.5`}),t?`Uploading...`:`Upload`]})]})}C();var Oe=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/shm-ring`,`@camstack/ui-library`]);function ke(e){return e!==void 0&&Oe.has(e)}function Ae(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function je(e){let t=e;if(!t?.manifest)return null;let n={...t.manifest,name:t.manifest.name??t.manifest.id,version:t.manifest.version??`0.0.0`,capabilities:t.manifest.capabilities??[]},r=t.process,i=r?{pid:r.pid,mode:r.mode===`forked`?`forked`:`in-process`,state:r.state??`unknown`}:void 0,a=t.health,o=t.declaration?.execution,s=t.manifest.execution,c=o?.placement??s?.placement;return{manifest:n,enabled:!0,source:t.source,installSource:t.installSource,installedOn:[],...i?{process:i}:{},hasBackup:t.hasBackup,...a?{health:a}:{},...c?{placement:c}:{}}}function Me(e){let t=new Map,n=[];for(let r of e){let e=r.manifest.packageName;if(!e){n.push(r);continue}let i=t.get(e);if(i)i.addons.push(r);else{let n=r.manifest.bundle,i={packageName:e,displayName:n?.displayName??r.manifest.packageDisplayName??r.manifest.name,version:r.manifest.packageVersion,addons:[r],...r.installSource===void 0?{}:{installSource:r.installSource},...n===void 0?{}:{bundle:n}};t.set(e,i)}}let r=[];for(let e of t.values())e.bundle!==void 0||e.addons.length>=2?r.push({bundle:e,representative:e.addons[0]}):r.push(e.addons[0]);return r.push(...n),r}function $(e){return`bundle`in e}function Ne({addons:t,clusterStatus:n,selectedNode:i,onRefresh:o,isRefreshing:c}){let l=D(),[u,d]=O(``),f=ae(u),[p,m]=O(!1),h=S(null);A(()=>{if(!p)return;let e=e=>{h.current&&!h.current.contains(e.target)&&m(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[p]);let{data:v}=s({nodeId:i.id}),ne=T(()=>{let e=new Map;for(let t of v??[])e.set(t.name,t.latestVersion);return e},[v]),re=T(()=>(v??[]).filter(e=>!e.isSystem).length,[v]),[ie,b]=O(()=>new Set),[C,E]=O(()=>new Map),oe=x(e=>{b(t=>new Set(t).add(e))},[]),se=x(e=>{b(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),ce=x((e,t)=>{E(n=>new Map(n).set(e,t))},[]),P=x(e=>{E(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),F=e({onMutate:e=>{oe(e.name),P(e.name)},onSuccess:(e,t)=>{se(t.name);let n=e;if(n&&n.success===!1){ce(t.name,n.error??`Update failed (no error message returned by server)`);return}l.invalidateQueries({queryKey:[[`addons`]]}),l.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{se(t.name),ce(t.name,e instanceof Error?e.message:String(e))}}),I=ve(),ue=S(new Set);A(()=>{let e=new Set;for(let[t,n]of I)J(n)&&e.add(t);let t=[...ue.current].some(t=>!e.has(t));ue.current=e,t&&(l.invalidateQueries({queryKey:[[`addons`]]}),l.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[I,l]);let{data:de}=_(void 0),z=te({onSuccess:()=>{l.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:B,isFetching:fe}=a({query:f||void 0},{enabled:p}),H=r(),{data:U}=g(void 0),pe=U?.requestedAt,[me,W]=O(null),[he,ge]=O(!1);A(()=>{if(U?.kind===`framework-bulk-update`&&U.requestedAt!==me){W(U.requestedAt),ge(!0);let e=window.setTimeout(()=>ge(!1),6e3);return()=>window.clearTimeout(e)}},[pe,me,U]),y();let G=x(async()=>{let e=(v??[]).filter(e=>!e.isSystem);e.length!==0&&await H.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[i.id]})},[v,i.id,H]),K=ee({onSuccess:()=>{l.invalidateQueries({queryKey:[[`addons`]]}),l.invalidateQueries({queryKey:[[`addonPages`]]}),l.invalidateQueries({queryKey:[[`capabilities`]]}),l.invalidateQueries({queryKey:[[`integrations`]]})}}),[q,_e]=O(`type`),[Y,ye]=O(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),be=e=>{ye(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[xe,Se]=le(),X=xe.get(`capability`),Ce=T(()=>{let e=t.filter(e=>!ke(e.manifest.packageName));return i.isHub||(e=e.filter(e=>Ae(e.placement,i.isHub))),X&&(e=e.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===X))),e},[t,i.isHub,X]),we=()=>{let e=new URLSearchParams(xe);e.delete(`capability`),Se(e,{replace:!0})},Te=Y===`flat`?Ce:Me(Ce),Ee=T(()=>{let e=[...Te];switch(q){case`type`:e.sort((e,t)=>{let n=+!$(e),r=+!$(t);if(n!==r)return n-r;let i=$(e)?e.bundle.displayName:e.manifest.name,a=$(t)?t.bundle.displayName:t.manifest.name;return i.localeCompare(a)});break;case`name`:e.sort((e,t)=>{let n=$(e)?e.bundle.displayName:e.manifest.name,r=$(t)?t.bundle.displayName:t.manifest.name;return n.localeCompare(r)});break;case`source`:e.sort((e,t)=>{let n=$(e)?e.bundle.installSource??``:e.installSource??``,r=$(t)?t.bundle.installSource??``:t.installSource??``;return n.localeCompare(r)});break}return e},[Te,q]);return w(`div`,{className:`space-y-4`,children:[[...C.entries()].map(([e,t])=>k(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px]`,children:w(`div`,{className:`flex items-start justify-between gap-3`,children:[w(`div`,{className:`space-y-0.5`,children:[w(`div`,{className:`font-medium text-danger`,children:[`Failed to update `,e]}),k(`div`,{className:`text-foreground-subtle font-mono`,children:t})]}),k(`button`,{type:`button`,onClick:()=>P(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:`dismiss`})]})},e)),w(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[w(`div`,{className:`flex items-center gap-1.5`,children:[k(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Sort:`}),w(`select`,{value:q,onChange:e=>_e(e.target.value),className:`rounded-md border border-border bg-surface px-2 py-1.5 text-[11px] text-foreground focus:outline-none focus:border-primary/50`,children:[k(`option`,{value:`type`,children:`Bundles first`}),k(`option`,{value:`name`,children:`Name`}),k(`option`,{value:`source`,children:`Install source`})]})]}),w(`div`,{className:`flex items-center gap-1.5`,children:[k(`span`,{className:`text-[10px] text-foreground-subtle`,children:`View:`}),k(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>k(`button`,{type:`button`,onClick:()=>be(e),className:`px-2.5 py-1.5 transition-colors capitalize ${Y===e?`bg-primary/10 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`}`,title:e===`grouped`?`Group multi-addon packages into a bundle card`:`Show every addon as its own card`,children:e},e))})]}),i.isHub&&w(`div`,{className:`flex items-center gap-1.5`,children:[k(M,{className:`h-3 w-3 text-foreground-subtle`}),k(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Auto-Update:`}),k(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>k(`button`,{type:`button`,onClick:()=>z.mutate({channel:e}),disabled:z.isPending,className:`px-2.5 py-1.5 transition-colors capitalize ${de?.channel===e?e===`off`?`bg-gray-700 text-gray-200`:e===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${e===`off`?``:`border-l border-border`}`,children:e},e))})]}),re>0&&w(`button`,{type:`button`,onClick:()=>void G(),disabled:H.isPending,className:`flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 border border-blue-500/30 disabled:opacity-50 transition-colors font-medium`,children:[H.isPending?k(R,{className:`w-3 h-3 animate-spin`}):k(j,{className:`w-3 h-3`}),H.isPending?`Updating…`:`Update All (${re})`]}),w(`button`,{type:`button`,onClick:o,disabled:c||H.isPending,className:`flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[k(M,{className:`w-3 h-3 ${c?`animate-spin`:``}`}),`Refresh`]})]}),w(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[w(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:h,children:[k(N,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),k(`input`,{type:`text`,value:u,onChange:e=>{d(e.target.value),m(!0)},onFocus:()=>m(!0),placeholder:`Search addons on npm...`,disabled:H.isPending,className:`w-full rounded-lg border border-border bg-background pl-9 pr-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-50 disabled:cursor-not-allowed`}),fe&&k(R,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle animate-spin`}),p&&B&&B.length>0&&w(`div`,{className:`absolute left-0 right-0 top-full mt-1 z-40 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,children:[B.length>0&&w(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[`npm results (`,B.length,`)`]}),B&&B.length>0&&k(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:B.map(e=>w(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[k(`div`,{className:`w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center text-primary text-[9px] font-bold shrink-0`,children:e.name.replace(`@camstack/addon-`,``).charAt(0).toUpperCase()}),w(`div`,{className:`flex-1 min-w-0`,children:[w(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[k(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),w(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),k(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&k(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?w(`span`,{className:`inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md border border-emerald-500/30 bg-emerald-500/10 text-emerald-400 shrink-0`,children:[k(L,{className:`h-3 w-3`}),e.installedVersion??`Installed`]}):w(`button`,{type:`button`,onClick:()=>K.mutate({packageName:e.name}),disabled:K.isPending,className:`inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0`,children:[K.isPending?k(R,{className:`h-3 w-3 animate-spin`}):k(j,{className:`h-3 w-3`}),`Install`]})]},e.name))})]})]}),k(Q,{onUploadSuccess:()=>{l.invalidateQueries({queryKey:[[`addons`]]}),o()}})]}),X&&w(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-primary/10 border border-primary/30 text-sm`,children:[k(`span`,{className:`text-foreground-subtle`,children:`Filtering by capability:`}),k(`span`,{className:`font-mono text-primary font-semibold`,children:X}),k(`button`,{type:`button`,onClick:we,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:`Clear`})]}),he&&w(`div`,{className:`fixed top-4 right-4 z-50 flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg backdrop-blur-sm max-w-sm pointer-events-auto`,children:[k(V,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),w(`div`,{children:[k(`div`,{className:`text-[11px] font-semibold text-foreground`,children:`Bulk update completed`}),k(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:`System packages updated — hub restarted successfully.`})]})]}),Ce.length===0&&k(`div`,{className:`text-xs text-foreground-subtle`,children:t.length===0?`No addons installed`:X?`No installed addons declare the "${X}" capability. Browse the npm catalog above to find a compatible addon.`:`No addons compatible with ${i.name} (placement filter active)`}),k(`div`,{className:`space-y-2`,children:Ee.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,r=ne.get(t),a=$(e)?e.representative:e,o=r?e=>F.mutate({name:t,version:e,nodeId:i.id}):void 0,s=I.get(t)??null,c=s!==null&&J(s);return k(De,{addon:a,clusterStatus:n?.[a.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:r,isUpdating:ie.has(t)||c,jobProgress:s,onUpdate:o,disabledByBulk:H.isPending},$(e)?t:e.manifest.id)})})]})}function Pe(){let e=D(),{data:t,isLoading:r,isError:i}=o(),{data:a}=p(void 0),{data:s}=n(void 0,{refetchInterval:1e4}),l=T(()=>{let e=new Map;e.set(`hub`,{id:`hub`,name:`Hub`,isHub:!0});for(let t of s??[]){let n=String(t.id??``);n&&e.set(n,{id:n,name:String(t.name??n),isHub:!!t.isHub})}return[...e.values()]},[s]),[u,ee]=O(`hub`),d=l.find(e=>e.id===u)??l[0],m=c(),h=ie(),g=m.isPending||h.isPending,_=async()=>{await m.mutateAsync({nodeId:u}),await h.mutateAsync(),e.invalidateQueries({queryKey:[[`addons`]]})},v=S(m);v.current=m,A(()=>{v.current.mutate({nodeId:`hub`})},[]);let y=(t??[]).map(je).filter(e=>e!==null);return w(U,{children:[w(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[k(f,{selectedNodeId:u,onSelect:ee}),w(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[!r&&!i&&w(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:[y.length,` installed`]}),w(`button`,{type:`button`,onClick:()=>void _(),disabled:g,className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,title:`Re-fetch addons + check npm for new versions`,children:[k(M,{className:`w-3 h-3 ${g?`animate-spin`:``}`}),`Check for updates`]})]})]}),!d.isHub&&w(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle`,children:[`Showing only addons compatible with`,` `,k(`span`,{className:`font-medium text-foreground`,children:d.name}),` — agents only run`,` `,k(`code`,{className:`font-mono`,children:`agent-only`}),` and`,` `,k(`code`,{className:`font-mono`,children:`any-node`}),` addons. Install / uninstall is hub-driven; agents auto-sync from the hub.`]}),r&&k(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading…`}),i&&k(`div`,{className:`text-xs text-danger`,children:`Failed to load addons`}),!r&&!i&&k(Ne,{addons:y,clusterStatus:a,selectedNode:d,onRefresh:()=>void _(),isRefreshing:g})]})}export{Pe as AddonsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e,x as t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{n,r,t as i}from"./zap-IxXrBEjL.js";import{t as a}from"./radio-Cidrh6lI.js";import{t as o}from"./refresh-cw-CQ8ZPCKP.js";import{t as s}from"./sparkles-Uqh90jkF.js";import{A as c,E as l,H as u,L as d,R as f,f as p,z as m}from"./index-pSZYK5ny.js";var h=u(`battery-full`,[[`rect`,{width:`16`,height:`10`,x:`2`,y:`7`,rx:`2`,ry:`2`,key:`1w10f2`}],[`line`,{x1:`22`,x2:`22`,y1:`11`,y2:`13`,key:`4dh1rd`}],[`line`,{x1:`6`,x2:`6`,y1:`11`,y2:`13`,key:`1wd6dw`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`13`,key:`haxvl5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`13`,key:`c6fn6x`}]]),g=u(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),_=u(`grid-2x2`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]),v=u(`map`,[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]),y=u(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),b={streaming:{icon:n,label:`Streaming`},detection:{icon:l,label:`Detection`},recording:{icon:g,label:`Recording`},audio:{icon:r,label:`Audio`},snapshot:{icon:d,label:`Snapshot`},motion:{icon:i,label:`Motion`},ptz:{icon:p,label:`PTZ`},webrtc:{icon:a,label:`WebRTC`},onvif:{icon:y,label:`ONVIF`},analytics:{icon:c,label:`Analytics`},"battery-operated":{icon:h,label:`Battery`},"native-snapshot":{icon:d,label:`Native Snapshot`},"pan-tilt-zoom":{icon:p,label:`PTZ`},"two-way-audio":{icon:r,label:`Two-way Audio`},"doorbell-button":{icon:m,label:`Doorbell`},rebootable:{icon:o,label:`Rebootable`},"vacuum-has-map":{icon:v,label:`Map`},"vacuum-has-ai":{icon:s,label:`AI Obstacle`},"mower-has-map":{icon:v,label:`Map`},"mower-has-targeted-mowing":{icon:_,label:`Targeted Mowing`}},x=f;function S({capabilities:n,showLabels:r=!1}){return t(`div`,{className:`flex items-center gap-1 flex-wrap`,children:n.map(n=>{let i=b[n],a=i?.icon??x,o=i?.label??n;return e(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] text-foreground-subtle`,title:o,children:[t(a,{className:`h-3 w-3`}),r&&t(`span`,{children:o})]},n)})})}export{S as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Ca as e,Er as t,Fr as n,Ir as r,Lr as i,Mr as a,Nr as o,Pr as s,Rr as c,Sa as l,Tr as u,ba as d,ca as f,g as p,gi as m,m as h,oa as g,ta as _,ti as v,xa as y}from"./src-DUz15ij3.js";import{I as b,K as x,Q as S,S as C,W as w,o as T,q as E,x as D,z as O}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 k}from"./player-overlays-D3fMTMSy.js";import{t as A}from"./pencil-DL1TJsTc.js";import{t as j}from"./radio-Cidrh6lI.js";import{t as M}from"./refresh-cw-CQ8ZPCKP.js";import{t as N}from"./rotate-cw-DR-mTm0L.js";import{t as ee}from"./upload-CbQEsRc1.js";import{A as P,F,H as I,I as L,N as R,R as z,S as B,i as V,m as H,o as U,p as W,s as G}from"./index-pSZYK5ny.js";import{n as K,t as q}from"./build-cluster-graph-DLb-k44M.js";import{t as J}from"./format-size-CO9d3C3-.js";import{t as Y}from"./NodeAddonsSettingsPanel-21ajRiKU.js";var X=I(`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`}]]),Z=I(`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`}]]),Q=I(`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`}]]),te=I(`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`}]]);S();function ne(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 re({nodeId:e,addons:t,isHub:n}){let r=T(),i=_(),[o,l]=E(null),[u,d]=E(null),[f,p]=E(!1),[m,h]=E(null),[g,v]=E(0),y=x(null),b=s(),S=c(),w=a({nodeId:e}),O=w.data??[],k=new Map(t.map(e=>[e.id,e.capabilities])),A=O.length>0?O.map(e=>({id:e.id,status:e.status,capabilities:k.get(e.id)??[],version:e.version,packageName:e.packageName})):t.map(e=>({id:e.id,status:e.status,capabilities:e.capabilities,version:void 0,packageName:void 0})),j=()=>{r.invalidateQueries({queryKey:[[`nodes`,`topology`]]}),w.refetch()},M=async t=>{l(t);try{await b.mutateAsync({nodeId:e,addonId:t}),j()}catch(e){console.error(`Failed to restart addon:`,e)}finally{l(null)}},P=async t=>{if(await i({title:`Uninstall addon`,message:`Remove "${t}" from ${e}? The addon directory will be deleted on disk.`,confirmLabel:`Uninstall`,variant:`danger`})){d(t);try{await S.mutateAsync({nodeId:e,addonId:t}),j()}catch(e){console.error(`Failed to uninstall addon:`,e)}finally{d(null)}}},F=C(`div`,{className:`flex items-center gap-2 mb-2`,children:[D(`input`,{ref:y,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),v(0);try{await ne({file:n,nodeId:e,token:localStorage.getItem(`camstack_admin_token`),onProgress:v}),j()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1),v(0)}}}}),C(`button`,{onClick:()=>y.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?D(B,{className:`h-3 w-3 animate-spin`}):D(ee,{className:`h-3 w-3`}),f?`Uploading… ${g}%`:`Upload addon (.tgz)`]}),f&&D(`div`,{className:`flex-1 h-1 rounded-full bg-muted overflow-hidden max-w-[140px]`,children:D(`div`,{className:`h-full bg-primary transition-all`,style:{width:`${g}%`}})}),m&&D(`span`,{className:`text-[10px] text-destructive`,children:m})]});return A.length===0?C(`div`,{children:[F,D(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:w.isLoading?`Loading addons…`:`No addons on this node`})]}):C(`div`,{children:[F,C(`table`,{className:`w-full text-xs`,children:[D(`thead`,{children:C(`tr`,{className:`text-muted-foreground text-left`,children:[D(`th`,{className:`py-2 font-medium`,children:`Addon`}),D(`th`,{className:`py-2 font-medium`,children:`Version`}),D(`th`,{className:`py-2 font-medium`,children:`Capabilities`}),D(`th`,{className:`py-2 font-medium`,children:`Status`}),D(`th`,{className:`py-2 font-medium w-16`})]})}),D(`tbody`,{children:A.map(e=>C(`tr`,{className:`border-t border-border/50`,children:[C(`td`,{className:`py-2 font-medium`,children:[D(`div`,{children:e.id}),e.packageName&&D(`div`,{className:`text-[9px] text-muted-foreground`,children:e.packageName})]}),D(`td`,{className:`py-2 text-muted-foreground`,children:e.version??`—`}),D(`td`,{className:`py-2`,children:D(`div`,{className:`flex flex-wrap gap-1`,children:e.capabilities.length>0?e.capabilities.map(e=>D(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400`,children:e},e)):D(`span`,{className:`text-muted-foreground`,children:`—`})})}),D(`td`,{className:`py-2`,children:D(`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})}),D(`td`,{className:`py-2`,children:C(`div`,{className:`flex items-center gap-1 justify-end`,children:[D(`button`,{onClick:()=>M(e.id),disabled:o===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:D(N,{className:`h-3 w-3 ${o===e.id?`animate-spin`:``}`})}),D(`button`,{onClick:()=>P(e.id),disabled:o===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?D(B,{className:`h-3 w-3 animate-spin`}):D(G,{className:`h-3 w-3`})})]})})]},e.id))})]})]})}S();function ie(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 ae({state:e}){return D(`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 oe=[`trace`,`debug`,`info`,`warn`,`error`];function se({proc:t,nodeId:i,defaultExpanded:a,activePanel:o,onTogglePanel:c}){let u=t.services??[],f=u.length===1,[m,g]=E(f||a),[_,v]=E(null),[b,x]=E(`info`),S=t.name.includes(`(core)`),w=s(),T=n(),O=r(),k=async e=>{v(e);try{await w.mutateAsync({nodeId:i,addonId:e})}catch(e){console.error(`Failed to restart addon:`,e)}finally{v(null)}},A=async()=>{v(t.name);try{await T.mutateAsync({nodeId:i,processName:t.name})}catch(e){console.error(`Failed to restart process:`,e)}finally{v(null)}},M=async e=>{let n=`${i}/${t.name}`;try{await O.mutateAsync({nodeId:n,level:e}),x(e)}catch(e){console.error(`Failed to set log level:`,e)}};return C(`div`,{className:`border border-border/50 rounded-lg overflow-hidden`,children:[C(`div`,{role:f?void 0:`button`,tabIndex:f?void 0:0,onClick:f?void 0:()=>g(!m),onKeyDown:f?void 0:e=>{(e.key===`Enter`||e.key===` `)&&g(!m)},className:`flex items-center gap-2 w-full px-3 py-2 bg-muted/20 transition-colors text-left select-none ${f?``:`hover:bg-muted/40 cursor-pointer`}`,children:[f?D(`span`,{className:`h-3 w-3 shrink-0`}):D(m?F:R,{className:`h-3 w-3 text-muted-foreground shrink-0`}),S?D(W,{className:`h-3.5 w-3.5 text-primary shrink-0`}):D(z,{className:`h-3.5 w-3.5 text-amber-500 shrink-0`}),D(`span`,{className:`text-xs font-semibold flex-1`,children:t.name}),C(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`PID `,t.pid]}),D(ae,{state:t.state}),C(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[t.cpuPercent,`% CPU`]}),D(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:J(t.memoryRss)}),D(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:ie(t.uptimeSeconds)}),!S&&C(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[C(d,{children:[D(e,{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:b}),D(y,{align:`end`,className:`min-w-[70px] py-0.5`,children:oe.map(e=>D(l,{onClick:()=>M(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===b?`text-primary font-semibold`:``}`,children:e},e))})]}),D(`button`,{onClick:A,disabled:_===t.name,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart process`,children:D(N,{className:`h-3 w-3 ${_===t.name?`animate-spin`:``}`})})]})]}),m&&u.length>0&&D(`div`,{className:`divide-y divide-border/30`,children:u.map(e=>C(`div`,{children:[C(`div`,{className:`flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors`,children:[D(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`running`?`bg-success`:`bg-muted-foreground/30`}`}),D(`span`,{className:`text-xs font-medium flex-1 min-w-0 truncate`,children:e.addonId}),e.capabilities.length>0&&C(`div`,{className:`flex gap-1 flex-shrink-0`,children:[e.capabilities.slice(0,3).map(e=>D(`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&&C(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.capabilities.length-3]})]}),C(`div`,{className:`flex items-center gap-1 shrink-0`,children:[D(`button`,{onClick:()=>c(e.addonId,`logs`),className:`p-0.5 rounded transition-colors ${o?.addonId===e.addonId&&o.type===`logs`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:`Show logs for ${e.addonId}`,children:D(H,{className:`h-3 w-3`})}),D(`button`,{onClick:()=>c(e.addonId,`events`),className:`p-0.5 rounded transition-colors ${o?.addonId===e.addonId&&o.type===`events`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:`Show events for ${e.addonId}`,children:D(j,{className:`h-3 w-3`})}),D(`button`,{onClick:()=>k(e.addonId),disabled:_===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:D(N,{className:`h-3 w-3 ${_===e.addonId?`animate-spin`:``}`})})]})]}),o?.addonId===e.addonId&&o.type===`logs`&&D(`div`,{className:`border-t border-border/40 bg-muted/5`,children:D(p,{addonId:e.addonId,agentId:i,maxHeight:`max-h-48`,showFilters:!1,onClose:()=>c(e.addonId,`logs`)})}),o?.addonId===e.addonId&&o.type===`events`&&D(`div`,{className:`border-t border-border/40 bg-muted/5`,children:D(h,{addonId:e.addonId,category:`addon.*`,maxHeight:`max-h-48`,onClose:()=>c(e.addonId,`events`)})})]},e.addonId))}),m&&u.length===0&&D(`div`,{className:`px-3 py-2 pl-9 text-[10px] text-muted-foreground`,children:`No services`})]})}function ce({nodeId:e,processes:t}){let[n,r]=E(null),i=(e,t)=>{r(n=>n?.addonId===e&&n.type===t?null:{addonId:e,type:t})};return t.length===0?D(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No processes on this node`}):D(`div`,{className:`space-y-2 py-1`,children:t.map((t,r)=>D(se,{proc:t,nodeId:e,defaultExpanded:r===0,activePanel:n,onTogglePanel:i},t.name))})}S();function le(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 ue(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function de({nodeId:e}){let n=T(),r=_(),[i,a]=E(`all`),o=g(`metrics.node-processes-snapshot`,t=>t.nodeId===e),{data:s}=t({nodeId:e}),c=o?.processes??s,l=w(()=>c?[...c]:[],[c]),d=w(()=>i===`ghost`?l.filter(e=>e.classification===`ghost`):l,[l,i]),f=w(()=>{let e=l.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)},[l]),p=u({onSettled:()=>{n.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]})}}),m=w(()=>{let e=new Map;for(let t of l)e.set(t.pid,t.classification);return e},[l]),h=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`})&&p.mutate({nodeId:e,pid:t.pid,force:n})},v=async(t,n)=>{try{await p.mutateAsync({nodeId:e,pid:t,force:n})}catch{}},y=async t=>{let i=m.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=l.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=l.filter(e=>e.classification===`ghost`).length,S=l.filter(e=>e.classification===`managed`).length,O=l.filter(e=>e.classification===`root`).length,k=l.filter(e=>e.classification===`system`).length;return C(`div`,{className:`space-y-4`,children:[C(`div`,{className:`flex items-start justify-between gap-4`,children:[C(`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."]}),C(`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:[D(M,{className:`h-3 w-3`}),` Refresh`]})]}),C(`div`,{className:`grid grid-cols-4 gap-3`,children:[C(`div`,{className:`rounded-lg border border-border p-3`,children:[D(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`Root`}),D(`div`,{className:`text-xl font-semibold text-foreground`,children:O})]}),C(`div`,{className:`rounded-lg border border-border p-3`,children:[D(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`Managed`}),D(`div`,{className:`text-xl font-semibold text-foreground`,children:S})]}),C(`div`,{className:`rounded-lg border border-border p-3`,children:[D(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`System`}),D(`div`,{className:`text-xl font-semibold text-foreground`,children:k})]}),C(`div`,{className:`rounded-lg border p-3 ${x>0?`border-destructive/40 bg-destructive/5`:`border-border`}`,children:[C(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle flex items-center gap-1`,children:[x>0&&D(Q,{className:`h-3 w-3 text-destructive`}),` Ghosts`]}),D(`div`,{className:`text-xl font-semibold ${x>0?`text-destructive`:`text-foreground`}`,children:x})]})]}),f.length>0&&C(`div`,{className:`rounded-lg border border-amber-500/40 bg-amber-500/5 p-3`,children:[C(`div`,{className:`flex items-center gap-1 text-[11px] font-semibold text-amber-400 mb-2`,children:[D(U,{className:`h-3 w-3`}),` Recurring ghost parents (`,f.length,`)`]}),D(`div`,{className:`space-y-1.5`,children:f.map(e=>C(`div`,{className:`text-[11px] text-foreground flex items-center justify-between gap-2`,children:[C(`div`,{className:`flex items-center gap-2`,children:[C(`span`,{className:`font-mono text-foreground-subtle`,children:[`ppid `,e.ppid]}),C(`span`,{children:[`→ `,e.children.length,` ghost(s)`]})]}),C(`button`,{type:`button`,disabled:p.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:[D(Q,{className:`h-3 w-3`}),` Kill parent + `,e.children.length]})]},e.ppid))})]}),C(`div`,{className:`flex items-center justify-between gap-2 text-[11px]`,children:[C(`div`,{className:`flex items-center gap-2`,children:[D(`span`,{className:`text-foreground-subtle`,children:`Filter:`}),C(`button`,{type:`button`,className:`px-2 py-0.5 rounded ${i===`all`?`bg-primary text-primary-foreground`:`border border-border text-foreground hover:bg-surface-hover`}`,onClick:()=>a(`all`),children:[`All (`,l.length,`)`]}),C(`button`,{type:`button`,className:`px-2 py-0.5 rounded ${i===`ghost`?`bg-destructive text-destructive-foreground`:`border border-border text-foreground hover:bg-surface-hover`}`,onClick:()=>a(`ghost`),children:[`Ghost only (`,x,`)`]})]}),x>0&&C(`button`,{type:`button`,disabled:p.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:[D(Q,{className:`h-3 w-3`}),` Kill all `,x,` ghost(s)`]})]}),D(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:C(`table`,{className:`w-full text-xs`,children:[D(`thead`,{className:`bg-surface`,children:C(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[D(`th`,{className:`text-left px-3 py-2`,children:`Class`}),D(`th`,{className:`text-right px-3 py-2`,children:`PID`}),D(`th`,{className:`text-right px-3 py-2`,children:`PPID`}),D(`th`,{className:`text-left px-3 py-2`,children:`Addon`}),D(`th`,{className:`text-left px-3 py-2`,children:`Command`}),D(`th`,{className:`text-right px-3 py-2`,children:`CPU%`}),D(`th`,{className:`text-right px-3 py-2`,children:`RSS`}),D(`th`,{className:`text-right px-3 py-2`,children:`Uptime`}),D(`th`,{className:`w-44`})]})}),C(`tbody`,{children:[d.length===0&&D(`tr`,{children:D(`td`,{colSpan:9,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:i===`ghost`?`No ghost processes detected.`:`Scanning…`})}),d.map(e=>C(`tr`,{className:`border-t border-border ${e.classification===`ghost`?`bg-destructive/5`:``}`,children:[D(`td`,{className:`px-3 py-2`,children:D(`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})}),D(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.pid}),C(`td`,{className:`px-3 py-2 text-right font-mono text-foreground-subtle`,children:[e.ppid,e.orphaned?` ⚠`:``]}),D(`td`,{className:`px-3 py-2 text-foreground-subtle text-[11px]`,children:e.addonId??`—`}),D(`td`,{className:`px-3 py-2 font-mono text-[10px] text-foreground-subtle break-all`,children:ue(e.command)}),D(`td`,{className:`px-3 py-2 text-right text-foreground`,children:e.cpuPercent.toFixed(1)}),D(`td`,{className:`px-3 py-2 text-right text-foreground`,children:J(e.memoryRssBytes)}),D(`td`,{className:`px-3 py-2 text-right text-foreground-subtle`,children:le(e.uptimeSec)}),D(`td`,{className:`px-3 py-2 text-right`,children:C(`div`,{className:`inline-flex gap-1`,children:[C(`button`,{type:`button`,disabled:p.isPending||e.classification===`root`||e.classification===`system`,onClick:()=>{h(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:[D(G,{className:`h-3 w-3`}),` Term`]}),C(`button`,{type:`button`,disabled:p.isPending||e.classification===`root`||e.classification===`system`,onClick:()=>{h(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:[D(Q,{className:`h-3 w-3`}),` Kill`]})]})})]},e.pid))]})]})}),p.isError&&C(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[`Kill failed:`,` `,p.error instanceof Error?p.error.message:`unknown`]})]})}function fe({nodeId:e,addonIds:t}){return t.length===0?D(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No addons on this node`}):D(`div`,{className:`w-full py-2`,children:D(Y,{nodeId:e,addonIds:t,level:`global`})})}S();function pe({nodeId:e,addons:t}){let n=T(),{data:r,isLoading:i}=v({nodeId:e}),a=w(()=>{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]),o=m({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCapabilityBindings`]]})}});return a.length===0?D(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No capabilities on this node`}):C(`table`,{className:`w-full text-xs`,children:[D(`thead`,{children:C(`tr`,{className:`text-muted-foreground text-left`,children:[D(`th`,{className:`py-2 font-medium w-1/2`,children:`Capability`}),D(`th`,{className:`py-2 font-medium`,children:`Bound provider`})]})}),D(`tbody`,{children:a.map(({capName:t,providers:n})=>{let a=r?.[t]??n[0]??``,s=n.length===1;return C(`tr`,{className:`border-t border-border/50`,children:[D(`td`,{className:`py-2 font-medium`,children:t}),D(`td`,{className:`py-2`,children:D(`select`,{value:a,onChange:n=>o.mutate({nodeId:e,capName:t,addonId:n.target.value}),disabled:s||o.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:s?`Only one provider installed — choice becomes available once a second addon registers this capability`:void 0,children:n.map(e=>D(`option`,{value:e,children:e},e))})})]},t)})})]})}S();function $(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 me(e){let[t,n]=E(!1),[r,i]=E(e.name),a=T(),s=o({onSuccess:()=>{a.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}}),c=(e.localIps??[]).filter(e=>!e.includes(`:`)),l=(e.localIps??[]).filter(e=>e.includes(`:`)),u=async()=>{if(!r.trim()||r===e.name){n(!1);return}try{await s.mutateAsync({nodeId:e.nodeId,name:r.trim()}),n(!1)}catch(e){console.error(`Rename failed:`,e)}},d=[[`Node ID`,D(`span`,{className:`font-mono text-xs`,children:e.nodeId})],[`Display Name`,t?C(`div`,{className:`flex items-center gap-1.5`,children:[D(`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:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&u(),e.key===`Escape`&&n(!1)},disabled:s.isPending,autoFocus:!0}),D(`button`,{onClick:()=>void u(),disabled:s.isPending,className:`p-0.5 text-success hover:bg-success/10 rounded`,title:`Save`,children:D(L,{className:`h-3.5 w-3.5`})}),D(`button`,{onClick:()=>n(!1),className:`p-0.5 text-muted-foreground hover:bg-muted rounded`,title:`Cancel`,children:D(V,{className:`h-3.5 w-3.5`})})]}):C(`div`,{className:`flex items-center gap-1.5`,children:[D(`span`,{className:`text-xs`,children:e.name}),!e.isHub&&D(`button`,{onClick:()=>{i(e.name),n(!0)},className:`p-0.5 text-muted-foreground hover:text-primary rounded`,title:`Rename`,children:D(A,{className:`h-3 w-3`})})]})],[`Hostname`,D(`span`,{className:`text-xs`,children:e.hostname})],[`Role`,e.isHub?D(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium`,children:`Hub`}):D(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-medium`,children:`Agent`})],[`Root Package`,e.rootPackage?C(`span`,{className:`font-mono text-xs`,children:[e.rootPackage.name,`@`,e.rootPackage.version]}):D(`span`,{className:`text-xs text-muted-foreground`,children:`—`})],[`Platform`,C(`span`,{className:`text-xs`,children:[e.platform,` / `,e.arch]})],[`CPU`,C(`span`,{className:`text-xs`,children:[e.cpuModel??`—`,` (`,e.cpuCores,` cores)`]})],[`Memory`,D(`span`,{className:`text-xs`,children:e.memoryMB>0?`${(e.memoryMB/1024).toFixed(1)} GB`:`—`})],[`Uptime`,D(`span`,{className:`text-xs`,children:$(e.uptime)})],[`Engines`,e.engines.length>0?D(`div`,{className:`flex flex-wrap gap-1`,children:e.engines.map(e=>D(`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(`span`,{className:`text-xs text-muted-foreground`,children:`—`})]];return c.length>0&&d.push([`IPv4`,D(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map((e,t)=>D(`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`,D(`div`,{className:`flex flex-wrap gap-1.5`,children:l.map((e,t)=>D(`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}`))})]),D(`div`,{className:`py-2`,children:D(`table`,{className:`w-full text-sm`,children:D(`tbody`,{children:d.map(([e,t],n)=>C(`tr`,{className:n%2==0?`bg-muted/20`:``,children:[D(`td`,{className:`py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap`,children:e}),D(`td`,{className:`py-1.5 px-2`,children:t})]},e))})})})}S();function he({node:e}){let t=k(),[n,r]=E(`info`),[i,a]=E(!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?C(`div`,{className:`border border-border rounded-xl overflow-hidden`,children:[C(`div`,{className:`flex items-center gap-3 px-4 py-3 bg-muted/30 border-b border-border`,children:[D(`div`,{className:`w-2.5 h-2.5 rounded-full bg-success`}),D(`span`,{className:`text-sm font-semibold`,children:e.name}),C(`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=>D(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium`,children:e},e)),C(`div`,{className:`ml-auto flex gap-3 text-xs text-muted-foreground`,children:[C(`span`,{className:`flex items-center gap-1`,children:[D(P,{className:`h-3 w-3`}),` `,e.cpuPercent,`%`]}),C(`span`,{className:`flex items-center gap-1`,children:[D(Z,{className:`h-3 w-3`}),` `,e.memoryPercent,`%`]})]})]}),D(`div`,{className:`flex border-b border-border px-4`,children:[`info`,`addons`,`forks`,`processes`,`settings`,`capabilities`].map(t=>D(`button`,{onClick:()=>r(t),className:`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`?`Info`:t===`addons`?`Addons (${e.addons.length})`:t===`forks`?`Forks (${o.length})`:t===`processes`?`Processes`:t===`settings`?`Settings`:`Capabilities`},t))}),C(`div`,{className:`px-4 py-2`,children:[n===`info`&&D(me,{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}),n===`addons`&&D(re,{nodeId:e.id,addons:e.addons,isHub:e.isHub}),n===`forks`&&D(ce,{nodeId:e.id,processes:o}),n===`processes`&&D(de,{nodeId:e.id}),n===`settings`&&D(fe,{nodeId:e.id,addonIds:s}),n===`capabilities`&&D(pe,{nodeId:e.id,addons:e.addons})]})]}):C(`div`,{className:`border border-border rounded-xl overflow-hidden opacity-60`,children:[C(`div`,{className:`flex items-center gap-3 px-4 py-3 bg-muted/30`,children:[D(`div`,{className:`w-2.5 h-2.5 rounded-full bg-destructive`}),D(`span`,{className:`text-sm font-semibold`,children:e.name}),C(`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=>D(`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(`span`,{className:`ml-auto text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`})]}),C(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[C(`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`]}),C(`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:[D(G,{className:`h-3 w-3`}),i?`Forgetting…`:`Forget node`]})]})]})}S();function ge({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=x(null);return O(()=>{if(!t)return;let e=i.current?.querySelector(`#node-card-${CSS.escape(t)}`);e&&e.scrollIntoView({behavior:`smooth`,block:`start`})},[t,n]),D(`div`,{ref:i,className:`flex flex-col gap-4`,children:r.map(e=>D(`div`,{id:`node-card-${e.id}`,children:D(he,{node:e})},e.id))})}S();function _e(e){let[t,n]=E(()=>typeof window<`u`?window.matchMedia(e).matches:!1);return O(()=>{let t=window.matchMedia(e),r=e=>n(e.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}function ve(){let{data:e,isLoading:t}=i(void 0,{staleTime:1/0}),[n,r]=E(null);return f(`cluster.topology-snapshot`,e=>{let t=e.data?.nodes;Array.isArray(t)&&r(t)}),{nodes:w(()=>n??e??[],[n,e]),isLoading:t&&!n}}function ye(){let[e,t]=E(`table`),[n,r]=E(void 0),[i,a]=E(0),o=_e(`(max-width: 767px)`),s=o&&e===`graph`?`table`:e,{nodes:c,isLoading:l}=ve(),u=w(()=>q(c),[c]),d=c.filter(e=>e.isOnline).length,f=c.filter(e=>!e.isOnline).length,p=b(e=>{t(`table`),r(e),a(e=>e+1)},[]),m=(n,r,i)=>C(`button`,{onClick:()=>t(n),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${e===n?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[D(i,{className:`h-3.5 w-3.5`}),r]});return C(`div`,{className:`flex flex-col h-full gap-4 p-4`,children:[C(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[C(`div`,{className:`flex items-center gap-2`,children:[d>0&&C(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-success/10 text-success`,children:[d,` online`]}),f>0&&C(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:[f,` offline`]})]}),C(`div`,{className:`flex gap-0.5 p-1 rounded-lg bg-muted`,children:[m(`table`,`Table`,te),!o&&m(`graph`,`Graph`,X)]})]}),l?D(`div`,{className:`flex items-center justify-center flex-1 text-muted-foreground`,children:`Loading cluster topology...`}):s===`graph`?D(K,{graph:u,onOpenNodeDetail:p}):D(`div`,{className:`flex-1 overflow-auto`,children:D(ge,{nodes:c,focusNodeId:n,focusNonce:i})})]})}export{ye as ClusterPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Ai as e,Bt as t,Ct as n,Gt as r,Ht as i,Kt as a,Mi as o,Oi as s,Rt as c,Ut as l,Vt as u,Wt as d,ki as f,sa as p,ta as m,zt as h}from"./src-DUz15ij3.js";import{I as g,Q as _,S as v,W as y,b,o as x,q as S,x as C,z as w}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{R as T}from"./src-B45-uhaF.js";import{t as E}from"./download-iZu8ddva.js";import{i as D,n as O,r as k,t as A}from"./AddLocationWizard-CIqEDdCn.js";import{t as j}from"./plus-CRDyDYzj.js";import{t as M}from"./rotate-cw-DR-mTm0L.js";import{B as ee,F as N,H as P,N as F,S as I,i as L,s as R}from"./index-pSZYK5ny.js";import{t as z}from"./AdminPage-BwmGKnRf.js";import{t as B}from"./format-size-CO9d3C3-.js";import{t as V}from"./AdminTabs-BeF-jlOp.js";var H=P(`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`}]]),te=P(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),ne=P(`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`}]]);_();function U(){let t=x(),n=m(),{data:r,isLoading:i,isError:a}=e({}),c=f(),l=y(()=>c.data??[],[c.data]),[u,d]=S(null),[p,h]=S(null),g=s({onSuccess:()=>{t.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),_=o({onSuccess:()=>{t.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),b=e=>{e.isDefault||_.mutate({id:e.id,type:e.type,providerId:e.providerId,displayName:e.displayName,config:e.config,isDefault:!0})},w=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`})&&g.mutate({id:e.id})},T=y(()=>{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]),E=i||c.isLoading,D=a||c.isError;return v(z,{children:[E&&C(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading locations…`}),D&&C(`div`,{className:`text-xs text-danger`,children:`Failed to load storage locations.`}),!E&&!D&&v(`div`,{className:`space-y-3`,children:[l.length===0&&C(`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.`}),l.map(e=>C(k,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:T.get(e.id)??[],onAdd:e=>d(e),onEdit:e=>h(e),onDelete:e=>{w(e)},onSetDefault:e=>b(e)},e.id))]}),u!==null&&C(A,{initialType:u,onClose:()=>d(null),onCreated:()=>{t.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),d(null)}}),p!==null&&C(O,{location:p,onClose:()=>h(null),onSaved:()=>{t.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),h(null)}})]})}_();var W=[[`backup`,`listDestinations`]],G=[`backup`,`listArchives`];function K({destinationId:e,restoreSupported:n,onOpenRestoreWizard:r}){let i=x(),a=m(),{data:o,isLoading:s,isError:l}=t({destinationId:e}),u=o??[],d=c({onSuccess:()=>{i.invalidateQueries({queryKey:[[...G]]}),i.invalidateQueries({queryKey:W})}}),f=g(async t=>{await a({title:`Delete this archive?`,message:`Permanently deletes "${t.label??t.id}" and frees ${B(t.sizeBytes)}.`,confirmLabel:`Delete`,variant:`danger`})&&d.mutate({destinationId:e,backupId:t.id})},[a,e,d]),[p,h]=S(null),_=g(async t=>{h(t.id);try{let n=localStorage.getItem(`camstack_admin_token`),r={};n&&(r.Authorization=`Bearer ${n}`);let i=await fetch(q(e,t.id),{headers:r});if(!i.ok)throw Error(`download failed: ${i.status} ${i.statusText}`);let a=await i.blob(),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=`${t.label??t.id}.tar.gz`,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o)}finally{h(null)}},[e]),b=y(()=>[...u].toSorted((e,t)=>t.createdAt-e.createdAt),[u]);return s?C(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:`Loading archives…`}):l?C(`div`,{className:`text-xs text-danger py-2`,children:`Failed to read manifest for this destination`}):b.length===0?C(`div`,{className:`text-xs text-foreground-subtle italic py-2`,children:`No archives at this destination yet.`}):C(`div`,{className:`rounded border border-border bg-surface overflow-x-auto`,children:v(`table`,{className:`w-full text-xs min-w-[640px]`,children:[C(`thead`,{children:v(`tr`,{className:`text-foreground-subtle bg-background/30`,children:[C(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`When`}),C(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Label`}),C(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Includes`}),C(`th`,{className:`text-right px-3 py-1.5 font-medium`,children:`Size`}),C(`th`,{className:`text-right px-3 py-1.5 font-medium w-52`,children:`Actions`})]})}),C(`tbody`,{children:b.map(t=>v(`tr`,{className:`border-t border-border hover:bg-primary/5`,children:[C(`td`,{className:`px-3 py-1.5 text-foreground tabular-nums`,children:J(t.createdAt)}),C(`td`,{className:`px-3 py-1.5 text-foreground`,children:t.label??C(`span`,{className:`text-foreground-subtle italic`,children:`—`})}),C(`td`,{className:`px-3 py-1.5 text-foreground-subtle`,children:t.locations.join(`, `)}),C(`td`,{className:`px-3 py-1.5 text-foreground text-right tabular-nums`,children:B(t.sizeBytes)}),C(`td`,{className:`px-3 py-1.5`,children:v(`div`,{className:`flex items-center justify-end gap-1`,children:[v(`button`,{onClick:()=>{_(t)},disabled:p===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:[p===t.id?C(I,{className:`h-3 w-3 animate-spin`}):C(E,{className:`h-3 w-3`}),`Download`]}),n&&r&&v(`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:[C(M,{className:`h-3 w-3`}),`Restore`]}),C(`button`,{onClick:()=>{f(t)},disabled:d.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:d.isPending?C(I,{className:`h-3 w-3 animate-spin`}):C(R,{className:`h-3 w-3`})})]})})]},t.id))})]})})}function q(e,t){return`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function J(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}_();var Y=[{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 X(e){let t=e.trim();for(let e of Y)if(e.cron===t)return e.id;return`custom`}function Z({value:e,onChange:t,previewCount:n=5,disabled:r=!1}){let i=X(e),[a,o]=S(i===`custom`);w(()=>{i!==`custom`&&o(!1)},[i]);let s=ae(e,250),c=l({cron:s,count:n},{enabled:s.trim().length>0}),u=c.data??null,d=e=>{o(!1),t(e.cron)},f=a||i===`custom`;return v(`div`,{className:`space-y-3`,children:[v(`div`,{className:`space-y-1`,children:[C(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Schedule preset`}),v(`div`,{className:`flex flex-wrap gap-1.5`,children:[Y.map(e=>C(`button`,{type:`button`,onClick:()=>d(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)),C(`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 `+(f?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),children:`Custom…`})]})]}),f&&v(`div`,{className:`space-y-1`,children:[C(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Cron expression (5-field POSIX)`}),C(`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`}),v(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Format: `,C(`span`,{className:`font-mono`,children:`minute hour day-of-month month day-of-week`}),` · all times server-local`]})]}),C(re,{cron:s,preview:u,loading:c.isFetching})]})}function re({cron:e,preview:t,loading:n}){return n&&t===null?v(`div`,{className:`flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:[C(I,{className:`h-3 w-3 animate-spin`}),`Validating…`]}):t===null?null:t.ok?t.nextRuns.length===0?C(`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.`}):v(`div`,{className:`space-y-1`,children:[C(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Next runs`}),C(`ul`,{className:`rounded border border-border bg-background/40 divide-y divide-border`,children:t.nextRuns.map((e,t)=>v(`li`,{className:`flex items-center justify-between px-3 py-1.5 text-[11px]`,children:[C(`span`,{className:`text-foreground tabular-nums`,children:new Date(e).toLocaleString()}),C(`span`,{className:`text-foreground-subtle text-[10px] tabular-nums`,children:ie(e)})]},`${e}-${t}`))})]}):C(`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 ie(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 ae(e,t){let[n,r]=S(e),i=y(()=>e,[e]);return w(()=>{let e=setTimeout(()=>r(i),t);return()=>clearTimeout(e)},[i,t]),n}_();var oe=[[`backup`,`listDestinations`]];function se({onCreateAt:e,onOpenRestoreWizard:t}){let{data:n,isLoading:r,isError:i}=u(),a=n??[],[o,s]=S(null),c=e=>{s(t=>t===e?null:e)},l=fe();return r?C(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading destinations…`}):i?C(`div`,{className:`text-xs text-danger`,children:`Failed to load destinations`}):a.length===0?C(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-8 text-center`,children:C(`p`,{className:`text-xs text-foreground-subtle`,children:"No `backups`-typed storage locations registered. Add one in Settings → Storage to begin."})}):C(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:v(`table`,{className:`w-full text-xs min-w-[720px]`,children:[C(`thead`,{children:v(`tr`,{className:`text-foreground-subtle border-b border-border bg-background/40`,children:[C(`th`,{className:`text-left px-3 py-2 font-medium w-6`}),C(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Destination`}),C(`th`,{className:`text-left px-3 py-2 font-medium w-20`,children:`Enabled`}),C(`th`,{className:`text-left px-3 py-2 font-medium w-28`,children:`Retention`}),C(`th`,{className:`text-left px-3 py-2 font-medium w-56`,children:`Schedule`}),C(`th`,{className:`text-left px-3 py-2 font-medium w-44`,children:`Last success`}),C(`th`,{className:`text-right px-3 py-2 font-medium w-44`,children:`Actions`})]})}),C(`tbody`,{children:a.map(n=>{let r=l.get(n.id);return C(ce,{row:n,isOpen:o===n.id,onToggle:()=>c(n.id),onCreateAt:e,liveLastSuccessAt:r?.at,liveLastSuccessSizeBytes:r?.sizeBytes,...t?{onOpenRestoreWizard:t}:{}},n.id)})})]})})}function ce({row:e,isOpen:t,onToggle:n,onCreateAt:r,onOpenRestoreWizard:i,liveLastSuccessAt:o,liveLastSuccessSizeBytes:s}){let c=x(),l=a({onSuccess:()=>{c.invalidateQueries({queryKey:oe})}}),[u,d]=S(String(e.retentionCount));w(()=>{d(String(e.retentionCount))},[e.retentionCount]);let[f,p]=S(!1),m=g(t=>{l.mutate({locationId:e.id,enabled:t,retentionCount:e.retentionCount,...e.label===void 0?{}:{label:e.label},...e.cron===void 0?{}:{cron:e.cron}})},[l,e.id,e.retentionCount,e.label,e.cron]),h=g(()=>{let t=Number.parseInt(u,10);if(Number.isNaN(t)||t<1){d(String(e.retentionCount));return}t!==e.retentionCount&&l.mutate({locationId:e.id,enabled:e.enabled,retentionCount:t,...e.label===void 0?{}:{label:e.label},...e.cron===void 0?{}:{cron:e.cron}})},[l,u,e.id,e.enabled,e.retentionCount,e.label,e.cron]),_=g(t=>{l.mutate({locationId:e.id,enabled:e.enabled,retentionCount:e.retentionCount,...e.label===void 0?{}:{label:e.label},cron:t},{onSuccess:()=>{p(!1)}})},[l,e.id,e.enabled,e.retentionCount,e.label]);return v(b,{children:[v(`tr`,{className:`border-t border-border first:border-t-0 hover:bg-primary/5`,children:[C(`td`,{className:`px-2 py-2`,children:C(`button`,{onClick:n,className:`inline-flex items-center justify-center rounded p-1 text-foreground-subtle hover:bg-primary/10 hover:text-foreground`,title:t?`Hide archives`:`Show archives`,children:C(t?N:F,{className:`h-3.5 w-3.5`})})}),C(`td`,{className:`px-3 py-2`,children:v(`button`,{onClick:n,className:`text-left hover:underline focus:outline-none`,title:`View archives`,children:[C(`div`,{className:`text-foreground font-medium`,children:e.displayName}),v(`div`,{className:`flex items-center gap-1.5 mt-0.5`,children:[C(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5`,children:e.kind}),C(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.id})]})]})}),C(`td`,{className:`px-3 py-2`,children:C(`label`,{className:`inline-flex items-center cursor-pointer`,children:C(`input`,{type:`checkbox`,className:`accent-primary`,checked:e.enabled,disabled:l.isPending,onChange:e=>m(e.target.checked)})})}),C(`td`,{className:`px-3 py-2`,children:C(`input`,{type:`number`,min:1,max:1e3,value:u,disabled:l.isPending,onChange:e=>d(e.target.value),onBlur:h,onKeyDown:t=>{t.key===`Enter`&&t.target.blur(),t.key===`Escape`&&d(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`})}),C(`td`,{className:`px-3 py-2`,children:C(le,{cron:e.cron,nextRunAt:e.nextRunAt,onEdit:()=>p(!0),disabled:l.isPending})}),C(`td`,{className:`px-3 py-2 text-foreground-subtle`,children:(()=>{let t=pe(o,e.lastSuccessAt),n=t===o?s:e.lastSuccessSizeBytes;return t===void 0?C(`span`,{className:`italic`,children:`Never`}):C(me,{at:t,sizeBytes:n})})()}),C(`td`,{className:`px-3 py-2`,children:C(`div`,{className:`flex items-center justify-end gap-1.5`,children:e.triggerSupported&&v(`button`,{onClick:()=>r(e),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`,children:[C(j,{className:`h-3 w-3`}),`Create here`]})})})]}),t&&C(`tr`,{className:`border-t border-border bg-background/30`,children:C(`td`,{colSpan:7,className:`px-4 py-3`,children:C(K,{destinationId:e.id,restoreSupported:e.restoreSupported,...i?{onOpenRestoreWizard:i}:{}})})}),f&&C(de,{destinationName:e.displayName,currentCron:e.cron??``,onSave:_,onClose:()=>p(!1),saving:l.isPending,saveError:l.error instanceof Error?l.error.message:null})]})}function le({cron:e,nextRunAt:t,onEdit:n,disabled:r}){let i=typeof e==`string`&&e.trim().length>0;return v(`button`,{type:`button`,onClick:n,disabled:r,className:`group flex flex-col items-start gap-0.5 text-left rounded px-1.5 py-1 -mx-1.5 hover:bg-primary/5 disabled:opacity-50`,title:`Edit schedule`,children:[v(`div`,{className:`flex items-center gap-1.5`,children:[C(ne,{className:`h-3 w-3 text-foreground-subtle group-hover:text-foreground`}),C(`span`,{className:i?`font-mono text-foreground`:`italic text-foreground-subtle`,children:i?e:`Manual`})]}),i&&t!==void 0&&v(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[`next `,ue(t)]})]})}function ue(e){let t=e-Date.now();if(t<=0)return`imminent`;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 de({destinationName:e,currentCron:t,onSave:n,onClose:r,saving:i,saveError:a}){let[o,s]=S(t);return C(`tr`,{children:C(`td`,{colSpan:7,className:`p-0`,children:C(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:r,children:v(`div`,{className:`w-full max-w-lg rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[v(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[v(`div`,{className:`space-y-0.5`,children:[C(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Schedule`}),v(`p`,{className:`text-xs text-foreground-subtle`,children:[`→ `,e]})]}),C(`button`,{onClick:r,className:`text-foreground-subtle hover:text-foreground`,title:`Close`,children:C(L,{className:`h-4 w-4`})})]}),v(`div`,{className:`p-4`,children:[C(Z,{value:o,onChange:s,disabled:i}),a!==null&&C(`div`,{className:`mt-3 rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:a})]}),v(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3`,children:[C(`button`,{onClick:r,disabled:i,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground disabled:opacity-50`,children:`Cancel`}),C(`button`,{onClick:()=>n(o.trim()),disabled:i||o.trim()===t.trim(),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:i?`Saving…`:`Save`})]})]})})})})}function fe(){let{map:e}=p(T.BackupCompleted,e=>e.destinationId);return y(()=>{let t=new Map;for(let[n,r]of e)t.set(n,{at:Date.now(),sizeBytes:r.sizeMB*1024*1024});return t},[e])}function pe(e,t){return e===void 0?t:t===void 0||e>t?e:t}function me({at:e,sizeBytes:t}){let n=he(e);return v(`span`,{title:y(()=>new Date(e).toLocaleString(),[e]),className:`text-foreground tabular-nums`,children:[n,t!==void 0&&v(`span`,{className:`ml-1 text-foreground-subtle`,children:[`· `,B(t)]})]})}function he(e){let[,t]=S(0);return w(()=>{let e=setInterval(()=>t(e=>e+1),3e4);return()=>clearInterval(e)},[]),ge(e)}function ge(e){let t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);if(a<30)return`${a}d ago`;let o=Math.floor(a/30);return o<12?`${o}mo ago`:`${Math.floor(a/365)}y ago`}_();var _e=[[`backup`,`list`]];function ve({initialDestinationId:e,initialArchiveId:n,onClose:r,onScheduled:i}){let a=x(),[o,s]=S(e&&n?2:1),[c,l]=S(e),[f,p]=S(n),[m,g]=S(new Set),{data:_}=u(),b=_??[],{data:T,isLoading:E}=t({destinationId:c??``},{enabled:!!c}),D=T??[];w(()=>{if(c!==void 0)return;let e=b.filter(e=>e.restoreSupported);e.length===1&&l(e[0].id)},[c,b]);let{data:O}=h({destinationId:c??``,backupId:f??``},{enabled:!!c&&!!f}),k=y(()=>O?.locations??[],[O]);w(()=>{k.length!==0&&g(e=>e.size===0?new Set(k):e)},[k]);let A=d({onSuccess:()=>{a.invalidateQueries({queryKey:_e}),i(),r()}}),j=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},N=!!c&&!!f,P=m.size>0,F=N&&P&&!A.isPending,R=()=>{!c||!f||A.mutate({destinationId:c,backupId:f,locations:[...m]})};return C(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:r,children:v(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[v(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[v(`div`,{className:`space-y-0.5`,children:[C(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Restore Backup`}),v(`p`,{className:`text-xs text-foreground-subtle`,children:[`Step `,o,` of 3 —`,` `,o===1?`pick source`:o===2?`pick locations`:`confirm`]})]}),C(`button`,{onClick:r,className:`text-foreground-subtle hover:text-foreground`,children:C(L,{className:`h-4 w-4`})})]}),o===1&&C(ye,{destinations:b,destinationId:c,onPickDestination:e=>{l(e),p(void 0),g(new Set)},archives:D,archivesLoading:E,archiveId:f,onPickArchive:p}),o===2&&C(be,{locations:k,picked:m,onToggle:j}),o===3&&C(xe,{destinationName:b.find(e=>e.id===c)?.displayName??c??``,archive:D.find(e=>e.id===f),picked:[...m]}),v(`div`,{className:`flex justify-between gap-2 border-t border-border px-4 py-3`,children:[C(`div`,{children:o>1&&v(`button`,{onClick:()=>s(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:[C(ee,{className:`h-3 w-3`}),`Back`]})}),v(`div`,{className:`flex items-center gap-2`,children:[C(`button`,{onClick:r,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),o<3?v(`button`,{disabled:o===1&&!N||o===2&&!P,onClick:()=>s(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`,C(te,{className:`h-3 w-3`})]}):v(`button`,{onClick:R,disabled:!F,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?C(I,{className:`h-3.5 w-3.5 animate-spin`}):C(M,{className:`h-3.5 w-3.5`}),`Schedule Restore`]})]})]})]})})}function ye({destinations:e,destinationId:t,onPickDestination:n,archives:r,archivesLoading:i,archiveId:a,onPickArchive:o}){let s=e.filter(e=>e.restoreSupported);return v(`div`,{className:`p-4 space-y-3`,children:[v(`div`,{className:`space-y-1.5`,children:[C(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Destination`}),v(`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:[C(`option`,{value:``,disabled:!0,children:`Select destination…`}),s.map(e=>v(`option`,{value:e.id,children:[e.displayName,` (`,e.kind,`)`]},e.id))]})]}),v(`div`,{className:`space-y-1.5`,children:[C(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Archive`}),!t&&C(`div`,{className:`text-xs text-foreground-subtle italic`,children:`Pick a destination first.`}),t&&i&&C(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Reading archives…`}),t&&!i&&r.length===0&&C(`div`,{className:`text-xs text-foreground-subtle italic`,children:`No archives available at this destination.`}),t&&r.length>0&&C(`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 v(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${t?`bg-primary/10`:`hover:bg-primary/5`}`,children:[v(`div`,{className:`flex items-center gap-2`,children:[C(`input`,{type:`radio`,name:`archive`,checked:t,onChange:()=>o(e.id),className:`accent-primary`}),v(`div`,{children:[C(`div`,{className:`font-medium text-foreground`,children:e.label??e.id}),C(`div`,{className:`text-[10px] text-foreground-subtle`,children:new Date(e.createdAt).toLocaleString()})]})]}),C(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:B(e.sizeBytes)})]},e.id)})})]})]})}function be({locations:e,picked:t,onToggle:n}){return e.length===0?C(`div`,{className:`p-4`,children:C(`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.`})}):v(`div`,{className:`p-4 space-y-3`,children:[C(`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.`}),v(`div`,{className:`space-y-1.5`,children:[C(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Apply`}),C(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:e.map(e=>v(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[C(`input`,{type:`checkbox`,checked:t.has(e),onChange:()=>n(e),className:`accent-primary`}),C(`span`,{className:`font-mono text-foreground`,children:e}),C(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:Ce(e)})]},e))})]})]})}function xe({destinationName:e,archive:t,picked:n}){return v(`div`,{className:`p-4 space-y-3 text-xs`,children:[C(`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.`}),v(`dl`,{className:`space-y-1.5`,children:[C(Q,{term:`Destination`,value:e}),C(Q,{term:`Archive`,value:t?.label??t?.id??`—`}),t&&C(Q,{term:`Created`,value:`${new Date(t.createdAt).toLocaleString()} · ${B(t.sizeBytes)}`}),C(Q,{term:`Locations`,value:n.length>0?n.join(`, `):`— (full archive)`})]})]})}function Q({term:e,value:t}){return v(`div`,{className:`flex justify-between gap-3`,children:[C(`dt`,{className:`text-foreground-subtle`,children:e}),C(`dd`,{className:`text-foreground font-mono text-right truncate`,children:t})]})}var Se={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function Ce(e){return Se[e]??``}_();var $=[[`backup`,`list`]],we=[[`backup`,`listLocations`]];function Te(){let e=x(),t=m(),a=r({onSuccess:()=>{e.invalidateQueries({queryKey:$}),e.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),e.invalidateQueries({queryKey:[[`backup`,`listArchives`]]})}}),o=n(),[s,c]=S(null),{data:l}=i(void 0,{enabled:s!==null,retry:1}),[u,d]=S(null),[f,p]=S(!1),[h,g]=S(!1),[_,y]=S(!1),b=async()=>{await t({title:`Restart server now?`,message:`Active connections will drop and the apply-backup hook will run before boot.`,confirmLabel:`Restart`,variant:`warning`})&&o.mutate({confirm:!0})};return v(z,{children:[v(`div`,{className:`flex items-center justify-end gap-2 flex-wrap`,children:[v(`button`,{onClick:()=>p(!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:[C(M,{className:`h-3.5 w-3.5`}),`Restore…`]}),v(`button`,{onClick:()=>y(!0),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:[C(j,{className:`h-3.5 w-3.5`}),`Add destination`]})]}),h&&C(`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:v(`div`,{className:`flex items-center justify-between gap-3`,children:[v(`div`,{className:`flex items-center gap-2`,children:[C(M,{className:`h-3.5 w-3.5`}),C(`span`,{children:`Restore scheduled. Restart the server to apply.`})]}),v(`button`,{onClick:()=>{b()},disabled:o.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:[o.isPending?C(I,{className:`h-3.5 w-3.5 animate-spin`}):C(M,{className:`h-3.5 w-3.5`}),`Restart Now`]})]})}),C(se,{onCreateAt:e=>c(e),onOpenRestoreWizard:e=>d(e)}),s&&C(Ee,{destination:s,locations:l,onClose:()=>c(null),onSubmit:(t,n)=>{a.mutate({destinations:[s.id],locations:t,label:n||void 0},{onSuccess:()=>{c(null),e.invalidateQueries({queryKey:we})}})},submitting:a.isPending}),(u||f)&&C(ve,{...u?{initialDestinationId:u.destinationId,initialArchiveId:u.archiveId}:{},onClose:()=>{d(null),p(!1)},onScheduled:()=>g(!0)}),_&&C(A,{initialType:`backups`,onClose:()=>y(!1),onCreated:()=>{y(!1),e.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]})}})]})}function Ee({destination:e,locations:t,onClose:n,onSubmit:r,submitting:i}){let a=(t??[]).filter(e=>e.present),[o,s]=S(``),[c,l]=S(null),u=c??new Set(a.map(e=>e.name)),d=e=>{l(t=>{let n=new Set(t??a.map(e=>e.name));return n.has(e)?n.delete(e):n.add(e),n})};return C(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:n,children:v(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[v(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[v(`div`,{className:`space-y-0.5`,children:[C(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Create Backup`}),v(`p`,{className:`text-xs text-foreground-subtle`,children:[`→ `,e.displayName]})]}),C(`button`,{onClick:n,className:`text-foreground-subtle hover:text-foreground`,children:C(L,{className:`h-4 w-4`})})]}),v(`div`,{className:`p-4 space-y-3`,children:[v(`div`,{className:`space-y-1`,children:[C(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Label (optional)`}),C(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:`pre-upgrade`,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`})]}),v(`div`,{className:`space-y-1.5`,children:[C(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Include`}),v(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:[t===void 0&&v(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground-subtle`,children:[C(I,{className:`h-3.5 w-3.5 animate-spin`}),`Calculating sizes…`]}),t!==void 0&&a.length===0&&C(`div`,{className:`px-3 py-2 text-xs text-foreground-subtle italic`,children:`Nothing to back up.`}),a.map(e=>v(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[v(`div`,{className:`flex items-center gap-2`,children:[C(`input`,{type:`checkbox`,checked:u.has(e.name),onChange:()=>d(e.name),className:`accent-primary`}),C(`span`,{className:`font-mono text-foreground`,children:e.name})]}),v(`div`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[B(e.sizeBytes),` · `,e.fileCount,` files`]})]},e.name))]})]})]}),v(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3`,children:[C(`button`,{onClick:n,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),v(`button`,{onClick:()=>r(Array.from(u),o.trim()),disabled:i||t===void 0||u.size===0,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:[i?C(I,{className:`h-3.5 w-3.5 animate-spin`}):C(H,{className:`h-3.5 w-3.5`}),i?`Creating…`:`Create`]})]})]})})}function De(){return C(`div`,{className:`flex flex-col p-4`,children:C(V,{tabs:[{id:`storage`,label:`Storage`,icon:D,content:C(U,{})},{id:`backup`,label:`Backup`,icon:H,content:C(Te,{})}]})})}export{De as DataPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$n as e,Da as t,Dn as n,Ea as r,Gn as i,Jn as a,Kn as o,Na as s,Oa as c,Pa as l,Qn as u,Ta as d,Un as f,Wn as p,Xn as m,Yn as h,Zn as g,er as _,ja as v,ka as y,qn as b,tr as x,wa as S}from"./src-DUz15ij3.js";import{K as C,Q as w,S as T,W as E,b as D,o as O,q as k,x as A,z as j}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 M}from"./pencil-DL1TJsTc.js";import{t as N}from"./plus-CRDyDYzj.js";import{t as ee}from"./sparkles-Uqh90jkF.js";import{t as te}from"./square-check-big-DHo5VpxB.js";import{t as ne}from"./square-DeI3vDTo.js";import{F as P,H as F,I,L as re,N as L,S as R,h as ie,i as z,s as B}from"./index-pSZYK5ny.js";import{t as V}from"./AdminPage-BwmGKnRf.js";var ae=F(`crop`,[[`path`,{d:`M6 2v14a2 2 0 0 0 2 2h14`,key:`ron5a4`}],[`path`,{d:`M18 22V8a2 2 0 0 0-2-2H2`,key:`7s9ehn`}]]),oe=F(`image-off`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),H=F(`scan`,[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}]]),U=F(`user-check`,[[`path`,{d:`m16 11 2 2 4-4`,key:`9rsbq5`}],[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),se=F(`user-round`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]),ce=F(`user-x`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`17`,x2:`22`,y1:`8`,y2:`13`,key:`3nzzx3`}],[`line`,{x1:`22`,x2:`17`,y1:`8`,y2:`13`,key:`1swrse`}]]);w();var W=[[`faceGallery`]];function G({identityId:e}){let t=O(),{data:n,isLoading:r}=h({identityId:e}),i=g();function a(n){i.mutate({identityId:e,sampleId:n.id},{onSettled:()=>{t.invalidateQueries({queryKey:W})}})}return r?T(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,children:[A(R,{className:`h-3.5 w-3.5 animate-spin`}),`Loading samples…`]}):!n||n.length===0?A(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No samples yet.`}):A(`div`,{className:`mt-2 grid grid-cols-4 gap-2 sm:grid-cols-6 md:grid-cols-8`,children:n.map(e=>T(`div`,{className:`group relative aspect-square overflow-hidden rounded-md border border-border bg-surface`,children:[e.base64?A(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Sample`,className:`h-full w-full object-cover`}):A(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:A(se,{className:`h-6 w-6`})}),A(`button`,{type:`button`,onClick:()=>a(e),disabled:i.isPending,className:`absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 transition-opacity group-hover:opacity-100 disabled:cursor-not-allowed`,"aria-label":`Remove sample`,children:A(z,{className:`h-4 w-4 text-white`})})]},e.id))})}function K({identity:e,expanded:n,onToggle:i}){let a=O(),[f,p]=k(``),[m,h]=k(!1),[g,_]=k(!1),b=u(),x=o();function C(){p(e.name),h(!0)}function w(){h(!1),p(``)}function E(){let t=f.trim();if(!t||t===e.name){w();return}b.mutate({id:e.id,name:t},{onSettled:()=>{a.invalidateQueries({queryKey:W}),w()}})}function j(){x.mutate({id:e.id},{onSettled:()=>{a.invalidateQueries({queryKey:W}),_(!1)}})}return T(`div`,{className:`rounded-md border border-border bg-surface`,children:[T(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[A(`div`,{className:`h-8 w-8 shrink-0 overflow-hidden rounded-full border border-border bg-surface-hover`,children:e.coverBase64?A(`img`,{src:`data:image/jpeg;base64,${e.coverBase64}`,alt:e.name,className:`h-full w-full object-cover`}):A(`div`,{className:`flex h-full w-full items-center justify-center`,children:A(se,{className:`h-4 w-4 text-foreground-subtle`})})}),A(`div`,{className:`flex flex-1 min-w-0 items-center gap-2`,children:m?T(D,{children:[A(v,{value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&E(),e.key===`Escape`&&w()},className:`h-6 text-xs`,autoFocus:!0}),A(`button`,{type:`button`,onClick:E,disabled:b.isPending,className:`text-success hover:text-success/80 disabled:opacity-50`,"aria-label":`Confirm rename`,children:A(I,{className:`h-3.5 w-3.5`})}),A(`button`,{type:`button`,onClick:w,className:`text-foreground-subtle hover:text-foreground`,"aria-label":`Cancel rename`,children:A(z,{className:`h-3.5 w-3.5`})})]}):A(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name})}),A(s,{variant:`default`,className:`text-[10px]`,children:e.sampleCount}),!m&&T(`div`,{className:`flex items-center gap-1`,children:[A(`button`,{type:`button`,onClick:C,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground`,"aria-label":`Rename`,children:A(M,{className:`h-3.5 w-3.5`})}),A(`button`,{type:`button`,onClick:()=>_(!0),className:`p-1 rounded hover:bg-danger/10 text-foreground-subtle hover:text-danger`,"aria-label":`Delete`,children:A(B,{className:`h-3.5 w-3.5`})})]}),A(`button`,{type:`button`,onClick:i,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":n?`Collapse`:`Expand`,children:A(n?P:L,{className:`h-3.5 w-3.5`})})]}),n&&A(`div`,{className:`border-t border-border px-3 pb-3 pt-2`,children:A(G,{identityId:e.id})}),A(S,{open:g,onOpenChange:e=>!e&&_(!1),children:T(d,{children:[T(c,{children:[A(y,{children:`Delete person`}),T(r,{children:[`Delete `,A(`strong`,{children:e.name}),` and all their samples? This cannot be undone.`]})]}),T(t,{children:[A(l,{variant:`secondary`,onClick:()=>_(!1),children:`Cancel`}),T(l,{variant:`danger`,onClick:j,disabled:x.isPending,children:[x.isPending?A(R,{className:`h-3.5 w-3.5 animate-spin`}):null,`Delete`]})]})]})})]})}function q(){let e=O(),[t,n]=k(``),r=p();function i(){let i=t.trim();i&&r.mutate({name:i},{onSettled:()=>{e.invalidateQueries({queryKey:W}),n(``)}})}return T(`div`,{className:`flex items-center gap-2 pt-2`,children:[A(v,{placeholder:`New person name…`,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i()},className:`h-7 text-xs flex-1`}),T(l,{variant:`primary`,size:`sm`,onClick:i,disabled:r.isPending||!t.trim(),children:[r.isPending?A(R,{className:`h-3.5 w-3.5 animate-spin`}):A(N,{className:`h-3.5 w-3.5`}),`Add`]})]})}function J(){let{data:e,isLoading:t}=a(),[n,r]=k(null);function i(e){r(t=>t===e?null:e)}return t?T(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[A(R,{className:`h-4 w-4 animate-spin`}),`Loading people…`]}):T(`div`,{className:`space-y-2`,children:[(!e||e.length===0)&&A(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No people enrolled yet. Add one below.`}),e?.map(e=>A(K,{identity:e,expanded:n===e.id,onToggle:()=>i(e.id)},e.id)),A(q,{})]})}function le(e){return e.base64===void 0||e.base64.length===0}function ue(e){return e.filter(le).map(e=>e.faceId)}function de(e){let t=0;for(let n of e)le(n)&&(t+=1);return t}var fe={fromMs:null,toMs:null},Y=36e5,X=24*Y;function Z(e,t){switch(e){case`24h`:return{fromMs:t-X,toMs:null};case`7d`:return{fromMs:t-7*X,toMs:null};case`30d`:return{fromMs:t-30*X,toMs:null};case`all`:return fe}}function Q(e){return e.fromMs!==null||e.toMs!==null}function pe(e,t){return Q(t)?e.filter(e=>!(t.fromMs!==null&&e.timestamp<t.fromMs||t.toMs!==null&&e.timestamp>t.toMs)):[...e]}function me(e,t){return t.size===0?[...e]:e.filter(e=>t.has(e.deviceId))}function he(e){let t=new Set,n=[];for(let r of e)t.has(r.deviceId)||(t.add(r.deviceId),n.push(r.deviceId));return n}function ge(e){if(!e)return null;let t=Date.parse(`${e}T00:00:00`);return Number.isNaN(t)?null:t}function _e(e){if(!e)return null;let t=Date.parse(`${e}T23:59:59.999`);return Number.isNaN(t)?null:t}function ve(e,t){if(!Number.isFinite(e)||e<=0)return`—`;let n=t-e;return n<6e4?`just now`:n<Y?`${String(Math.floor(n/6e4))}m ago`:n<X?`${String(Math.floor(n/Y))}h ago`:n<7*X?`${String(Math.floor(n/X))}d ago`:new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function ye(e){return!Number.isFinite(e)||e<=0?`—`:new Date(e).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}w();function be({cameras:e,selected:t,onChange:n}){let[r,i]=k(!1),a=C(null);j(()=>{if(!r)return;function e(e){a.current&&e.target instanceof Node&&!a.current.contains(e.target)&&i(!1)}function t(e){e.key===`Escape`&&i(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);function o(e){let r=new Set(t);r.has(e)?r.delete(e):r.add(e),n(r)}let s=t.size,c=s===0?`All cameras`:s===1?e.find(e=>t.has(e.id))?.name??`1 camera`:`${String(s)} cameras`;return T(`div`,{ref:a,className:`relative`,children:[T(`button`,{type:`button`,onClick:()=>i(e=>!e),disabled:e.length===0,className:`flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs transition-colors disabled:opacity-40 ${s>0?`border-primary/40 bg-primary/8 text-primary`:`border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[A(re,{className:`h-3.5 w-3.5`}),A(`span`,{className:`max-w-[10rem] truncate`,children:c}),A(P,{className:`h-3 w-3 opacity-70`})]}),r&&T(`div`,{className:`absolute left-0 z-30 mt-1 max-h-64 w-[min(15rem,calc(100vw-1.5rem))] overflow-y-auto rounded-md border border-border bg-surface p-1 shadow-lg shadow-black/30`,children:[s>0&&A(`button`,{type:`button`,onClick:()=>n(new Set),className:`mb-1 w-full rounded px-2 py-1 text-left text-[11px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:`Clear selection`}),e.map(e=>{let n=t.has(e.id);return T(`button`,{type:`button`,onClick:()=>o(e.id),className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs transition-colors ${n?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[A(`span`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border ${n?`border-primary bg-primary text-white`:`border-border`}`,children:n&&A(I,{className:`h-2.5 w-2.5`})}),A(`span`,{className:`truncate`,children:e.name})]},e.id)})]})]})}w();var xe=[{label:`24h`,value:`24h`},{label:`7d`,value:`7d`},{label:`30d`,value:`30d`},{label:`All`,value:`all`}];function Se({onChange:e}){let[t,n]=k(`all`),[r,i]=k(``),[a,o]=k(``);function s(t){n(t),i(``),o(``),e(Z(t,Date.now()))}function c(t,r){n(`custom`),i(t),o(r),e({fromMs:ge(t),toMs:_e(r)})}let l=`rounded-md border border-border bg-surface px-2 py-1.5 text-[11px] text-foreground outline-none focus:border-primary [color-scheme:light] dark:[color-scheme:dark]`;return T(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[A(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:xe.map(e=>A(`button`,{type:`button`,onClick:()=>s(e.value),className:`rounded px-2.5 py-1 text-[11px] transition-colors ${t===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.label},e.value))}),T(`div`,{className:`flex items-center gap-1`,children:[A(`input`,{type:`date`,"aria-label":`From date`,value:r,max:a||void 0,onChange:e=>c(e.target.value,a),className:`${l} ${t===`custom`&&r?`border-primary/50`:``}`}),A(`span`,{className:`text-[11px] text-foreground-subtle`,children:`→`}),A(`input`,{type:`date`,"aria-label":`To date`,value:a,min:r||void 0,onChange:e=>c(r,e.target.value),className:`${l} ${t===`custom`&&a?`border-primary/50`:``}`})]})]})}w();var Ce=2.6;function we({src:e,alt:t,className:n,overlay:r,fit:i=`contain`}){let[a,o]=k(!1),[s,c]=k(`50% 50%`);function l(e){if(!a){let t=e.currentTarget.getBoundingClientRect(),n=(e.clientX-t.left)/t.width*100,r=(e.clientY-t.top)/t.height*100;c(`${String(n)}% ${String(r)}%`)}o(e=>!e)}let u=i===`natural`;return A(`div`,{className:`relative overflow-hidden bg-background ${n??``}`,onClick:l,children:T(`div`,{className:`relative select-none transition-transform duration-200 ease-out ${u?`w-full`:`h-full w-full`} ${a?`cursor-zoom-out`:`cursor-zoom-in`}`,style:{transformOrigin:s,transform:a?`scale(${String(Ce)})`:`scale(1)`},children:[A(`img`,{src:e,alt:t,draggable:!1,className:u?`block h-auto w-full object-contain`:`h-full w-full object-contain`}),r]})})}w();function Te(e){let t=e.filter(e=>e.base64.length>0);return t.length===0?null:t.find(e=>/crop|face/i.test(e.kind))??t[0]}function $({label:e,value:t}){return T(`div`,{className:`flex items-baseline justify-between gap-3 py-1.5 border-b border-border/60 last:border-0`,children:[A(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:e}),A(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-foreground`,children:t})]})}function Ee({box:e}){return A(`div`,{className:`pointer-events-none absolute rounded-[3px] border-2 border-primary shadow-[0_0_0_9999px_rgba(0,0,0,0.28)]`,style:{left:`${String(e.x*100)}%`,top:`${String(e.y*100)}%`,width:`${String(e.width*100)}%`,height:`${String(e.height*100)}%`},children:A(`span`,{className:`absolute -top-4 left-0 rounded bg-primary px-1 text-[9px] font-semibold uppercase tracking-wide text-white`,children:`Face`})})}function De({face:e,cameraName:t,onClose:n,onAssign:r,onUnassign:i,onDelete:a,actionsPending:o}){let{data:s,isFetching:c}=b({faceId:e?.faceId??``},{enabled:e!==null}),[u,f]=k(`frame`),p=E(()=>{let t=Te(s??[]);return t?`data:image/jpeg;base64,${t.base64}`:e?.base64?`data:image/jpeg;base64,${e.base64}`:null},[s,e]);if(e===null)return null;let m=typeof e.keyFrameUrl==`string`&&e.keyFrameUrl.length>0,h=m&&u===`frame`,g=e.assigned?e.identityName??`Assigned`:e.recognizedIdentityId?`${e.identityName??`Recognized`} (suggested)`:`Unassigned`;return A(S,{open:!0,onOpenChange:e=>!e&&n(),children:T(d,{width:`lg`,"aria-label":`Face detail`,className:`flex max-h-[92dvh] flex-col gap-0 overflow-hidden p-0 bottom-0 left-0 right-0 top-auto w-full max-w-full translate-x-0 translate-y-0 rounded-b-none md:bottom-auto md:left-1/2 md:right-auto md:top-1/2 md:w-[calc(100vw-2rem)] md:max-w-xl md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-lg md:max-h-[calc(100dvh-2rem)]`,children:[T(`header`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-border px-4 py-3`,children:[T(`div`,{className:`min-w-0`,children:[A(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:`Face detail`}),A(`div`,{className:`mt-0.5 truncate text-[11px] text-foreground-subtle`,children:t})]}),A(`button`,{type:`button`,onClick:n,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:A(z,{className:`h-4 w-4`})})]}),T(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 py-3`,children:[m&&T(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5 text-xs`,children:[T(`button`,{type:`button`,onClick:()=>f(`frame`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${u===`frame`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[A(H,{className:`h-3.5 w-3.5`}),` Full frame`]}),T(`button`,{type:`button`,onClick:()=>f(`crop`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${u===`crop`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[A(ae,{className:`h-3.5 w-3.5`}),` Crop`]})]}),h&&e.keyFrameUrl?A(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:A(we,{src:e.keyFrameUrl,alt:`Full frame with detected face`,fit:`natural`,className:`w-full`,overlay:e.bbox?A(Ee,{box:e.bbox}):void 0})}):p?T(`div`,{className:`relative aspect-square w-full overflow-hidden rounded-lg border border-border`,children:[A(we,{src:p,alt:`Detected face`,className:`h-full w-full`}),c&&A(`div`,{className:`absolute right-2 top-2 rounded-full bg-black/50 p-1 text-white`,children:A(R,{className:`h-3.5 w-3.5 animate-spin`})})]}):T(`div`,{className:`flex aspect-square w-full flex-col items-center justify-center gap-1.5 rounded-lg border border-border bg-warning/5 text-foreground-subtle`,children:[A(oe,{className:`h-8 w-8 text-warning/70`}),A(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-warning/80`,children:`No image`}),A(`span`,{className:`px-6 text-center text-[10px] text-foreground-subtle`,children:`The crop media for this face could not be resolved (a pre-fix orphan). Safe to delete.`})]}),T(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-1`,children:[A($,{label:`Camera`,value:t}),A($,{label:`Captured`,value:ye(e.timestamp)}),A($,{label:`Track`,value:e.trackId}),A($,{label:`Identity`,value:g})]})]}),T(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[e.assigned?T(l,{variant:`secondary`,onClick:()=>i(e.faceId),disabled:o,children:[A(ce,{className:`h-3.5 w-3.5`}),` Detach`]}):T(l,{variant:`primary`,onClick:()=>r(e.faceId),disabled:o,children:[A(U,{className:`h-3.5 w-3.5`}),` Assign`]}),T(l,{variant:`secondary`,onClick:()=>a(e.faceId),disabled:o,children:[A(B,{className:`h-3.5 w-3.5`}),` Delete`]})]})]})})}w();var Oe=[[`faceGallery`]],ke=500;function Ae({faceIds:e,identities:n,onDone:i}){let a=O(),o=f(),s=p(),[u,m]=k(``),[h,g]=k(!1),[_,b]=k(null),x=e!==null&&e.length>0,C=e?.length??0;function w(){g(!1),m(``),b(null)}function E(){w(),i()}function D(t){!e||e.length===0||o.mutate({faceIds:[...e],identityId:t},{onSettled:()=>{a.invalidateQueries({queryKey:Oe}),E()}})}function j(){!e||!u.trim()||s.mutate({name:u.trim()},{onSuccess:e=>{e?.id&&D(e.id)},onError:()=>{a.invalidateQueries({queryKey:Oe}),E()}})}let M=o.isPending||s.isPending;return A(S,{open:x,onOpenChange:e=>!e&&E(),children:T(d,{children:[T(c,{children:[A(y,{children:C>1?`Assign ${String(C)} faces to person`:`Assign face to person`}),A(r,{children:`Select an existing person or create a new one.`})]}),A(`div`,{className:`space-y-1 max-h-56 overflow-y-auto`,children:n.map(e=>T(`button`,{type:`button`,onClick:()=>b(e.id),className:`w-full rounded-md px-3 py-2 text-left text-xs transition-colors ${_===e.id?`bg-primary/12 text-primary`:`hover:bg-surface-hover text-foreground`}`,children:[A(`span`,{className:`font-medium`,children:e.name}),T(`span`,{className:`ml-2 text-foreground-subtle`,children:[e.sampleCount,` samples`]})]},e.id))}),h?A(`div`,{className:`flex items-center gap-2 pt-2 border-t border-border`,children:A(v,{placeholder:`New person name…`,value:u,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&j()},autoFocus:!0,className:`flex-1`})}):A(`button`,{type:`button`,onClick:()=>{b(null),g(!0)},className:`mt-2 w-full rounded-md border border-dashed border-border px-3 py-2 text-left text-xs text-foreground-subtle hover:border-primary hover:text-primary transition-colors`,children:`+ New person…`}),T(t,{children:[A(l,{variant:`secondary`,onClick:E,disabled:M,children:`Cancel`}),h?T(l,{variant:`primary`,onClick:j,disabled:M||!u.trim(),children:[M&&A(R,{className:`h-3.5 w-3.5 animate-spin`}),`Create & assign`]}):T(l,{variant:`primary`,onClick:()=>_&&D(_),disabled:M||!_,children:[M&&A(R,{className:`h-3.5 w-3.5 animate-spin`}),`Assign`,C>1?` ${String(C)}`:``]})]})]})})}function je({face:e,cameraName:t,nowMs:n,selected:r,onToggleSelect:a,onAssign:o,onOpenDetail:s}){let c=O(),l=_(),u=i(),d=()=>{c.invalidateQueries({queryKey:Oe})},f=()=>s(e.faceId);return T(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden ${r?`border-primary ring-1 ring-primary`:`border-border`}`,children:[T(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[e.base64?A(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Face from ${t}`,onClick:f,className:`h-full w-full cursor-zoom-in object-cover`}):T(`button`,{type:`button`,onClick:f,className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,title:`No crop image — the face's crop media is missing (a pre-fix orphan). Safe to delete.`,children:[A(oe,{className:`h-7 w-7 text-warning/70`}),A(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}),A(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),a(e.faceId)},className:`absolute left-0 top-0 z-10 rounded-br-md bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":r?`Deselect`:`Select`,children:r?A(te,{className:`h-4 w-4 text-primary`}):A(ne,{className:`h-4 w-4`})})]}),T(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[A(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:t,children:t}),A(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:ve(e.timestamp,n)}),e.identityName&&A(`p`,{className:`text-[10px] font-medium text-primary truncate`,title:e.identityName,children:e.identityName})]}),T(`div`,{className:`mt-1 flex items-center gap-0.5 border-t border-border/60 px-1 py-0.5`,children:[e.assigned?A(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),l.mutate({faceId:e.faceId},{onSettled:d})},disabled:l.isPending,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-warning/10 hover:text-warning disabled:opacity-40`,"aria-label":`Detach face`,title:`Detach`,children:l.isPending?A(R,{className:`h-4 w-4 animate-spin`}):A(ce,{className:`h-4 w-4`})}):A(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),o(e.faceId)},className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-primary/10 hover:text-primary`,"aria-label":`Assign face to person`,title:`Assign to person`,children:A(U,{className:`h-4 w-4`})}),A(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),u.mutate({faceId:e.faceId},{onSettled:d})},disabled:u.isPending,className:`ml-auto rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":`Delete face`,title:`Delete face`,children:u.isPending?A(R,{className:`h-4 w-4 animate-spin`}):A(B,{className:`h-4 w-4`})})]})]})}var Me=[{label:`All`,value:`all`},{label:`Unassigned`,value:`unassigned`},{label:`Recognized`,value:`recognized`}];function Ne(){let t=O(),[r,o]=k(`all`),[s,c]=k(fe),[u,d]=k(new Set),[p,h]=k(new Set),[g,v]=k(null),[y,b]=k(!1),[S,C]=k(null),{data:w,isLoading:D}=m({limit:ke,filter:r}),{data:j=[]}=a(),{data:M}=n({}),{data:N,isFetching:te}=e({threshold:.5,minClusterSize:2,limit:20},{enabled:y}),ne=f(),P=_(),F=x(),I=i(),re=Date.now(),L=w??[],ie=E(()=>{let e=new Map;for(let t of M??[])e.set(t.id,t.name);return e},[M]),V=e=>ie.get(e)??`Camera #${String(e)}`,ae=E(()=>he(L).map(e=>({id:e,name:V(e)})).sort((e,t)=>e.name.localeCompare(t.name)),[L,ie]),H=E(()=>me(pe(L,s),u),[L,s,u]),W=E(()=>new Map(L.map(e=>[e.faceId,e])),[L]),G=E(()=>de(H),[H]),K=S===null?null:W.get(S)??null,q=()=>{t.invalidateQueries({queryKey:Oe})},J=()=>h(new Set);function le(e){h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function Y(e){h(t=>{let n=new Set(t);for(let t of e)n.add(t);return n})}function X(){Y(ue(H))}let Z=[...p],Q=ne.isPending||F.isPending||I.isPending,ge=P.isPending||I.isPending;function _e(){Z.length!==0&&F.mutate({faceIds:Z},{onSettled:()=>{q(),J()}})}function ve(){Z.length!==0&&Promise.allSettled(Z.map(e=>I.mutateAsync({faceId:e}))).then(()=>{q(),J()})}function ye(e){C(null),v([e])}function xe(e){P.mutate({faceId:e},{onSettled:q}),C(null)}function Ce(e){I.mutate({faceId:e},{onSettled:q}),C(null)}let we=H.length!==L.length;return T(`div`,{className:`relative space-y-3`,children:[T(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[A(`div`,{className:`flex items-center gap-1`,children:Me.map(e=>A(`button`,{type:`button`,onClick:()=>o(e.value),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${r===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.label},e.value))}),A(Se,{onChange:c}),A(be,{cameras:ae,selected:u,onChange:d}),T(`button`,{type:`button`,onClick:()=>b(e=>!e),className:`flex items-center gap-1 rounded-md px-2.5 py-1 text-xs transition-colors ${y?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[A(ee,{className:`h-3.5 w-3.5`}),` Similar groups`]}),!D&&G>0&&T(`button`,{type:`button`,onClick:X,className:`ml-auto flex items-center gap-1 rounded-md px-2.5 py-1 text-xs text-warning/90 transition-colors hover:bg-warning/10`,title:`Select every visible face whose crop image is missing so you can delete the orphans in one pass`,children:[A(oe,{className:`h-3.5 w-3.5`}),` Select `,G,` crop-less`]}),!D&&A(`span`,{className:`text-[10px] text-foreground-subtle ${G>0?`ml-2`:`ml-auto`}`,children:we?`${String(H.length)} of ${String(L.length)} faces`:`${String(H.length)} face${H.length===1?``:`s`}`})]}),p.size>0&&T(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[T(`span`,{className:`text-xs font-medium text-foreground`,children:[p.size,` selected`]}),T(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[T(l,{variant:`primary`,onClick:()=>v(Z),disabled:Q,children:[A(U,{className:`h-3.5 w-3.5`}),` Assign`]}),T(l,{variant:`secondary`,onClick:_e,disabled:Q,children:[F.isPending?A(R,{className:`h-3.5 w-3.5 animate-spin`}):A(ce,{className:`h-3.5 w-3.5`}),` `,`Detach`]}),T(l,{variant:`secondary`,onClick:ve,disabled:Q,children:[A(B,{className:`h-3.5 w-3.5`}),` Delete`]}),A(l,{variant:`ghost`,onClick:J,disabled:Q,children:A(z,{className:`h-3.5 w-3.5`})})]})]}),y&&T(`div`,{className:`rounded-md border border-border bg-surface p-3`,children:[A(`p`,{className:`mb-2 text-xs font-medium text-foreground`,children:`Look-alike groups`}),te?T(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[A(R,{className:`h-4 w-4 animate-spin`}),` Finding similar faces…`]}):!N||N.length===0?A(`p`,{className:`text-xs text-foreground-subtle`,children:`No look-alike groups found among unassigned faces.`}):A(`div`,{className:`space-y-2`,children:N.map(e=>T(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md bg-surface-hover/50 p-2`,children:[A(`div`,{className:`flex -space-x-1.5`,children:e.faceIds.slice(0,6).map(e=>{let t=W.get(e);return A(`div`,{className:`h-8 w-8 overflow-hidden rounded border border-border bg-surface`,children:t?.base64?A(`img`,{src:`data:image/jpeg;base64,${t.base64}`,alt:``,className:`h-full w-full object-cover`}):A(se,{className:`h-full w-full p-1.5 text-foreground-subtle`})},e)})}),T(`span`,{className:`text-xs text-foreground-subtle`,children:[e.size,` faces · `,Math.round(e.cohesion*100),`% alike`]}),T(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[A(l,{variant:`secondary`,onClick:()=>Y(e.faceIds),children:`Select group`}),T(l,{variant:`primary`,onClick:()=>v(e.faceIds),children:[A(U,{className:`h-3.5 w-3.5`}),` Assign all`]})]})]},e.representativeFaceId))})]}),D&&T(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[A(R,{className:`h-4 w-4 animate-spin`}),` Loading faces…`]}),!D&&H.length===0&&A(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:L.length>0?`No faces match the current date / camera filters.`:`No faces found for this filter.`}),!D&&H.length>0&&A(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(6.5rem,1fr))] gap-2`,children:H.map(e=>A(je,{face:e,cameraName:V(e.deviceId),nowMs:re,selected:p.has(e.faceId),onToggleSelect:le,onAssign:e=>v([e]),onOpenDetail:C},e.faceId))}),A(De,{face:K,cameraName:K?V(K.deviceId):``,onClose:()=>C(null),onAssign:ye,onUnassign:xe,onDelete:Ce,actionsPending:ge}),A(Ae,{faceIds:g,identities:j,onDone:()=>{v(null),J()}})]})}function Pe(){return A(V,{icon:ie,title:`Detection Intelligence`,subtitle:`Manage enrolled identities and assign detected face crops to people.`,children:T(`section`,{className:`space-y-3`,children:[T(`div`,{children:[A(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`People`}),A(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Enrolled identities used for face recognition. Expand a row to view or remove training samples.`}),A(J,{})]}),T(`div`,{className:`pt-4 border-t border-border`,children:[A(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Recent detected faces`}),A(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Face crops captured by the detection pipeline. Assign them to a person to build recognition training data.`}),A(Ne,{})]})]})})}export{Pe as DetectionIntelligencePage};
|