@camstack/addon-admin-ui 1.2.38 → 1.2.40
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-Dt7Vz9Le.js → AddLocationWizard-_UpnD2Rb.js} +1 -1
- package/dist/assets/AddonCollectionPage-DsqpERSx.js +1 -0
- package/dist/assets/Addons-Cbzvs2ne.js +1 -0
- package/dist/assets/{AdminTabs-Ye2mzpqs.js → AdminTabs-C1b21Umm.js} +1 -1
- package/dist/assets/{AiProfiles-DqPxH0J5.js → AiProfiles-CxmKPOGN.js} +1 -1
- package/dist/assets/{BrokerForm-D3fTTpv3.js → BrokerForm-BxVQ7-k2.js} +1 -1
- package/dist/assets/Build-eERcQhc5.js +32 -0
- package/dist/assets/{Capabilities-Ce97mPD2.js → Capabilities-CkTJoG8P.js} +1 -1
- package/dist/assets/{CapabilityBadges-DtkhlewS.js → CapabilityBadges-Pi0oFNyA.js} +1 -1
- package/dist/assets/{Cluster-BG2luAid.js → Cluster-D7MeMUz9.js} +1 -1
- package/dist/assets/{ClusterRecordingTab-Htot8l7Z.js → ClusterRecordingTab-g0pESRbc.js} +1 -1
- package/dist/assets/{Dashboard-mWuskBWk.js → Dashboard-BOdpB8Zi.js} +1 -1
- package/dist/assets/Data-D_lbeA81.js +1 -0
- package/dist/assets/DetectionIntelligence-Dsj8oMfR.js +1 -0
- package/dist/assets/{DeviceAggregateSection-bI7kL3uM.js → DeviceAggregateSection-UayHxH_7.js} +1 -1
- package/dist/assets/DeviceDetail-2vx05ko3.js +2 -0
- package/dist/assets/{Devices-jtpgjbMp.js → Devices-Ctgv5UD9.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-DuZxiSdE.js → EmbedPlayerPage-BH6rYrQY.js} +1 -1
- package/dist/assets/Events-GU0DqH5U.js +1 -0
- package/dist/assets/{FormBuilder-BILjZtIe.js → FormBuilder-4y2vfIFX.js} +1 -1
- package/dist/assets/{Identity-Crk0vUgk.js → Identity-lIu4PKp0.js} +1 -1
- package/dist/assets/{IntegrationDetail-DJurXzOC.js → IntegrationDetail-C0Zcxbgi.js} +1 -1
- package/dist/assets/{Integrations-ySnIH1Sd.js → Integrations-BP2jk3NT.js} +1 -1
- package/dist/assets/Integrations-CtXQURhT.js +1 -0
- package/dist/assets/{Logs-Bb1TGrRD.js → Logs-CjKk3Pid.js} +1 -1
- package/dist/assets/{MotionZonesSettings-BWWbwGHM.js → MotionZonesSettings-Lydieqfe.js} +1 -1
- package/dist/assets/{MyAccess-C2PAPIAg.js → MyAccess-W28I5kd-.js} +1 -1
- package/dist/assets/Network-Cnq4bp10.js +1 -0
- package/dist/assets/{NodeAddonsSettingsPanel-JNSINmAv.js → NodeAddonsSettingsPanel-BI-P31wN.js} +1 -1
- package/dist/assets/{NodeInferenceDevices-Cht6qC4t.js → NodeInferenceDevices-BmhhZKpR.js} +1 -1
- package/dist/assets/Notifications-BGKlEsy-.js +1 -0
- package/dist/assets/Pipeline-6vY94dNS.js +1 -0
- package/dist/assets/{Plates-HrXlNj-Q.js → Plates-CXXsVO_i.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-DXEaUNBs.js → PrivacyMaskSettings-Cm6_Ayev.js} +1 -1
- package/dist/assets/{ProviderIcon-KgF3V3AC.js → ProviderIcon-NBKDrcT9.js} +1 -1
- package/dist/assets/{Recordings-BnrqoOrs.js → Recordings-fIC-_Plr.js} +1 -1
- package/dist/assets/{ScanNetworkModal-Dxx2BKAi.js → ScanNetworkModal-BEJE3rpa.js} +1 -1
- package/dist/assets/{Settings-ButH6GlA.js → Settings-2DUxyOI7.js} +1 -1
- package/dist/assets/{Showroom-DLHqovib.js → Showroom-DsDBDxPb.js} +1 -1
- package/dist/assets/{Terminal-CHE7uMQo.js → Terminal-DsDxn595.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-KB1NgTYv.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DuoUM9go.js} +1 -1
- package/dist/assets/{boxes-DXbr65aS.js → boxes-byknuFCy.js} +1 -1
- package/dist/assets/{build-cluster-graph-C_OKGVaH.js → build-cluster-graph-gWLixa2m.js} +2 -2
- package/dist/assets/circle-check-big-D8Wjv0ct.js +1 -0
- package/dist/assets/clock-ISV-5mJ1.js +1 -0
- package/dist/assets/{copy-DRrD5vDH.js → copy-DtilJJvc.js} +1 -1
- package/dist/assets/{debounced-invalidate-D66PzHBd.js → debounced-invalidate-DHj6wyxg.js} +1 -1
- package/dist/assets/{dist-DJVIQtZJ.js → dist-CL9jy06y.js} +1 -1
- package/dist/assets/dist-DwLd0mpq.js +345 -0
- package/dist/assets/{download-D3-L-PWN.js → download-Dj8UGwXy.js} +1 -1
- package/dist/assets/{face-bbox-D2xVdmEv.js → face-bbox-BFrLPrmw.js} +1 -1
- package/dist/assets/{hostInit-DWq68ula.js → hostInit-dir45U0P.js} +1 -1
- package/dist/assets/index-BMoYnIQI.js +4 -0
- package/dist/assets/index-DW7B7QJD.css +2 -0
- package/dist/assets/{key-round-D5V99ce_.js → key-round-DmdC7g1C.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-93f87015.js → mf-entry-bootstrap-0-7417bcdb.js} +2 -2
- package/dist/assets/{pencil-DMAfyiaP.js → pencil-CM0OcKoQ.js} +1 -1
- package/dist/assets/play-CBwgjWMW.js +1 -0
- package/dist/assets/{player-overlays-DTb-cTgy.js → player-overlays-CM9K8NbB.js} +1 -1
- package/dist/assets/plus-CByuXPqh.js +1 -0
- package/dist/assets/{radio-CykuQXCK.js → radio-C1-CuToc.js} +1 -1
- package/dist/assets/{refresh-cw-B0NcvZHF.js → refresh-cw-BCQ0uqSo.js} +1 -1
- package/dist/assets/remoteEntry-BtIghGso.js +1 -0
- package/dist/assets/rotate-ccw-CiIETsd8.js +1 -0
- package/dist/assets/rotate-cw-Bo4UhVCj.js +1 -0
- package/dist/assets/search-m5N8S4EI.js +1 -0
- package/dist/assets/{send-CtqhPev6.js → send-85b3c2pF.js} +1 -1
- package/dist/assets/{server-BbRPd6PC.js → server-CqHxFx4j.js} +1 -1
- package/dist/assets/square-CwYcDkPi.js +1 -0
- package/dist/assets/{square-check-big-p7HpHDXe.js → square-check-big-BFcA-8wr.js} +1 -1
- package/dist/assets/src-BaYQ7lHC.js +345 -0
- package/dist/assets/src-s1tm1Ako.js +67 -0
- package/dist/assets/{undo-2-BWEA1U6J.js → undo-2-DDQAKjyU.js} +1 -1
- package/dist/assets/{upload-CmfKc09s.js → upload-D0e5f6HZ.js} +1 -1
- package/dist/assets/{useEventInvalidation-R75mI5og.js → useEventInvalidation-BnSiq41g.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CeDNF2vl.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-1o9kxso_.js} +2 -2
- package/dist/assets/{wifi-CTmFh8-0.js → wifi-CkMq-H2F.js} +1 -1
- package/dist/assets/{zap-Cf83BCyl.js → zap-C0CZz-JF.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/server/addon.js +1918 -1719
- package/package.json +1 -1
- package/dist/assets/AddonCollectionPage-6Aw2YAGA.js +0 -1
- package/dist/assets/Addons-CjZHq6IY.js +0 -1
- package/dist/assets/Build-DwyWB5rK.js +0 -29
- package/dist/assets/Data-rCQoSzSV.js +0 -1
- package/dist/assets/DetectionIntelligence-DlGH85sl.js +0 -1
- package/dist/assets/DeviceDetail-CWLhoPV9.js +0 -2
- package/dist/assets/Events-DUxFB5Bn.js +0 -1
- package/dist/assets/Integrations-BHcc42O_.js +0 -1
- package/dist/assets/Network-Cy3RUcrg.js +0 -1
- package/dist/assets/Notifications-D27LJgTU.js +0 -1
- package/dist/assets/Pipeline-Cf3BtloJ.js +0 -1
- package/dist/assets/circle-check-big-CDvvzYtx.js +0 -1
- package/dist/assets/clock-MA7PvDC7.js +0 -1
- package/dist/assets/dist-CTF62Sfi.js +0 -7
- package/dist/assets/index-dqzu-f71.js +0 -4
- package/dist/assets/index-mdJi1UIz.css +0 -2
- package/dist/assets/plus-DBb9xrVk.js +0 -1
- package/dist/assets/remoteEntry-vNWEaSPf.js +0 -1
- package/dist/assets/rotate-ccw-CpixHLR5.js +0 -1
- package/dist/assets/rotate-cw-DiU5mosj.js +0 -1
- package/dist/assets/search-871hv572.js +0 -1
- package/dist/assets/square-DX2ha0JW.js +0 -1
- package/dist/assets/src-BxX2FkJ3.js +0 -67
- package/dist/assets/src-CV0JUB8F.js +0 -7
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{At as e,Tt as t,Vo as n,ao as r,d as i,g as a,io as o,m as s,zo as c}from"./src-BxX2FkJ3.js";import{Q as l,S as u,o as d,q as f,x as p,z as m}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{t as h}from"./plus-DBb9xrVk.js";import{t as g}from"./refresh-cw-B0NcvZHF.js";import{t as _}from"./square-DX2ha0JW.js";import{G as v,H as y,K as b,L as x,S,m as C}from"./index-dqzu-f71.js";import{t as w}from"./AdminPage-Dq33XE9j.js";import{t as T}from"./NodeAddonsSettingsPanel-JNSINmAv.js";var E=v(`play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]);l();function D({addonId:e,fallback:t,tileClassName:n,iconPath:r=`assets/icon.svg`}){let[i,a]=f(!1),o=`/api/addon-assets/${e}/${r}`;return p(`div`,{className:`h-10 w-10 rounded-lg flex items-center justify-center shrink-0 ${n}`,children:i?p(t,{className:`h-5 w-5`}):p(`img`,{src:o,alt:e,className:`h-7 w-7 rounded-md bg-white p-1 ring-1 ring-black/5`,onError:()=>a(!0)})})}l();function O({addonId:e,defaultActivity:t,showActivity:n=!0,maxHeight:r=`max-h-64`,defaultTab:i,capability:o}){let[c,l]=f(t??(i===`events`?`events`:`logs`));return u(`div`,{className:`flex flex-col gap-4`,children:[p(T,{nodeId:`hub`,addonIds:[e],level:`global`,capability:o}),n&&u(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[u(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border bg-surface-hover/20`,children:[p(`span`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:`Activity`}),u(`div`,{className:`flex items-center gap-1`,children:[p(k,{kind:`logs`,active:c===`logs`,onClick:()=>l(`logs`)}),p(k,{kind:`events`,active:c===`events`,onClick:()=>l(`events`)})]})]}),c===`logs`?p(a,{addonId:e,maxHeight:r,showFilters:!1}):p(s,{addonId:e,category:`addon.*`,maxHeight:r})]})]})}function k({kind:e,active:t,onClick:n}){return u(`button`,{onClick:n,className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${t?`bg-primary/10 text-primary`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[p(e===`logs`?C:y,{className:`h-3 w-3`}),e===`logs`?`Logs`:`Events`]})}l();function A(e){let{title:t,subtitle:i,pageIcon:a,itemIcon:s,capability:l,installButtonLabel:d=`Add addon`,items:g,isLoading:_,emptyTitle:v=`No addons installed for this capability`,emptyDescription:y,itemIconColor:S,renderStatusBadges:C,renderPrimaryAction:T,itemError:E,renderExpandedPanel:k,workspaceMaxHeight:A=`max-h-72`,trailing:P,showChrome:F=!1}=e,I=g.length>1,[L,R]=f(()=>g[0]?.addonId??null);m(()=>{L&&(g.some(e=>e.addonId===L)||R(g[0]?.addonId??null))},[g,L]);let z=e=>R(t=>t===e?null:e),B=`/system/addons?capability=${encodeURIComponent(l)}`;return p(w,{icon:F?a:void 0,title:F?t:void 0,subtitle:F?i:void 0,actions:F?p(b,{to:B,children:u(n,{variant:`primary`,size:`sm`,children:[p(h,{className:`h-3.5 w-3.5 mr-1`}),d]})}):void 0,children:_?p(c,{children:p(`div`,{className:`p-6 text-sm text-foreground-subtle`,children:`Loading…`})}):g.length===0?p(c,{children:p(r,{title:v,description:y??`Install an addon that declares the "${l}" capability to get started.`,action:F?p(b,{to:B,children:u(n,{variant:`primary`,size:`sm`,children:[p(h,{className:`h-3.5 w-3.5 mr-1`}),d]})}):void 0})}):u(`div`,{className:`flex flex-col gap-4`,children:[g.map(e=>{let t=!I||L===e.addonId,n=S?.(e)??(e.isActive?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:`bg-foreground-subtle/15 text-foreground-subtle`),r=E?.(e)??null;return u(c,{children:[u(`div`,{className:`flex flex-col gap-3 p-4 sm:flex-row sm:items-center ${t?`border-b border-border`:``}`,children:[u(`div`,{className:`flex items-center gap-3 flex-1 min-w-0`,children:[I&&p(`button`,{type:`button`,onClick:()=>z(e.addonId),"aria-label":t?`Collapse`:`Expand`,className:`shrink-0 p-1 rounded hover:bg-foreground-subtle/10 transition-colors`,children:p(x,{className:`h-4 w-4 text-foreground-subtle transition-transform ${t?`rotate-180`:``}`})}),u(`button`,{type:`button`,onClick:()=>I&&z(e.addonId),className:`flex items-center gap-4 flex-1 min-w-0 text-left ${I?`hover:opacity-80 transition-opacity`:``}`,disabled:!I,children:[p(D,{addonId:e.addonId,fallback:s,tileClassName:n}),u(`div`,{className:`flex-1 min-w-0`,children:[u(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[p(`span`,{className:`font-semibold text-foreground`,children:e.displayName}),p(j,{isActive:e.isActive}),C?.(e)]}),p(`div`,{className:`text-xs text-foreground-subtle mt-1 font-mono break-all`,children:e.addonId})]})]})]}),u(`div`,{className:`flex items-center gap-1 shrink-0 flex-wrap justify-end`,children:[T?.(e),p(M,{capName:e.capName??l,addonId:e.addonId,isActive:e.isActive}),p(N,{addonId:e.addonId,displayName:e.displayName})]})]}),t&&u(`div`,{className:`p-4 flex flex-col gap-3`,children:[r!==null&&p(o,{message:r}),k?.(e),p(O,{addonId:e.addonId,maxHeight:A,capability:e.capName??l})]})]},e.addonId)}),P]})})}function j({isActive:e}){return p(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${e?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:`bg-foreground-subtle/15 text-foreground-subtle`}`,children:e?`Enabled`:`Disabled`})}function M({capName:t,addonId:r,isActive:i}){let a=d(),o=e({onSuccess:()=>{a.invalidateQueries({queryKey:[[`addons`,`listCapabilityProviders`]]})}}),s=o.isPending;return u(n,{size:`sm`,variant:i?`secondary`:`primary`,disabled:s,onClick:()=>o.mutate({capName:t,addonId:r,enabled:!i}),children:[s?p(S,{className:`h-3 w-3 animate-spin`}):p(i?_:E,{className:`h-3 w-3`}),i?`Disable`:`Enable`]})}function N({addonId:e,displayName:n}){let r=d(),a=t({onSuccess:()=>{r.invalidateQueries({queryKey:[[`addons`,`listCapabilityProviders`]]})}});return p(i,{label:`Restart`,icon:g,size:`sm`,title:`Restart "${n}"?`,description:`Restarting the addon bounces its subprocess — the provider will briefly drop and reconnect automatically.`,confirmLabel:`Restart`,triggerVariant:`ghost`,confirmVariant:`danger`,disabled:a.isPending,action:()=>a.mutateAsync({addonId:e})})}export{E as n,A as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Ct as e,Dt as t,Hr as n,Ir as r,Mt as i,Nt as a,Ot as o,St as s,Tt as c,_t as l,bt as u,g as ee,gt as d,ht as f,jt as p,kt as m,lo as h,m as g,mt as _,oo as te,pt as v,ro as ne,v as re,vt as ie,wt as y,yt as ae}from"./src-BxX2FkJ3.js";import{I as b,K as x,Q as S,R as oe,S as C,W as w,b as T,o as se,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{K as k}from"./src-CV0JUB8F.js";import{p as ce}from"./player-overlays-DTb-cTgy.js";import{t as A}from"./clock-MA7PvDC7.js";import{t as j}from"./download-D3-L-PWN.js";import{t as le}from"./plus-DBb9xrVk.js";import{t as M}from"./refresh-cw-B0NcvZHF.js";import{t as ue}from"./search-871hv572.js";import{t as N}from"./upload-CmfKc09s.js";import{G as P,L as F,N as de,R as I,S as L,Y as R,g as fe,i as z,m as B,p as pe,q as V,s as H}from"./index-dqzu-f71.js";import{t as U}from"./AdminPage-Dq33XE9j.js";import{t as me}from"./NodeAddonsSettingsPanel-JNSINmAv.js";var he=P(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),W=P(`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=P(`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=P(`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`}]]);S();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}=s({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=h(k.AddonsJobProgress,e=>e.job.jobId);return w(()=>{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:A,cls:`bg-muted text-foreground-subtle`,label:`queued`},fetching:{icon:L,cls:`bg-primary/10 text-primary`,label:`fetching`,spin:!0},staged:{icon:L,cls:`bg-primary/10 text-primary`,label:`staged`,spin:!0},validating:{icon:L,cls:`bg-primary/10 text-primary`,label:`validating`,spin:!0},applying:{icon:L,cls:`bg-primary/10 text-primary`,label:`applying`,spin:!0},restarting:{icon:L,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,label:`restarting`,spin:!0},applied:{icon:L,cls:`bg-primary/10 text-primary`,label:`finalizing`,spin:!0},done:{icon:I,cls:`bg-success/10 text-success`,label:`updated`},failed:{icon:W,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 C(`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:[D(n,{className:`w-2.5 h-2.5 ${t.spin?`animate-spin`:``}`}),t.label,C(`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}=ie({name:e});return C(`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:[C(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[D(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:`Versions`}),D(`button`,{type:`button`,onClick:i,className:`text-foreground-subtle hover:text-foreground`,children:D(z,{className:`h-3 w-3`})})]}),s&&C(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[D(N,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),C(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[C(`span`,{className:`font-semibold`,children:[n===`upload`?`Uploaded copy`:`Local copy`,` in place.`]}),` `,`Re-install `,D(`span`,{className:`font-mono`,children:t}),` from npm to track upstream releases again.`]})]}),l&&C(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[D(L,{className:`h-3.5 w-3.5 animate-spin`}),`Loading versions...`]}),c&&D(`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=C(T,{children:[D(`span`,{className:`font-mono flex-1 text-left ${n?`text-primary font-semibold`:c?`text-amber-400`:`text-foreground`}`,children:e.version}),n&&D(`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=>D(`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&&D(`span`,{className:`text-[9px] text-red-400 line-through`,children:`deprecated`}),D(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return a?C(`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?D(I,{className:`h-3 w-3 text-primary shrink-0`}):D(`span`,{className:`w-3 shrink-0`})]},e.version):C(`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?D(I,{className:`h-3 w-3 text-primary shrink-0`}):D(`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:D(j,{className:`h-3 w-3`})})]},e.version)})}),c&&c.length===0&&D(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:`No versions found`})]})}var xe={queued:{icon:A,bg:`bg-muted text-foreground-subtle`,label:`queued`},updating:{icon:L,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:I,bg:`bg-success/10 text-success`,label:`done`},failed:{icon:W,bg:`bg-danger/10 text-danger`,label:`failed`}};function Se({item:e}){let t=xe[e.status],n=t.icon;return C(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${t.bg}`,title:e.error,children:[D(n,{className:`w-2.5 h-2.5 ${t.spin?`animate-spin`:``}`}),t.label]})}S();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]=E(!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 C(`div`,{className:`relative flex-shrink-0`,children:[D(`div`,{className:`h-9 w-9 rounded-lg flex items-center justify-center ${s?``:c}`,style:s,children:u?D(`img`,{src:l,alt:n,className:`h-5 w-5`,onError:()=>o(!0)}):D(e?ge:fe,{className:`h-4 w-4`})}),t===`local`&&D(`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`&&D(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:D(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:D(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),t===`upload`&&D(`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:D(N,{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 C(`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:[D(L,{className:`h-3 w-3 animate-spin`}),`Updating…`]});if(t){let r=n??t;return C(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[o&&C(`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:[D(j,{className:`h-3 w-3`}),`Update`]}),C(`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:[D(`span`,{className:`font-normal opacity-70`,children:e}),D(`span`,{className:`font-normal opacity-70`,children:`→`}),r,D(F,{className:`h-3 w-3`})]}),c]})}return C(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[C(`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,D(F,{className:`h-3 w-3 opacity-50`})]}),c]})}function Ee({addonId:e}){let t=se(),{data:n=`inherit`}=f({addonId:e}),r=m({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return D(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>D(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),r.mutate({addonId:e,channel:t})},disabled:r.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===t?t===`inherit`?`bg-gray-700/50 text-gray-700 dark:text-gray-300`:t===`off`?`bg-gray-700 text-gray-700 dark:text-gray-300`:t===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${t===`inherit`?``:`border-l border-border`}`,children:t},t))})}function De({addon:e,agents:n=[],clusterStatus:r,hideVersion:a,availableUpdate:o,onUpdate:s,isUpdating:l,jobProgress:u,bundle:d,bulkItem:f,disabledByBulk:p,isSystem:m}){let[h,_]=E(!1),[te,v]=E(!1),[ie,y]=E(!1),[b,x]=E(null);O(()=>{x(null)},[o]);let S=b??o,[oe,w]=E(!1),[k,A]=E(!1),[j,ue]=E(`logs`),N=se(),P=ce(),de=V(),I=ne(),{manifest:L}=e,R=e.installedOn??[],fe=!d&&!L.protected&&L.removable!==!1,U=!!d,G=d?.displayName??L.name,K=d?.packageName??L.packageName,q=d?.version??L.packageVersion??L.version,J=d?.installSource??e.installSource,_e=d?d.bundle?.description??d.addons[0]?.manifest.description:L.description,ve=i({onSuccess:()=>{N.invalidateQueries({queryKey:[[`addons`]]}),N.invalidateQueries({queryKey:[[`addonPages`]]}),N.invalidateQueries({queryKey:[[`capabilities`]]})}}),Y=c({onSuccess:()=>{N.invalidateQueries({queryKey:[[`addons`]]})}}),xe=ae({onSuccess:()=>{N.invalidateQueries({queryKey:[[`addons`]]}),N.invalidateQueries({queryKey:[[`addonPages`]]}),N.invalidateQueries({queryKey:[[`capabilities`]]}),N.invalidateQueries({queryKey:[[`integrations`]]})}}),X=t({onSuccess:()=>{N.invalidateQueries({queryKey:[[`addons`]]}),N.invalidateQueries({queryKey:[[`alerts`]]})}}),Z=e.health,Q=Z?.phase===`failed`&&!Z.inGracePeriod,Oe=Q&&Z?.nextRetryAt&&!Z.retrying;return C(`div`,{className:`rounded-lg border bg-surface overflow-hidden ${Q?`border-red-500/50`:`border-border`}`,children:[Q&&Z&&C(`div`,{className:`bg-danger/10 border-b border-danger/30 px-4 py-2.5 flex items-start gap-2.5`,children:[D(W,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),C(`div`,{className:`flex-1 min-w-0`,children:[C(`div`,{className:`text-xs font-semibold text-danger`,children:[`Failed to load (attempt #`,Z.retryCount,`)`]}),D(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:Z.lastError?.message??`Unknown error`}),Oe&&Z.nextRetryAt&&C(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:[`Auto-retry at `,new Date(Z.nextRetryAt).toLocaleTimeString()]})]}),C(`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:[D(M,{className:`h-3 w-3 ${X.isPending||Z.retrying?`animate-spin`:``}`}),`Retry now`]})]}),C(`div`,{className:`flex items-start gap-3 px-4 py-3`,children:[D(we,{isBundle:U||!!L.components&&L.components.length>1,installSource:J,addonId:U?d.addons[0]?.manifest.id:L.id,iconPath:U?d.bundle?.icon??d.addons[0]?.manifest.icon:L.icon,color:U?d.addons[0]?.manifest.color:L.color}),C(`div`,{className:`flex-1 min-w-0`,children:[C(`div`,{className:`flex items-start justify-between gap-2`,children:[D(`span`,{className:`text-sm font-semibold text-foreground truncate min-w-0`,children:G}),!a&&D(Te,{version:q,availableUpdate:o,...S===void 0?{}:{selectedVersion:S},isUpdating:l,installSource:J,disabled:p,...s&&S!==void 0?{onUpdate:()=>s(S)}:{},onOpenPicker:()=>y(e=>!e),children:ie&&D(be,{packageName:K,currentVersion:q,...J?{installSource:J}:{},...o!==void 0&&S!==void 0?{selectedVersion:S,onSelect:e=>{x(e),y(!1)}}:{},onInstall:e=>{y(!1),xe.mutate({packageName:K,version:e})},onClose:()=>y(!1)})})]}),C(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[K!==G&&D(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:K}),U&&C(`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:[D(ge,{className:`h-3 w-3`}),d.addons.length]}),m&&C(`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:[D(M,{className:`h-3 w-3`}),`System`]}),f!=null&&D(Se,{item:f}),u!=null&&D(ye,{progress:u})]}),_e&&D(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:_e}),!U&&e.process&&C(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[D(`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&&C(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),D(`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})]})]})]}),!U&&C(`div`,{className:`flex items-center gap-1 px-4 py-1.5 border-t border-border/50 bg-surface-hover/20`,children:[C(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Y.mutate({addonId:L.id})},disabled:Y.isPending||p,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:[D(M,{className:`h-3 w-3 ${Y.isPending?`animate-spin`:``}`}),`Restart`]}),C(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),w(e=>!e)},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:[D(B,{className:`h-3 w-3`}),`Logs`]}),!U&&C(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),A(!0)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${k?`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:[D(pe,{className:`h-3 w-3`}),`Settings`]}),D(`div`,{className:`flex-1`}),fe&&C(`button`,{type:`button`,onClick:async e=>{e.stopPropagation(),await I({title:`Uninstall ${L.name}?`,message:`This will remove the addon package and all its data. This action cannot be undone.`,confirmLabel:`Uninstall`,variant:`danger`})&&ve.mutate({packageName:L.packageName})},disabled:ve.isPending||p,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:[D(H,{className:`h-3 w-3`}),ve.isPending?`Removing...`:`Uninstall`]})]}),r&&r.nodes.length>1&&!U&&C(`div`,{className:`border-t border-border px-4 py-2 bg-muted/10`,children:[D(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:`Cluster Deployment`}),D(`div`,{className:`space-y-1`,children:r.nodes.map(e=>C(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[D(`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`}`}),D(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),D(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&D(`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`&&D(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:`offline`}),e.synced&&e.status!==`offline`&&D(`span`,{className:`text-[9px] text-success`,children:`synced`})]},e.nodeId))})]}),oe&&!U&&C(`div`,{className:`border-t border-border`,children:[C(`div`,{className:`flex items-center px-4 py-1 bg-surface-hover/20 border-b border-border/50`,children:[C(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[D(`button`,{type:`button`,onClick:()=>ue(`logs`),className:`px-2 py-0.5 transition-colors ${j===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Logs`}),D(`button`,{type:`button`,onClick:()=>ue(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${j===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Events`})]}),D(`div`,{className:`flex-1`}),D(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),w(!1)},className:`text-foreground-subtle hover:text-foreground`,children:D(z,{className:`h-3.5 w-3.5`})})]}),j===`logs`&&D(ee,{addonId:L.id,maxHeight:`max-h-64`,showFilters:!1}),j===`events`&&D(g,{addonId:L.id,category:`addon.*`,maxHeight:`max-h-64`})]}),U&&C(T,{children:[D(`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:D(h?he:F,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),h&&D(`div`,{className:`border-t border-border px-3 py-2 space-y-2`,children:d.addons.map(e=>D(De,{addon:e,agents:n,hideVersion:!0},e.manifest.id))})]}),k&&!U&&D(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4`,onClick:()=>A(!1),children:C(`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:[C(`div`,{className:`flex items-center justify-between px-5 py-3 border-b border-border flex-shrink-0`,children:[C(`div`,{className:`flex items-center gap-2`,children:[D(pe,{className:`h-4 w-4 text-primary`}),C(`h2`,{className:`text-sm font-semibold text-foreground`,children:[G,` Settings`]})]}),D(`button`,{onClick:()=>A(!1),className:`text-foreground-subtle hover:text-foreground transition-colors p-1 rounded`,children:D(z,{className:`h-4 w-4`})})]}),C(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[D(me,{nodeId:`hub`,addonIds:[L.id],level:`global`}),Ce(L)&&C(`div`,{children:[D(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Device export`}),D(re,{addonId:L.id,trpc:P.trpcClient,onOpenDevice:e=>de(`/devices/${e}`)})]}),J===`npm`&&C(`div`,{children:[D(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Auto-Update`}),D(Ee,{addonId:L.id})]}),L.components&&L.components.length>0&&C(`div`,{children:[C(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Components (`,L.components.length,`)`]}),D(`div`,{className:`flex flex-wrap gap-1`,children:L.components.map(e=>D(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]}),n.length>=2&&C(`div`,{children:[D(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Installed on`}),C(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[R.length===0&&D(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Hub (local)`}),R.map(e=>D(`span`,{className:`rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle`,children:e},e)),C(`div`,{className:`relative`,children:[C(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),v(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:[D(le,{className:`h-3 w-3`}),`Add agent`]}),te&&C(`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:[n.filter(e=>!e.isHub&&!R.includes(e.name)).map(e=>D(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),v(!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)),n.filter(e=>!e.isHub&&!R.includes(e.name)).length===0&&D(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle`,children:`No available agents`})]})]})]})]})]}),D(`div`,{className:`flex items-center justify-end px-5 py-3 border-t border-border flex-shrink-0`,children:D(`button`,{type:`button`,onClick:()=>A(!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`})})]})})]})}S();var Z=`.tgz,.tar.gz,.zip`;function Q({onUploadSuccess:e}){let[t,n]=E(!1),r=x(null),i=b(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 C(T,{children:[D(`input`,{ref:r,type:`file`,accept:Z,onChange:b(e=>{let t=e.target.files?.[0];t&&i(t),e.target.value=``},[i]),className:`hidden`}),C(`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?D(L,{className:`w-3.5 h-3.5 animate-spin`}):D(N,{className:`w-3.5 h-3.5`}),t?`Uploading...`:`Upload`]})]})}S();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:r,onRefresh:i,isRefreshing:s}){let c=se(),[u,ee]=E(``),f=oe(u),[m,h]=E(!1),g=x(null);O(()=>{if(!m)return;let e=e=>{g.current&&!g.current.contains(e.target)&&h(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[m]);let{data:_}=e({nodeId:r.id}),te=w(()=>{let e=new Map;for(let t of _??[])e.set(t.name,t.latestVersion);return e},[_]),re=w(()=>(_??[]).filter(e=>!e.isSystem).length,[_]),[ie,y]=E(()=>new Set),[S,T]=E(()=>new Map),k=b(e=>{y(t=>new Set(t).add(e))},[]),ce=b(e=>{y(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),A=b((e,t)=>{T(n=>new Map(n).set(e,t))},[]),le=b(e=>{T(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),N=a({onMutate:e=>{k(e.name),le(e.name)},onSuccess:(e,t)=>{ce(t.name);let n=e;if(n&&n.success===!1){A(t.name,n.error??`Update failed (no error message returned by server)`);return}c.invalidateQueries({queryKey:[[`addons`]]}),c.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{ce(t.name),A(t.name,e instanceof Error?e.message:String(e))}}),P=ve(),F=x(new Set);O(()=>{let e=new Set;for(let[t,n]of P)J(n)&&e.add(t);let t=[...F.current].some(t=>!e.has(t));F.current=e,t&&(c.invalidateQueries({queryKey:[[`addons`]]}),c.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[P,c]);let{data:fe}=d(void 0),z=v({onSuccess:()=>{c.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:B,isFetching:pe}=o({query:f||void 0},{enabled:m}),V=p(),{data:H}=l(void 0),U=H?.requestedAt,[me,he]=E(null),[W,ge]=E(!1);O(()=>{if(H?.kind===`framework-bulk-update`&&H.requestedAt!==me){he(H.requestedAt),ge(!0);let e=window.setTimeout(()=>ge(!1),6e3);return()=>window.clearTimeout(e)}},[U,me,H]),ne();let G=b(async()=>{let e=(_??[]).filter(e=>!e.isSystem);e.length!==0&&await V.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[r.id]})},[_,r.id,V]),K=ae({onSuccess:()=>{c.invalidateQueries({queryKey:[[`addons`]]}),c.invalidateQueries({queryKey:[[`addonPages`]]}),c.invalidateQueries({queryKey:[[`capabilities`]]}),c.invalidateQueries({queryKey:[[`integrations`]]})}}),[q,_e]=E(`type`),[Y,ye]=E(()=>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]=R(),X=xe.get(`capability`),Ce=w(()=>{let e=t.filter(e=>!ke(e.manifest.packageName));return r.isHub||(e=e.filter(e=>Ae(e.placement,r.isHub))),X&&(e=e.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===X))),e},[t,r.isHub,X]),we=()=>{let e=new URLSearchParams(xe);e.delete(`capability`),Se(e,{replace:!0})},Te=Y===`flat`?Ce:Me(Ce),Ee=w(()=>{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 C(`div`,{className:`space-y-4`,children:[[...S.entries()].map(([e,t])=>D(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px]`,children:C(`div`,{className:`flex items-start justify-between gap-3`,children:[C(`div`,{className:`space-y-0.5`,children:[C(`div`,{className:`font-medium text-danger`,children:[`Failed to update `,e]}),D(`div`,{className:`text-foreground-subtle font-mono`,children:t})]}),D(`button`,{type:`button`,onClick:()=>le(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:`dismiss`})]})},e)),C(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[C(`div`,{className:`flex items-center gap-1.5`,children:[D(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Sort:`}),C(`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:[D(`option`,{value:`type`,children:`Bundles first`}),D(`option`,{value:`name`,children:`Name`}),D(`option`,{value:`source`,children:`Install source`})]})]}),C(`div`,{className:`flex items-center gap-1.5`,children:[D(`span`,{className:`text-[10px] text-foreground-subtle`,children:`View:`}),D(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>D(`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))})]}),r.isHub&&C(`div`,{className:`flex items-center gap-1.5`,children:[D(M,{className:`h-3 w-3 text-foreground-subtle`}),D(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Auto-Update:`}),D(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>D(`button`,{type:`button`,onClick:()=>z.mutate({channel:e}),disabled:z.isPending,className:`px-2.5 py-1.5 transition-colors capitalize ${fe?.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&&C(`button`,{type:`button`,onClick:()=>void G(),disabled:V.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:[V.isPending?D(L,{className:`w-3 h-3 animate-spin`}):D(j,{className:`w-3 h-3`}),V.isPending?`Updating…`:`Update All (${re})`]}),C(`button`,{type:`button`,onClick:i,disabled:s||V.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:[D(M,{className:`w-3 h-3 ${s?`animate-spin`:``}`}),`Refresh`]})]}),C(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[C(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:g,children:[D(ue,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),D(`input`,{type:`text`,value:u,onChange:e=>{ee(e.target.value),h(!0)},onFocus:()=>h(!0),placeholder:`Search addons on npm...`,disabled:V.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`}),pe&&D(L,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle animate-spin`}),m&&B&&B.length>0&&C(`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&&C(`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&&D(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:B.map(e=>C(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[D(`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()}),C(`div`,{className:`flex-1 min-w-0`,children:[C(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[D(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),C(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),D(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&D(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?C(`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:[D(I,{className:`h-3 w-3`}),e.installedVersion??`Installed`]}):C(`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?D(L,{className:`h-3 w-3 animate-spin`}):D(j,{className:`h-3 w-3`}),`Install`]})]},e.name))})]})]}),D(Q,{onUploadSuccess:()=>{c.invalidateQueries({queryKey:[[`addons`]]}),i()}})]}),X&&C(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-primary/10 border border-primary/30 text-sm`,children:[D(`span`,{className:`text-foreground-subtle`,children:`Filtering by capability:`}),D(`span`,{className:`font-mono text-primary font-semibold`,children:X}),D(`button`,{type:`button`,onClick:we,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:`Clear`})]}),W&&C(`div`,{className:`fixed top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg backdrop-blur-sm max-w-sm pointer-events-auto`,children:[D(de,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),C(`div`,{children:[D(`div`,{className:`text-[11px] font-semibold text-foreground`,children:`Bulk update completed`}),D(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:`System packages updated — hub restarted successfully.`})]})]}),Ce.length===0&&D(`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 ${r.name} (placement filter active)`}),D(`div`,{className:`space-y-2`,children:Ee.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,i=te.get(t),a=$(e)?e.representative:e,o=i?e=>N.mutate({name:t,version:e,nodeId:r.id}):void 0,s=P.get(t)??null,c=s!==null&&J(s);return D(De,{addon:a,clusterStatus:n?.[a.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:i,isUpdating:ie.has(t)||c,jobProgress:s,onUpdate:o,disabledByBulk:V.isPending},$(e)?t:e.manifest.id)})})]})}function Pe(){let e=se(),{data:t,isLoading:i,isError:a}=u(),{data:o}=r(void 0),{data:s}=n(void 0,{refetchInterval:1e4}),c=w(()=>{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]),[l,ee]=E(`hub`),d=c.find(e=>e.id===l)??c[0],f=_(),p=y(),m=f.isPending||p.isPending,h=async()=>{await f.mutateAsync({nodeId:l}),await p.mutateAsync(),e.invalidateQueries({queryKey:[[`addons`]]})},g=x(f);g.current=f,O(()=>{g.current.mutate({nodeId:`hub`})},[]);let v=(t??[]).map(je).filter(e=>e!==null);return C(U,{children:[C(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[D(te,{selectedNodeId:l,onSelect:ee}),C(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[!i&&!a&&C(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:[v.length,` installed`]}),C(`button`,{type:`button`,onClick:()=>void h(),disabled:m,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:[D(M,{className:`w-3 h-3 ${m?`animate-spin`:``}`}),`Check for updates`]})]})]}),!d.isHub&&C(`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`,` `,D(`span`,{className:`font-medium text-foreground`,children:d.name}),` — agents only run`,` `,D(`code`,{className:`font-mono`,children:`agent-only`}),` and`,` `,D(`code`,{className:`font-mono`,children:`any-node`}),` addons. Install / uninstall is hub-driven; agents auto-sync from the hub.`]}),i&&D(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading…`}),a&&D(`div`,{className:`text-xs text-danger`,children:`Failed to load addons`}),!i&&!a&&D(Ne,{addons:v,clusterStatus:o,selectedNode:d,onRefresh:()=>void h(),isRefreshing:m})]})}export{Pe as AddonsPage};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import{$o as e,Bo as t,Co as n,Ro as r,So as i,Vo as a,Zo as o,bo as s,g as c,io as l,oo as u,xo as d,zo as f}from"./src-BxX2FkJ3.js";import{I as p,K as m,M as h,Q as g,S as _,T as v,W as y,a as b,b as x,q as S,t as C,x as w,z 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{k as E}from"./src-CV0JUB8F.js";import{p as D}from"./player-overlays-DTb-cTgy.js";import{t as O}from"./boxes-DXbr65aS.js";import{t as k}from"./pencil-DMAfyiaP.js";import{t as A}from"./plus-DBb9xrVk.js";import{t as j}from"./rotate-cw-DiU5mosj.js";import{G as M,N,S as P,T as F,Y as I,m as ee,o as te,s as L}from"./index-dqzu-f71.js";import{t as R}from"./AdminPage-Dq33XE9j.js";var ne=M(`workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]);function z({onOpenScripts:e}){return w(f,{children:_(`div`,{className:`max-w-2xl space-y-3 p-6`,children:[_(`div`,{className:`flex items-center gap-2`,children:[w(ne,{className:`h-5 w-5 text-foreground-subtle`}),w(`h3`,{className:`font-medium`,children:`Automations are not built yet`})]}),_(`p`,{className:`text-sm text-foreground-subtle`,children:[`A CamStack automation will be a `,w(`strong`,{children:`trigger`}),`, a set of`,` `,w(`strong`,{children:`conditions`}),`, and `,w(`strong`,{children:`actions`}),` — authored here, with its own trigger vocabulary. It is deliberately not the notification rule engine: the two share words and nothing else, and folding one into the other was ruled out.`]}),_(`p`,{className:`text-sm text-foreground-subtle`,children:[`Nothing is hidden behind this tab — there is no engine to configure, so there is no screen to show. Until there is, a `,w(`strong`,{children:`script`}),` does the same job in code: it runs in its own supervised process with the full addon context, so it can watch the event bus and drive devices.`]}),w(a,{variant:`outline`,onClick:e,children:`Write a script instead`})]})})}function re({onOpenScripts:e}){return w(f,{children:_(`div`,{className:`max-w-2xl space-y-3 p-6`,children:[_(`div`,{className:`flex items-center gap-2`,children:[w(O,{className:`h-5 w-5 text-foreground-subtle`}),w(`h3`,{className:`font-medium`,children:`Composed devices are not built yet`})]}),_(`p`,{className:`text-sm text-foreground-subtle`,children:[`A composed device will be a real device — its own row, its own name, its own on/off — with its state `,w(`strong`,{children:`derived from other devices`}),` and, optionally, methods that forward to them. Because it is a device row and not an overlay, it reaches HomeKit, Alexa, Home Assistant and the notification rules with nothing having to learn about it.`]}),_(`p`,{className:`text-sm text-foreground-subtle`,children:[`Nothing is hidden behind this section: no device can be declared this way yet, so there is no list to show and no form that would work. A `,w(`strong`,{children:`script`}),` is the surface that exists today — it runs in its own supervised process with the full addon context, which is the same context a composed device will be built on.`]}),w(a,{variant:`outline`,onClick:e,children:`Write a script instead`})]})})}g();function B(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function V(e){if(Array.isArray(e))return e}function ie(e,t,n){return(t=fe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ae(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function oe(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function se(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function H(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?se(Object(n),!0).forEach(function(t){ie(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):se(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ce(e,t){if(e==null)return{};var n,r,i=le(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function le(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function ue(e,t){return V(e)||ae(e,t)||pe(e,t)||oe()}function de(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function fe(e){var t=de(e,`string`);return typeof t==`symbol`?t:t+``}function pe(e,t){if(e){if(typeof e==`string`)return B(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?B(e,t):void 0}}function me(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function he(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ge(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?he(Object(n),!0).forEach(function(t){me(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):he(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function _e(){var e=[...arguments];return function(t){return e.reduceRight(function(e,t){return t(e)},t)}}function U(e){return function t(){var n=this,r=[...arguments];return r.length>=e.length?e.apply(this,r):function(){var e=[...arguments];return t.apply(n,[].concat(r,e))}}}function W(e){return{}.toString.call(e).includes(`Object`)}function ve(e){return!Object.keys(e).length}function G(e){return typeof e==`function`}function ye(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function be(e,t){return W(t)||K(`changeType`),Object.keys(t).some(function(t){return!ye(e,t)})&&K(`changeField`),t}function xe(e){G(e)||K(`selectorType`)}function Se(e){G(e)||W(e)||K(`handlerType`),W(e)&&Object.values(e).some(function(e){return!G(e)})&&K(`handlersType`)}function Ce(e){e||K(`initialIsRequired`),W(e)||K(`initialType`),ve(e)&&K(`initialContent`)}function we(e,t){throw Error(e[t]||e.default)}var K=U(we)({initialIsRequired:`initial state is required`,initialType:`initial state should be an object`,initialContent:`initial state shouldn't be an empty object`,handlerType:`handler should be an object or a function`,handlersType:`all handlers should be a functions`,selectorType:`selector should be a function`,changeType:`provided value of changes should be an object`,changeField:`it seams you want to change a field in the state which is not specified in the "initial" state`,default:"an unknown error accured in `state-local` package"}),q={changes:be,selector:xe,handler:Se,initial:Ce};function Te(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};q.initial(e),q.handler(t);var n={current:e},r=U(Oe)(n,t),i=U(De)(n),a=U(q.changes)(e),o=U(Ee)(n);function s(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(e){return e};return q.selector(e),e(n.current)}function c(e){_e(r,i,a,o)(e)}return[s,c]}function Ee(e,t){return G(t)?t(e.current):t}function De(e,t){return e.current=ge(ge({},e.current),t),t}function Oe(e,t,n){return G(t)?t(e.current):Object.keys(n).forEach(function(n){return t[n]?.call(t,e.current[n])}),n}var ke={create:Te},Ae={paths:{vs:`https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs`}};function je(e){return function t(){var n=this,r=[...arguments];return r.length>=e.length?e.apply(this,r):function(){var e=[...arguments];return t.apply(n,[].concat(r,e))}}}function Me(e){return{}.toString.call(e).includes(`Object`)}function Ne(e){return e||Le(`configIsRequired`),Me(e)||Le(`configType`),e.urls?(Pe(),{paths:{vs:e.urls.monacoBase}}):e}function Pe(){console.warn(Ie.deprecation)}function Fe(e,t){throw Error(e[t]||e.default)}var Ie={configIsRequired:`the configuration object is required`,configType:`the configuration object should be an object`,default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
3
|
-
You are using deprecated way of configuration.
|
|
4
|
-
|
|
5
|
-
Instead of using
|
|
6
|
-
monaco.config({ urls: { monacoBase: '...' } })
|
|
7
|
-
use
|
|
8
|
-
monaco.config({ paths: { vs: '...' } })
|
|
9
|
-
|
|
10
|
-
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
11
|
-
`},Le=je(Fe)(Ie),Re={config:Ne},ze=function(){var e=[...arguments];return function(t){return e.reduceRight(function(e,t){return t(e)},t)}};function Be(e,t){return Object.keys(t).forEach(function(n){t[n]instanceof Object&&e[n]&&Object.assign(t[n],Be(e[n],t[n]))}),H(H({},e),t)}var Ve={type:`cancelation`,msg:`operation is manually canceled`};function He(e){var t=!1,n=new Promise(function(n,r){e.then(function(e){return t?r(Ve):n(e)}),e.catch(r)});return n.cancel=function(){return t=!0},n}var Ue=[`monaco`],We=ue(ke.create({config:Ae,isInitialized:!1,resolve:null,reject:null,monaco:null}),2),J=We[0],Ge=We[1];function Ke(e){var t=Re.config(e),n=t.monaco,r=ce(t,Ue);Ge(function(e){return{config:Be(e.config,r),monaco:n}})}function qe(){var e=J(function(e){return{monaco:e.monaco,isInitialized:e.isInitialized,resolve:e.resolve}});if(!e.isInitialized){if(Ge({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),He(et);if(window.monaco&&window.monaco.editor)return Qe(window.monaco),e.resolve(window.monaco),He(et);ze(Je,Xe)(Ze)}return He(et)}function Je(e){return document.body.appendChild(e)}function Ye(e){var t=document.createElement(`script`);return e&&(t.src=e),t}function Xe(e){var t=J(function(e){return{config:e.config,reject:e.reject}}),n=Ye(`${t.config.paths.vs}/loader.js`);return n.onload=function(){return e()},n.onerror=t.reject,n}function Ze(){var e=J(function(e){return{config:e.config,resolve:e.resolve,reject:e.reject}}),t=window.require;t.config(e.config),t([`vs/editor/editor.main`],function(t){var n=t.m||t;Qe(n),e.resolve(n)},function(t){e.reject(t)})}function Qe(e){J().monaco||Ge({monaco:e})}function $e(){return J(function(e){return e.monaco})}var et=new Promise(function(e,t){return Ge({resolve:e,reject:t})}),tt={config:Ke,init:qe,__getMonacoInstance:$e},nt={wrapper:{display:`flex`,position:`relative`,textAlign:`initial`},fullWidth:{width:`100%`},hide:{display:`none`}},rt={container:{display:`flex`,height:`100%`,width:`100%`,justifyContent:`center`,alignItems:`center`}};function it({children:e}){return v.createElement(`div`,{style:rt.container},e)}var at=it;function ot({width:e,height:t,isEditorReady:n,loading:r,_ref:i,className:a,wrapperProps:o}){return v.createElement(`section`,{style:{...nt.wrapper,width:e,height:t},...o},!n&&v.createElement(at,null,r),v.createElement(`div`,{ref:i,style:{...nt.fullWidth,...!n&&nt.hide},className:a}))}var st=h(ot);function ct(e){T(e,[])}var lt=ct;function ut(e,t,n=!0){let r=m(!0);T(r.current||!n?()=>{r.current=!1}:e,t)}var Y=ut;function X(){}function Z(e,t,n,r){return dt(e,r)||ft(e,t,n,r)}function dt(e,t){return e.editor.getModel(pt(e,t))}function ft(e,t,n,r){return e.editor.createModel(t,n,r?pt(e,r):void 0)}function pt(e,t){return e.Uri.parse(t)}function mt({original:e,modified:t,language:n,originalLanguage:r,modifiedLanguage:i,originalModelPath:a,modifiedModelPath:o,keepCurrentOriginalModel:s=!1,keepCurrentModifiedModel:c=!1,theme:l=`light`,loading:u=`Loading...`,options:d={},height:f=`100%`,width:h=`100%`,className:g,wrapperProps:_={},beforeMount:y=X,onMount:b=X}){let[x,C]=S(!1),[w,E]=S(!0),D=m(null),O=m(null),k=m(null),A=m(b),j=m(y),M=m(!1);lt(()=>{let e=tt.init();return e.then(e=>(O.current=e)&&E(!1)).catch(e=>e?.type!==`cancelation`&&console.error(`Monaco initialization: error:`,e)),()=>D.current?F():e.cancel()}),Y(()=>{if(D.current&&O.current){let t=D.current.getOriginalEditor(),i=Z(O.current,e||``,r||n||`text`,a||``);i!==t.getModel()&&t.setModel(i)}},[a],x),Y(()=>{if(D.current&&O.current){let e=D.current.getModifiedEditor(),r=Z(O.current,t||``,i||n||`text`,o||``);r!==e.getModel()&&e.setModel(r)}},[o],x),Y(()=>{let e=D.current.getModifiedEditor();e.getOption(O.current.editor.EditorOption.readOnly)?e.setValue(t||``):t!==e.getValue()&&(e.executeEdits(``,[{range:e.getModel().getFullModelRange(),text:t||``,forceMoveMarkers:!0}]),e.pushUndoStop())},[t],x),Y(()=>{D.current?.getModel()?.original.setValue(e||``)},[e],x),Y(()=>{let{original:e,modified:t}=D.current.getModel();O.current.editor.setModelLanguage(e,r||n||`text`),O.current.editor.setModelLanguage(t,i||n||`text`)},[n,r,i],x),Y(()=>{O.current?.editor.setTheme(l)},[l],x),Y(()=>{D.current?.updateOptions(d)},[d],x);let N=p(()=>{if(!O.current)return;j.current(O.current);let s=Z(O.current,e||``,r||n||`text`,a||``),c=Z(O.current,t||``,i||n||`text`,o||``);D.current?.setModel({original:s,modified:c})},[n,t,i,e,r,a,o]),P=p(()=>{!M.current&&k.current&&(D.current=O.current.editor.createDiffEditor(k.current,{automaticLayout:!0,...d}),N(),O.current?.editor.setTheme(l),C(!0),M.current=!0)},[d,l,N]);T(()=>{x&&A.current(D.current,O.current)},[x]),T(()=>{!w&&!x&&P()},[w,x,P]);function F(){let e=D.current?.getModel();s||e?.original?.dispose(),c||e?.modified?.dispose(),D.current?.dispose()}return v.createElement(st,{width:h,height:f,isEditorReady:x,loading:u,_ref:k,className:g,wrapperProps:_})}h(mt);function ht(e){let t=m();return T(()=>{t.current=e},[e]),t.current}var gt=ht,_t=new Map;function vt({defaultValue:e,defaultLanguage:t,defaultPath:n,value:r,language:i,path:a,theme:o=`light`,line:s,loading:c=`Loading...`,options:l={},overrideServices:u={},saveViewState:d=!0,keepCurrentModel:f=!1,width:h=`100%`,height:g=`100%`,className:_,wrapperProps:y={},beforeMount:b=X,onMount:x=X,onChange:C,onValidate:w=X}){let[E,D]=S(!1),[O,k]=S(!0),A=m(null),j=m(null),M=m(null),N=m(x),P=m(b),F=m(),I=m(r),ee=gt(a),te=m(!1),L=m(!1);lt(()=>{let e=tt.init();return e.then(e=>(A.current=e)&&k(!1)).catch(e=>e?.type!==`cancelation`&&console.error(`Monaco initialization: error:`,e)),()=>j.current?ne():e.cancel()}),Y(()=>{let o=Z(A.current,e||r||``,t||i||``,a||n||``);o!==j.current?.getModel()&&(d&&_t.set(ee,j.current?.saveViewState()),j.current?.setModel(o),d&&j.current?.restoreViewState(_t.get(a)))},[a],E),Y(()=>{j.current?.updateOptions(l)},[l],E),Y(()=>{!j.current||r===void 0||(j.current.getOption(A.current.editor.EditorOption.readOnly)?j.current.setValue(r):r!==j.current.getValue()&&(L.current=!0,j.current.executeEdits(``,[{range:j.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),j.current.pushUndoStop(),L.current=!1))},[r],E),Y(()=>{let e=j.current?.getModel();e&&i&&A.current?.editor.setModelLanguage(e,i)},[i],E),Y(()=>{s!==void 0&&j.current?.revealLine(s)},[s],E),Y(()=>{A.current?.editor.setTheme(o)},[o],E);let R=p(()=>{if(!(!M.current||!A.current)&&!te.current){P.current(A.current);let c=a||n,f=Z(A.current,r||e||``,t||i||``,c||``);j.current=A.current?.editor.create(M.current,{model:f,automaticLayout:!0,...l},u),d&&j.current.restoreViewState(_t.get(c)),A.current.editor.setTheme(o),s!==void 0&&j.current.revealLine(s),D(!0),te.current=!0}},[e,t,n,r,i,a,l,u,d,o,s]);T(()=>{E&&N.current(j.current,A.current)},[E]),T(()=>{!O&&!E&&R()},[O,E,R]),I.current=r,T(()=>{E&&C&&(F.current?.dispose(),F.current=j.current?.onDidChangeModelContent(e=>{L.current||C(j.current.getValue(),e)}))},[E,C]),T(()=>{if(E){let e=A.current.editor.onDidChangeMarkers(e=>{let t=j.current.getModel()?.uri;if(t&&e.find(e=>e.path===t.path)){let e=A.current.editor.getModelMarkers({resource:t});w?.(e)}});return()=>{e?.dispose()}}return()=>{}},[E,w]);function ne(){F.current?.dispose(),f?d&&_t.set(a,j.current.saveViewState()):j.current.getModel()?.dispose(),j.current.dispose()}return v.createElement(st,{width:h,height:g,isEditorReady:E,loading:c,_ref:M,className:_,wrapperProps:y})}var yt=h(vt);g();var bt={target:99,module:99,moduleResolution:2,strict:!0,noImplicitAny:!0,strictNullChecks:!0,allowNonTsExtensions:!0,isolatedModules:!0};function xt(e,t){let n=e.languages.typescript.typescriptDefaults;n.setCompilerOptions({...n.getCompilerOptions(),...bt}),n.setExtraLibs(t.map(e=>({filePath:e.filePath,content:e.content})))}function St({value:e,onChange:t,extraLibs:n=[],onDiagnostics:r,readOnly:i=!1,heightPx:a=420,dark:o=!0}){let s=m(null),c=p((e,t)=>{if(s.current=t,xt(t,n),r===void 0)return;let i=e.getModel();if(i===null)return;let a=()=>{r(t.editor.getModelMarkers({resource:i.uri}).map(e=>({line:e.startLineNumber,column:e.startColumn,message:e.message,severity:e.severity})))};t.editor.onDidChangeMarkers(a),a()},[n,r]);return w(yt,{height:a,defaultLanguage:`typescript`,path:`file:///block.ts`,theme:o?`vs-dark`:`vs`,value:e,onChange:e=>t(e??``),onMount:c,options:{readOnly:i,minimap:{enabled:!1},fontSize:12,lineNumbers:`on`,scrollBeyondLastLine:!1,automaticLayout:!0,tabSize:2,renderWhitespace:`selection`}})}function Ct(e){return e.some(e=>e.severity>=8)}var wt=`import type { AddonContext } from '@camstack/types'
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* A core block. Runs in its own process, with the same \`ctx\` an addon gets.
|
|
15
|
-
* Return a function to release whatever you took (timers, sockets, listeners) —
|
|
16
|
-
* it is awaited on shutdown.
|
|
17
|
-
*/
|
|
18
|
-
export default function block(ctx: AddonContext) {
|
|
19
|
-
ctx.logger.info('hello from a core block')
|
|
20
|
-
|
|
21
|
-
const timer = setInterval(() => {
|
|
22
|
-
ctx.logger.info('tick')
|
|
23
|
-
}, 60_000)
|
|
24
|
-
|
|
25
|
-
return () => {
|
|
26
|
-
clearInterval(timer)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
`;function Q(e){if(!e.enabled)return{tone:`idle`,label:`Disabled`,detail:`Not started — the block is turned off.`};switch(e.status){case`running`:return{tone:`ok`,label:`Running`,detail:`One process, supervised.`};case`starting`:return{tone:`pending`,label:`Starting`,detail:e.lastError??`Waiting for the process to report ready.`};case`failed`:return{tone:`error`,label:`Failed`,detail:e.lastError??`Failed with no reason recorded — check the node logs.`};default:return{tone:`error`,label:`Not running`,detail:e.lastError??`Enabled but no process is running. The supervisor reconciles every 15s; if this persists, the node may not be running a block supervisor.`}}}function Tt(e){switch(e){case`ok`:return`success`;case`pending`:return`warning`;case`error`:return`danger`;default:return`default`}}function Et(e){let t=e=>{let t=Q(e).tone;return t===`error`?0:t===`pending`?1:t===`ok`?2:3};return[...e].sort((e,n)=>t(e)-t(n)||e.name.localeCompare(n.name))}function Dt(e){if(e.length===0)return`No blocks yet.`;let t=e.filter(e=>Q(e).tone===`error`).length,n=e.filter(e=>Q(e).tone===`ok`).length,r=[`${String(e.length)} block${e.length===1?``:`s`}`];return n>0&&r.push(`${String(n)} running`),t>0&&r.push(`${String(t)} NOT running`),r.join(` · `)}function Ot({existing:e,dirty:t,saving:n,restarting:r}){return e===null?`Save the script first — there is no process to restart yet.`:n?`Saving…`:r?`Restarting…`:t?`Save first — a restart now would run the last SAVED code, not what is on screen.`:e.enabled?null:`This script is disabled. Enable it instead of restarting it.`}g();var kt=`hub`;function At({existing:n,typeDefs:i,typeDefsLoading:o,saving:s,saveError:l,restarting:d,restartError:p,onRestart:m,onSave:h,onCancel:g}){let v=D(),{resolvedMode:b}=e(),[T,O]=S(n?.name??``),[k,A]=S(n?.code??wt),[M,F]=S(n?.placement??kt),[I,L]=S(n?.integrationId??``),[R,ne]=S([]),[z,re]=S(!1),B=C({mutationFn:e=>v.trpcClient.coreBlocks.compile.mutate({code:e})}),V=y(()=>R.filter(e=>e.severity>=8),[R]),ie=Ct(R),ae=T.trim()===``,oe=n===null||k!==n.code||T.trim()!==n.name||M!==n.placement||(I.trim()===``?void 0:I.trim())!==n.integrationId,se=()=>{B.reset(),h({name:T.trim(),code:k,enabled:n?.enabled??!0,placement:M,...I.trim()===``?{}:{integrationId:I.trim()}})},H=n===null?null:Q(n),ce=Ot({existing:n,dirty:oe,saving:s,restarting:d});return w(f,{children:_(`div`,{className:`space-y-4 p-4`,children:[_(`div`,{className:`flex flex-wrap items-center gap-2`,children:[w(`h3`,{className:`font-medium`,children:n===null?`New script`:`Edit ${n.name}`}),H!==null&&w(t,{variant:Tt(H.tone),children:H.label})]}),_(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[_(`label`,{className:`block text-sm`,children:[w(`span`,{className:`text-foreground-subtle`,children:`Name`}),w(r,{className:`mt-1`,value:T,onChange:e=>O(e.target.value),placeholder:`What this script does`})]}),_(`label`,{className:`block text-sm`,children:[w(`span`,{className:`text-foreground-subtle`,children:`Integration (optional)`}),w(r,{className:`mt-1`,value:I,onChange:e=>L(e.target.value),placeholder:`Leave empty for the shared system integration`})]})]}),_(`div`,{children:[w(u,{selectedNodeId:M,onSelect:F,label:`Runs on`,alwaysShow:!0}),M!==kt&&_(`p`,{className:`mt-2 flex items-start gap-2 text-xs text-warning`,children:[w(te,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),_(`span`,{children:[`Block execution is hub-only today. Saved with this placement the block will be stored and compiled, but it will report `,w(`strong`,{children:`Failed`}),` instead of running.`]})]})]}),_(`div`,{className:z?`grid gap-3 lg:grid-cols-2`:``,children:[w(`div`,{className:`rounded border border-border`,children:o?w(`p`,{className:`p-4 text-sm text-foreground-subtle`,children:`Loading the node's type definitions…`}):w(St,{value:k,onChange:A,extraLibs:i?.libs??[],onDiagnostics:ne,dark:b===`dark`,heightPx:420})}),z&&_(`div`,{className:`rounded border border-border`,children:[w(`div`,{className:`border-b border-border px-3 py-1.5 text-xs text-foreground-subtle`,children:n===null?`Logs appear once the script has been saved and started.`:_(x,{children:[`Logs — `,w(`code`,{children:E(n.id)})]})}),n!==null&&w(c,{addonId:E(n.id),maxHeight:`max-h-[420px]`,showFilters:!1})]})]}),i!==void 0&&i.libs.length===0&&w(`p`,{className:`text-xs text-warning`,children:`The node returned no type definitions, so this code is NOT being checked against the system's types. The server-side compile still applies on save.`}),V.length>0&&_(`div`,{className:`space-y-1 rounded border border-danger/40 bg-danger/10 p-3 text-xs`,children:[_(`p`,{className:`font-medium text-danger`,children:[V.length,` error`,V.length===1?``:`s`,` — the block cannot be saved.`]}),V.slice(0,5).map(e=>_(`p`,{className:`text-danger`,children:[`line `,e.line,`: `,e.message]},`${String(e.line)}:${String(e.column)}:${e.message}`)),V.length>5&&_(`p`,{className:`text-foreground-subtle`,children:[`…and `,V.length-5,` more.`]})]}),B.data!==void 0&&(B.data.ok?_(`p`,{className:`flex items-center gap-2 text-xs text-success`,children:[w(N,{className:`h-3.5 w-3.5`}),` The node compiled this code. Nothing was saved.`]}):_(`div`,{className:`rounded border border-danger/40 bg-danger/10 p-3 text-xs text-danger`,children:[B.data.line===void 0?``:`line ${String(B.data.line)}: `,B.data.error??`the code does not compile`]})),B.error!==null&&_(`div`,{className:`rounded border border-danger/40 bg-danger/10 p-3 text-xs text-danger`,children:[`Could not reach the compiler: `,jt(B.error)]}),l!==null&&w(`div`,{className:`rounded border border-danger/40 bg-danger/10 p-3 text-xs text-danger`,children:l}),p!==null&&w(`div`,{className:`rounded border border-danger/40 bg-danger/10 p-3 text-xs text-danger`,children:p}),_(`div`,{className:`flex flex-wrap items-center gap-2`,children:[_(a,{variant:`outline`,onClick:()=>B.mutate(k),disabled:B.isPending||s,title:`Type-check on the node without saving`,children:[B.isPending&&w(P,{className:`h-4 w-4 animate-spin`}),` Compile`]}),_(a,{onClick:se,disabled:s||ie||ae,children:[s&&w(P,{className:`h-4 w-4 animate-spin`}),` Save`]}),_(a,{variant:`outline`,onClick:()=>m?.(),disabled:ce!==null||m===void 0,title:ce??`Stop the process and let the supervisor bring it back`,children:[d?w(j,{className:`h-4 w-4 animate-spin`}):w(j,{className:`h-4 w-4`}),` `,`Restart`]}),_(a,{variant:`ghost`,onClick:()=>re(!z),title:`Show this script's process logs`,children:[w(ee,{className:`h-4 w-4`}),` Logs `,z?`⇤`:`⇄`]}),w(a,{variant:`ghost`,onClick:g,disabled:s,children:`Close`}),_(`span`,{className:`ml-auto text-xs text-foreground-subtle`,children:[`errors: `,V.length,oe&&n!==null?` · unsaved changes`:``]}),ae&&w(t,{variant:`warning`,children:`Name required`})]})]})})}function jt(e){return e instanceof Error?e.message:String(e)}g();var Mt=[`coreBlocks`,`list`],Nt=[`coreBlocks`,`getTypeDefs`],Pt=5e3;function $(e){return e instanceof Error?e.message:String(e)}function Ft(e,t){let n=e.find(e=>e.id===t.id);return n===void 0?t:n.updatedAt>=t.updatedAt?n:t}function It(){let e=D(),[t,n]=S({mode:`closed`}),[r,i]=S(null),[o,s]=S(null),c=b({queryKey:Mt,refetchInterval:Pt,queryFn:async()=>(await e.trpcClient.coreBlocks.list.query({})).blocks}),u=b({queryKey:Nt,enabled:t.mode===`edit`,staleTime:1/0,gcTime:1/0,queryFn:()=>e.trpcClient.coreBlocks.getTypeDefs.query({})}),d=()=>{c.refetch()},p=C({mutationFn:t=>e.trpcClient.coreBlocks.create.mutate({block:t}),onSuccess:e=>{n({mode:`edit`,block:e.block}),d()}}),m=C({mutationFn:t=>e.trpcClient.coreBlocks.update.mutate(t),onSuccess:e=>{n({mode:`edit`,block:e.block}),d()}}),h=C({mutationFn:t=>e.trpcClient.coreBlocks.delete.mutate({blockId:t}),onSuccess:()=>{i(null),d()}}),g=C({mutationFn:t=>e.trpcClient.coreBlocks.setEnabled.mutate(t),onSuccess:d}),v=C({mutationFn:t=>e.trpcClient.coreBlocks.restart.mutate({blockId:t}),onSuccess:d}),y=Et(c.data??[]),x=c.data!==void 0&&y.length===0,T=p.isPending||m.isPending,E=p.error===null?m.error===null?null:$(m.error):$(p.error),O=t.mode===`edit`&&t.block!==null?Ft(y,t.block):null;return _(`div`,{className:`space-y-3`,children:[_(`div`,{className:`flex items-center justify-between gap-3`,children:[w(`p`,{className:`text-xs text-foreground-subtle`,children:c.data===void 0?``:Dt(y)}),_(a,{onClick:()=>n({mode:`edit`,block:null}),children:[w(A,{className:`h-4 w-4`}),` New script`]})]}),c.error!=null&&w(l,{title:`Could not read the scripts`,message:$(c.error),onRetry:d}),t.mode===`edit`&&w(At,{existing:O,typeDefs:u.data,typeDefsLoading:u.isLoading,saving:T,saveError:E,restarting:v.isPending,restartError:v.error===null?null:$(v.error),onRestart:O===null?void 0:()=>v.mutate(O.id),onSave:e=>{let t=O;t===null?p.mutate(e):m.mutate({blockId:t.id,block:e})},onCancel:()=>{p.reset(),m.reset(),v.reset(),n({mode:`closed`})}}),x&&w(f,{children:_(`div`,{className:`space-y-1 p-4`,children:[w(`p`,{className:`text-sm text-foreground`,children:`No scripts yet.`}),w(`p`,{className:`text-xs text-foreground-subtle`,children:`A script is TypeScript the hub runs in its own process, with the same context an addon gets — devices, storage, the event bus. It is supervised: one that throws or hangs is marked failed and shown here, not left silently absent.`})]})}),y.length>0&&w(f,{children:w(`ul`,{className:`divide-y divide-border`,children:y.map(e=>w(Lt,{block:e,busy:g.isPending||h.isPending,restarting:v.isPending&&v.variables===e.id,confirming:r===e.id,logsOpen:o===e.id,onToggle:t=>g.mutate({blockId:e.id,enabled:t}),onRestart:()=>v.mutate(e.id),onToggleLogs:()=>s(o===e.id?null:e.id),onEdit:()=>n({mode:`edit`,block:e}),onAskDelete:()=>i(e.id),onCancelDelete:()=>i(null),onConfirmDelete:()=>h.mutate(e.id)},e.id))})}),h.error!=null&&w(l,{message:$(h.error)}),g.error!=null&&w(l,{message:$(g.error)}),v.error!=null&&w(l,{message:$(v.error)})]})}function Lt({block:e,busy:n,restarting:r,confirming:i,logsOpen:s,onToggle:l,onRestart:u,onToggleLogs:d,onEdit:f,onAskDelete:p,onCancelDelete:m,onConfirmDelete:h}){let g=Q(e),v=o(e.updatedAt);return _(`li`,{className:`flex flex-col gap-2 p-3`,children:[_(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[_(`div`,{className:`min-w-0 flex-1`,children:[_(`div`,{className:`flex flex-wrap items-center gap-2`,children:[w(`span`,{className:`truncate font-medium`,children:e.name}),w(t,{variant:Tt(g.tone),children:g.label}),w(t,{variant:`info`,children:e.placement}),v!==null&&_(`span`,{className:`text-xs text-foreground-subtle`,children:[`edited `,v]})]}),w(`p`,{className:`mt-0.5 text-xs text-foreground-subtle`,children:g.detail})]}),i?_(`div`,{className:`flex items-center gap-2`,children:[w(`span`,{className:`text-xs text-foreground-subtle`,children:`Delete this script?`}),w(a,{variant:`danger`,onClick:h,disabled:n,children:`Delete`}),w(a,{variant:`ghost`,onClick:m,children:`Cancel`})]}):_(`div`,{className:`flex items-center gap-2`,children:[w(a,{variant:`ghost`,onClick:f,title:`Edit`,children:w(k,{className:`h-4 w-4`})}),w(a,{variant:`ghost`,onClick:u,disabled:n||r||!e.enabled,title:e.enabled?`Restart`:`Enable it instead — a disabled script has no process`,children:w(j,{className:`h-4 w-4${r?` animate-spin`:``}`})}),w(a,{variant:`ghost`,onClick:d,title:`Logs`,children:w(ee,{className:`h-4 w-4`})}),w(a,{variant:`ghost`,onClick:()=>l(!e.enabled),disabled:n,title:e.enabled?`Disable`:`Enable`,children:e.enabled?`Disable`:`Enable`}),w(a,{variant:`ghost`,onClick:p,title:`Delete`,children:w(L,{className:`h-4 w-4`})})]})]}),s&&_(`div`,{className:`rounded border border-border`,children:[_(`div`,{className:`border-b border-border px-3 py-1.5 text-xs text-foreground-subtle`,children:[`Logs — `,w(`code`,{children:E(e.id)})]}),w(c,{addonId:E(e.id),maxHeight:`max-h-64`,showFilters:!1})]})]})}var Rt=[`automations`,`scripts`,`custom-device`];function zt(e){return e!==null&&Rt.some(t=>t===e)}function Bt(){let[e,t]=I(),r=e.get(`tab`),a=zt(r)?r:`automations`,o=e=>{t(t=>{let n=new URLSearchParams(t);return n.set(`tab`,e),n},{replace:!0})};return w(R,{icon:F,title:`Build-your-self`,subtitle:`Automations, scripts and composed devices — what this installation does on its own.`,children:_(s,{value:a,onValueChange:o,children:[_(i,{children:[w(n,{value:`automations`,children:`Automations`}),w(n,{value:`scripts`,children:`Scripts`}),w(n,{value:`custom-device`,children:`Custom Device`})]}),w(d,{value:`automations`,children:w(z,{onOpenScripts:()=>o(`scripts`)})}),w(d,{value:`scripts`,children:w(It,{})}),w(d,{value:`custom-device`,children:w(re,{onOpenScripts:()=>o(`scripts`)})})]})})}export{Bt as BuildPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Ea as e,Et as t,Gt as n,Ht as r,Jt as i,Kt as a,Oa as o,Ta as s,Ut as c,Vt as l,Wt as u,Xt as d,Yt as f,bt as p,qt as m,ro as h,wa as g,xt as _}from"./src-BxX2FkJ3.js";import{I as v,Q as y,S as b,W as x,a as S,b as C,o as w,q as T,x as E,z as D}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{p as O}from"./player-overlays-DTb-cTgy.js";import{a as k,i as A,n as j,r as M,t as N}from"./AddLocationWizard-Dt7Vz9Le.js";import{t as P}from"./download-D3-L-PWN.js";import{t as F}from"./pencil-DMAfyiaP.js";import{n as ee,t as I}from"./AddonCollectionPage-6Aw2YAGA.js";import{t as te}from"./plus-DBb9xrVk.js";import{t as L}from"./rotate-cw-DiU5mosj.js";import{F as ne,G as R,L as re,S as z,U as ie,i as B,m as V,s as H}from"./index-dqzu-f71.js";import{t as U}from"./AdminPage-Dq33XE9j.js";import{r as ae}from"./authed-media-B8T1dsFh.js";import{t as W}from"./AdminTabs-Ye2mzpqs.js";import{t as G}from"./format-size-CO9d3C3-.js";import{t as K}from"./addon-display-names-DvSEQty-.js";var q=R(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),J=R(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),oe=R(`calendar-clock`,[[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M17.5 17.5 16 16.3V14`,key:`akvzfd`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),se=R(`file-text`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]);y();var ce=new Set([`recordings`,`recordingsLow`]);function le(e){let t=e.filesTotal===null?``:`/${e.filesTotal}`,n=Math.round(e.bytesMoved/(1024*1024)),r=`${e.entities.join(`+`)}: ${e.filesMoved}${t} files, ${n} MB — ${e.state}`;return e.error?`${r} (${e.error})`:r}function ue({location:e,onClose:t}){let n=O().trpcClient,[r,i]=T(``),[a,o]=T(!0),[s,c]=T(!0),[l,u]=T(null),[d,f]=T(!1),p=S({queryKey:[`storage`,`listLocations`,`relocate`],queryFn:()=>n.storage.listLocations.query({})}),m=x(()=>(p.data??[]).filter(t=>t.id!==e.id&&ce.has(t.type)&&t.config.readOnly!==!0&&t.config.basePath!==e.config.basePath),[p.data,e]),h=S({queryKey:[`relocate`,`jobs`],queryFn:async()=>{let[e,t]=await Promise.all([n.recording.getRelocateStatus.query({}).catch(()=>[]),n.pipelineAnalytics.getMediaRelocateStatus.query({}).catch(()=>[])]);return[...e,...t].sort((e,t)=>t.startedAt-e.startedAt)},refetchInterval:2e3}),g=h.data??[],_=g.some(e=>e.state===`running`);D(()=>{r===``&&m.length>0&&i(m[0].id)},[m,r]);let v=async()=>{if(r!==``){u(null),f(!0);try{a&&await n.recording.relocateFootage.mutate({fromLocationId:e.id,toLocationId:r}),s&&await n.pipelineAnalytics.relocateMedia.mutate({toLocationId:r}),await h.refetch()}catch(e){u(e instanceof Error?e.message:String(e))}finally{f(!1)}}},y=async e=>{try{e.entities.includes(`media`)?await n.pipelineAnalytics.cancelMediaRelocate.mutate({jobId:e.jobId}):await n.recording.cancelRelocate.mutate({jobId:e.jobId}),await h.refetch()}catch{}};return E(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:t,children:b(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[b(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[b(`div`,{className:`space-y-0.5`,children:[b(`h2`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[E(k,{className:`h-3.5 w-3.5`}),`Relocate from `,e.displayName]}),E(`p`,{className:`text-xs text-foreground-subtle`,children:`Throttled background move; safe to re-run — it resumes where it stopped. Mark this location read-only first so nothing new lands here.`})]}),E(`button`,{onClick:t,className:`text-foreground-subtle hover:text-foreground`,children:E(B,{className:`h-4 w-4`})})]}),b(`div`,{className:`p-4 space-y-3`,children:[b(`div`,{className:`space-y-1`,children:[E(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Target location`}),m.length===0?E(`p`,{className:`text-[11px] text-foreground-subtle`,children:`No writable recordings location on a different root to move to.`}):E(`select`,{value:r,onChange:e=>i(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:m.map(e=>b(`option`,{value:e.id,children:[e.displayName,` (`,String(e.config.basePath??e.id),`)`]},e.id))})]}),b(`div`,{className:`space-y-1`,children:[b(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[E(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),className:`accent-primary`}),`Footage (segments + strips)`]}),b(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[E(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked),className:`accent-primary`}),`Event media (crops, thumbnails, snapshots)`]})]}),l&&E(`p`,{className:`text-[11px] text-danger`,children:l}),g.length>0&&E(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:g.slice(0,4).map(e=>b(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5`,children:[E(`span`,{className:`flex-1 truncate text-[11px] text-foreground`,children:le(e)}),e.state===`running`&&E(`button`,{onClick:()=>void y(e),className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground`,children:`Cancel`})]},e.jobId))})]}),b(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3`,children:[E(`button`,{onClick:t,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground`,children:`Close`}),E(`button`,{onClick:()=>void v(),disabled:r===``||d||_||!a&&!s,className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:_?`Running…`:`Start relocation`})]})]})})}y();function de(){let t=w(),n=h(),{data:r,isLoading:i,isError:a}=e({}),c=s(),l=x(()=>c.data??[],[c.data]),[u,d]=T(null),[f,p]=T(null),[m,_]=T(null),v=g({onSuccess:()=>{t.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),y=o({onSuccess:()=>{t.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),S=e=>{e.isDefault||y.mutate({id:e.id,type:e.type,providerId:e.providerId,displayName:e.displayName,config:e.config,isDefault:!0})},C=async e=>{if(e.isDefault){await n({title:`Cannot delete default location`,message:`"${e.displayName}" is the default for type "${e.type}". Mark another location as default first, then delete this one.`,confirmLabel:`OK`,variant:`warning`});return}await n({title:`Delete location "${e.displayName}"?`,message:`This removes the location record. Files on disk are not deleted; the underlying directory or remote path stays untouched.`,confirmLabel:`Delete`,variant:`danger`})&&v.mutate({id:e.id})},D=x(()=>{let e=new Map;for(let t of r??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[r]),O=i||c.isLoading,k=a||c.isError;return b(U,{children:[O&&E(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading locations…`}),k&&E(`div`,{className:`text-xs text-danger`,children:`Failed to load storage locations.`}),!O&&!k&&b(`div`,{className:`space-y-3`,children:[l.length===0&&E(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-[11px] text-foreground-subtle italic`,children:`No storage locations declared by any installed addon.`}),l.map(e=>E(M,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:D.get(e.id)??[],onAdd:e=>d(e),onEdit:e=>p(e),onDelete:e=>{C(e)},onSetDefault:e=>S(e),...e.id===`recordings`||e.id===`recordingsLow`?{onRelocate:e=>_(e)}:{}},e.id))]}),u!==null&&E(N,{initialType:u,onClose:()=>d(null),onCreated:()=>{t.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),d(null)}}),f!==null&&E(j,{location:f,onClose:()=>p(null),onSaved:()=>{t.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),p(null)}}),m&&E(ue,{location:m,onClose:()=>_(null)})]})}y();var fe=[[`backup`,`listDestinations`]],pe=[`backup`,`listArchives`];function me({destinationId:e,restoreSupported:t,onOpenRestoreWizard:n}){let r=w(),i=h(),{data:a,isLoading:o,isError:s}=u({destinationId:e}),c=a??[],d=l({onSuccess:()=>{r.invalidateQueries({queryKey:[[...pe]]}),r.invalidateQueries({queryKey:fe})}}),f=v(async t=>{await i({title:`Delete this archive?`,message:`Permanently deletes "${t.label??t.id}" and frees ${G(t.sizeBytes)}.`,confirmLabel:`Delete`,variant:`danger`})&&d.mutate({destinationId:e,backupId:t.id})},[i,e,d]),[p,m]=T(null),g=v(async t=>{m(t.id);try{let n=await ae(he(e,t.id)),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${t.label??t.id}.tar.gz`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}finally{m(null)}},[e]),_=x(()=>[...c].toSorted((e,t)=>t.createdAt-e.createdAt),[c]);return o?E(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:`Loading archives…`}):s?E(`div`,{className:`text-xs text-danger py-2`,children:`Failed to read manifest for this destination`}):_.length===0?E(`div`,{className:`text-xs text-foreground-subtle italic py-2`,children:`No archives at this destination yet.`}):E(`div`,{className:`rounded border border-border bg-surface overflow-x-auto`,children:b(`table`,{className:`w-full text-xs min-w-[640px]`,children:[E(`thead`,{children:b(`tr`,{className:`text-foreground-subtle bg-background/30`,children:[E(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`When`}),E(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Label`}),E(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Includes`}),E(`th`,{className:`text-right px-3 py-1.5 font-medium`,children:`Size`}),E(`th`,{className:`text-right px-3 py-1.5 font-medium w-52`,children:`Actions`})]})}),E(`tbody`,{children:_.map(r=>b(`tr`,{className:`border-t border-border hover:bg-primary/5`,children:[E(`td`,{className:`px-3 py-1.5 text-foreground tabular-nums`,children:ge(r.createdAt)}),E(`td`,{className:`px-3 py-1.5 text-foreground`,children:r.label??E(`span`,{className:`text-foreground-subtle italic`,children:`—`})}),E(`td`,{className:`px-3 py-1.5 text-foreground-subtle`,children:r.locations.join(`, `)}),E(`td`,{className:`px-3 py-1.5 text-foreground text-right tabular-nums`,children:G(r.sizeBytes)}),E(`td`,{className:`px-3 py-1.5`,children:b(`div`,{className:`flex items-center justify-end gap-1`,children:[b(`button`,{onClick:()=>{g(r)},disabled:p===r.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===r.id?E(z,{className:`h-3 w-3 animate-spin`}):E(P,{className:`h-3 w-3`}),`Download`]}),t&&n&&b(`button`,{onClick:()=>n({destinationId:e,archiveId:r.id}),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-primary hover:bg-primary/10`,title:`Restore from this archive`,children:[E(L,{className:`h-3 w-3`}),`Restore`]}),E(`button`,{onClick:()=>{f(r)},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?E(z,{className:`h-3 w-3 animate-spin`}):E(H,{className:`h-3 w-3`})})]})})]},r.id))})]})})}function he(e,t){return`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function ge(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}y();var Y=[[`backup`,`listSchedules`]];function _e({onEdit:e,onOpenRestoreWizard:t}){let{data:r,isLoading:i,isError:o}=a(),s=r??[],c=n().data??[],l=x(()=>{let e=new Map;for(let t of c)e.set(t.id,t);return e},[c]),[u,d]=T(null),f=e=>{d(t=>t===e?null:e)};return i?E(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading backup entries…`}):o?E(`div`,{className:`text-xs text-danger`,children:`Failed to load backup entries`}):s.length===0?E(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-8 text-center`,children:E(`p`,{className:`text-xs text-foreground-subtle`,children:`No backup entries yet. Create one to schedule backups across one or more storage locations.`})}):E(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:b(`table`,{className:`w-full text-xs min-w-[820px]`,children:[E(`thead`,{children:b(`tr`,{className:`text-foreground-subtle border-b border-border bg-background/40`,children:[E(`th`,{className:`text-left px-3 py-2 font-medium w-6`}),E(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Entry`}),E(`th`,{className:`text-left px-3 py-2 font-medium w-20`,children:`Enabled`}),E(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Locations`}),E(`th`,{className:`text-left px-3 py-2 font-medium w-24`,children:`Retention`}),E(`th`,{className:`text-left px-3 py-2 font-medium w-48`,children:`Schedule`}),E(`th`,{className:`text-right px-3 py-2 font-medium w-52`,children:`Actions`})]})}),E(`tbody`,{children:s.map(n=>E(ve,{row:n,destById:l,isOpen:u===n.id,onToggle:()=>f(n.id),onEdit:()=>e(n),...t?{onOpenRestoreWizard:t}:{}},n.id))})]})})}function ve({row:e,destById:t,isOpen:n,onToggle:i,onEdit:a,onOpenRestoreWizard:o}){let s=w(),c=h(),l=d({onSuccess:()=>{s.invalidateQueries({queryKey:Y})}}),u=r({onSuccess:()=>{s.invalidateQueries({queryKey:Y})}}),p=f({onSuccess:()=>{s.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),s.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]})}}),[m,g]=T(String(e.retentionCount));D(()=>{g(String(e.retentionCount))},[e.retentionCount]);let _=x(()=>({id:e.id,label:e.label,cron:e.cron,locationIds:[...e.locationIds],retentionCount:e.retentionCount,...e.dataSources?{dataSources:[...e.dataSources]}:{}}),[e]),y=v(e=>{l.mutate({..._,enabled:e})},[l,_]),S=v(()=>{let t=Number.parseInt(m,10);if(Number.isNaN(t)||t<1){g(String(e.retentionCount));return}t!==e.retentionCount&&l.mutate({..._,enabled:e.enabled,retentionCount:t})},[l,_,m,e.retentionCount,e.enabled]),O=v(()=>{e.locationIds.length!==0&&p.mutate({destinations:[...e.locationIds],...e.dataSources&&e.dataSources.length>0?{locations:[...e.dataSources]}:{},label:e.label,retentionCount:e.retentionCount})},[p,e]),k=v(async()=>{await c({title:`Delete backup entry?`,message:`"${e.label||e.id}" will stop running. Existing archives are kept.`,confirmLabel:`Delete`,variant:`warning`})&&u.mutate({id:e.id})},[c,u,e.id,e.label]),A=e.cron.trim().length>0,j=l.isPending||u.isPending;return b(C,{children:[b(`tr`,{className:`border-t border-border first:border-t-0 hover:bg-primary/5`,children:[E(`td`,{className:`px-2 py-2`,children:E(`button`,{onClick:i,className:`inline-flex items-center justify-center rounded p-1 text-foreground-subtle hover:bg-primary/10 hover:text-foreground`,title:n?`Hide archives`:`Show archives`,children:E(n?re:ne,{className:`h-3.5 w-3.5`})})}),E(`td`,{className:`px-3 py-2`,children:b(`button`,{onClick:a,className:`text-left hover:underline focus:outline-none`,children:[E(`div`,{className:`text-foreground font-medium`,children:e.label||`(unnamed)`}),e.lastRunAt!==void 0&&b(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:[`last run `,new Date(e.lastRunAt).toLocaleString()]})]})}),E(`td`,{className:`px-3 py-2`,children:E(`label`,{className:`inline-flex items-center cursor-pointer`,children:E(`input`,{type:`checkbox`,className:`accent-primary`,checked:e.enabled,disabled:j,onChange:e=>y(e.target.checked)})})}),E(`td`,{className:`px-3 py-2`,children:b(`div`,{className:`flex flex-wrap gap-1`,children:[e.locationIds.length===0&&E(`span`,{className:`text-[11px] text-danger italic`,children:`No locations`}),e.locationIds.map(e=>E(`span`,{className:`inline-flex items-center rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-foreground`,title:e,children:t.get(e)?.displayName??e},e))]})}),E(`td`,{className:`px-3 py-2`,children:E(`input`,{type:`number`,min:1,max:1e3,value:m,disabled:j,onChange:e=>g(e.target.value),onBlur:S,onKeyDown:t=>{t.key===`Enter`&&t.target.blur(),t.key===`Escape`&&g(String(e.retentionCount))},className:`w-16 rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})}),E(`td`,{className:`px-3 py-2`,children:b(`button`,{onClick:a,className:`group flex flex-col items-start gap-0.5 text-left`,title:`Edit schedule`,children:[b(`span`,{className:`inline-flex items-center gap-1`,children:[E(oe,{className:`h-3 w-3 text-foreground-subtle group-hover:text-foreground`}),E(`span`,{className:`font-mono text-[11px] text-foreground`,children:A?e.cron:`Manual`})]}),A&&e.nextRunAt!==void 0&&b(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`next `,new Date(e.nextRunAt).toLocaleString()]})]})}),E(`td`,{className:`px-3 py-2`,children:b(`div`,{className:`flex items-center justify-end gap-1.5`,children:[b(`button`,{onClick:O,disabled:p.isPending||e.locationIds.length===0,className:`inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,title:`Run this entry now`,children:[p.isPending?E(z,{className:`h-3 w-3 animate-spin`}):E(ee,{className:`h-3 w-3`}),`Run now`]}),E(`button`,{onClick:a,className:`inline-flex items-center justify-center rounded border border-border p-1 text-foreground-subtle hover:text-foreground hover:bg-primary/5`,title:`Edit entry`,children:E(F,{className:`h-3 w-3`})}),E(`button`,{onClick:()=>{k()},disabled:j,className:`inline-flex items-center justify-center rounded border border-border p-1 text-foreground-subtle hover:text-danger hover:border-danger/40 disabled:opacity-50`,title:`Delete entry`,children:E(H,{className:`h-3 w-3`})})]})})]}),n&&E(`tr`,{className:`border-t border-border bg-background/30`,children:b(`td`,{colSpan:7,className:`px-4 py-3 space-y-4`,children:[e.locationIds.length===0&&E(`p`,{className:`text-xs text-foreground-subtle italic`,children:`This entry has no locations selected.`}),e.locationIds.map(e=>b(`div`,{className:`space-y-1.5`,children:[E(`div`,{className:`text-[11px] font-medium text-foreground-subtle`,children:t.get(e)?.displayName??e}),E(me,{destinationId:e,restoreSupported:t.get(e)?.restoreSupported??!0,...o?{onOpenRestoreWizard:o}:{}})]},e))]})})]})}y();var X=[{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 ye(e){let t=e.trim();for(let e of X)if(e.cron===t)return e.id;return`custom`}function be({value:e,onChange:t,previewCount:n=5,disabled:r=!1}){let i=ye(e),[a,o]=T(i===`custom`);D(()=>{i!==`custom`&&o(!1)},[i]);let s=Ce(e,250),c=m({cron:s,count:n},{enabled:s.trim().length>0}),l=c.data??null,u=e=>{o(!1),t(e.cron)},d=a||i===`custom`;return b(`div`,{className:`space-y-3`,children:[b(`div`,{className:`space-y-1`,children:[E(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Schedule preset`}),b(`div`,{className:`flex flex-wrap gap-1.5`,children:[X.map(e=>E(`button`,{type:`button`,onClick:()=>u(e),disabled:r,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(!a&&i===e.id?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),title:e.description??e.label,children:e.label},e.id)),E(`button`,{type:`button`,onClick:()=>{o(!0),e.trim().length===0&&t(`0 3 * * *`)},disabled:r,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(d?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),children:`Custom…`})]})]}),d&&b(`div`,{className:`space-y-1`,children:[E(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Cron expression (5-field POSIX)`}),E(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),disabled:r,placeholder:`0 3 * * *`,spellCheck:!1,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`}),b(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Format: `,E(`span`,{className:`font-mono`,children:`minute hour day-of-month month day-of-week`}),` · all times server-local`]})]}),E(xe,{cron:s,preview:l,loading:c.isFetching})]})}function xe({cron:e,preview:t,loading:n}){return n&&t===null?b(`div`,{className:`flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:[E(z,{className:`h-3 w-3 animate-spin`}),`Validating…`]}):t===null?null:t.ok?t.nextRuns.length===0?E(`div`,{className:`rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:`No future runs match this expression.`}):b(`div`,{className:`space-y-1`,children:[E(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Next runs`}),E(`ul`,{className:`rounded border border-border bg-background/40 divide-y divide-border`,children:t.nextRuns.map((e,t)=>b(`li`,{className:`flex items-center justify-between px-3 py-1.5 text-[11px]`,children:[E(`span`,{className:`text-foreground tabular-nums`,children:new Date(e).toLocaleString()}),E(`span`,{className:`text-foreground-subtle text-[10px] tabular-nums`,children:Se(e)})]},`${e}-${t}`))})]}):E(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:t.error??`Invalid cron expression`})}function Se(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 Ce(e,t){let[n,r]=T(e),i=x(()=>e,[e]);return D(()=>{let e=setTimeout(()=>r(i),t);return()=>clearTimeout(e)},[i,t]),n}y();var we=[[`backup`,`listSchedules`]];function Te({entry:e,onClose:t,onSaved:r}){let i=w(),a=n(),o=a.data??[],[s,c]=T(e?.label??``),[l,u]=T(e?.cron??`0 3 * * *`),[f,p]=T(e?.enabled??!0),[m,h]=T(String(e?.retentionCount??7)),[g,_]=T(new Set(e?.locationIds??[])),v=d({onSuccess:()=>{i.invalidateQueries({queryKey:we}),r()}}),y=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},S=Number.parseInt(m,10),C=x(()=>s.trim().length>0&&g.size>0&&!Number.isNaN(S)&&S>=1&&S<=1e3,[s,g,S]),D=()=>{C&&v.mutate({...e?{id:e.id}:{},label:s.trim(),cron:l.trim(),enabled:f,locationIds:Array.from(g),retentionCount:S})},O=v.error instanceof Error?v.error.message:null;return E(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:t,children:b(`div`,{className:`w-full max-w-lg rounded-xl border border-border bg-surface shadow-2xl max-h-[90vh] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:[b(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3 sticky top-0 bg-surface`,children:[E(`h2`,{className:`text-sm font-semibold text-foreground`,children:e?`Edit backup entry`:`New backup entry`}),E(`button`,{onClick:t,className:`text-foreground-subtle hover:text-foreground`,children:E(B,{className:`h-4 w-4`})})]}),b(`div`,{className:`p-4 space-y-4`,children:[b(`div`,{className:`space-y-1`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Name`}),E(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`Nightly offsite`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`})]}),b(`div`,{className:`space-y-1.5`,children:[b(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:[`Locations (`,g.size,` selected)`]}),a.isLoading&&b(`div`,{className:`flex items-center gap-2 px-1 py-2 text-xs text-foreground-subtle`,children:[E(z,{className:`h-3.5 w-3.5 animate-spin`}),`Loading locations…`]}),!a.isLoading&&o.length===0&&E(`div`,{className:`rounded border border-border bg-background px-3 py-2 text-xs text-foreground-subtle italic`,children:"No `backups` storage locations configured. Add one in Settings → Storage first."}),o.length>0&&E(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-52 overflow-y-auto`,children:o.map(e=>b(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[b(`div`,{className:`flex items-center gap-2`,children:[E(`input`,{type:`checkbox`,checked:g.has(e.id),onChange:()=>y(e.id),className:`accent-primary`}),E(`span`,{className:`text-foreground`,children:e.displayName})]}),b(`div`,{className:`flex items-center gap-1.5`,children:[E(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-surface border border-border rounded px-1.5 py-0.5`,children:e.kind}),E(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.id})]})]},e.id))})]}),b(`div`,{className:`grid grid-cols-2 gap-3`,children:[b(`div`,{className:`space-y-1`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Retention (archives kept)`}),E(`input`,{type:`number`,min:1,max:1e3,value:m,onChange:e=>h(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),b(`div`,{className:`space-y-1`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Enabled`}),b(`label`,{className:`inline-flex items-center gap-2 py-1.5 cursor-pointer`,children:[E(`input`,{type:`checkbox`,checked:f,onChange:e=>p(e.target.checked),className:`accent-primary`}),E(`span`,{className:`text-xs text-foreground-subtle`,children:`Run on schedule`})]})]})]}),b(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Schedule`}),E(be,{value:l,onChange:u,disabled:v.isPending})]}),O&&E(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:O})]}),b(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3 sticky bottom-0 bg-surface`,children:[E(`button`,{onClick:t,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),b(`button`,{onClick:D,disabled:!C||v.isPending,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[v.isPending&&E(z,{className:`h-3.5 w-3.5 animate-spin`}),e?`Save`:`Create entry`]})]})]})})}y();var Ee=[[`backup`,`list`]];function De({initialDestinationId:e,initialArchiveId:t,onClose:r,onScheduled:a}){let o=w(),[s,l]=T(e&&t?2:1),[d,f]=T(e),[p,m]=T(t),[h,g]=T(new Set),{data:_}=n(),v=_??[],{data:y,isLoading:S}=u({destinationId:d??``},{enabled:!!d}),C=y??[];D(()=>{if(d!==void 0)return;let e=v.filter(e=>e.restoreSupported);e.length===1&&f(e[0].id)},[d,v]);let{data:O}=c({destinationId:d??``,backupId:p??``},{enabled:!!d&&!!p}),k=x(()=>O?.locations??[],[O]);D(()=>{k.length!==0&&g(e=>e.size===0?new Set(k):e)},[k]);let A=i({onSuccess:()=>{o.invalidateQueries({queryKey:Ee}),a(),r()}}),j=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},M=!!d&&!!p,N=h.size>0,P=M&&N&&!A.isPending,F=()=>{!d||!p||A.mutate({destinationId:d,backupId:p,locations:[...h]})};return E(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:r,children:b(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[b(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[b(`div`,{className:`space-y-0.5`,children:[E(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Restore Backup`}),b(`p`,{className:`text-xs text-foreground-subtle`,children:[`Step `,s,` of 3 —`,` `,s===1?`pick source`:s===2?`pick locations`:`confirm`]})]}),E(`button`,{onClick:r,className:`text-foreground-subtle hover:text-foreground`,children:E(B,{className:`h-4 w-4`})})]}),s===1&&E(Oe,{destinations:v,destinationId:d,onPickDestination:e=>{f(e),m(void 0),g(new Set)},archives:C,archivesLoading:S,archiveId:p,onPickArchive:m}),s===2&&E(ke,{locations:k,picked:h,onToggle:j}),s===3&&E(Ae,{destinationName:v.find(e=>e.id===d)?.displayName??d??``,archive:C.find(e=>e.id===p),picked:[...h]}),b(`div`,{className:`flex justify-between gap-2 border-t border-border px-4 py-3`,children:[E(`div`,{children:s>1&&b(`button`,{onClick:()=>l(e=>e===3?2:1),className:`inline-flex items-center gap-1 rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:[E(ie,{className:`h-3 w-3`}),`Back`]})}),b(`div`,{className:`flex items-center gap-2`,children:[E(`button`,{onClick:r,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),s<3?b(`button`,{disabled:s===1&&!M||s===2&&!N,onClick:()=>l(e=>e===1?2:3),className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[`Next`,E(J,{className:`h-3 w-3`})]}):b(`button`,{onClick:F,disabled:!P,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[A.isPending?E(z,{className:`h-3.5 w-3.5 animate-spin`}):E(L,{className:`h-3.5 w-3.5`}),`Schedule Restore`]})]})]})]})})}function Oe({destinations:e,destinationId:t,onPickDestination:n,archives:r,archivesLoading:i,archiveId:a,onPickArchive:o}){let s=e.filter(e=>e.restoreSupported);return b(`div`,{className:`p-4 space-y-3`,children:[b(`div`,{className:`space-y-1.5`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Destination`}),b(`select`,{value:t??``,onChange:e=>n(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:[E(`option`,{value:``,disabled:!0,children:`Select destination…`}),s.map(e=>b(`option`,{value:e.id,children:[e.displayName,` (`,e.kind,`)`]},e.id))]})]}),b(`div`,{className:`space-y-1.5`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Archive`}),!t&&E(`div`,{className:`text-xs text-foreground-subtle italic`,children:`Pick a destination first.`}),t&&i&&E(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Reading archives…`}),t&&!i&&r.length===0&&E(`div`,{className:`text-xs text-foreground-subtle italic`,children:`No archives available at this destination.`}),t&&r.length>0&&E(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:r.map(e=>{let t=a===e.id;return b(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${t?`bg-primary/10`:`hover:bg-primary/5`}`,children:[b(`div`,{className:`flex items-center gap-2`,children:[E(`input`,{type:`radio`,name:`archive`,checked:t,onChange:()=>o(e.id),className:`accent-primary`}),b(`div`,{children:[E(`div`,{className:`font-medium text-foreground`,children:e.label??e.id}),E(`div`,{className:`text-[10px] text-foreground-subtle`,children:new Date(e.createdAt).toLocaleString()})]})]}),E(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:G(e.sizeBytes)})]},e.id)})})]})]})}function ke({locations:e,picked:t,onToggle:n}){return e.length===0?E(`div`,{className:`p-4`,children:E(`div`,{className:`text-xs text-foreground-subtle`,children:`Loading archive manifest… If this persists, the archive may predate manifests — restoring will apply everything in the tarball.`})}):b(`div`,{className:`p-4 space-y-3`,children:[E(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:`Selected entries will overwrite live data on the next server restart. Unchecked entries stay current.`}),b(`div`,{className:`space-y-1.5`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Apply`}),E(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:e.map(e=>b(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[E(`input`,{type:`checkbox`,checked:t.has(e),onChange:()=>n(e),className:`accent-primary`}),E(`span`,{className:`font-mono text-foreground`,children:e}),E(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:je(e)})]},e))})]})]})}function Ae({destinationName:e,archive:t,picked:n}){return b(`div`,{className:`p-4 space-y-3 text-xs`,children:[E(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-amber-700 dark:text-amber-300`,children:`Restore is applied at next server boot. Active connections will drop when you restart.`}),b(`dl`,{className:`space-y-1.5`,children:[E(Z,{term:`Destination`,value:e}),E(Z,{term:`Archive`,value:t?.label??t?.id??`—`}),t&&E(Z,{term:`Created`,value:`${new Date(t.createdAt).toLocaleString()} · ${G(t.sizeBytes)}`}),E(Z,{term:`Locations`,value:n.length>0?n.join(`, `):`— (full archive)`})]})]})}function Z({term:e,value:t}){return b(`div`,{className:`flex justify-between gap-3`,children:[E(`dt`,{className:`text-foreground-subtle`,children:e}),E(`dd`,{className:`text-foreground font-mono text-right truncate`,children:t})]})}var Q={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function je(e){return Q[e]??``}y();function Me(){let e=h(),n=t(),[r,i]=T(null),[a,o]=T(!1),[s,c]=T(!1),[l,u]=T(void 0),d=async()=>{await e({title:`Restart server now?`,message:`Active connections will drop and the apply-backup hook will run before boot.`,confirmLabel:`Restart`,variant:`warning`})&&n.mutate({confirm:!0})};return b(U,{children:[b(`div`,{className:`flex items-center justify-end gap-2 flex-wrap`,children:[b(`button`,{onClick:()=>o(!0),className:`inline-flex items-center gap-1.5 rounded-lg bg-surface border border-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5 hover:border-primary/30`,children:[E(L,{className:`h-3.5 w-3.5`}),`Restore…`]}),b(`button`,{onClick:()=>u(null),className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:[E(te,{className:`h-3.5 w-3.5`}),`New entry`]})]}),s&&E(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs text-amber-700 dark:text-amber-300`,children:b(`div`,{className:`flex items-center justify-between gap-3`,children:[b(`div`,{className:`flex items-center gap-2`,children:[E(L,{className:`h-3.5 w-3.5`}),E(`span`,{children:`Restore scheduled. Restart the server to apply.`})]}),b(`button`,{onClick:()=>{d()},disabled:n.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:[n.isPending?E(z,{className:`h-3.5 w-3.5 animate-spin`}):E(L,{className:`h-3.5 w-3.5`}),`Restart Now`]})]})}),E(_e,{onEdit:e=>u(e),onOpenRestoreWizard:e=>i(e)}),l!==void 0&&E(Te,{entry:l,onClose:()=>u(void 0),onSaved:()=>u(void 0)}),(r||a)&&E(De,{...r?{initialDestinationId:r.destinationId,initialArchiveId:r.archiveId}:{},onClose:()=>{i(null),o(!1)},onScheduled:()=>c(!0)})]})}y();var $=5e3,Ne={"winston-logging":`Rotated log files on this node’s disk.`,"console-logging":`stdout / stderr of the node process.`,"loki-logging":`Pushes to a Grafana Loki instance. Off until enabled with a URL.`,"hub-forwarder":`Agent-only — forwards this node’s entries to the hub.`};function Pe(){let e=_({capName:`log-destination`},{refetchInterval:$}),t=p(void 0,{refetchInterval:$}),n=x(()=>K(t.data??[]),[t.data]),r=x(()=>{let e=new Map;for(let n of t.data??[]){let t=n.description,r=n.id;typeof r==`string`&&typeof t==`string`&&t.length>0&&e.set(r,t)}return e},[t.data]);return E(I,{title:`Logging`,subtitle:`Every registered log destination. Entries are fanned to all enabled destinations at once — enabling one does not disable another. Each destination's own configuration is docked under it.`,pageIcon:V,itemIcon:se,capability:`log-destination`,installButtonLabel:`Add destination`,items:x(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:n.get(e.addonId)??e.addonId,isActive:e.isActive,caption:r.get(e.addonId)??Ne[e.addonId]??``})),[e.data,n,r]),isLoading:e.isLoading,emptyTitle:`No log destinations registered`,emptyDescription:`This should not happen — the console and rotated-file destinations are builtins. If the list is empty, the node is still booting.`,renderStatusBadges:e=>e.caption.length>0?E(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.caption}):null})}function Fe(){return E(`div`,{className:`flex flex-col p-4`,children:E(W,{tabs:[{id:`storage`,label:`Storage`,icon:A,content:E(de,{})},{id:`backup`,label:`Backup`,icon:q,content:E(Me,{})},{id:`logging`,label:`Logging`,icon:V,content:E(Pe,{})}]})})}export{Fe as DataPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$n as e,Ao as t,Bo as n,Fo as r,Jn as i,Kn as a,Mo as o,No as s,Po as c,Qn as l,Ro as u,Vo as d,Xn as f,Yn as p,Zn as m,er as h,ir as g,jn as _,jo as v,nr as y,qn as b,ro as x,rr as S,tr as C,uo as w}from"./src-BxX2FkJ3.js";import{K as T,Q as E,S as D,W as O,b as k,o as A,q as j,x as M,z as N}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{K as P}from"./src-CV0JUB8F.js";import{a as F,i as I,n as L,r as ee,t as R}from"./face-bbox-D2xVdmEv.js";import{a as te,c as ne,f as z,i as re,l as ie,m as B,n as V,o as ae,p as H,r as oe,s as se,t as ce,u as le}from"./debounced-invalidate-D66PzHBd.js";import{t as U}from"./pencil-DMAfyiaP.js";import{t as W}from"./plus-DBb9xrVk.js";import{t as ue}from"./refresh-cw-B0NcvZHF.js";import{t as G}from"./square-check-big-p7HpHDXe.js";import{t as de}from"./square-DX2ha0JW.js";import{t as K}from"./undo-2-BWEA1U6J.js";import{F as q,G as fe,L as pe,R as me,S as J,h as Y,i as X,l as he,s as Z}from"./index-dqzu-f71.js";import{t as Q}from"./AdminPage-Dq33XE9j.js";import{r as ge,t as _e}from"./authed-media-B8T1dsFh.js";var ve=fe(`user-round`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]);E();var $=[[`faceGallery`]];function ye({identityId:e}){let t=A(),{data:n,isLoading:r}=l({identityId:e}),i=h();function a(n){i.mutate({identityId:e,sampleId:n.id},{onSettled:()=>{t.invalidateQueries({queryKey:$})}})}return r?D(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,children:[M(J,{className:`h-3.5 w-3.5 animate-spin`}),`Loading samples…`]}):!n||n.length===0?M(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No samples yet.`}):M(`div`,{className:`mt-2 grid grid-cols-4 gap-2 sm:grid-cols-6 md:grid-cols-8`,children:n.map(e=>D(`div`,{className:`group relative aspect-square overflow-hidden rounded-md border border-border bg-surface`,children:[e.base64?M(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Sample`,className:`h-full w-full object-cover`}):M(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:M(ve,{className:`h-6 w-6`})}),M(`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:M(X,{className:`h-4 w-4 text-white`})})]},e.id))})}function be({identity:e,expanded:i,onToggle:a}){let l=A(),[f,m]=j(``),[h,g]=j(!1),[_,y]=j(!1),b=C(),x=p();function S(){m(e.name),g(!0)}function w(){g(!1),m(``)}function T(){let t=f.trim();if(!t||t===e.name){w();return}b.mutate({id:e.id,name:t},{onSettled:()=>{l.invalidateQueries({queryKey:$}),w()}})}function E(){x.mutate({id:e.id},{onSettled:()=>{l.invalidateQueries({queryKey:$}),y(!1)}})}return D(`div`,{className:`rounded-md border border-border bg-surface`,children:[D(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[M(`div`,{className:`h-8 w-8 shrink-0 overflow-hidden rounded-full border border-border bg-surface-hover`,children:e.coverBase64?M(`img`,{src:`data:image/jpeg;base64,${e.coverBase64}`,alt:e.name,className:`h-full w-full object-cover`}):M(`div`,{className:`flex h-full w-full items-center justify-center`,children:M(ve,{className:`h-4 w-4 text-foreground-subtle`})})}),M(`div`,{className:`flex flex-1 min-w-0 items-center gap-2`,children:h?D(k,{children:[M(u,{value:f,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&T(),e.key===`Escape`&&w()},className:`h-6 text-xs`,autoFocus:!0}),M(`button`,{type:`button`,onClick:T,disabled:b.isPending,className:`text-success hover:text-success/80 disabled:opacity-50`,"aria-label":`Confirm rename`,children:M(me,{className:`h-3.5 w-3.5`})}),M(`button`,{type:`button`,onClick:w,className:`text-foreground-subtle hover:text-foreground`,"aria-label":`Cancel rename`,children:M(X,{className:`h-3.5 w-3.5`})})]}):M(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name})}),M(n,{variant:`default`,className:`text-[10px]`,children:e.sampleCount}),!h&&D(`div`,{className:`flex items-center gap-1`,children:[M(`button`,{type:`button`,onClick:S,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground`,"aria-label":`Rename`,children:M(U,{className:`h-3.5 w-3.5`})}),M(`button`,{type:`button`,onClick:()=>y(!0),className:`p-1 rounded hover:bg-danger/10 text-foreground-subtle hover:text-danger`,"aria-label":`Delete`,children:M(Z,{className:`h-3.5 w-3.5`})})]}),M(`button`,{type:`button`,onClick:a,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":i?`Collapse`:`Expand`,children:M(i?pe:q,{className:`h-3.5 w-3.5`})})]}),i&&M(`div`,{className:`border-t border-border px-3 pb-3 pt-2`,children:M(ye,{identityId:e.id})}),M(t,{open:_,onOpenChange:e=>!e&&y(!1),children:D(v,{children:[D(c,{children:[M(r,{children:`Delete person`}),D(o,{children:[`Delete `,M(`strong`,{children:e.name}),` and all their samples? This cannot be undone.`]})]}),D(s,{children:[M(d,{variant:`secondary`,onClick:()=>y(!1),children:`Cancel`}),D(d,{variant:`danger`,onClick:E,disabled:x.isPending,children:[x.isPending?M(J,{className:`h-3.5 w-3.5 animate-spin`}):null,`Delete`]})]})]})})]})}function xe(){let e=A(),[t,n]=j(``),r=b();function i(){let i=t.trim();i&&r.mutate({name:i},{onSettled:()=>{e.invalidateQueries({queryKey:$}),n(``)}})}return D(`div`,{className:`flex items-center gap-2 pt-2`,children:[M(u,{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`}),D(d,{variant:`primary`,size:`sm`,onClick:i,disabled:r.isPending||!t.trim(),children:[r.isPending?M(J,{className:`h-3.5 w-3.5 animate-spin`}):M(W,{className:`h-3.5 w-3.5`}),`Add`]})]})}function Se(){let{data:e,isLoading:t}=m(),[n,r]=j(null);function i(e){r(t=>t===e?null:e)}return t?D(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[M(J,{className:`h-4 w-4 animate-spin`}),`Loading people…`]}):D(`div`,{className:`space-y-2`,children:[(!e||e.length===0)&&M(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No people enrolled yet. Add one below.`}),e?.map(e=>M(be,{identity:e,expanded:n===e.id,onToggle:()=>i(e.id)},e.id)),M(xe,{})]})}function Ce(e){let t=e.cropUrl!==void 0&&e.cropUrl.length>0,n=e.base64!==void 0&&e.base64.length>0;return!t&&!n}function we(e){return e.filter(Ce).map(e=>e.faceId)}function Te(e){let t=0;for(let n of e)Ce(n)&&(t+=1);return t}E();var Ee=[[`faceGallery`]];function De({faceIds:e,identities:n,onDone:i}){let l=A(),f=a(),p=b(),[m,h]=j(``),[g,_]=j(!1),[y,x]=j(null),S=e!==null&&e.length>0,C=e?.length??0;function w(){_(!1),h(``),x(null)}function T(){w(),i()}function E(t){!e||e.length===0||f.mutate({faceIds:[...e],identityId:t},{onSettled:()=>{l.invalidateQueries({queryKey:Ee}),T()}})}function O(){!e||!m.trim()||p.mutate({name:m.trim()},{onSuccess:e=>{e?.id&&E(e.id)},onError:()=>{l.invalidateQueries({queryKey:Ee}),T()}})}let k=f.isPending||p.isPending;return M(t,{open:S,onOpenChange:e=>!e&&T(),children:D(v,{children:[D(c,{children:[M(r,{children:C>1?`Assign ${String(C)} faces to person`:`Assign face to person`}),M(o,{children:`Select an existing person or create a new one.`})]}),M(`div`,{className:`space-y-1 max-h-56 overflow-y-auto`,children:n.map(e=>D(`button`,{type:`button`,onClick:()=>x(e.id),className:`w-full rounded-md px-3 py-2 text-left text-xs transition-colors ${y===e.id?`bg-primary/12 text-primary`:`hover:bg-surface-hover text-foreground`}`,children:[M(`span`,{className:`font-medium`,children:e.name}),D(`span`,{className:`ml-2 text-foreground-subtle`,children:[e.sampleCount,` samples`]})]},e.id))}),g?M(`div`,{className:`flex items-center gap-2 pt-2 border-t border-border`,children:M(u,{placeholder:`New person name…`,value:m,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&O()},autoFocus:!0,className:`flex-1`})}):M(`button`,{type:`button`,onClick:()=>{x(null),_(!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…`}),D(s,{children:[M(d,{variant:`secondary`,onClick:T,disabled:k,children:`Cancel`}),g?D(d,{variant:`primary`,onClick:O,disabled:k||!m.trim(),children:[k&&M(J,{className:`h-3.5 w-3.5 animate-spin`}),`Create & assign`]}):D(d,{variant:`primary`,onClick:()=>y&&E(y),disabled:k||!y,children:[k&&M(J,{className:`h-3.5 w-3.5 animate-spin`}),`Assign`,C>1?` ${String(C)}`:``]})]})]})})}E();function Oe(e){let[t,n]=j(null),[r,i]=j(null),[a,o]=j(!1);return N(()=>{if(n(null),i(null),o(!1),!e)return;let t=!1,r=null;return(async()=>{try{let i=await ge(`${_e}/${encodeURIComponent(e)}`);if(t)return;r=URL.createObjectURL(i),n(r)}catch{t||o(!0)}})(),()=>{t=!0,r&&URL.revokeObjectURL(r)}},[e]),N(()=>{if(!t)return;let e=new Image;return e.onload=()=>i({width:e.naturalWidth,height:e.naturalHeight}),e.onerror=()=>o(!0),e.src=t,()=>{e.onload=null,e.onerror=null}},[t]),{frameSrc:t,naturalWidth:r?.width??null,naturalHeight:r?.height??null,failed:a}}function ke(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 Ae({label:e,value:t}){return D(`div`,{className:`flex items-baseline justify-between gap-3 py-1.5 border-b border-border/60 last:border-0`,children:[M(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:e}),M(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-foreground`,children:t})]})}function je({box:e}){return M(`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:M(`span`,{className:`absolute -top-4 left-0 rounded bg-primary px-1 text-[9px] font-semibold uppercase tracking-wide text-white`,children:`Face`})})}function Me({face:e,cameraName:n,onClose:r,onAssign:i,onUnassign:a,onDelete:o,actionsPending:s}){let{data:c,isFetching:l}=f({faceId:e?.faceId??``},{enabled:e!==null}),[u,p]=j(`frame`),{frameSrc:m,naturalWidth:h,naturalHeight:g,failed:_}=Oe(e?.keyFrameMediaKey),y=O(()=>{let t=ke(c??[]);return t?`data:image/jpeg;base64,${t.base64}`:e?.base64?`data:image/jpeg;base64,${e.base64}`:null},[c,e]),b=O(()=>!e?.faceBbox||h===null||g===null?null:R(e.faceBbox,h,g),[e?.faceBbox,h,g]);if(e===null)return null;let x=typeof e.keyFrameMediaKey==`string`&&e.keyFrameMediaKey.length>0&&!_,S=x&&u===`frame`,C=e.assigned?e.identityName??`Assigned`:e.recognizedIdentityId?`${e.identityName??`Recognized`} (suggested)`:`Unassigned`;return M(t,{open:!0,onOpenChange:e=>!e&&r(),children:D(v,{width:`lg`,placement:`sheet-on-mobile`,"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:[D(`header`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-border px-4 py-3`,children:[D(`div`,{className:`min-w-0`,children:[M(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:`Face detail`}),M(`div`,{className:`mt-0.5 truncate text-[11px] text-foreground-subtle`,children:n})]}),M(`button`,{type:`button`,onClick:r,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:M(X,{className:`h-4 w-4`})})]}),D(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 py-3`,children:[x&&D(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5 text-xs`,children:[D(`button`,{type:`button`,onClick:()=>p(`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:[M(I,{className:`h-3.5 w-3.5`}),` Full frame`]}),D(`button`,{type:`button`,onClick:()=>p(`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:[M(F,{className:`h-3.5 w-3.5`}),` Crop`]})]}),S&&m?M(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:M(V,{src:m,alt:`Full frame with detected face`,fit:`natural`,className:`w-full`,overlay:b?M(je,{box:b}):void 0})}):y?D(`div`,{className:`relative aspect-square w-full overflow-hidden rounded-lg border border-border`,children:[M(V,{src:y,alt:`Detected face`,className:`h-full w-full`}),l&&M(`div`,{className:`absolute right-2 top-2 rounded-full bg-black/50 p-1 text-white`,children:M(J,{className:`h-3.5 w-3.5 animate-spin`})})]}):D(`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:[M(B,{className:`h-8 w-8 text-warning/70`}),M(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-warning/80`,children:`No image`}),M(`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.`})]}),D(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-1`,children:[M(Ae,{label:`Camera`,value:n}),M(Ae,{label:`Captured`,value:H(e.timestamp)}),M(Ae,{label:`Track`,value:e.trackId}),M(Ae,{label:`Identity`,value:C})]})]}),D(`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?D(d,{variant:`secondary`,onClick:()=>a(e.faceId),disabled:s,children:[M(L,{className:`h-3.5 w-3.5`}),` Detach`]}):D(d,{variant:`primary`,onClick:()=>i(e.faceId),disabled:s,children:[M(ee,{className:`h-3.5 w-3.5`}),` Assign`]}),D(d,{variant:`secondary`,onClick:()=>o(e.faceId),disabled:s,children:[M(Z,{className:`h-3.5 w-3.5`}),` Delete`]})]})]})})}function Ne(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Pe(e,t){return e.faceIds.filter(e=>!t.has(e))}function Fe(e,t){return e.faceIds.filter(e=>t(e))}E();var Ie=[[`faceGallery`]],Le=20,Re=.3,ze=.9,Be=.05,Ve=.5,He=2,Ue=10,We=2;function Ge({cluster:e,face:t,active:n,onSelect:r}){return D(`button`,{type:`button`,onClick:r,className:`flex shrink-0 flex-col items-center gap-1.5 rounded-md border p-2 text-center transition-colors md:w-full md:flex-row md:gap-2.5 md:text-left ${n?`border-primary bg-primary/8`:`border-border bg-surface hover:bg-surface-hover`}`,children:[M(`div`,{className:`h-24 w-24 shrink-0 overflow-hidden rounded bg-surface-hover`,children:t?.base64?M(`img`,{src:`data:image/jpeg;base64,${t.base64}`,alt:``,className:`h-24 w-24 object-cover`}):M(B,{className:`h-24 w-24 p-6 text-foreground-subtle`})}),D(`span`,{className:`w-24 text-[11px] leading-tight text-foreground-subtle md:w-auto`,children:[e.size,` faces · `,Math.round(e.cohesion*100),`% alike`]})]})}function Ke({face:e,cameraName:t,nowMs:n,excluded:r,onToggleExclude:i,onDelete:a,deletePending:o}){return D(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden transition-opacity ${r?`border-border opacity-40 grayscale`:`border-border`}`,children:[D(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[e.base64?M(V,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Face from ${t}`,className:`h-full w-full`}):D(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,children:[M(B,{className:`h-7 w-7 text-warning/70`}),M(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}),M(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),i()},className:`absolute right-1 top-1 z-10 rounded-full bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":r?`Include face`:`Exclude face`,title:r?`Include`:`Exclude`,children:M(r?K:X,{className:`h-3.5 w-3.5`})})]}),D(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[M(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:t,children:t}),M(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:z(e.timestamp,n)})]}),M(`div`,{className:`mt-1 flex items-center justify-end border-t border-border/60 px-1 py-0.5`,children:M(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a()},disabled:o,className:`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:o?M(J,{className:`h-4 w-4 animate-spin`}):M(Z,{className:`h-4 w-4`})})})]})}function qe({open:e,onClose:n,byId:r,cameraName:a,nowMs:o,identities:s,selectMany:c}){let l=A(),u=x(),f=i(),[p,m]=j(Ve),[h,g]=j(We),[_,b]=j(null),[S,C]=j({}),[w,T]=j(null),{data:E,isFetching:P,refetch:F}=y({threshold:p,minClusterSize:h,limit:Le},{enabled:e}),I=E??[];N(()=>{C({})},[p,h]),N(()=>{if(I.length===0){b(null);return}I.some(e=>e.representativeFaceId===_)||b(I[0]?.representativeFaceId??null)},[I]);let L=O(()=>I.find(e=>e.representativeFaceId===_)??null,[I,_]),R=L?S[L.representativeFaceId]??new Set:new Set,te=O(()=>L?Fe(L,e=>r.has(e)):[],[L,r]),ne=L?L.faceIds.length-te.length:0,z=L?Pe({...L,faceIds:te},R):[];function re(e){if(!L)return;let t=L.representativeFaceId;C(n=>({...n,[t]:Ne(n[t]??new Set,e)}))}function ie(){l.invalidateQueries({queryKey:Ie})}async function B(e){await u({title:`Delete face`,message:`Permanently deletes this face crop. This cannot be undone.`,confirmLabel:`Delete`,variant:`danger`})&&f.mutate({faceId:e},{onSettled:ie})}function V(){T(null),n()}function ae(){z.length!==0&&(c(z),V())}return D(t,{open:e,onOpenChange:e=>!e&&V(),children:[D(v,{placement:`sheet-on-mobile`,width:`lg`,"aria-label":`Look-alike groups`,className:`flex max-h-[92dvh] flex-col gap-0 overflow-hidden p-0 md:max-w-4xl`,children:[D(`header`,{className:`flex shrink-0 flex-col gap-2 border-b border-border px-4 py-3`,children:[D(`div`,{className:`flex items-center justify-between gap-2`,children:[D(`div`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[M(he,{className:`h-4 w-4 text-primary`}),` Look-alike groups`]}),M(`button`,{type:`button`,onClick:V,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:M(X,{className:`h-4 w-4`})})]}),D(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[D(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Threshold`,M(`input`,{type:`range`,min:Re,max:ze,step:Be,value:p,onChange:e=>m(Number(e.target.value)),className:`h-1.5 w-28 cursor-pointer accent-primary`}),M(`span`,{className:`w-8 shrink-0 text-right font-mono text-[11px] tabular-nums text-foreground`,children:p.toFixed(2)})]}),D(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Min size`,M(`input`,{type:`number`,min:He,max:Ue,step:1,value:h,onChange:e=>g(Math.min(Ue,Math.max(He,Number(e.target.value)||He))),className:`w-12 rounded border border-border bg-background px-1.5 py-0.5 text-xs text-foreground`})]}),D(d,{variant:`secondary`,onClick:()=>{C({}),F()},disabled:P,children:[P?M(J,{className:`h-3.5 w-3.5 animate-spin`}):M(ue,{className:`h-3.5 w-3.5`}),`Re-analyze`]})]})]}),M(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden px-4 py-3 md:flex-row`,children:P&&I.length===0?D(`div`,{className:`flex flex-1 items-center justify-center gap-2 py-8 text-xs text-foreground-subtle`,children:[M(J,{className:`h-4 w-4 animate-spin`}),` Finding similar faces…`]}):I.length===0?M(`div`,{className:`flex flex-1 items-center justify-center py-8 text-xs text-foreground-subtle`,children:`No look-alike groups at this threshold.`}):D(k,{children:[M(`div`,{className:`flex gap-2 overflow-x-auto pb-1 md:hidden`,children:I.map(e=>M(Ge,{cluster:e,face:r.get(e.representativeFaceId),active:e.representativeFaceId===_,onSelect:()=>b(e.representativeFaceId)},e.representativeFaceId))}),M(`div`,{className:`hidden shrink-0 flex-col gap-2 overflow-y-auto md:flex md:w-56`,children:I.map(e=>M(Ge,{cluster:e,face:r.get(e.representativeFaceId),active:e.representativeFaceId===_,onSelect:()=>b(e.representativeFaceId)},e.representativeFaceId))}),M(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:L&&D(k,{children:[ne>0&&D(`p`,{className:`mb-2 text-[11px] text-foreground-subtle`,children:[ne,` not loaded — excluded from actions`]}),M(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(13rem,1fr))] gap-2`,children:te.map(e=>{let t=r.get(e);return t?M(Ke,{face:t,cameraName:a(t.deviceId),nowMs:o,excluded:R.has(e),onToggleExclude:()=>re(e),onDelete:()=>void B(e),deletePending:f.isPending&&f.variables?.faceId===e},e):null})})]})})]})}),D(`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:[M(d,{variant:`secondary`,onClick:ae,disabled:z.length===0,children:`Select in gallery`}),D(d,{variant:`primary`,onClick:()=>T(z),disabled:z.length===0,children:[M(ee,{className:`h-3.5 w-3.5`}),` Adopt (`,z.length,`)`]})]})]}),M(De,{faceIds:w,identities:s,onDone:()=>T(null)})]})}E();var Je=[[`faceGallery`]],Ye=500,Xe=120;function Ze({face:e,cameraName:t,nowMs:n,selected:r,onToggleSelect:a,onAssign:o,onOpenDetail:s}){let c=A(),l=S(),u=i(),d=()=>{c.invalidateQueries({queryKey:Je})},f=()=>s(e.faceId),p=e.cropUrl!==void 0&&e.cropUrl.length>0?e.cropUrl:e.base64!==void 0&&e.base64.length>0?`data:image/jpeg;base64,${e.base64}`:null;return D(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden ${r?`border-primary ring-1 ring-primary`:`border-border`}`,children:[D(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[p===null?D(`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:[M(B,{className:`h-7 w-7 text-warning/70`}),M(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}):M(`img`,{src:p,alt:`Face from ${t}`,onClick:f,loading:`lazy`,decoding:`async`,className:`h-full w-full cursor-zoom-in object-cover`}),M(`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?M(G,{className:`h-4 w-4 text-primary`}):M(de,{className:`h-4 w-4`})})]}),D(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[M(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:t,children:t}),M(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:z(e.timestamp,n)}),e.identityName&&M(`p`,{className:`text-[10px] font-medium text-primary truncate`,title:e.identityName,children:e.identityName})]}),D(`div`,{className:`mt-1 flex items-center gap-0.5 border-t border-border/60 px-1 py-0.5`,children:[e.assigned?M(`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?M(J,{className:`h-4 w-4 animate-spin`}):M(L,{className:`h-4 w-4`})}):M(`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:M(ee,{className:`h-4 w-4`})}),M(`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?M(J,{className:`h-4 w-4 animate-spin`}):M(Z,{className:`h-4 w-4`})})]})]})}var Qe=[{label:`All`,value:`all`},{label:`Unassigned`,value:`unassigned`},{label:`Recognized`,value:`recognized`}];function $e(){let t=A(),[n,r]=j(`all`),[o,s]=j(se),[c,l]=j(new Set),[u,f]=j(new Set),[p,h]=j(null),[v,y]=j(!1),[b,x]=j(null),{data:C,isLoading:w}=e({limit:Ye,filter:n},{refetchInterval:3e4}),{data:T=[]}=m(),{data:E}=_({}),N=a(),P=S(),F=g(),I=i(),R=Date.now(),z=C??[],V=O(()=>{let e=new Map;for(let t of E??[])e.set(t.id,t.name);return e},[E]),H=e=>V.get(e)??`Camera #${String(e)}`,ce=O(()=>ne(z).map(e=>({id:e,name:H(e)})).sort((e,t)=>e.name.localeCompare(t.name)),[z,V]),U=O(()=>ie(le(z,o),c),[z,o,c]),W=ae(U,Xe,O(()=>JSON.stringify([n,o.fromMs,o.toMs,[...c].sort((e,t)=>e-t)]),[n,o.fromMs,o.toMs,c])),ue=O(()=>new Map(z.map(e=>[e.faceId,e])),[z]),G=O(()=>Te(U),[U]),de=b===null?null:ue.get(b)??null,K=()=>{t.invalidateQueries({queryKey:Je})},q=()=>f(new Set);function fe(e){f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function pe(e){f(t=>{let n=new Set(t);for(let t of e)n.add(t);return n})}function me(){pe(we(U))}let Y=[...u],Q=N.isPending||F.isPending||I.isPending,ge=P.isPending||I.isPending;function _e(){Y.length!==0&&F.mutate({faceIds:Y},{onSettled:()=>{K(),q()}})}function ve(){Y.length!==0&&Promise.allSettled(Y.map(e=>I.mutateAsync({faceId:e}))).then(()=>{K(),q()})}function $(e){x(null),h([e])}function ye(e){P.mutate({faceId:e},{onSettled:K}),x(null)}function be(e){I.mutate({faceId:e},{onSettled:K}),x(null)}let xe=U.length!==z.length;return D(`div`,{className:`relative space-y-3`,children:[D(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[M(`div`,{className:`flex items-center gap-1`,children:Qe.map(e=>M(`button`,{type:`button`,onClick:()=>r(e.value),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${n===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.label},e.value))}),M(oe,{onChange:s}),M(re,{cameras:ce,selected:c,onChange:l}),D(`button`,{type:`button`,onClick:()=>y(!0),className:`flex items-center gap-1 rounded-md px-2.5 py-1 text-xs transition-colors ${v?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[M(he,{className:`h-3.5 w-3.5`}),` Similar groups`]}),!w&&G>0&&D(`button`,{type:`button`,onClick:me,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:[M(B,{className:`h-3.5 w-3.5`}),` Select `,G,` crop-less`]}),!w&&M(`span`,{className:`text-[10px] text-foreground-subtle ${G>0?`ml-2`:`ml-auto`}`,children:xe?`${String(U.length)} of ${String(z.length)} faces`:`${String(U.length)} face${U.length===1?``:`s`}`})]}),u.size>0&&D(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[D(`span`,{className:`text-xs font-medium text-foreground`,children:[u.size,` selected`]}),D(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[D(d,{variant:`primary`,onClick:()=>h(Y),disabled:Q,children:[M(ee,{className:`h-3.5 w-3.5`}),` Assign`]}),D(d,{variant:`secondary`,onClick:_e,disabled:Q,children:[F.isPending?M(J,{className:`h-3.5 w-3.5 animate-spin`}):M(L,{className:`h-3.5 w-3.5`}),` `,`Detach`]}),D(d,{variant:`secondary`,onClick:ve,disabled:Q,children:[M(Z,{className:`h-3.5 w-3.5`}),` Delete`]}),M(d,{variant:`ghost`,onClick:q,disabled:Q,children:M(X,{className:`h-3.5 w-3.5`})})]})]}),w&&D(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[M(J,{className:`h-4 w-4 animate-spin`}),` Loading faces…`]}),!w&&U.length===0&&M(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:z.length>0?`No faces match the current date / camera filters.`:`No faces found for this filter.`}),!w&&U.length>0&&D(k,{children:[M(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(6.5rem,1fr))] gap-2`,children:W.pageItems.map(e=>M(Ze,{face:e,cameraName:H(e.deviceId),nowMs:R,selected:u.has(e.faceId),onToggleSelect:fe,onAssign:e=>h([e]),onOpenDetail:x},e.faceId))}),M(te,{currentPage:W.page,totalItems:W.totalItems,pageSize:W.pageSize,onPageChange:W.setPage,itemNoun:`faces`})]}),M(Me,{face:de,cameraName:de?H(de.deviceId):``,onClose:()=>x(null),onAssign:$,onUnassign:ye,onDelete:be,actionsPending:ge}),M(De,{faceIds:p,identities:T,onDone:()=>{h(null),q()}}),M(qe,{open:v,onClose:()=>y(!1),byId:ue,cameraName:H,nowMs:R,identities:T,selectMany:pe})]})}E();var et=[[`faceGallery`]],tt=2e3;function nt(){let e=A(),t=T(e);t.current=e;let n=T(void 0);n.current||=ce({delayMs:tt,invalidate:()=>{t.current.invalidateQueries({queryKey:et})}}),N(()=>()=>n.current?.cancel(),[]),w(P.PipelineAnalyticsFaceGalleryChanged,()=>{n.current?.trigger()})}function rt(){return nt(),M(Q,{icon:Y,title:`Faces`,subtitle:`Manage enrolled identities and assign detected face crops to people.`,children:D(`section`,{className:`space-y-3`,children:[D(`div`,{children:[M(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`People`}),M(`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.`}),M(Se,{})]}),D(`div`,{className:`pt-4 border-t border-border`,children:[M(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Recent detected faces`}),M(`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.`}),M($e,{})]})]})})}export{rt as DetectionIntelligencePage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{$ as e,An as t,Bn as n,Bt as r,Ci as i,Cn as a,Co as o,D as s,Dn as c,E as l,Ei as u,F as d,Fr as f,H as p,Hi as m,Hn as h,Hr as g,In as _,J as v,Jo as y,Ko as b,Mi as x,Mn as S,N as C,Nn as w,O as T,On as ee,P as te,Q as ne,Rn as re,So as E,T as D,Ti as O,To as ie,Tt as ae,U as k,Ui as oe,Un as A,Vn as j,W as M,Wi as N,X as se,Xi as ce,Y as P,Yo as le,Z as ue,_o as de,_r as F,a as fe,at as pe,bo as me,cn as I,da as he,eo as ge,et as L,f as _e,fo as ve,g as ye,gn as be,go as xe,gr as Se,ho as Ce,hr as R,i as we,ki as Te,l as Ee,ln as De,lr as Oe,m as ke,mi as Ae,n as je,o as Me,ot as Ne,p as Pe,po as Fe,qo as Ie,r as Le,ro as Re,rt as ze,st as Be,to as Ve,tt as He,u as Ue,vn as We,vo as Ge,wn as Ke,xo as qe,y as Je,zn as Ye}from"./src-BxX2FkJ3.js";import{I as z,K as B,Q as V,S as H,W as U,a as Xe,b as Ze,o as W,q as G,t as Qe,x as K,z as q}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{N as J,W as $e,a as et,i as tt,j as nt}from"./src-CV0JUB8F.js";import{c as rt,k as it,p as Y,r as at,t as ot,u as st}from"./player-overlays-DTb-cTgy.js";import{t as ct}from"./CapabilityBadges-DtkhlewS.js";import{t as lt}from"./boxes-DXbr65aS.js";import{t as ut}from"./ProviderIcon-KgF3V3AC.js";import{a as dt,c as ft,l as pt,n as mt,o as ht}from"./NodeInferenceDevices-Cht6qC4t.js";import{n as gt}from"./FormBuilder-BILjZtIe.js";import{t as _t}from"./pencil-DMAfyiaP.js";import{t as vt}from"./refresh-cw-B0NcvZHF.js";import{t as yt}from"./rotate-ccw-CpixHLR5.js";import{t as bt}from"./rotate-cw-DiU5mosj.js";import{t as xt}from"./server-BbRPd6PC.js";import{t as St}from"./wifi-CTmFh8-0.js";import{B as Ct,G as X,H as wt,J as Tt,M as Et,R as Dt,S as Ot,W as kt,Y as At,a as jt,c as Mt,i as Nt,j as Pt,m as Ft,o as It,q as Lt,s as Rt,t as zt,v as Bt,y as Vt}from"./index-dqzu-f71.js";import{t as Ht}from"./StatusBadge-Dcr2bw58.js";import{t as Ut}from"./useEventInvalidation-R75mI5og.js";import{i as Wt,n as Gt,r as Kt,t as qt}from"./DeviceAggregateSection-bI7kL3uM.js";var Jt=X(`circle-help`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Yt=X(`hand`,[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]),Xt=X(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),Zt=X(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),Qt=X(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),$t=X(`volume-2`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]);V();function en({parentDeviceId:e}){let{t}=zt(),n=Lt(),r=Y(),{data:i,isLoading:a,isError:o}=ht(e),{data:s}=c({deviceId:e},{enabled:Number.isFinite(e)});if(a)return K(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:K(`p`,{className:`text-[10px] text-foreground-subtle`,children:t(`common.loading`,{defaultValue:`Loading…`})})});if(o)return K(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:K(`p`,{className:`text-[10px] text-warning`,children:t(`integrations.childrenLoadError`,{defaultValue:`Failed to load children`})})});let l=(i??[]).filter(e=>e.display?.hidden!==!0);if(l.length===0)return null;let u=se(s?.stableId??``,l,s?.childLayout),d=u.ungrouped,f=e=>n(`/devices/${String(e)}`),p=s?.name??``,m=(e,t)=>K(v,{trpc:r.trpcClient,device:{...t,name:L(t,p)},variant:`minimal`,onNavigate:f},e),h=d.some(e=>!!e.role),g=d.some(e=>!e.role),_=h&&!g?t(`device.accessories`,{defaultValue:`Accessories`}):!h&&g?t(`device.adoptedDevices`,{defaultValue:`Adopted devices`}):t(`device.children`,{defaultValue:`Children`}),y=d.length>0?H(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[K(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle mb-1.5`,children:_}),K(`div`,{className:`space-y-1`,children:d.map(e=>m(e.id,e))})]}):null,b=u.disabledSection===void 0?null:K(P,{title:t(`device.disabledSection`,{defaultValue:`Disabled`}),count:u.disabledSection.children.length,defaultOpen:!1,children:K(`div`,{className:`opacity-60 space-y-1`,children:u.disabledSection.children.map(e=>m(e.id,e))})},u.disabledSection.title);return u.sections.length===0?b===null?y:H(`div`,{className:`space-y-2`,children:[y,b]}):H(`div`,{className:`space-y-2`,children:[u.sections.map(e=>K(P,{title:e.title,count:e.children.length,defaultOpen:e.defaultOpen,children:e.children.map(e=>m(e.id,e))},e.title)),y,b]})}function tn({deviceId:e}){let t=Y(),{data:n,isLoading:r}=dt(e),{data:i,isLoading:a}=ht(e),o=r||a,s=(i??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:e.name,features:e.features,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}})),c=typeof n?.linkDeviceId==`number`?n.linkDeviceId:null,l=typeof n?.primaryChildEntityId==`string`?n.primaryChildEntityId:null;return o?K(`div`,{className:`h-full min-h-32 w-full animate-pulse rounded-lg bg-surface`,"aria-hidden":`true`}):K(`div`,{className:`flex h-full w-full flex-col`,children:K(k,{trpc:t.trpcClient,children:s,linkDeviceId:c,primaryChildEntityId:l})})}function nn({dev:e,busy:t,setBusy:n}){let r=e?.motionTrigger,i=st(e?.state.motionTrigger),[a,o]=G(!1);if(!r)return null;let s=i?.enabled===!0,c=i!==void 0,l=async()=>{if(t||!c)return;let e=!s;n(!0),o(!0);try{await r.setMotionTrigger({enabled:e})}finally{n(!1),o(!1)}};return H(`button`,{type:`button`,onClick:()=>{l()},disabled:t||!c,title:c?s?`Disable trigger on motion`:`Enable trigger on motion`:`Awaiting state…`,"aria-pressed":s,className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${s?`border-primary/50 bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle hover:text-foreground`}`,children:[K(kt,{className:`h-3 w-3`}),K(`span`,{children:a?s?`Disabling…`:`Enabling…`:c?s?`On motion: on`:`On motion: off`:`On motion: …`})]})}V();function Z({deviceId:e,deviceType:t,features:n}){let r=Y(),i=Ne(t)?.HeroCard??ge,a=rt(r.trpcClient,e),o=st(a?.state.deviceStatus),[s,c]=G(!1),l=o!==void 0&&o.online===!1,u=l?o.lastChangedAt:null;return H(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:[l?K(`div`,{className:`flex justify-center`,children:K(M,{lastChangedAt:u})}):null,K(i,{trpc:r.trpcClient,deviceId:e,features:n}),K(`div`,{className:`flex justify-center`,children:K(nn,{dev:a,busy:s,setBusy:c})})]})}function rn({deviceId:e,features:t}){return K(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:K(Ve,{trpc:Y().trpcClient,deviceId:e,features:t})})}function an({deviceId:e,features:t}){return K(`div`,{className:`flex h-full w-full flex-col items-stretch p-3 sm:p-4`,children:K(ge,{trpc:Y().trpcClient,deviceId:e,features:t})})}function on(e){if(!e)return null;let t=e.channel;return typeof t!=`number`||!Number.isInteger(t)||t<0?null:t}function sn(e){if(!e)return null;let t=on(e.data);return t===null?e.eventType:`Button ${String(t)} · ${e.eventType}`}var cn=1e3,ln=60*cn,un=60*ln,dn=24*un;function fn(e,t){if(e==null||e<=0)return`—`;let n=t-e;return n<cn?`just now`:n<ln?`${String(Math.floor(n/cn))}s ago`:n<un?`${String(Math.floor(n/ln))}m ago`:n<dn?`${String(Math.floor(n/un))}h ago`:`${String(Math.floor(n/dn))}d ago`}V();var pn=1500,mn=15e3,hn=1e3;function gn({deviceId:e}){let t=rt(Y().trpcClient,e)?.state.eventEmitter,n=st(t);q(()=>{if(!t)return;t.refresh();let e=setInterval(()=>{t.refresh()},mn);return()=>{clearInterval(e)}},[t]);let r=n?.lastEvent??null,i=r?.seq??null,a=B(null),[o,s]=G(!1);q(()=>{if(i===null)return;let e=a.current;if(a.current=i,e===null||e===i)return;s(!0);let t=setTimeout(()=>{s(!1)},pn);return()=>{clearTimeout(t)}},[i]);let[c,l]=G(()=>Date.now());q(()=>{let e=setInterval(()=>{l(Date.now())},hn);return()=>{clearInterval(e)}},[]);let u=sn(r),d=n?.eventTypes??[],f=n?.eventCountSinceStart??0,p=n!==void 0,m=on(r?.data);return H(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 p-4`,children:[K(`div`,{"data-testid":`event-emitter-indicator`,"data-flashing":String(o),className:`flex h-24 w-24 items-center justify-center rounded-full border-2 transition-all ${o?`border-primary bg-primary/20 text-primary shadow-lg shadow-primary/30 scale-105`:`border-border bg-surface text-foreground-subtle`}`,"aria-live":`polite`,title:u??`No press recorded`,children:K(o?Zt:Yt,{className:`h-10 w-10`})}),H(`div`,{className:`text-center`,children:[m!==null&&K(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-primary`,children:`Button ${String(m)}`}),K(`div`,{"data-testid":`event-emitter-headline`,className:`text-sm font-semibold ${u?`text-foreground`:`text-foreground-subtle`}`,children:u??(p?`No press recorded`:`Awaiting state…`)}),K(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:r?fn(r.timestamp,c):`Waiting for the first event`})]}),d.length>0&&K(`div`,{className:`flex max-w-full flex-wrap justify-center gap-1`,children:d.map(e=>K(`span`,{"data-testid":`event-emitter-chip`,className:`rounded-full border px-2 py-0.5 text-[10px] font-medium ${e===r?.eventType?`border-primary bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle`}`,children:e},e))}),K(`div`,{className:`text-[10px] text-foreground-subtle`,children:`${String(f)} ${f===1?`event`:`events`} since start`})]})}function _n({deviceName:e,deviceType:t,provider:n,isOnline:r,features:i}){return H(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border bg-surface p-6 text-center`,children:[K(ut,{type:n,size:`lg`}),H(`div`,{children:[K(`div`,{className:`text-sm font-semibold text-foreground`,children:e}),K(`div`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wider mt-0.5`,children:t})]}),H(`div`,{className:`flex items-center gap-2 flex-wrap justify-center`,children:[K(Ht,{status:r?`online`:`offline`}),i.length>0&&K(ct,{capabilities:i})]}),K(`div`,{className:`text-[10px] text-foreground-subtle italic max-w-xs mt-1`,children:`No live view for this device type. Use the Config tab or the shortcut row to interact.`})]})}V();function vn({deviceId:e}){let t=W(),n=I({deviceId:e},{refetchInterval:1e4,retry:!1}),r=De({onSuccess:()=>{t.invalidateQueries({queryKey:[[`deviceDiscovery`,`listDiscovered`]]}),t.invalidateQueries({queryKey:[[`deviceDiscovery`,`getStatus`]]})}}),i=U(()=>yn(n.data??[]),[n.data]);return H(`div`,{className:`flex h-full w-full flex-col gap-3 p-3 sm:p-4`,children:[H(`div`,{className:`flex flex-wrap items-stretch gap-2 sm:gap-3`,children:[K(bn,{label:`Discovered`,value:i.total,icon:K(Bt,{className:`h-3.5 w-3.5`})}),K(bn,{label:`Adopted`,value:i.adopted,accent:`success`}),K(bn,{label:`Available`,value:i.available,accent:i.available>0?`primary`:void 0}),H(`button`,{type:`button`,onClick:()=>{r.mutateAsync({deviceId:e}).catch(()=>{})},disabled:r.isPending,className:`inline-flex items-center justify-center gap-1.5 rounded-lg border border-border px-3 py-2 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 self-stretch shrink-0`,children:[r.isPending?K(Ot,{className:`h-3.5 w-3.5 animate-spin`}):K(vt,{className:`h-3.5 w-3.5`}),K(`span`,{className:`hidden sm:inline`,children:`Discover`})]})]}),H(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-foreground-subtle border-t border-border-subtle pt-2`,children:[K(xn,{icon:K(St,{className:`h-3 w-3 text-emerald-500`}),label:`${i.online} online`}),K(xn,{icon:K(Vt,{className:`h-3 w-3 text-amber-500`}),label:`${i.sleeping} sleeping`}),K(xn,{icon:K(jt,{className:`h-3 w-3 text-destructive`}),label:`${i.offline} offline`}),i.unknown>0?K(xn,{icon:K(Jt,{className:`h-3 w-3 text-foreground-subtle`}),label:`${i.unknown} unknown`}):null]})]})}function yn(e){let t={total:e.length,adopted:0,available:0,online:0,sleeping:0,offline:0,unknown:0};for(let n of e)n.alreadyAdopted?t.adopted+=1:t.available+=1,t[n.status]+=1;return t}function bn({label:e,value:t,icon:n,accent:r}){return H(`div`,{className:`flex flex-1 basis-[140px] min-w-0 flex-col gap-1 rounded-lg border px-2 py-1.5 sm:px-3 sm:py-2 ${r===`success`?`bg-emerald-500/10 border-emerald-500/30 text-emerald-500`:r===`primary`?`bg-primary/10 border-primary/30 text-primary`:`bg-surface-hover border-border text-foreground`}`,children:[H(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wider opacity-70 truncate`,children:[n,K(`span`,{className:`truncate`,children:e})]}),K(`div`,{className:`text-xl sm:text-2xl font-semibold tabular-nums leading-none`,children:t})]})}function xn({icon:e,label:t}){return H(`span`,{className:`inline-flex items-center gap-1`,children:[e,K(`span`,{children:t})]})}var Sn={[J.Switch]:Z,[J.Siren]:Z,[J.Light]:Z,[J.Sensor]:Z,[J.Button]:Z,[J.Hub]:vn,[J.Cover]:rn,[J.Valve]:Z,[J.Humidifier]:Z,[J.WaterHeater]:Z,[J.Container]:tn,[J.Lock]:Z,[J.Fan]:Z,[J.Thermostat]:Z,[J.Climate]:Z,[J.MediaPlayer]:Z,[J.Control]:Z,[J.AlarmPanel]:Z,[J.EventEmitter]:gn,[J.Notifier]:an,[J.Script]:Z,[J.Automation]:Z,[J.Presence]:Z,[J.Update]:Z,[J.Vacuum]:Z,[J.LawnMower]:Z,[J.Weather]:Z,[J.Image]:Z,[J.PetFeeder]:Z};function Cn(e){return Sn[e]??_n}function wn(e){return K(Cn(e.deviceType),{...e})}function Tn(e){return fe(Y().trpcClient,e)}V();function En(e){let[t,n]=G(`idle`),[r,i]=G(null),a=B(null),o=B(null),s=B(null),c=B(!0),l=Se(),u=R(),d=F(),f=z(()=>{if(a.current){try{a.current.close()}catch{}a.current=null}if(o.current){for(let e of o.current.getTracks())try{e.stop()}catch{}o.current=null}s.current=null},[]),p=z(async()=>{if(t===`idle`)return;n(`stopping`);let r=s.current;if(r&&e!==null)try{await Promise.race([d.mutateAsync({deviceId:e,sessionId:r}),new Promise((e,t)=>setTimeout(()=>t(Error(`server stopSession timeout`)),2e3))])}catch(e){console.warn(`[intercom] server stopSession failed (continuing teardown)`,e)}f(),c.current&&(n(`idle`),i(null))},[t,e,d,f]),m=z(async()=>{if(e===null||t!==`idle`&&t!==`error`)return;i(null);let r=null,f=null,m=null;try{n(`requesting-mic`),r=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),o.current=r,n(`starting`);let t=await l.mutateAsync({deviceId:e});m=t.sessionId,s.current=m,n(`connecting`),f=new RTCPeerConnection,a.current=f,f.oniceconnectionstatechange=()=>{if(!c.current)return;let e=f.iceConnectionState;e===`connected`||e===`completed`?n(`talking`):(e===`failed`||e===`closed`||e===`disconnected`)&&c.current&&(i(e===`failed`?`WebRTC connection failed`:null),p())};for(let e of r.getAudioTracks())f.addTrack(e,r);await f.setRemoteDescription({type:`offer`,sdp:t.sdpOffer});let d=await f.createAnswer();await f.setLocalDescription(d);let h=f.localDescription?.sdp??d.sdp??``;await u.mutateAsync({deviceId:e,sessionId:m,sdpAnswer:h})}catch(t){let l=t instanceof Error?t.message:String(t);if(console.warn(`[intercom] start failed`,t),f)try{f.close()}catch{}if(r)for(let e of r.getTracks())try{e.stop()}catch{}if(a.current=null,o.current=null,m!==null)try{await d.mutateAsync({deviceId:e,sessionId:m})}catch{}s.current=null,c.current&&(i(l),n(`error`))}},[e,t,l,u,d,p]);return q(()=>(c.current=!0,()=>{c.current=!1;let t=s.current;if(t!==null&&e!==null&&d.mutate({deviceId:e,sessionId:t}),a.current){try{a.current.close()}catch{}a.current=null}if(o.current){for(let e of o.current.getTracks())try{e.stop()}catch{}o.current=null}s.current=null}),[e]),{state:t,error:r,start:m,stop:p,isTalking:t===`talking`}}V();var Dn=0;function Q(){return++Dn}function On(e){switch(e.type){case`system`:return`system`;case`device`:return`#${e.deviceId}`;case`provider`:return e.providerId;case`addon`:return e.addonId}}function kn(e){return[``,`Commands`,` help Show this help`,` examples Show usage examples for the current scope`,` context Show every available variable + full API surface`,` clear Clear terminal (also Ctrl+L)`,``,`Shortcuts`,` Enter Execute expression`,` Arrow Up/Down Navigate command history`,` Ctrl+L Clear terminal`,``,`Try: ${{system:` sm.summary() // fleet overview`,device:` device.state.battery.value?.sleeping // sync read`,provider:` devices.map(d => d.name)`,addon:` manifest.version`}[e.type]}`,``,`Top-level objects: sm (SystemMirror), DeviceType, Math, JSON, Date, …`]}function An(e){switch(e.type){case`device`:return[``,`── State (sync, zero round-trip) ─────────────────────────`,` device.state.battery.value`,` device.state.battery.value?.percentage`,` device.state.motion.value?.detected`,``,`── Actions (async, through wrapper chain) ────────────────`,` await device.snapshot.getSnapshot({})`,` await device.ptz.move({ direction: 'left', steps: 1 })`,` await device.switch.setState({ on: true })`,``,`── Wait for condition ───────────────────────────────────`,` await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)`,``,`── Subscribe to changes ─────────────────────────────────`,` const off = device.state.battery.subscribe(s => console.log(s))`,``,`── Quick info ───────────────────────────────────────────`,` info.name device name`,` info.addonId owning addon`,` sm.dump(deviceId) full debug dump`];case`system`:return[``,`── Lookups ──────────────────────────────────────────────`,` sm.getDeviceById(8)`,` sm.getDeviceByName('Sala da pranzo')`,` sm.getDevicesByAddon('reolink')`,` sm.getDevicesByType(DeviceType.Camera)`,``,`── Filters (typed query) ────────────────────────────────`,` sm.query({ addonId: 'reolink', online: true })`,` sm.query({ caps: ['battery', 'snapshot'] })`,` sm.query({ name: /^Cam-/ })`,``,`── Cross-device ─────────────────────────────────────────`,` sm.whereState('battery', s => s.percentage < 20).length`,` sm.mapState('battery', s => s.percentage)`,` sm.countByCap('snapshot')`,``,`── Batch action ─────────────────────────────────────────`,` await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })`,``,`── Listen ───────────────────────────────────────────────`,` sm.listenCap('motion', (id, s) => console.log(id, s))`,` sm.onDeviceAdded((id, info) => console.log('+', info.name))`,``,`── Diagnostics ──────────────────────────────────────────`,` sm.summary()`,` sm.dump(8)`];case`provider`:return[``,` devices.map(d => d.name)`,` await getIntegration()`,` sm.getDevicesByAddon('<this-addon-id>').length`];case`addon`:return[``,` manifest.name`,` manifest.version`,` declaration`]}}function jn(e){let t=[``,`Scope: ${e.type}`,``];switch(e.type){case`system`:return[...t,`Primary API — sm (SystemMirror):`,` sm.getDeviceById(id) DeviceProxy | null (sync)`,` sm.getDeviceByName(name) DeviceProxy | null`,` sm.getDeviceByStableId(sid) DeviceProxy | null`,` sm.getAllDevices() readonly DeviceProxy[]`,` sm.getDeviceInfo(id) DeviceInfo | null`,` sm.summary() fleet stats`,``,`Filters — sm.query({...}):`,` sm.query({ addonId: 'reolink', online: true })`,` sm.query({ caps: ['battery', 'snapshot'] }) // ALL caps required`,` sm.query({ anyCap: ['ptz', 'motion'] }) // ANY cap`,` sm.query({ name: { contains: 'sala' } }) // case-insensitive`,` sm.query({ name: /^Cam-\\d+$/ })`,` sm.query({ type: DeviceType.Camera })`,` sm.query({ parentDeviceId: 8 }) // accessories of cam 8`,` sm.query({ where: (info, dev) => dev.state.battery.value?.sleeping })`,``,`State queries:`,` sm.whereState('battery', s => s.percentage < 20)`,` sm.mapState('battery', s => s.percentage)`,` sm.findState('motion', s => s.detected)`,` sm.countByCap('snapshot')`,``,`Listeners (return unsubscribe fn):`,` sm.listen((id, cap, slice) => …) // every state change`,` sm.listenCap('motion', (id, slice) => …)`,` sm.listenDevice(8, (id, cap, slice) => …)`,` sm.onDeviceAdded((id, info) => …)`,` sm.onDeviceRemoved((id, info) => …)`,``,`Wait primitives:`,` await sm.waitForState(8, 'battery', s => !s.sleeping, 30_000)`,` await sm.waitForDevice(99, 30_000)`,``,`Batch:`,` await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })`,` await sm.forEachCap('reboot', d => d.reboot.reboot({}))`,``,`Diagnostics:`,` sm.dump(8) debug dump (one device)`,` sm.dump() full fleet dump`,` sm.summary() breakdown by cap/addon/type`,``,`Legacy: deviceRegistry, addonRegistry, eventBus, devices(), addons()`];case`device`:return[...t,`Pre-bound variables:`,` device DeviceProxy for this device (sync state + async methods)`,` deviceId number`,` info DeviceInfo metadata (name, addonId, type, online, …)`,` sm SystemMirror (full cluster view)`,` rawDevice legacy IDevice instance (escape hatch)`,``,`Reactive state (sync, zero round-trip):`,` device.state.battery.value BatteryStatus | undefined`,` device.state.battery.value?.sleeping`,` device.state.battery.value?.percentage`,` device.state.motion.value?.detected`,` device.state.switch.value?.on`,` device.state.brightness.value?.percentage`,` device.state.doorbell.value?.lastPressedAt`,``,`Cap actions (async, through wrapper chain):`,` await device.snapshot.getSnapshot({})`,` await device.snapshot.getSnapshot({ streamId: 'high' })`,` await device.ptz.move({ direction: 'left', steps: 1 })`,` await device.ptz.goToPreset({ presetId: 'home' })`,` await device.switch.setState({ on: true })`,` await device.brightness.setBrightness({ percentage: 60 })`,` await device.reboot.reboot({})`,``,`Subscribe to slice changes:`,` const off = device.state.battery.subscribe(s => console.log(s))`,` // off() to unsubscribe`,``,`Wait for a state condition:`,` await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)`,``,`Diagnostics:`,` info.name device name`,` info.addonId which addon owns it`,` info.online transport health`,` sm.dump(deviceId) full debug dump (binding + state + info)`];case`provider`:return[...t,`Pre-bound variables:`,` devices Devices belonging to this provider (raw IDevice[])`,` getIntegration() Integration metadata`,``,`For typed device access use the SystemMirror:`,` await getSystemMirror()`,` sm.getDevicesByAddon('this-addon-id')`];case`addon`:return[...t,`Pre-bound variables:`,` manifest { name, version, ... }`,` declaration addon declaration`,` source addon source location`,``,`Examples:`,` manifest.name`,` manifest.version`]}}function Mn({scope:e,greeting:t,className:n}){let r=Y(),[i,a]=G(()=>{let n=[];return t&&n.push({id:Q(),kind:`info`,text:t}),n.push({id:Q(),kind:`info`,text:`scope: ${On(e)} — type help or context for available commands`}),n}),[o,s]=G(``),[c,l]=G([]),[u,d]=G(-1),f=B(null),p=B(null);q(()=>{let e=p.current;e&&(e.scrollTop=e.scrollHeight)},[i]);let m=z(()=>{f.current?.focus()},[]),h=Qe({mutationFn:t=>r.trpcClient.repl.execute.mutate({code:t,scope:e}),onSuccess:e=>{let t=e??{},n=typeof t.output==`string`?t.output:e==null?`undefined`:typeof e==`string`?e:JSON.stringify(e,null,2),r=t.type===`error`;a(e=>[...e,{id:Q(),kind:r?`error`:`result`,text:n}])},onError:e=>{let t=e instanceof Error?e.message:String(e);a(e=>[...e,{id:Q(),kind:`error`,text:t}])}});function g(t){let n=t.trim();if(n){if(n===`clear`){a([{id:Q(),kind:`info`,text:`scope: ${On(e)}`}]),s(``);return}if(n===`help`){a(t=>[...t,{id:Q(),kind:`input`,text:`> ${n}`},...kn(e).map(e=>({id:Q(),kind:`info`,text:e}))]),s(``);return}if(n===`context`){a(t=>[...t,{id:Q(),kind:`input`,text:`> ${n}`},...jn(e).map(e=>({id:Q(),kind:`info`,text:e}))]),s(``);return}if(n===`examples`){a(t=>[...t,{id:Q(),kind:`input`,text:`> ${n}`},...An(e).map(e=>({id:Q(),kind:`info`,text:e}))]),s(``);return}l(e=>[...e,n]),d(-1),a(e=>[...e,{id:Q(),kind:`input`,text:`> ${n}`}]),s(``),h.mutate(n)}}function _(t){if(t.key===`Enter`){t.preventDefault(),g(o);return}if(t.key===`ArrowUp`){if(t.preventDefault(),c.length===0)return;let e=u===-1?c.length-1:Math.max(0,u-1);d(e),s(c[e]??``);return}if(t.key===`ArrowDown`){if(t.preventDefault(),u===-1)return;let e=u+1;e>=c.length?(d(-1),s(``)):(d(e),s(c[e]??``));return}t.ctrlKey&&t.key===`l`&&(t.preventDefault(),a([{id:Q(),kind:`info`,text:`scope: ${On(e)}`}]))}let v={input:`text-zinc-300`,result:`text-emerald-300`,error:`text-red-300`,info:`text-zinc-400`};return H(`div`,{className:`flex flex-col bg-[#0c0a09] rounded-lg border border-border overflow-hidden font-mono text-xs ${n??``}`,onClick:m,children:[H(`div`,{ref:p,className:`flex-1 overflow-y-auto p-3 space-y-1 min-h-[120px]`,children:[i.map(e=>K(`pre`,{className:`whitespace-pre-wrap break-words leading-relaxed ${v[e.kind]}`,children:e.text},e.id)),h.isPending&&K(`span`,{className:`text-zinc-500 animate-pulse`,children:`…thinking`})]}),H(`div`,{className:`flex items-center gap-2 border-t border-zinc-800 px-3 py-2 bg-[#0c0a09]`,children:[K(`span`,{className:`text-emerald-400 flex-shrink-0 select-none font-bold`,children:`>`}),K(`input`,{ref:f,value:o,onChange:e=>s(e.target.value),onKeyDown:_,disabled:h.isPending,placeholder:`device.state.battery.value`,autoFocus:!0,className:`flex-1 bg-transparent text-zinc-100 placeholder:text-zinc-600 focus:outline-none caret-emerald-400 disabled:opacity-50`,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`})]})]})}function Nn({deviceId:e,intercomAvailable:t=!1}){let n=Y(),r=typeof window<`u`?window.location.origin:``,i=Number.isFinite(e),a=Tn(i?e:null),{streams:o,pipelineMetrics:s,createSession:c,sendAnswer:l,handleOffer:u,getIceServers:d,addIceCandidate:f,getIceCandidates:p,closeSession:m,getSessionState:h}=we(n.trpcClient,i?e:null),g=ne(i?e:null,{width:Rn}),_=En(i&&t?e:null),v=_.state===`requesting-mic`||_.state===`starting`||_.state===`connecting`||_.state===`stopping`,y=_.isTalking||v,b=()=>{_.state===`idle`||_.state===`error`?_.start():_.state!==`stopping`&&_.stop()},x=at(),S=T(),C=typeof window<`u`?window.localStorage.getItem(`camstack_admin_token`):null,w=x.length>0?K(Ze,{children:x.map(e=>K(`div`,{className:`absolute inset-0`,children:e.node},e.id))}):null;return K(Je,{serverUrl:r,createSession:c,sendAnswer:l,handleOffer:u,getIceServers:d,addIceCandidate:f,getIceCandidates:p,closeSession:m,getSessionState:h,...S.request?{playbackUrl:S.request.url,playbackAuthToken:C,...S.request.label?{playbackLabel:S.request.label}:{},onExitPlayback:()=>S.clear()}:{},streams:o,pipelineMetrics:s,phase:a.phase,detections:a,defaultShowDetections:!0,defaultShowMotion:!0,showPlayStop:!0,snapshotSrc:g.src,...g.src?{posterUrl:g.src}:{},snapshotLoading:g.loading,onRefreshSnapshot:g.refresh,intercomAvailable:t,intercomShown:y,onIntercomToggle:b,extraOverlay:w,chromeless:!0,className:`h-full`})}function Pn({deviceId:e,containerDeviceId:t}){return Number.isFinite(e)?K(`div`,{className:`flex flex-col h-full`,children:K(ye,{...t===void 0?{deviceId:e}:{containerDeviceId:t},limit:50,maxHeight:`max-h-full`,showScope:!1,showFilters:!1})}):H(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}function Fn({deviceId:e}){if(!Number.isFinite(e))return H(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]});let t=[`CamStack REPL — device #${e}`,``,` device.state.battery.value sync state read`,` await device.snapshot.getSnapshot({}) cap action`,``,` type 'examples' for more, 'context' for the full API`].join(`
|
|
2
|
-
`);return K(Mn,{scope:{type:`device`,deviceId:e},greeting:t,className:`h-full border-0 rounded-none`})}function In({deviceId:e}){return Number.isFinite(e)?K(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:K(ke,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):H(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}function Ln({deviceId:e}){return Number.isFinite(e)?K(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:K(_e,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):H(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}var Rn=960,zn={"no-provider":`Not available — nothing in this installation provides it.`,"source-unreachable":`Unknown — the service that owns this did not answer.`,"not-configured":`Nothing set up yet — configure it first (Image → Privacy Mask).`};function Bn({deviceId:e}){let t=W(),{data:n,isLoading:r,error:i}=u({deviceId:e},{enabled:Number.isFinite(e)});Ut([`pipelineOrchestrator`,`getCameraSwitches`],[`capability.binding-changed`]);let a=[[`pipelineOrchestrator`,`getCameraSwitches`],{input:{deviceId:e}}],o=N({onMutate:async e=>{await t.cancelQueries({queryKey:a});let n=t.getQueryData(a);return n!==void 0&&t.setQueryData(a,{...n,switches:n.switches.map(t=>t.id===e.switchId&&t.available?{...t,enabled:e.enabled}:t)}),{previous:n}},onError:(e,n,r)=>{r?.previous!==void 0&&t.setQueryData(a,r.previous)},onSuccess:e=>{t.setQueryData(a,e),t.invalidateQueries({queryKey:[[`deviceManager`]]}),t.invalidateQueries({queryKey:[[`recording`]]})}});return r?H(`div`,{className:`flex items-center gap-2 text-xs text-muted`,children:[K(Ot,{className:`h-3 w-3 animate-spin`}),` Loading camera functions…`]}):i||!n?H(`div`,{className:`flex items-start gap-2 rounded-lg border border-border p-3 text-xs text-muted`,children:[K(It,{className:`mt-0.5 h-3 w-3 shrink-0`}),K(`span`,{children:`Camera functions could not be read. Nothing has changed — the switches are not shown rather than shown with a guessed state.`})]}):K(`div`,{className:`flex flex-col gap-2`,children:n.switches.map(t=>K(Vn,{row:t,busy:o.isPending&&o.variables?.switchId===t.id,onToggle:n=>o.mutate({deviceId:e,switchId:t.id,enabled:n})},t.id))})}function Vn({row:e,busy:t,onToggle:n}){let r=e.available&&!e.enabled;return H(`div`,{className:`rounded-lg border p-3 ${r?`border-warning/50 bg-warning/5`:`border-border`}`,children:[H(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[H(`div`,{className:`flex items-center gap-2`,children:[K(`span`,{className:`text-sm font-medium`,children:e.label}),r?K(`span`,{className:`rounded bg-warning/20 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-warning`,children:`Off`}):null]}),e.available?K(`button`,{type:`button`,disabled:t,onClick:()=>n(!e.enabled),className:`shrink-0 rounded border border-border px-2 py-1 text-xs disabled:opacity-50`,children:e.enabled?`Turn off`:`Turn on`}):K(`span`,{className:`shrink-0 text-[11px] text-muted`,children:e.unavailableReason?zn[e.unavailableReason]:`Not available.`})]}),K(`p`,{className:`mt-1.5 text-xs leading-snug text-muted`,children:e.costWhenOff})]})}function Hn({deviceId:e}){let t=W(),n=Number.isFinite(e),{data:r}=c({deviceId:e},{enabled:n}),i=typeof r?.type==`string`?r.type:`camera`;Ut([`deviceManager`,`getBindings`],[`capability.binding-changed`]);let{data:a,isLoading:o,isError:s,error:l}=Ke({deviceId:e},{enabled:n}),{data:u}=S({deviceType:i},{enabled:!!i}),d=A({onSuccess:()=>{t.invalidateQueries({queryKey:[[`deviceManager`,`getBindings`]]})}});if(o)return K(`div`,{className:`p-4`,children:K(`div`,{className:`h-20 rounded-lg border border-border bg-surface animate-pulse`})});if(s)return H(`div`,{className:`p-4 text-xs text-red-400`,children:[`Failed to load bindings: `,l instanceof Error?l.message:String(l)]});let f=new Map,p={};for(let e of u??[])p[e.capName]=e.wrappers;for(let e of a?.entries??[])f.set(e.capName,{...e,wrappers:p[e.capName]??[]});for(let e of u??[])f.has(e.capName)||f.set(e.capName,{capName:e.capName,kind:`unbound`,providerAddonId:``,providerNodeId:``,nativeAddonId:``,wrappers:e.wrappers});let m=[...f.values()].toSorted((e,t)=>e.capName.localeCompare(t.capName));if(m.length===0)return H(`div`,{className:`flex flex-col items-center justify-center gap-2 p-8 text-foreground-subtle`,children:[K(lt,{className:`h-8 w-8 opacity-40`}),K(`p`,{className:`text-xs`,children:`No capability providers applicable to this device yet.`}),K(`p`,{className:`text-[10px] opacity-60`,children:`Native providers show up here as soon as the owning addon registers them.`})]});let h=m.filter(e=>e.kind!==`unbound`).length;return H(`div`,{className:`flex flex-col gap-3 p-1`,children:[i===`camera`?H(`section`,{className:`flex flex-col gap-2`,children:[K(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Camera functions`}),K(Bn,{deviceId:e})]}):null,H(`div`,{className:`text-[11px] text-foreground-subtle`,children:[K(`span`,{className:`font-medium text-foreground`,children:h}),` of `,m.length,` capabilit`,m.length===1?`y`:`ies`,` bound — rows marked `,K(`em`,{children:`unbound`}),` have a wrapper available you can activate.`]}),K(de,{columns:[{key:`capability`,header:`Capability`,render:e=>K(`span`,{className:`font-mono text-foreground`,children:e.capName})},{key:`kind`,header:`Kind`,render:e=>K(Un,{kind:e.kind})},{key:`provider`,header:`Active Provider`,render:e=>K(`span`,{className:`font-mono text-foreground-subtle`,children:e.providerAddonId||K(`span`,{className:`opacity-40`,children:`—`})})},{key:`node`,header:`Node`,render:e=>e.providerNodeId?K(Wn,{nodeId:e.providerNodeId}):K(`span`,{className:`text-[10px] opacity-40`,children:`—`})},{key:`native`,header:`Native`,render:e=>K(`span`,{className:`font-mono text-foreground-subtle`,children:e.nativeAddonId||K(`span`,{className:`opacity-40`,children:`—`})})},{key:`wrapper`,header:`Wrapper`,render:t=>{let n=t.kind===`wrapped`?t.providerAddonId:null;return K(Gn,{wrappers:t.wrappers,activeWrapperId:n,disabled:d.isPending,onPick:r=>{let i=n===r;d.mutate({deviceId:e,capName:t.capName,wrapperAddonId:r,active:!i})}})}}],rows:m,rowKey:e=>e.capName,minWidthPx:720})]})}function Un({kind:e}){return e===`native`?H(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-success/30 text-success bg-success/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[K(xt,{className:`h-3 w-3`}),`native`]}):e===`wrapped`?H(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-primary/30 text-primary bg-primary/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[K(pt,{className:`h-3 w-3`}),`wrapped`]}):e===`linked`?H(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-warning/30 text-warning bg-warning/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[K(Xt,{className:`h-3 w-3`}),`linked`]}):H(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border text-foreground-subtle/70 px-1.5 py-0.5 text-[10px] font-medium`,children:[K(ft,{className:`h-3 w-3`}),`unbound`]})}function Wn({nodeId:e}){return K(`span`,{className:`inline-flex items-center rounded-md border border-border px-1.5 py-0.5 font-mono text-[10px] ${e===`hub`?`text-foreground-subtle`:`text-foreground`}`,children:e})}function Gn({wrappers:e,activeWrapperId:t,disabled:n,onPick:r}){return e.length===0?K(`span`,{className:`text-[10px] opacity-40`,children:`none available`}):K(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>{let i=e===t;return H(`button`,{disabled:n,onClick:()=>r(e),title:i?`Click to deactivate (revert to native)`:`Activate wrapper ${e}`,className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 font-mono text-[10px] transition-colors disabled:opacity-50 ${i?`border-primary/40 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[K(i?Dt:yt,{className:`h-3 w-3`}),e]},e)})})}function Kn({deviceId:e,activeSubTab:t,onSubTabChange:n}){return K(`div`,{className:`flex flex-col gap-3`,children:K(qt,{deviceId:e,activeSubTab:t,onSubTabChange:n})})}V();var qn=new Set([`package-detection`]);function Jn(e,t){if(!e)return null;for(let n of e.slots)for(let e of n.addons)if(e.id===t)return e;return null}function Yn(e){return e?e.modelId!==void 0||e.settings!==void 0:!1}function Xn({deviceId:e,refreshToken:t}){let n=W(),r=Y().trpcClient,[a,o]=G(null),[s,c]=G(null),[l,u]=G(null),d=i({deviceId:e},{refetchOnMount:`always`}),f=O({deviceId:e},{refetchOnMount:`always`}),p=x(void 0,{refetchOnMount:`always`});Ut([`nodes`,`topology`],[`agent.online`,`agent.offline`,`agent.unregistered`,`addon.installed`,`addon.uninstalled`]);let h=g(void 0,{refetchOnMount:`always`}),_=U(()=>{let e=new Set;for(let t of h.data??[])t.isOnline&&e.add(t.id);return e},[h.data]),v=U(()=>(p.data??[]).filter(e=>_.has(e.nodeId)).map(e=>e.nodeId),[p.data,_]),b=v[0]??``,S=Ae({nodeId:b},{enabled:b!==``,refetchOnMount:`always`}),C=Xe({enabled:v.length>0,queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`],`device-step`,v.join(`,`),t],queryFn:async()=>{let e={};for(let t of v)try{e[t]=(await r.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:t})).devices}catch{e[t]=[]}return e}}),w=()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraSettings`]]}),n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStepOverrides`]]})},T=m({onSuccess:w}),ee=oe({onSuccess:w}),te=U(()=>S.data?Ce(S.data):[],[S.data]),ne=U(()=>{let e=p.data??[],t=_.size===0?[]:e.filter(e=>_.has(e.nodeId)),n=[];for(let e of t){let t=(C.data?.[e.nodeId]??[]).filter(e=>e.enabled&&e.available);if(t.length>=2)for(let r of t)n.push({agentNodeId:e.nodeId,engineLabel:r.format,deviceKey:r.key,deviceLabel:mt(r).label});else n.push({agentNodeId:e.nodeId,engineLabel:t[0]?.format??`(engine unknown)`})}return n},[p.data,C.data,_]),re=(e,t)=>C.data?.[e]?.find(e=>e.key===t)??null,E=e=>{if(e.deviceKey!==void 0)return e.deviceKey;let t=C.data?.[e.agentNodeId]??[],n=t.filter(e=>e.enabled&&e.available);return n.length>=1?n[0].key:t.find(e=>e.available)?.key??t[0]?.key??null},D=(e,t,n)=>f.data?.[e]?.[t]?.[n]??null,ie=e=>{if(qn.has(e))return{kind:`zone-driven`};let t=Jn(S.data??null,e)?.enabledByDefault??!0,n=d.data?.stepToggles?.[e];return{kind:`gate`,effectiveOn:n??t,defaultOn:t,explicit:n!==void 0}},ae=(e,t)=>{let n=Jn(S.data??null,e);if(n)return Ie(n,t)},k=(e,t)=>{let n=ie(e),r=n.kind===`gate`?n.effectiveOn:!1,i=Jn(S.data??null,e),a=E(t),o=a===null?null:re(t.agentNodeId,a);if(!le(i?.models??[],o?.format))return r?{kind:`skip`}:{kind:`na`};let s=a===null?null:D(t.agentNodeId,a,e),c=o?.steps?.[e];return{kind:`enabled`,modelId:(i?y({catalog:i,device:o,override:s?.modelId,base:c?.modelId}):void 0)??`Auto`,overridden:Yn(s)}},A=a&&S.data?Jn(S.data,a.addonId):null,j=a?re(a.agentNodeId,a.deviceKey):null,M=j?.format??`coreml`,N=a?Yn(D(a.agentNodeId,a.deviceKey,a.addonId)):!1,se=a?ae(a.addonId,j):void 0,ce=U(()=>{if(!a||!j)return null;let e=j.steps?.[a.addonId];return{enabled:!0,...e?.modelId===void 0?{}:{modelId:e.modelId},settings:e?.settings??{}}},[a,j]),P=()=>{o(null),c(null)},ue=(e,t)=>{let n=E(t);n!==null&&(o({addonId:e,agentNodeId:t.agentNodeId,deviceKey:n}),c(D(t.agentNodeId,n,e)))},de=(t,n)=>{ee.mutate({deviceId:e,addonId:t,enabled:n})},F=()=>{a&&T.mutate({deviceId:e,agentNodeId:a.agentNodeId,deviceKey:a.deviceKey,addonId:a.addonId,patch:s},{onSuccess:P})},fe=()=>{a&&T.mutate({deviceId:e,agentNodeId:a.agentNodeId,deviceKey:a.deviceKey,addonId:a.addonId,patch:null},{onSuccess:P})};if(p.isLoading||b!==``&&S.isLoading)return K(`div`,{className:`text-xs text-foreground-subtle animate-pulse p-4`,children:`Loading pipeline…`});if(ne.length===0)return K(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`No online agents.`});if(!S.data)return K(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`Catalog unavailable.`});let pe=a!==null&&A!==null&&j!==null;return H(`div`,{className:`relative h-full w-full space-y-3`,children:[H(`div`,{className:`rounded-md border border-border bg-muted/20 px-3 py-2 text-[11px] leading-relaxed text-foreground-subtle`,children:[K(`span`,{className:`font-medium text-foreground`,children:`Gate`}),` (col 1) decides whether this camera runs a step — independent of nodes. Each`,` `,K(`span`,{className:`font-medium text-foreground`,children:`node column`}),` shows the model that node runs; click a cell to pin a per-camera model override for that accelerator. A gated-on step with no model on a device shows a clickable `,K(`span`,{className:`text-amber-500`,children:`⚠ skip`}),` `,`and won't run there.`]}),H(`div`,{className:`rounded-md border border-sky-500/25 bg-sky-500/[0.06] px-3 py-2 text-[11px] leading-relaxed text-foreground-subtle`,children:[K(`span`,{className:`font-medium text-sky-400`,children:`Placement is dynamic.`}),` When a node has multiple inference accelerators, each session is balanced across them per-session at dispatch time — these device columns show each accelerator's effective model (override ?? device default), not a fixed assignment.`]}),K(`div`,{className:pe?`md:pr-[360px]`:``,children:te.length>0?K(ve,{tree:te,agents:ne,gateFor:ie,getCellState:k,onCellClick:ue,selectedCell:a,onSetGate:de,gateBusy:ee.isPending,fallbackNodeId:l,onFallbackNodeChange:u}):K(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),K(xe,{open:pe,onClose:P,title:A?.name??``,subtitle:a&&j?`${a.agentNodeId} · ${mt(j).label} · ${j.format}`:``,footer:H(Ze,{children:[K(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted text-foreground-subtle disabled:opacity-50`,disabled:!N||T.isPending,onClick:fe,children:`Clear override`}),K(`div`,{className:`flex-1`}),K(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:P,children:`Cancel`}),K(`button`,{type:`button`,disabled:!a||!ce||T.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:F,children:T.isPending?`Saving…`:`Save`})]}),children:A&&a&&ce?K(Fe,{mode:`device`,addon:A,agentDefault:ce,agentNodeId:a.agentNodeId,currentPatch:s,engineFormat:M,effectiveModelId:se,onChangePatch:c}):K(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-300`,children:`This accelerator is no longer reported by the node, so there is nothing to provision here.`})})]})}var Zn=[{id:`object-detection`,label:`Object detection`,icon:`scan-search`},{id:`tracking`,label:`Tracking`,icon:`route`},{id:`motion`,label:`Motion`,icon:`activity`},{id:`stationary`,label:`Stationary`,icon:`square-parking`},{id:`zones`,label:`Zones`,icon:`shapes`},{id:`audio`,label:`Audio`,icon:`volume-2`},{id:`cluster`,label:`Cluster`,icon:`server`}],Qn={"pipeline-object-detection":`object-detection`,"detection-sensitivity":`object-detection`,"onboard-object-detection":`object-detection`,tracking:`tracking`,"tracking-core":`tracking`,"motion-tuning":`motion`,"stationary-objects":`stationary`,occupancy:`stationary`,zones:`zones`,"pipeline-audio":`audio`,"cluster-assignment":`cluster`,"orchestrator-live":`cluster`};function $n(e){return Qn[e]??`object-detection`}V();var er=`steps`,tr=`settings`,nr=new Set([er,tr]);function rr(e){return e.location===`top-tab`&&(e.tab===`detection-pipeline`||e.tab===`zones`)}function ir({deviceId:e,activeSubTab:t,onSubTabChange:n}){return H(me,{value:t&&nr.has(t)?t:er,onValueChange:z(e=>{n?.(e)},[n]),className:`flex flex-col`,children:[H(E,{className:`flex-shrink-0`,children:[K(o,{value:er,children:`Steps`}),K(o,{value:tr,children:`Settings`})]}),K(qe,{value:er,children:K(Xn,{deviceId:e,refreshToken:0})}),K(qe,{value:tr,children:K(qt,{deviceId:e,sectionFilter:rr,subTabGrouping:{groupOf:e=>$n(e.id),tabs:Zn}})})]})}function $({label:e,value:t}){return H(`div`,{className:`${it} flex items-start gap-2 sm:gap-3`,children:[K(`span`,{className:`w-20 sm:w-28 flex-shrink-0 text-[11px] text-foreground-subtle`,children:e}),K(`div`,{className:`flex-1 min-w-0 text-[11px] text-foreground`,children:t})]})}V();function ar({deviceId:e,initialName:t}){let r=W(),[i,a]=G(!1),[o,s]=G(t),[c,l]=G(!1),u=B(null);q(()=>{i||s(t)},[t,i]),q(()=>{i&&u.current?.focus()},[i]);let d=n({onSuccess:()=>{r.invalidateQueries({queryKey:[[`deviceManager`,`getDevice`]]}),r.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),r.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),f=async()=>{let n=o.trim();if(n.length===0||n===t){a(!1),s(t);return}l(!0);try{await d.mutateAsync({deviceId:e,name:n}),a(!1)}catch{}finally{l(!1)}},p=()=>{s(t),a(!1)};return i?K($,{label:`Name`,value:H(`div`,{className:`flex items-center gap-1`,children:[K(`input`,{ref:u,type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`?f():e.key===`Escape`&&p()},disabled:c,className:`flex-1 min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary`}),K(`button`,{type:`button`,onClick:()=>void f(),disabled:c,className:`p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50`,"aria-label":`Save`,children:K(Dt,{className:`h-3 w-3`})}),K(`button`,{type:`button`,onClick:p,disabled:c,className:`p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50`,"aria-label":`Cancel`,children:K(Nt,{className:`h-3 w-3`})})]})}):K($,{label:`Name`,value:H(`div`,{className:`flex items-center gap-2 group`,children:[K(`span`,{className:`truncate`,children:t}),K(`button`,{type:`button`,onClick:()=>a(!0),className:`p-0.5 rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":`Edit name`,children:K(_t,{className:`h-3.5 w-3.5`})})]})})}V();function or({deviceId:e,initialLocation:t}){let n=W(),[r,i]=G(!1),[a,o]=G(t??``),[s,c]=G(!1),l=B(null),{data:u}=w(void 0,{enabled:r}),d=u??[];q(()=>{r||o(t??``)},[t,r]),q(()=>{r&&l.current?.focus()},[r]);let f=Ye({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`,`getDevice`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]})}}),p=U(()=>{let e=a.trim().toLowerCase();return e.length===0?d:d.filter(t=>t.toLowerCase()!==e&&t.toLowerCase().includes(e))},[d,a]),m=a.trim().length>0&&!d.some(e=>e.toLowerCase()===a.trim().toLowerCase()),h=async n=>{let r=(n??a).trim(),o=r.length===0?null:r;if(o===(t??null)){i(!1);return}c(!0);try{await f.mutateAsync({deviceId:e,location:o}),i(!1)}catch{}finally{c(!1)}},g=()=>{o(t??``),i(!1)};return r?K($,{label:`Location`,value:H(`div`,{className:`relative`,children:[H(`div`,{className:`flex items-center gap-1`,children:[K(`input`,{ref:l,type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`?h():e.key===`Escape`&&g()},disabled:s,placeholder:`Room / area (or leave empty to clear)`,className:`flex-1 min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary`}),K(`button`,{type:`button`,onClick:()=>void h(),disabled:s,className:`p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50`,"aria-label":`Save`,children:K(Dt,{className:`h-3 w-3`})}),K(`button`,{type:`button`,onClick:g,disabled:s,className:`p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50`,"aria-label":`Cancel`,children:K(Nt,{className:`h-3 w-3`})})]}),(p.length>0||m)&&H(`div`,{className:`absolute z-10 left-0 right-0 mt-0.5 max-h-40 overflow-y-auto rounded-md border border-border bg-surface shadow-md`,children:[p.map(e=>H(`button`,{type:`button`,onClick:()=>{o(e),h(e)},className:`w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover`,children:[K(gt,{className:`h-3 w-3 text-foreground-subtle flex-shrink-0`}),K(`span`,{className:`truncate`,children:e})]},e)),m&&H(`button`,{type:`button`,onClick:()=>void h(),className:`w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover border-t border-border`,children:[K(`span`,{className:`text-foreground-subtle`,children:`Create`}),H(`span`,{className:`font-medium truncate`,children:[`"`,a.trim(),`"`]})]})]})]})}):K($,{label:`Location`,value:H(`div`,{className:`flex items-center gap-2 group`,children:[t?K(`span`,{className:`truncate`,children:t}):K(`span`,{className:`italic text-foreground-subtle`,children:`unset`}),K(`button`,{type:`button`,onClick:()=>i(!0),className:`p-0.5 rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":`Edit location`,children:K(_t,{className:`h-3.5 w-3.5`})})]})})}V();function sr({deviceId:e}){let t=W(),{data:n}=dt(e),{data:r}=ht(e),[i,a]=G(null),o=j({onSuccess:()=>{a(null),t.invalidateQueries({queryKey:[[`deviceManager`]]})},onError:e=>{a(`Could not change primary child: ${e.message}`)}});if(n==null||String(n.type??``)!==J.Container)return null;let s=(r??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:e.name,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}}));if(s.length<=1)return null;let c=pe(s,typeof n.linkDeviceId==`number`?n.linkDeviceId:null,typeof n.primaryChildEntityId==`string`?n.primaryChildEntityId:null);return H(Ze,{children:[K($,{label:`Primary child`,value:K(p,{childrenList:s,selectedId:c===null?s[0].id:c.id,onSetPrimary:t=>o.mutate({deviceId:e,primaryChildEntityId:t}),disabled:o.isPending})}),i!==null&&K(`p`,{role:`alert`,className:`px-3 sm:px-4 py-1.5 text-[11px] text-danger`,children:i})]})}V();var cr=[`manufacturer`,`model`,`hardware`,`firmware`,`serialNumber`,`uid`,`mac`,`itemNo`];function lr(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function ur(e){return e==null?`—`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function dr(){let e=te(),t=d(),{data:n}=c({deviceId:e??0},{enabled:e!==null}),{data:r}=Ke({deviceId:e??0},{enabled:e!==null}),i=n??t??null,[a,o]=G(`identity`);if(e===null||!i)return null;let s=String(i.stableId??``),l=String(i.name??``),u=String(i.type??``),f=String(i.addonId??``),p=i.features??[],m=new Set([`device-status`,`feature-probe`,`device-ops`]),h=(r?.entries??[]).filter(e=>e.kind===`native`&&!m.has(e.capName)).map(e=>e.capName),g=p.length>0?p:h,_=i.location??null,v=i.metadata??null,y=v!==null&&Object.keys(v).length>0;return H(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[H(`div`,{className:`border-b border-border px-3 sm:px-4 py-2 flex items-center justify-between gap-3`,children:[K(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:`Device Info`}),y&&H(`div`,{className:`flex items-center gap-1 rounded-md bg-surface-hover p-0.5`,children:[K(fr,{active:a===`identity`,onClick:()=>o(`identity`),label:`Identity`}),K(fr,{active:a===`hardware`,onClick:()=>o(`hardware`),label:`Hardware`})]})]}),(!y||a===`identity`)&&H(`div`,{className:`divide-y divide-border`,children:[K($,{label:`ID`,value:H(`span`,{className:`font-mono text-[11px] text-foreground`,children:[`#${e}`,H(`span`,{className:`ml-1.5 text-foreground-subtle`,children:[`(`,s,`)`]})]})}),K(ar,{deviceId:e,initialName:l}),K(or,{deviceId:e,initialLocation:_}),K(sr,{deviceId:e}),K($,{label:`Type`,value:u}),K($,{label:`Provider`,value:K(ut,{type:f,size:`sm`,showLabel:!0})}),K($,{label:`Capabilities`,value:g.length>0?K(ct,{capabilities:g,showLabels:!0}):K(`span`,{className:`text-[11px] text-foreground-subtle`,children:`None`})})]}),y&&a===`hardware`&&K(pr,{metadata:v})]})}function fr({active:e,onClick:t,label:n}){return K(`button`,{type:`button`,onClick:t,className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${e?`bg-surface text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`}`,children:n})}function pr({metadata:e}){let t=cr.filter(t=>t in e),n=Object.keys(e).filter(e=>!cr.includes(e)).toSorted(),r=[...t,...n];return H(`div`,{children:[K(`div`,{className:`px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-b border-border bg-surface-subtle/40`,children:`Auto-populated by the driver on every connect. Read-only.`}),K(`div`,{className:`divide-y divide-border`,children:r.map(t=>K($,{label:lr(t),value:K(`span`,{className:`font-mono text-[11px] text-foreground break-all`,children:ur(e[t])})},t))})]})}V();function mr({deviceId:e}){let[t,n]=G(null),r=be({onSuccess:e=>{n(e.changed?`Re-aligned with source — ${e.rebuiltChildren} child${e.rebuiltChildren===1?``:`ren`} rebuilt.`:`Already up to date.`)},onError:e=>n(`Re-sync failed: ${e.message}`)});return H(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3`,children:[H(`div`,{className:`flex items-center justify-between gap-3`,children:[H(`div`,{children:[K(`h2`,{className:`text-xs font-semibold uppercase tracking-wider text-foreground`,children:`Re-sync`}),K(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:`Re-align this device's type, role, capabilities and units with its source.`})]}),H(`button`,{type:`button`,disabled:r.isPending,onClick:()=>{n(null),r.mutate({camDeviceId:e})},className:`inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-foreground hover:bg-surface disabled:opacity-50`,children:[K(vt,{className:`h-3 w-3 ${r.isPending?`animate-spin`:``}`}),r.isPending?`Re-syncing…`:`Re-sync`]})]}),t!==null&&K(`p`,{className:`mt-2 text-[11px] text-foreground-subtle`,children:t})]})}V();var hr={icon:``,label:``,unit:``,precision:``,hidden:!1};function gr(e){return{icon:e?.icon??``,label:e?.label??``,unit:e?.unit??``,precision:e?.precision===void 0?``:String(e.precision),hidden:e?.hidden===!0}}function _r(e){if(typeof e!=`object`||!e)return;let t=e.unit;return typeof t==`string`?t:void 0}function vr(e){let t=e.precision.trim()===``?void 0:Number.parseInt(e.precision,10),n={...e.icon===``?{}:{icon:e.icon},...e.label.trim()===``?{}:{label:e.label.trim()},...e.unit===``?{}:{unit:e.unit},...t!==void 0&&Number.isFinite(t)?{precision:t}:{},...e.hidden?{hidden:!0}:{}};return Object.keys(n).length===0?null:n}function yr({deviceId:e}){let n=Y(),r=W(),{data:i}=c({deviceId:e},{enabled:e>0}),a=typeof i?.role==`string`?i.role:null,o=a===null?void 0:Be[a],s=o?.kind===`numeric`,l=je(n.trpcClient,e,a??``),u=o?.kind===`numeric`?o.canonicalUnit:void 0,d=_r(l)??u,f=d===void 0?void 0:tt(d),p=U(()=>f===void 0?[]:et(f),[f]),[m,g]=G(null),_=m??gr(i?.display),v=re({onSuccess:()=>{r.invalidateQueries({queryKey:[[`deviceManager`]]})}}),{data:y}=t({},{staleTime:6e4}),b=h({onSuccess:()=>{r.invalidateQueries({queryKey:[[`deviceManager`]]})}});if(i===void 0||a===null)return null;let x=e=>{g({..._,...e})},S=()=>{v.mutate({deviceId:e,display:vr(_)})},C=()=>{g(hr),v.mutate({deviceId:e,display:null})},w=()=>{let e={..._.icon===``?{}:{icon:_.icon},..._.unit===``?{}:{unit:_.unit},..._.precision.trim()!==``&&Number.isFinite(Number.parseInt(_.precision,10))?{precision:Number.parseInt(_.precision,10)}:{}},t={...y?.defaults??{},[a]:e};b.mutate({defaults:t})},T=ze(a).label,ee=Object.keys(He);return H(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[K(`div`,{className:`border-b border-border px-4 py-2`,children:K(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:`Display`})}),H(`div`,{className:`p-4 space-y-3`,children:[H(`label`,{className:`block`,children:[K(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Icon`}),H(`select`,{className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,value:_.icon,onChange:e=>x({icon:e.target.value}),children:[H(`option`,{value:``,children:[`Default (`,T,`)`]}),ee.map(e=>K(`option`,{value:e,children:e},e))]})]}),H(`label`,{className:`block`,children:[K(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Label`}),K(`input`,{type:`text`,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,placeholder:T,value:_.label,onChange:e=>x({label:e.target.value})})]}),s&&H(`div`,{className:`grid grid-cols-2 gap-3`,children:[H(`label`,{className:`block`,children:[K(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Unit`}),H(`select`,{className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,value:_.unit,onChange:e=>x({unit:e.target.value}),disabled:p.length===0,children:[H(`option`,{value:``,children:[`Source`,d?` (${d})`:``]}),p.map(e=>K(`option`,{value:e,children:e},e))]})]}),H(`label`,{className:`block`,children:[K(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Precision`}),K(`input`,{type:`number`,min:0,max:10,step:1,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,placeholder:`inherit`,value:_.precision,onChange:e=>x({precision:e.target.value})})]})]}),H(`label`,{className:`flex items-center gap-2`,children:[K(`input`,{type:`checkbox`,checked:_.hidden,onChange:e=>x({hidden:e.target.checked})}),K(`span`,{className:`text-sm text-foreground`,children:`Hide from device lists`})]}),H(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[K(`button`,{type:`button`,className:`rounded bg-primary px-3 py-1 text-sm font-medium text-primary-foreground disabled:opacity-50`,onClick:S,disabled:v.isPending,children:`Save`}),K(`button`,{type:`button`,className:`rounded border border-border px-3 py-1 text-sm text-foreground-subtle`,onClick:C,disabled:v.isPending,children:`Reset`}),H(`button`,{type:`button`,className:`rounded border border-border px-3 py-1 text-sm text-foreground-subtle`,onClick:w,disabled:b.isPending,title:`Apply this unit / precision / icon as the default for every ${T} sensor`,children:[`Set as default for all `,T,` sensors`]})]})]})]})}function br(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function xr({device:e}){let t=Lt(),n=typeof e.id==`number`?e.id:null,r=String(e.type??``),i=r===J.Camera,a=r===J.Hub,o=typeof e.role==`string`&&e.role.length>0,s=e.features??[],c=s.includes(nt.Resyncable),{data:l}=f({deviceId:n??0},{enabled:n!==null&&i,refetchInterval:5e3}),u=l?.streams??{},d=Object.entries(u),p=s.includes(nt.DoorbellButton),m=Le(p?{deviceId:n??void 0,historyLimit:10}:void 0),h=m.latest?Date.now()-m.latest.timestamp<3e4:!1;return H(`div`,{className:`space-y-5`,children:[a&&n!==null&&K(Pe,{deviceId:n,onOpenChild:e=>t(`/devices/${e}`)}),c&&n!==null&&K(mr,{deviceId:n}),i&&n!==null&&K(D,{widgetId:`pipeline-orchestrator/pipeline-quick-stats`,host:`device-tab`,deviceId:n}),p&&K(Ue,{history:m.history,latestIsFresh:h}),i&&n!==null&&K(D,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:n}),i&&d.length>0&&H(`div`,{className:`@container rounded-lg border border-border bg-surface overflow-hidden`,style:{containerType:`inline-size`},children:[K(`div`,{className:`border-b border-border px-4 py-2`,children:K(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:`Stream Network`})}),K(`div`,{className:`divide-y divide-border`,children:d.map(([e,t])=>H(`div`,{className:`px-4 py-2.5`,children:[H(`div`,{className:`flex items-center gap-2 mb-2`,children:[K(St,{className:`h-3 w-3 text-foreground-subtle`}),K(`span`,{className:`text-[11px] font-medium text-foreground`,children:e})]}),H(`div`,{className:`grid grid-cols-2 @[640px]:grid-cols-4 gap-2`,children:[K(Sr,{label:`Nominal`,value:br(t.nominalBitrateKbps??0)}),K(Sr,{label:`Observed`,value:br(t.observedBitrateKbps??0)}),K(Sr,{label:`Peak`,value:br(t.peakBitrateKbps??0)}),K(Sr,{label:`Packet Loss`,value:`${(t.packetLossPercent??0).toFixed(2)}%`,warning:(t.packetLossPercent??0)>1})]})]},e))})]}),K(dr,{}),o&&n!==null&&K(yr,{deviceId:n})]})}function Sr({label:e,value:t,warning:n}){return H(`div`,{children:[K(`p`,{className:`text-[10px] text-foreground-subtle`,children:e}),K(`p`,{className:`text-xs font-medium ${n?`text-warning`:`text-foreground`}`,children:t})]})}V();var Cr=[{id:`overview`,label:`Overview`,cameraOnly:!1},{id:`config`,label:`Config`,cameraOnly:!1},{id:`detection-pipeline`,label:`Detection pipeline`,cameraOnly:!0},{id:`bindings`,label:`Bindings`,cameraOnly:!0}];function wr(e){let t=e===J.Camera;return Cr.filter(e=>t||!e.cameraOnly).map(({id:e,label:t})=>({id:e,label:t}))}var Tr=[{id:`logs`,icon:Ft,label:`Logs`},{id:`repl`,icon:Mt,label:`REPL`},{id:`events`,icon:wt,label:`Events`},{id:`state`,icon:Pt,label:`State`}];function Er(){let t=Tt(),n=Number(t.deviceId),i=Number.isFinite(n),o=Lt(),u=W(),d=Re(),f=Y(),[p,m]=At(),h=p.get(`tab`)??`overview`,g=p.get(`sub`),[v,y]=G(`logs`),b=`device-detail.left-col-width-px`,[x,S]=G(()=>{if(typeof window>`u`)return null;let e=window.localStorage.getItem(b),t=e?Number(e):NaN;return Number.isFinite(t)&&t>0?t:null}),w=B(x);w.current=x;function T(e){e.preventDefault();let t=e.clientX,n=e.currentTarget.previousElementSibling?.getBoundingClientRect().width??x??0,r=Math.max(330,Math.floor(window.innerWidth*.7)),i=e=>{S(Math.max(280,Math.min(r,n+(e.clientX-t))))},a=()=>{document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a);let e=w.current;if(e!==null)try{window.localStorage.setItem(b,String(Math.round(e)))}catch{}document.body.style.userSelect=``,document.body.style.cursor=``};document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`,document.addEventListener(`mousemove`,i),document.addEventListener(`mouseup`,a)}let{data:te,isLoading:ne,isError:re}=c({deviceId:n},{enabled:i,refetchInterval:5e3,retry:1}),{data:E}=ee({deviceId:n},{enabled:i}),D=U(()=>{let e=E?.settings?.sections??[],t=E?.live?.sections??[],n=[...e,...t],r=new Set;for(let e of n)e.location===`top-tab`&&e.tab&&r.add(e.tab===`zones`?`detection-pipeline`:e.tab);return n.some(Wt)&&r.add(Gt),[...r].map(e=>e===`export`?{id:e,label:Kt,isAddonContrib:!0}:{id:e,label:$e[e]?.label??e,isAddonContrib:!0})},[E]),O=te,k=String(O?.name??t.deviceId??`Device`),oe=O?.online===!0,A=oe?`online`:`offline`,j=String(O?.addonId??`rtsp`),M=O?.features??[],N=O?.type,se=N===J.Camera,{data:P}=ht(i?n:0),le=N===J.Container,de=U(()=>(P??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}})),[P]),F=U(()=>le?pe(de,typeof O?.linkDeviceId==`number`?O.linkDeviceId:null,typeof O?.primaryChildEntityId==`string`?O.primaryChildEntityId:null)?.id??null:null,[le,de,O?.linkDeviceId,O?.primaryChildEntityId]),{data:fe}=ee({deviceId:F??0},{enabled:F!==null}),me=U(()=>{if(F===null)return[];let e=fe?.settings?.sections??[],t=fe?.live?.sections??[],n=new Set;for(let r of[...e,...t])r.location===`top-tab`&&r.tab&&n.add(r.tab);return[...n].map(e=>({id:e,label:$e[e]?.label??e,isAddonContrib:!0,childDeviceId:F}))},[F,fe]),I=typeof O?.parentDeviceId==`number`?O.parentDeviceId:null,{data:ge}=c({deviceId:I??0},{enabled:I!==null}),L=ie(),_e=O?.disabled!==!0,ve=U(()=>{let e=new Set,t=[];for(let n of[...wr(N),...D,...me])e.has(n.id)||(e.add(n.id),t.push(n));return t},[N,D,me]),ye=U(()=>ve.some(e=>e.id===h)?h:`overview`,[ve,h]),be=z(e=>{m(t=>{let n=new URLSearchParams(t);return e===`overview`?n.delete(`tab`):n.set(`tab`,e),n.delete(`sub`),n},{replace:!0})},[m]),xe=z(e=>{m(t=>{let n=new URLSearchParams(t);return n.set(`sub`,e),n},{replace:!0})},[m]),Se=(P??[]).length>0,Ce=U(()=>Tr.filter(({featureGate:e})=>!e||M.includes(e)),[M]),{data:R}=Oe({addonId:j},{enabled:!!j&&j!==`rtsp`}),we=_({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]}),o(R?.id?`/integrations/${R.id}`:`/integrations`)}}),De=a({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),ke=We({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ae=he(),je=ae({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ne=M.includes(nt.Rebootable),Pe=M.includes(nt.BatteryOperated),Fe=e(f.trpcClient,Pe&&i?n:null),[Ie,Le]=G(!1),ze=rt(f.trpcClient,i?n:null),Be=async()=>{if(!(Ie||!ze)){Le(!0);try{await ze.snapshot?.invalidateCache({});let e=await ze.snapshot?.getSnapshot({});if(!e)return;let t=`data:${e.contentType};base64,${e.base64}`,n=e.contentType.includes(`png`)?`png`:`jpg`,r=k.replace(/[^a-zA-Z0-9_.-]+/g,`_`),i=new Date().toISOString().replace(/[:.]/g,`-`),a=document.createElement(`a`);a.href=t,a.download=`${r}-${i}.${n}`,document.body.appendChild(a),a.click(),document.body.removeChild(a)}finally{Le(!1)}}},Ve=De.isPending||ke.isPending,{data:He}=Te({deviceId:n},{enabled:i,refetchInterval:1e4}),Ue=He?.agentNodeId??null,Ke=typeof Ue==`string`&&Ue.length>0&&!Ue.startsWith(`addon:`)?Ue:void 0,{data:qe}=ce({deviceId:n,...Ke?{nodeId:Ke}:{}},{enabled:i,refetchInterval:3e3,retry:!1}),{data:Je}=r({deviceId:n},{enabled:i,refetchInterval:3e3,retry:!1}),Ye=Je?.level?.dbfs??null;function V(){if(!i)return null;switch(ye){case`overview`:return K(xr,{device:O??{}});case`config`:return K(Kn,{deviceId:n,activeSubTab:g,onSubTabChange:xe});case`detection-pipeline`:return K(ir,{deviceId:n,activeSubTab:g,onSubTabChange:xe});case`bindings`:return K(Hn,{deviceId:n});default:{let e=ye,t=D.some(t=>t.id===e),r=me.find(t=>t.id===e);if(!t&&r===void 0)return null;let i=r?.childDeviceId??n;if(e===`export`)return K(qt,{deviceId:n,sectionFilter:Wt,activeSubTab:g,onSubTabChange:xe});let a=K(qt,{deviceId:i,sectionFilter:t=>t.location===`top-tab`&&(t.tab===e||e===`detection-pipeline`&&t.tab===`zones`),flattenSubTabs:e===`detection-pipeline`,activeSubTab:g,onSubTabChange:xe});return r!==void 0&&i!==n?K(C,{deviceId:i,children:a}):a}}}return i?ne?H(`div`,{className:`flex flex-col h-full`,children:[H(`div`,{className:`border-b border-border bg-surface px-6 py-4`,children:[K(`div`,{className:`h-4 w-48 rounded bg-surface-hover animate-pulse mb-3`}),K(`div`,{className:`h-8 w-64 rounded bg-surface-hover animate-pulse`})]}),K(`div`,{className:`flex-1 p-6`,children:K(`div`,{className:`h-40 rounded-lg border border-border bg-surface animate-pulse`})})]}):re||!te?H(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle`,children:[K(`p`,{className:`text-lg font-semibold text-foreground`,children:`Device not found`}),H(`p`,{className:`text-xs`,children:[`No device with ID`,` `,H(`code`,{className:`font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]`,children:[`#`,n]})]}),K(`button`,{onClick:()=>o(`/integrations`),className:`mt-2 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:`Back to Integrations`})]}):H(`div`,{className:`absolute inset-0 flex flex-col overflow-hidden`,children:[H(`div`,{className:`border-b border-border bg-surface px-6 py-3 flex-shrink-0`,children:[K(`div`,{className:`mb-2`,children:K(Ge,{items:[{label:`Integrations`,onClick:()=>o(`/integrations`)},{label:R?.name??j,onClick:()=>R?.id&&o(`/integrations/${R.id}`)},{label:k}]})}),H(`div`,{className:`flex items-center gap-2 sm:gap-3`,children:[K(ut,{type:j,size:`lg`}),H(`div`,{className:`min-w-0 flex-1`,children:[H(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[K(`h1`,{className:`text-sm sm:text-base font-semibold text-foreground truncate`,children:k}),K(Ht,{status:A}),Pe&&K(ue,{status:Fe,variant:`full`})]}),I!==null&&ge&&H(`button`,{type:`button`,onClick:()=>o(`/devices/${I}`),className:`text-[10px] text-foreground-subtle hover:text-primary transition-colors mt-0.5 inline-flex items-center gap-1`,title:`Open parent device ${ge.name}`,children:[K(`span`,{children:`↑`}),K(`span`,{className:`truncate`,children:String(ge.name??`Device #${I}`)})]}),K(`div`,{className:`hidden md:flex items-center gap-3 mt-0.5 text-[10px] text-foreground-subtle`,children:M.length>0&&K(ct,{capabilities:M})})]}),qe&&K(`div`,{className:`hidden lg:flex`,children:K(Dr,{metrics:qe,dbfs:Ye})}),H(`div`,{className:`flex items-center gap-1 shrink-0`,children:[H(`button`,{onClick:async()=>{_e?await d({title:`Disable "${k}"?`,message:`The device will stop processing streams and events. You can re-enable it later.`,confirmLabel:`Disable`,variant:`danger`})&&ke.mutate({deviceId:n}):De.mutate({deviceId:n})},disabled:Ve,title:_e?`Disable device`:`Enable device`,className:`inline-flex items-center gap-1.5 rounded-lg px-2 sm:px-2.5 py-1.5 text-[11px] font-medium border transition-colors disabled:opacity-50 ${_e?`border-success/30 text-success hover:bg-success/10`:`border-border text-foreground-subtle/50 hover:text-foreground hover:bg-surface-hover`}`,children:[K(Qt,{className:`h-3.5 w-3.5`}),K(`span`,{className:`hidden sm:inline`,children:Ve?`Updating…`:_e?`Enabled`:`Disabled`})]}),K(`div`,{className:`hidden sm:block h-5 w-px bg-border mx-1`}),K(Ee,{triggerClassName:`ml-1`,items:[{id:`snapshot`,label:`Take snapshot`,description:`Fetch a fresh frame and download it.`,icon:Ct,disabled:Ie,onClick:()=>{Be()}},{id:`reboot`,label:`Reboot device`,description:`Camera goes offline for ~30 seconds.`,icon:bt,hidden:!Ne,disabled:Ae.isPending,danger:!0,onClick:async()=>{await d({title:`Reboot "${k}"?`,message:`The camera will go offline for around 30 seconds while the firmware reboots.`,confirmLabel:`Reboot`,variant:`danger`})&&Ae.mutate({deviceId:n})}},{id:`restart-addon`,label:`Restart addon`,description:`Bounces every device served by ${R?.name??j}.`,icon:vt,disabled:je.isPending,danger:!0,onClick:async()=>{await d({title:`Restart "${R?.name??j}"?`,message:`Restarting the addon will briefly disconnect every device served by it (not just "${k}"). Streams will reconnect automatically.`,confirmLabel:`Restart`,variant:`danger`})&&je.mutate({addonId:j})}},{id:`delete`,label:`Delete device`,description:`Remove the device and all its settings.`,icon:Rt,separatorBefore:!0,disabled:we.isPending,danger:!0,onClick:async()=>{await d({title:`Delete "${k}"?`,message:`This will remove the device and all its settings. This action cannot be undone.`,confirmLabel:`Delete`,variant:`danger`})&&we.mutate({deviceId:n})}}]})]})]})]}),K(C,{deviceId:n,device:O??void 0,children:K(s,{children:K(l,{children:K(ot,{children:K(Me,{children:H(`main`,{className:L?`flex-1 overflow-y-auto flex flex-col`:`flex-1 min-h-0 overflow-hidden flex flex-row`,children:[H(`div`,{className:L?`flex flex-col bg-surface`:`${x===null?`w-1/2 lg:w-1/3`:``} flex-shrink-0 flex flex-col bg-surface min-h-0 overflow-hidden`,style:!L&&x!==null?{width:`${String(x)}px`}:void 0,children:[K(`div`,{className:se?`flex-shrink-0 border-b border-border-subtle bg-black`:L?`flex-shrink-0 border-b border-border-subtle bg-surface`:`max-h-[55%] shrink-0 overflow-y-auto border-b border-border-subtle bg-surface`,children:se?K(Nn,{deviceId:n,intercomAvailable:M.includes(nt.TwoWayAudio)}):K(wn,{deviceId:n,deviceName:k,deviceType:N??`unknown`,provider:j,isOnline:oe,features:M})}),H(`div`,{className:L?`flex flex-col border-b border-border`:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[K(`div`,{className:`flex-shrink-0 border-b border-border-subtle px-2 py-1.5`,children:K(`div`,{className:`flex gap-1 overflow-x-auto -mx-1 px-1 pb-0.5`,children:Ce.map(({id:e,label:t,icon:n})=>H(`button`,{onClick:()=>y(e),title:t,className:`flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium transition-colors flex-shrink-0 ${v===e?`bg-primary/15 text-primary`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[K(n,{className:`h-3 w-3`}),t]},e))})}),H(`div`,{className:L?`h-72 overflow-hidden`:`flex-1 min-h-0 overflow-hidden`,children:[v===`logs`&&K(Pn,{deviceId:n,containerDeviceId:N===`container`?n:void 0}),v===`repl`&&K(Fn,{deviceId:n}),v===`events`&&K(In,{deviceId:n}),v===`state`&&K(Ln,{deviceId:n})]})]})]}),!L&&K(`div`,{role:`separator`,"aria-orientation":`vertical`,title:`Drag to resize`,onMouseDown:T,className:`flex-shrink-0 w-1 cursor-col-resize bg-border hover:bg-primary/40 transition-colors group relative z-10`,children:K(`span`,{className:`absolute inset-y-0 -left-1 -right-1`})}),H(`div`,{className:L?`flex flex-col`:`flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden`,children:[K(`div`,{className:`flex-shrink-0 border-b border-border bg-surface px-4`,children:K(`div`,{className:`flex flex-nowrap overflow-x-auto md:flex-wrap md:overflow-x-visible items-center gap-0`,children:ve.map(e=>{let t=ye===e.id;return H(`button`,{onClick:()=>be(e.id),className:`relative flex-shrink-0 px-3 py-2 text-xs font-medium transition-colors ${t?`text-primary`:`text-foreground-subtle hover:text-foreground`}`,children:[e.label,t&&K(`span`,{className:`absolute bottom-0 left-0 right-0 h-0.5 rounded-full bg-primary`})]},e.id)})})}),H(`div`,{className:L?`p-3 flex flex-col gap-3`:`flex-1 min-h-0 overflow-y-auto p-4 flex flex-col gap-3`,children:[ye===`overview`&&Se&&K(en,{parentDeviceId:n}),V()]})]})]})})})})})})]}):H(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle`,children:[K(`p`,{className:`text-lg font-semibold text-foreground`,children:`Invalid device id`}),H(`p`,{className:`text-xs`,children:[`The URL segment`,` `,K(`code`,{className:`font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]`,children:t.deviceId}),` `,`is not a number.`]}),K(`button`,{onClick:()=>o(`/integrations`),className:`mt-2 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:`Back to Integrations`})]})}function Dr({metrics:e,dbfs:t}){let n=b(e.phase??`idle`);return H(`div`,{className:`flex items-center gap-3 flex-shrink-0`,children:[H(`div`,{className:`flex items-center gap-1.5`,children:[K(`span`,{className:`h-1.5 w-1.5 rounded-full ${n.dotClass}`}),K(`span`,{className:`text-[10px] font-medium ${n.textColor}`,children:n.label})]}),K(`div`,{className:`h-3 w-px bg-border`}),H(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[K(kt,{className:`h-3 w-3`}),K(`span`,{className:`text-foreground tabular-nums`,children:(e.actualFps??0).toFixed(1)}),K(`span`,{children:`fps`})]}),H(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[K(Et,{className:`h-3 w-3`}),K(`span`,{className:`text-foreground tabular-nums`,children:(e.avgInferenceTimeMs??0).toFixed(0)}),K(`span`,{children:`ms`})]}),H(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,title:`Current audio level (dBFS)`,children:[K($t,{className:`h-3 w-3`}),K(`span`,{className:`text-foreground tabular-nums`,children:t==null?`—`:t.toFixed(0)}),K(`span`,{children:`dB`})]}),(e.queueDepth??0)>0&&H(`span`,{className:`text-[10px] text-warning tabular-nums`,children:[`q:`,e.queueDepth]})]})}export{Er as DeviceDetailPage};
|