@camstack/addon-admin-ui 1.2.16 → 1.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/AddLocationWizard-BowIG3iq.js +1 -0
- package/dist/assets/{AddonCollectionPage-BM908g2f.js → AddonCollectionPage-DzUEOYUV.js} +1 -1
- package/dist/assets/Addons-B5DucodR.js +1 -0
- package/dist/assets/{AdminTabs-6yXsZXxy.js → AdminTabs-C-SMNF-6.js} +1 -1
- package/dist/assets/{AiProfiles-BD68Zj9J.js → AiProfiles-D65CezzL.js} +1 -1
- package/dist/assets/{BrokerForm-DdIHaTEB.js → BrokerForm-ENHOk64X.js} +1 -1
- package/dist/assets/{Capabilities-Bqn-RV72.js → Capabilities-dtlaxRnV.js} +1 -1
- package/dist/assets/{CapabilityBadges-DzvvSaPs.js → CapabilityBadges-QVudw7lC.js} +1 -1
- package/dist/assets/Cluster-9-Ysfuh5.js +1 -0
- package/dist/assets/{ClusterRecordingTab-z1xB2po9.js → ClusterRecordingTab-CvimJgTY.js} +1 -1
- package/dist/assets/{Dashboard-CADMRCrw.js → Dashboard-CXFEM2IR.js} +1 -1
- package/dist/assets/Data-DPmsq4Rb.js +1 -0
- package/dist/assets/DetectionIntelligence-CsY0BCKS.js +1 -0
- package/dist/assets/DeviceAggregateSection-CzThj0Vt.js +1 -0
- package/dist/assets/DeviceDetail-BWX7NeMm.js +2 -0
- package/dist/assets/{Devices-OO1Obho0.js → Devices-CdMd1Rxe.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-Dj5RZE6X.js → EmbedPlayerPage-BPMSAjgX.js} +1 -1
- package/dist/assets/Events-DlSc5xWS.js +1 -0
- package/dist/assets/{FormBuilder-D6rV90RE.js → FormBuilder-BTBth7Mm.js} +1 -1
- package/dist/assets/{Identity-CyhpFEp5.js → Identity-BkJfHHax.js} +1 -1
- package/dist/assets/IntegrationDetail-DjcVm32z.js +1 -0
- package/dist/assets/{Integrations-Cf-P7zbM.js → Integrations-BstWDI9y.js} +1 -1
- package/dist/assets/{Integrations-uId-1G3x.js → Integrations-CCkqm_Su.js} +1 -1
- package/dist/assets/{Logs-BsuRve34.js → Logs-BKvPV_wj.js} +1 -1
- package/dist/assets/{MotionZonesSettings-CDt7HiBk.js → MotionZonesSettings-C3F5tNrn.js} +1 -1
- package/dist/assets/{MyAccess-nr6vCJQp.js → MyAccess-D94hQDyr.js} +1 -1
- package/dist/assets/Network-DRjrjeQG.js +1 -0
- package/dist/assets/{NodeAddonsSettingsPanel-DQhn50qD.js → NodeAddonsSettingsPanel-CL75zTHK.js} +1 -1
- package/dist/assets/{NodeInferenceDevices-DreXBx4e.js → NodeInferenceDevices-gVLIWG74.js} +1 -1
- package/dist/assets/Notifications-7spoN22j.js +1 -0
- package/dist/assets/Pipeline-Dmgt7OdK.js +1 -0
- package/dist/assets/{Plates-D93zGL-b.js → Plates-0nXxdKJX.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-CeRPYNws.js → PrivacyMaskSettings-BC6o9lqJ.js} +1 -1
- package/dist/assets/{ProviderIcon-DXM0Cs6A.js → ProviderIcon-tK6tKDtF.js} +1 -1
- package/dist/assets/Recordings-BtjWTugI.js +1 -0
- package/dist/assets/{ScanNetworkModal-DtqM9hw3.js → ScanNetworkModal-CwPUWLnW.js} +1 -1
- package/dist/assets/{Settings-DcxnlT5r.js → Settings-CmklSlYL.js} +1 -1
- package/dist/assets/{Showroom-DiNuN2DK.js → Showroom-fSzPo12F.js} +1 -1
- package/dist/assets/{Terminal-Yn1yb5UR.js → Terminal-DLULQ5yw.js} +2 -2
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DHOV12JB.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C8V797Ba.js} +1 -1
- package/dist/assets/{build-cluster-graph--dRyE6jp.js → build-cluster-graph-DIGI0NJ3.js} +2 -2
- package/dist/assets/circle-check-big-DifLR11P.js +1 -0
- package/dist/assets/clock-BXw5TTp6.js +1 -0
- package/dist/assets/{copy-BBaHyGT3.js → copy-D4StuZzs.js} +1 -1
- package/dist/assets/{debounced-invalidate-oJQtaYsH.js → debounced-invalidate-CXo5TVm0.js} +1 -1
- package/dist/assets/{dist-BfuZVKjE.js → dist-B1ZcDDOx.js} +1 -1
- package/dist/assets/dist-BqHHqLgd.js +7 -0
- package/dist/assets/{download-BARV2Xt2.js → download-Dq6V-5xf.js} +1 -1
- package/dist/assets/{face-bbox-CB0AdRxV.js → face-bbox-CnD55hf6.js} +1 -1
- package/dist/assets/{hostInit-D1YIG8Xp.js → hostInit-DyHdo8Gk.js} +1 -1
- package/dist/assets/index-BsmimqzB.js +4 -0
- package/dist/assets/index-D_09pXCE.css +2 -0
- package/dist/assets/{key-round-Cu-m43BY.js → key-round-BC8uv06u.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-7505e378.js → mf-entry-bootstrap-0-278ef480.js} +2 -2
- package/dist/assets/{pencil-C3NxLuzk.js → pencil-BuY8CueB.js} +1 -1
- package/dist/assets/{player-overlays-5vIS4o_W.js → player-overlays-CNHQKrHd.js} +1 -1
- package/dist/assets/plus-DyBHOfPx.js +1 -0
- package/dist/assets/{radio-IH3FZ-ad.js → radio-CQ2Qddgd.js} +1 -1
- package/dist/assets/{refresh-cw-DXzAUpGT.js → refresh-cw-BwbLLVV6.js} +1 -1
- package/dist/assets/remoteEntry-BQiHtOSG.js +1 -0
- package/dist/assets/{rotate-ccw-mo9YtqUE.js → rotate-ccw-D9ag3NNh.js} +1 -1
- package/dist/assets/rotate-cw-J5QBXynE.js +1 -0
- package/dist/assets/search-BLl1nrAm.js +1 -0
- package/dist/assets/{send-DUT5ZyQM.js → send-CrQGjBpn.js} +1 -1
- package/dist/assets/{server-B2_ttQ96.js → server-C-ApRIN8.js} +1 -1
- package/dist/assets/square-D5oi0WlG.js +1 -0
- package/dist/assets/{square-check-big-D5MMfdqS.js → square-check-big-D0Ns-qwF.js} +1 -1
- package/dist/assets/src-BDNLbHXL.js +67 -0
- package/dist/assets/src-SFNx0Juf.js +7 -0
- package/dist/assets/{upload-DfBkWUj-.js → upload-OKC5mQ8W.js} +1 -1
- package/dist/assets/{useEventInvalidation-tttDHu6H.js → useEventInvalidation-BHTo3YFv.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CcewkvoR.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CkMK9IKI.js} +2 -2
- package/dist/assets/{wifi-jwlQfCJ5.js → wifi-xQgrxKer.js} +1 -1
- package/dist/assets/{zap-CUnbY527.js → zap-B6f_Rmgy.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/server/addon.js +452 -77
- package/package.json +1 -1
- package/dist/assets/AddLocationWizard-B_z3eUPS.js +0 -1
- package/dist/assets/Addons-D8SC8yBw.js +0 -1
- package/dist/assets/Cluster-CQhoefyJ.js +0 -1
- package/dist/assets/Data-Dk7iSdmP.js +0 -1
- package/dist/assets/DetectionIntelligence-CxKHKx0p.js +0 -1
- package/dist/assets/DeviceDetail-KFtEf0dr.js +0 -2
- package/dist/assets/Events-xEfJUDrb.js +0 -1
- package/dist/assets/IntegrationDetail-CkhuZF-B.js +0 -1
- package/dist/assets/Network-Cc-kPHj4.js +0 -1
- package/dist/assets/Notifications-BSPhogBa.js +0 -1
- package/dist/assets/Pipeline-CNL8qV10.js +0 -1
- package/dist/assets/Recordings-C5GO3GeS.js +0 -1
- package/dist/assets/circle-check-big-BUonJKZG.js +0 -1
- package/dist/assets/clock-CDpOjQuj.js +0 -1
- package/dist/assets/dist-BINwBvR-.js +0 -7
- package/dist/assets/index-B2Lt4mEF.css +0 -2
- package/dist/assets/index-DcoBSPD8.js +0 -4
- package/dist/assets/plus-zsIhHGHK.js +0 -1
- package/dist/assets/remoteEntry-CqqHuqZU.js +0 -1
- package/dist/assets/rotate-cw-RF_Q6dlG.js +0 -1
- package/dist/assets/search-BU0QQbas.js +0 -1
- package/dist/assets/square-CCYHDGJh.js +0 -1
- package/dist/assets/src-D49drDQI.js +0 -67
- package/dist/assets/src-PXZvyYDe.js +0 -7
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Co as e,Do as t,Eo as n,S as r,So as i,To as a,Ua as o,_o as s,bo as c,go as l,wo as u,xo as d,yo as f}from"./src-D49drDQI.js";import{Q as p,S as m,W as h,a as g,b as _,q as v,t as y,x as b}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{E as x}from"./src-PXZvyYDe.js";import{p as S}from"./player-overlays-5vIS4o_W.js";import{t as C}from"./circle-check-big-BUonJKZG.js";import{t as w}from"./copy-BBaHyGT3.js";import{t as T}from"./pencil-C3NxLuzk.js";import{t as E}from"./plus-zsIhHGHK.js";import{t as D}from"./refresh-cw-DXzAUpGT.js";import{t as O}from"./search-BU0QQbas.js";import{t as k}from"./send-DUT5ZyQM.js";import{N as A,S as j,V as M,W as N,i as ee,s as P}from"./index-DcoBSPD8.js";import{t as F}from"./AdminPage-Dq33XE9j.js";import{t as te}from"./AdminTabs-6yXsZXxy.js";var I=N(`bell-ring`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]),ne=N(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),L=N(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]);p();var R=e=>typeof e==`string`&&e.length>0;function re(e){return{levels:e.levels,formats:e.format,bodyMaxLen:e.bodyMaxLen,attachmentSlots:e.attachments.mediaTypes,attachmentMode:e.attachments.mode,attachmentMax:e.attachments.max,attachmentMaxBytes:e.attachments.maxBytes,maxActions:e.actions,showActions:e.actions>0,showClickUrl:e.clickUrl,showSound:e.sound,showTtl:e.ttl,showTag:!0}}function ie(e,t){return e.format.includes(t)?t:e.format[0]??`text`}function ae(e,t){let n=[];for(let r of e.attachments.mediaTypes){if(n.length>=e.attachments.max)break;let i=t[r];R(i)&&n.push({mediaType:r,url:i})}return n}function oe(e,t){if(e.actions<=0)return[];let n=[];for(let r of t){if(n.length>=e.actions)break;let t=R(r.label),i=R(r.url);!t&&!i||n.push({id:`test-${n.length+1}`,label:t?r.label:`Action ${n.length+1}`,...i?{url:r.url}:{}})}return n}function z(e,t){let n=e.levels.some(e=>e.id===t.level)?t.level:void 0,r=ae(e,t.attachmentUrls),i=oe(e,t.actions),a=e.ttl&&R(t.ttl)?Number(t.ttl):void 0;return{body:t.body,format:ie(e,t.format),priority:se(t.priority),...R(t.title)?{title:t.title}:{},...n?{level:n}:{},...r.length>0?{attachments:r}:{},...i.length>0?{actions:i}:{},...e.clickUrl&&R(t.clickUrl)?{clickUrl:t.clickUrl}:{},...e.sound&&R(t.sound)?{sound:t.sound}:{},...a!==void 0&&Number.isFinite(a)?{ttl:a}:{},...R(t.tag)?{tag:t.tag}:{}}}function se(e){return Number.isFinite(e)?Math.min(5,Math.max(1,Math.round(e))):3}function ce(e){return e.levels.find(e=>e.flags?.critical===!0)||e.levels.filter(e=>typeof e.ordinal==`number`).sort((e,t)=>t.ordinal-e.ordinal)[0]}function B(e){return{level:``,priority:3,format:e.format[0]??`text`,title:``,body:``,attachmentUrls:{},actions:[],clickUrl:``,sound:``,ttl:``,tag:``}}var le={image:`https://example.com/sample.jpg`,video:`https://example.com/sample.mp4`,gif:`https://example.com/sample.gif`,audio:`https://example.com/sample.mp3`,icon:`https://example.com/icon.png`};function ue(e,t){let n=B(e);switch(t){case`minimal`:return{...n,body:`Test notification`};case`overflow`:return{...n,body:`X`.repeat(e.bodyMaxLen+50)};case`critical`:{let t=ce(e);return{...n,body:`Critical test notification`,priority:5,level:t?.id??``}}case`everything`:{let t={},n=0;for(let r of e.attachments.mediaTypes){if(n>=e.attachments.max)break;t[r]=le[r],n+=1}let r=Array.from({length:e.actions},(e,t)=>({label:`Action ${t+1}`,url:`https://example.com/action/${t+1}`}));return{level:``,priority:4,format:e.format.includes(`markdown`)?`markdown`:e.format.includes(`html`)?`html`:e.format[0]??`text`,title:`Everything the kind supports`,body:`This sample fills every control the kind advertises.`,attachmentUrls:t,actions:r,clickUrl:e.clickUrl?`https://example.com/open`:``,sound:e.sound?`default`:``,ttl:e.ttl?`3600`:``,tag:`camstack-test`}}}}var de=[{id:`minimal`,label:`Minimal (body only)`},{id:`everything`,label:`Everything supported`},{id:`overflow`,label:`Overflow`},{id:`critical`,label:`Critical`}],V=`w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none`,H=`block text-[11px] font-medium text-foreground mb-1`;function fe({target:e,kind:r,open:i,onClose:a}){let o=S(),u=h(()=>re(r.caps),[r.caps]),[p,g]=v(()=>B(r.caps)),[_,x]=v(null),C=h(()=>z(r.caps,p),[r.caps,p]),w=p.body.length,T=w>u.bodyMaxLen,E=e=>g(t=>({...t,...e})),D=y({mutationFn:()=>o.trpcClient.notificationOutput.testTarget.mutate({addonId:e.addonId,targetId:e.id,sample:z(r.caps,p)}),onMutate:()=>x(null),onSuccess:e=>x(e),onError:e=>x({success:!1,error:e instanceof Error?e.message:`Test failed`})}),O=e=>{g(ue(r.caps,e)),x(null)},A=(e,t,n)=>{let r=p.actions.length>0?[...p.actions]:[];for(;r.length<=e;)r.push({label:``,url:``});r[e]={...r[e],[t]:n},E({actions:r})};return b(l,{open:i,onOpenChange:e=>!e&&a(),children:m(s,{width:`lg`,className:`!max-w-2xl`,children:[b(c,{children:m(d,{children:[`Test "`,e.name,`" (`,r.label,`)`]})}),m(`div`,{className:`space-y-4 max-h-[60vh] overflow-y-auto pr-1`,children:[b(`div`,{className:`flex flex-wrap gap-1.5`,children:de.map(e=>b(t,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>O(e.id),children:e.label},e.id))}),m(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[u.levels.length>0&&m(`div`,{children:[b(`label`,{className:H,children:`Level`}),m(`select`,{className:V,value:p.level,onChange:e=>E({level:e.target.value}),children:[b(`option`,{value:``,children:`— derive from priority —`}),u.levels.map(e=>m(`option`,{value:e.id,children:[e.label,e.ordinal===null?` (qualitative)`:` (p${e.ordinal})`]},e.id))]}),(()=>{let e=u.levels.find(e=>e.id===p.level);return e?m(`div`,{className:`mt-1 space-y-1`,children:[e.description&&b(`p`,{className:`text-[10px] text-foreground-subtle`,children:e.description}),m(`div`,{className:`flex flex-wrap gap-1`,children:[e.flags?.critical&&b(n,{variant:`danger`,"data-testid":`flag-critical`,children:`critical`}),e.flags?.silent&&b(n,{variant:`info`,children:`silent`}),e.flags?.noPush&&b(n,{variant:`warning`,children:`no-push`})]}),e.requires&&e.requires.length>0&&m(`p`,{className:`text-[10px] text-warning`,children:[`Requires target config: `,e.requires.join(`, `)]})]}):null})()]}),m(`div`,{children:[m(`label`,{className:H,children:[`Priority (ordinal): `,p.priority]}),b(`input`,{type:`range`,min:1,max:5,step:1,value:p.priority,onChange:e=>E({priority:Number(e.target.value)}),className:`w-full accent-primary`,"aria-label":`priority`})]})]}),u.formats.length>0&&m(`div`,{children:[b(`label`,{className:H,children:`Format`}),b(`div`,{className:`flex flex-wrap gap-2`,children:u.formats.map(e=>m(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[b(`input`,{type:`radio`,name:`format`,className:`accent-primary`,checked:p.format===e,onChange:()=>E({format:e})}),e]},e))})]}),m(`div`,{children:[b(`label`,{className:H,children:`Title`}),b(`input`,{className:V,value:p.title,onChange:e=>E({title:e.target.value})})]}),m(`div`,{children:[m(`label`,{className:H,children:[`Body`,` `,m(`span`,{className:T?`text-danger`:`text-foreground-subtle`,children:[`(`,w,`/`,u.bodyMaxLen,T?` — overflow`:``,`)`]})]}),b(`textarea`,{className:`${V} min-h-[80px] resize-y`,value:p.body,onChange:e=>E({body:e.target.value})})]}),u.attachmentSlots.length>0&&m(`div`,{children:[m(`label`,{className:H,children:[`Attachments`,` `,m(`span`,{className:`text-foreground-subtle`,children:[`(mode: `,u.attachmentMode,`, max `,u.attachmentMax,u.attachmentMaxBytes?`, ≤${Math.round(u.attachmentMaxBytes/1024/1024)}MB`:``,`)`]})]}),b(`div`,{className:`space-y-1.5`,children:u.attachmentSlots.map(e=>m(`div`,{className:`flex items-center gap-2`,children:[b(`span`,{className:`text-[10px] w-12 shrink-0 text-foreground-subtle`,children:e}),b(`input`,{className:V,placeholder:`${e} URL`,value:p.attachmentUrls[e]??``,onChange:t=>E({attachmentUrls:{...p.attachmentUrls,[e]:t.target.value}})})]},e))})]}),u.showActions&&m(`div`,{children:[m(`label`,{className:H,children:[`Actions (up to `,u.maxActions,`)`]}),b(`div`,{className:`space-y-1.5`,children:Array.from({length:Math.min(u.maxActions,3)},(e,t)=>m(`div`,{className:`flex items-center gap-2`,children:[b(`input`,{className:V,placeholder:`label`,value:p.actions[t]?.label??``,onChange:e=>A(t,`label`,e.target.value)}),b(`input`,{className:V,placeholder:`url`,value:p.actions[t]?.url??``,onChange:e=>A(t,`url`,e.target.value)})]},t))})]}),m(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[u.showClickUrl&&m(`div`,{children:[b(`label`,{className:H,children:`Click URL`}),b(`input`,{className:V,value:p.clickUrl,onChange:e=>E({clickUrl:e.target.value})})]}),u.showSound&&m(`div`,{children:[b(`label`,{className:H,children:`Sound`}),b(`input`,{className:V,value:p.sound,onChange:e=>E({sound:e.target.value})})]}),u.showTtl&&m(`div`,{children:[b(`label`,{className:H,children:`TTL (seconds)`}),b(`input`,{className:V,type:`number`,value:p.ttl,onChange:e=>E({ttl:e.target.value})})]}),u.showTag&&m(`div`,{children:[b(`label`,{className:H,children:`Tag`}),b(`input`,{className:V,value:p.tag,onChange:e=>E({tag:e.target.value})})]})]}),_&&b(pe,{result:_}),m(`details`,{className:`text-[10px]`,children:[b(`summary`,{className:`cursor-pointer text-foreground-subtle`,children:`Payload preview`}),b(`pre`,{className:`mt-1 overflow-x-auto rounded bg-surface p-2 text-foreground-subtle`,children:JSON.stringify(C,null,2)})]})]}),m(f,{children:[b(t,{variant:`secondary`,size:`sm`,type:`button`,onClick:a,children:`Close`}),m(t,{size:`sm`,type:`button`,disabled:D.isPending||p.body.length===0,onClick:()=>D.mutate(),children:[D.isPending?b(j,{className:`h-3.5 w-3.5 animate-spin`}):b(k,{className:`h-3.5 w-3.5`}),`Send test`]})]})]})})}function pe({result:e}){let t=e.renderedAs;return m(`div`,{className:`rounded-md border px-3 py-2 text-xs ${e.success?`border-success/40 bg-success/10`:`border-danger/40 bg-danger/10`}`,"data-testid":`test-result`,children:[m(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.success?b(C,{className:`h-3.5 w-3.5 text-success`}):b(A,{className:`h-3.5 w-3.5 text-danger`}),b(`span`,{children:e.success?`Delivered`:`Failed`})]}),e.error&&b(`p`,{className:`mt-1 text-danger`,children:e.error}),t&&m(`dl`,{className:`mt-2 grid grid-cols-2 gap-x-3 gap-y-0.5 text-[11px] text-foreground-subtle`,children:[b(`dt`,{children:`Resolved level`}),b(`dd`,{className:`text-foreground`,children:t.level}),b(`dt`,{children:`Format sent`}),b(`dd`,{className:`text-foreground`,children:t.format}),b(`dt`,{children:`Attachments sent`}),b(`dd`,{className:`text-foreground`,children:t.attachmentsSent}),b(`dt`,{children:`Actions sent`}),b(`dd`,{className:`text-foreground`,children:t.actionsSent}),b(`dt`,{children:`Truncated`}),b(`dd`,{className:`text-foreground`,children:t.truncated?`yes`:`no`}),b(`dt`,{children:`Dropped`}),b(`dd`,{className:`text-foreground`,children:t.dropped.length>0?t.dropped.join(`, `):`—`})]})]})}function me(e){let t=[],n=new Map;for(let r of e){let e=n.get(r.addonId);e?e.push(r):(n.set(r.addonId,[r]),t.push(r.addonId))}return t.map(e=>({addonId:e,kinds:n.get(e)??[]}))}function he(e){let t=[],n=e=>{for(let r of e){if(r.type===`password`){t.push(r.key);continue}if(r.type===`group`){n(r.fields);continue}if(r.type===`sub-tabs`)for(let e of r.tabs)n(e.fields)}};for(let t of e.sections)n(t.fields);return t}function ge(e,t,n){let r=new Set(n),i={};for(let[n,a]of Object.entries(e)){if(!r.has(n)){i[n]=a;continue}a==null||a===``||a!==t[n]&&(i[n]=a)}return i}function _e(e,t){let n=new Set(t),r={};for(let[t,i]of Object.entries(e))r[t]=n.has(t)?``:i;return r}p();var ve=[`notificationOutput`,`listTargets`],ye=[`notificationOutput`,`listTargetKinds`];function U({kind:e,imgClassName:t,fallbackClassName:n}){return e?.iconUrl?b(`img`,{src:e.iconUrl,alt:e.label,className:t,loading:`lazy`,draggable:!1}):b(`span`,{className:n,children:e?.icon??`🔔`})}function be(){let e=S(),[r,s]=v({mode:`closed`}),[c,l]=v(null),u=g({queryKey:ve,queryFn:()=>e.trpcClient.notificationOutput.listTargets.query({})}),d=g({queryKey:ye,queryFn:async()=>(await e.trpcClient.notificationOutput.listTargetKinds.query({})).map(e=>{let t=e.iconUrl;return{...e,configSchema:e.configSchema,iconUrl:t}})}),f=h(()=>d.data??[],[d.data]),p=h(()=>{let e=new Map;for(let t of f)e.set(t.kind,t);return e},[f]),_=y({mutationFn:t=>e.trpcClient.notificationOutput.setTargetEnabled.mutate({addonId:t.target.addonId,targetId:t.target.id,enabled:t.enabled}),onSuccess:()=>void u.refetch()}),x=y({mutationFn:t=>e.trpcClient.notificationOutput.deleteTarget.mutate({addonId:t.addonId,targetId:t.id}),onSuccess:()=>void u.refetch()}),C=c?p.get(c.kind):void 0;return m(F,{icon:M,title:`Notification Targets`,subtitle:`Deliver notifications to ntfy, Pushover, Telegram, Home Assistant and more. Each target's kind declares its capabilities; the test panel shows exactly what a message degrades to.`,actions:m(t,{size:`sm`,type:`button`,onClick:()=>s({mode:`pick-kind`}),children:[b(E,{className:`h-3.5 w-3.5`}),`Add target`]}),children:[u.isLoading&&b(`div`,{className:`flex items-center justify-center py-16`,children:b(j,{className:`h-6 w-6 animate-spin text-primary`})}),u.isError&&!u.isLoading&&b(o,{title:`Failed to load targets`,message:u.error instanceof Error?u.error.message:`Unknown error`,onRetry:()=>void u.refetch()}),!u.isLoading&&!u.isError&&(u.data??[]).length===0&&b(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:`No notification targets yet. Click "Add target" to configure one.`}),(u.data??[]).length>0&&b(a,{children:b(`ul`,{className:`divide-y divide-border`,children:(u.data??[]).map(e=>{let r=p.get(e.kind);return m(`li`,{className:`flex items-center gap-3 px-4 py-2.5`,children:[b(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface text-xs`,title:r?.label??e.kind,children:b(U,{kind:r,imgClassName:`h-5 w-5 object-contain`,fallbackClassName:``})}),m(`div`,{className:`min-w-0 flex-1`,children:[b(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),b(`div`,{className:`text-[11px] text-foreground-subtle`,children:r?.label??e.kind})]}),!e.enabled&&b(n,{variant:`warning`,children:`disabled`}),b(i,{checked:e.enabled,onCheckedChange:t=>_.mutate({target:e,enabled:t}),"aria-label":`toggle ${e.name}`}),b(t,{size:`sm`,variant:`ghost`,type:`button`,disabled:!r,onClick:()=>l(e),title:`Test`,children:b(k,{className:`h-3.5 w-3.5`})}),b(t,{size:`sm`,variant:`ghost`,type:`button`,disabled:!r,onClick:()=>r&&s({mode:`form`,kind:r,target:e}),title:`Edit`,children:b(T,{className:`h-3.5 w-3.5`})}),b(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>x.mutate(e),title:`Delete`,children:b(P,{className:`h-3.5 w-3.5 text-danger`})})]},e.id)})})}),r.mode===`pick-kind`&&b(xe,{kinds:f,onCancel:()=>s({mode:`closed`}),onPick:e=>s({mode:`form`,kind:e,target:null})}),r.mode===`form`&&b(Se,{kind:r.kind,target:r.target,onCancel:()=>s({mode:`closed`}),onSaved:()=>{s({mode:`closed`}),u.refetch()}}),c&&C&&b(fe,{target:c,kind:C,open:!0,onClose:()=>l(null)})]})}function xe({kinds:e,onPick:r,onCancel:i}){let o=h(()=>me(e),[e]);return m(a,{className:`p-4 space-y-4`,children:[m(`div`,{className:`flex items-center justify-between`,children:[b(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Choose a notification kind`}),b(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:i,children:`Cancel`})]}),o.length===0&&b(`p`,{className:`text-xs text-foreground-subtle`,children:`No notification providers are installed. Install the notifiers addon (or connect Home Assistant) to add targets.`}),o.map(e=>m(`div`,{children:[b(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1.5`,children:e.addonId}),b(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-2`,children:e.kinds.map(t=>m(`button`,{type:`button`,onClick:()=>r(t),className:`flex flex-col items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-3 text-xs hover:border-primary/50 hover:bg-surface-hover transition-colors`,children:[b(U,{kind:t,imgClassName:`h-7 w-7 object-contain`,fallbackClassName:`text-lg leading-7`}),b(`span`,{className:`font-medium text-foreground`,children:t.label}),t.supportsDiscovery&&b(n,{variant:`info`,style:`outline`,children:`discover`})]},`${e.addonId}:${t.kind}`))})]},e.addonId))]})}function Se({kind:e,target:n,onSaved:i,onCancel:o}){let s=S(),c=h(()=>he(e.configSchema),[e.configSchema]),l=h(()=>n?.config??{},[n]),[u,d]=v(n?.name??e.label),[f,p]=v(()=>n?_e(n.config,c):{}),[g,_]=v(null),[x,C]=v(null),w=y({mutationFn:()=>s.trpcClient.notificationOutput.discoverTargets.query({addonId:e.addonId,kind:e.kind,config:f}),onSuccess:e=>_(e),onError:e=>C(e instanceof Error?e.message:`Discovery failed`)}),T=y({mutationFn:()=>{let t=ge(f,l,c),r={id:n?.id??`${e.kind}-${Date.now()}`,name:u,kind:e.kind,addonId:e.addonId,enabled:n?.enabled??!0,config:t};return s.trpcClient.notificationOutput.upsertTarget.mutate({addonId:e.addonId,target:r})},onSuccess:i,onError:e=>C(e instanceof Error?e.message:`Save failed`)}),E=e=>{d(e.suggestedName),p(t=>({...t,...e.config})),_(null)};return m(a,{className:`p-4 space-y-4`,children:[m(`div`,{className:`flex items-center justify-between`,children:[m(`h3`,{className:`text-sm font-semibold text-foreground flex items-center gap-2`,children:[b(U,{kind:e,imgClassName:`h-5 w-5 object-contain`,fallbackClassName:`text-lg`}),n?`Edit ${n.name}`:`Add ${e.label} target`]}),b(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:o,children:`Cancel`})]}),x&&b(`div`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:x}),m(`div`,{children:[b(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Name`}),b(`input`,{className:`w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none`,value:u,onChange:e=>d(e.target.value)})]}),e.supportsDiscovery&&m(`div`,{className:`space-y-2`,children:[m(t,{size:`sm`,variant:`outline`,type:`button`,disabled:w.isPending,onClick:()=>{C(null),w.mutate()},children:[w.isPending?b(j,{className:`h-3.5 w-3.5 animate-spin`}):b(O,{className:`h-3.5 w-3.5`}),`Discover`]}),g&&g.length===0&&b(`p`,{className:`text-[11px] text-foreground-subtle`,children:`No candidates discovered.`}),g&&g.length>0&&b(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:g.map((e,t)=>m(`button`,{type:`button`,onClick:()=>E(e),className:`flex w-full items-center justify-between px-3 py-1.5 text-xs hover:bg-surface-hover`,children:[b(`span`,{className:`text-foreground`,children:e.suggestedName}),b(`span`,{className:`text-[10px] text-primary`,children:`use`})]},`${e.suggestedName}-${t}`))})]}),c.length>0&&n&&b(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Secret fields are hidden. Leave them blank to keep the stored value; type a new value to replace it.`}),b(r,{schema:e.configSchema,values:f,onChange:p}),m(`div`,{className:`flex justify-end gap-2`,children:[b(t,{variant:`secondary`,size:`sm`,type:`button`,onClick:o,children:`Cancel`}),m(t,{size:`sm`,type:`button`,disabled:T.isPending||u.trim().length===0,onClick:()=>{C(null),T.mutate()},children:[T.isPending&&b(j,{className:`h-3.5 w-3.5 animate-spin`}),n?`Save changes`:`Create target`]})]})]})}var W=[{value:`immediate`,label:`Immediate`,hint:`Fires on the first matching detection of a track (lowest latency).`},{value:`track-end`,label:`Track end`,hint:`Evaluates the finalised track record when it closes.`},{value:`device-event`,label:`Device event`,hint:`Doorbell press / sensor state change on a linked device.`},{value:`package-event`,label:`Package event`,hint:`A parcel delivery or pick-up.`}];function Ce(e){return W.find(t=>t.value===e)?.label??e}function we(e){return W.find(t=>t.value===e)?.value}var G=[{value:`best`,label:`Best available image`,description:`The best subject crop available when the notification is sent.`},{value:`best-matching`,label:`Best matching image`,description:`The image that explains why the rule fired — the face crop for an identity rule, the plate crop for a plate rule; falls back to the best image otherwise.`},{value:`keyFrame`,label:`Key frame`,description:`The clean full scene frame with no subject box.`},{value:`none`,label:`No attachment`,description:`Send the notification with no image.`}];function Te(e){return G.find(t=>t.value===e)?.value}var Ee=[{value:`any`,label:`Any source`},{value:`pipeline`,label:`Pipeline`},{value:`onboard`,label:`Onboard (camera)`},{value:`sensor`,label:`Sensor`}],K=[{value:`delivered`,label:`Delivered`},{value:`picked-up`,label:`Picked up`},{value:`both`,label:`Both`}],De=[{value:`any`,label:`Any of`},{value:`all`,label:`All of`}],Oe=[{value:1,label:`1 — Min`},{value:2,label:`2 — Low`},{value:3,label:`3 — Default`},{value:4,label:`4 — High`},{value:5,label:`5 — Max`}];function ke(){return{name:``,enabled:!0,delivery:`immediate`,targetIds:[],targetParams:{},priority:3,mediaAttach:`best`,templateTitle:``,templateBody:``,conditions:{},schedule:void 0}}function Ae(e){let t={};for(let n of e.targets)n.params&&Object.keys(n.params).length>0&&(t[n.targetId]=n.params);return{name:e.name,enabled:e.enabled,delivery:e.delivery,targetIds:e.targets.map(e=>e.targetId),targetParams:t,priority:e.priority,mediaAttach:e.media.attach,templateTitle:e.template?.title??``,templateBody:e.template?.body??``,conditions:e.conditions,schedule:e.schedule}}function q(e){return e.name.trim().length>0&&e.targetIds.length>0}function J(e,t){return e.appliesTo.includes(t)}function je(e){if(e==null)return!0;if(Array.isArray(e))return e.length===0;if(typeof e==`string`)return e.length===0||e===`any`;if(typeof e==`number`)return!Number.isFinite(e);if(typeof e==`object`){if(`ids`in e){let t=e.ids;return!Array.isArray(t)||t.length===0}if(`values`in e){let t=e.values;return!Array.isArray(t)||t.length===0}return!1}return!1}function Me(e,t,n){let r=n.length===0?null:new Set(n.filter(e=>e.id!==`schedule`&&J(e,t)).map(e=>e.id)),i={};for(let[t,n]of Object.entries(e))r!==null&&!r.has(t)||je(n)||(i[t]=n);return i}function Ne(e){return e!==void 0&&e.windows.length>0}function Y(e,t,n=[]){let r=e.templateTitle.trim(),i=e.templateBody.trim(),a=r.length>0||i.length>0?{...r.length>0?{title:r}:{},...i.length>0?{body:i}:{}}:void 0,o=(n.length===0||n.some(t=>t.id===`schedule`&&J(t,e.delivery)))&&Ne(e.schedule)?e.schedule:void 0;return{name:e.name.trim(),enabled:e.enabled,delivery:e.delivery,conditions:Me(e.conditions,e.delivery,n),...o?{schedule:o}:{},targets:e.targetIds.map(t=>{let n=e.targetParams[t];return n&&Object.keys(n).length>0?{targetId:t,params:n}:{targetId:t}}),media:{attach:e.mediaAttach},throttle:t?.throttle??{cooldownSec:60,scope:`rule-device`},priority:e.priority,...a?{template:a}:{}}}p();var Pe=[{id:`scope`,label:`Scope`},{id:`class`,label:`Classes`},{id:`zones`,label:`Zones`},{id:`quality`,label:`Quality`},{id:`label`,label:`Identity & plates`},{id:`device`,label:`Device event`},{id:`package`,label:`Package`},{id:`schedule`,label:`Schedule`}],Fe=`block text-[11px] font-medium text-foreground`,X=`text-[10px] text-foreground-subtle mt-0.5`;function Ie({catalog:e,delivery:t,conditions:r,schedule:i,cameras:a,onConditionsChange:o,onScheduleChange:s}){let c=(e,t)=>{let n={...r};t===void 0?delete n[e]:n[e]=t,o(n)};return b(`div`,{className:`space-y-4`,children:Pe.map(t=>({...t,descriptors:e.filter(e=>e.group===t.id)})).filter(e=>e.descriptors.length>0).map(e=>m(`div`,{className:`space-y-2.5`,children:[b(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:e.label}),e.descriptors.map(e=>{let o=J(e,t);return m(`div`,{className:o?``:`opacity-50`,"data-testid":`condition-${e.id}`,children:[m(`div`,{className:`flex items-center justify-between gap-2`,children:[b(`label`,{className:Fe,children:e.label}),!o&&m(n,{variant:`default`,children:[`not for `,e.appliesTo.join(` / `)]})]}),o?b(Le,{descriptor:e,conditions:r,schedule:i,cameras:a,onFieldChange:c,onScheduleChange:s}):b(`p`,{className:X,children:`Not evaluated for the selected trigger — switch the trigger to use it.`}),o&&e.description&&b(`p`,{className:X,children:e.description})]},e.id)})]},e.id))})}function Le({descriptor:t,conditions:n,schedule:r,cameras:i,onFieldChange:a,onScheduleChange:o}){switch(t.valueType){case`deviceIdList`:return b(Ke,{cameras:i,value:n.devices??[],onChange:e=>a(`devices`,e.length>0?e:void 0)});case`stringList`:{if(!ze(t.id))return null;let e=t.id;return b(Z,{value:He(n,e),placeholder:`Add value…`,onChange:t=>a(e,t.length>0?t:void 0)})}case`zoneIdList`:return b(Z,{value:n.zonesExclude??[],placeholder:`Zone id…`,onChange:e=>a(`zonesExclude`,e.length>0?e:void 0)});case`number01`:{if(!Ve(t.id))return null;let e=t.id;return b(Q,{value:Ue(n,e),min:0,max:1,step:.05,onChange:t=>a(e,t)})}case`number`:return b(Q,{value:n.minDwellSeconds,min:0,step:1,onChange:e=>a(`minDwellSeconds`,e)});case`sourceSelect`:return b(e,{value:n.source??`any`,options:Ee.map(e=>({value:e.value,label:e.label})),onChange:e=>a(`source`,We(e.target.value))});case`packagePhase`:return b(e,{value:n.packagePhase??``,options:[{value:``,label:`— any phase —`},...K.map(e=>({value:e.value,label:e.label}))],onChange:e=>a(`packagePhase`,Ge(e.target.value))});case`zoneSelection`:return b(qe,{value:n.zones,onChange:e=>a(`zones`,e)});case`plateMatcher`:return b(Je,{value:n.plates,onChange:e=>a(`plates`,e)});case`schedule`:return b(Qe,{value:r,onChange:o});default:return null}}var Re={classes:!0,classesExclude:!0,labelEquals:!0,identities:!0,identitiesExclude:!0,zonesExclude:!0,eventTypeTokens:!0,sensorKinds:!0};function ze(e){return Object.prototype.hasOwnProperty.call(Re,e)}var Be={minConfidence:!0,minImportance:!0,minLabelConfidence:!0};function Ve(e){return Object.prototype.hasOwnProperty.call(Be,e)}function He(e,t){let n=e[t];return Array.isArray(n)?n:[]}function Ue(e,t){let n=e[t];return typeof n==`number`?n:void 0}function We(e){if(e===`pipeline`||e===`onboard`||e===`sensor`||e===`any`)return e}function Ge(e){return K.find(t=>t.value===e)?.value}function Ke({cameras:e,value:t,onChange:n}){if(e.length===0)return b(`p`,{className:X,children:`No cameras available — the rule applies to all devices.`});let r=e=>n(t.includes(e)?t.filter(t=>t!==e):[...t,e]);return b(`div`,{className:`mt-1 max-h-40 overflow-y-auto rounded-md border border-border divide-y divide-border`,children:e.map(e=>m(`label`,{className:`flex items-center gap-2.5 px-3 py-1.5 text-xs text-foreground cursor-pointer hover:bg-surface-hover`,children:[b(`input`,{type:`checkbox`,checked:t.includes(e.id),onChange:()=>r(e.id),className:`accent-primary`}),b(`span`,{className:`flex-1 truncate`,children:e.name})]},e.id))})}function Z({value:e,placeholder:t,onChange:n}){let[r,i]=v(``),a=()=>{let t=r.trim();if(t.length===0||e.includes(t)){i(``);return}n([...e,t]),i(``)},o=t=>n(e.filter(e=>e!==t));return m(`div`,{className:`mt-1 space-y-1.5`,children:[e.length>0&&b(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>m(`span`,{className:`inline-flex items-center gap-1 rounded bg-surface-hover px-1.5 py-0.5 text-[11px] text-foreground`,children:[e,b(`button`,{type:`button`,onClick:()=>o(e),"aria-label":`remove ${e}`,className:`text-foreground-subtle hover:text-danger`,children:b(ee,{className:`h-3 w-3`})})]},e))}),b(u,{value:r,placeholder:t,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),a())},onBlur:a})]})}function Q({value:e,min:t,max:n,step:r,onChange:i}){return m(`div`,{className:`mt-1 flex items-center gap-2`,children:[b(u,{type:`number`,value:e??``,min:t,max:n,step:r,className:`max-w-[8rem]`,onChange:e=>{let t=e.target.value;if(t===``){i(void 0);return}let n=Number(t);i(Number.isFinite(n)?n:void 0)}}),e!==void 0&&n!==void 0&&b(`input`,{type:`range`,min:t,max:n,step:r,value:e,onChange:e=>i(Number(e.target.value)),className:`flex-1 accent-primary`,"aria-label":`value`})]})}function qe({value:t,onChange:n}){let r=t?.ids??[],i=t?.match??`any`,a=e=>n(e.length>0?{ids:e,match:i}:void 0),o=e=>n(r.length>0?{ids:r,match:e}:void 0);return m(`div`,{className:`mt-1 space-y-1.5`,children:[b(`div`,{className:`max-w-[10rem]`,children:b(e,{value:i,options:De.map(e=>({value:e.value,label:e.label})),onChange:e=>o(e.target.value===`all`?`all`:`any`)})}),b(Z,{value:r,placeholder:`Zone id…`,onChange:a})]})}function Je({value:e,onChange:t}){let n=e?.values??[],r=e?.maxDistance??1,i=e=>t(e.length>0?{values:e,maxDistance:r}:void 0),a=e=>t(n.length>0?{values:n,maxDistance:e}:void 0);return m(`div`,{className:`mt-1 space-y-1.5`,children:[b(Z,{value:n,placeholder:`Plate text…`,onChange:i}),m(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Max distance`,b(u,{type:`number`,min:0,max:3,step:1,value:r,className:`max-w-[5rem]`,onChange:e=>{let t=Number(e.target.value);a(Number.isFinite(t)?Math.max(0,Math.min(3,t)):1)}})]})]})}var Ye=[{value:1,label:`Mon`},{value:2,label:`Tue`},{value:3,label:`Wed`},{value:4,label:`Thu`},{value:5,label:`Fri`},{value:6,label:`Sat`},{value:0,label:`Sun`}];function $(e){let t=Math.floor(e/60),n=e%60;return`${String(t).padStart(2,`0`)}:${String(n).padStart(2,`0`)}`}function Xe(e){let[t,n]=e.split(`:`),r=Number(t)*60+Number(n);return Number.isFinite(r)?Math.max(0,Math.min(1439,r)):0}function Ze(){return{days:[1,2,3,4,5],startMinute:540,endMinute:1080}}function Qe({value:e,onChange:t}){let n=e?.windows??[],r=e?.invert??!1,i=(n,r)=>{if(n.length===0){t(void 0);return}t({windows:n,...r?{invert:!0}:{},...e?.timezone?{timezone:e.timezone}:{}})},a=()=>i([...n,Ze()],r),o=e=>i(n.filter((t,n)=>n!==e),r),s=(e,t)=>i(n.map((n,r)=>r===e?t:n),r);return m(`div`,{className:`mt-1 space-y-2`,children:[n.length===0?b(`p`,{className:X,children:`Always active — add a window to restrict when the rule fires.`}):n.map((e,t)=>b($e,{window:e,onChange:e=>s(t,e),onRemove:()=>o(t)},t)),m(`div`,{className:`flex items-center gap-3`,children:[m(`button`,{type:`button`,onClick:a,className:`flex items-center gap-1 rounded-md bg-surface-hover px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground`,children:[b(E,{className:`h-3 w-3`}),` Add window`]}),n.length>0&&m(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[b(`input`,{type:`checkbox`,checked:r,onChange:e=>i([...n],e.target.checked),className:`accent-primary`}),`Active outside the windows`]})]})]})}function $e({window:e,onChange:t,onRemove:n}){let r=n=>{let r=e.days.includes(n)?e.days.filter(e=>e!==n):[...e.days,n];r.length!==0&&t({...e,days:r})};return m(`div`,{className:`space-y-1.5 rounded-md border border-border p-2`,children:[m(`div`,{className:`flex items-center gap-2 text-xs`,children:[b(`input`,{type:`time`,value:$(e.startMinute),onChange:n=>t({...e,startMinute:Xe(n.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),b(`span`,{className:`text-foreground-subtle`,children:`→`}),b(`input`,{type:`time`,value:$(e.endMinute),onChange:n=>t({...e,endMinute:Xe(n.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),b(`span`,{className:`flex-1`}),b(`button`,{type:`button`,onClick:n,"aria-label":`Remove window`,className:`text-foreground-subtle hover:text-danger`,children:b(P,{className:`h-3.5 w-3.5`})})]}),b(`div`,{className:`flex flex-wrap gap-1`,children:Ye.map(t=>b(`button`,{type:`button`,onClick:()=>r(t.value),className:`rounded px-1.5 py-0.5 text-[10px] ${e.days.includes(t.value)?`bg-primary text-primary-foreground`:`bg-surface-hover text-foreground-subtle`}`,children:t.label},t.value))})]})}p();var et=[`notificationRules`,`listRules`],tt=[`notificationOutput`,`listTargets`,`forRules`],nt=[`notificationRules`,`getConditionCatalog`],rt=[`deviceManager`,`listAll`,`forRules`];function it(){let e=S(),[r,s]=v({mode:`closed`}),[c,l]=v(null),u=g({queryKey:et,queryFn:async()=>(await e.trpcClient.notificationRules.listRules.query({})).rules}),d=g({queryKey:tt,queryFn:()=>e.trpcClient.notificationOutput.listTargets.query({})}),f=g({queryKey:nt,queryFn:async()=>(await e.trpcClient.notificationRules.getConditionCatalog.query({})).catalog}),p=g({queryKey:rt,queryFn:async()=>(await e.trpcClient.deviceManager.listAll.query({})).filter(e=>e.type===x.Camera).map(e=>({id:e.id,name:e.name}))}),_=h(()=>{let e=new Map;for(let t of d.data??[])e.set(t.id,t.name);return e},[d.data]),C=y({mutationFn:t=>e.trpcClient.notificationRules.setRuleEnabled.mutate(t),onSuccess:()=>void u.refetch()}),D=y({mutationFn:t=>e.trpcClient.notificationRules.deleteRule.mutate({ruleId:t}),onSuccess:()=>{l(null),u.refetch()}}),O=u.data??[];return m(F,{icon:I,title:`Notification Rules`,subtitle:`Author rules that turn detections, doorbell presses and package events into notifications. Each rule picks a trigger, matches conditions and fans out to one or more delivery targets.`,actions:m(t,{size:`sm`,type:`button`,onClick:()=>s({mode:`form`,rule:null}),children:[b(E,{className:`h-3.5 w-3.5`}),`New rule`]}),children:[u.isLoading&&b(`div`,{className:`flex items-center justify-center py-16`,children:b(j,{className:`h-6 w-6 animate-spin text-primary`})}),u.isError&&!u.isLoading&&b(o,{title:`Failed to load rules`,message:u.error instanceof Error?u.error.message:`Unknown error`,onRetry:()=>void u.refetch()}),!u.isLoading&&!u.isError&&O.length===0&&b(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:`No notification rules yet. Click "New rule" to author one.`}),O.length>0&&b(a,{children:b(`ul`,{className:`divide-y divide-border`,children:O.map(e=>{let r=e.targets.length,a=e.targets[0]?_.get(e.targets[0].targetId)??e.targets[0].targetId:null,o=c===e.id;return m(`li`,{className:`flex flex-wrap items-center gap-3 px-4 py-2.5`,children:[m(`div`,{className:`min-w-0 flex-1`,children:[b(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),m(`div`,{className:`text-[11px] text-foreground-subtle flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[b(`span`,{children:Ce(e.delivery)}),b(`span`,{"aria-hidden":!0,children:`·`}),m(`span`,{children:[r,` target`,r===1?``:`s`,a&&r===1?` (${a})`:``]}),b(`span`,{"aria-hidden":!0,children:`·`}),m(`span`,{children:[`priority `,e.priority]})]})]}),!e.enabled&&b(n,{variant:`warning`,children:`disabled`}),b(i,{checked:e.enabled,onCheckedChange:t=>C.mutate({ruleId:e.id,enabled:t}),"aria-label":`toggle ${e.name}`}),b(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>s({mode:`form`,rule:e}),title:`Edit`,children:b(T,{className:`h-3.5 w-3.5`})}),b(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>s({mode:`form`,rule:{...e,id:``,name:`${e.name} (copy)`}}),title:`Duplicate`,children:b(w,{className:`h-3.5 w-3.5`})}),o?m(`span`,{className:`flex items-center gap-1.5`,children:[m(t,{size:`sm`,variant:`danger`,type:`button`,disabled:D.isPending,onClick:()=>D.mutate(e.id),children:[D.isPending&&b(j,{className:`h-3.5 w-3.5 animate-spin`}),`Confirm`]}),b(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>l(null),children:`Cancel`})]}):b(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>l(e.id),title:`Delete`,children:b(P,{className:`h-3.5 w-3.5 text-danger`})})]},e.id)})})}),r.mode===`form`&&b(at,{rule:r.rule,targets:d.data??[],catalog:f.data??[],cameras:p.data??[],onCancel:()=>s({mode:`closed`}),onSaved:()=>{s({mode:`closed`}),u.refetch()}})]})}function at({rule:r,targets:a,catalog:o,cameras:c,onSaved:d,onCancel:f}){let p=S(),h=r!=null&&r.id.length>0,[g,_]=v(()=>r?Ae(r):ke()),[x,C]=v(null),[w,T]=v(null),E=e=>_(t=>({...t,...e})),D=h&&r?{throttle:r.throttle}:void 0,O=y({mutationFn:async()=>{let e=Y(g,D,o);h&&r?await p.trpcClient.notificationRules.updateRule.mutate({ruleId:r.id,patch:e}):await p.trpcClient.notificationRules.createRule.mutate({rule:e})},onSuccess:d,onError:e=>C(e instanceof Error?e.message:`Save failed`)}),k=y({mutationFn:async()=>{let e=Y(g,D,o);return(await p.trpcClient.notificationRules.testRule.mutate({rule:e,lookbackMinutes:60})).results},onMutate:()=>T(null),onSuccess:e=>T(e),onError:e=>C(e instanceof Error?e.message:`Test failed`)}),A=g.targetIds.map(e=>a.find(t=>t.id===e)?.name??e),M=e=>E({targetIds:g.targetIds.includes(e)?g.targetIds.filter(t=>t!==e):[...g.targetIds,e]}),N=W.find(e=>e.value===g.delivery)?.hint;return b(l,{open:!0,onOpenChange:e=>!e&&f(),children:m(s,{width:`lg`,placement:`sheet-on-mobile`,children:[m(`div`,{className:`flex items-center justify-between mb-3`,children:[m(`h3`,{className:`text-sm font-semibold text-foreground flex items-center gap-2`,children:[b(I,{className:`h-4 w-4 text-foreground-subtle`}),h?`Edit ${r?.name}`:`New notification rule`]}),b(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:f,children:`Cancel`})]}),x&&b(`div`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger mb-3`,children:x}),m(`div`,{className:`space-y-4`,children:[m(`div`,{className:`flex items-end gap-3`,children:[m(`div`,{className:`min-w-0 flex-1`,children:[b(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Name`}),b(u,{value:g.name,onChange:e=>E({name:e.target.value}),placeholder:`e.g. Front door package`})]}),m(`label`,{className:`flex items-center gap-2 pb-1.5 text-[11px] font-medium text-foreground`,children:[b(i,{checked:g.enabled,onCheckedChange:e=>E({enabled:e}),"aria-label":`enabled`}),`Enabled`]})]}),m(`div`,{children:[b(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Trigger`}),b(e,{value:g.delivery,onChange:e=>{let t=we(e.target.value);t&&E({delivery:t})},options:W.map(e=>({value:e.value,label:e.label}))}),N&&b(`p`,{className:`text-[10px] text-foreground-subtle mt-1`,children:N})]}),m(`div`,{children:[b(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Delivery targets`}),a.length===0?b(`p`,{className:`text-[11px] text-foreground-subtle`,children:`No delivery targets configured. Add one under the Targets tab first.`}):b(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:a.map(e=>m(`label`,{className:`flex items-center gap-2.5 px-3 py-1.5 text-xs text-foreground cursor-pointer hover:bg-surface-hover`,children:[b(`input`,{type:`checkbox`,checked:g.targetIds.includes(e.id),onChange:()=>M(e.id),className:`accent-primary`}),b(`span`,{className:`flex-1 truncate`,children:e.name}),!e.enabled&&b(n,{variant:`warning`,children:`disabled`})]},e.id))})]}),m(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[m(`div`,{children:[b(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Priority`}),b(e,{value:String(g.priority),onChange:e=>E({priority:Number(e.target.value)}),options:Oe.map(e=>({value:String(e.value),label:e.label}))})]}),m(`div`,{children:[b(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Media attachment`}),b(e,{value:g.mediaAttach,onChange:e=>{let t=Te(e.target.value);t&&E({mediaAttach:t})},options:G.map(e=>({value:e.value,label:e.label}))}),b(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:G.find(e=>e.value===g.mediaAttach)?.description})]})]}),m(`div`,{className:`space-y-2`,children:[m(`div`,{children:[b(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Notification title`}),b(u,{value:g.templateTitle,onChange:e=>E({templateTitle:e.target.value}),placeholder:`{{camera}} — {{class}}`})]}),m(`div`,{children:[b(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Notification body`}),b(`textarea`,{value:g.templateBody,onChange:e=>E({templateBody:e.target.value}),rows:2,placeholder:`{{label}} seen in {{zone}} at {{time}}`,className:`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`})]}),m(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Leave blank to use the backend default text. Supported variables include`,` `,b(`code`,{children:`{{camera}}`}),`, `,b(`code`,{children:`{{class}}`}),`, `,b(`code`,{children:`{{label}}`}),`,`,` `,b(`code`,{children:`{{zone}}`}),`, `,b(`code`,{children:`{{confidence}}`}),`, `,b(`code`,{children:`{{time}}`}),`.`]})]}),m(`div`,{className:`rounded-md border border-border px-3 py-3`,children:[b(`div`,{className:`mb-2 text-[11px] font-semibold text-foreground`,children:`Conditions`}),o.length===0?b(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Condition catalog unavailable — this rule matches on its trigger and targets alone.`}):b(Ie,{catalog:o,delivery:g.delivery,conditions:g.conditions,schedule:g.schedule,cameras:c,onConditionsChange:e=>E({conditions:e}),onScheduleChange:e=>E({schedule:e})})]}),m(`div`,{className:`rounded-md border border-border px-3 py-3`,children:[m(`div`,{className:`flex items-center justify-between gap-2`,children:[b(`div`,{className:`text-[11px] font-semibold text-foreground`,children:`Test rule`}),m(t,{size:`sm`,variant:`outline`,type:`button`,disabled:k.isPending||!q(g),onClick:()=>{C(null),k.mutate()},children:[k.isPending?b(j,{className:`h-3.5 w-3.5 animate-spin`}):b(ne,{className:`h-3.5 w-3.5`}),`Dry-run (last 60 min)`]})]}),b(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:`Evaluate the CURRENT (unsaved) rule against recently persisted records — no notification is sent.`}),w!==null&&b(ot,{delivery:g.delivery,results:w,targetNames:A})]})]}),m(`div`,{className:`flex justify-end gap-2 mt-4`,children:[b(t,{variant:`secondary`,size:`sm`,type:`button`,onClick:f,children:`Cancel`}),m(t,{size:`sm`,type:`button`,disabled:O.isPending||!q(g),onClick:()=>{C(null),O.mutate()},children:[O.isPending&&b(j,{className:`h-3.5 w-3.5 animate-spin`}),h?`Save changes`:`Create rule`]})]})]})})}function ot({delivery:e,results:t,targetNames:n}){if(e===`device-event`)return b(`p`,{className:`mt-2 text-[11px] text-foreground-subtle`,children:`Device-event rules cannot be dry-run: the sensor-event store has no cross-device scan surface, so a test returns no candidate records. The rule still fires live on a matching doorbell press / sensor change.`});if(t.length===0)return b(`p`,{className:`mt-2 text-[11px] text-foreground-subtle`,children:`No records in the last 60 minutes matched — nothing to evaluate.`});let r=t.filter(e=>e.wouldFire).length;return m(`div`,{className:`mt-2 space-y-1.5`,children:[m(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r,` of `,t.length,` evaluated record`,t.length===1?``:`s`,` would fire.`]}),b(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.slice(0,50).map(e=>m(`li`,{className:`flex items-center gap-2 px-2.5 py-1.5 text-[11px]`,children:[e.wouldFire?b(C,{className:`h-3.5 w-3.5 shrink-0 text-success`}):b(A,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),b(`span`,{className:`w-32 shrink-0 text-foreground-subtle`,children:new Date(e.timestamp).toLocaleString()}),m(`span`,{className:`w-14 shrink-0 text-foreground-subtle`,children:[`#`,e.deviceId]}),b(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.label??e.className??`object`}),e.wouldFire?m(`span`,{className:`shrink-0 truncate text-success`,children:[`→ `,n.join(`, `)||`targets`]}):e.failedCondition&&m(`span`,{className:`shrink-0 text-foreground-subtle`,children:[`failed: `,e.failedCondition]})]},e.recordId))})]})}p();var st=[{value:1,label:`Last hour`},{value:24,label:`Last 24 hours`},{value:168,label:`Last 7 days`},{value:0,label:`All time`}],ct=[{value:``,label:`Any status`},{value:`pending`,label:`Pending`},{value:`sent`,label:`Sent`},{value:`dead`,label:`Dead`}],lt=[50,100,250,500];function ut(){return{ruleId:``,deviceId:``,status:``,windowHours:24,limit:100}}function dt(e){return e===`pending`||e===`sent`||e===`dead`?e:void 0}function ft(e){switch(e){case`pending`:return`info`;case`sent`:return`success`;case`dead`:return`danger`}}function pt(){let t=S(),[n,r]=v(ut),i=e=>r(t=>({...t,...e})),o=g({queryKey:[`notificationRules`,`listRules`,`forHistory`],queryFn:async()=>(await t.trpcClient.notificationRules.listRules.query({})).rules}),s=g({queryKey:[`deviceManager`,`listAll`,`forHistory`],queryFn:async()=>(await t.trpcClient.deviceManager.listAll.query({})).filter(e=>e.type===x.Camera).map(e=>({id:e.id,name:e.name}))}),c=Date.now(),l=g({queryKey:[`notificationRules`,`getHistory`,n],retry:!1,queryFn:async()=>{let e=n.windowHours>0?c-n.windowHours*36e5:void 0;return(await t.trpcClient.notificationRules.getHistory.query({filter:{limit:n.limit,...n.ruleId?{ruleId:n.ruleId}:{},...n.deviceId?{deviceId:Number(n.deviceId)}:{},...dt(n.status)?{status:dt(n.status)}:{},...e===void 0?{}:{since:e}}})).entries}}),u=h(()=>{let e=new Map;for(let t of s.data??[])e.set(t.id,t.name);return e},[s.data]),d=e=>u.get(e)??`Camera #${String(e)}`,f=l.data??[],p=l.isError;return m(F,{icon:L,title:`Delivery history`,subtitle:`A searchable log of every notification the rules delivered (or failed to deliver).`,children:[m(`div`,{className:`mb-4 grid grid-cols-2 gap-2 sm:grid-cols-5`,children:[m(`div`,{children:[b(`label`,{className:`mb-1 block text-[10px] font-medium text-foreground-subtle`,children:`Rule`}),b(e,{value:n.ruleId,onChange:e=>i({ruleId:e.target.value}),options:[{value:``,label:`All rules`},...(o.data??[]).map(e=>({value:e.id,label:e.name}))]})]}),m(`div`,{children:[b(`label`,{className:`mb-1 block text-[10px] font-medium text-foreground-subtle`,children:`Camera`}),b(e,{value:n.deviceId,onChange:e=>i({deviceId:e.target.value}),options:[{value:``,label:`All cameras`},...(s.data??[]).map(e=>({value:String(e.id),label:e.name}))]})]}),m(`div`,{children:[b(`label`,{className:`mb-1 block text-[10px] font-medium text-foreground-subtle`,children:`Status`}),b(e,{value:n.status,onChange:e=>i({status:e.target.value}),options:ct.map(e=>({value:e.value,label:e.label}))})]}),m(`div`,{children:[b(`label`,{className:`mb-1 block text-[10px] font-medium text-foreground-subtle`,children:`Window`}),b(e,{value:String(n.windowHours),onChange:e=>i({windowHours:Number(e.target.value)}),options:st.map(e=>({value:String(e.value),label:e.label}))})]}),m(`div`,{children:[b(`label`,{className:`mb-1 block text-[10px] font-medium text-foreground-subtle`,children:`Limit`}),b(e,{value:String(n.limit),onChange:e=>i({limit:Number(e.target.value)}),options:lt.map(e=>({value:String(e),label:String(e)}))})]})]}),l.isLoading&&b(`div`,{className:`flex items-center justify-center py-16`,children:b(j,{className:`h-6 w-6 animate-spin text-primary`})}),p&&!l.isLoading&&b(a,{children:m(`div`,{className:`flex flex-col items-center gap-2 px-4 py-14 text-center`,children:[b(L,{className:`h-6 w-6 text-foreground-subtle`}),b(`div`,{className:`text-sm font-medium text-foreground`,children:`Delivery history requires a server update`}),b(`p`,{className:`max-w-md text-xs text-foreground-subtle`,children:`The history query is not available on this hub yet. It becomes queryable after the next server update ships the notification-center history endpoint. Rules still deliver and record their outcome in the meantime.`}),m(`button`,{type:`button`,onClick:()=>void l.refetch(),className:`mt-1 inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:[b(D,{className:`h-3 w-3`}),` Retry`]})]})}),!p&&!l.isLoading&&f.length===0&&b(`div`,{className:`py-16 text-center text-xs text-foreground-subtle`,children:`No deliveries match these filters.`}),!p&&f.length>0&&b(a,{children:b(`ul`,{className:`divide-y divide-border`,children:f.map(e=>b(mt,{entry:e,cameraName:d},e.id))})})]})}function mt({entry:e,cameraName:t}){let r=new Date(e.createdAt).toLocaleString(),i=e.subject.label??e.subject.className;return b(`li`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5`,children:m(`div`,{className:`min-w-0 flex-1`,children:[m(`div`,{className:`flex items-center gap-2`,children:[b(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.ruleName}),b(n,{variant:ft(e.status),children:e.status})]}),m(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px] text-foreground-subtle`,children:[b(`span`,{children:r}),b(`span`,{"aria-hidden":!0,children:`·`}),b(`span`,{children:t(e.deviceId)}),b(`span`,{"aria-hidden":!0,children:`·`}),b(`span`,{children:i}),e.subject.confidence!==void 0&&m(_,{children:[b(`span`,{"aria-hidden":!0,children:`·`}),m(`span`,{children:[Math.round(e.subject.confidence*100),`%`]})]}),e.attempts>1&&m(_,{children:[b(`span`,{"aria-hidden":!0,children:`·`}),m(`span`,{children:[e.attempts,` attempts`]})]})]}),e.status===`dead`&&e.error&&b(`div`,{className:`mt-1 rounded border border-danger/30 bg-danger/10 px-2 py-1 text-[11px] text-danger`,children:e.error})]})})}function ht(){return b(`div`,{className:`flex flex-col p-4`,children:b(te,{tabs:[{id:`targets`,label:`Targets`,icon:M,content:b(be,{})},{id:`rules`,label:`Rules`,icon:I,content:b(it,{})},{id:`history`,label:`History`,icon:L,content:b(pt,{})}]})})}export{ht as NotificationsPage,ht as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$a as e,$r as t,Ci as n,Di as r,Ei as i,Eo as a,Fi as o,Ha as s,Hr as c,Ja as l,Ka as u,Li as d,Mi as f,Mo as p,Ni as m,No as h,Pi as g,Qa as _,Si as v,T as y,Ti as b,Ya as x,Za as S,_ as C,_i as w,ai as T,bi as E,ci as D,ei as O,fi as k,ft as A,g as j,hi as ee,ii as te,li as ne,lt as M,ni as re,no as ie,oi as ae,qa as oe,ri as se,si as ce,ti as le,to as ue,ui as de,ut as fe,vi as pe,wi as me,xi as he,yi as ge}from"./src-D49drDQI.js";import{I as _e,K as ve,Q as N,S as P,T as ye,W as F,b as I,o as L,q as R,x as z,z as B}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{G as be,K as xe,X as Se}from"./src-PXZvyYDe.js";import{c as Ce,n as V,o as we,r as Te,s as Ee,t as De}from"./NodeInferenceDevices-DreXBx4e.js";import{t as Oe}from"./download-BARV2Xt2.js";import{i as ke}from"./AddLocationWizard-B_z3eUPS.js";import{n as Ae,r as je,t as Me}from"./zap-CUnbY527.js";import{t as Ne}from"./pencil-C3NxLuzk.js";import{t as Pe}from"./plus-zsIhHGHK.js";import{t as Fe}from"./radio-IH3FZ-ad.js";import{t as Ie}from"./refresh-cw-DXzAUpGT.js";import{t as Le}from"./search-BU0QQbas.js";import{t as Re}from"./server-B2_ttQ96.js";import{t as ze}from"./square-check-big-D5MMfdqS.js";import{t as Be}from"./square-CCYHDGJh.js";import{E as Ve,I as He,J as Ue,L as H,M as We,N as Ge,P as Ke,S as U,T as qe,W as Je,i as Ye,j as W,o as Xe,s as Ze}from"./index-DcoBSPD8.js";import{t as Qe}from"./AdminPage-Dq33XE9j.js";import{t as G}from"./useEventInvalidation-tttDHu6H.js";import{r as $e,t as et}from"./build-cluster-graph--dRyE6jp.js";import{n as tt}from"./format-size-CO9d3C3-.js";import{t as nt}from"./NodeAddonsSettingsPanel-DQhn50qD.js";import{n as rt,t as it}from"./ClusterRecordingTab-z1xB2po9.js";var at=Je(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),ot=Je(`flame`,[[`path`,{d:`M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z`,key:`96xj49`}]]),st=Je(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]);N();function ct(e){return e}function lt(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function ut(e,t){return typeof e==`boolean`?e:ct(t)}function dt(e,t){return{pipeline:ut(lt(e,`detect`),t),audio:ut(lt(e,`audio`),t),ingest:ut(lt(e,`ingest`),t)}}function ft(e,t,n){let r=e?.find(e=>e.nodeId===t);return dt(r?.settings,n)}function pt({selectedNodeId:e,onSelect:t,refreshToken:n}){let{data:r}=c(void 0),{data:i}=w(void 0),{data:o}=ge(void 0),s=new Map;for(let e of i??[])s.set(e.agentNodeId,(s.get(e.agentNodeId)??0)+1);let l=r??[],u=l.filter(e=>e.isOnline).length,d=l.filter(e=>!e.isOnline).length;return P(`div`,{className:`flex flex-col h-full`,children:[P(`button`,{type:`button`,onClick:()=>t(Sr),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${e===`__cluster__`?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[z(qe,{className:`h-4 w-4 flex-shrink-0`}),P(`div`,{className:`min-w-0 flex-1`,children:[z(`div`,{className:`text-xs font-semibold truncate`,children:`Cluster`}),z(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Balancer + failover + assignments`})]})]}),z(`div`,{className:`flex-1 overflow-y-auto`,children:l.map(n=>{let r=e===n.id,i=s.get(n.id)??0,c=n.isHub?Re:W,l=ft(o,n.id,n.isHub),u=n.isOnline?null:h($e(n.lastSeen));return P(`button`,{type:`button`,onClick:()=>t(n.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${r?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${n.isOnline?``:` opacity-60`}`,children:[z(c,{className:`h-4 w-4 flex-shrink-0`}),P(`div`,{className:`min-w-0 flex-1`,children:[P(`div`,{className:`flex items-center gap-2`,children:[z(`span`,{className:`text-xs font-semibold truncate`,children:n.name}),n.isHub&&z(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`}),!n.isOnline&&z(`span`,{className:`h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0`}),n.isOnline&&z(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),P(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[P(`span`,{children:[n.cpuCores,` cores`]}),z(`span`,{children:`•`}),P(`span`,{children:[Math.round(n.memoryMB/1024),` GB`]}),i>0&&P(I,{children:[z(`span`,{children:`•`}),P(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[z(Ae,{className:`h-2.5 w-2.5`}),i]})]}),!n.isOnline&&P(I,{children:[z(`span`,{children:`•`}),P(`span`,{className:`text-destructive`,children:[`offline`,u===null?``:` · ${u}`]})]})]}),P(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[z(a,{variant:l.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.pipeline?`Pipeline: enabled`:`Pipeline: not enabled (agent capability)`,children:`Pipe`}),z(a,{variant:l.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.audio?`Audio: enabled`:`Audio: not enabled (agent capability)`,children:`Aud`})]})]})]},n.id)})}),P(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[P(`span`,{children:[u,` online`]}),d>0&&P(`span`,{className:`text-destructive`,children:[d,` offline`]})]})]})}function mt({nodeId:e,refreshToken:t}){let{data:n}=c(void 0),r=n?.find(t=>t.id===e),i=oe(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return r?P(`div`,{className:`px-6 py-4 border-b border-border`,children:[P(`div`,{className:`flex items-center gap-2 mb-1`,children:[z(`h2`,{className:`text-base font-semibold text-foreground`,children:r.name}),r.isOnline?z(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:`online`}):z(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`}),r.isHub&&z(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`})]}),P(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[z(`span`,{children:r.cpuModel??`CPU`}),z(`span`,{children:`•`}),P(`span`,{children:[r.cpuCores,` cores`]}),z(`span`,{children:`•`}),P(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),i&&P(I,{children:[z(`span`,{children:`•`}),P(`span`,{children:[i.attachedCameras,` cameras (`,i.activeCameras,` active)`]}),z(`span`,{children:`•`}),P(`span`,{children:[i.avgInferenceTimeMs.toFixed(0),`ms avg inference`]}),z(`span`,{children:`•`}),P(`span`,{children:[`queue `,i.queueDepthTotal]}),i.hardware.hasGpu&&P(I,{children:[z(`span`,{children:`•`}),z(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):z(`div`,{className:`px-6 py-4 border-b border-border`,children:P(`div`,{className:`text-xs text-foreground-subtle`,children:[`Node not found: `,e]})})}function ht({refreshToken:e,nodeId:t}){let[n,r]=R(new Map),{nodes:i}=u();x(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&r(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:a}=de(void 0),o=F(()=>{let e=new Map;for(let t of a??[])e.set(t.nodeId,t.deviceCount);return e},[a]),s=F(()=>{let e=new Map,t=Date.now()-3e4;for(let r of n.values()){if(r.timestamp<t)continue;let n=r.nodeId??`hub`,i=e.get(n)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,r.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=r.metrics.actualFps,i.totalInferenceWeighted+=r.metrics.avgInferenceTimeMs,i.queueDepth+=r.metrics.queueDepth,e.set(n,i)}return e},[n]),c=F(()=>{let e=new Map;for(let t of i)e.set(t.id,t.shortName);return e},[i]),l=F(()=>{let e=0,t=0,n=0,r=0,a=0;for(let i of s.values())e+=i.attachedCameras,t+=i.activeCameras,n+=i.totalFps,r+=i.totalInferenceWeighted,a+=i.queueDepth;let o=e>0?r/e:0;return{totalAgents:i.length,onlineAgents:i.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:o,queueDepth:a,totalFps:n}},[s,i]);if(t){let e=s.get(t);return P(`div`,{className:`@container/liveload`,children:[z(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),P(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[z(K,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),z(K,{label:`Active / Attached`,value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),z(K,{label:`Avg infer ms`,value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),z(K,{label:`Queue`,value:e?String(e.queueDepth):`—`}),z(K,{label:`Audio`,value:String(o.get(t)??`—`)})]})]})}let d=[...s.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return P(`div`,{className:`@container/liveload`,children:[z(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),P(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[z(K,{label:`Total agents`,value:`${l.onlineAgents}/${l.totalAgents}`}),z(K,{label:`Active / Attached`,value:`${l.activeCameras}/${l.attachedCameras}`}),z(K,{label:`Total FPS`,value:l.totalFps.toFixed(1)}),z(K,{label:`Avg inference ms`,value:l.avgInferenceTimeMs.toFixed(0)}),z(K,{label:`Queue depth`,value:String(l.queueDepth)})]}),z(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:P(`table`,{className:`w-full text-xs min-w-[480px]`,children:[z(`thead`,{className:`bg-surface`,children:P(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[z(`th`,{className:`text-left px-3 py-2`,children:`Agent`}),z(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),z(`th`,{className:`text-right px-3 py-2`,children:`Cameras`}),z(`th`,{className:`text-right px-3 py-2`,children:`Inference ms`}),z(`th`,{className:`text-right px-3 py-2`,children:`Queue`}),z(`th`,{className:`text-right px-3 py-2`,children:`Audio`})]})}),P(`tbody`,{children:[d.map(([e,t])=>P(`tr`,{className:`border-t border-border`,children:[z(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:c.get(e)??e}),z(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.totalFps.toFixed(1)}),z(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras}),z(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),z(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.queueDepth}),z(`td`,{className:`px-3 py-2 text-right text-foreground`,children:o.get(e)??`—`})]},e)),d.length===0&&z(`tr`,{children:z(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No camera metrics received yet`})})]})]})})]})}function K({label:e,value:t}){return P(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[z(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:e}),z(`div`,{className:`text-lg font-semibold text-foreground`,children:t})]})}N();var gt={active:!1,pinned:!1,nodeId:null,reason:``},_t=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`],vt={pipeline:W,decoder:Ve,audio:je},yt={pipeline:`Pipeline`,decoder:`Decoder`,audio:`Audio`};function bt({mode:e,nodeId:t,compact:n=!1}){if(e===`agent`&&!t)throw Error(`CameraAssignmentsTable: nodeId is required when mode === "agent"`);let r=L(),[i,a]=R(null),[o,s]=R(null),[c,l]=R(new Map);G([`pipelineOrchestrator`,`getPipelineAssignments`],_t),G([`pipelineOrchestrator`,`getAudioAssignments`],_t),G([`pipelineOrchestrator`,`getCameraStatuses`],_t);let{data:d}=w(void 0),{data:f}=ne(void 0),{data:p}=k({},{enabled:e===`agent`}),{nodes:h}=u(),{data:_}=we();x(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t.deviceId==`number`&&l(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})}),B(()=>{if(c.size===0)return;let e=setInterval(()=>{l(e=>{let t=Date.now()-1e4,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},5e3);return()=>clearInterval(e)},[c.size]);let v=F(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.name);return e},[_]),b=F(()=>{if(e===`agent`){let e=[];for(let n of p??[]){let r=n.assignment,i=(e,n,r)=>({active:e!==null&&e===t,pinned:n,nodeId:e,reason:r??``}),a=i(r.detectionNodeId,r.pinned.detection,r.reasons.detection),o=i(r.decoderNodeId,r.pinned.decoder,r.reasons.decoder),s=i(r.audioNodeId,r.pinned.audio,r.reasons.audio);!a.active&&!o.active&&!s.active||e.push({deviceId:n.deviceId,deviceName:v.get(n.deviceId)??`Device ${n.deviceId}`,pipeline:a,decoder:o,audio:s})}return e.sort((e,t)=>e.deviceId-t.deviceId),e}let n=new Map,r=e=>{let t=n.get(e);if(t)return t;let r={deviceId:e,deviceName:v.get(e)??`Device ${e}`,pipeline:gt,decoder:gt,audio:gt};return n.set(e,r),r};for(let i of d??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,pipeline:{active:!0,pinned:i.pinned,nodeId:i.agentNodeId,reason:i.reason??``},decoder:{active:e===`cluster`?!0:i.agentNodeId===t,pinned:!1,nodeId:i.agentNodeId,reason:`co-located`}})}for(let e of f??[]){let t=r(e.deviceId);n.set(e.deviceId,{...t,audio:{active:!0,pinned:e.pinned,nodeId:e.nodeId,reason:`capacity`}})}let i=[...n.values()];return i.sort((e,t)=>e.deviceId-t.deviceId),i},[d,f,p,v,e,t]),S=F(()=>(h??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[h]),C=()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},T=ce({onSuccess:C}),E=g({onSuccess:C}),D=ae({onSuccess:C}),O=m({onSuccess:C}),A=(e,t,n)=>{t===`pipeline`?T.mutate({deviceId:e,agentNodeId:n}):D.mutate({deviceId:e,nodeId:n}),a(null)},j=(e,t)=>{t===`pipeline`?E.mutate({deviceId:e}):O.mutate({deviceId:e}),a(null)};return z(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:P(`table`,{className:`w-full text-xs min-w-[760px] table-fixed`,children:[z(`thead`,{className:`bg-surface`,children:P(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[!n&&z(`th`,{className:`w-10`}),z(`th`,{className:`min-w-[200px] text-left px-3 py-2 align-middle`,children:`Camera`}),e===`cluster`?P(I,{children:[z(`th`,{className:`w-[168px] text-left px-3 py-2 align-middle`,children:`Auto | Pin`}),z(`th`,{className:`w-[188px] text-left px-3 py-2 align-middle`,children:`Resolved placement`})]}):P(I,{children:[z(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Pipeline`}),z(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Decoder`}),z(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Audio`})]}),z(`th`,{className:`w-[132px] text-left px-3 py-2 align-middle`,children:`Status`})]})}),P(`tbody`,{children:[b.map(t=>{let r=c.get(t.deviceId),l=o===t.deviceId;return P(ye.Fragment,{children:[P(`tr`,{className:`border-t border-border align-middle relative`,children:[!n&&z(`td`,{className:`px-2 py-2 align-middle`,children:z(`button`,{type:`button`,onClick:()=>s(l?null:t.deviceId),className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":l?`Collapse broker details`:`Expand broker details`,children:z(l?He:Ke,{className:`h-3.5 w-3.5`})})}),P(`td`,{className:`px-3 py-2 align-middle min-w-0`,children:[z(`div`,{className:`text-foreground font-medium leading-tight line-clamp-2 break-words`,title:t.deviceName,children:t.deviceName}),P(`div`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[`#`,t.deviceId]})]}),e===`cluster`?P(I,{children:[z(`td`,{className:`px-3 py-2 align-middle`,children:z(St,{state:t.pipeline,onlineNodes:S,pending:T.isPending||E.isPending,onChange:e=>{e===`auto`?j(t.deviceId,`pipeline`):A(t.deviceId,`pipeline`,e)}})}),z(`td`,{className:`px-3 py-2 align-middle`,children:z(Ct,{state:t.pipeline,deviceId:t.deviceId})})]}):P(I,{children:[z(Tt,{role:`pipeline`,state:t.pipeline,mode:e,deviceId:t.deviceId,onlineNodes:S,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`pipeline`,onToggleMenu:()=>a(i?.deviceId===t.deviceId&&i.role===`pipeline`?null:{deviceId:t.deviceId,role:`pipeline`}),onCloseMenu:()=>a(null),onMove:e=>A(t.deviceId,`pipeline`,e),onUnpin:()=>j(t.deviceId,`pipeline`)}),z(Tt,{role:`decoder`,state:t.decoder,mode:e,deviceId:t.deviceId,onlineNodes:S,readOnly:!0,isMenuOpen:!1,onToggleMenu:()=>void 0,onCloseMenu:()=>void 0,onMove:()=>void 0,onUnpin:()=>void 0}),z(Tt,{role:`audio`,state:t.audio,mode:e,deviceId:t.deviceId,onlineNodes:S,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`audio`,onToggleMenu:()=>a(i?.deviceId===t.deviceId&&i.role===`audio`?null:{deviceId:t.deviceId,role:`audio`}),onCloseMenu:()=>a(null),onMove:e=>A(t.deviceId,`audio`,e),onUnpin:()=>j(t.deviceId,`audio`)})]}),z(`td`,{className:`px-3 py-2 align-middle`,children:z(kt,{snap:r})})]}),l&&!n&&P(`tr`,{className:`bg-surface/50`,children:[z(`td`,{}),P(`td`,{colSpan:e===`cluster`?4:5,className:`px-3 py-2 space-y-3`,children:[t.pipeline.nodeId&&z(xt,{deviceId:t.deviceId,nodeId:t.pipeline.nodeId}),z(y,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:t.deviceId,instanceId:`pipeline-row/${t.deviceId}`,config:{variant:`compact`,title:`Stream brokers & clients`}})]})]})]},t.deviceId)}),b.length===0&&z(`tr`,{children:z(`td`,{colSpan:n?e===`cluster`?4:5:e===`cluster`?5:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:e===`agent`?`No cameras assigned to this node`:`No cameras currently assigned`})})]})]})})}function xt({deviceId:e,nodeId:t}){let n=L(),{data:r}=ee({nodeId:t}),{data:i}=pe({deviceId:e}),a=f({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}}),o=r?.devices??[],s=i?.deviceKey??`auto`,c=s!==`auto`&&!o.some(e=>e.key===s);return P(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[z(`span`,{className:`shrink-0 font-medium text-foreground`,children:`Inference device`}),P(`select`,{value:s,disabled:a.isPending,"aria-label":`Inference device pin`,onChange:t=>a.mutate({deviceId:e,deviceKey:t.target.value}),className:`rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground`,children:[z(`option`,{value:`auto`,children:`Auto (balanced)`}),c&&P(`option`,{value:s,children:[`Pin → `,s,` (not on this node)`]}),o.map(e=>P(`option`,{value:e.key,children:[`Pin → `,e.key,e.available?``:` (unavailable)`]},e.key))]}),a.isPending&&z(`span`,{className:`text-[10px] opacity-70`,children:`saving…`})]})}function St({state:e,onlineNodes:t,pending:n,onChange:r}){let i=e.pinned&&e.nodeId?e.nodeId:`auto`,a=[...new Set([...e.nodeId?[e.nodeId]:[],...t.map(e=>e.id)])];return P(`select`,{value:i,disabled:n,"aria-label":`Pipeline placement pin`,onChange:e=>r(e.target.value),className:`w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground`,children:[z(`option`,{value:`auto`,children:`Auto`}),a.map(e=>P(`option`,{value:e,children:[`Pin → `,t.find(t=>t.id===e)?.name??e]},e))]})}function Ct({state:e,deviceId:t}){if(!e.active||!e.nodeId)return z(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`});let n=e.pinned?`pinned · manual`:`auto · ${e.reason||`capacity`}`;return P(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[z(`span`,{className:`font-mono text-[11px] text-foreground truncate`,title:e.nodeId,children:e.nodeId}),z(`span`,{className:`truncate ${e.pinned?`text-amber-400 text-[10px]`:`text-foreground-subtle text-[10px]`}`,title:n,children:n}),z(wt,{deviceId:t,nodeId:e.nodeId})]})}function wt({deviceId:e,nodeId:t}){let n=L(),{data:r}=pe({deviceId:e},{refetchOnMount:`always`}),{data:i}=ee({nodeId:t},{refetchOnMount:`always`}),a=f({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});if(r===void 0||i===void 0)return z(`span`,{className:`mt-0.5 text-[10px] text-foreground-subtle italic`,children:`device: …`});let o=i.devices??[],s=o.filter(e=>e.enabled),c=r.deviceKey??`auto`,l=c!==`auto`&&!s.some(e=>e.key===c),u=o.find(e=>e.key===c);return P(`select`,{value:c,disabled:a.isPending,"aria-label":`Inference device pin`,onChange:t=>a.mutate({deviceId:e,deviceKey:t.target.value}),className:`mt-0.5 w-full min-w-0 rounded border border-border bg-background px-1 py-0.5 text-[10px] text-foreground disabled:opacity-50`,children:[z(`option`,{value:`auto`,children:`Auto (balanced)`}),l&&P(`option`,{value:c,children:[u?`${V(u).label} (${c})`:c,` (not enabled)`]}),s.map(e=>P(`option`,{value:e.key,children:[V(e).label,` · `,e.format]},e.key))]})}function Tt({role:e,state:t,mode:n,onlineNodes:r,readOnly:i=!1,isMenuOpen:a,onToggleMenu:o,onCloseMenu:s,onMove:c,onUnpin:l}){let u=vt[e],d=r.filter(e=>e.id!==(t.nodeId??``)),f=!i&&(t.active||n===`cluster`)&&(d.length>0||t.pinned);return P(`td`,{className:`px-3 py-2 align-middle relative min-w-0`,children:[P(`div`,{className:`flex items-center gap-2 min-w-0`,children:[z(n===`agent`?Et:Dt,{state:t,Icon:u}),z(`div`,{className:`ml-auto shrink-0`,children:f&&z(`button`,{type:`button`,onClick:o,className:`p-1 rounded hover:bg-surface-hover`,"aria-label":`${yt[e]} actions`,children:z(at,{className:`h-3 w-3 text-foreground-subtle`})})})]}),a&&f&&z(At,{title:yt[e],targets:d,pinned:t.pinned,onMove:c,onUnpin:l,onClose:s})]})}function Et({state:e,Icon:t}){return P(`div`,{className:`flex items-center gap-1.5`,children:[z(e.active?ze:Be,{className:`h-3.5 w-3.5 ${e.active?`text-success`:`text-foreground-subtle/50`}`}),z(t,{className:`h-3 w-3 ${e.active?`text-foreground-subtle`:`text-foreground-subtle/40`}`}),e.pinned&&z(st,{className:`h-2.5 w-2.5 text-amber-400`})]})}function Dt({state:e,Icon:t}){return!e.active||!e.nodeId?P(`div`,{className:`flex items-center gap-1.5 text-foreground-subtle/60`,children:[z(t,{className:`h-3 w-3`}),z(`span`,{className:`text-[10px] italic`,children:`—`})]}):P(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[z(t,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),P(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[z(`span`,{className:`font-mono text-[11px] text-foreground truncate`,children:e.nodeId}),z(`span`,{className:`flex items-center gap-1 text-[10px]`,children:e.pinned?P(`span`,{className:`inline-flex items-center gap-0.5 text-amber-400`,children:[z(st,{className:`h-2.5 w-2.5`}),` manual`]}):P(`span`,{className:`text-foreground-subtle truncate`,children:[`auto · `,e.reason||`capacity`]})})]})]})}var Ot=`min-h-[3.25rem]`;function kt({snap:e}){if(!e)return z(`div`,{className:`flex items-center ${Ot}`,children:z(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`})});let{phase:t,actualFps:n,avgInferenceTimeMs:r,queueDepth:i,configuredFps:a,droppedFrames:o}=e.metrics,s=p(t);return P(`div`,{className:`flex flex-col justify-center gap-0.5 font-mono text-[10px] tabular-nums leading-tight min-w-0 ${Ot}`,children:[P(`span`,{className:`inline-flex items-center gap-1 min-w-0 ${s.textColor}`,children:[z(C,{phase:t,className:`h-2.5 w-2.5 shrink-0`}),z(`span`,{className:`font-semibold uppercase tracking-wider truncate`,children:s.label})]}),P(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[z(`span`,{className:`text-foreground`,children:n.toFixed(1)}),P(`span`,{children:[`/`,a.toFixed(0),` fps`]})]}),P(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[z(`span`,{className:`text-foreground`,children:r.toFixed(0)}),z(`span`,{children:` ms`}),i>0&&P(`span`,{className:`text-warning ml-1`,children:[`q`,i]})]}),P(`span`,{className:`whitespace-nowrap truncate ${o>0?`text-warning`:`text-foreground-subtle`}`,children:[`drops `,z(`span`,{className:`text-foreground`,children:o})]})]})}function At({title:e,targets:t,pinned:n,onMove:r,onUnpin:i,onClose:a}){let o=ve(null);return B(()=>{let e=e=>{o.current?.contains(e.target)||a()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[a]),P(`div`,{ref:o,className:`absolute right-2 top-full mt-1 w-48 rounded-lg border border-border bg-surface shadow-lg z-20 text-left`,children:[z(`div`,{className:`px-3 py-1 text-[9px] uppercase tracking-wider text-foreground-subtle border-b border-border`,children:e}),t.length>0&&z(`div`,{className:`py-1`,children:t.map(e=>P(`button`,{type:`button`,onClick:()=>r(e.id),className:`block w-full text-left px-3 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[`Move to `,e.name]},e.id))}),n&&P(`button`,{type:`button`,onClick:i,className:`block w-full text-left px-3 py-1.5 text-[11px] text-destructive hover:bg-destructive/10 border-t border-border`,children:[`Unpin `,e.toLowerCase()]}),t.length===0&&!n&&z(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle italic`,children:`Already auto · no other nodes online`})]})}function jt({nodeId:e,refreshToken:t}){return P(`div`,{className:`space-y-6`,children:[z(ht,{refreshToken:t,nodeId:e}),P(`div`,{children:[z(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Cameras on this node`}),P(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`Checkboxes mark the roles currently running on `,e,`. Use the kebab to move a role to another node or unpin it; live KPIs come from the runner snapshot stream.`]})]}),z(bt,{mode:`agent`,nodeId:e,compact:!0})]})}N();function Mt(e,t){let n=Math.max(0,t-e);return`${Math.floor(e/1e3)}s idle · ${Math.floor(n/1e3)}s left`}function Nt({nodeId:e,refreshToken:t}){let n=L(),r=te({onSettled:()=>{n.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:i}=T({nodeId:e}),a=oe(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??i??null,o=a===null;G([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:s}=d({nodeId:e}),{values:c}=l(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),u=F(()=>c.filter(e=>e.metrics.phase===`active`).length,[c]),f=t=>{let n=s??[];n.length>0&&!window.confirm(`${n.length} camera(s) are dispatching through this engine. Killing it forces a respawn on the next frame. Continue?`)||r.mutate({nodeId:e,engine:t,force:n.length>0})};return P(`div`,{className:`space-y-6`,children:[P(`div`,{children:[z(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Inference engines on this node`}),P(`p`,{className:`text-[11px] text-foreground-subtle`,children:[(a??[]).length,` engine(s) resident in RAM. `,(s??[]).length,` `,`camera(s) attached, `,u,` actively dispatching frames. Refreshes every 5s.`]})]}),z(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:P(`table`,{className:`w-full text-xs min-w-[640px]`,children:[z(`thead`,{className:`bg-surface`,children:P(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[z(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Kind`}),z(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Runtime / Backend / Device`}),z(`th`,{className:`text-left px-3 py-2`,children:`Models`}),z(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Pool PID`}),z(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Auto-kill`}),z(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`In use`}),z(`th`,{className:`w-20`})]})}),P(`tbody`,{children:[o&&z(`tr`,{children:z(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`Loading…`})}),!o&&(a??[]).map(e=>{let t=e.kind===`warm-override`,n=e.kind===`device-pool`;return P(`tr`,{className:`border-t border-border ${t?`bg-amber-500/5`:n?`bg-primary/[0.05]`:``}`,children:[z(`td`,{className:`px-3 py-2`,children:P(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${t?`bg-amber-500/15 text-amber-400`:n?`bg-primary/15 text-primary`:`bg-success/15 text-success`}`,children:[z(t?ot:n?Ce:W,{className:`h-3 w-3`}),t?`warm`:n?`pool`:`runtime`]})}),z(`td`,{className:`px-3 py-2`,children:P(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[z(Me,{className:`h-3 w-3`}),e.engine.runtime,`/`,e.engine.backend,e.engine.device?`/${e.engine.device}`:``,e.engine.format?` · ${e.engine.format}`:``]})}),z(`td`,{className:`px-3 py-2`,children:e.modelsLoaded.length===0?z(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):z(`div`,{className:`flex flex-wrap gap-1`,children:e.modelsLoaded.map(e=>z(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),z(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.poolPid??`—`}),z(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:e.idleMs!==null&&e.idleTtlMs!==null?z(`span`,{className:`text-foreground-subtle`,children:Mt(e.idleMs,e.idleTtlMs)}):z(`span`,{className:`text-foreground-subtle/50`,children:`never`})}),z(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t?`—`:(s??[]).length}),z(`td`,{className:`px-3 py-2 text-right`,children:n?z(`span`,{className:`text-[11px] text-foreground-subtle`,children:`auto`}):P(`button`,{type:`button`,disabled:r.isPending,onClick:()=>f(e.engine),className:`inline-flex items-center gap-1 px-2 py-1 rounded border border-destructive/30 text-destructive text-[11px] hover:bg-destructive/10 disabled:opacity-50`,children:[z(Ze,{className:`h-3 w-3`}),`Kill`]})})]},e.engineKey)}),!o&&(a??[]).length===0&&z(`tr`,{children:z(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No engines resident — the factory spins up on the first pipeline run.`})})]})]})}),P(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:[z(`strong`,{className:`text-foreground`,children:`runtime`}),`: main camera-serving engine; never auto-killed while cameras attached. `,z(`strong`,{className:`text-foreground`,children:`warm`}),`: benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL.`,` `,z(`strong`,{className:`text-foreground`,children:`pool`}),`: a per-device balanced inference pool (one per enabled accelerator, running concurrently); reaper-managed on its own idle TTL.`]}),r.isError&&P(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[`Kill failed:`,` `,r.error instanceof Error?r.error.message:`unknown`]})]})}N();var Pt=new Set(Se);function Ft(e){return Pt.has(e)}function It(e,t,n){return`${e}/${t}/${n}`}function Lt(e){return{coreml:`CoreML`,openvino:`OpenVINO`,onnx:`ONNX`}[e.format]??e.format.toUpperCase()}function Rt(e){return{coreml:`Apple Neural Engine / GPU — .mlpackage`,openvino:`Intel CPU / GPU / NPU — .xml`,onnx:`CPU, CUDA, Node.js — .onnx`}[e.format]??`.${e.format}`}function q(e){return e.format}function zt(e,t){let n=0,r=0,i=0;for(let a of e)for(let e of a.addons)for(let a of e.models){let e=a.formats[t];e&&(n++,e.downloaded&&(r++,i+=e.sizeMB))}return{total:n,downloaded:r,downloadedSizeMB:i}}function Bt({addonId:e,model:t,format:n,isActive:r,progress:i,errorMsg:a,onDownload:o,onDelete:s}){let c=t.formats[n];return c?P(`div`,{className:`flex items-center gap-3 px-4 py-3 border-b border-border/50 last:border-b-0 hover:bg-surface-hover/30 transition-colors`,children:[z(`div`,{className:`h-2 w-2 rounded-full shrink-0 ${c.downloaded?`bg-success`:`bg-foreground-subtle/30`}`}),P(`div`,{className:`flex-1 min-w-0`,children:[P(`div`,{className:`flex items-center gap-2`,children:[z(`span`,{className:`text-sm font-medium text-foreground`,children:t.name}),P(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`(`,t.id,`)`]})]}),i&&i.progress>=0&&i.progress<100&&P(`div`,{className:`mt-1.5 flex items-center gap-2 max-w-xs`,children:[z(`div`,{className:`flex-1 h-1 bg-surface-hover rounded-full overflow-hidden`,children:z(`div`,{className:`bg-primary h-full rounded-full transition-all duration-300`,style:{width:`${i.progress}%`}})}),P(`span`,{className:`text-[9px] text-primary font-mono tabular-nums shrink-0`,children:[Math.round(i.progress),`%`]})]})]}),z(`span`,{className:`text-xs text-foreground-subtle tabular-nums shrink-0`,children:tt(c.sizeMB)}),a&&P(`span`,{className:`flex items-center gap-1 text-[10px] text-danger max-w-[160px] truncate shrink-0`,title:a,children:[z(Ge,{className:`h-3 w-3 shrink-0`}),a]}),c.downloaded?P(`button`,{onClick:s,disabled:r,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md border border-danger/30 text-danger hover:bg-danger/10 disabled:opacity-50 transition-colors shrink-0`,children:[r?z(U,{className:`h-3 w-3 animate-spin`}):z(Ze,{className:`h-3 w-3`}),r?`Deleting...`:`Delete`]}):P(`button`,{onClick:o,disabled:r,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0`,children:[r?z(U,{className:`h-3 w-3 animate-spin`}):z(Oe,{className:`h-3 w-3`}),r?`Downloading...`:`Download`]})]}):null}function Vt({engines:e,activeEngine:t,viewEngine:n,onSelect:r}){let[i,a]=R(!1);return P(`div`,{className:`relative`,children:[P(`button`,{type:`button`,onClick:()=>a(!i),className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-4 py-2.5 w-full text-left hover:bg-surface-hover transition-colors`,children:[z(W,{className:`h-4 w-4 text-primary shrink-0`}),P(`div`,{className:`flex-1 min-w-0`,children:[P(`div`,{className:`flex items-center gap-2`,children:[z(`span`,{className:`text-sm font-medium text-foreground`,children:Lt(n)}),q(n)===q(t)&&z(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),z(`div`,{className:`text-[10px] text-foreground-subtle`,children:Rt(n)})]}),z(He,{className:`h-4 w-4 text-foreground-subtle transition-transform ${i?`rotate-180`:``}`})]}),i&&z(`div`,{className:`absolute top-full left-0 right-0 mt-1 rounded-lg border border-border bg-surface shadow-lg z-50 overflow-hidden`,children:e.map(e=>{let i=q(e)===q(n),o=q(e)===q(t);return P(`button`,{type:`button`,onClick:()=>{r(e),a(!1)},className:`flex items-center gap-3 px-4 py-2.5 w-full text-left transition-colors ${i?`bg-primary/5`:`hover:bg-surface-hover`}`,children:[z(W,{className:`h-4 w-4 shrink-0 ${i?`text-primary`:`text-foreground-subtle`}`}),P(`div`,{className:`flex-1`,children:[P(`div`,{className:`flex items-center gap-2`,children:[z(`span`,{className:`text-sm font-medium ${i?`text-primary`:`text-foreground`}`,children:Lt(e)}),o&&z(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),z(`div`,{className:`text-[10px] text-foreground-subtle`,children:Rt(e)})]}),i&&z(We,{className:`h-4 w-4 text-primary shrink-0`})]},q(e))})})]})}function Ht({embedded:e=!1,nodeId:n}={}){let r=L(),i=n??`hub`,[a,o]=R(null),[s,c]=R(new Set),[l,u]=R(new Map),[d,f]=R(new Map),[p,m]=R(``),{data:h=[]}=le({nodeId:i}),g=h.filter((e,t,n)=>n.findIndex(t=>t.format===e.format)===t),{data:_}=se({nodeId:i}),v=_,{data:y,isLoading:b}=re({nodeId:i}),S=O(),C=t();x(`model.download.progress`,e=>{let t=e.data,n=typeof t.modelId==`string`?t.modelId:void 0,i=typeof t.progress==`number`?t.progress:void 0,a=typeof t.totalMB==`number`?t.totalMB:0;n===void 0||i===void 0||(u(e=>{let t=new Map(e);return i===100||i===-1?t.delete(n):t.set(n,{modelId:n,progress:i,totalMB:a}),t}),i===100&&r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]}))});let w=v??{runtime:`node`,backend:`cpu`,format:`onnx`},T=g.find(e=>e.format===a)??w,E=T.format,D=y?.slots??[],k=D.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(e=>e.formats[E]!==void 0)})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0),A=zt(k,E),j=_e(async(e,t,n)=>{if(!Ft(n))return;let a=It(e,t,n);c(e=>new Set([...e,a])),f(e=>{let t=new Map(e);return t.delete(a),t});try{await S.mutateAsync({addonId:e,modelId:t,format:n,nodeId:i}),r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){f(t=>new Map([...t,[a,e instanceof Error?e.message:`Download failed`]]))}finally{c(e=>{let t=new Set(e);return t.delete(a),t})}},[S,r,i]),ee=_e(async(e,t,n)=>{if(!Ft(n))return;let a=It(e,t,n);c(e=>new Set([...e,a])),f(e=>{let t=new Map(e);return t.delete(a),t});try{await C.mutateAsync({addonId:e,modelId:t,format:n,nodeId:i}),r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){f(t=>new Map([...t,[a,e instanceof Error?e.message:`Delete failed`]]))}finally{c(e=>{let t=new Set(e);return t.delete(a),t})}},[C,r,i]),te=_e(e=>{o(e.format)},[]),ne=p.trim()?k.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(t=>t.name.toLowerCase().includes(p.toLowerCase())||t.id.toLowerCase().includes(p.toLowerCase())||e.name.toLowerCase().includes(p.toLowerCase()))})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0):k,M=P(I,{children:[b&&z(`div`,{className:`flex items-center justify-center py-16`,children:z(U,{className:`h-5 w-5 animate-spin text-foreground-subtle`})}),!b&&D.length===0&&P(`div`,{className:`flex flex-col items-center justify-center py-16 text-foreground-subtle`,children:[z(ke,{className:`h-8 w-8 mb-3 opacity-30`}),z(`span`,{className:`text-sm`,children:`No pipeline steps available`}),z(`span`,{className:`text-xs mt-1`,children:`Configure the detection pipeline to see available models.`})]}),!b&&D.length>0&&P(I,{children:[z(Vt,{engines:g,activeEngine:w,viewEngine:T,onSelect:te}),P(`div`,{className:`flex items-center gap-4 text-xs text-foreground-subtle`,children:[P(`span`,{children:[z(`span`,{className:`font-semibold text-foreground tabular-nums`,children:A.total}),z(`span`,{className:`ml-1`,children:`compatible models`})]}),z(`span`,{className:`text-border`,children:`|`}),P(`span`,{children:[z(`span`,{className:`font-semibold text-success tabular-nums`,children:A.downloaded}),z(`span`,{className:`ml-1`,children:`downloaded`})]}),z(`span`,{className:`text-border`,children:`|`}),P(`span`,{className:`tabular-nums`,children:[tt(A.downloadedSizeMB),z(`span`,{className:`ml-1`,children:`on disk`})]})]}),A.total>5&&P(`div`,{className:`relative`,children:[z(Le,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),z(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:`Search models...`,className:`w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-border bg-surface text-foreground placeholder:text-foreground-subtle/50 focus:outline-none focus:ring-1 focus:ring-primary`})]}),ne.map(e=>{let t=e.addons.reduce((e,t)=>e+t.models.length,0),n=e.addons.reduce((e,t)=>e+t.models.filter(e=>e.formats[E]?.downloaded).length,0);return P(`div`,{children:[P(`div`,{className:`flex items-center gap-2 mb-2`,children:[z(`h2`,{className:`text-sm font-semibold text-foreground`,children:e.label}),z(`div`,{className:`flex-1 h-px bg-border`}),P(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[n,`/`,t]})]}),z(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:e.addons.map(e=>e.models.map(t=>{let n=It(e.id,t.id,E);return z(Bt,{addonId:e.id,model:t,format:E,isActive:s.has(n),progress:l.get(t.id),errorMsg:d.get(n),onDownload:()=>j(e.id,t.id,E),onDelete:()=>ee(e.id,t.id,E)},`${e.id}/${t.id}`)}))})]},e.id)}),ne.length===0&&z(`div`,{className:`text-center py-8 text-sm text-foreground-subtle`,children:p.trim()?P(I,{children:[`No models matching “`,p,`”`]}):P(I,{children:[`No models available for `,Lt(T),` format`]})})]})]});return e?z(`div`,{className:`space-y-4`,children:M}):z(Qe,{children:M})}function Ut({nodeId:e,refreshToken:t}){return z(Ht,{embedded:!0,nodeId:e})}var Wt=`pipeline-runner`,Gt=200;function Kt({nodeId:e}){return P(`div`,{className:`flex flex-col gap-3`,children:[P(`div`,{children:[z(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Runner logs`}),P(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`pipeline-runner activity on `,e,` — camera attach/detach, engine phases and pipeline errors. Streaming live; the device chip on a line tells which camera it refers to.`]})]}),z(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:z(j,{agentId:e,addonId:Wt,limit:Gt,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}N(),N();function qt({nodeId:e,title:t}){let{data:n}=we(),{data:r}=w(void 0),i=F(()=>{let e=new Map;for(let t of n??[])e.set(t.id,t.name);return e},[n]),a=F(()=>{if(!e)return null;let t=new Set;for(let n of r??[])n.agentNodeId===e&&t.add(n.deviceId);return t},[e,r]),[o,s]=R(new Map);x(`pipeline.camera-metrics-snapshot`,t=>{let n=t.data;typeof n.deviceId==`number`&&(e&&n.nodeId!==e||s(e=>{let t=new Map(e);return t.set(n.deviceId,n),t}))}),B(()=>{if(o.size===0)return;let e=setInterval(()=>{s(e=>{let t=Date.now()-1e4,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},5e3);return()=>clearInterval(e)},[o.size]);let c=F(()=>{let e=[];for(let t of o.values())a&&!a.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[o,a]);return c.length===0?P(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[t??`Cameras`,`: no live snapshots yet`]}):P(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[P(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[z(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??`Cameras`}),z(`span`,{className:`text-[10px] text-foreground-subtle`,children:c.length})]}),z(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map(e=>{let t=i.get(e.deviceId)??`#${e.deviceId}`,n=p(e.metrics.phase);return P(`div`,{title:`${t} · ${n.label} · ${e.metrics.actualFps.toFixed(1)} fps · ${e.metrics.avgInferenceTimeMs.toFixed(0)}ms infer · q=${e.metrics.queueDepth}`,className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${n.badgeClass}`,children:[z(C,{phase:e.metrics.phase,className:`h-2.5 w-2.5`}),z(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:t}),z(`span`,{className:`font-mono tabular-nums`,children:e.metrics.actualFps.toFixed(1)}),z(`span`,{className:`opacity-60`,children:`fps`})]},e.deviceId)})})]})}N();function J(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 Jt(e){if(!e)return null;let t=e.modelId!==void 0&&e.modelId!==``?e.modelId:void 0,n=e.settings&&Object.keys(e.settings).length>0?e.settings:void 0;return t===void 0&&n===void 0?null:{...t===void 0?{}:{modelId:t},...n===void 0?{}:{settings:n}}}function Yt({nodeId:t,refreshToken:n}){let r=L(),[a,o]=R(null),[s,c]=R(null),[l,u]=R(``),[d,f]=R(null),p=ee({nodeId:t},{refetchOnMount:`always`}),m=re({nodeId:t},{refetchOnMount:`always`}),h=p.data?.devices??[],g=i({onSuccess:()=>{r.invalidateQueries({queryKey:[`pipelineOrchestrator`,`getNodeInferenceDevices`]})}}),v=F(()=>m.data?ue(m.data):[],[m.data]),y=F(()=>h.map(e=>({agentNodeId:t,engineLabel:e.format,deviceKey:e.key,deviceLabel:V(e).label})),[h,t]),b=e=>h.find(t=>t.key===e)??null,x=F(()=>h.filter(e=>e.enabled),[h]),C=x.length>=2,w=(e,t)=>{let n=J(m.data??null,e),r=t?.format;return n?.models.some(e=>r!==void 0&&!!e.formats[r])??!1},T=e=>{let t=b(e);return t?V(t).label:e},E=(e,t)=>x.filter(n=>n.key!==t&&w(e,n)).toSorted((e,t)=>e.key<t.key?-1:+(e.key>t.key))[0]??null,D=e=>{let t=J(m.data??null,e)?.enabledByDefault??!0;return{kind:`gate`,effectiveOn:t,defaultOn:t,explicit:!1}},O=(e,t)=>{let n=J(m.data??null,e),r=t?.format;if(!(!n||r===void 0))return(n.slot===`detector`?t?.defaultModelId:void 0)??S(n,r)},k=(e,t)=>{let n=D(e),r=n.kind===`gate`?n.effectiveOn:!1,i=J(m.data??null,e),a=t.deviceKey===void 0?null:b(t.deviceKey),o=a?.format,s=i?.models.some(e=>o!==void 0&&!!e.formats[o])??!1,c=a?.steps?.[e];if(!s){if(!r)return{kind:`na`};let n=c?.jumpDeviceKey,i=n!==void 0&&x.some(e=>e.key===n)?n:t.deviceKey===void 0?void 0:E(e,t.deviceKey)?.key;return i===void 0?{kind:`skip`}:{kind:`skip`,jumpTo:T(i)}}return{kind:`enabled`,modelId:c?.modelId??O(e,a)??`Auto`,...c?.jumpDeviceKey!==void 0&&x.some(e=>e.key===c.jumpDeviceKey)?{jumpTo:T(c.jumpDeviceKey)}:{}}},A=a&&m.data?J(m.data,a.addonId):null,j=a?b(a.deviceKey):null,te=j?.format??`coreml`,ne=a?O(a.addonId,j):void 0,M=()=>{o(null),c(null),u(``)},ae=(e,t)=>{if(t.deviceKey===void 0)return;let n=b(t.deviceKey)?.steps?.[e];o({addonId:e,deviceKey:t.deviceKey}),c({enabled:!0,...n?.modelId===void 0?{}:{modelId:n.modelId},settings:n?.settings??{}}),u(n?.jumpDeviceKey??``)},oe=()=>{if(!a)return;let e=Jt(s),n=l!==``&&l!==a.deviceKey?l:void 0,r=e||n!==void 0?{...e,...n===void 0?{}:{jumpDeviceKey:n}}:null,i={};for(let e of h){if(!e.enabled&&e.key!==a.deviceKey)continue;let t={...e.steps};e.key===a.deviceKey&&(r?t[a.addonId]=r:delete t[a.addonId]);let n=Object.keys(t).length>0;i[e.key]={enabled:!0,weight:Math.max(1,e.weight),...e.maxSessions!=null&&e.maxSessions>0?{maxSessions:e.maxSessions}:{},...n?{steps:t}:{}}}g.mutate({agentNodeId:t,inferenceDevices:i},{onSuccess:M})};if(p.isLoading||m.isLoading)return z(`div`,{className:`text-xs text-foreground-subtle animate-pulse p-4`,children:`Loading pipeline…`});if(h.length===0)return z(`div`,{className:`rounded-md border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No inference devices reported by this node's platform probe.`});if(!m.data)return z(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`Catalog unavailable.`});let se=a!==null&&A!==null&&j!==null;return P(`div`,{className:`relative h-full w-full space-y-3`,children:[P(`div`,{className:`rounded-md border border-border bg-muted/20 px-3 py-2 text-[11px] leading-relaxed text-foreground-subtle`,children:[`Each column is one of this node's inference accelerators. A cell shows the`,` `,z(`span`,{className:`font-medium text-foreground`,children:`base model`}),` every camera landing on that accelerator runs; click to change it. Whether a camera runs a step is set per-camera on that camera's Detection pipeline tab — there is no gate here.`]}),z(`div`,{className:se?`md:pr-[360px]`:``,children:v.length>0?z(_,{tree:v,agents:y,gateFor:D,getCellState:k,onCellClick:ae,selectedCell:a?{addonId:a.addonId,agentNodeId:t,deviceKey:a.deviceKey}:null,onSetGate:()=>{},fallbackNodeId:d,onFallbackNodeChange:f,hideGate:!0}):z(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),z(ie,{open:se,onClose:M,title:A?.name??``,subtitle:a&&j?`${t} · ${V(j).label} · ${j.format}`:``,footer:P(I,{children:[z(`div`,{className:`flex-1`}),z(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:M,children:`Cancel`}),z(`button`,{type:`button`,disabled:!a||!s||g.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:oe,children:g.isPending?`Saving…`:`Save`})]}),children:A&&a&&s?P(`div`,{className:`space-y-3`,children:[C&&P(`div`,{className:`rounded-md border border-border bg-muted/10 px-3 py-2 space-y-1`,children:[z(`label`,{className:`block text-[11px] font-medium text-foreground`,children:`Run on`}),P(`select`,{className:`w-full rounded border border-border bg-surface px-2 py-1 text-xs`,value:l,onChange:e=>u(e.target.value),children:[z(`option`,{value:``,children:`Auto (this device, or auto-jump if unsupported)`}),x.filter(e=>e.key!==a.deviceKey).map(e=>P(`option`,{value:e.key,children:[V(e).label,` · `,e.format]},e.key))]}),z(`p`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:`Route this step (and its child steps) to another accelerator on this node.`})]}),z(e,{mode:`agent`,addon:A,agentDefault:s,agentNodeId:t,engineFormat:te,effectiveModelId:ne,onChangeAgentConfig:c})]}):z(`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.`})})]})}N();var Xt=[`pipeline-orchestrator`],Zt=[`decoder`],Qt=!1;function $t({nodeId:e,refreshToken:t}){let n=s(),[r,i]=R(null),[a,o]=R(null),l=(c(void 0).data??[]).find(t=>t.id===e),u=l?.name??e,d=l?.isOnline??!1,f=v({onSuccess:e=>{o(e.effectiveModelId===null?`Reset done — model config cleared (node offline: effective model resolves on reconnect)`:`Reset done — effective detection model: ${e.effectiveModelId} (Auto)`)}}),p=async()=>{await n({title:`Reset ${u} to hardware-aware defaults?`,message:`This clears every per-device model default on this node (back to the format default) and every per-camera step override scoped to it. Existing per-camera customisations on this node are lost.`,confirmLabel:`Reset`,variant:`danger`})&&(o(null),f.mutate({agentNodeId:e}))};return P(`div`,{className:`relative h-full w-full space-y-3`,children:[P(`div`,{className:`flex items-center justify-end gap-2 text-xs`,children:[a&&z(`span`,{className:`text-emerald-400`,children:a}),f.isError&&z(`span`,{className:`text-red-400`,children:f.error instanceof Error?f.error.message:`Reset failed`}),z(`button`,{type:`button`,onClick:()=>{p()},disabled:f.isPending,className:`rounded border border-amber-500/40 bg-surface px-2 py-0.5 text-amber-300 hover:bg-surface-hover disabled:opacity-50`,title:`Clear this node's per-device model defaults + per-camera overrides scoped to this node`,children:f.isPending?`Resetting…`:`Reset to default`})]}),z(qt,{nodeId:e}),z(nt,{nodeId:e,addonIds:Xt,level:`global`,sectionIds:Zt}),Qt,Qt,P(`div`,{children:[z(`h3`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Inference devices — default model per accelerator`}),z(De,{nodeId:e,nodeName:u,isOnline:d})]}),P(`div`,{children:[z(`h3`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Detection steps — model per accelerator`}),z(Yt,{nodeId:e,refreshToken:t})]})]})}var en=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],tn=`decoder-nodeav`;function nn({nodeId:e,refreshToken:t}){let{data:n}=c(void 0),r=n?.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.id??tn,i=[...en,r];return P(`div`,{className:`flex flex-col h-full`,children:[z(mt,{nodeId:e,refreshToken:t}),z(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-6`,children:z(nt,{nodeId:e,addonIds:i,level:`global`,extraTabs:[{id:`assignments`,label:`Assignments`,order:-10,content:z(jt,{nodeId:e,refreshToken:t})},{id:`tree`,label:`Pipeline`,order:39,content:z($t,{nodeId:e,refreshToken:t})},{id:`engines`,label:`Warm instances`,order:180,content:z(Nt,{nodeId:e,refreshToken:t})},{id:`models`,label:`Models`,order:200,content:z(Ut,{nodeId:e,refreshToken:t})},{id:`logs`,label:`Logs`,order:300,content:z(Kt,{nodeId:e})}]})})]})}function rn(){return P(`div`,{className:`space-y-6`,children:[z(qt,{title:`Cluster cameras`}),P(`div`,{className:`min-w-0`,children:[z(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Placement matrix`}),z(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Pipeline · audio assignments per camera (decode always runs co-located with the pipeline). Use the Auto | Pin control to pin a camera to a node, the inference-device select to pin it to an accelerator, or the kebab to move a role; expand the chevron for the per-camera broker drill-down. Cluster load, inference-device weights, and Rebalance live on the Balancer tab.`})]}),z(bt,{mode:`cluster`})]})}var an=`pipeline-orchestrator`,on=`recorder`,sn=`recordingNodeId`,cn=[`ingestNode`,`recordingNode`,`audioNode`,`motionNode`],ln=[{key:`detect`,label:`Detect`,hint:`Runs the detection pipeline (decode + inference) for assigned cameras`}];function un(e,t){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t)return e.value}function dn(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function fn(e,t,n){let r=un(e,t);return typeof r==`string`&&r.length>0?r:n}function pn(e,t,n){let r=un(e,t);return typeof r==`number`&&Number.isFinite(r)?r:n}function mn(e,t){let n=dn(e,t);return typeof n==`number`&&Number.isFinite(n)?n:null}function hn(e,t){let n=dn(e,t);return typeof n==`string`&&n.length>0?n:null}function gn(e){return e===`ingestNode`?`Ingest`:e===`recordingNode`?`Recording`:e===`audioNode`?`Audio`:`Motion Node`}function _n(e){return e===`ingestNode`?`Node that terminates default camera ingest`:e===`recordingNode`?`Node that owns the recorder (recording-node)`:e===`audioNode`?`Node that runs singleton audio work`:`Runs software (analyzer) motion-watch. Onboard cameras are unaffected.`}function vn(e,t){switch(t){case`detect`:return e.pipeline}}function yn(e){return e instanceof Error?e.message:`Failed to save`}function bn(e){e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listAgentSettings`]]}),e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]}),e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}function xn({capability:e,label:t,hint:n,nodeId:r,active:i,pending:a,layout:o,onToggle:s}){let c=i?`border-success/30 bg-success/15 text-success hover:bg-success/25`:`border-border bg-surface-hover text-foreground-subtle hover:bg-surface hover:text-foreground`,l=o===`card`?`w-full justify-center px-3 py-2 text-xs`:`px-2.5 py-1 text-[11px]`,u=i?H:Ee;return P(`button`,{type:`button`,role:`switch`,"aria-checked":i,"aria-label":`${t} capability for ${r}`,title:`${t} — ${n}`,disabled:a,onClick:()=>s(e,!i),className:`inline-flex items-center gap-1.5 rounded-full border font-medium transition-colors disabled:opacity-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 ${c} ${l}`,children:[z(u,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":`true`}),z(`span`,{children:t})]})}function Sn({node:e,emphasis:t=!1}){let n=e.isHub?Re:W;return P(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[z(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),z(n,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),P(`div`,{className:`min-w-0`,children:[P(`div`,{className:`flex items-center gap-1.5 ${t?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[z(`span`,{className:`truncate`,children:e.name}),e.isHub&&z(a,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`hub`}),!e.isOnline&&z(a,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`offline`})]}),z(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:e.id})]})]})}N();function Cn({nodeId:e,value:t,detectedHosts:n,status:r,errorMessage:i,onCommit:a}){let[o,s]=R(t??``);B(()=>{s(t??``)},[t]);let c=n[0],l=c===void 0?`auto-detect`:`auto: ${c}`,u=r===`pending`,d=o.trim(),f=d!==(t??``),p=f&&!u,m=()=>{p&&a(e,d.length>0?d:null)};return P(`div`,{className:`flex items-center gap-1.5`,children:[z(`input`,{"aria-label":`Reachable host for ${e}`,type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:l,value:o,disabled:u,onChange:e=>s(e.target.value),onBlur:m,onKeyDown:e=>{e.key===`Enter`&&m(),e.key===`Escape`&&s(t??``)},className:`w-40 rounded-md border border-border bg-background px-2.5 py-1.5 text-sm text-foreground placeholder:text-foreground-subtle focus:border-primary focus:outline-none disabled:opacity-50`}),P(`button`,{type:`button`,onClick:m,disabled:!p,"aria-label":`Save reachable host for ${e}`,title:`Save reachable host`,className:`inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1.5 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed`,children:[u?z(U,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):z(H,{className:`h-3 w-3`,"aria-hidden":`true`}),`Save`]}),!f&&!u&&r===`success`&&z(H,{className:`h-3.5 w-3.5 shrink-0 text-emerald-400`,"aria-label":`Saved`,role:`img`}),r===`error`&&z(`span`,{title:i??`Failed to save reachable host`,children:z(Ge,{className:`h-3.5 w-3.5 shrink-0 text-red-400`,"aria-label":i??`Failed to save reachable host`,role:`img`})})]})}function wn({label:e,children:t}){return P(`div`,{className:`flex items-center justify-between gap-3`,children:[z(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-foreground-subtle`,children:e}),t]})}function Tn({node:e,actions:t}){return P(`div`,{className:`rounded-xl border border-border bg-background p-4 space-y-4 ${e.isOnline?``:`opacity-60`}`,children:[z(Sn,{node:e,emphasis:!0}),z(`div`,{className:`grid grid-cols-2 gap-2`,children:ln.map(n=>z(xn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:vn(e.effective,n.key),pending:t.capabilityPending,layout:`card`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)},n.key))}),z(`div`,{className:`space-y-3 border-t border-border pt-3`,children:z(wn,{label:`Reachable host`,children:z(Cn,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,status:t.reachableHostStatus(e.id),errorMessage:t.reachableHostErrorMessage(e.id),onCommit:t.onCommitReachableHost})})})]})}function En(){return P(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-foreground-subtle`,children:[P(`span`,{className:`inline-flex items-center gap-1.5`,children:[z(`span`,{className:`h-2.5 w-2.5 rounded-full border border-success/30 bg-success/15`}),`Active capability`]}),P(`span`,{className:`inline-flex items-center gap-1.5`,children:[z(`span`,{className:`h-2.5 w-2.5 rounded-full border border-border bg-surface-hover`}),`Idle`]}),P(`span`,{className:`inline-flex items-center gap-1.5`,children:[z(`span`,{className:`h-2 w-2 rounded-full bg-success`}),`Node online`]}),P(`span`,{className:`inline-flex items-center gap-1.5`,children:[z(`span`,{className:`h-2 w-2 rounded-full bg-danger`}),`Node offline`]})]})}function Dn({nodes:e,actions:t}){return z(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:P(`table`,{className:`w-full min-w-[720px] border-collapse text-sm`,children:[z(`thead`,{children:P(`tr`,{className:`border-b border-border bg-background text-[10px] uppercase tracking-wider text-foreground-subtle`,children:[z(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Node`}),ln.map(e=>z(`th`,{className:`px-3 py-3 text-center font-semibold`,children:e.label},e.key)),z(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Reachable host`})]})}),z(`tbody`,{children:e.map(e=>P(`tr`,{className:`border-b border-border last:border-b-0 transition-colors hover:bg-surface-hover/40 ${e.isOnline?``:`opacity-60`}`,children:[z(`td`,{className:`px-4 py-3 align-middle`,children:z(Sn,{node:e})}),ln.map(n=>z(`td`,{className:`px-3 py-3 text-center align-middle`,children:z(xn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:vn(e.effective,n.key),pending:t.capabilityPending,layout:`cell`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)})},n.key)),z(`td`,{className:`px-4 py-3 align-middle`,children:z(Cn,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,status:t.reachableHostStatus(e.id),errorMessage:t.reachableHostErrorMessage(e.id),onCommit:t.onCommitReachableHost})})]},e.id))})]})})}function On({role:e,value:t,options:n,pending:r,onChange:i}){return P(`label`,{className:`flex flex-col gap-1.5 rounded-lg border border-border bg-background p-3`,children:[z(`span`,{className:`text-xs font-semibold text-foreground`,children:gn(e)}),z(`select`,{value:t,disabled:r,onChange:t=>i(e,t.target.value),className:`rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,children:n.map(e=>z(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),z(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:_n(e)})]})}function kn({roleValues:e,options:t,pending:n,lowFpsEnabled:r,fpsMinThreshold:i,onRoleChange:a,onLowFpsToggle:o}){return P(`div`,{className:`grid gap-3 @lg/clustertab:grid-cols-2 @3xl/clustertab:grid-cols-4`,children:[cn.map(r=>z(On,{role:r,value:e[r],options:t,pending:n,onChange:a},r)),P(`label`,{className:`flex items-start gap-2.5 rounded-lg border border-border bg-background p-3 text-sm text-foreground`,children:[z(`input`,{type:`checkbox`,checked:r,disabled:n,onChange:e=>o(e.target.checked),className:`mt-0.5 h-4 w-4 shrink-0 accent-primary`}),P(`span`,{className:`flex flex-col gap-0.5`,children:[z(`span`,{className:`text-xs font-semibold`,children:`Low-fps relocate/shed`}),P(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:[`fpsMinThreshold `,r?`${i} fps`:`disabled`]})]})]})]})}N();function An(){let e=L(),{nodes:t}=u(),n=ge(void 0),i=fe({addonId:an}),a=fe({addonId:on}),o=()=>bn(e),s=me({onSuccess:o}),c=b(),l=r({onSuccess:o}),d=A({onSuccess:o}),[f,p]=R(!1),m=F(()=>{let e=new Map;for(let t of n.data??[])e.set(t.nodeId,t.settings);return e},[n.data]),h=F(()=>t.map(e=>{let t=m.get(e.id),n=dt(t,e.isHub),r=mn(t,`detectWeight`);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n,weight:r??1,maxCameras:mn(t,`maxCameras`),reachableHost:hn(t,`reachableHost`),detectedHosts:e.localIps}}),[t,m]),g=h.filter(e=>e.effective.pipeline),_={ingestNode:fn(i.data,`ingestNode`,`hub`),recordingNode:fn(a.data,sn,`hub`),audioNode:fn(i.data,`audioNode`,`hub`),motionNode:fn(i.data,`motionNode`,`hub`)},v=F(()=>{let e=t.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,...cn.map(e=>_[e]),...e])].filter(e=>e.length>0)},[t,_]),y=pn(i.data,`fpsMinThreshold`,0),x=y>0,S=n.isLoading||i.isLoading||a.isLoading,C=(e,t,n)=>{s.mutate({agentNodeId:e,[t]:n})},w=(e,t)=>{if(e===`recordingNode`){d.mutate({addonId:on,patch:{[sn]:t}});return}d.mutate({addonId:an,patch:{[e]:t}})},T=e=>{d.mutate({addonId:an,patch:{fpsMinThreshold:e?Math.max(1,y):0}})},E=e=>l.variables?.agentNodeId===e?l.isPending?`pending`:l.isError?`error`:l.isSuccess?`success`:`idle`:`idle`,D=e=>E(e)===`error`?yn(l.error):null,O=async e=>{p(!0);try{for(let t of e)await c.mutateAsync({agentNodeId:t.nodeId,detectWeight:t.weight})}finally{p(!1),o()}},k={capabilityPending:s.isPending,onToggleCapability:C,onCommitReachableHost:(e,t)=>l.mutate({agentNodeId:e,reachableHost:t}),reachableHostStatus:E,reachableHostErrorMessage:D};return P(`section`,{className:`rounded-xl border border-border bg-surface p-5 @3xl/clustertab:p-6 space-y-6`,children:[P(`header`,{className:`flex items-start justify-between gap-4`,children:[P(`div`,{className:`space-y-1`,children:[z(`h3`,{className:`text-base font-semibold text-foreground`,children:`Pipeline placement`}),z(`p`,{className:`max-w-prose text-xs leading-relaxed text-foreground-subtle`,children:`Toggle which node runs each pipeline capability, distribute detection weight across detect-capable nodes, and choose the singleton cluster roles.`})]}),S&&z(U,{className:`h-5 w-5 shrink-0 animate-spin text-foreground-subtle`,"aria-label":`Loading`})]}),P(`div`,{className:`space-y-3`,children:[z(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Singleton cluster roles`}),z(kn,{roleValues:_,options:v,pending:d.isPending,lowFpsEnabled:x,fpsMinThreshold:y,onRoleChange:w,onLowFpsToggle:T})]}),P(`div`,{className:`space-y-3`,children:[P(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[z(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Per-node capabilities`}),z(En,{})]}),h.length===0?z(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No cluster nodes reporting yet.`}):P(I,{children:[z(`div`,{className:`grid gap-4 @xl/clustertab:grid-cols-2 @3xl/clustertab:hidden`,children:h.map(e=>z(Tn,{node:e,actions:k},e.id))}),z(`div`,{className:`hidden @3xl/clustertab:block`,children:z(Dn,{nodes:h,actions:k})})]})]}),P(`div`,{className:`space-y-3`,children:[z(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Detection weight`}),z(Te,{nodes:g,pending:f,onCommitWeights:e=>void O(e)})]}),P(`div`,{className:`space-y-3`,children:[z(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Inference devices`}),g.length===0?z(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No detect-capable nodes — enable detection on a node above to configure its accelerators.`}):z(`div`,{className:`space-y-2`,children:g.map(e=>z(De,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline},e.id))})]})]})}N();var jn=!1;function Mn({refreshToken:e}){let t=L(),{data:n}=c(void 0);F(()=>et(n??[]),[n]);let r=he({onSuccess:()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})}});return P(`div`,{className:`space-y-6`,children:[z(ht,{refreshToken:e}),z(An,{}),jn,P(`div`,{className:`flex flex-col gap-3 @md/clustertab:flex-row @md/clustertab:items-center @md/clustertab:justify-between`,children:[P(`div`,{className:`min-w-0`,children:[z(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Rebalance`}),z(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Recompute the optimal node for every assigned camera from current load + hardware affinity, and migrate the ones no longer on their best node. Pinned cameras never move.`})]}),P(`button`,{type:`button`,onClick:()=>r.mutate(void 0),disabled:r.isPending,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-white hover:bg-primary/90 disabled:opacity-50 shrink-0 self-start @md/clustertab:self-auto whitespace-nowrap`,children:[z(Me,{className:`h-3.5 w-3.5`}),r.isPending?`Rebalancing…`:`Rebalance pipelines`]})]})]})}var Nn=[`pipeline-orchestrator`];function Pn({refreshToken:e}){return z(`div`,{className:`space-y-4 max-w-3xl`,children:z(nt,{nodeId:`hub`,addonIds:Nn,level:`global`,title:`Cluster settings`,description:`Cluster-wide orchestration knobs: enabled nodes, load balancer thresholds, and failover policy. Per-camera pipelines live in Device Overrides; live cluster load is on the Assignments tab.`})})}N();function Fn({refreshToken:e}){let t=L(),{data:n,isLoading:r}=E(),[i,a]=R(null),[s,c]=R(``),[l,u]=R(``),d=()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listTemplates`]]})},f=o({onSuccess:()=>{a(null),d()}}),p=D({onSuccess:d}),m=e=>{a(e.id),c(e.name),u(e.description??``)},h=()=>{a(null),c(``),u(``)},g=()=>{if(!i)return;let e=l.trim();f.mutate({id:i,name:s.trim()||`Untitled`,...e?{description:e}:{}})};if(r)return z(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading templates…`});let _=[...n??[]].toSorted((e,t)=>e.name.localeCompare(t.name));return z(`div`,{className:`space-y-6 max-w-4xl`,children:P(`section`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[P(`div`,{className:`border-b border-border px-4 py-3 flex items-center justify-between`,children:[P(`div`,{children:[z(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Templates`}),z(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:`Curated pipeline presets operators can apply to any camera. Apply-time is a copy — future edits to a template don't retroactively change cameras that were seeded from it. Save a template from the device Pipeline tab.`})]}),P(`div`,{className:`text-[11px] text-foreground-subtle`,children:[_.length,` template`,_.length===1?``:`s`]})]}),_.length===0?P(`div`,{className:`px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2`,children:[z(Pe,{className:`h-6 w-6 opacity-40`}),z(`div`,{children:`No templates yet. Create one from a device Pipeline tab ("Save as template").`})]}):z(`ul`,{className:`divide-y divide-border`,children:_.map(e=>{let t=i===e.id;return z(`li`,{className:`px-4 py-3 text-xs`,children:P(`div`,{className:`flex items-start gap-3`,children:[z(`div`,{className:`flex-1 min-w-0`,children:t?P(`div`,{className:`space-y-2`,children:[z(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`,value:s,onChange:e=>c(e.target.value),placeholder:`Template name`,autoFocus:!0}),z(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary`,value:l,onChange:e=>u(e.target.value),placeholder:`Description (optional)`})]}):P(I,{children:[z(`div`,{className:`font-medium text-foreground`,children:e.name}),e.description&&z(`div`,{className:`text-foreground-subtle mt-0.5`,children:e.description}),P(`div`,{className:`mt-1 font-mono text-[10px] text-foreground-subtle`,children:[e.config.steps.length,` step(s)`,e.config.audio?.enabled?` · audio`:``,P(`span`,{className:`ml-2`,children:[`updated `,new Date(e.updatedAt).toLocaleString()]})]})]})}),z(`div`,{className:`flex items-center gap-1 shrink-0`,children:t?P(I,{children:[P(`button`,{type:`button`,onClick:g,disabled:f.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-50`,children:[z(H,{className:`h-3 w-3`}),`Save`]}),P(`button`,{type:`button`,onClick:h,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover`,children:[z(Ye,{className:`h-3 w-3`}),`Cancel`]})]}):P(I,{children:[z(`button`,{type:`button`,onClick:()=>m(e),title:`Rename`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,children:z(Ne,{className:`h-3 w-3`})}),z(`button`,{type:`button`,onClick:()=>{confirm(`Delete template "${e.name}"?`)&&p.mutate({id:e.id})},disabled:p.isPending,title:`Delete`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-red-400 hover:bg-surface-hover disabled:opacity-50`,children:z(Ze,{className:`h-3 w-3`})})]})})]})},e.id)})})]})})}N();var In=`pipeline-analytics`;function Ln(e){for(let t of e?.sections??[])for(let e of t.fields??[])if(e.key===`postProcessingNodeId`&&typeof e.value==`string`)return e.value;return`hub`}function Rn(){let e=L(),{data:t}=c(void 0),{data:n,isLoading:r}=fe({addonId:In}),i=Ln(n),a=A({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),o=F(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,i,...e])].filter(Boolean)},[t,i]);return P(`div`,{className:`flex flex-col gap-6`,children:[P(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[z(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Post-processing node`}),z(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that runs detection post-processing (events, media, audio & motion). Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),P(`div`,{className:`mt-3 flex items-center gap-2`,children:[r?z(U,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):z(`select`,{value:i,onChange:e=>{e.target.value!==i&&a.mutate({addonId:In,patch:{postProcessingNodeId:e.target.value}})},disabled:a.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:o.map(e=>z(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),a.isPending&&z(U,{className:`h-4 w-4 animate-spin text-primary`})]})]}),P(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[z(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Events folder`}),z(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`}),z(rt,{types:[`eventMedia`]})]})]})}var zn=`pipeline-orchestrator`,Bn=200;function Vn(){return P(`div`,{className:`flex flex-col gap-3`,children:[P(`div`,{children:[z(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Orchestrator logs`}),z(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Dispatch decisions, balancer moves and failover events from the pipeline orchestrator. Streaming live; the device chip on a line tells which camera it refers to.`})]}),z(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:z(j,{addonId:zn,limit:Bn,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}N();var Hn=[{id:`assignments`,label:`Assignments`},{id:`balancer`,label:`Balancer`},{id:`events`,label:`Events`},{id:`recording`,label:`Recording`},{id:`settings`,label:`Settings`},{id:`templates`,label:`Templates`},{id:`logs`,label:`Logs`}];function Un({refreshToken:e}){let[t,n]=R(`assignments`);return P(`div`,{className:`flex flex-col h-full`,children:[P(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[z(`h2`,{className:`text-base font-semibold text-foreground`,children:`Cluster Orchestration`}),z(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:`Per-camera assignments, the load balancer (live load + inference-device weights), cluster-wide settings, and the pipeline template library.`})]}),z(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:Hn.map(e=>z(`button`,{type:`button`,onClick:()=>n(e.id),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${t===e.id?`border-primary text-primary`:`border-transparent text-foreground-subtle hover:text-foreground`}`,children:e.label},e.id))}),P(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[t===`assignments`&&z(rn,{}),t===`balancer`&&z(Mn,{refreshToken:e}),t===`events`&&z(Rn,{}),t===`recording`&&z(it,{}),t===`settings`&&z(Pn,{refreshToken:e}),t===`templates`&&z(Fn,{refreshToken:e}),t===`logs`&&z(Vn,{})]})]})}function Wn(e){let t=[],n=[],{assignment:r,detection:i,decoder:a,broker:o}=e;i!==null&&i.provisioning.state===`failed`&&t.push({code:`provisioning-failed`,severity:`error`,message:i.provisioning.error!==void 0&&i.provisioning.error.length>0?`Engine provisioning failed: ${i.provisioning.error}`:`Engine provisioning failed on the detection node`}),i!==null&&i.phase===`active`&&i.actualFps===0&&t.push({code:`detection-black-hole`,severity:`error`,message:`Detection phase is ACTIVE but 0 fps are being processed — frames are not reaching the detector (cross-node black-hole signature)`}),i!==null&&i.phase===`active`&&a!==null&&a.shm.framesWritten===0&&t.push({code:`decoder-black-hole`,severity:`error`,message:`Decoder on ${a.nodeId} has written 0 frames to the shared-memory plane while detection is active — the decode path is stalled`}),r.detectionNodeId===null&&i===null&&n.push({code:`unassigned`,severity:`warning`,message:`Not placed on any detection node — no pipeline is running for this camera`});for(let e of o?.profiles??[])e.status===`streaming`&&e.inFps===0&&n.push({code:`broker-stalled`,severity:`warning`,message:`Broker profile "${e.profile}" reports streaming but 0 in-fps — the source pull may be stalled`});return[...t,...n]}function Gn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e){return typeof e==`string`&&e.length>0?e:null}function Kn(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function qn(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Jn(e,t){return e==null?!1:JSON.stringify(e)!==JSON.stringify(t??null)}var Yn={detectionMode:null,detectionStreamProfile:null,detectionFps:null,motionSources:[],motionFps:null,motionCooldownMs:null,motionStreamProfile:null,audioMode:null,pipelineNodeId:null,decoderNodeId:null,audioNodeId:null,overriddenKeys:new Set};function Xn(e){if(!Gn(e)||!Array.isArray(e.sections))return Yn;let t=be(e),n=e=>{let n=t.get(e);if(n!==void 0)return n.value??n.default},r=new Set;for(let[e,n]of t)Jn(n.value,n.default)&&r.add(e);return{detectionMode:Y(n(`detectionMode`)),detectionStreamProfile:Y(n(`detectionStreamProfile`)),detectionFps:Kn(n(`detectionFps`)),motionSources:qn(n(`motionSources`)),motionFps:Kn(n(`motionFps`)),motionCooldownMs:Kn(n(`motionCooldownMs`)),motionStreamProfile:Y(n(`motionStreamProfile`)),audioMode:Y(n(`audioMode`)),pipelineNodeId:Y(n(`pipelineNodeId`)),decoderNodeId:Y(n(`decoderNodeId`)),audioNodeId:Y(n(`audioNodeId`)),overriddenKeys:r}}function Zn(e,t=0){let n=[];for(let r of e)n.push({addonId:r.addonId,modelId:r.modelId??null,enabled:r.enabled,depth:t}),r.children!==void 0&&r.children.length>0&&n.push(...Zn(r.children,t+1));return n}function Qn(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}function X({title:e,children:t}){return P(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[z(`div`,{className:`text-[9px] font-semibold uppercase tracking-[0.14em] text-foreground-subtle mb-2`,children:e}),z(`div`,{className:`flex flex-col gap-1 min-w-0`,children:t})]})}function Z({label:e,children:t,overridden:n=!1}){return P(`div`,{className:`flex items-baseline gap-2 text-[11px] leading-snug min-w-0`,children:[z(`span`,{className:`text-foreground-subtle shrink-0 w-24 truncate`,title:e,children:e}),z(`span`,{className:`font-mono tabular-nums text-foreground min-w-0 truncate flex-1`,children:t}),n&&z($n,{})]})}function $n(){return z(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0 self-center`,title:`Device-level override active`,"aria-label":`Device-level override active`,role:`img`})}var er={neutral:`border-border text-foreground-muted`,success:`border-success/40 text-success`,warning:`border-warning/40 text-warning`,danger:`border-danger/40 text-danger`,info:`border-info/40 text-info`};function Q({tone:e=`neutral`,children:t,title:n}){return z(`span`,{title:n,className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-medium leading-tight whitespace-nowrap ${er[e]}`,children:t})}function $({children:e}){return z(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function tr({icon:e,label:t,nodeId:n,pinned:r,reason:i,overridden:a}){return P(`div`,{className:`flex items-center gap-2 text-[11px] leading-snug min-w-0`,children:[z(e,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),z(`span`,{className:`text-foreground-subtle w-[4.5rem] shrink-0`,children:t}),n===null?z(`span`,{className:`text-foreground-subtle italic`,children:`unassigned`}):P(I,{children:[z(`span`,{className:`font-mono text-foreground truncate`,title:n,children:n}),r?P(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:`Manually pinned`,children:[z(st,{className:`h-2.5 w-2.5`}),` manual`]}):P(`span`,{className:`text-[10px] text-foreground-subtle shrink-0 truncate`,children:[`auto · `,i!==void 0&&i.length>0?i:`capacity`]}),a&&z(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0`,title:`Persisted settings pin for this role`})]})]})}function nr({assignment:e,settings:t,onlineNodes:n,pinPending:r,onDetectionPinChange:i}){let a=e.pinned.detection&&e.detectionNodeId!==null?e.detectionNodeId:`auto`,o=[...new Set([...e.detectionNodeId===null?[]:[e.detectionNodeId],...n.map(e=>e.id)])];return P(X,{title:`Where it runs`,children:[z(tr,{icon:W,label:`Detection`,nodeId:e.detectionNodeId,pinned:e.pinned.detection,reason:e.reasons.detection,overridden:t.overriddenKeys.has(`pipelineNodeId`)}),z(tr,{icon:Ve,label:`Decoder`,nodeId:e.decoderNodeId,pinned:e.pinned.decoder,reason:e.reasons.decoder,overridden:t.overriddenKeys.has(`decoderNodeId`)}),z(tr,{icon:je,label:`Audio`,nodeId:e.audioNodeId,pinned:e.pinned.audio,reason:e.reasons.audio,overridden:t.overriddenKeys.has(`audioNodeId`)}),z(tr,{icon:Fe,label:`Source`,nodeId:e.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),z(`div`,{className:`mt-1.5`,children:P(`select`,{value:a,disabled:r,"aria-label":`Detection placement pin`,onChange:e=>i(e.target.value),className:`w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-[11px] text-foreground disabled:opacity-50`,children:[z(`option`,{value:`auto`,children:`Auto (load balanced)`}),o.map(e=>P(`option`,{value:e,children:[`Pin detection → `,n.find(t=>t.id===e)?.name??e]},e))]})})]})}function rr(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function ir(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function ar(e){return e===null?`default`:e===0?`native (no throttle)`:`${e} fps`}function or({streams:e,brokerProfiles:t,settings:n,motionEnabled:r,motionFpsLive:i}){let a=ir(t,n.detectionStreamProfile),o=ir(t,n.motionStreamProfile),s=n.motionSources.includes(`analyzer`);return P(X,{title:`Streams & motion`,children:[P(Z,{label:`Detect stream`,overridden:n.overriddenKeys.has(`detectionStreamProfile`),children:[n.detectionStreamProfile??`—`,a!==void 0&&` · ${a.width}×${a.height} ${a.codec}`]}),z(Z,{label:`Detect FPS`,overridden:n.overriddenKeys.has(`detectionFps`),children:ar(n.detectionFps)}),P(Z,{label:`Motion src`,overridden:n.overriddenKeys.has(`motionSources`),children:[n.motionSources.length>0?n.motionSources.join(` + `):`none`,r===!1&&` · inactive`]}),s&&P(I,{children:[P(Z,{label:`Motion stream`,overridden:n.overriddenKeys.has(`motionStreamProfile`),children:[n.motionStreamProfile??`—`,o!==void 0&&` · ${o.width}×${o.height} ${o.codec}`]}),P(Z,{label:`Motion FPS`,overridden:n.overriddenKeys.has(`motionFps`),children:[ar(n.motionFps),i!==null&&` · live ${i.toFixed(1)}`]})]}),z(Z,{label:`Cooldown`,overridden:n.overriddenKeys.has(`motionCooldownMs`),children:n.motionCooldownMs===null?`default`:`${n.motionCooldownMs/1e3}s`}),z(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:e.length===0?z($,{children:`No streams registered`}):e.map(e=>P(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:e.camStreamId,children:[z(`span`,{className:`text-foreground-muted`,children:e.kind}),` `,rr(e)]},e.camStreamId))})]})}function sr({steps:e,audioModelId:t,audioEnabled:n,audioMode:r}){return P(X,{title:`Pipeline steps`,children:[e===void 0?z($,{children:`Resolving…`}):e.length===0?z($,{children:`No steps configured`}):z(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>z(Q,{tone:e.enabled&&e.depth===0?`info`:`neutral`,title:e.modelId??e.addonId,children:P(`span`,{className:e.enabled?``:`line-through opacity-60`,children:[e.depth>0&&z(`span`,{className:`opacity-50`,children:`↳ `}),e.addonId,e.modelId!==null&&P(`span`,{className:`font-mono opacity-75`,children:[` · `,e.modelId]})]})},`${e.addonId}-${t}`))}),z(`div`,{className:`mt-1`,children:P(Z,{label:`Audio class.`,children:[r??`—`,n!==null&&(n?` · running`:` · off`),t!==null&&` · ${t}`]})})]})}var cr={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function lr({detection:e,live:t,detectionMode:n,modeOverridden:r}){if(e===null)return P(X,{title:`Detection runtime`,children:[z(Z,{label:`Mode`,overridden:r,children:n??`—`}),z($,{children:`Detection stage inactive or unreachable`})]});let i=t?.phase??e.phase,a=t?.actualFps??e.actualFps,o=t?.configuredFps??e.configuredFps,s=t?.avgInferenceTimeMs??e.avgInferenceMs,c=t?.queueDepth??e.queueDepth,l=p(i),u=i===`active`&&a===0;return P(X,{title:`Detection runtime`,children:[P(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[P(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider ${l.badgeClass}`,children:[z(C,{phase:i,className:`h-2.5 w-2.5`}),l.label]}),t!==void 0&&z(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:`live`})]}),z(Z,{label:`Mode`,overridden:r,children:n??`—`}),P(Z,{label:`FPS`,children:[z(`span`,{className:u?`text-danger font-semibold`:``,children:a.toFixed(1)}),P(`span`,{className:`text-foreground-subtle`,children:[` / `,o.toFixed(0),` configured`]})]}),P(Z,{label:`Inference`,children:[s.toFixed(0),` ms`,c>0&&P(`span`,{className:`text-warning`,children:[` · queue `,c]}),t!==void 0&&t.droppedFrames>0&&P(`span`,{className:`text-warning`,children:[` · drops `,t.droppedFrames]})]}),P(Z,{label:`Engine`,children:[e.engine.backend,` · `,e.engine.device]}),P(Z,{label:`Provisioning`,children:[z(Q,{tone:cr[e.provisioning.state]??`neutral`,children:e.provisioning.state}),e.provisioning.error!==void 0&&P(`span`,{className:`text-danger text-[10px]`,children:[` `,e.provisioning.error]})]})]})}function ur({broker:e}){return e===null?z(X,{title:`Stream broker`,children:z($,{children:`Broker stage inactive or unreachable`})}):P(X,{title:`Stream broker`,children:[e.profiles.length===0?z($,{children:`No broker profiles`}):z(`div`,{className:`flex flex-col gap-1`,children:e.profiles.map(e=>{let t=e.status===`streaming`,n=t&&e.inFps===0;return P(`div`,{className:`flex items-center gap-2 text-[11px] font-mono tabular-nums min-w-0`,children:[z(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full shrink-0 ${n?`bg-danger`:t?`bg-success animate-pulse`:`bg-border`}`,title:e.status}),z(`span`,{className:`text-foreground w-10 shrink-0 truncate`,title:e.profile,children:e.profile}),P(`span`,{className:`text-foreground-subtle truncate`,children:[e.width,`×`,e.height,` `,e.codec]}),P(`span`,{className:`ml-auto shrink-0 ${n?`text-danger`:`text-foreground`}`,children:[e.inFps.toFixed(0),`→`,e.outFps.toFixed(0),`fps`]}),P(`span`,{className:`text-foreground-subtle shrink-0`,title:`Subscribers`,children:[`×`,e.subscribers]})]},e.profile)})}),P(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[P(Q,{tone:e.webrtcSessions>0?`info`:`neutral`,children:[`WebRTC `,e.webrtcSessions]}),P(Q,{tone:e.rtspRestream?`success`:`neutral`,children:[`restream `,e.rtspRestream?`on`:`off`]})]})]})}function dr({decoder:e,detectionActive:t}){if(e===null)return z(X,{title:`Decoder`,children:z($,{children:`Decoder stage inactive or unreachable`})});let n=t&&e.shm.framesWritten===0;return P(X,{title:`Decoder`,children:[z(Z,{label:`Node`,children:e.nodeId}),z(Z,{label:`Sessions`,children:e.sessionCount}),P(Z,{label:`SHM frames`,children:[z(`span`,{className:n?`text-danger font-semibold`:``,children:e.shm.framesWritten}),z(`span`,{className:`text-foreground-subtle`,children:` written`})]}),P(Z,{label:`SHM reads`,children:[e.shm.getFrameHits,` hits`,e.shm.getFrameMisses>0&&P(`span`,{className:`text-warning`,children:[` · `,e.shm.getFrameMisses,` misses`]})]}),P(Z,{label:`SHM budget`,children:[e.shm.budgetMb,` MB`]}),e.formats.length>0&&z(Z,{label:`Formats`,children:e.formats.join(`, `)})]})}N();var fr=`pipeline-orchestrator`,pr={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},mr={healthy:`Healthy`,idle:`Idle`,error:`Error`};function hr({problems:e}){return z(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:e.map(e=>P(`div`,{className:`flex items-start gap-2 px-4 py-1.5 text-[11px] font-medium ${e.severity===`error`?`bg-danger/10 text-danger`:`bg-warning/10 text-warning`}`,children:[z(Xe,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),z(`span`,{className:`min-w-0`,children:e.message})]},e.code))})}function gr({deviceId:e,name:t,online:r,status:i,live:a,onlineNodes:o}){let s=L(),{data:c}=M({addonId:fr,deviceId:e,nodeId:`hub`},{staleTime:3e4}),{data:l}=n({deviceId:e},{staleTime:3e4}),u=F(()=>Xn(c),[c]),d=F(()=>l===void 0?void 0:Zn(l.steps),[l]),f=F(()=>i===void 0?[]:Wn(i),[i]),p=()=>{s.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),s.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},m=ce({onSuccess:p}),h=g({onSuccess:p}),_=t=>{t===`auto`?h.mutate({deviceId:e}):m.mutate({deviceId:e,agentNodeId:t})},v=i===void 0?`idle`:Qn(i),y=f.some(e=>e.severity===`error`),b=f.length>0,x=y?`border-danger/50`:b?`border-warning/40`:`border-border`;return P(`article`,{"aria-label":`${t} pipeline status`,className:`rounded-lg border ${x} bg-background overflow-hidden`,children:[P(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[z(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${y?`bg-danger`:pr[v]}`,title:y?`Error`:mr[v],"aria-label":y?`Error`:mr[v],role:`img`}),z(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:t,children:t}),P(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,e]}),!r&&z(Q,{tone:`danger`,children:`offline`}),P(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[u.detectionMode!==null&&z(Q,{tone:u.detectionMode===`disabled`?`warning`:u.detectionMode===`always-on`?`info`:`neutral`,title:`Object detection mode`,children:u.detectionMode===`disabled`?`detection off`:u.detectionMode}),i?.recording!=null&&(i.recording.active?P(Q,{tone:`danger`,title:`Recording (${i.recording.mode})`,children:[z(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):i.recording.mode!==`off`&&P(Q,{tone:`neutral`,title:`Recording mode`,children:[`rec `,i.recording.mode]}))]})]}),f.length>0&&z(hr,{problems:f}),i===void 0?z(`div`,{className:`px-4 py-5 text-[11px] text-foreground-subtle italic`,children:`No pipeline status yet — the orchestrator has not composed a snapshot for this camera.`}):P(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[z(nr,{assignment:i.assignment,settings:u,onlineNodes:o,pinPending:m.isPending||h.isPending,onDetectionPinChange:_}),z(lr,{detection:i.detection,live:a,detectionMode:u.detectionMode,modeOverridden:u.overriddenKeys.has(`detectionMode`)}),z(sr,{steps:d,audioModelId:l?.audio?.modelId??null,audioEnabled:i.audio?.enabled??l?.audio?.enabled??null,audioMode:u.audioMode}),z(or,{streams:i.source.streams,brokerProfiles:i.broker?.profiles,settings:u,motionEnabled:i.motion?.enabled??null,motionFpsLive:i.motion?.fps??null}),z(ur,{broker:i.broker}),z(dr,{decoder:i.decoder,detectionActive:i.detection?.phase===`active`})]})]})}N();var _r=5e3,vr=1e4,yr=5e3;function br(e){let t=L(),{data:n,isLoading:r}=we(),{data:i,isLoading:a}=k({},{refetchInterval:_r}),{nodes:o}=u();B(()=>{e!==0&&t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,t]);let[s,c]=R(new Map);x(xe.PipelineCameraMetricsSnapshot,e=>{let t=e.data;typeof t.deviceId==`number`&&c(e=>{let n=new Map(e);return n.set(t.deviceId,{phase:t.metrics.phase,configuredFps:t.metrics.configuredFps,actualFps:t.metrics.actualFps,queueDepth:t.metrics.queueDepth,avgInferenceTimeMs:t.metrics.avgInferenceTimeMs,droppedFrames:t.metrics.droppedFrames,timestamp:t.timestamp}),n})}),B(()=>{if(s.size===0)return;let e=setInterval(()=>{c(e=>{let t=Date.now()-vr,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},yr);return()=>clearInterval(e)},[s.size]);let l=F(()=>{let e=new Map;for(let t of i??[])e.set(t.deviceId,t);return e},[i]);return{rows:F(()=>(n??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,online:e.online,status:l.get(e.id)})).sort((e,t)=>e.name.localeCompare(t.name)),[n,l]),liveMetrics:s,onlineNodes:F(()=>(o??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[o]),isLoading:r||a}}N();function xr({refreshToken:e}){let{rows:t,liveMetrics:n,onlineNodes:r,isLoading:i}=br(e),a=F(()=>[...t.map(e=>{let t=e.status===void 0?[]:Wn(e.status);return{row:e,errorCount:t.filter(e=>e.severity===`error`).length,warningCount:t.filter(e=>e.severity===`warning`).length}})].sort((e,t)=>e.errorCount===t.errorCount?e.warningCount===t.warningCount?0:t.warningCount-e.warningCount:t.errorCount-e.errorCount),[t]),o=F(()=>{let e=0,t=0;for(let r of a)(r.errorCount>0||r.warningCount>0)&&(t+=1),(n.get(r.row.deviceId)?.phase??r.row.status?.detection?.phase)===`active`&&(e+=1);return{total:a.length,active:e,issues:t}},[a,n]);return i&&t.length===0?z(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`Loading camera pipelines…`}):t.length===0?z(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`No cameras found`}):z(`div`,{className:`h-full overflow-y-auto`,children:P(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[P(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[P(`span`,{children:[z(`span`,{className:`font-semibold text-foreground`,children:o.total}),` cameras`]}),P(`span`,{children:[z(`span`,{className:`font-semibold text-success`,children:o.active}),` actively inferring`]}),P(`span`,{children:[z(`span`,{className:`font-semibold ${o.issues>0?`text-danger`:`text-foreground`}`,children:o.issues}),` `,`with issues`]}),z(`span`,{className:`ml-auto hidden sm:inline text-[10px]`,children:`polled every 5 s · detection metrics live at 1 Hz`})]}),a.map(({row:e})=>z(gr,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:n.get(e.deviceId),onlineNodes:r},e.deviceId))]})})}N();var Sr=`__cluster__`;function Cr(e){return e===`cameras`?`cameras`:`nodes`}function wr(){let[e,t]=Ue(),n=Cr(e.get(`view`)),r=e.get(`node`)??`__cluster__`,[i,a]=R(0),[o,s]=R(!1);return B(()=>{n===`nodes`&&!e.get(`node`)&&t({view:`nodes`,node:Sr},{replace:!0})},[n,e,t]),P(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[P(`div`,{className:`flex items-center justify-between gap-4 px-4 py-3 border-b border-border shrink-0`,children:[P(`div`,{className:`flex items-center gap-1 rounded-lg border border-border p-0.5 bg-surface`,children:[z(`button`,{type:`button`,onClick:()=>{t({view:`nodes`,node:r},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Nodes`}),z(`button`,{type:`button`,onClick:()=>{t({view:`cameras`},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Cameras`})]}),P(`button`,{type:`button`,onClick:()=>a(e=>e+1),title:`Refresh`,className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[z(Ie,{className:`h-3.5 w-3.5`}),`Refresh`]})]}),n===`nodes`&&P(`button`,{type:`button`,onClick:()=>s(e=>!e),"aria-expanded":o,className:`md:hidden flex items-center justify-between gap-2 px-4 py-2 border-b border-border shrink-0 text-[11px] font-medium text-foreground-subtle hover:text-foreground transition-colors`,children:[P(`span`,{children:[o?`Hide`:`Show`,` node list`]}),z(He,{className:[`h-4 w-4 transition-transform`,o?`rotate-180`:``].join(` `)})]}),z(`div`,{className:`flex-1 flex flex-col md:flex-row overflow-hidden min-h-0`,children:n===`nodes`?P(I,{children:[z(`aside`,{className:[o?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border`,`max-h-[60vh] md:max-h-none overflow-y-auto`].join(` `),children:z(pt,{selectedNodeId:r,onSelect:e=>{t({view:`nodes`,node:e},{replace:!0}),s(!1)},refreshToken:i})}),z(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:r===`__cluster__`?z(Un,{refreshToken:i}):z(nn,{nodeId:r,refreshToken:i})})]}):z(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:z(xr,{refreshToken:i})})})]})}export{wr as PipelinePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$i as e,Ha as t,Ja as n,Mn as r,Qi as i,Wa as a,Wr as o,Xr as s,Zr as c,ea as l,ia as u,na as d,qr as f,ra as p,ro as m,ta as h}from"./src-D49drDQI.js";import{I as g,Q as _,S as v,W as y,o as b,q as x,x as S,z as C}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{K as w}from"./src-PXZvyYDe.js";import{o as T,p as E}from"./player-overlays-5vIS4o_W.js";import{t as D}from"./download-BARV2Xt2.js";import{i as O}from"./AddLocationWizard-B_z3eUPS.js";import{A as k,E as A,S as j,U as M,W as N,s as P}from"./index-DcoBSPD8.js";import{t as F}from"./AdminPage-Dq33XE9j.js";import{n as I}from"./authed-media-XfBD4Ma-.js";import{t as L}from"./format-size-CO9d3C3-.js";import{t as ee}from"./ClusterRecordingTab-z1xB2po9.js";import{t as R}from"./AdminTabs-6yXsZXxy.js";var z=N(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),B=N(`scissors`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M8.12 8.12 12 12`,key:`1alkpv`}],[`path`,{d:`M20 4 8.12 15.88`,key:`xgtan2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M14.8 14.8 20 20`,key:`ptml3r`}]]);_();function V(e){let t=[];return e.timelapse?t.push(`timelapse ${String(e.timelapse.everyMs/1e3)}s`):(t.push(`${String(e.speed??1)}×`),e.includeAudio&&t.push(`+ audio`)),t.join(` `)}function H(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function U(e,t){let n=Math.max(0,Math.round((t-e)/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60,o=r>0?`${String(r)}:${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`:`${String(i)}:${String(a).padStart(2,`0`)}`;return`${H(e)} · ${o}`}function W(e,t){let n=e-t;if(n<=0)return`expired`;let r=Math.floor(n/6e4);if(r<60)return`in ${String(r)}m`;let i=Math.floor(r/60);return i<24?`in ${String(i)}h`:`in ${String(Math.floor(i/24))}d`}function G(e,t,n,r){return e.map(e=>{if(e.state===`expired`||e.state===`deleted`)return e;let i=r.get(e.id);if(i)return{...e,state:`failed`,error:i.error,progressPct:null};let a=n.get(e.id);if(a)return{...e,state:`ready`,fileBytes:a.fileBytes,progressPct:100};let o=t.get(e.id);return o&&(e.state===`queued`||e.state===`rendering`)?{...e,state:`rendering`,progressPct:o.progressPct}:e})}var K=[[`recordingExport`]],q={queued:{cls:`bg-muted text-foreground-subtle`,label:`queued`},rendering:{cls:`bg-primary/10 text-primary`,label:`rendering`,spin:!0},ready:{cls:`bg-success/10 text-success`,label:`ready`},failed:{cls:`bg-danger/10 text-danger`,label:`failed`},expired:{cls:`bg-muted text-foreground-subtle`,label:`expired`},deleted:{cls:`bg-muted text-foreground-subtle`,label:`deleted`}};function J(){let{data:e,isLoading:t}=h({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:r}=n(w.RecordingExportProgress,e=>e.exportId),{map:i}=n(w.RecordingExportCompleted,e=>e.exportId),{map:a}=n(w.RecordingExportFailed,e=>e.exportId);return{rows:y(()=>G(e??[],r,i,a),[e,r,i,a]),isLoading:t}}function Y(e){let[t,n]=x(()=>Date.now());return C(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function X(){let n=b(),i=t(),o=E().trpcClient,s=Y(6e4),{rows:c,isLoading:u}=J(),{data:d}=r({}),f=y(()=>{let e=new Map;for(let t of d??[])e.set(t.id,t.name);return e},[d]),p=g(()=>{n.invalidateQueries({queryKey:K})},[n]),h=e({onSuccess:p}),_=l({onSuccess:p}),[C,w]=x(null),T=g(async e=>{w(e.id);try{let{url:t}=await o.recordingExport.getDownloadUrl.query({exportId:e.id}),n=await I(t),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.options.title??e.id}.mp4`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r),p()}finally{w(null)}},[o,p]),O=g(async e=>{await i({title:`Cancel this export?`,message:`Stops the render. The partial file is discarded.`,confirmLabel:`Cancel export`,variant:`danger`})&&h.mutate({exportId:e.id})},[i,h]),k=g(async e=>{await i({title:`Delete this export?`,message:`Permanently removes the rendered file and its history row.`,confirmLabel:`Delete`,variant:`danger`})&&_.mutate({exportId:e.id})},[i,_]),M=y(()=>[{key:`camera`,header:`Camera`,render:e=>S(`span`,{className:`text-foreground`,children:f.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:`Range`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:U(e.fromMs,e.toMs)})},{key:`variant`,header:`Variant`,render:e=>S(`span`,{className:`text-foreground-subtle`,children:V(e.options)})},{key:`state`,header:`State`,render:e=>{let t=q[e.state];return v(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${t.cls}`,children:[t.spin&&S(j,{className:`h-2.5 w-2.5 animate-spin`}),t.label,e.state===`rendering`&&e.progressPct!==null&&v(`span`,{className:`tabular-nums`,children:[e.progressPct,`%`]})]})}},{key:`expiry`,header:`Expires`,nowrap:!0,render:e=>e.state===`deleted`?S(`span`,{className:`text-foreground-subtle`,children:`—`}):S(`span`,{className:`text-foreground-subtle tabular-nums`,children:W(e.expiresAt,s)})},{key:`size`,header:`Size`,align:`right`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:e.fileBytes===null?`—`:L(e.fileBytes)})},{key:`actions`,header:``,align:`right`,render:e=>{let t=e.state===`ready`,n=e.state===`queued`||e.state===`rendering`,r=e.state!==`deleted`;return v(`div`,{className:`flex items-center justify-end gap-1`,children:[t&&v(`button`,{onClick:()=>{T(e)},disabled:C===e.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-primary/10 hover:text-foreground disabled:opacity-50`,title:`Download MP4`,children:[C===e.id?S(j,{className:`h-3 w-3 animate-spin`}):S(D,{className:`h-3 w-3`}),`Download`]}),n&&v(`button`,{onClick:()=>{O(e)},disabled:h.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:`Cancel render`,children:[S(z,{className:`h-3 w-3`}),`Cancel`]}),r&&S(`button`,{onClick:()=>{k(e)},disabled:_.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 export`,children:S(P,{className:`h-3 w-3`})})]})}}],[f,s,C,h.isPending,_.isPending,T,O,k]);return u&&c.length===0?v(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[S(j,{className:`h-4 w-4 animate-spin`}),`Loading exports…`]}):c.length===0?S(a,{icon:A,title:`No exports yet`,description:`Export a footage range from a camera's timeline in the viewer. Rendered clips show up here to download or manage.`}):S(m,{columns:M,rows:c,rowKey:e=>e.id,minWidthPx:720})}_();var Z=[[`recording`]],Q=[{value:`retention`,label:`Retention policy`},{value:`quota`,label:`Quota / disk pressure`},{value:`operator`,label:`Operator`}];function te(e){return e.totalBytes===null||e.totalBytes<=0?null:Math.min(1,Math.max(0,e.usedBytes/e.totalBytes))}function ne(){let e=b(),n=t(),[o,s]=x(`retention`),{data:c,isLoading:l}=d({},{refetchOnWindowFocus:!1}),{data:f}=r({}),p=y(()=>{let e=new Map;for(let t of f??[])e.set(t.id,t.name);return e},[f]),h=g(()=>{e.invalidateQueries({queryKey:Z})},[e]),_=u({onSuccess:h}),C=i({onSuccess:h}),w=g(async e=>{await n({title:`Prune ${p.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Applies the retention policy now (reason: ${o}). Footage beyond the policy is permanently deleted.`,confirmLabel:`Prune now`,variant:`danger`})&&_.mutate({deviceId:e.deviceId,reason:o})},[n,_,o,p]),E=g(async e=>{await n({title:`Delete all footage for ${p.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Permanently deletes ${L(e.usedBytes)} of recorded footage for this camera. This cannot be undone.`,confirmLabel:`Delete ${L(e.usedBytes)}`,variant:`danger`})&&C.mutate({deviceId:e.deviceId})},[n,C,p]),D=y(()=>[{key:`camera`,header:`Camera`,render:e=>S(`span`,{className:`text-foreground`,children:p.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`used`,header:`Used`,align:`right`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:L(e.usedBytes)})},{key:`actions`,header:``,align:`right`,render:e=>v(`div`,{className:`flex items-center justify-end gap-1`,children:[v(`button`,{onClick:()=>{w(e)},disabled:_.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:`Apply retention policy now`,children:[S(B,{className:`h-3 w-3`}),`Prune`]}),v(`button`,{onClick:()=>{E(e)},disabled:C.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 all footage`,children:[S(P,{className:`h-3 w-3`}),`Delete`]})]})}],[p,w,E,_.isPending,C.isPending]);if(l&&!c)return v(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[S(j,{className:`h-4 w-4 animate-spin`}),`Loading storage usage…`]});if(!c)return S(a,{icon:O,title:`No storage data`,description:`The recording node has not reported any storage usage yet.`});let k=c.devices.length;return v(`div`,{className:`flex flex-col gap-6`,children:[v(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[S(T,{label:`Total used`,icon:S(O,{className:`h-3 w-3`}),footer:`${String(k)} camera${k===1?``:`s`} on ${c.nodeId}`,children:L(c.totalUsedBytes)}),c.locations.map(e=>{let t=te(e),n=e.locationId??`default`;return S(T,{label:`Disk ${n}`,footer:e.availableBytes===null?`${L(e.usedBytes)} used (capacity unknown)`:`${L(e.availableBytes)} free${e.totalBytes===null?``:` of ${L(e.totalBytes)}`}`,children:t===null?S(`span`,{className:`tabular-nums`,children:L(e.usedBytes)}):v(`div`,{className:`flex items-center gap-2`,children:[S(`div`,{className:`h-2 flex-1 overflow-hidden rounded bg-muted`,children:S(`div`,{className:`h-full rounded ${t>.9?`bg-danger`:t>.75?`bg-amber-500`:`bg-primary`}`,style:{width:`${String(Math.round(t*100))}%`}})}),v(`span`,{className:`tabular-nums text-xs`,children:[Math.round(t*100),`%`]})]})},n)})]}),v(`section`,{className:`flex items-center gap-2 text-xs`,children:[S(`label`,{htmlFor:`prune-reason`,className:`text-foreground-subtle`,children:`Prune reason`}),S(`select`,{id:`prune-reason`,value:o,onChange:e=>{let t=Q.find(t=>t.value===e.target.value);t&&s(t.value)},className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:Q.map(e=>S(`option`,{value:e.value,children:e.label},e.value))})]}),k===0?S(a,{icon:O,title:`No recorded footage`,description:`No camera has recorded footage on this node yet.`}):S(m,{columns:D,rows:[...c.devices],rowKey:e=>e.deviceId,minWidthPx:480})]})}_();var re=[[`pipelineAnalytics`]],ie=1440*60*1e3,ae=[{days:1,label:`1 day`},{days:7,label:`7 days`},{days:30,label:`30 days`},{days:90,label:`90 days`}];function oe(){let e=b(),n=t(),[i,s]=x(30),{data:l,isLoading:u}=f({},{refetchOnWindowFocus:!1}),{data:d}=r({}),p=y(()=>{let e=new Map;for(let t of d??[])e.set(t.id,t.name);return e},[d]),h=g(()=>{e.invalidateQueries({queryKey:re})},[e]),_=c({onSuccess:h}),C=o({onSuccess:h}),w=g(async()=>{await n({title:`Prune events older than ${String(i)} day${i===1?``:`s`}?`,message:`Permanently deletes every event (motion / object / audio) older than the cutoff across all cameras, and their media. This cannot be undone.`,confirmLabel:`Prune events`,variant:`danger`})&&_.mutate({olderThanMs:Date.now()-i*ie,reason:`retention`})},[n,_,i]),E=g(async e=>{await n({title:`Delete all events for ${p.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Permanently deletes ${String(e.rows)} event${e.rows===1?``:`s`} (${L(e.bytes)} of media) for this camera. This cannot be undone.`,confirmLabel:`Delete events`,variant:`danger`})&&C.mutate({deviceId:e.deviceId})},[n,C,p]),D=y(()=>[{key:`camera`,header:`Camera`,render:e=>S(`span`,{className:`text-foreground`,children:p.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`rows`,header:`Events`,align:`right`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:e.rows.toLocaleString()})},{key:`bytes`,header:`Media`,align:`right`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:L(e.bytes)})},{key:`actions`,header:``,align:`right`,render:e=>v(`button`,{onClick:()=>{E(e)},disabled:C.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 all events for this camera`,children:[S(P,{className:`h-3 w-3`}),`Delete`]})}],[p,E,C.isPending]);return u&&!l?v(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[S(j,{className:`h-4 w-4 animate-spin`}),`Loading event-store footprint…`]}):l?v(`div`,{className:`flex flex-col gap-6`,children:[v(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[S(T,{label:`Total events`,icon:S(k,{className:`h-3 w-3`}),footer:`across ${String(l.devices.length)} camera${l.devices.length===1?``:`s`}`,children:l.totalRows.toLocaleString()}),S(T,{label:`Event media on disk`,children:L(l.totalBytes)})]}),v(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[S(`span`,{className:`text-foreground-subtle`,children:`Prune events older than`}),S(`select`,{value:i,onChange:e=>s(Number(e.target.value)),className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:ae.map(e=>S(`option`,{value:e.days,children:e.label},e.days))}),v(`button`,{onClick:()=>{w()},disabled:_.isPending,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,children:[_.isPending?S(j,{className:`h-3 w-3 animate-spin`}):S(B,{className:`h-3 w-3`}),`Prune now`]})]}),l.devices.length===0?S(a,{icon:k,title:`No stored events`,description:`No camera has persisted events yet.`}):S(m,{columns:D,rows:[...l.devices],rowKey:e=>e.deviceId,minWidthPx:480})]}):S(a,{icon:k,title:`No event data`,description:`Pipeline analytics has not reported any event-store footprint yet.`})}_();var $=[{value:`all`,label:`All`},{value:`recording`,label:`Recordings`},{value:`events`,label:`Events`}],se={recording:`bg-primary/10 text-primary`,events:`bg-violet-500/10 text-violet-400`};function ce(e){return new Date(e).toLocaleString()}function le(){let[e,t]=x(`all`),{data:n,isLoading:i}=p({},{refetchOnWindowFocus:!1}),{data:o,isLoading:c}=s({},{refetchOnWindowFocus:!1}),{data:l}=r({}),u=y(()=>{let e=new Map;for(let t of l??[])e.set(t.id,t.name);return e},[l]),d=y(()=>{let t=[...n??[],...o??[]];return(e===`all`?t:t.filter(t=>t.domain===e)).toSorted((e,t)=>t.at-e.at)},[n,o,e]),f=y(()=>[{key:`at`,header:`When`,nowrap:!0,render:e=>S(`span`,{className:`text-foreground-subtle tabular-nums`,children:ce(e.at)})},{key:`domain`,header:`Domain`,render:e=>S(`span`,{className:`inline-flex rounded px-1.5 py-0.5 text-[10px] font-medium ${se[e.domain]}`,children:e.domain})},{key:`op`,header:`Operation`,render:e=>S(`span`,{className:`text-foreground`,children:e.op})},{key:`reason`,header:`Reason`,render:e=>S(`span`,{className:`text-foreground-subtle`,children:e.reason})},{key:`device`,header:`Camera`,render:e=>e.deviceId===null?S(`span`,{className:`text-foreground-subtle`,children:`cluster`}):S(`span`,{className:`text-foreground`,children:u.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`items`,header:`Items`,align:`right`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:e.itemsAffected.toLocaleString()})},{key:`bytes`,header:`Reclaimed`,align:`right`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:e.bytesReclaimed>0?L(e.bytesReclaimed):`—`})}],[u]),h=i||c;return v(`div`,{className:`flex flex-col gap-4`,children:[S(`div`,{className:`flex items-center gap-1`,children:$.map(n=>S(`button`,{onClick:()=>t(n.value),className:`rounded px-2 py-1 text-xs font-medium ${e===n.value?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-muted`}`,children:n.label},n.value))}),h&&d.length===0?v(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[S(j,{className:`h-4 w-4 animate-spin`}),`Loading activity…`]}):d.length===0?S(a,{icon:M,title:`No activity yet`,description:`Prune, delete and rescan operations across recordings and events show up here.`}):S(m,{columns:f,rows:d,rowKey:e=>e.id,minWidthPx:720})]})}function ue(){return S(F,{icon:A,title:`Recordings`,subtitle:`Recording node & storage, event-store management, exported clips, and an activity log.`,children:S(R,{tabs:[{id:`recordings`,label:`Recordings`,icon:O,content:S(ee,{})},{id:`storage`,label:`Storage`,icon:O,content:S(ne,{})},{id:`events`,label:`Events`,icon:k,content:S(oe,{})},{id:`exports`,label:`Exports`,icon:A,content:S(X,{})},{id:`activity`,label:`Activity`,icon:M,content:S(le,{})}]})})}export{ue as RecordingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{W as e}from"./index-DcoBSPD8.js";var t=e(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{W as e}from"./index-DcoBSPD8.js";var t=e(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]);export{t};
|