@camstack/addon-admin-ui 1.2.689 → 1.2.690
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/CHANGELOG.md +9 -0
- package/dist/assets/Addons-Ckr6vlsW.js +5 -0
- package/dist/assets/{AdminPage-BZ0d3KIi.js → AdminPage-z8USGyNk.js} +1 -1
- package/dist/assets/{AdminSectionedPage-CivTk-bE.js → AdminSectionedPage-CtcZ5jHa.js} +1 -1
- package/dist/assets/AiProfiles-DZj0TWuh.js +3 -0
- package/dist/assets/Archive-B0FJwta9.js +1 -0
- package/dist/assets/ArchiveCamera-DdovP4ro.js +1 -0
- package/dist/assets/{BootstrapSettingsForm-Cyk46Mh8.js → BootstrapSettingsForm-CKBDm4C-.js} +1 -1
- package/dist/assets/Build-B3CB1er7.js +40 -0
- package/dist/assets/{Calendars-DcanbjM1.js → Calendars-DeXYk6f7.js} +1 -1
- package/dist/assets/{CameraGrids-D0rLrR4c.js → CameraGrids-A_aGLmzE.js} +1 -1
- package/dist/assets/{Cluster-Dr-johc0.js → Cluster-D2auKPXI.js} +1 -1
- package/dist/assets/{CompositionBlockEditor-Dm8WVd7r.js → CompositionBlockEditor-DtVxeX5F.js} +2 -2
- package/dist/assets/CompositionEditorPage-BvetDCib.js +1 -0
- package/dist/assets/Data-oQJyojZK.js +2 -0
- package/dist/assets/DeviceDetail-DPxmWhcP.js +1 -0
- package/dist/assets/{Devices-Dn8t45Xi.js → Devices-3Lm2uV9o.js} +1 -1
- package/dist/assets/{EmbedDevicePage-BtrHGVT2.js → EmbedDevicePage-BgNfY1Ap.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-Cpe5M1Q-.js → EmbedPlayerPage-BFXQpQxb.js} +1 -1
- package/dist/assets/History-jl2iyeKb.js +1 -0
- package/dist/assets/Identity-BpPWgRxJ.js +1 -0
- package/dist/assets/InstancesTable-DIKWKA5W.js +1 -0
- package/dist/assets/IntegrationDetail-ClVirS0M.js +1 -0
- package/dist/assets/{Integrations-BDNPovWf.js → Integrations-CldsYVl0.js} +2 -2
- package/dist/assets/Integrations-CprYyiDb.js +1 -0
- package/dist/assets/Library-B86tjZ0-.js +1 -0
- package/dist/assets/Locations-CpNbotTl.js +3 -0
- package/dist/assets/Logs-DSr8wCY-.js +1 -0
- package/dist/assets/{MaskShapeCanvas-CkL1-Z2p.js → MaskShapeCanvas-_BFcQxc-.js} +1 -1
- package/dist/assets/{MotionZonesSettings-CglI9jLC.js → MotionZonesSettings-DJDcu3fl.js} +1 -1
- package/dist/assets/MyAccess-DqKyBAxI.js +2 -0
- package/dist/assets/{Network-BRESDnEF.js → Network-Csm4YFXB.js} +1 -1
- package/dist/assets/NodeAddonsSettingsPanel-FjpwQjGM.js +2 -0
- package/dist/assets/Notifications-B-JLj82A.js +1 -0
- package/dist/assets/PanelContent-DJ8p-hQ1.js +2 -0
- package/dist/assets/Pipeline-DIXgco7S.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-Cfst7tBt.js → PrivacyMaskSettings-Dx5nRU-t.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-DPm4jF5N.js → SceneMonitorEditor-DFZ94G-a.js} +1 -1
- package/dist/assets/{ServerShell-CTyuWz03.js → ServerShell-BYRylYTw.js} +1 -1
- package/dist/assets/SessionsList-BcO2x9OZ.js +2 -0
- package/dist/assets/{Showroom-Ca4Y5ZQK.js → Showroom-DO1bQcNO.js} +1 -1
- package/dist/assets/StorageLocationsTable-BymZx5tG.js +1 -0
- package/dist/assets/System-dsyXpTx9.js +1 -0
- package/dist/assets/TemplateEditorDialog-DJIaNKn3.js +1 -0
- package/dist/assets/Terminal-BiXbwaPr.js +3 -0
- package/dist/assets/{TerminalPanel-CGquUW8j.js → TerminalPanel-BeJx-I2E.js} +2 -2
- package/dist/assets/{TrainingProviders-CPNjxb58.js → TrainingProviders-CPV9_SJC.js} +1 -1
- package/dist/assets/{Viewer-CO1F-6xh.js → Viewer-BN42pCqQ.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-D0G_tF_l.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DQNUYumg.js} +1 -1
- package/dist/assets/{action-draft-Bg11zRAj.js → action-draft-BBdPH6FV.js} +1 -1
- package/dist/assets/{ai-page.helpers-CB1jbKz_.js → ai-page.helpers-ChgVcsV9.js} +1 -1
- package/dist/assets/{assignment-candidates-B6H3O80X.js → assignment-candidates-Bs3KAjz2.js} +1 -1
- package/dist/assets/{authed-media-xniEMsSm.js → authed-media-BK50tJc4.js} +1 -1
- package/dist/assets/{board-model-B2JiEhiD.js → board-model-CWzkqJEj.js} +1 -1
- package/dist/assets/circle-play-BxUrE_Qy.js +1 -0
- package/dist/assets/client-DhfZUoXe.js +1120 -0
- package/dist/assets/{command-vocab-CnGweFaG.js → command-vocab-B3pUOKtp.js} +1 -1
- package/dist/assets/device-detail-B0RHrAPi.js +1 -0
- package/dist/assets/{device-integration-icon-BL4OR8Tu.js → device-integration-icon-JcMIVFtX.js} +1 -1
- package/dist/assets/device-picker-model-B2oUIKRS.js +1 -0
- package/dist/assets/{dist-b4Z4Rn9L.js → dist-BNuE6NKf.js} +1 -1
- package/dist/assets/dist-CyFeeFb8.js +1120 -0
- package/dist/assets/{format-D-lO-1j1.js → format-iFFzavy7.js} +1 -1
- package/dist/assets/{hostInit-DVaasUc0.js → hostInit-CzaZPFle.js} +1 -1
- package/dist/assets/i18n-DCYaeyv_.js +1 -0
- package/dist/assets/icons-CXirq6Hu.js +1 -0
- package/dist/assets/index-CpurjMmX.css +2 -0
- package/dist/assets/index-DPyWa2vo.js +6 -0
- package/dist/assets/{linked-devices-model-Bz36XHKW.js → linked-devices-model-CuXMtCW5.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-a6b7ded2.js → mf-entry-bootstrap-0-02bb2c8e.js} +2 -2
- package/dist/assets/mount-B2oUIKRS.js +1 -0
- package/dist/assets/{notification-rule-status-BprPUtT4.js → notification-rule-status-zg20pl7f.js} +1 -1
- package/dist/assets/player-overlays-BF9w4QU-.js +1 -0
- package/dist/assets/remoteEntry-ZZWQQQTl.js +1 -0
- package/dist/assets/square-check-big-DAcFGNUN.js +1 -0
- package/dist/assets/src-D9hgltMI.js +279 -0
- package/dist/assets/{sso-popup-CTYyuiaU.js → sso-popup-CdVjmZ9n.js} +1 -1
- package/dist/assets/{step-inspector-model-BBqHZ2d-.js → step-inspector-model-CxSQZZiN.js} +1 -1
- package/dist/assets/terminal-Dgb4lrgM.js +1 -0
- package/dist/assets/use-archive-data-D7nUbRKv.js +1 -0
- package/dist/assets/use-paged-list-DTJY2xpg.js +1 -0
- package/dist/assets/{use-scenes-feed-Ci4MtEAr.js → use-scenes-feed-BW5wMevx.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-C2ITjRTs.js → useAdminDeviceRemoval-kU8epr6n.js} +1 -1
- package/dist/assets/useEventInvalidation-B2oUIKRS.js +1 -0
- package/dist/assets/{useNodeUrlSelection-Dfowz4k5.js → useNodeUrlSelection-CfN-OrGq.js} +1 -1
- package/dist/assets/user-x-DkWcmF99.js +1 -0
- package/dist/assets/variable-DTEpBbRf.js +1 -0
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-D4WQjLc3.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-D3AQM66O.js} +2 -2
- package/dist/index.html +10 -10
- package/dist/server/addon.js +237 -4
- package/package.json +2 -2
- package/dist/assets/Addons-DY29xpxZ.js +0 -5
- package/dist/assets/AiProfiles-tt4dx8wK.js +0 -3
- package/dist/assets/Build-CDp7r2o2.js +0 -42
- package/dist/assets/CompositionEditorPage-BQzbI-bs.js +0 -1
- package/dist/assets/Data-DLn1T8hw.js +0 -2
- package/dist/assets/DeviceDetail-BiT7xDfc.js +0 -2
- package/dist/assets/History-BbdiSj1c.js +0 -1
- package/dist/assets/Identity-C0GPwuiI.js +0 -1
- package/dist/assets/InstancesTable-j-4OK4zO.js +0 -1
- package/dist/assets/IntegrationDetail-jfy5nNNW.js +0 -1
- package/dist/assets/Integrations-beSlWUhd.js +0 -1
- package/dist/assets/Library-B2A58WTO.js +0 -1
- package/dist/assets/Locations-CisH18lP.js +0 -3
- package/dist/assets/Logs-D7jdjIJK.js +0 -1
- package/dist/assets/MyAccess-BaeZoW7T.js +0 -2
- package/dist/assets/NodeAddonsSettingsPanel-Cs-4A2nm.js +0 -2
- package/dist/assets/Notifications-BLIvNXbr.js +0 -1
- package/dist/assets/Pipeline-DQlV8HzY.js +0 -1
- package/dist/assets/Recordings-BoAz9UAs.js +0 -1
- package/dist/assets/SessionsList-CKIbxGRm.js +0 -2
- package/dist/assets/StorageLocationsTable-C4W7zsGI.js +0 -1
- package/dist/assets/System-JFcPuvVK.js +0 -1
- package/dist/assets/TemplateEditorDialog-BqcmsBtt.js +0 -1
- package/dist/assets/Terminal-DpsQgC9x.js +0 -3
- package/dist/assets/archive-ChKlYFY2.js +0 -1
- package/dist/assets/client-CuXMhtQa.js +0 -1120
- package/dist/assets/device-detail-DJ7UsGNh.js +0 -1
- package/dist/assets/device-picker-model-CmD_rtEB.js +0 -1
- package/dist/assets/dist-BIKSreSn.js +0 -1120
- package/dist/assets/i18n-BXCE99oN.js +0 -1
- package/dist/assets/icons-C8z46zRV.js +0 -1
- package/dist/assets/index-CJG5kQrR.css +0 -2
- package/dist/assets/index-DltGFPYA.js +0 -4
- package/dist/assets/mount-CmD_rtEB.js +0 -1
- package/dist/assets/player-overlays-6CqWKNYt.js +0 -1
- package/dist/assets/remoteEntry-DKzXIU3g.js +0 -1
- package/dist/assets/src-Ddt5cb2R.js +0 -279
- package/dist/assets/terminal-DU-tvcEm.js +0 -1
- package/dist/assets/use-stationary-objects-DK2HFw6V.js +0 -1
- package/dist/assets/useEventInvalidation-CmD_rtEB.js +0 -1
- package/dist/assets/user-x-BcmVBo8D.js +0 -1
- package/dist/assets/variable-Cq3v1-Kt.js +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,t as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{G as d,Z as f,r as p,yt as m}from"./player-overlays-BF9w4QU-.js";import{Ar as h,Qc as g,Xc as _,Zc as v,Zi as y,c as b,dr as x,fr as S,l as C,pr as w,sp as T,z as E}from"./src-D9hgltMI.js";import{t as D}from"./useTranslation-BJr-n0es.js";import"./mount-B2oUIKRS.js";import"./index-DPyWa2vo.js";c();function O(e){return C(m().trpcClient,e)}var k=15e3,A={rows:[],unreadableCount:0};function j(e){let t=m(),n=e.length>0,r=[...e].sort((e,t)=>e-t),{data:i,isLoading:a}=s({queryKey:[`stationary-objects`,r],enabled:n,staleTime:k,refetchInterval:k,queryFn:async()=>{let e=await t.trpcClient.zoneAnalytics.getCurrentSnapshotBatch.query({deviceIds:r}),n=[],i=0;for(let t of e){if(t.read===`unreadable`){i++;continue}for(let e of t.snapshot?.stationaryObjects??[])n.push({...e,deviceId:t.deviceId})}return{rows:n,unreadableCount:i}}}),o=i??A;return{rows:o.rows.toSorted((e,t)=>t.becameStationaryAt-e.becameStationaryAt),isLoading:n&&a,unreadableCount:o.unreadableCount}}function M(e){let[n,i]=o(`idle`),[s,c]=o(null),l=t(null),u=t(null),d=t(null),f=t(!0),p=v(),m=_(),h=g(),y=r(()=>{if(l.current){try{l.current.close()}catch{}l.current=null}if(u.current){for(let e of u.current.getTracks())try{e.stop()}catch{}u.current=null}d.current=null},[]),b=r(async()=>{if(n===`idle`)return;i(`stopping`);let t=d.current;if(t&&e!==null)try{await Promise.race([h.mutateAsync({deviceId:e,sessionId:t}),new Promise((e,t)=>setTimeout(()=>t(Error(`server stopSession timeout`)),2e3))])}catch(e){console.warn(`[intercom] server stopSession failed (continuing teardown)`,e)}y(),f.current&&(i(`idle`),c(null))},[n,e,h,y]),x=r(async()=>{if(e===null||n!==`idle`&&n!==`error`)return;c(null);let t=null,r=null,a=null;try{i(`requesting-mic`),t=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),u.current=t,i(`starting`);let n=await p.mutateAsync({deviceId:e});a=n.sessionId,d.current=a,i(`connecting`),r=new RTCPeerConnection,l.current=r,r.oniceconnectionstatechange=()=>{if(!f.current)return;let e=r.iceConnectionState;e===`connected`||e===`completed`?i(`talking`):(e===`failed`||e===`closed`||e===`disconnected`)&&f.current&&(c(e===`failed`?`WebRTC connection failed`:null),b())};for(let e of t.getAudioTracks())r.addTrack(e,t);await r.setRemoteDescription({type:`offer`,sdp:n.sdpOffer});let o=await r.createAnswer();await r.setLocalDescription(o);let s=r.localDescription?.sdp??o.sdp??``;await m.mutateAsync({deviceId:e,sessionId:a,sdpAnswer:s})}catch(n){let o=n instanceof Error?n.message:String(n);if(console.warn(`[intercom] start failed`,n),r)try{r.close()}catch{}if(t)for(let e of t.getTracks())try{e.stop()}catch{}if(l.current=null,u.current=null,a!==null)try{await h.mutateAsync({deviceId:e,sessionId:a})}catch{}d.current=null,f.current&&(c(o),i(`error`))}},[e,n,p,m,h,b]);return a(()=>(f.current=!0,()=>{f.current=!1;let t=d.current;if(t!==null&&e!==null&&h.mutate({deviceId:e,sessionId:t}),l.current){try{l.current.close()}catch{}l.current=null}if(u.current){for(let e of u.current.getTracks())try{e.stop()}catch{}u.current=null}d.current=null}),[e]),{state:n,error:s,start:x,stop:b,isTalking:n===`talking`}}c();var N=0;function P(){return++N}function F(e){switch(e.type){case`system`:return`system`;case`device`:return`#${e.deviceId}`;case`provider`:return e.providerId;case`addon`:return e.addonId}}function I(e){return[``,`Commands`,` help Show this help`,` examples Show usage examples for the current scope`,` context Show every available variable + full API surface`,` clear Clear terminal (also Ctrl+L)`,``,`Shortcuts`,` Enter Execute expression`,` Arrow Up/Down Navigate command history`,` Ctrl+L Clear terminal`,``,`Try: ${{system:` sm.summary() // fleet overview`,device:` device.state.battery.value?.sleeping // sync read`,provider:` devices.map(d => d.name)`,addon:` manifest.version`}[e.type]}`,``,`Top-level objects: sm (SystemMirror), DeviceType, Math, JSON, Date, …`]}function L(e){switch(e.type){case`device`:return[``,`── State (sync, zero round-trip) ─────────────────────────`,` device.state.battery.value`,` device.state.battery.value?.level`,` device.state.motion.value?.detected`,``,`── Actions (async, through wrapper chain) ────────────────`,` await device.snapshot.getSnapshot({})`,` await device.ptz.move({ direction: 'left', steps: 1 })`,` await device.switch.setState({ on: true })`,``,`── Wait for condition ───────────────────────────────────`,` await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)`,``,`── Subscribe to changes ─────────────────────────────────`,` const off = device.state.battery.subscribe(s => console.log(s))`,``,`── Quick info ───────────────────────────────────────────`,` info.name device name`,` info.addonId owning addon`,` sm.dump(deviceId) full debug dump`];case`system`:return[``,`── Lookups ──────────────────────────────────────────────`,` sm.getDeviceById(8)`,` sm.getDeviceByName('Sala da pranzo')`,` sm.getDevicesByAddon('reolink')`,` sm.getDevicesByType(DeviceType.Camera)`,``,`── Filters (typed query) ────────────────────────────────`,` sm.query({ addonId: 'reolink', online: true })`,` sm.query({ caps: ['battery', 'snapshot'] })`,` sm.query({ name: /^Cam-/ })`,``,`── Cross-device ─────────────────────────────────────────`,` sm.whereState('battery', s => s.level < 20).length`,` sm.mapState('battery', s => s.level)`,` sm.countByCap('snapshot')`,``,`── Batch action ─────────────────────────────────────────`,` await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })`,``,`── Listen ───────────────────────────────────────────────`,` sm.listenCap('motion', (id, s) => console.log(id, s))`,` sm.onDeviceAdded((id, info) => console.log('+', info.name))`,``,`── Diagnostics ──────────────────────────────────────────`,` sm.summary()`,` sm.dump(8)`];case`provider`:return[``,` devices.map(d => d.name)`,` await getIntegration()`,` sm.getDevicesByAddon('<this-addon-id>').length`];case`addon`:return[``,` manifest.name`,` manifest.version`,` declaration`]}}function R(e){let t=[``,`Scope: ${e.type}`,``];switch(e.type){case`system`:return[...t,`Primary API — sm (SystemMirror):`,` sm.getDeviceById(id) DeviceProxy | null (sync)`,` sm.getDeviceByName(name) DeviceProxy | null`,` sm.getDeviceByStableId(sid) DeviceProxy | null`,` sm.getAllDevices() readonly DeviceProxy[]`,` sm.getDeviceInfo(id) DeviceInfo | null`,` sm.summary() fleet stats`,``,`Filters — sm.query({...}):`,` sm.query({ addonId: 'reolink', online: true })`,` sm.query({ caps: ['battery', 'snapshot'] }) // ALL caps required`,` sm.query({ anyCap: ['ptz', 'motion'] }) // ANY cap`,` sm.query({ name: { contains: 'sala' } }) // case-insensitive`,` sm.query({ name: /^Cam-\\d+$/ })`,` sm.query({ type: DeviceType.Camera })`,` sm.query({ parentDeviceId: 8 }) // accessories of cam 8`,` sm.query({ where: (info, dev) => dev.state.battery.value?.sleeping })`,``,`State queries:`,` sm.whereState('battery', s => s.level < 20)`,` sm.mapState('battery', s => s.level)`,` sm.findState('motion', s => s.detected)`,` sm.countByCap('snapshot')`,``,`Listeners (return unsubscribe fn):`,` sm.listen((id, cap, slice) => …) // every state change`,` sm.listenCap('motion', (id, slice) => …)`,` sm.listenDevice(8, (id, cap, slice) => …)`,` sm.onDeviceAdded((id, info) => …)`,` sm.onDeviceRemoved((id, info) => …)`,``,`Wait primitives:`,` await sm.waitForState(8, 'battery', s => !s.sleeping, 30_000)`,` await sm.waitForDevice(99, 30_000)`,``,`Batch:`,` await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })`,` await sm.forEachCap('reboot', d => d.reboot.reboot({}))`,``,`Diagnostics:`,` sm.dump(8) debug dump (one device)`,` sm.dump() full fleet dump`,` sm.summary() breakdown by cap/addon/type`,``,`Legacy: deviceRegistry, addonRegistry, eventBus, devices(), addons()`];case`device`:return[...t,`Pre-bound variables:`,` device DeviceProxy for this device (sync state + async methods)`,` deviceId number`,` info DeviceInfo metadata (name, addonId, type, online, …)`,` sm SystemMirror (full cluster view)`,` rawDevice legacy IDevice instance (escape hatch)`,``,`Reactive state (sync, zero round-trip):`,` device.state.battery.value BatteryStatus | undefined`,` device.state.battery.value?.sleeping`,` device.state.battery.value?.level`,` device.state.motion.value?.detected`,` device.state.switch.value?.on`,` device.state.brightness.value?.level`,` device.state.doorbell.value?.lastPressedAt`,``,`Cap actions (async, through wrapper chain):`,` await device.snapshot.getSnapshot({})`,` await device.snapshot.getSnapshot({ streamId: 'high' })`,` await device.ptz.move({ direction: 'left', steps: 1 })`,` await device.ptz.goToPreset({ presetId: 'home' })`,` await device.switch.setState({ on: true })`,` await device.brightness.setBrightness({ level: 60 })`,` await device.reboot.reboot({})`,``,`Subscribe to slice changes:`,` const off = device.state.battery.subscribe(s => console.log(s))`,` // off() to unsubscribe`,``,`Wait for a state condition:`,` await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)`,``,`Diagnostics:`,` info.name device name`,` info.addonId which addon owns it`,` info.online transport health`,` sm.dump(deviceId) full debug dump (binding + state + info)`];case`provider`:return[...t,`Pre-bound variables:`,` devices Devices belonging to this provider (raw IDevice[])`,` getIntegration() Integration metadata`,``,`For typed device access use the SystemMirror:`,` await getSystemMirror()`,` sm.getDevicesByAddon('this-addon-id')`];case`addon`:return[...t,`Pre-bound variables:`,` manifest { name, version, ... }`,` declaration addon declaration`,` source addon source location`,``,`Examples:`,` manifest.name`,` manifest.version`]}}function z({scope:n,greeting:s,className:c}){let{t:u}=D(),d=m(),[f,p]=o(()=>{let e=[];return s&&e.push({id:P(),kind:`info`,text:s}),e.push({id:P(),kind:`info`,text:`scope: ${F(n)} — type help or context for available commands`}),e}),[h,g]=o(``),[_,v]=o([]),[y,b]=o(-1),x=t(null),S=t(null);a(()=>{let e=S.current;e&&(e.scrollTop=e.scrollHeight)},[f]);let C=r(()=>{x.current?.focus()},[]),w=l({mutationFn:e=>d.trpcClient.repl.execute.mutate({code:e,scope:n}),onSuccess:e=>{let t=e??{},n=typeof t.output==`string`?t.output:e==null?`undefined`:typeof e==`string`?e:JSON.stringify(e,null,2),r=t.type===`error`;p(e=>[...e,{id:P(),kind:r?`error`:`result`,text:n}])},onError:e=>{let t=e instanceof Error?e.message:String(e);p(e=>[...e,{id:P(),kind:`error`,text:t}])}});function E(e){let t=e.trim();if(t){if(t===`clear`){p([{id:P(),kind:`info`,text:`scope: ${F(n)}`}]),g(``);return}if(t===`help`){p(e=>[...e,{id:P(),kind:`input`,text:`> ${t}`},...I(n).map(e=>({id:P(),kind:`info`,text:e}))]),g(``);return}if(t===`context`){p(e=>[...e,{id:P(),kind:`input`,text:`> ${t}`},...R(n).map(e=>({id:P(),kind:`info`,text:e}))]),g(``);return}if(t===`examples`){p(e=>[...e,{id:P(),kind:`input`,text:`> ${t}`},...L(n).map(e=>({id:P(),kind:`info`,text:e}))]),g(``);return}v(e=>[...e,t]),b(-1),p(e=>[...e,{id:P(),kind:`input`,text:`> ${t}`}]),g(``),w.mutate(t)}}function O(e){if(e.key===`Enter`){e.preventDefault(),E(h);return}if(e.key===`ArrowUp`){if(e.preventDefault(),_.length===0)return;let t=y===-1?_.length-1:Math.max(0,y-1);b(t),g(_[t]??``);return}if(e.key===`ArrowDown`){if(e.preventDefault(),y===-1)return;let t=y+1;t>=_.length?(b(-1),g(``)):(b(t),g(_[t]??``));return}e.ctrlKey&&e.key===`l`&&(e.preventDefault(),p([{id:P(),kind:`info`,text:`scope: ${F(n)}`}]))}let k={input:`text-zinc-300`,result:`text-emerald-300`,error:`text-red-300`,info:`text-zinc-400`};return e(`div`,{className:`flex flex-col bg-[#0c0a09] rounded-lg border border-border overflow-hidden font-mono text-xs ${c??``}`,onClick:C,children:[e(`div`,{ref:S,className:`flex-1 overflow-y-auto p-3 space-y-1 min-h-[120px]`,children:[f.map(e=>i(`pre`,{className:`whitespace-pre-wrap break-words leading-relaxed ${k[e.kind]}`,children:e.text},e.id)),w.isPending&&i(`span`,{className:`text-zinc-500 animate-pulse`,children:u(`shared.replTerminal.thinking`,`…thinking`)})]}),e(`div`,{className:`flex items-center gap-2 border-t border-zinc-800 px-3 py-2 bg-[#0c0a09]`,children:[i(`span`,{className:`text-emerald-400 flex-shrink-0 select-none font-bold`,children:u(`shared.replTerminal.text`,`>`)}),i(T,{ref:x,value:h,onChange:e=>g(e.target.value),onKeyDown:O,disabled:w.isPending,placeholder:`device.state.battery.value`,autoFocus:!0,className:`flex-1 bg-transparent text-zinc-100 placeholder:text-zinc-600 focus:outline-none caret-emerald-400 disabled:opacity-50`,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`})]})]})}function B(e,t){return e===null?null:{playbackUrl:e.url,...e.format===void 0?{}:{playbackFormat:e.format},playbackAuthToken:t,...e.label===void 0?{}:{playbackLabel:e.label}}}c();function V({deviceId:e,intercomAvailable:t=!1}){let r=m(),a=typeof window<`u`?f():``,o=Number.isFinite(e),s=O(o?e:null),c=j(o?[e]:[]),l=n(()=>{if(!o)return;let e=[];for(let t of c.rows){let n=b(t);n!==null&&e.push(n)}return e},[o,c.rows]),{streams:g,pipelineMetrics:_,createSession:v,sendAnswer:x,handleOffer:S,getIceServers:C,addIceCandidate:w,getIceCandidates:T,closeSession:D,getSessionState:k,applyDownlinkProbe:A}=h(r.trpcClient,o?e:null),N=d(o?e:null,{width:K}),P=M(o&&t?e:null),F=P.state===`requesting-mic`||P.state===`starting`||P.state===`connecting`||P.state===`stopping`,I=P.isTalking||F,L=()=>{P.state===`idle`||P.state===`error`?P.start():P.state!==`stopping`&&P.stop()},R=p(),z=y(),V=typeof window<`u`?window.localStorage.getItem(`camstack_admin_token`):null,H=B(z.request,V),U=R.length>0?i(u,{children:R.map(e=>i(`div`,{className:`absolute inset-0`,children:e.node},e.id))}):null;return i(E,{serverUrl:a,createSession:v,sendAnswer:x,handleOffer:S,getIceServers:C,addIceCandidate:w,getIceCandidates:T,closeSession:D,getSessionState:k,applyDownlinkProbe:A,...H===null?{}:{...H,onExitPlayback:()=>z.clear()},streams:g,pipelineMetrics:_,phase:s.phase,detections:s,...l===void 0?{}:{stationaryObjects:l},defaultShowDetections:!0,defaultShowMotion:!0,showPlayStop:!0,snapshotSrc:N.src,...N.src?{posterUrl:N.src}:{},snapshotLoading:N.loading,onRefreshSnapshot:N.refresh,intercomAvailable:t,intercomShown:I,onIntercomToggle:L,extraOverlay:U,chromeless:!0,className:`h-full`})}function H({deviceId:e,containerDeviceId:t}){let{t:n}=D();return Number.isFinite(e)?i(`div`,{className:`flex flex-col h-full`,children:i(w,{...t===void 0?{deviceId:e}:{containerDeviceId:t},limit:50,maxHeight:`max-h-full`,showScope:!1,showFilters:!1})}):i(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:n(`device.panelContent.notLoaded`,{id:e})})}function U({deviceId:e}){let{t}=D();if(!Number.isFinite(e))return i(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:t(`device.panelContent.notLoaded`,{id:e})});let n=[`CamStack REPL — device #${e}`,``,` device.state.battery.value sync state read`,` await device.snapshot.getSnapshot({}) cap action`,``,` type 'examples' for more, 'context' for the full API`].join(`
|
|
2
|
+
`);return i(z,{scope:{type:`device`,deviceId:e},greeting:n,className:`h-full border-0 rounded-none`})}function W({deviceId:e}){let{t}=D();return Number.isFinite(e)?i(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:i(S,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):i(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:t(`device.panelContent.notLoaded`,{id:e})})}function G({deviceId:e}){let{t}=D();return Number.isFinite(e)?i(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:i(x,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):i(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:t(`device.panelContent.notLoaded`,{id:e})})}var K=960;export{V as a,G as i,H as n,j as o,U as r,W as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,i as c,o as l,p as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{A as f,D as p,Fr as m,Ga as h,Hn as g,Ja as _,Ka as v,Lr as y,N as b,O as x,Oi as S,Pn as C,Pr as w,Rn as T,Rt as E,T as D,Tr as O,Tt as k,V as A,Vr as j,Xn as M,Yn as ee,Zt as N,b as P,cr as te,ct as F,eo as I,ft as L,j as R,jt as z,k as B,oi as ne,pi as V,qa as re,ta as H,tn as ie,v as ae,wt as U,y as oe,yn as se,yt as ce,z as W}from"./player-overlays-BF9w4QU-.js";import{Bi as le,Gi as ue,Hi as de,Hn as fe,Ui as pe,Wi as me,Zc as he,ci as ge,di as _e,fi as ve,g as ye,h as be,li as xe,mi as Se,oi as Ce,pi as we,ui as Te,v as Ee}from"./client-DhfZUoXe.js";import{t as De}from"./chevron-down-CBb-F8DT.js";import{d as Oe,f as ke}from"./terminal-Dgb4lrgM.js";import{a as Ae,i as je,n as Me,r as Ne,t as Pe}from"./usb-P4R9CjYI.js";import{t as Fe}from"./crop-B-t0rzRY.js";import{t as Ie}from"./layers-BH9u1mrE.js";import{n as Le}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DzoL8nR8.js";import{$f as G,$u as Re,B as ze,Bi as Be,Br as Ve,Cu as He,Dr as Ue,Du as We,Fp as Ge,Fr as Ke,Fu as qe,Ga as Je,H as Ye,Ha as Xe,Hi as Ze,Ii as Qe,Ip as $e,Iu as et,Ju as tt,K as nt,Lp as rt,Lu as it,Mp as K,Mr as q,Mu as at,Np as ot,Nu as st,Oi as ct,Ou as lt,Pp as ut,Pr as dt,Qu as ft,Ri as pt,Rr as mt,Ru as ht,Si as gt,Ti as _t,Tu as vt,U as yt,Ua as bt,Ui as xt,V as St,Vi as Ct,W as wt,Wi as Tt,Xu as Et,Yu as Dt,Zu as Ot,_a as kt,a as At,au as jt,bc as Mt,br as Nt,bu as Pt,ci as Ft,cp as It,cu as Lt,du as Rt,ea as zt,ei as Bt,et as Vt,fi as Ht,ft as Ut,fu as Wt,gi as Gt,gp as Kt,gu as qt,hi as Jt,hu as Yt,jn as Xt,ju as Zt,kn as Qt,ku as $t,mi as en,mp as tn,mu as nn,ni as rn,ou as an,pi as on,pr as sn,pt as cn,pu as ln,qu as un,ri as dn,sp as fn,st as pn,su as mn,td as hn,uu as gn,wi as _n,xc as vn,ya as J,yc as yn,zi as bn,zr as xn,zs as Sn,zu as Cn}from"./src-D9hgltMI.js";import{t as Y}from"./i18n-DCYaeyv_.js";import{t as X}from"./useTranslation-BJr-n0es.js";import{K as wn,mi as Tn,pi as En,yi as Dn}from"./index-DPyWa2vo.js";import{t as On}from"./NodeAddonsSettingsPanel-FjpwQjGM.js";import"./useEventInvalidation-B2oUIKRS.js";import{_ as kn,a as An,b as jn,c as Mn,d as Nn,f as Pn,g as Fn,h as In,i as Ln,l as Rn,m as zn,n as Bn,p as Vn,r as Hn,s as Un,u as Wn,v as Gn,y as Kn}from"./step-inspector-model-CxSQZZiN.js";import{a as qn,c as Jn,d as Yn,f as Xn,g as Zn,i as Qn,l as $n,m as er,n as tr,o as nr,r as rr,s as ir,t as ar,u as or,v as sr,y as cr}from"./board-model-CWzkqJEj.js";s();function lr(e){if(e==null)return null;if(typeof e==`number`)return e>0?e:null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function ur(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function dr(e){return e!==!1}function fr(e){return{pipeline:dr(ur(e,`detect`)),audio:dr(ur(e,`audio`)),ingest:dr(ur(e,`ingest`))}}function pr(e,t){let n=e?.find(e=>e.nodeId===t);return fr(n?.settings)}function mr({selectedNodeId:t,onSelect:n,refreshToken:r}){let a=I(),{t:o}=X(),{nodes:s}=ot(),{data:c}=We(void 0),{data:l}=Zt(void 0),u=new Map;for(let e of c??[])u.set(e.agentNodeId,(u.get(e.agentNodeId)??0)+1);let f=s??[],p=f.filter(e=>e.isOnline).length,m=f.filter(e=>!e.isOnline).length;return e(`div`,{className:`flex flex-col h-full`,children:[e(G,{variant:`unstyled`,type:`button`,onClick:()=>n($o),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${t===`__cluster__`?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[i(Oe,{className:`h-4 w-4 flex-shrink-0`}),e(`div`,{className:`min-w-0 flex-1`,children:[i(`div`,{className:`text-xs font-semibold truncate`,children:o(`pipeline.nodeList.cluster`,`Cluster`)}),i(`div`,{className:`text-[10px] text-foreground-subtle`,children:o(`pipeline.nodeList.assignmentsLoadBalancingRoles`,`Assignments, load balancing, roles`)})]})]}),i(`div`,{className:`flex-1 overflow-y-auto`,children:f.map(r=>{let s=t===r.id,c=u.get(r.id)??0,f=r.isHub?T:S,p=pr(l,r.id),m=r.isOnline?null:Xt(lr(r.lastSeen),a);return e(G,{variant:`unstyled`,type:`button`,onClick:()=>n(r.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${s?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${r.isOnline?``:` opacity-60`}`,children:[i(f,{className:`h-4 w-4 flex-shrink-0`}),e(`div`,{className:`min-w-0 flex-1`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-xs font-semibold truncate`,children:r.name}),r.isHub&&i(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:o(`common.hubWord`)}),!r.isOnline&&i(`span`,{className:`h-1.5 w-1.5 rounded-full bg-danger flex-shrink-0`}),r.isOnline&&i(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),e(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[i(`span`,{children:o(`common.coresCount`,{count:r.cpuCores})}),i(`span`,{children:`•`}),e(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),c>0&&e(d,{children:[i(`span`,{children:`•`}),e(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[i(E,{className:`h-2.5 w-2.5`}),c]})]}),!r.isOnline&&e(d,{children:[i(`span`,{children:`•`}),e(`span`,{className:`text-danger`,children:[o(`common.offline`),m===null?``:` · ${m}`]})]})]}),e(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[i(J,{variant:p.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:p.pipeline?o(`pipeline.nodeList.pipelineEnabled`,`Pipeline: enabled`):o(`pipeline.nodeList.pipelineNotEnabledAgentCapability`,`Pipeline: not enabled (agent capability)`),children:o(`pipeline.nodeList.pipe`,`Pipe`)}),i(J,{variant:p.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:p.audio?o(`pipeline.nodeList.audioEnabled`,`Audio: enabled`):o(`pipeline.nodeList.audioNotEnabledAgentCapability`,`Audio: not enabled (agent capability)`),children:o(`pipeline.nodeList.aud`,`Aud`)})]})]})]},r.id)})}),e(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[i(`span`,{children:o(`common.onlineCount`,{count:p})}),m>0&&i(`span`,{className:`text-danger`,children:o(`common.offlineCount`,{count:m})})]})]})}function hr({nodeId:t,refreshToken:n}){let{t:r}=X(),{nodes:a}=ot(),o=a?.find(e=>e.id===t),s=ut(`pipeline.runner-load-snapshot`,e=>e.nodeId===t)?.load??null;return o?e(`div`,{className:`px-6 py-4 border-b border-border`,children:[e(`div`,{className:`flex items-center gap-2 mb-1`,children:[i(`h2`,{className:`text-base font-semibold text-foreground`,children:o.name}),o.isOnline?i(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:r(`common.online`)}):i(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-danger/10 text-danger`,children:r(`common.offline`)}),o.isHub&&i(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:r(`common.hubWord`)})]}),e(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[i(`span`,{children:o.cpuModel??`CPU`}),i(`span`,{children:`•`}),i(`span`,{children:r(`common.coresCount`,{count:o.cpuCores})}),i(`span`,{children:`•`}),e(`span`,{children:[Math.round(o.memoryMB/1024),` GB`]}),s&&e(d,{children:[i(`span`,{children:`•`}),i(`span`,{children:r(`pipeline.nodeDetailHeader.cameras`,{attached:s.attachedCameras,active:s.activeCameras})}),i(`span`,{children:`•`}),i(`span`,{children:r(`pipeline.nodeDetailHeader.avgInference`,{ms:s.avgInferenceTimeMs.toFixed(0)})}),i(`span`,{children:`•`}),i(`span`,{children:r(`pipeline.nodeDetailHeader.queue`,{depth:s.queueDepthTotal})}),s.hardware.hasGpu&&e(d,{children:[i(`span`,{children:`•`}),i(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):i(`div`,{className:`px-6 py-4 border-b border-border`,children:e(`div`,{className:`text-xs text-foreground-subtle`,children:[r(`pipeline.nodeDetailHeader.nodeNotFound`,`Node not found:`),` `,t]})})}var gr=[`assignments`,`tree`,`engines`,`logs`];function _r({refreshToken:t,nodeId:r}){let{t:a}=X(),[s,c]=o(new Map),{nodes:l}=K();$e(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&c(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:u}=qt(void 0),d=n(()=>{let e=new Map;for(let t of u??[])e.set(t.nodeId,t.deviceCount);return e},[u]),f=n(()=>{let e=new Map,t=Date.now()-3e4;for(let n of s.values()){if(n.timestamp<t)continue;let r=n.nodeId??`hub`,i=e.get(r)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,n.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=n.metrics.actualFps,i.totalInferenceWeighted+=n.metrics.avgInferenceTimeMs,i.queueDepth+=n.metrics.queueDepth,e.set(r,i)}return e},[s]),p=n(()=>{let e=new Map;for(let t of l)e.set(t.id,t.shortName);return e},[l]),m=n(()=>{let e=0,t=0,n=0,r=0,i=0;for(let a of f.values())e+=a.attachedCameras,t+=a.activeCameras,n+=a.totalFps,r+=a.totalInferenceWeighted,i+=a.queueDepth;let a=e>0?r/e:0;return{totalAgents:l.length,onlineAgents:l.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:a,queueDepth:i,totalFps:n}},[f,l]);if(r){let t=f.get(r);return e(`div`,{className:`@container/liveload`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:a(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),e(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[i(Z,{label:`FPS`,value:t?t.totalFps.toFixed(1):`—`}),i(Z,{label:a(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:t?`${t.activeCameras}/${t.attachedCameras}`:`—`}),i(Z,{label:a(`pipeline.liveLoadPanel.avgInferMs`,`Avg infer ms`),value:t&&t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),i(Z,{label:a(`pipeline.liveLoadPanel.queue`,`Queue`),value:t?String(t.queueDepth):`—`}),i(Z,{label:a(`pipeline.liveLoadPanel.audio`,`Audio`),value:String(d.get(r)??`—`)})]})]})}let h=[...f.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return e(`div`,{className:`@container/liveload`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:a(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),e(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[i(Z,{label:a(`pipeline.liveLoadPanel.totalAgents`,`Total agents`),value:`${m.onlineAgents}/${m.totalAgents}`}),i(Z,{label:a(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:`${m.activeCameras}/${m.attachedCameras}`}),i(Z,{label:a(`pipeline.liveLoadPanel.totalFps`,`Total FPS`),value:m.totalFps.toFixed(1)}),i(Z,{label:a(`pipeline.liveLoadPanel.avgInferenceMs`,`Avg inference ms`),value:m.avgInferenceTimeMs.toFixed(0)}),i(Z,{label:a(`pipeline.liveLoadPanel.queueDepth`,`Queue depth`),value:String(m.queueDepth)})]}),i(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:e(`table`,{className:`w-full text-xs min-w-[480px]`,children:[i(`thead`,{className:`bg-surface`,children:e(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[i(`th`,{className:`text-left px-3 py-2`,children:a(`pipeline.liveLoadPanel.agent`,`Agent`)}),i(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),i(`th`,{className:`text-right px-3 py-2`,children:a(`pipeline.liveLoadPanel.cameras`,`Cameras`)}),i(`th`,{className:`text-right px-3 py-2`,children:a(`pipeline.liveLoadPanel.inferenceMs`,`Inference ms`)}),i(`th`,{className:`text-right px-3 py-2`,children:a(`pipeline.liveLoadPanel.queue`,`Queue`)}),i(`th`,{className:`text-right px-3 py-2`,children:a(`pipeline.liveLoadPanel.audio`,`Audio`)})]})}),e(`tbody`,{children:[h.map(([t,n])=>e(`tr`,{className:`border-t border-border`,children:[i(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:p.get(t)??t}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:n.totalFps.toFixed(1)}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:n.attachedCameras}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:n.attachedCameras>0?(n.totalInferenceWeighted/n.attachedCameras).toFixed(0):`—`}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:n.queueDepth}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:d.get(t)??`—`})]},t)),h.length===0&&i(`tr`,{children:i(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:a(`pipeline.liveLoadPanel.noCameraMetricsReceivedYet`,`No camera metrics received yet`)})})]})]})})]})}function Z({label:t,value:n}){return e(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[i(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:t}),i(`div`,{className:`text-lg font-semibold text-foreground`,children:n})]})}var vr={active:!1,pinned:!1,nodeId:null,reason:``};function yr(e,t){return e.deviceName.localeCompare(t.deviceName)||e.deviceId-t.deviceId}function br(e,t,n){let r=new Map(t.map(e=>[e.deviceId,e])),i=new Map(n.map(e=>[e.deviceId,e]));return e.map(e=>{let t=r.get(e.id),n=i.get(e.id),a=t?{active:!0,pinned:t.pinned,nodeId:t.agentNodeId,reason:t.reason??``}:vr,o=n?{active:!0,pinned:n.pinned,nodeId:n.nodeId,reason:``}:vr;return{deviceId:e.id,deviceName:e.name,disabled:e.disabled===!0,pipeline:a,detection:a,decoder:vr,audio:o}}).toSorted(yr)}function xr(e,t,n){return{active:e!==null,pinned:t,nodeId:e,reason:n??``}}function Sr(e,t){let n=new Map(t.map(e=>[e.deviceId,e.assignment]));return e.map(e=>{let t=n.get(e.deviceId);return t===void 0?e:{...e,detection:xr(t.detectionNodeId,t.pinned.detection,t.reasons.detection),decoder:xr(t.decoderNodeId,t.pinned.decoder,t.reasons.decoder),audio:xr(t.audioNodeId,t.pinned.audio,t.reasons.audio)}})}function Cr(e,t,n){let r=(t,n,r)=>({active:t!==null&&t===e,pinned:n,nodeId:t,reason:r??``});return t.map(({deviceId:e,assignment:t})=>({deviceId:e,deviceName:n(e),detection:r(t.detectionNodeId,t.pinned.detection,t.reasons.detection),decoder:r(t.decoderNodeId,t.pinned.decoder,t.reasons.decoder),audio:r(t.audioNodeId,t.pinned.audio,t.reasons.audio)})).filter(e=>e.detection.active||e.decoder.active||e.audio.active).toSorted(yr)}function wr(e){let t=new Map(e.map(e=>[e.id,e.name]));return e=>{let n=t.get(e);return n!==void 0&&n!==``?n:e}}function Tr(e){let t=new Map(e.map(e=>[e.id,e.name]));return e=>t.get(e)??Y.t(`helpers.assignmentRows.cameraFallback`,{id:e})}function Er(e,t,n){let r=[...new Set([...e.nodeId===null?[]:[e.nodeId],...t.map(e=>e.id)])];return[{value:`auto`,label:Y.t(`helpers.assignmentRows.auto`)},...r.map(e=>({value:e,label:Y.t(`helpers.assignmentRows.pinTo`,{node:n(e)})}))]}function Dr({roleId:e,roleLabel:t,state:n,nameOf:r,colorByNodeId:a,emphasizeOnNodeId:o}){if(n.nodeId===null)return null;let s=n.nodeId,c=o===void 0?!1:n.active&&s===o;return i(mt,{roleId:e,roleLabel:t,nodeName:r(s),colorId:Ve(a,s),emphasized:c,pinned:n.pinned})}function Or({detection:t,decoder:n,audio:r,nameOf:a,colorByNodeId:o,emphasizeOnNodeId:s}){let c=(e,t,n)=>i(Dr,{roleId:e,roleLabel:t,state:n,nameOf:a,colorByNodeId:o,emphasizeOnNodeId:s},e);return e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[c(`detection`,`Detection`,t),c(`decode`,`Decode`,n),c(`audio`,`Audio`,r)]})}function kr({snap:t}){let n=I(),{t:r}=X();if(t===void 0)return i(`div`,{className:`flex h-8 items-center text-[11px] text-foreground-subtle`,title:r(`assignments.assignmentStatusCell.noMetricsInTheLast`,`No metrics in the last 10 s — the camera has no session running`),children:r(`assignments.assignmentStatusCell.noLiveData`,`no live data`)});let{phase:a,actualFps:o,avgInferenceTimeMs:s,queueDepth:c,configuredFps:l,droppedFrames:u}=t.metrics,d=Nt(a,n);return e(`div`,{className:`flex h-8 min-w-0 flex-col justify-center font-mono text-[10px] leading-tight tabular-nums`,children:[e(`span`,{className:`inline-flex min-w-0 items-center gap-1 ${d.textColor}`,children:[i(Vt,{phase:a,className:`h-2.5 w-2.5 shrink-0`}),i(`span`,{className:`truncate font-semibold uppercase tracking-wider`,children:d.label}),i(`span`,{className:`text-foreground`,children:o.toFixed(1)}),i(`span`,{className:`text-foreground-subtle`,children:r(`pipeline.assignmentStatusCell.configuredFps`,{fps:l.toFixed(0)})})]}),e(`span`,{className:`truncate text-foreground-subtle`,children:[i(`span`,{className:`text-foreground`,children:s.toFixed(0)}),` ms`,c>0&&e(`span`,{className:`ml-1 text-warning`,children:[`q`,c]}),i(`span`,{className:u>0?`ml-1 text-warning`:`ml-1`,children:r(`pipeline.assignmentStatusCell.drops`,{count:u})})]})]})}s();var Ar=1e4,jr=5e3;function Mr(e){let[t,n]=o(new Map);return $e(`pipeline.camera-metrics-snapshot`,t=>{let r=t.data;typeof r.deviceId==`number`&&(e!==void 0&&r.nodeId!==e||n(e=>new Map(e).set(r.deviceId,r)))}),a(()=>{if(t.size===0)return;let e=setInterval(()=>{n(e=>{let t=Date.now()-Ar,n=[...e].filter(([,e])=>e.timestamp>=t);return n.length===e.size?e:new Map(n)})},jr);return()=>clearInterval(e)},[t.size]),t}var Nr=3e5;function Pr({state:e,onlineNodes:t,nameOf:n,pending:r,onChange:a}){let{t:o}=X();return i(L,{"aria-label":o(`assignments.placementControls.nodePin`,`Node pin`),title:o(`assignments.placementControls.autoLetsEachSessionPick`,`Auto lets each session pick its node; a pin keeps the camera on one node.`),value:e.pinned&&e.nodeId!==null?e.nodeId:`auto`,disabled:r,options:[...Er(e,t,n)],onChange:e=>a(e.target.value)})}function Fr({deviceId:e,nodeId:t}){let{t:n}=X(),r=l(),{data:a}=lt({deviceId:e},{refetchOnMount:`always`}),{data:o}=vt({nodeId:t},{staleTime:Nr}),s=Dt({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});if(a===void 0||o===void 0)return i(`span`,{className:`text-[10px] italic text-foreground-subtle`,children:n(`assignments.placementControls.accelerator`,`accelerator: …`)});let c=o.devices??[],u=c.filter(e=>e.enabled),d=a?.deviceKey??`auto`,f=d!==`auto`&&!u.some(e=>e.key===d),p=c.find(e=>e.key===d),m=[{value:`auto`,label:n(`assignments.placementControls.anyAccelerator`,`Any accelerator`)},...f?[{value:d,label:n(`pipeline.placementControls.notEnabled`,{name:p?`${_n(p)} (${d})`:d})}]:[],...u.map(e=>({value:e.key,label:`${_n(e)} · ${e.format}`}))];return i(L,{"aria-label":n(`assignments.placementControls.inferenceDevicePin`,`Inference device pin`),title:n(`assignments.placementControls.pinDetectionToOneAccelerator`,`Pin detection to one accelerator of the node, or let each session pick.`),value:d,disabled:s.isPending,options:m,onChange:t=>s.mutate({deviceId:e,deviceKey:t.target.value})})}s();function Ir(e){let n=t(null);return e.nodeId!==null&&(n.current=e),n.current}function Lr({deviceId:t,state:n,...r}){let{t:a}=X(),o=Ir(n);return e(`div`,{className:`grid w-80 grid-cols-2 gap-1.5`,children:[i(Pr,{state:n,...r}),o?.nodeId==null?i(L,{"aria-label":a(`assignments.clusterRowCells.inferenceDevicePinNoNode`,`Inference device pin (no node yet)`),title:a(`assignments.clusterRowCells.anAcceleratorIsPinnedOn`,`An accelerator is pinned on the camera's node; this camera has not run on one yet.`),disabled:!0,defaultValue:`auto`,options:[{value:`auto`,label:a(`assignments.clusterRowCells.anyAccelerator`,`Any accelerator`)}]}):i(Fr,{deviceId:t,nodeId:o.nodeId})]})}function Rr({state:t,nameOf:n}){let{t:r}=X(),a=Ir(t);if(a?.nodeId==null)return i(`span`,{className:`text-[11px] text-foreground-subtle`,children:r(`assignments.clusterRowCells.noSessionYet`,`— no session yet`)});let o=t.active&&t.nodeId!==null,s=a.pinned?`pinned`:`auto · ${a.reason||`capacity`}`;return e(`div`,{"data-testid":`resolved-placement`,className:`flex w-40 min-w-0 flex-col leading-tight`,title:a.pinned?void 0:r(`assignments.clusterRowCells.anUnpinnedCameraIsPlaced`,`An unpinned camera is placed again at every session start, so this can change between sessions.`),children:[e(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs`,children:[i(`span`,{"aria-hidden":!0,className:`h-1.5 w-1.5 shrink-0 rounded-full ${o?`bg-success`:`bg-foreground-subtle/40`}`}),i(`span`,{"data-testid":`resolved-placement-node`,className:`truncate font-medium ${o?`text-foreground`:`text-foreground-muted`}`,children:n(a.nodeId)})]}),i(`span`,{className:`truncate pl-3 text-[10px] ${a.pinned?`text-warning`:`text-foreground-subtle`}`,children:o?s:r(`assignments.clusterRowCells.idleLastSession`,`{{how}} · idle, last session`,{how:s})})]})}function zr({deviceId:t,deviceName:n}){let{t:r}=X(),[a,s]=o(!1);return e(d,{children:[i(It,{icon:M,variant:`ghost`,size:`sm`,"aria-label":r(`assignments.clusterRowCells.streamBrokersOf`,`Stream brokers of {{deviceName}}`,{deviceName:n}),title:r(`assignments.clusterRowCells.streamBrokersClients`,`Stream brokers & clients`),onClick:()=>s(!0)}),i(pt,{open:a,onOpenChange:s,children:e(Be,{width:`lg`,scroll:`body`,placement:`sheet-on-mobile`,children:[i(xt,{children:i(Tt,{children:r(`pipeline.clusterRowCells.brokersTitle`,{device:n})})}),i(bn,{children:a&&i(Qe,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:t,instanceId:`pipeline-row/${t}`,config:{variant:`compact`}})})]})})]})}function Br(e){return e.hasFreshMetrics?`active`:e.hasPipelineAssignment?`recently-active`:`inactive`}function Vr(e,t){return t.size===0?!0:t.has(e)}var Hr=[{value:`active`,get label(){return Y.t(`helpers.cameraActivity.active`)}},{value:`recently-active`,get label(){return Y.t(`helpers.cameraActivity.recentlyActive`)}},{value:`inactive`,get label(){return Y.t(`helpers.cameraActivity.inactive`)}}];s();var Ur=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`];function Wr(e){for(let t of[`getPipelineAssignments`,`getAudioAssignments`,`getCameraStatuses`])e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,t]]})}function Gr(){let{t}=X(),r=l();At([`pipelineOrchestrator`,`getPipelineAssignments`],Ur),At([`pipelineOrchestrator`,`getAudioAssignments`],Ur),At([`pipelineOrchestrator`,`getCameraStatuses`],Ur);let{data:a}=Sn({isCamera:!0,projection:`slim`}),{data:s}=We(void 0),{data:c}=Yt(void 0),{data:u}=Pt({}),{data:d}=Zt(void 0),{nodes:f}=K(),p=Mr(),m=n(()=>wr(f),[f]),h=n(()=>xn(d),[d]),g=n(()=>f.filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[f]),v=n(()=>Sr(br((a??[]).map(e=>({id:e.id,name:e.name,disabled:e.disabled})),s??[],c??[]),u??[]),[a,s,c,u]),[y,b]=o(()=>new Set),x=n(()=>v.filter(e=>Vr(Br({hasPipelineAssignment:e.pipeline.active,hasFreshMetrics:p.has(e.deviceId)}),y)),[v,p,y]),S=e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},C=()=>Wr(r),w=Rt({onSuccess:C}),T=Re({onSuccess:C}),E=w.isPending||T.isPending,D=[{key:`camera`,header:t(`pipeline.cameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:n=>e(`div`,{className:`flex w-44 min-w-0 items-center gap-1.5`,children:[i(Tn,{to:`/devices/${String(n.deviceId)}`,className:`min-w-0 truncate text-xs font-medium text-primary hover:underline`,title:n.deviceName,children:n.deviceName}),n.disabled&&i(J,{variant:`default`,children:t(`common.off`)})]})},{key:`placement`,header:t(`pipeline.cameraAssignmentsTable.placement`,`Placement`),width:`w-80`,notSortableReason:`A pair of controls — editing one would move the row under the cursor.`,render:e=>i(Lr,{deviceId:e.deviceId,state:e.pipeline,onlineNodes:g,nameOf:m,pending:E,onChange:t=>t===`auto`?T.mutate({deviceId:e.deviceId}):w.mutate({deviceId:e.deviceId,agentNodeId:t})})},{key:`roles`,header:t(`pipeline.cameraAssignmentsTable.rolesHere`,`Roles here`),notSortableReason:`A set of roles has no single order.`,render:e=>i(Or,{detection:e.detection,decoder:e.decoder,audio:e.audio,nameOf:m,colorByNodeId:h})},{key:`resolved`,header:t(`pipeline.cameraAssignmentsTable.runningOn`,`Running on`),width:`w-40`,sortValue:e=>e.pipeline.nodeId===null?null:m(e.pipeline.nodeId),render:e=>i(Rr,{state:e.pipeline,nameOf:m})},{key:`status`,header:t(`pipeline.cameraAssignmentsTable.status`,`Status`),width:`w-40`,sortValue:e=>p.get(e.deviceId)?.metrics.actualFps??null,render:e=>i(kr,{snap:p.get(e.deviceId)})},{key:`brokers`,header:``,align:`right`,width:`w-10`,notSortableReason:`An action`,render:e=>i(zr,{deviceId:e.deviceId,deviceName:e.deviceName})}],O=a===void 0?`Loading cameras…`:v.length===0?`No cameras`:`No cameras match this activity filter.`;return e(`div`,{className:`flex flex-col gap-2`,children:[i(`nav`,{"aria-label":t(`pipeline.cameraAssignmentsTable.filterByCameraActivity`,`Filter by camera activity`),"data-testid":`assignments-activity-filter`,children:i(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:Hr.map(e=>{let t=y.has(e.value);return i(`button`,{type:`button`,"aria-pressed":t,"data-testid":`assignments-activity-${e.value}`,className:_(oe,t?ae:P),onClick:()=>S(e.value),children:e.label},e.value)})})}),i(dt,{columns:D,rows:x,rowKey:e=>e.deviceId,minWidthPx:920,maxBodyHeight:Ke,emptyMessage:O})]})}s();function Kr({nodeId:e}){let{t}=X(),r=l();At([`pipelineOrchestrator`,`getCameraStatuses`],Ur);let{data:a}=Pt({}),{data:o}=Zt(void 0),{data:s}=Sn({isCamera:!0,projection:`slim`}),{nodes:c}=K(),u=Mr(),d=n(()=>wr(c),[c]),f=n(()=>xn(o),[o]),p=n(()=>Cr(e,a??[],Tr((s??[]).map(e=>({id:e.id,name:e.name})))),[e,a,s]),m=c.filter(t=>t.isOnline&&t.id!==e),h=()=>Wr(r),g=Rt({onSuccess:h}),_=Re({onSuccess:h}),v=gn({onSuccess:h}),y=ft({onSuccess:h}),b=e=>[...e.detection.active?m.map(n=>({id:`detect-${n.id}`,label:t(`pipeline.nodeCameraAssignmentsTable.moveDetectionTo`,`Move detection to {{name}}`,{name:n.name}),onClick:()=>g.mutate({deviceId:e.deviceId,agentNodeId:n.id})})):[],...e.audio.active?m.map(n=>({id:`audio-${n.id}`,label:t(`pipeline.nodeCameraAssignmentsTable.moveAudioTo`,`Move audio to {{name}}`,{name:n.name}),onClick:()=>v.mutate({deviceId:e.deviceId,nodeId:n.id})})):[],{id:`unpin-detect`,label:t(`pipeline.nodeCameraAssignmentsTable.unpinDetection`,`Unpin detection`),hidden:!(e.detection.active&&e.detection.pinned),separatorBefore:!0,onClick:()=>_.mutate({deviceId:e.deviceId})},{id:`unpin-audio`,label:t(`pipeline.nodeCameraAssignmentsTable.unpinAudio`,`Unpin audio`),hidden:!(e.audio.active&&e.audio.pinned),onClick:()=>y.mutate({deviceId:e.deviceId})}];return i(dt,{columns:[{key:`camera`,header:t(`pipeline.nodeCameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:e=>i(Tn,{to:`/devices/${String(e.deviceId)}`,className:`block w-44 truncate text-xs font-medium text-primary hover:underline`,title:e.deviceName,children:e.deviceName})},{key:`roles`,header:t(`pipeline.nodeCameraAssignmentsTable.rolesHere`,`Roles here`),notSortableReason:`A set of roles has no single order.`,render:t=>i(Or,{detection:t.detection,decoder:t.decoder,audio:t.audio,nameOf:d,colorByNodeId:f,emphasizeOnNodeId:e})},{key:`status`,header:t(`pipeline.nodeCameraAssignmentsTable.status`,`Status`),width:`w-40`,sortValue:e=>u.get(e.deviceId)?.metrics.actualFps??null,render:e=>i(kr,{snap:u.get(e.deviceId)})},{key:`actions`,header:``,align:`right`,width:`w-10`,notSortableReason:`Actions`,render:e=>i(Qt,{items:b(e),title:t(`pipeline.nodeCameraAssignmentsTable.move`,`Move {{deviceName}}`,{deviceName:e.deviceName})})}],rows:p,rowKey:e=>e.deviceId,minWidthPx:560,maxBodyHeight:Ke,emptyMessage:a===void 0?t(`pipeline.nodeCameraAssignmentsTable.loadingCameras`,`Loading cameras…`):t(`pipeline.nodeCameraAssignmentsTable.noCameraRunsOnThis`,`No camera runs on this node right now`)})}function qr({nodeId:t,refreshToken:n}){let{t:r}=X(),{nodes:a}=K(),o=a.find(e=>e.id===t)?.name??t;return e(`div`,{className:`space-y-3 sm:space-y-4`,children:[i(_r,{refreshToken:n,nodeId:t}),e(`div`,{className:`space-y-2`,children:[e(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:r(`pipeline.nodeCamerasTab.camerasOn`,{node:o})}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`pipeline.nodeCamerasTab.theRolesEachCameraRuns`,`The roles each camera runs here right now. Move a role or unpin it from the row menu; pins for every camera are on Cluster → Assignments.`)})]}),i(Kr,{nodeId:t})]})]})}s();function Jr(e,t){let n=Math.max(0,t-e),r=Math.floor(e/1e3),i=Math.floor(n/1e3);return Y.t(`pipeline.nodeEnginesTab.idleLeft`,{idle:r,left:i})}function Yr({nodeId:t,refreshToken:r}){let{t:a}=X(),o=l(),s=F(),c=an({onSettled:()=>{o.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:u}=mn({nodeId:t}),d=ut(`pipeline.engine-metrics-snapshot`,e=>e.nodeId===t)?.engines??u??null,f=d===null;At([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:p}=hn({nodeId:t}),{values:m}=Ge(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,e=>e.nodeId===t),h=n(()=>m.filter(e=>e.metrics.phase===`active`).length,[m]),g=e=>{let n=p??[];if(n.length===0){c.mutate({nodeId:t,engine:e,force:!1});return}(async()=>{await s({title:a(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),message:`${String(n.length)} camera(s) are dispatching through this engine. Killing it drops their in-flight work and forces a respawn on the next frame.`,confirmLabel:a(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),variant:`danger`})&&c.mutate({nodeId:t,engine:e,force:!0})})()};return e(`div`,{className:`space-y-6`,children:[e(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:a(`pipeline.nodeEnginesTab.inferenceEnginesOnThisNode`,`Inference engines on this node`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`pipeline.nodeEnginesTab.summary`,{engines:(d??[]).length,cameras:(p??[]).length,active:h})})]}),i(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:e(`table`,{className:`w-full text-xs min-w-[640px]`,children:[i(`thead`,{className:`bg-surface`,children:e(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[i(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.kind`,`Kind`)}),i(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.runtimeBackendDevice`,`Runtime / Backend / Device`)}),i(`th`,{className:`text-left px-3 py-2`,children:a(`pipeline.nodeEnginesTab.models`,`Models`)}),i(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.poolPid`,`Pool PID`)}),i(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.autoKill`,`Auto-kill`)}),i(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.inUse`,`In use`)}),i(`th`,{className:`w-20`})]})}),e(`tbody`,{children:[f&&i(`tr`,{children:i(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:a(`common.loading`,`Loading…`)})}),!f&&(d??[]).map(t=>{let n=t.kind===`device-pool`;return e(`tr`,{className:`border-t border-border ${n?`bg-primary/[0.05]`:``}`,children:[i(`td`,{className:`px-3 py-2`,children:e(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${n?`bg-primary/15 text-primary`:`bg-success/15 text-success`}`,children:[i(n?Ie:S,{className:`h-3 w-3`}),a(n?`pipeline.nodeEnginesTab.pool`:`pipeline.nodeEnginesTab.runtime`)]})}),i(`td`,{className:`px-3 py-2`,children:e(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[i(U,{className:`h-3 w-3`}),t.engine.runtime,`/`,t.engine.backend,t.engine.device?`/${t.engine.device}`:``,t.engine.format?` · ${t.engine.format}`:``]})}),i(`td`,{className:`px-3 py-2`,children:t.modelsLoaded.length===0?i(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):i(`div`,{className:`flex flex-wrap gap-1`,children:t.modelsLoaded.map(e=>i(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),i(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:t.poolPid??`—`}),i(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:t.idleMs!==null&&t.idleTtlMs!==null?i(`span`,{className:`text-foreground-subtle`,children:Jr(t.idleMs,t.idleTtlMs)}):i(`span`,{className:`text-foreground-subtle/50`,children:a(`common.never`)})}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:(p??[]).length}),i(`td`,{className:`px-3 py-2 text-right`,children:n?i(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`common.auto`)}):e(G,{variant:`ghost`,size:`sm`,disabled:c.isPending,onClick:()=>g(t.engine),className:`text-danger hover:bg-danger/10 hover:text-danger`,children:[i(ie,{className:`h-3.5 w-3.5`}),a(`pipeline.nodeEnginesTab.kill`,`Kill`)]})})]},t.engineKey)}),!f&&(d??[]).length===0&&i(`tr`,{children:i(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:a(`pipeline.nodeEnginesTab.noEnginesResidentTheFactory`,`No engines resident — the factory spins up on the first pipeline run.`)})})]})]})}),i(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:i(En,{i18nKey:`pipeline.nodeEnginesTab.legend`,components:{strong:i(`strong`,{className:`text-foreground`})}})}),c.isError&&i(kt,{message:a(`pipeline.nodeEnginesTab.killFailed`,{message:c.error instanceof Error?c.error.message:a(`common.unknownError`)})})]})}var Xr=`pipeline-runner`,Zr=200;function Qr({nodeId:t}){let{t:n}=X();return e(`div`,{className:`flex flex-col gap-3`,children:[e(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:n(`pipeline.nodeLogsTab.runnerLogs`,`Runner logs`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`pipeline.nodeLogsTab.description`,{node:t})})]}),i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:i(sn,{agentId:t,addonId:Xr,limit:Zr,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1,showSourceSelect:!0})})]})}s();function $r({nodeId:t,title:r}){let a=I(),{t:o}=X(),{data:s}=wn(),{data:c}=We(void 0),l=n(()=>{let e=new Map;for(let t of s??[])e.set(t.id,t.name);return e},[s]),u=n(()=>{if(!t)return null;let e=new Set;for(let n of c??[])n.agentNodeId===t&&e.add(n.deviceId);return e},[t,c]),d=Mr(t),f=n(()=>{let e=[];for(let t of d.values())u&&!u.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[d,u]);return f.length===0?e(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[r??o(`pipeline.cameraStatusStrip.cameras`,`Cameras`),`: no live snapshots yet`]}):e(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[e(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[i(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:r??o(`pipeline.cameraStatusStrip.cameras`,`Cameras`)}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:f.length})]}),i(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(t=>{let n=l.get(t.deviceId)??`#${t.deviceId}`,r=Nt(t.metrics.phase,a);return e(`div`,{title:o(`pipeline.cameraStatusStrip.fpsMsInferQ`,`{{name}} · {{label}} · {{value3}} fps · {{value4}}ms infer · q={{queueDepth}}`,{name:n,label:r.label,value3:t.metrics.actualFps.toFixed(1),value4:t.metrics.avgInferenceTimeMs.toFixed(0),queueDepth:t.metrics.queueDepth}),className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${r.badgeClass}`,children:[i(Vt,{phase:t.metrics.phase,className:`h-2.5 w-2.5`}),i(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:n}),i(`span`,{className:`font-mono tabular-nums`,children:t.metrics.actualFps.toFixed(1)}),i(`span`,{className:`opacity-60`,children:o(`common.fpsWord`)})]},t.deviceId)})})]})}function ei(e,t,n,r){let i=t===void 0?void 0:e.find(e=>e.key===t)?.steps?.[n]?.settings,a={...r?.[n],...i};return Object.keys(a).length>0?a:void 0}function ti(e){let t={};for(let n of e){let e=Object.keys(n.steps).length>0;t[n.key]={enabled:n.enabled,weight:Math.max(1,n.weight),...n.maxSessions!==null&&n.maxSessions>0?{maxSessions:n.maxSessions}:{},...e?{steps:n.steps}:{}}}return t}var ni=`pipeline-analytics`,ri=`face-gallery`,ii=`pipeline-orchestrator`,ai=`pipeline-runner`,oi=`audio-analyzer`;function si(e){return[...ge.filter(t=>t.stepId===e).map(e=>Te(e.stepId)),...xe.filter(t=>t.stepId===e).map(e=>ve(e.stepId,e.key))]}var ci=`faces`,li=`semantic-search`,ui=`load-balancer`,di=`load`,fi=[{id:ci,get title(){return Y.t(`helpers.clusterSettingsSections.facesTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.facesHint`)},panels:[{addonId:ii,fieldKeys:si(`face-embedding`)},{addonId:ni,capability:ri}]},{id:li,get title(){return Y.t(`helpers.clusterSettingsSections.semanticTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.semanticHint`)},panels:[{addonId:ii,fieldKeys:si(`clip-embedding`)}]},{id:ye,get title(){return Y.t(`helpers.clusterSettingsSections.cropTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.cropHint`)},panels:[{addonId:ii,sectionIds:[ye]}]},{id:be,get title(){return Y.t(`helpers.clusterSettingsSections.nativeTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.nativeHint`)},panels:[{addonId:ii,sectionIds:[be]}]},{id:`runner-defaults`,get title(){return Y.t(`helpers.clusterSettingsSections.runnerTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.runnerHint`)},panels:[{addonId:ai,fieldScope:`cluster`},{addonId:oi,fieldScope:`cluster`}]},{id:ui,get title(){return Y.t(`helpers.clusterSettingsSections.loadTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.loadHint`)},panels:[{addonId:ii,sectionIds:[di]}]},{id:`failover`,get title(){return Y.t(`helpers.clusterSettingsSections.failoverTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.failoverHint`)},panels:[{addonId:ii,sectionIds:[`failover`]}]}],pi={"cluster-step-models":ci};function mi(e){return e===`clip-embedding`?li:ci}var hi=`ctab`,gi=`section`;function _i(e,t){let n=new URLSearchParams({view:`nodes`,node:$o,[hi]:e});return t!==void 0&&n.set(gi,t),`/system/pipeline?${n.toString()}`}function vi(e){return _i(`settings`,mi(e))}function yi(){return _i(`load-balancing`)}var bi=`pipeline-orchestrator`;function xi(e){return ge.find(t=>t.stepId===e)??null}function Si({step:t,engineFormat:n,runnableModelIds:r}){let{t:a}=X(),{data:o}=bt({addonId:bi,cap:bi,scope:`cluster`}),s=we(o??null)[t.stepId]??t.defaultModelId,c=t.options.find(e=>e.id===s)?.label??s,l=r.length>0&&!r.includes(s);return e(`div`,{className:`space-y-2 rounded-md border border-primary/30 bg-primary/5 px-3 py-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[i(`span`,{className:`font-medium text-foreground`,children:t.label}),i(`span`,{className:`font-mono text-foreground`,children:c}),i(`span`,{title:a(`pipeline.clusterStepModel.oneValueForTheWhole`,`One value for the whole cluster — this step writes into a shared vector index, where two encoders make similarity scores meaningless.`),className:`rounded border border-primary/40 bg-primary/10 px-1 py-px text-[9px] font-medium uppercase tracking-wide text-primary`,children:a(`pipeline.clusterStepModel.clusterWide`)}),i(Tn,{to:vi(t.stepId),className:`ml-auto text-[11px] text-primary hover:underline`,children:a(`pipeline.clusterStepModel.changeInClusterSettings`,`Change in Cluster → Settings ›`)})]}),e(`p`,{className:W,children:[a(`pipeline.clusterStepModel.oneModelForEveryNode`,`One model for every node and camera:`),` `,a(`pipeline.clusterStepModel.indexNote`,{index:t.indexName})]}),l&&i(`p`,{className:`rounded border border-warning/40 bg-warning/10 px-2 py-1 text-[10px] leading-snug text-warning`,children:i(En,{i18nKey:`pipeline.clusterStepModel.noBuild`,values:{engine:n,model:s,index:t.indexName},components:{b:i(`b`,{})}})})]})}var Ci=`pipeline-orchestrator`;function wi({addonId:t,highlightLabel:n}){let{t:r}=X(),a=_e(t),{data:o}=bt({addonId:Ci,cap:Ci,scope:`cluster`});if(a.length===0)return null;let s=Se(o??null)[t]??{};return e(`section`,{className:`space-y-1.5 border-t border-border/60 pt-3`,"aria-label":r(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`),children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`h3`,{className:A,children:r(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`)}),i(Tn,{to:vi(t),className:`ml-auto text-[11px] text-primary hover:underline`,children:r(`stepInspector.clusterOwnedSettings.editInClusterSettings`,`Edit in Cluster → Settings ›`)})]}),a.map(t=>e(`div`,{className:`${f} rounded px-2 ${n===t.label?`bg-primary/5 ring-1 ring-primary/40`:``}`,children:[i(`span`,{className:R,children:t.label}),i(`span`,{className:b,children:i(`span`,{className:`font-mono text-xs text-foreground`,children:String(s[t.key]??t.default)})})]},t.key)),i(`p`,{className:W,children:r(`stepInspector.clusterOwnedSettings.oneValueForEveryNode`,`One value for every node and camera — this step writes into a shared index.`)})]})}function Ti({rows:t,hint:n}){let{t:r}=X();return e(`div`,{className:`space-y-1.5`,"data-testid":`effective-models`,children:[i(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.map(t=>e(`li`,{className:`${D} flex flex-wrap items-baseline gap-x-2 text-xs`,children:[i(`span`,{className:t.href===void 0?`min-w-0 flex-1 truncate text-foreground-muted`:`basis-full text-foreground-muted`,children:t.label}),i(`span`,{className:`font-mono text-foreground`,children:t.modelId??`—`}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:t.sourceLabel}),t.href!==void 0&&i(Tn,{to:t.href,className:`ml-auto text-[11px] text-primary hover:underline`,children:r(`stepInspector.effectiveModelSummary.changeOnAccelerator`)})]},t.id))}),i(`p`,{className:W,children:n??r(`stepInspector.effectiveModelSummary.toChangeAModelOpen`,`To change a model, open that accelerator's cell in the table.`)})]})}s();function Ei(e){return{agentNodeId:e.nodeId,nodeLabel:e.nodeLabel,engineLabel:e.device.format,deviceKey:e.deviceKey,deviceLabel:_n(e.device),detail:e.device.defaultModelId,disabled:e.disabled}}function Di({tree:a,searchRows:s,accelerators:c,cellState:l,stepBadge:u,disabledCount:d,showDisabled:f,onShowDisabledChange:p,dirty:m,onDiscard:h,summary:g,toolbar:_,label:y,renderDetail:b}){let{t:x}=X(),S=F(),C=tn(),{selection:w,open:T,close:E}=zn(n(()=>An(a).map(e=>e.node.addonId),[a]),n(()=>c.map(e=>e.id),[c])),[D,O]=o(``),[A,j]=o(null),[M,ee]=o(null),N=t(null),P=t(null),te=t(null);Kt(te);let I=t(null),L=n(()=>St(s,D),[s,D]),R=n(()=>D.trim()===``?a:Hn(a,new Set(L.map(e=>e.addonId))),[a,L,D]),z=e=>L.find(t=>t.addonId===e)?.matchedField??null,B=n(()=>c.map(Ei),[c]),ne=e=>c.find(t=>t.nodeId===e.agentNodeId&&t.deviceKey===e.deviceKey),V=c.find(e=>e.id===w.acceleratorId)??null,re=w.stepId!==null,H=r(async e=>{if(m){if(!await S({title:x(`stepInspector.stepMatrixFrame.discardUnsavedChanges`,`Discard unsaved changes?`),message:x(`stepInspector.stepMatrixFrame.thisStepHasChangesThat`,`This step has changes that are not saved yet.`),confirmLabel:x(`stepInspector.stepMatrixFrame.discard`,`Discard`),variant:`danger`}))return;h()}e()},[S,m,h,x]),ie=()=>{requestAnimationFrame(()=>I.current?.focus())},ae=(e,t,n=!1)=>{if(e===w.stepId&&(t?.id??null)===w.acceleratorId){n&&ie();return}let r=()=>{j(z(e)),T({stepId:e,...t===void 0?{}:{acceleratorId:t.id}}),n&&ie()};e===w.stepId?r():H(r)},U=()=>{let e=w.stepId;H(()=>{if(E(),e!==null){let t=V===null?null:cn({agentNodeId:V.nodeId,deviceKey:V.deviceKey});requestAnimationFrame(()=>N.current?.focusCell(e,t))}})},oe=e=>{if(e.key===`Enter`){let t=L[0];if(t===void 0)return;e.preventDefault(),ae(t.addonId,void 0,!0)}else e.key===`Escape`&&O(``)},se=C?i(wt,{onClick:U}):i(It,{icon:k,variant:`ghost`,size:`sm`,"aria-label":x(`common.close`,`Close`),onClick:U});return e(`div`,{ref:P,className:`space-y-2`,onKeyDown:e=>{let t=e.target instanceof HTMLElement&&e.target.dataset.r!==void 0;e.key===`/`&&t&&(e.preventDefault(),te.current?.focus()),e.key===`Escape`&&t&&re&&(e.preventDefault(),U())},children:[e(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[i(`div`,{className:`min-w-0 basis-full sm:basis-auto`,children:g}),i(fn,{ref:te,type:`search`,value:D,onChange:e=>O(e.target.value),onKeyDown:oe,placeholder:x(`stepInspector.stepMatrixFrame.filterStepsOrSettings`,`Filter steps or settings /`),"aria-label":x(`stepInspector.stepMatrixFrame.filterStepsOrSettings2`,`Filter steps or settings`),className:`h-9 w-56 rounded-md border border-border bg-background px-2 text-xs text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 md:h-7`}),d>0&&e(`label`,{className:`inline-flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(v,{checked:f,onChange:e=>p(e.target.checked)}),x(`stepInspector.stepMatrixFrame.showDisabled`,{count:d})]}),_]}),w.staleStepId!==null&&i(`p`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-1.5 text-[11px] text-warning`,children:x(`stepInspector.stepMatrixFrame.staleStep`,{id:w.staleStepId})}),R.length===0?i(`p`,{className:`${W} rounded-md border border-dashed border-border px-3 py-4 text-center`,children:x(`stepInspector.stepMatrixFrame.noStepMatches`,{query:D})}):i(Ut,{ref:N,tree:R,agents:B,label:y,getCellState:(e,t)=>{let n=ne(t);return n===void 0?{kind:`na`}:l(e,n)},onCellClick:(e,t,n)=>ae(e,ne(t),n),onStepClick:(e,t)=>ae(e,void 0,t),...u===void 0?{}:{stepBadge:u},selectedCell:re&&w.stepId!==null&&V!==null?{addonId:w.stepId,agentNodeId:V.nodeId,deviceKey:V.deviceKey}:null,fallbackNodeId:M,onFallbackNodeChange:ee,reserveRightPx:re&&!C?432:0}),i(nt,{open:re,anchor:P,onClose:U,label:x(`stepInspector.stepMatrixFrame.stepSettings`,`Step settings`),children:w.stepId!==null&&b({stepId:w.stepId,accelerator:V,matchedField:A,closeButton:se,onEscape:U,headingRef:e=>{I.current=e}})})]})}s();function Oi(e){a(()=>{if(e===null)return;let t=document.getElementById(e);t===null||typeof t.scrollIntoView!=`function`||t.scrollIntoView({block:`center`,behavior:`smooth`})},[e])}s();function ki(e,t,n){return e.map(e=>{let r={...e.steps},i=r[t.stepId]??{},a=t.models[e.key],o=t.jumps[e.key],s=t.accelerator?.deviceKey===e.key?{...Object.fromEntries(Object.entries(i.settings??{}).filter(([e])=>!n(e))),...t.accelerator.settings}:i.settings,c=s!==void 0&&Object.keys(s).length>0?s:void 0,l=a===void 0?i.modelId:a??void 0,u=o===void 0?i.jumpDeviceKey:o||void 0,d={...l===void 0?{}:{modelId:l},...c===void 0?{}:{settings:c},...u===void 0?{}:{jumpDeviceKey:u}};return Object.keys(d).length>0?r[t.stepId]=d:delete r[t.stepId],{key:e.key,enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:r}})}function Ai(e,t){return t===void 0?0:[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>!Ee(e[n],t[n])).length}function ji(e,t,n,r){if(t===null)return 0;let i=Object.entries(t.models).filter(([n,r])=>(r??void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.modelId).length,a=Object.entries(t.jumps).filter(([n,r])=>(r||void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.jumpDeviceKey).length,o=Ai(n,t.nodeSettings),s=t.accelerator===void 0?0:Ai(r(t.accelerator.deviceKey),t.accelerator.settings);return i+a+o+s}function Mi({nodeId:t,nodeName:r,toolbar:a}){let{t:s}=X(),c=l(),u=vt({nodeId:t},{refetchOnMount:`always`}),f=jt({nodeId:t},{refetchOnMount:`always`}),p=nn({agentNodeId:t},{refetchOnMount:`always`}),m=p.data?.stepSettings,h=we(bt({addonId:`pipeline-orchestrator`,cap:`pipeline-orchestrator`,scope:`cluster`}).data??null),g=u.data?.devices??[],_=f.data??null,[v,y]=o(null),[b,x]=o(null),[S,C]=o(null),w=ht({onSuccess:()=>{c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),T=tt({onSuccess:()=>{c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]})}}),[E,D]=o(!1),O=n(()=>_?ze(_):[],[_]),k=n(()=>An(O),[O]),[j,M]=o(!1),ee=n(()=>Un(t,r,g,j),[t,r,g,j]),N=n(()=>Un(t,r,g),[t,r,g]),P=N.length>=2,te=(e,t)=>ei(g,t?.deviceKey,e,m)??{},F=e=>m?.[e]??{},I=(e,t)=>g.find(e=>e.key===t)?.steps?.[e]?.settings??{},R=(e,t,n)=>{let r=n??t.device.steps?.[e?.id??``]?.jumpDeviceKey;if(r!==void 0&&r!==``)return N.find(e=>e.deviceKey===r);if(!Rn(e,t))return N.filter(n=>n.id!==t.id&&Rn(e,n)).toSorted((e,t)=>e.deviceKey.localeCompare(t.deviceKey))[0]},z=(e,t)=>{let n=Ln(_,e),r=xi(e),i=Mn(_,t),a=te(e,t),o=R(n,t);return Bn({addon:n,acc:t,gatedOn:n?.enabledByDefault??!0,model:n?Pn(n,t,{nodePin:t.device.steps?.[e]?.modelId}):{modelId:void 0,source:`default`},...Vn(e,a,i)&&i?{rootName:i.name}:{},...r?{clusterModelId:h[e]??r.defaultModelId}:{},...o?{jumpTo:_t(o.device)}:{}})},B=k.map(({node:e})=>({addonId:e.addonId,name:e.addonName,fieldLabels:Nn(Ln(_,e.addonId))}));if(u.isLoading||f.isLoading||p.isLoading)return i(`div`,{className:`animate-pulse p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.loadingPipeline`,`Loading pipeline…`)});if(_===null)return i(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.catalogUnavailable`,`Catalog unavailable.`)});let ne=e(`span`,{className:W,children:[s(`stepInspector.nodeStepInspector.accelerators`,`Accelerators:`),` `,i(`span`,{className:`text-foreground`,children:N.length>0?N.map(e=>_t(e.device)).join(` · `):s(`stepInspector.nodeStepInspector.noneEnabled`,`none enabled`)}),g.some(e=>!e.enabled)&&e(d,{children:[` `,s(`stepInspector.nodeStepInspector.off`,`— off:`),` `,g.filter(e=>!e.enabled).map(_t).join(`, `)]}),` `,`·`,` `,i(Tn,{to:yi(),className:`text-primary hover:underline`,children:s(`stepInspector.nodeStepInspector.clusterLoadBalancing`,`Cluster → Load balancing ›`)})]});return i(Di,{tree:O,searchRows:B,accelerators:ee,cellState:z,disabledCount:g.filter(e=>!e.enabled).length,showDisabled:j,onShowDisabledChange:M,dirty:v!==null&&ji(g,v,F(v.stepId),e=>I(v.stepId,e))>0,onDiscard:()=>y(null),summary:ne,...a===void 0?{}:{toolbar:a},label:s(`stepInspector.nodeStepInspector.detectionSteps`,`Detection steps`),renderDetail:({stepId:n,accelerator:a,matchedField:o,closeButton:c,onEscape:l,headingRef:u})=>{let f=Ln(_,n);if(f===null)return i(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.noStepSelected`,`No step selected.`)});let p=v?.stepId===n?v:null,m=a??N[0]??ee[0],h=p?.nodeSettings??F(n),O=a===null?{}:p?.accelerator?.deviceKey===a.deviceKey?p.accelerator.settings:I(n,a.deviceKey),k={...h,...O},j=ji(g,p,F(n),e=>I(n,e)),M=e=>{C(null),y(t=>({...t?.stepId===n?t:{stepId:n,models:{},jumps:{}},...e}))},z=xi(n),B=en(f),{nodeFields:ne,acceleratorFields:V}=Wn(B),re=new Set(V.flatMap(e=>`key`in e?[e.key,`${e.key}ModelId`]:[])),H=m===void 0?void 0:Mn(_,m),ie=e=>{let t=p?.models[e.deviceKey];return t===void 0?e.device.steps?.[n]?.modelId:t??void 0},ae=m===void 0?void 0:Pn(f,m,{nodePin:ie(m)}).modelId,U=t=>{let r=ie(t),o=Pn(f,t,{nodePin:r}),c=Mn(_,t),l=Vn(n,a?.id===t.id?k:te(n,t),c),u=p?.jumps[t.deviceKey],m=R(f,t,u),h=Rn(f,t)?l&&c?i(Ht,{rootModel:c,stepModelId:o.modelId}):void 0:e(d,{children:[s(`stepInspector.nodeStepInspector.noBuild`,{format:t.device.format}),` `,m?s(`stepInspector.nodeStepInspector.itRunsOnInstead`,`It runs on {{shortLabel}} instead.`,{shortLabel:m.shortLabel}):s(`stepInspector.nodeStepInspector.itDoesNotRunHere`,`It does not run here.`)]}),g=P?e(`label`,{className:`block space-y-1`,children:[i(`span`,{className:`text-[11px] font-medium text-foreground`,children:s(`stepInspector.nodeStepInspector.runOn`,`Run on`)}),i(L,{"aria-label":s(`stepInspector.nodeStepInspector.runOn`,`Run on`),value:u??t.device.steps?.[n]?.jumpDeviceKey??``,options:[{value:``,label:s(`stepInspector.nodeStepInspector.autoThisAcceleratorOrThe`,`Auto (this accelerator, or the next one that can run it)`)},...N.filter(e=>e.id!==t.id).map(e=>({value:e.deviceKey,label:`${e.label} · ${e.device.format}`}))],onChange:e=>M({jumps:{...p?.jumps,[t.deviceKey]:e.target.value}})}),i(`span`,{className:W,children:s(`stepInspector.nodeStepInspector.routesThisStepAndIts`,`Routes this step (and its child steps) to another accelerator of this node.`)})]}):void 0;return{label:t.label,format:t.device.format,modelId:o.modelId,source:o.source===`node`?`node`:`default`,sourceLabel:o.source===`node`?`node pin`:`hardware default`,models:gt(f.models??[],t.device.format),defaultModelId:f.defaultModelIdByFormat?.[t.device.format]??f.defaultModelId,expanded:b===t.id,onToggle:()=>x(e=>e===t.id?null:t.id),onChangeModel:e=>M({models:{...p?.models,[t.deviceKey]:e}}),...r===void 0?{}:{onReset:()=>M({models:{...p?.models,[t.deviceKey]:null}}),resetLabel:`Reset to hardware default`},...h===void 0?{}:{note:h},...g===void 0?{}:{extra:g},changed:p?.models[t.deviceKey]!==void 0||u!==void 0}},oe=async()=>{if(p!==null){D(!0);try{(Object.keys(p.models).length>0||Object.keys(p.jumps).length>0||p.accelerator!==void 0)&&await w.mutateAsync({agentNodeId:t,inferenceDevices:ti(ki(g,p,e=>re.has(e)))}),p.nodeSettings!==void 0&&Ai(F(n),p.nodeSettings)>0&&await T.mutateAsync({agentNodeId:t,addonId:n,settings:Object.keys(p.nodeSettings).length>0?{...p.nodeSettings}:null}),y(null),C({kind:`saved`})}catch(e){C({kind:`error`,error:e instanceof Error?e.message:String(e)})}finally{D(!1)}}};return i(yt,{ref:u,title:a===null?`${f.name} · ${r}`:`${f.name} · ${a.label}`,subtitle:a===null?s(`stepInspector.nodeStepInspector.everyAcceleratorOf`,`{{slot}} · every accelerator of {{nodeName}}`,{slot:f.slot,nodeName:r}):s(`stepInspector.nodeStepInspector.baseForEveryCameraThat`,`{{slot}} · {{format}} · base for every camera that lands here`,{slot:f.slot,format:a.device.format}),leading:c,onEscape:l,saveBar:{dirtyCount:j,saving:E,status:S?.kind??null,...S?.error===void 0?{}:{error:S.error},onSave:()=>void oe(),onDiscard:()=>y(null)},children:e(`div`,{className:`space-y-3`,children:[e(`section`,{className:`space-y-2`,"aria-label":s(`stepInspector.nodeStepInspector.model`,`Model`),children:[i(`h3`,{className:A,children:s(`stepInspector.nodeStepInspector.model`,`Model`)}),z!==null&&m!==void 0?i(Si,{step:z,engineFormat:m.device.format,runnableModelIds:gt(f.models??[],m.device.format).map(e=>e.id)}):ee.length===0?i(`p`,{className:W,children:i(En,{i18nKey:`stepInspector.nodeStepInspector.noAcceleratorEnabled`,components:{link:i(Tn,{to:yi(),className:`text-primary hover:underline`})}})}):a===null?i(Ti,{rows:ee.map(e=>{let t=Pn(f,e,{nodePin:ie(e)});return{id:e.id,label:e.label,modelId:t.modelId,sourceLabel:t.source===`node`?`node pin`:`hardware default`}})}):i(Ye,{...U(a)},a.id)]}),(B.length>0||H!==void 0)&&z===null&&e(`section`,{"aria-label":s(`stepInspector.nodeStepInspector.settings`,`Settings`),className:`space-y-2 border-t border-border/60 pt-2`,children:[i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`settings-scope`,children:s(`stepInspector.nodeStepInspector.nodeWideSettings`,{node:r})}),(ne.length>0||H!==void 0)&&i(Ni,{addon:f,fields:ne,settings:h,layerLabel:s(`stepInspector.nodeStepInspector.nodeLayer`,`Node`),modelId:on(f,ae,k,H),root:H,highlight:o,onChange:e=>M({nodeSettings:e})}),V.length>0&&(a===null?i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`accelerator-settings-hint`,children:s(`stepInspector.nodeStepInspector.thresholdsPerAccelerator`,`Confidence thresholds belong to the model, so they are set per accelerator: open that accelerator's cell.`)}):e(`div`,{className:`space-y-1 border-t border-border/60 pt-2`,children:[i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`accelerator-settings-scope`,children:s(`stepInspector.nodeStepInspector.acceleratorSettings`,{accelerator:a.label})}),i(Ni,{addon:f,fields:V,settings:O,layerLabel:s(`stepInspector.nodeStepInspector.acceleratorLayer`,`This accelerator`),modelId:on(f,ae,k,H),root:void 0,highlight:o,onChange:e=>M({accelerator:{deviceKey:a.deviceKey,settings:e}})})]}))]}),i(wi,{addonId:n,highlightLabel:o})]})})}})}function Ni({addon:e,fields:t,settings:n,layerLabel:r,modelId:a,root:o,highlight:s,onChange:c}){let l=t.find(e=>`label`in e&&e.label===s)?.key??null;return Oi(l===null?null:Gt(l)),i(Jt,{addon:e,fields:t,layers:{node:n},target:`node`,labels:{node:r},modelId:a,...o===void 0?{}:{rootModel:o},highlightKey:l,onChangeLayer:c})}s();function Pi({nodeId:t,refreshToken:n}){let{t:r}=X(),a=F(),[s,c]=o(null),{nodes:l}=K(),u=l.find(e=>e.id===t)?.name??t,f=qe({onSuccess:e=>{c(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 a({title:r(`pipeline.nodePipelineTab.resetToHardwareAwareDefaults`,`Reset {{nodeName}} to hardware-aware defaults?`,{nodeName:u}),message:r(`pipeline.nodePipelineTab.thisClearsEveryPerDevice`,`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:r(`common.reset`,`Reset`),variant:`danger`})&&(c(null),f.mutate({agentNodeId:t}))};return e(`div`,{className:`space-y-2`,children:[i($r,{nodeId:t}),i(Mi,{nodeId:t,nodeName:u,toolbar:e(d,{children:[s&&i(`span`,{className:`text-[11px] text-success`,children:s}),f.isError&&i(`span`,{className:`text-[11px] text-danger`,children:f.error instanceof Error?f.error.message:r(`pipeline.nodePipelineTab.resetFailed`,`Reset failed`)}),i(G,{variant:`outline`,size:`sm`,onClick:()=>{p()},disabled:f.isPending,title:r(`pipeline.nodePipelineTab.clearThisNodeSPer`,`Clear this node's per-device model defaults + per-camera overrides scoped to this node`),children:f.isPending?r(`pipeline.nodePipelineTab.resetting`,`Resetting…`):r(`pipeline.nodePipelineTab.resetToDefault`,`Reset to default`)})]})})]})}var Fi=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],Ii=`decoder-nodeav`,Li=`ntab`,Ri={decoder:`engine`},zi={engine:`Engine & decoder`},Bi=`Nothing here is set per node. Cluster-wide values are on Cluster → Settings.`;function Vi({nodeId:t,refreshToken:n}){let{t:r}=X(),[a,o]=Dn(),{nodes:s}=K(),c=s.find(e=>e.id===t)?.addons.find(e=>e.capabilities.includes(`decoder`))?.addonId??Ii,l=[...Fi,c],u=a.get(Li),d={assignments:{id:`assignments`,label:r(`pipeline.nodeDetail.assignments`,`Assignments`),order:-10,content:i(qr,{nodeId:t,refreshToken:n})},tree:{id:`tree`,label:r(`pipeline.nodeDetail.pipeline`,`Pipeline`),order:39,content:i(Pi,{nodeId:t,refreshToken:n})},engines:{id:`engines`,label:r(`pipeline.nodeDetail.warmInstances`,`Warm instances`),order:180,content:i(Yr,{nodeId:t,refreshToken:n})},logs:{id:`logs`,label:r(`pipeline.nodeDetail.logs`,`Logs`),order:300,content:i(Qr,{nodeId:t})}},f=gr.map(e=>d[e]);return e(`div`,{className:`flex flex-col h-full`,children:[i(hr,{nodeId:t,refreshToken:n}),i(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6`,children:i(On,{nodeId:t,addonIds:l,level:`global`,fieldScope:`perNode`,emptyMessage:Bi,tabAliases:Ri,tabLabelOverrides:zi,extraTabs:f,activeTab:u===null?null:Ri[u]??u,onActiveTabChange:e=>o(t=>{let n=new URLSearchParams(t);n.set(Li,e);for(let e of In)n.delete(e);return n},{replace:!0})})})]})}function Hi(){let{t}=X();return e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`min-w-0`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`pipeline.clusterAssignmentsTab.cameraPlacement`,`Camera placement`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.clusterAssignmentsTab.pinACameraToA`,`Pin a camera to a node, or to one accelerator of its node; Auto lets each session pick. Decode always runs with detection. Load, shares and caps are on Load balancing.`)})]}),i(Gr,{})]})}function Ui(e){return`${Math.round(e*100)}%`}function Wi(e){return Y.t(`helpers.autoTuneViewModel.sessions`,{count:e})}var Gi={"intel-npu":`Intel NPU`,"intel-igpu":`Intel iGPU`,"amd-igpu":`AMD iGPU (WebGPU)`,"amd-npu":`AMD XDNA NPU`,"x86-cpu":`CPU`,"arm-cpu":`CPU`,"apple-ane":`Apple Neural Engine`,coral:`Coral Edge TPU`},Ki={"intel-core-ultra":`Intel Core Ultra`,"intel-n-series":`Intel N-series`,"apple-m-base":`Apple M (base)`,"apple-m-pro":`Apple M Pro / Max / Ultra`,"amd-phoenix":`AMD Ryzen Phoenix / Hawk Point`,unknown:`Not measured`};function qi(e){return e===null?`—`:Gi[e]??e}function Ji(e){return e===null?`—`:Ki[e]??e}function Yi(e){switch(e.kind){case`capacity`:return Y.t(`helpers.autoTuneViewModel.capacity`,{sessions:Wi(e.sessions),min:e.minSessions});case`tie-faster`:return Y.t(`helpers.autoTuneViewModel.tieFaster`,{over:e.over,recall:Ui(e.recallDelta)});case`stepped-down`:return Y.t(`helpers.autoTuneViewModel.steppedDown`,{from:e.from,limitedBy:e.limitedBy,to:e.to});case`no-fit-lightest`:return Y.t(`helpers.autoTuneViewModel.noFitLightest`,{min:Wi(e.minSessions),sessions:Wi(e.sessions)});case`derived-latency`:return Y.t(`helpers.autoTuneViewModel.derivedLatency`,{modelId:e.modelId});case`cpu-device`:return Y.t(`helpers.autoTuneViewModel.cpuDevice`);case`device-disabled`:return Y.t(`helpers.autoTuneViewModel.deviceDisabled`);case`device-unavailable`:return Y.t(`helpers.autoTuneViewModel.deviceUnavailable`);case`node-offline`:return Y.t(`helpers.autoTuneViewModel.nodeOffline`);case`no-hardware-facts`:return Y.t(`helpers.autoTuneViewModel.noHardwareFacts`);case`no-measured-data`:return Y.t(`helpers.autoTuneViewModel.noMeasuredData`);case`no-family-build`:return Y.t(`helpers.autoTuneViewModel.noFamilyBuild`,{format:e.format});case`kept-custom-pin`:return Y.t(`helpers.autoTuneViewModel.keptCustomPin`,{modelId:e.modelId,deviceKey:e.deviceKey})}}function Xi(e,t){switch(e.kind){case`custom-pin-kept`:return Y.t(`helpers.autoTuneViewModel.customPinNode`,{node:t(e.nodeId),modelId:e.modelId,deviceKey:e.deviceKey});case`custom-registry-unreadable`:return Y.t(`helpers.autoTuneViewModel.customRegistryUnreadable`,{error:e.error})}}function Zi(e){return{modelChanges:e.nodeChanges.reduce((e,t)=>e+t.modelPins.length,0),thresholdClears:e.nodeChanges.reduce((e,t)=>e+t.thresholds.length,0)}}function Qi(e){let t=Zi(e);return t.modelChanges+t.thresholdClears===0}function $i(e,t,n){let r=e.nodeChanges.find(e=>e.nodeId===t&&e.deviceKey===n)?.modelPins.find(e=>e.stepId===`object-detection`);return r===void 0?null:{before:r.before,after:r.after}}function ea(e,t){return e?.kind===`node-benchmark`?Y.t(`helpers.autoTuneViewModel.latencyMeasured`,{date:new Date(e.measuredAtMs).toLocaleDateString(t,{day:`numeric`,month:`short`})}):e?.kind===`estimated`?Y.t(`helpers.autoTuneViewModel.latencyEstimated`,{hardware:Ji(e.estimatedFrom)}):Y.t(`helpers.autoTuneViewModel.latencyTable`)}s();var ta=[.3,.4,.5];function na(e){return ta.some(t=>t===e)}var ra=[1,2,3,4,6,8];function ia({plan:t,node:n,nodeName:r}){let{t:a}=X();return e(`section`,{className:x,"data-testid":`auto-tune-node-${n.nodeId}`,children:[e(`header`,{className:`${B} flex flex-wrap items-center gap-2`,children:[i(S,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),i(`h3`,{className:`${A} min-w-0 flex-1`,children:r(n.nodeId)}),e(`span`,{className:`text-[11px] text-foreground-subtle`,children:[Ji(n.hardwareClass),n.cpuModel===null?``:` · ${n.cpuModel}`]}),n.skipped?i(J,{variant:`warning`,children:a(`pipeline.clusterAutoTuneTab.notChanged`,`Not changed`)}):n.acceleratorModelId!==null&&i(J,{variant:`info`,children:n.acceleratorModelId})]}),n.reasons.length>0&&i(`ul`,{className:`px-3 pt-2 text-[11px] text-foreground-muted`,children:n.reasons.map((e,t)=>i(`li`,{children:Yi(e)},t))}),i(`div`,{className:`overflow-x-auto`,children:e(`table`,{className:`w-full text-xs`,children:[i(`thead`,{children:e(`tr`,{className:`text-left text-[11px] text-foreground-subtle`,children:[i(`th`,{className:`px-3 py-1.5 font-medium`,children:a(`pipeline.clusterAutoTuneTab.device`,`Device`)}),i(`th`,{className:`px-3 py-1.5 font-medium`,children:a(`pipeline.clusterAutoTuneTab.capacity`,`Capacity`)}),i(`th`,{className:`px-3 py-1.5 font-medium`,children:a(`pipeline.clusterAutoTuneTab.detector`,`Detector`)}),i(`th`,{className:`px-3 py-1.5 font-medium`,children:a(`pipeline.clusterAutoTuneTab.why`,`Why`)})]})}),i(`tbody`,{children:n.devices.map(r=>{let o=$i(t,n.nodeId,r.deviceKey);return e(`tr`,{className:`border-t border-border align-top`,children:[e(`td`,{className:`px-3 py-1.5`,children:[i(`div`,{className:`font-mono text-foreground`,children:r.deviceKey}),i(`div`,{className:`text-[11px] text-foreground-subtle`,children:qi(r.accelerator)})]}),e(`td`,{className:`px-3 py-1.5 text-foreground-muted`,children:[r.chosen===null?`—`:a(`pipeline.clusterAutoTuneTab.sessionsAtFps`,{count:r.chosen.capacitySessions,fps:t.cameraFps}),r.chosen!==null&&e(`div`,{className:`text-[11px] text-foreground-subtle`,children:[a(`pipeline.clusterAutoTuneTab.fpsKeptFree`,{fps:r.chosen.fps,percent:Math.round(t.headroom*100)}),i(`div`,{children:ea(r.chosen.source)})]})]}),i(`td`,{className:`px-3 py-1.5`,children:r.chosen===null?i(`span`,{className:`text-foreground-subtle`,children:a(`common.unchanged`)}):o!==null&&o.before!==o.after?e(`span`,{children:[i(`span`,{className:`text-foreground-subtle`,children:o.before??a(`common.defaultWord`)}),` → `,i(`span`,{className:`font-medium text-foreground`,children:o.after})]}):i(`span`,{className:`text-foreground`,children:r.chosen.modelId})}),i(`td`,{className:`px-3 py-1.5 text-[11px] text-foreground-muted`,children:r.reasons.map((e,t)=>i(`div`,{children:Yi(e)},t))})]},r.deviceKey)})})]})})]})}function aa({plan:t,nodeName:n}){let{t:r}=X();return i(`div`,{className:`flex flex-col gap-3 text-xs`,"data-testid":`auto-tune-change-list`,children:e(`div`,{children:[i(`div`,{className:A,children:r(`pipeline.clusterAutoTuneTab.nodeSettings`,`Node settings`)}),t.nodeChanges.length===0?i(`div`,{className:`text-foreground-subtle`,children:r(`pipeline.clusterAutoTuneTab.noChange`,`No change.`)}):i(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:t.nodeChanges.flatMap(t=>[...t.modelPins.map(i=>e(`li`,{children:[e(`span`,{className:`font-mono`,children:[n(t.nodeId),` · `,t.deviceKey]}),` `,`— `,i.stepId,`: `,i.before??r(`pipeline.clusterAutoTuneTab.defaultModel`),` →`,` `,i.after??r(`pipeline.clusterAutoTuneTab.stepDefault`,`step default`)]},`${t.nodeId}/${t.deviceKey}/${i.stepId}/pin`)),...t.thresholds.map(i=>e(`li`,{children:[e(`span`,{className:`font-mono`,children:[n(t.nodeId),` · `,t.deviceKey]}),` `,`—`,` `,r(`pipeline.clusterAutoTuneTab.thresholdReset`,{step:i.stepId,keys:i.keys.join(`, `)})]},`${t.nodeId}/${t.deviceKey}/${i.stepId}/thr`))])})]})})}function oa({result:t}){let{t:n}=X();return t.kind===`refused`?i(`div`,{className:`text-xs text-warning`,children:n(`pipeline.clusterAutoTuneTab.anotherApplyIsAlreadyRunning`,`Another apply is already running.`)}):t.kind===`stale`?i(`div`,{className:`text-xs text-warning`,children:n(`pipeline.clusterAutoTuneTab.theConfigurationChangedSinceThe`,`The configuration changed since the plan was shown. Review the updated plan below and apply again.`)}):e(`ul`,{className:`text-xs`,"data-testid":`auto-tune-result`,children:[t.kind===`aborted`&&i(`li`,{className:`text-danger`,children:n(`pipeline.clusterAutoTuneTab.aModelCouldNotBe`,`A model could not be downloaded: nothing was changed.`)}),t.phases.map(t=>e(`li`,{className:t.ok?`text-foreground-muted`:`text-danger`,children:[t.ok?`✓`:`✗`,` `,t.phase,`: `,t.detail]},t.phase))]})}function sa(){let{t}=X(),r=l(),[a,s]=o(.4),[c,u]=o(2),[d,f]=o(!1),[p,m]=o(!1),[h,g]=o(null),{nodes:_}=K(),v=n(()=>wr(_),[_]),y=at({headroom:a,minSessionsPerDevice:c},{enabled:d,refetchOnWindowFocus:!1}),b=Lt({onSuccess:e=>{g(e),m(!1),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]}),e.kind===`applied`&&y.refetch()}}),S=h?.kind===`stale`?h.plan:y.data,C=S===void 0?null:Zi(S);return e(`div`,{className:`flex flex-col gap-3`,"data-testid":`cluster-auto-tune`,children:[e(`section`,{className:x,children:[e(`header`,{className:`${B} flex flex-wrap items-center gap-2`,children:[i(se,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),i(`h3`,{className:`${A} min-w-0 flex-1`,children:t(`pipeline.clusterAutoTuneTab.autoTune`,`Auto tune`)})]}),e(`div`,{className:`flex flex-col gap-2 px-3 py-2 text-xs text-foreground-muted`,children:[i(`p`,{children:t(`pipeline.clusterAutoTuneTab.picksForEveryAcceleratorThe`,`Picks, for every accelerator, the most accurate YOLOv9 detector that still carries at least the chosen number of cameras at once, from the node's hardware and measured speeds. Nothing is measured or estimated about your cameras' activity. Applying it sets those models on the accelerators and clears their threshold overrides, so each model runs its own default thresholds. Cameras carry no model or threshold of their own. Enabled steps, devices, pins, recording, notifications, zones and rules are not touched. There is no undo.`)}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(`label`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`whitespace-nowrap`,children:t(`pipeline.clusterAutoTuneTab.keepFree`,`Keep free`)}),i(L,{"aria-label":t(`pipeline.clusterAutoTuneTab.shareOfEachAcceleratorKept`,`Share of each accelerator kept free`),value:String(a),options:ta.map(e=>({value:String(e),label:t(`pipeline.clusterAutoTuneTab.ofEachAccelerator`,`{{value1}}% of each accelerator`,{value1:Math.round(e*100)})})),onChange:e=>{let t=Number(e.target.value);na(t)&&s(t)}})]}),e(`label`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`whitespace-nowrap`,children:t(`pipeline.clusterAutoTuneTab.atLeast`,`At least`)}),i(L,{"aria-label":t(`pipeline.clusterAutoTuneTab.minimumParallelSessionsPerDevice`,`Minimum parallel sessions per device`),value:String(c),options:ra.map(e=>({value:String(e),label:t(`pipeline.clusterAutoTuneTab.camerasAtOnce`,{count:e})})),onChange:e=>{let t=Number(e.target.value);ra.some(e=>e===t)&&u(t)}})]}),i(G,{size:`sm`,variant:`secondary`,onClick:()=>{g(null),f(!0),d&&y.refetch()},children:y.isFetching?t(`pipeline.clusterAutoTuneTab.computing`,`Computing…`):S===void 0?t(`pipeline.clusterAutoTuneTab.computePlan`,`Compute plan`):t(`pipeline.clusterAutoTuneTab.recompute`,`Recompute`)}),S!==void 0&&i(G,{size:`sm`,disabled:Qi(S),onClick:()=>m(!0),children:t(`pipeline.clusterAutoTuneTab.apply`,`Apply…`)})]}),y.error!==null&&i(`div`,{className:`text-danger`,children:y.error.message}),h!==null&&i(oa,{result:h}),C!==null&&i(`div`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.clusterAutoTuneTab.planSummary`,{modelChanges:C.modelChanges,thresholdClears:C.thresholdClears})})]})]}),S?.warnings.map((e,t)=>i(`div`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:Xi(e,v)},t)),S?.nodes.map(e=>i(ia,{plan:S,node:e,nodeName:v},e.nodeId)),S!==void 0&&i(pt,{open:p,onOpenChange:m,children:e(Be,{width:`lg`,scroll:`body`,children:[e(xt,{children:[i(Tt,{children:t(`pipeline.clusterAutoTuneTab.applyAutoTune`,`Apply auto tune?`)}),i(Ct,{children:t(`pipeline.clusterAutoTuneTab.theseAreAllTheChanges`,`These are all the changes. Every override listed is removed and cannot be restored.`)})]}),i(bn,{children:i(aa,{plan:S,nodeName:v})}),e(Ze,{children:[i(G,{variant:`ghost`,onClick:()=>m(!1),children:t(`common.cancel`,`Cancel`)}),i(G,{variant:`danger`,disabled:b.isPending,onClick:()=>b.mutate({planHash:S.planHash,headroom:a,minSessionsPerDevice:c}),children:b.isPending?t(`pipeline.clusterAutoTuneTab.applying`,`Applying…`):t(`common.apply`,`Apply`)})]})]})})]})}var ca={disabled:`pipeline.nodeLoadOverview.exclusion.disabled`,unavailable:`pipeline.nodeLoadOverview.exclusion.unavailable`,"cannot-host-camera-root":`pipeline.nodeLoadOverview.exclusion.cannotHostCameraRoot`,"accelerator-preferred":`pipeline.nodeLoadOverview.exclusion.acceleratorPreferred`};function la(e,t){return t<=0?0:Math.round(e/t*1e3)/10}function ua(e){return e===void 0?!1:e.load.devices.reduce((e,t)=>e+t.attachedCameras,0)>=e.load.attachedCameras}function da(e,t,n){let r=e.filter(e=>e.exclusion===null).reduce((e,t)=>e+(t.weight>0?t.weight:1),0);return e.map(e=>{let i=t.get(e.key)??(n?0:null),a=e.weight>0?e.weight:1;return{key:e.key,label:_n(e),format:e.format,sessions:i,weight:a,weightSharePct:e.exclusion===null?la(a,r):null,maxSessions:e.maxSessions,atCap:e.maxSessions!==null&&i!==null&&i>=e.maxSessions,available:e.available,enabled:e.enabled,exclusion:e.exclusion}}).toSorted((e,t)=>e.exclusion===null==(t.exclusion===null)?e.key.localeCompare(t.key):e.exclusion===null?-1:1)}function fa(e){let t=new Map(e.loads.map(e=>[e.nodeId,e])),n=e.nodes.filter(e=>e.isOnline&&e.detectEnabled).reduce((e,t)=>e+(t.weight>0?t.weight:1),0);return e.nodes.map(r=>{let i=t.get(r.id),a=da(e.devicesByNode[r.id]??[],new Map((i?.load.devices??[]).map(e=>[e.deviceKey,e.attachedCameras])),ua(i)),o=r.isOnline&&r.detectEnabled,s=r.weight>0?r.weight:1,c=i?.load.attachedCameras??null;return{nodeId:r.id,name:r.name,isOnline:r.isOnline,detectEnabled:r.detectEnabled,reported:i!==void 0,attachedCameras:c,activeCameras:i?.load.activeCameras??null,maxCameras:r.maxCameras,capacityPct:c!==null&&r.maxCameras!==null&&r.maxCameras>0?la(c,r.maxCameras):null,queueDepthTotal:i?.load.queueDepthTotal??null,avgInferenceTimeMs:i?.load.avgInferenceTimeMs??null,score:i?.score??null,weight:s,weightSharePct:o?la(s,n):null,decodeHwaccel:i?.decodeHwaccel??null,devices:a,eligibleDeviceCount:a.filter(e=>e.exclusion===null).length}})}s();var pa=2e4,ma=3e5;function ha({stats:e,targetWeights:t,showAccelerators:r=!0}){let{t:a}=X(),{nodes:o}=K(),s=ce().trpcClient,l=ln(void 0,{placeholderData:u,staleTime:pa,refetchInterval:pa,refetchOnWindowFocus:!0}),d=Zt(void 0,{staleTime:ma}),f=n(()=>o.map(e=>e.id),[o]),m=c({queries:f.map(e=>({queryKey:Le(rt.pipelineOrchestrator.getNodeInferenceDevices,{nodeId:e},`query`),queryFn:()=>s.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:e}),staleTime:ma,refetchOnWindowFocus:!1,placeholderData:u}))}),g=n(()=>{let e={};return f.forEach((t,n)=>{let r=m[n]?.data;r&&(e[t]=r.devices)}),e},[f,m.map(e=>e.dataUpdatedAt).join(`|`)]),_=n(()=>{let e=new Map;for(let t of d.data??[])e.set(t.nodeId,t.settings);return e},[d.data]),v=n(()=>o.map(e=>{let n=_.get(e.id);return{id:e.id,name:e.name,isOnline:e.isOnline,detectEnabled:fr(n).pipeline,weight:t?.[e.id]??er(n,`detectWeight`)??1,maxCameras:er(n,`maxCameras`)}}),[o,_,t]),y=l.data??[],b=n(()=>fa({nodes:v,loads:y,devicesByNode:g}),[v,y,g]),x=b.reduce((e,t)=>e+(t.attachedCameras??0),0),S=b.reduce((e,t)=>e+(t.activeCameras??0),0),C=l.dataUpdatedAt>0?Date.now()-l.dataUpdatedAt:null,w=new Map((e?.nodes??[]).map(e=>[e.nodeId,e]));return i(q,{headingId:`load-balancing-node-load`,title:a(`pipeline.nodeLoadOverview.nodeLoad`,`Node load`),icon:h,actions:i(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:a(`pipeline.nodeLoadOverview.summaryLine`,{active:S,attached:x,reading:l.data===void 0?a(`pipeline.nodeLoadOverview.reading`,`reading…`):a(`pipeline.nodeLoadOverview.readingAge`,{age:C===null?`—`:`${Math.round(C/1e3)}s`})})}),children:i(`div`,{className:p,children:b.length===0?i(`p`,{className:`text-[11px] italic text-foreground-subtle`,children:a(`pipeline.nodeLoadOverview.noClusterNodesReportedYet`,`No cluster nodes reported yet.`)}):i(`div`,{className:`grid gap-2 @2xl/clustertab:grid-cols-2 @5xl/clustertab:grid-cols-3`,children:b.map(e=>i(ga,{row:e,placed:w.get(e.nodeId),showAccelerators:r},e.nodeId))})})})}function ga({row:t,placed:n,showAccelerators:r}){let{t:a}=X(),o=t.attachedCameras===null?`—`:`${t.activeCameras??0} / ${t.attachedCameras}${t.maxCameras===null?``:` of ${t.maxCameras}`}`;return e(`div`,{className:`rounded-lg border border-border bg-surface/60 p-2.5 min-w-0`,children:[e(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[i(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${t.isOnline?`bg-emerald-400`:`bg-foreground-subtle/40`}`}),i(`span`,{className:`truncate text-xs font-medium text-foreground`,title:t.nodeId,children:t.name}),!t.detectEnabled&&i(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 text-[9px] uppercase tracking-wide text-foreground-subtle`,children:a(`pipeline.nodeLoadOverview.noDetect`,`no detect`)}),!t.reported&&t.isOnline&&e(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-amber-400`,title:a(`pipeline.nodeLoadOverview.onlineButItDidNot`,`Online, but it did not answer the last load read — its numbers below are unknown, not zero.`),children:[i(N,{className:`h-2.5 w-2.5`}),` `,a(`pipeline.nodeLoadOverview.noReading`)]}),!t.isOnline&&e(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-foreground-subtle`,children:[i(z,{className:`h-2.5 w-2.5`}),` `,a(`common.offline`)]})]}),e(`dl`,{className:`mt-1.5 grid grid-cols-2 gap-x-2 gap-y-0.5 text-[10px]`,children:[i(ya,{label:a(`pipeline.nodeLoadOverview.runningAttached`,`Running / attached`),value:o,title:a(`pipeline.nodeLoadOverview.sessionsInInferenceNowCameras`,`Sessions in inference now / cameras attached to this runner (the balancer's committed load) / operator cap.`)}),i(ya,{label:a(`pipeline.nodeLoadOverview.targetShare`,`Target share`),value:t.weightSharePct===null?`out of play`:`${t.weightSharePct}%`,title:a(`pipeline.nodeLoadOverview.theNodeShareAutomaticOr`,`The node share (automatic or manual) normalised over the nodes the balancer actually ranks (online AND detect-enabled).`)}),i(ya,{label:a(`pipeline.nodeLoadOverview.actualShare1H`,`Actual share (1 h)`),value:n?.observedShare===null||n===void 0?`—`:`${Math.round(n.observedShare*100)}%`,title:a(`pipeline.nodeLoadOverview.timeWeightedShareOfThe`,`Time-weighted share of the cluster's PARALLEL detection sessions this node carried over the last hour — the quantity a share holds. '—' = no session ran here in the window.`)}),i(ya,{label:a(`pipeline.nodeLoadOverview.peakYields`,`Peak · yields`),value:n===void 0?`—`:`${n.peakSessions} · ${n.yieldsAway}`,title:a(`pipeline.nodeLoadOverview.mostSessionsThisNodeRan`,`Most sessions this node ran at once in the last hour, and how many share turns it handed to another node because it was full or drowning.`)}),i(ya,{label:a(`pipeline.nodeLoadOverview.scoreQueue`,`Score · queue`),value:t.score===null?`—`:`${t.score} · ${t.queueDepthTotal??0}`,title:a(`pipeline.nodeLoadOverview.theCapacityScoreBalanceMinimises`,`The capacity score balance() minimises (attached + queue depth), and the raw queue depth.`)}),t.capacityPct!==null&&i(ya,{label:a(`pipeline.nodeLoadOverview.capFill`,`Cap fill`),value:`${t.capacityPct}%`,title:a(`pipeline.nodeLoadOverview.attachedMaxcameras`,`attached / maxCameras.`)}),t.avgInferenceTimeMs!==null&&i(ya,{label:a(`pipeline.nodeLoadOverview.avgInfer`,`Avg infer`),value:`${Math.round(t.avgInferenceTimeMs)} ms`,title:a(`pipeline.nodeLoadOverview.meanInferenceTimeAcrossThis`,`Mean inference time across this node's attached cameras.`)}),t.decodeHwaccel!==null&&i(ya,{label:a(`pipeline.nodeLoadOverview.decode`,`Decode`),value:t.decodeHwaccel,title:a(`pipeline.nodeLoadOverview.thisNodeSProbedDecode`,`This node's probed decode hwaccel.`)})]}),r&&i(_a,{row:t})]})}function _a({row:t}){let{t:n}=X();return t.devices.length===0?i(`p`,{className:`mt-2 text-[10px] italic text-foreground-subtle`,children:n(`pipeline.nodeLoadOverview.acceleratorsNotReadYet`,`Accelerators not read yet.`)}):e(`div`,{className:`mt-2 border-t border-border pt-1.5`,children:[e(`div`,{className:`flex items-center gap-1 text-[9px] uppercase tracking-wider text-foreground-subtle`,children:[i(ne,{className:`h-2.5 w-2.5`}),n(`pipeline.nodeLoadOverview.accelerators`,`Accelerators`),t.eligibleDeviceCount===0&&i(`span`,{className:`ml-1 normal-case tracking-normal text-amber-400`,title:n(`pipeline.nodeLoadOverview.noDeviceIsACamera`,`No device is a camera-root candidate on this node — sessions run on the runner's default (CPU) pool.`),children:n(`pipeline.nodeLoadOverview.noneInPlayRunnerDefault`,`none in play · runner default pool`)})]}),i(`ul`,{className:`mt-1 space-y-0.5`,children:t.devices.map(e=>i(va,{device:e},e.key))})]})}function va({device:t}){let{t:n}=X(),r=t.exclusion;return e(`li`,{className:`flex items-baseline gap-1.5 text-[10px] min-w-0`,children:[i(S,{className:`h-2.5 w-2.5 shrink-0 ${r===null?`text-foreground-subtle`:`text-foreground-subtle/50`}`}),i(`span`,{className:`shrink-0 font-medium ${r===null?`text-foreground`:`text-foreground-subtle`}`,title:`${t.key} · ${t.format}`,children:t.label}),r===null?e(d,{children:[i(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,children:n(`pipeline.nodeLoadOverview.sharePct`,{pct:t.weightSharePct})}),e(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,title:t.sessions===null?n(`pipeline.nodeLoadOverview.notKnownTheNodeDid`,`Not known: the node did not report, or runs a session no device accounts for.`):void 0,children:[`· `,n(`common.sessionsCount`,{count:t.sessions??0}),t.maxSessions===null?``:`/${t.maxSessions}`]}),t.atCap&&i(`span`,{className:`shrink-0 text-amber-400`,title:n(`pipeline.nodeLoadOverview.atItsMaxsessionsCapThe`,`At its maxSessions cap — the balancer skips it until a session ends.`),children:n(`pipeline.nodeLoadOverview.atCap`,`· at cap`)})]}):i(`span`,{className:`truncate text-foreground-subtle/80`,title:n(ca[r]),children:n(`pipeline.nodeLoadOverview.excludedWith`,{reason:n(ca[r])})})]})}function ya({label:t,value:n,title:r}){return e(`div`,{className:`min-w-0`,title:r,children:[i(`dt`,{className:`text-[9px] uppercase tracking-wide text-foreground-subtle`,children:t}),i(`dd`,{className:`truncate font-medium tabular-nums text-foreground`,children:n})]})}function ba(e){return{nodes:Object.fromEntries(e.map(e=>[e.nodeId,Math.max(1,e.weight)])),devices:{}}}function xa(e){let t={},n={};for(let r of e.nodes){if(r.share===null||r.share<=0)continue;t[r.nodeId]=r.share;let e=Object.fromEntries(r.devices.filter(e=>e.share>0).map(e=>[e.deviceKey,e.share]));Object.keys(e).length>0&&(n[r.nodeId]=e)}return{nodes:t,devices:n}}function Sa(e){return Object.fromEntries(e.nodes.map(e=>[e.nodeId,Object.fromEntries(e.devices.map(e=>[e.deviceKey,e.suggestedMaxSessions]))]))}function Ca(e){return e.reason===`disabled`?Y.t(`helpers.loadBalancingViewModel.stalePinDisabled`,{deviceKey:e.deviceKey}):Y.t(`helpers.loadBalancingViewModel.stalePinMissing`,{deviceKey:e.deviceKey})}function wa(e,t){if(t===void 0||t.source===`manual`||t.autoPending)return{nodes:e,readOnly:t!==void 0&&t.source!==`manual`};let n=new Map(t.nodes.map(e=>[e.nodeId,e.configuredPct]));return{nodes:e.map(e=>({...e,weight:Math.round(n.get(e.id)??e.weight)})),readOnly:!0}}function Ta(e,t){let n=e.nodes.filter(e=>!e.eligible);if(n.length===0)return null;let r=e.nodes.filter(e=>e.eligible).map(e=>`${t(e.nodeId)} ${Math.round(e.effectivePct)}%`).join(`, `),i=n.map(e=>t(e.nodeId)).join(`, `);return Y.t(`helpers.loadBalancingViewModel.shareNote`,{count:n.length,names:i,into:r})}var Ea=[{value:`hardware`,get label(){return Y.t(`helpers.loadBalancingViewModel.hardwareLabel`)},get hint(){return Y.t(`helpers.loadBalancingViewModel.hardwareHint`)}},{value:`benchmark`,get label(){return Y.t(`helpers.loadBalancingViewModel.benchmarkLabel`)},get hint(){return Y.t(`helpers.loadBalancingViewModel.benchmarkHint`)}},{value:`manual`,get label(){return Y.t(`helpers.loadBalancingViewModel.manualLabel`)},get hint(){return Y.t(`helpers.loadBalancingViewModel.manualHint`)}}];function Da(e){return e===`no-benchmark-results`?Y.t(`helpers.loadBalancingViewModel.fallbackNone`):e===`partial-benchmark-results`?Y.t(`helpers.loadBalancingViewModel.fallbackPartial`):null}function Oa(e,t){if(e.source!==`benchmark`)return null;let n=e.nodes.filter(e=>e.capacityFallback!==null);return n.length===0?null:n.map(e=>`${t(e.nodeId)}: ${Da(e.capacityFallback)??``}`).join(` · `)}s();function ka(e,t,n){return Math.min(Math.max(e,t),n)}function Aa(e){let t=e.reduce((e,t)=>e+Math.max(t.weight,0),0);if(t<=0){let t=e.length>0?100/e.length:0;return Object.fromEntries(e.map(e=>[e.id,t]))}return Object.fromEntries(e.map(e=>[e.id,Math.max(e.weight,0)/t*100]))}function ja(e,t,n,r,i){let a=i.filter(e=>e!==t&&r.has(e)).reduce((t,n)=>t+Math.max(e[n]??0,0),0),o=Math.max(0,100-a),s=i.filter(e=>e!==t&&!r.has(e)),c=s.length===0?o:ka(n,0,o),l={...e,[t]:c};if(s.length>0){let e=Math.max(0,o-c)/s.length;for(let t of s)l[t]=e}return l}function Ma(e,t,n){let r={},i=0,a=[];for(let o of t){let t=Math.max(e[o]??0,0);if(n.has(o)){let e=Math.round(t);r[o]=e,i+=e}else{let e=Math.floor(t);r[o]=e,a.push({id:o,floor:e,frac:t-e})}}let o=Math.max(0,100-i)-a.reduce((e,t)=>e+t.floor,0),s=[...a].sort((e,t)=>t.frac-e.frac);for(let e=0;o>0&&s.length>0;e+=1)r[s[e%s.length].id]+=1,--o;let c=[...a].sort((e,t)=>e.frac-t.frac);for(let e=0;o<0&&c.length>0;e+=1){let t=c[e%c.length].id;r[t]>0&&(--r[t],o+=1)}return r}function Na({nodes:t,pending:n,onCommitWeights:r,weightLabel:s=`Detection weight`,emptyHint:c,footnote:l,readOnly:u=!1}){let{t:f}=X(),[p,h]=o(()=>Aa(t)),[g,_]=o(new Set);a(()=>{h(Aa(t)),_(e=>new Set([...e].filter(e=>t.some(t=>t.id===e))))},[t.map(e=>`${e.id}:${e.weight}`).join(`|`)]);let v=t.map(e=>e.id),y=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},b=(e,t)=>{h(n=>ja(n,e,t,g,v))},x=()=>{let e=Ma(p,v,g),n=t.filter(t=>(e[t.id]??0)!==t.weight).map(e=>e.id);if(n.length===0)return;let i=new Set([...n,...g]);r(t.filter(e=>i.has(e.id)).map(t=>({nodeId:t.id,weight:e[t.id]??0})))};if(t.length===0)return i(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:c??f(`placementBoard.weightSliderStack.noDetectEnabledNodesEnable`,`No detect-enabled nodes. Enable “Detect” on a node above to distribute detection weight.`)});let S=t.length===1;return e(`div`,{className:`space-y-3`,children:[t.map(t=>{let r=p[t.id]??0,a=g.has(t.id);return e(`div`,{className:`flex items-center gap-3`,children:[i(`span`,{className:`w-28 shrink-0 truncate text-xs font-medium text-foreground`,title:t.name,children:t.name}),i(re,{"aria-label":f(`placementBoard.weightSliderStack.for`,`{{weightLabel}} for {{name}}`,{weightLabel:s,name:t.name}),min:0,max:100,step:1,value:Math.round(r),disabled:u||n||a||S,onChange:e=>b(t.id,Number(e.target.value)),onPointerUp:()=>x(),onKeyUp:()=>x(),className:`h-1.5 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50`}),e(`span`,{className:`w-10 shrink-0 text-right font-mono text-xs tabular-nums text-foreground`,children:[Math.round(r),`%`]}),!u&&i(G,{variant:`unstyled`,type:`button`,onClick:()=>y(t.id),disabled:n||S,"aria-pressed":a,title:a?f(`placementBoard.weightSliderStack.unlockAllowRebalancing`,`Unlock — allow rebalancing`):f(`placementBoard.weightSliderStack.lockThisShareWhenOthers`,`Lock this share when others change`),className:`shrink-0 rounded p-1 hover:bg-surface-hover disabled:opacity-40 ${a?`text-amber-400`:`text-foreground-subtle`}`,children:i(a?w:m,{className:`h-3.5 w-3.5`})})]},t.id)}),i(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:l??i(d,{children:f(`placementBoard.weightSliderStack.draggingOneSliderSplitsThe`,`Dragging one slider splits the rest equally across the unlocked nodes; lock a node to pin its share — locked nodes never move and the total always stays at 100%, so a drag is bounded by the room the unlocked nodes leave. Detection only distributes across nodes that can source a camera’s frames.`)})})]})}function Pa(e){let t=e.steps?.[`object-detection`]?.modelId;return typeof t==`string`&&t.length>0?t:typeof e.defaultModelId==`string`&&e.defaultModelId.length>0?e.defaultModelId:null}function Fa(e){if(e.presence===`absent`)return`absent`;if(e.presence===`unknown`)return`unknown`;switch(e.exclusion){case null:return`active`;case`disabled`:return`disabled`;case`unavailable`:return e.available?`backoff`:`unavailable`;case`cannot-host-camera-root`:return`root-incapable`;case`accelerator-preferred`:return`standby`}}function Ia(e,t,n){let r=new Map((t?.devices??[]).map(e=>[e.deviceKey,e])),i=new Map((n?.devices??[]).map(e=>[e.deviceKey,e.sessionsNow]));return e.map(e=>{let t=r.get(e.key),a=n===void 0?null:i.get(e.key)??0;return{device:e,state:Fa(e),share:t===void 0?null:{configuredPct:t.configuredPct,effectivePct:t.effectivePct},sessionsNow:a,atCap:a!==null&&e.maxSessions!==null&&a>=e.maxSessions}})}var La={active:`success`,disabled:`neutral`,absent:`danger`,unknown:`neutral`,unavailable:`warning`,backoff:`warning`,"root-incapable":`info`,standby:`neutral`};s();function Ra(e){let t=_n(e),n=e.backend.toLowerCase(),r=e.device.toLowerCase();return e.key===`cpu`||r===`cpu`?{label:t,Icon:S,hue:`slate`}:r===`npu`?{label:t,Icon:U,hue:`sky`}:r===`gpu`||r===`igpu`?{label:t,Icon:Ae,hue:`violet`}:n===`edgetpu`?{label:t,Icon:Pe,hue:`emerald`}:{label:t,Icon:S,hue:`slate`}}var za={active:[`placementBoard.nodeInferenceDevices.state.active`,`in use`],disabled:[`placementBoard.nodeInferenceDevices.state.disabled`,`switched off`],absent:[`placementBoard.nodeInferenceDevices.state.absent`,`absent`],unknown:[`placementBoard.nodeInferenceDevices.state.unknown`,`unknown`],unavailable:[`placementBoard.nodeInferenceDevices.state.unavailable`,`unavailable`],backoff:[`placementBoard.nodeInferenceDevices.state.backoff`,`pool down`],"root-incapable":[`placementBoard.nodeInferenceDevices.state.rootIncapable`,`no root model`],standby:[`placementBoard.nodeInferenceDevices.state.standby`,`fallback`]},Ba={active:[`placementBoard.nodeInferenceDevices.stateHint.active`,`A camera-root candidate: placement may start sessions on it.`],disabled:[`placementBoard.nodeInferenceDevices.stateHint.disabled`,`Switched off: it takes no sessions.`],absent:[`placementBoard.nodeInferenceDevices.stateHint.absent`,`The node no longer reports this device (unplugged, or moved to another node). Its settings are kept; it is never used. Forget it to delete them.`],unknown:[`placementBoard.nodeInferenceDevices.stateHint.unknown`,`The node's probe did not answer, so whether the device is there is not known.`],unavailable:[`placementBoard.nodeInferenceDevices.stateHint.unavailable`,`On the node, but the probe reports it unusable.`],backoff:[`placementBoard.nodeInferenceDevices.stateHint.backoff`,`Reported by the node, but its inference pool is down or backing off.`],"root-incapable":[`placementBoard.nodeInferenceDevices.stateHint.rootIncapable`,`Its format cannot run the camera root detector; it serves enrichment steps only.`],standby:[`placementBoard.nodeInferenceDevices.stateHint.standby`,`The CPU fallback: it takes no sessions while an accelerator is serving this node.`]};function Va({nodeId:t,nodeName:r,isOnline:s,suggestedMaxSessions:c,shareSource:u,sharesAutomatic:f,share:p,placed:m}){let{t:h}=X(),g=l(),{data:_,isLoading:v}=vt({nodeId:t},{refetchInterval:15e3}),y=()=>{g.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},b=ht({onSettled:y}),x=Wt({onSettled:y}),S=rt.platformProbe.rescanAccelerators.useMutation({onSettled:y}),C=_?.devices??[],w=_?.reachable??s,[T,E]=o({});a(()=>{E(Object.fromEntries(C.map(e=>[e.key,Ha(e)])))},[C.map(e=>`${e.key}:${e.enabled}:${e.weight}:${e.maxSessions}:${JSON.stringify(e.steps??{})}`).join(`|`)]);let D=n(()=>C.filter(e=>(T[e.key]?.enabled??e.enabled)&&e.available).length,[C,T]),[O,k]=o(null),A=O??!0,j=e=>{let n=C.map(t=>{let n=e[t.key]??Ha(t);return{key:t.key,enabled:n.enabled,weight:n.weight,maxSessions:n.maxSessions,steps:n.steps}});b.mutate({agentNodeId:t,inferenceDevices:ti(n)})},M=(e,t)=>{let n=T[e.key]??Ha(e),r={...T,[e.key]:{...n,...t}};E(r),j(r)},N=n(()=>Ia(C,p,m),[C,p,m]),P=n(()=>C.filter(e=>(T[e.key]?.enabled??e.enabled)&&e.available),[C,T]),te=n(()=>P.map(e=>({id:e.key,name:Ra(e).label,weight:T[e.key]?.weight??e.weight})),[P,T]),F=e=>{let t={...T};for(let n of e){let e=t[n.nodeId];e&&(t[n.nodeId]={...e,weight:n.weight})}E(t),j(t)},I=b.isPending||x.isPending,L=Ua(h,f?u:`manual`),R=[{key:`device`,header:h(`placementBoard.nodeInferenceDevices.colDevice`,`Device`),nowrap:!1,sortValue:e=>Ra(e.device).label,render:e=>i(Ga,{row:e,steps:T[e.device.key]?.steps})},{key:`state`,header:h(`placementBoard.nodeInferenceDevices.colState`,`State`),sortValue:e=>e.state,render:e=>i(`span`,{title:h(Ba[e.state][0],Ba[e.state][1]),children:i(J,{variant:La[e.state],size:`sm`,children:h(za[e.state][0],za[e.state][1])})})},{key:`share`,header:h(`placementBoard.nodeInferenceDevices.colShare`,`Share`),align:`right`,sortValue:e=>e.share?.effectivePct??null,render:e=>i(Ka,{row:e,sourceLabel:L})},{key:`sessions`,header:h(`placementBoard.nodeInferenceDevices.colSessions`,`Sessions`),align:`right`,sortValue:e=>e.sessionsNow,render:t=>e(`span`,{className:`tabular-nums text-xs text-foreground`,children:[t.sessionsNow??`—`,t.atCap&&i(J,{variant:`warning`,size:`sm`,className:`ml-1`,children:h(`placementBoard.nodeInferenceDevices.atCap`,`at cap`)})]})},{key:`cap`,header:h(`placementBoard.nodeInferenceDevices.colCap`,`Max sessions`),notSortableReason:h(`placementBoard.nodeInferenceDevices.capNotSortable`,`An editable field: sort by Sessions instead.`),render:t=>{let n=T[t.device.key]??Ha(t.device);if(!(n.enabled&&t.device.available))return i(`span`,{className:`text-xs text-foreground-subtle`,children:`—`});let r=Ra(t.device).label;return e(`div`,{className:`flex items-center justify-end gap-1`,children:[i(fn,{type:`number`,min:1,placeholder:`∞`,value:n.maxSessions??``,onChange:e=>{let n=e.target.value.trim(),r=n===``?null:Number.parseInt(n,10);M(t.device,{maxSessions:r!==null&&r>0?r:null})},disabled:I,"aria-label":h(`placementBoard.nodeInferenceDevices.maxConcurrentSessionsFor`,`Max concurrent sessions for {{label}}`,{label:r}),className:`w-16 text-right`}),i(qa,{suggested:c?.[t.device.key]??null,current:n.maxSessions,pending:I,onApply:e=>M(t.device,{maxSessions:e})})]})}},{key:`enabled`,header:h(`placementBoard.nodeInferenceDevices.colEnabled`,`Enabled`),align:`right`,notSortableReason:h(`placementBoard.nodeInferenceDevices.enabledNotSortable`,`A switch: sort by State instead.`),render:e=>{let n=Ra(e.device).label;if(e.state===`absent`)return i(Ue,{label:h(`placementBoard.nodeInferenceDevices.forget`,`Forget`),icon:ie,size:`sm`,triggerVariant:`ghost`,disabled:I,title:h(`placementBoard.nodeInferenceDevices.forgetTitle`,`Forget {{label}} on {{node}}?`,{label:n,node:r}),description:h(`placementBoard.nodeInferenceDevices.forgetDescription`,`Its stored settings (switch, weight, cap, step models) are deleted. If the device comes back it starts from the defaults.`),action:()=>x.mutateAsync({agentNodeId:t,deviceKey:e.device.key})});let a=T[e.device.key]??Ha(e.device);return i(Ft,{checked:a.enabled&&e.device.available,onCheckedChange:()=>M(e.device,{enabled:!a.enabled}),disabled:!e.device.available||I,"aria-label":h(`placementBoard.nodeInferenceDevices.enable`,`Enable {{label}}`,{label:n})})}}],B=b.error??x.error??S.error;return e(`div`,{className:`rounded-lg border border-border bg-surface`,children:[e(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[e(G,{variant:`ghost`,size:`sm`,onClick:()=>k(!A),className:`min-w-0 flex-1 justify-start`,"aria-expanded":A,children:[i(H,{className:`h-4 w-4 shrink-0 text-foreground-subtle transition-transform ${A?`rotate-90`:``}`}),i(`span`,{className:`truncate text-sm font-medium text-foreground`,children:r}),i(`span`,{className:`ml-auto flex items-center gap-1 text-xs text-foreground-subtle`,children:w?e(d,{children:[i(Ie,{className:`h-3.5 w-3.5`}),h(`pipeline.nodeInferenceDevices.accelerators`,{count:D})]}):e(d,{children:[i(z,{className:`h-3.5 w-3.5`}),` `,h(`common.unreachable`)]})})]}),e(G,{variant:`ghost`,size:`sm`,onClick:()=>S.mutate({nodeId:t}),disabled:S.isPending||!w,title:h(`placementBoard.nodeInferenceDevices.rescanTitle`,`Probe this node for accelerators now (a Coral plugged in or pulled out). The node also re-probes every minute.`),children:[i(ee,{className:`h-3.5 w-3.5 ${S.isPending?`animate-spin`:``}`}),h(`placementBoard.nodeInferenceDevices.rescan`,`Rescan`)]})]}),A&&e(`div`,{className:`space-y-3 border-t border-border p-3`,children:[w?v&&C.length===0?i(`p`,{className:`text-center text-xs text-foreground-subtle`,children:h(`placementBoard.nodeInferenceDevices.probingAccelerators`,`Probing accelerators…`)}):i(dt,{columns:R,rows:N,rowKey:e=>e.device.key,minWidthPx:640,bordered:!1,emptyMessage:h(`placementBoard.nodeInferenceDevices.noInferenceDevicesReportedBy`,`No inference devices reported by this node's platform probe.`)}):i(Ja,{}),S.data!==void 0&&i(`p`,{className:`text-xs text-foreground-subtle`,children:Wa(h,S.data.appeared,S.data.disappeared)}),w&&!f&&P.length>=2&&e(`div`,{className:`space-y-3 rounded-lg border border-border p-3`,children:[e(`h4`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:[i(Me,{className:`h-3.5 w-3.5`}),h(`placementBoard.nodeInferenceDevices.acceleratorShare`,`Accelerator share`)]}),i(Na,{nodes:te,pending:I,onCommitWeights:F,weightLabel:`Accelerator share`,footnote:h(`placementBoard.nodeInferenceDevices.dragToShiftTheShare`,`Drag to shift the share of detection sessions each accelerator handles; lock one to pin its share while the others rebalance. Shares always sum to 100%.`)})]}),B!=null&&e(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-xs text-danger`,children:[h(`placementBoard.nodeInferenceDevices.failedToSaveInferenceDevices`,`Failed to save inference devices:`),` `,B.message]})]})]})}function Ha(e){return{enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}}function Ua(e,t){switch(t){case`benchmark`:return e(`placementBoard.nodeInferenceDevices.sourceBenchmark`,`benchmark`);case`hardware`:return e(`placementBoard.nodeInferenceDevices.sourceHardware`,`hardware`);case`manual`:return e(`placementBoard.nodeInferenceDevices.sourceManual`,`manual`);case void 0:return null}}function Wa(e,t,n){return t.length===0&&n.length===0?e(`placementBoard.nodeInferenceDevices.rescanNoChange`,`Rescanned: no change.`):e(`placementBoard.nodeInferenceDevices.rescanChanged`,`Rescanned: appeared {{appeared}} · disappeared {{disappeared}}`,{appeared:t.length>0?t.join(`, `):`—`,disappeared:n.length>0?n.join(`, `):`—`})}function Ga({row:t,steps:n}){let r=Ra(t.device),a=Pa({defaultModelId:t.device.defaultModelId,steps:n??t.device.steps??{}});return e(`div`,{className:`flex min-w-0 items-center gap-2`,children:[i(r.Icon,{className:`h-4 w-4 shrink-0 text-foreground-subtle`}),e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:r.label}),i(J,{variant:`neutral`,size:`sm`,className:`font-mono`,children:t.device.format})]}),e(`div`,{className:`flex flex-wrap items-center gap-x-1.5 text-xs text-foreground-subtle`,children:[i(`span`,{className:`font-mono`,children:t.device.key}),a!==null&&e(d,{children:[i(`span`,{"aria-hidden":!0,children:`·`}),i(`span`,{children:i(En,{i18nKey:`pipeline.nodeInferenceDevices.rootModel`,values:{model:a},components:{mono:i(`span`,{className:`font-mono text-foreground-muted`})}})})]})]})]})]})}function Ka({row:t,sourceLabel:n}){let{t:r}=X();if(t.share===null)return i(`span`,{className:`text-xs text-foreground-subtle`,children:`—`});let{configuredPct:a,effectivePct:o}=t.share,s=Math.round(a)!==Math.round(o);return e(`div`,{className:`text-right`,children:[e(`div`,{className:`tabular-nums text-sm text-foreground`,children:[Math.round(o),`%`]}),e(`div`,{className:`text-xs text-foreground-subtle`,children:[s?r(`placementBoard.nodeInferenceDevices.shareConfigured`,`set {{pct}}%`,{pct:Math.round(a)}):null,s&&n!==null?` · `:null,n]})]})}function qa({suggested:e,current:t,pending:n,onApply:r}){let{t:a}=X();return e===null||e<1||e===t?null:i(G,{variant:`ghost`,size:`sm`,onClick:()=>r(e),disabled:n,title:a(`placementBoard.nodeInferenceDevices.advisoryCapFromTheMeasured`,`Advisory cap from the measured throughput at the suggested model, with the headroom kept free. Applying it writes this device's cap.`),children:a(`pipeline.nodeInferenceDevices.use`,{value:e})})}function Ja(){let{t}=X();return e(`div`,{className:`flex flex-col items-center gap-2 px-4 py-6 text-center`,children:[i(z,{className:`h-6 w-6 text-foreground-subtle`}),i(`p`,{className:`text-xs font-medium text-foreground`,children:t(`placementBoard.nodeInferenceDevices.nodeUnreachable`,`Node unreachable`)}),i(`p`,{className:`max-w-sm text-xs text-foreground-subtle`,children:t(`placementBoard.nodeInferenceDevices.thePlatformProbeCouldnT`,`The platform probe couldn't be reached, so its live accelerator set is unavailable. Settings resume once the node reconnects.`)})]})}s();var Ya=3600*1e3,Xa=2e4,Za=.4;function Qa({refreshToken:t,onOpenAutoTune:r}){let{t:a}=X(),s=l(),{nodes:c}=K(),f=Zt(void 0),m=Sn({isCamera:!0,projection:`slim`}),h=$t({windowMs:Ya},{refetchInterval:Xa,placeholderData:u}).data,g=He(void 0,{refetchInterval:Xa,placeholderData:u}).data,_=()=>{Xn(s),s.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},v=un({onSuccess:_}),y=Et({onSuccess:()=>{_(),s.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getEffectiveShares`]]})}}),b=Cn({onSuccess:_}),x=st(),[C,w]=o(!1),T=g?.source,E=T===`benchmark`?`benchmark`:`hardware`,O=Ot({headroom:Za,source:E},{enabled:C,staleTime:1/0}),k=O.data,A=n(()=>{let e=new Map((f.data??[]).map(e=>[e.nodeId,e.settings]));return c.filter(t=>fr(e.get(t.id)).pipeline).map(t=>{let n=e.get(t.id);return{id:t.id,name:t.name,isOnline:t.isOnline,weight:er(n,`detectWeight`)??1,maxCameras:er(n,`maxCameras`)}})},[c,f.data]),M=e=>c.find(t=>t.id===e)?.name??e,ee=Tr((m.data??[]).map(e=>({id:e.id,name:e.name}))),N=k?Sa(k):void 0,P=wa(A,g),te=T!==`manual`,F=g!==void 0&&g.source!==`manual`&&!g.autoPending,I=e=>g?.nodes.find(t=>t.nodeId===e),L=e=>h?.nodes.find(t=>t.nodeId===e),R=g?Ta(g,M):null,z=g?Oa(g,M):null,B=Ea.find(e=>e.value===T)?.hint;return e(`div`,{className:`space-y-3 sm:space-y-4`,children:[i(_r,{refreshToken:t}),i(ha,{stats:h,showAccelerators:!1,...g!==void 0&&g.source!==`manual`&&!g.autoPending?{targetWeights:Object.fromEntries(g.nodes.map(e=>[e.nodeId,e.configuredPct]))}:{}}),i(q,{headingId:`load-balancing-node-shares`,title:a(`pipeline.clusterLoadBalancingTab.nodeShares`,`Node shares`),icon:Me,actions:e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(`div`,{role:`radiogroup`,"aria-label":a(`pipeline.clusterLoadBalancingTab.shareSource`,`Share source`),className:`flex items-center gap-1`,children:Ea.map(e=>i(G,{role:`radio`,"aria-checked":T===e.value,variant:T===e.value?`primary`:`outline`,size:`sm`,title:e.hint,disabled:y.isPending||g===void 0,onClick:()=>{T!==e.value&&y.mutate({source:e.value})},children:e.label},e.value))}),e(G,{variant:`outline`,size:`sm`,onClick:()=>{w(!0),C&&O.refetch()},disabled:O.isFetching,children:[i(j,{className:`h-3.5 w-3.5`}),O.isFetching?a(`pipeline.clusterLoadBalancingTab.suggesting`,`Suggesting…`):E===`benchmark`?a(`pipeline.clusterLoadBalancingTab.suggestFromBenchmark`,`Suggest from benchmark`):a(`pipeline.clusterLoadBalancingTab.suggestFromHardware`,`Suggest from hardware`)]}),e(G,{variant:`ghost`,size:`sm`,onClick:r,children:[i(se,{className:`h-3.5 w-3.5`}),a(`pipeline.clusterLoadBalancingTab.autoTune`,`Auto tune`)]}),e(G,{variant:`outline`,size:`sm`,onClick:()=>x.mutate(void 0),disabled:x.isPending,title:a(`pipeline.clusterLoadBalancingTab.moveStandingAlwaysOnCameras`,`Move standing (always-on) cameras that are no longer on their best node. Pinned cameras never move; on-motion sessions are placed per session anyway.`),children:[i(U,{className:`h-3.5 w-3.5`}),x.isPending?a(`pipeline.clusterLoadBalancingTab.rebalancing`,`Rebalancing…`):a(`pipeline.clusterLoadBalancingTab.rebalance`,`Rebalance`)]})]}),children:e(`div`,{className:`${p} space-y-3`,children:[B!==void 0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:B}),h&&e(`p`,{className:`text-[10px] text-foreground-subtle`,children:[a(`pipeline.clusterLoadBalancingTab.policy`,`Policy:`),` `,i(J,{variant:h.policy===`share`?`info`:`default`,children:h.policy===`share`?a(`pipeline.clusterLoadBalancingTab.honourShares`,`honour shares`):`least-loaded`}),` `,` · ${a(`pipeline.clusterLoadBalancingTab.clusterPeak`,{count:h.clusterPeakSessions})}`,h.policy===`least-loaded`&&` · ${a(`pipeline.clusterLoadBalancingTab.leastLoadedNote`)}`]}),i(Na,{nodes:P.nodes,pending:v.isPending,readOnly:P.readOnly,onCommitWeights:e=>v.mutate(ba(e)),weightLabel:`Node share`,...P.readOnly?{footnote:g?.autoPending?i(d,{children:a(`pipeline.clusterLoadBalancingTab.automaticSharesAreBeingComputed`,`Automatic shares are being computed from the cluster's measured capacity; the stored values are used meanwhile.`)}):e(d,{children:[T===`benchmark`?a(`pipeline.clusterLoadBalancingTab.benchmarkEachNodeSShare`,`Benchmark: each node's share follows its measured capacity from node benchmark results (hardware capacity where it has none)`):a(`pipeline.clusterLoadBalancingTab.hardwareEachNodeSShare`,`Hardware: each node's share follows its capacity at its Auto tune model, from the measured speed of its hardware`),a(`pipeline.clusterLoadBalancingTab.recomputedWheneverANodeOr`,`, recomputed whenever a node or accelerator is added, removed, switched on or off, or changes model`),g?.computedAt!=null&&i(`span`,{className:`ml-1`,children:a(g.trigger===null?`pipeline.clusterLoadBalancingTab.lastAt`:`pipeline.clusterLoadBalancingTab.lastAtTrigger`,{time:new Date(g.computedAt).toLocaleTimeString(),trigger:g.trigger??``})}),`.`]})}:{}}),R!==null&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:R}),z!==null&&i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`benchmark-fallback-note`,children:z}),y.isError&&i(kt,{message:a(`pipeline.clusterLoadBalancingTab.switchFailed`,{message:y.error instanceof Error?y.error.message:a(`common.unknownError`)})}),v.isError&&i(kt,{message:a(`pipeline.clusterLoadBalancingTab.saveFailed`,{message:v.error instanceof Error?v.error.message:a(`common.unknownError`)})}),e(`details`,{className:`rounded-md border border-border`,children:[i(`summary`,{className:`${D} cursor-pointer text-xs text-foreground`,children:a(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsAdvanced`,`Max concurrent sessions (advanced)`)}),i(`ul`,{className:`divide-y divide-border border-t border-border`,children:A.map(t=>e(`li`,{className:`${D} flex items-center gap-2`,children:[i(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:t.name}),i(fn,{type:`number`,min:1,placeholder:`∞`,defaultValue:t.maxCameras??``,"aria-label":a(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsFor`,`Max concurrent sessions for {{name}}`,{name:t.name}),className:`w-20 text-right`,disabled:b.isPending,onBlur:e=>{let n=e.target.value.trim(),r=n===``?null:Number.parseInt(n,10),i=r!==null&&r>0?r:null;i!==t.maxCameras&&b.mutate({agentNodeId:t.id,maxCameras:i})}})]},t.id))}),i(`p`,{className:`${D} ${W} border-t border-border`,children:a(`pipeline.clusterLoadBalancingTab.aHardCapOnThe`,`A hard cap on the sessions a node runs at once (always-on cameras count too). A node at its cap is never chosen; under shares its turn goes to a free node. Empty = unlimited.`)})]})]})}),O.isError&&i(kt,{message:a(`pipeline.clusterLoadBalancingTab.suggestionFailed`,{message:O.error instanceof Error?O.error.message:a(`common.unknownError`)})}),k&&i($a,{suggestion:k,nameOf:M,pending:v.isPending,...te?{}:{onApply:()=>v.mutate(xa(k))}}),i(q,{headingId:`load-balancing-accelerators`,title:a(`pipeline.clusterLoadBalancingTab.accelerators`,`Accelerators`),icon:S,children:i(`div`,{className:`${p} space-y-2`,children:A.length===0?i(zt,{title:a(`pipeline.clusterLoadBalancingTab.noDetectCapableNodes`,`No detect-capable nodes`),description:a(`pipeline.clusterLoadBalancingTab.enableDetectionOnANode`,`Enable detection on a node in Roles & nodes to configure its accelerators.`)}):A.map(e=>i(Va,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline,...N?.[e.id]===void 0?{}:{suggestedMaxSessions:N[e.id]},sharesAutomatic:F,...g===void 0?{}:{shareSource:g.source},...I(e.id)===void 0?{}:{share:I(e.id)},...L(e.id)===void 0?{}:{placed:L(e.id)}},e.id))})}),h!==void 0&&h.stalePins.length>0&&i(eo,{stats:h,cameraName:ee})]})}function $a({suggestion:t,nameOf:n,pending:r,onApply:a}){let{t:o}=X();return e(q,{headingId:`load-balancing-suggestion`,title:t.source===`benchmark`?o(`pipeline.clusterLoadBalancingTab.suggestedFromBenchmark`,`Suggested from benchmark`):o(`pipeline.clusterLoadBalancingTab.suggestedFromHardware`,`Suggested from hardware`),icon:j,...a===void 0?{}:{actions:i(G,{size:`sm`,onClick:a,disabled:r,children:o(`pipeline.clusterLoadBalancingTab.applySuggestedShares`,`Apply suggested shares`)})},children:[i(`ul`,{className:`divide-y divide-border`,children:t.nodes.map(t=>e(`li`,{className:`${D} space-y-0.5`,children:[e(`div`,{className:`flex items-baseline gap-2 text-xs`,children:[i(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:n(t.nodeId)}),i(`span`,{className:`tabular-nums text-foreground`,children:t.share===null?o(`common.skipped`):`${t.share}%`})]}),e(`p`,{className:W,children:[Da(t.capacityFallback)===null?``:`${Da(t.capacityFallback)} · `,t.skippedReason===null?o(`pipeline.clusterLoadBalancingTab.parallelSessions`,`≈ {{capacitySessions}} parallel sessions · {{value2}}`,{capacitySessions:t.capacitySessions,value2:t.devices.map(e=>`${e.deviceKey} ${e.share}% (${e.modelId??`—`}${e.measured?``:`, estimated`}, cap ${e.suggestedMaxSessions??`—`})`).join(` · `)}):o(`pipeline.clusterLoadBalancingTab.notPartOfTheSuggestion`,`not part of the suggestion — {{skippedReason}}`,{skippedReason:t.skippedReason})]})]},t.nodeId))}),e(`p`,{className:`${D} ${W} border-t border-border`,children:[o(`pipeline.clusterLoadBalancingTab.sharesIntro`,{fps:t.cameraFps,headroom:Math.round(t.headroom*100),basis:t.source===`benchmark`?o(`pipeline.clusterLoadBalancingTab.measuredByNodeBenchmarksOr`,`measured by node benchmarks, or from the hardware table where a node has no results`):o(`pipeline.clusterLoadBalancingTab.atTheModelsAutoTune`,`at the models Auto tune picks (at least {{minSessionsPerDevice}} per accelerator), from the measured speed of each node's hardware`,{minSessionsPerDevice:t.minSessionsPerDevice})}),` `,a===void 0?o(`pipeline.clusterLoadBalancingTab.automaticSharesAlreadyFollowThis`,`Automatic shares already follow this; the caps are advisory — apply each from its accelerator row.`):o(`pipeline.clusterLoadBalancingTab.applyingWritesTheNodeAnd`,`Applying writes the node and accelerator shares; the caps are advisory — apply each from its accelerator row.`)]})]})}function eo({stats:t,cameraName:n}){let{t:r}=X(),a=l(),o=Dt({onSuccess:()=>{a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPlacementStats`]]}),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});return i(q,{headingId:`load-balancing-stale-pins`,title:r(`pipeline.clusterLoadBalancingTab.staleDevicePins`,`Stale device pins`),icon:Ne,children:i(`ul`,{className:`divide-y divide-border`,children:t.stalePins.map(t=>e(`li`,{className:`${D} flex items-center gap-2`,children:[e(`div`,{className:`min-w-0 flex-1`,children:[i(`p`,{className:`truncate text-xs text-foreground`,title:n(t.deviceId),children:n(t.deviceId)}),i(`p`,{className:W,children:Ca(t)})]}),i(G,{variant:`outline`,size:`sm`,disabled:o.isPending,onClick:()=>o.mutate({deviceId:t.deviceId,deviceKey:`auto`}),children:r(`pipeline.clusterLoadBalancingTab.clearPin`,`Clear pin`)})]},t.deviceId))})})}function to({node:t,emphasis:n=!1}){let{t:r}=X(),a=t.isHub?T:S;return e(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[i(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${t.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),i(a,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex items-center gap-1.5 ${n?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[i(`span`,{className:`truncate`,children:t.name}),t.isHub&&i(J,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:r(`common.hubWord`)}),!t.isOnline&&i(J,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:r(`common.offline`)})]}),i(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:t.id})]})]})}function no({nodes:e,actions:t}){let{t:n}=X();return i(dt,{columns:[{key:`node`,header:n(`placementBoard.nodeCapabilitiesTable.node`,`Node`),sortValue:e=>e.name,render:e=>i(to,{node:e})},...rr.map(e=>({key:e.key,header:n(e.labelKey),align:`center`,notSortableReason:`A switch — sorting would move the row while it is being changed.`,render:r=>i(Ft,{"aria-label":n(`placementBoard.nodeCapabilitiesTable.on`,`{{label}} on {{name}}`,{label:n(e.labelKey),name:r.name}),title:n(e.hintKey),checked:Yn(r.effective,e.key),disabled:t.capabilityPending,onCheckedChange:n=>t.onToggleCapability(r.id,e.key,n)})}))],rows:e,rowKey:e=>e.id,bordered:!1,minWidthPx:720,rowClassName:e=>e.isOnline?void 0:`opacity-60`,emptyMessage:n(`placementBoard.nodeCapabilitiesTable.noClusterNodesReportingYet`,`No cluster nodes reporting yet.`)})}function ro({roleValues:t,options:n,pending:r,onRoleChange:a}){let{t:o}=X(),s=n.map(e=>({value:e.id,label:e.id===`hub`?o(`placementBoard.roleControls.default`,`{{name}} (default)`,{name:e.name}):e.name}));return i(`ul`,{className:`divide-y divide-border`,children:or.map(n=>e(`li`,{className:`${D} flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[e(`div`,{className:`min-w-0 flex-1 basis-56`,children:[i(`div`,{className:`text-xs font-medium text-foreground`,children:cr(n)}),i(`p`,{className:W,children:sr(n)})]}),i(`div`,{className:`w-full sm:w-48`,children:i(L,{"aria-label":o(`placementBoard.roleControls.node`,`{{value1}} node`,{value1:cr(n)}),value:t[n],disabled:r,options:s,onChange:e=>a(n,e.target.value)})})]},n))})}s();function io(){let{t}=X(),r=l(),{nodes:a}=K(),o=Zt(void 0),s=bt({addonId:Qn,cap:qn,scope:`cluster`}),c=bt({addonId:ir,cap:Jn,scope:`cluster`}),u=bt({addonId:ar,cap:tr,scope:`cluster`}),d=()=>Xn(r),f=it({onSuccess:d}),p=Je({onSuccess:d}),m=n(()=>{let e=new Map;for(let t of o.data??[])e.set(t.nodeId,t.settings);return e},[o.data]),h=n(()=>a.map(e=>{let t=m.get(e.id),n=fr(t);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n}}),[a,m]),g={ingestNode:Zn(s.data,`ingestNode`,`hub`),recordingNode:Zn(c.data,$n,`hub`),audioNode:Zn(s.data,`audioNode`,`hub`),motionNode:Zn(s.data,`motionNode`,`hub`),postProcessingNode:Zn(u.data,nr,`hub`)},_=n(()=>{let e=a.filter(e=>e.isOnline).map(e=>e.id),t=e=>a.find(t=>t.id===e)?.name||e;return[...new Set([`hub`,...or.map(e=>g[e]),...e])].filter(e=>e.length>0).map(e=>({id:e,name:t(e)}))},[a,g]),v=o.isLoading||s.isLoading||c.isLoading||u.isLoading,b=(e,t,n)=>{f.mutate({agentNodeId:e,[t]:n})},x=(e,t)=>{if(e===`recordingNode`){p.mutate({addonId:ir,cap:Jn,scope:`cluster`,patch:{[$n]:t}});return}if(e===`postProcessingNode`){p.mutate({addonId:ar,cap:tr,scope:`cluster`,patch:{[nr]:t}});return}p.mutate({addonId:Qn,cap:qn,scope:`cluster`,patch:{[e]:t}})},S={capabilityPending:f.isPending,onToggleCapability:b},C=v?i(y,{className:`h-3.5 w-3.5 animate-spin text-foreground-subtle`,"aria-label":t(`pipeline.clusterRolesNodesTab.loading`,`Loading`)}):null;return e(`div`,{className:`space-y-3 sm:space-y-4`,children:[e(q,{headingId:`roles-nodes-cluster-roles`,title:t(`pipeline.clusterRolesNodesTab.clusterRoles`,`Cluster roles`),icon:je,actions:C,children:[i(`p`,{className:`${W} border-b border-border px-3 py-1.5 sm:px-4`,children:t(`pipeline.clusterRolesNodesTab.oneNodeHoldsEachRole`,`One node holds each role for every camera. Detection shares and caps are on Load balancing.`)}),i(ro,{roleValues:g,options:_,pending:p.isPending,onRoleChange:x})]}),i(q,{headingId:`roles-nodes-node-capabilities`,title:t(`pipeline.clusterRolesNodesTab.nodeCapabilities`,`Node capabilities`),icon:T,children:i(no,{nodes:h,actions:S})})]})}s();var ao=2500,oo={faces:g,"semantic-search":se,"detail-crop":Fe,"native-lease":Ie,"runner-defaults":S,"load-balancer":Me,failover:C},so=[`cluster`,di];function co(e){a(()=>{if(e===null)return;let t=pi[e]??e,n=`[data-cluster-settings-card="${CSS.escape(t)}"]`,r=()=>{let e=document.querySelector(n);return e===null?!1:(e.scrollIntoView({block:`start`,behavior:`smooth`}),e.classList.add(`ring-2`,`ring-primary/60`),setTimeout(()=>e.classList.remove(`ring-2`,`ring-primary/60`),ao),!0)};if(r())return;let i=new MutationObserver(()=>{r()&&i.disconnect()});return i.observe(document.body,{childList:!0,subtree:!0}),()=>i.disconnect()},[e])}function lo({section:t}){let{t:n}=X();return i(`div`,{"data-cluster-settings-card":t.id,className:`rounded-lg`,children:i(q,{headingId:`cluster-settings-${t.id}`,title:t.title,...oo[t.id]===void 0?{}:{icon:oo[t.id]},children:e(`div`,{className:`${p} space-y-3`,children:[i(`p`,{className:W,children:t.hint}),t.panels.map(e=>i(On,{nodeId:`hub`,addonIds:[e.addonId],level:`global`,hideSectionChrome:!0,omitSectionIds:so.filter(t=>!(e.sectionIds??[]).includes(t)),emptyMessage:n(`pipeline.clusterSettingsTab.notAvailableTheAddonThat`,`Not available — the addon that owns these settings did not answer.`),...e.capability===void 0?{}:{capability:e.capability},...e.sectionIds===void 0?{}:{sectionIds:e.sectionIds},...e.fieldKeys===void 0?{}:{fieldKeys:e.fieldKeys},...e.fieldScope===void 0?{}:{fieldScope:e.fieldScope}},`${e.addonId}:${e.capability??``}`))]})})})}function uo({refreshToken:e}){let[t]=Dn();return co(t.get(gi)),i(`div`,{className:`space-y-3 sm:space-y-4`,children:fi.map(e=>i(lo,{section:e},e.id))})}function fo(e){return e?.hex}function po({hex:e}){return i(`span`,{className:`inline-block h-3 w-3 shrink-0 rounded-sm border border-border`,style:{backgroundColor:e}})}function mo({id:t,label:n,swatch:r}){let a=fo(r);return a===void 0?null:e(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-xs`,"data-testid":`palette-entry-${t}`,children:[r?.form===`gradient`?i(`span`,{className:`flex h-4 overflow-hidden rounded-sm`,children:me.map(e=>i(`span`,{className:`h-4 w-2`,style:{backgroundColor:a,opacity:e}},e))}):i(`span`,{className:`h-4 w-3 shrink-0 rounded-sm`,style:{backgroundColor:a}}),i(`span`,{children:n}),i(`span`,{className:`font-mono text-[11px] opacity-80`,children:a})]})}function ho({ground:t,group:n,swatches:r}){let{t:a}=X();return e(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[i(mo,{id:n.id,label:n.label,swatch:r[n.id]}),n.children.length>0&&e(`details`,{"data-testid":`palette-subs-${t}-${n.id}`,children:[i(`summary`,{className:`cursor-pointer text-[11px] opacity-80`,children:a(`pipeline.palette.subclasses`,`Subclasses`)}),i(`div`,{className:`mt-1 flex flex-col gap-1 pl-4`,children:n.children.map(e=>i(mo,{id:e.id,label:e.label,swatch:r[e.id]},e.id))})]})]})}function go({swatches:t}){let{t:n}=X(),r=fe(),a=[{id:`dark`,background:pe.dark,ink:pe.light},{id:`light`,background:pe.light,ink:pe.dark}];return e(`div`,{className:`flex flex-col gap-2`,"data-testid":`palette-preview`,children:[i(`div`,{className:`text-[11px] text-foreground-subtle`,children:n(`pipeline.palette.preview`,`Timeline marks`)}),a.map(e=>i(`div`,{className:`grid grid-cols-1 gap-x-4 gap-y-2 rounded-md border border-border p-2 sm:grid-cols-2`,"data-testid":`palette-ground-${e.id}`,style:{backgroundColor:e.background,color:e.ink},children:r.map(n=>i(ho,{ground:e.id,group:n,swatches:t},n.id))},e.id))]})}function _o(e){for(let t of fe()){if(t.id===e)return t.label;let n=t.children.find(t=>t.id===e);if(n!==void 0)return n.label}return e}s();function vo(e){return/^#[0-9a-f]{6}$/.test(e)}function yo(e,t){let n={};for(let r of ue){let i=t[r],a=e[r];i===void 0||a===void 0||i.hex!==a.hex&&(n[r]=i)}return n}function bo({status:t,reason:r,source:a,presetId:s,customized:c,swatches:l,presets:u,saving:d,onApply:f}){let{t:p}=X(),[m,h]=o(c===!0),[g,_]=o(s??u[0]?.id??`camstack`),[v,y]=o(l??u[0]?.swatches??{}),b=u.find(e=>e.id===g)??u[0],x=n(()=>b===void 0?null:de(v,b.fallbacks),[b,v]);if(t===`pending`)return i(`p`,{className:`text-xs text-foreground-subtle`,role:`status`,children:p(`pipeline.palette.pending`,`Reading the cluster palette…`)});let S=e=>{let t=u.find(t=>t.id===e);t!==void 0&&(h(!1),_(e),y(t.swatches),f({presetId:e}))},C=()=>{b!==void 0&&(h(!0),y(b.swatches))},w=(e,t)=>{if(typeof t!=`string`)return;let n=t.trim().toLowerCase();if(!vo(n))return;let r=v[e],i=r?.form===`gradient`?{...r,hex:n}:{form:`solid`,hex:n};y({...v,[e]:i})};return e(`div`,{className:`flex flex-col gap-4`,children:[t===`unknown`&&i(`p`,{className:`text-xs text-warning`,role:`status`,"data-testid":`palette-unknown`,children:p(`pipeline.palette.unknown`,`The stored palette cannot be read ({{reason}}). Boxes use the bundled CamStack preset.`,{reason:r??``})}),t===`ready`&&a===`unconfigured`&&i(`p`,{className:`text-xs text-foreground-subtle`,children:p(`pipeline.palette.sourceUnconfigured`,`CamStack preset (cluster default)`)}),i(q,{headingId:`palette-presets`,title:p(`pipeline.palette.presets`,`Presets`),children:e(`div`,{className:`flex flex-wrap gap-2 p-3`,children:[u.map(t=>i(G,{type:`button`,size:`sm`,variant:!m&&t.id===g?`primary`:`outline`,onClick:()=>S(t.id),disabled:d,children:e(`span`,{className:`inline-flex items-center gap-1`,children:[[`person`,`vehicle`,`animal`].map(e=>{let n=fo(t.swatches[e]);return n===void 0?null:i(po,{hex:n},e)}),t.name]})},t.id)),i(G,{type:`button`,size:`sm`,variant:m?`primary`:`outline`,onClick:C,disabled:d||b===void 0,children:p(`pipeline.palette.custom`,`Custom`)})]})}),i(go,{swatches:v}),x!==null&&x.ok&&i(`p`,{className:`text-xs text-success`,"data-testid":`palette-verdict`,children:p(`pipeline.palette.valid`,`Every colour is distinct on both themes.`)}),x!==null&&!x.ok&&i(`p`,{className:`text-xs text-danger`,"data-testid":`palette-verdict`,children:p(`pipeline.palette.invalid`,`This palette is refused: {{reason}}`,{reason:le(x.violations)})}),m&&b!==void 0&&i(q,{headingId:`palette-custom`,title:p(`pipeline.palette.custom`,`Custom`),children:e(`div`,{className:`flex flex-col gap-2 p-3`,children:[ue.map(e=>{let t=fo(v[e]);return t===void 0?null:i(ct,{field:{type:`color`,key:e,label:_o(e)},values:{[e]:t},onChange:(t,n)=>w(e,n)},e)}),i(G,{type:`button`,size:`sm`,onClick:()=>{if(b===void 0||x===null||!x.ok)return;let e=yo(b.swatches,v);f(Object.keys(e).length>0?{presetId:b.id,overrides:e}:{presetId:b.id})},disabled:d||x===null||!x.ok,children:p(`pipeline.palette.save`,`Save custom palette`)})]})})]})}function xo(){let e=yn({}),t=Mt({}),n=vn(),r=r=>{n.mutate(r,{onSuccess:()=>{e.refetch(),t.refetch()}})};if(e.isPending||t.isPending)return i(bo,{status:`pending`,presets:[],onApply:r});if(e.isError||e.data===void 0)return i(bo,{status:`unknown`,reason:e.isError?String(e.error):`no palette`,presets:t.data??[],saving:n.isPending,onApply:r});if(t.isError||t.data===void 0)return i(bo,{status:`unknown`,reason:String(t.error),presets:[],saving:n.isPending,onApply:r});if(e.data.status===`unknown`)return i(bo,{status:`unknown`,reason:e.data.reason,presets:t.data,saving:n.isPending,onApply:r});let a=e.data;return i(bo,{status:`ready`,source:a.source,presetId:a.presetId,customized:a.customized,swatches:a.swatches,presets:t.data,saving:n.isPending,onApply:r},`${a.presetId}:${String(a.customized)}`)}var So=`pipeline-orchestrator`,Co=200;function wo(){let{t}=X();return e(`div`,{className:`flex flex-col gap-3`,children:[e(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:t(`pipeline.clusterOrchestratorLogsTab.orchestratorLogs`,`Orchestrator logs`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.clusterOrchestratorLogsTab.dispatchDecisionsBalancerMovesAnd`,`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.`)})]}),i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:i(sn,{addonId:So,limit:Co,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1,showSourceSelect:!0})})]})}var To=[{id:`assignments`,labelKey:`pipeline.clusterDetail.tabAssignments`},{id:`load-balancing`,labelKey:`pipeline.clusterDetail.tabLoadBalancing`},{id:`auto-tune`,labelKey:`pipeline.clusterDetail.tabAutoTune`},{id:`roles-nodes`,labelKey:`pipeline.clusterDetail.tabRoles`},{id:`settings`,labelKey:`common.settings`},{id:`logs`,labelKey:`common.logs`},{id:`palette`,labelKey:`pipeline.clusterDetail.tabPalette`}];function Eo(e){return To.some(t=>t.id===e)}function Do({refreshToken:t}){let{t:n}=X(),[r,a]=Dn(),o=r.get(hi),s=Eo(o)?o:`assignments`,c=e=>{a(t=>{let n=new URLSearchParams(t);return n.set(hi,e),n.delete(gi),n},{replace:!0})};return e(`div`,{className:`flex flex-col h-full`,children:[e(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[i(`h2`,{className:`text-base font-semibold text-foreground`,children:n(`pipeline.clusterDetail.clusterOrchestration`,`Cluster Orchestration`)}),i(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:n(`pipeline.clusterDetail.cameraAssignmentsLoadBalancingThe`,`Camera assignments, load balancing, the detector recommendation, cluster roles, settings and the display palette.`)})]}),i(Bt,{value:s,onValueChange:e=>{Eo(e)&&c(e)},className:`px-4 sm:px-6`,children:i(rn,{className:`border-border`,children:To.map(e=>i(dn,{value:e.id,className:`h-auto py-2 border-b-2`,children:n(e.labelKey)},e.id))})}),e(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[s===`assignments`&&i(Hi,{}),s===`load-balancing`&&i(Qa,{refreshToken:t,onOpenAutoTune:()=>c(`auto-tune`)}),s===`auto-tune`&&i(sa,{}),s===`roles-nodes`&&i(io,{}),s===`settings`&&i(uo,{refreshToken:t}),s===`logs`&&i(wo,{}),s===`palette`&&i(xo,{})]})]})}function Q({title:t,children:n}){return e(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[i(`div`,{className:`text-[9px] font-semibold uppercase tracking-[0.14em] text-foreground-subtle mb-2`,children:t}),i(`div`,{className:`flex flex-col gap-1 min-w-0`,children:n})]})}function $({label:t,children:n,overridden:r=!1}){return e(`div`,{className:`flex items-baseline gap-2 text-[11px] leading-snug min-w-0`,children:[i(`span`,{className:`text-foreground-subtle shrink-0 w-24 truncate`,title:t,children:t}),i(`span`,{className:`font-mono tabular-nums text-foreground min-w-0 truncate flex-1`,children:n}),r&&i(Oo,{})]})}function Oo(){let{t:e}=X();return i(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0 self-center`,title:e(`cameras.cardPrimitives.deviceLevelOverrideActive`,`Device-level override active`),"aria-label":e(`cameras.cardPrimitives.deviceLevelOverrideActive`,`Device-level override active`),role:`img`})}var ko={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 Ao({tone:e=`neutral`,children:t,title:n}){return i(`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 ${ko[e]}`,children:t})}function jo({children:e}){return i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function Mo({icon:t,label:n,nodeId:r,pinned:a,reason:o,overridden:s}){let{t:c}=X();return e(`div`,{className:`flex items-center gap-2 text-[11px] leading-snug min-w-0`,children:[i(t,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),i(`span`,{className:`text-foreground-subtle w-[4.5rem] shrink-0`,children:n}),r===null?i(`span`,{className:`text-foreground-subtle italic`,children:c(`cameras.configBlocks.unassigned`)}):e(d,{children:[i(`span`,{className:`font-mono text-foreground truncate`,title:r,children:r}),a?e(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:c(`cameras.configBlocks.manuallyPinned`,`Manually pinned`),children:[i(te,{className:`h-2.5 w-2.5`}),` `,c(`cameras.configBlocks.manual`)]}):i(`span`,{className:`text-[10px] text-foreground-subtle shrink-0 truncate`,children:c(`cameras.configBlocks.autoReason`,{reason:o!==void 0&&o.length>0?o:c(`cameras.configBlocks.capacity`)})}),s&&i(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0`,title:c(`cameras.configBlocks.persistedSettingsPinForThis`,`Persisted settings pin for this role`)})]})]})}function No({assignment:t,settings:n,onlineNodes:r,pinPending:a,onDetectionPinChange:o}){let{t:s}=X(),c=t.pinned.detection&&t.detectionNodeId!==null?t.detectionNodeId:`auto`,l=[...new Set([...t.detectionNodeId===null?[]:[t.detectionNodeId],...r.map(e=>e.id)])];return e(Q,{title:s(`cameras.configBlocks.whereItRuns`,`Where it runs`),children:[i(Mo,{icon:S,label:s(`cameras.configBlocks.detection`,`Detection`),nodeId:t.detectionNodeId,pinned:t.pinned.detection,reason:t.reasons.detection,overridden:n.overriddenKeys.has(`pipelineNodeId`)}),i(Mo,{icon:V,label:s(`cameras.configBlocks.decoder`,`Decoder`),nodeId:t.decoderNodeId,pinned:t.pinned.decoder,reason:t.reasons.decoder,overridden:n.overriddenKeys.has(`decoderNodeId`)}),i(Mo,{icon:O,label:s(`cameras.configBlocks.audio`,`Audio`),nodeId:t.audioNodeId,pinned:t.pinned.audio,reason:t.reasons.audio,overridden:n.overriddenKeys.has(`audioNodeId`)}),i(Mo,{icon:M,label:s(`cameras.configBlocks.source`,`Source`),nodeId:t.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),i(`div`,{className:`mt-1.5`,children:e(L,{value:c,disabled:a,"aria-label":s(`cameras.configBlocks.detectionPlacementPin`,`Detection placement pin`),onChange:e=>o(e.target.value),className:`w-full min-w-0`,children:[i(`option`,{value:`auto`,children:s(`cameras.configBlocks.autoLoadBalanced`,`Auto (load balanced)`)}),l.map(e=>i(`option`,{value:e,children:s(`cameras.configBlocks.pinDetection`,{node:r.find(t=>t.id===e)?.name??e})},e))]})})]})}function Po(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function Fo(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function Io(e){return e===null?Y.t(`pipeline.configBlocks.fpsDefault`):e===0?Y.t(`pipeline.configBlocks.fpsNative`):`${e} fps`}function Lo({streams:t,brokerProfiles:n,settings:r,motionEnabled:a,motionFpsLive:o,cameraSensors:s}){let{t:c}=X(),l=Fo(n,r.detectionStreamProfile),u=Fo(n,r.motionStreamProfile),f=r.motionSources.includes(`analyzer`);return e(Q,{title:c(`cameras.configBlocks.streamsMotion`,`Streams & motion`),children:[e($,{label:c(`cameras.configBlocks.detectStream`,`Detect stream`),overridden:r.overriddenKeys.has(`detectionStreamProfile`),children:[r.detectionStreamProfile??`—`,l!==void 0&&` · ${l.width}×${l.height} ${l.codec}`]}),i($,{label:c(`cameras.configBlocks.detectFps`,`Detect FPS`),overridden:r.overriddenKeys.has(`detectionFps`),children:Io(r.detectionFps)}),e($,{label:c(`cameras.configBlocks.motionSrc`,`Motion src`),overridden:r.overriddenKeys.has(`motionSources`),children:[r.motionSources.length>0?r.motionSources.map(Ce).join(` + `):c(`cameras.configBlocks.none`),a===!1&&` · ${c(`cameras.configBlocks.inactive`)}`]}),i($,{label:c(`cameras.configBlocks.cameraSensors`,`Camera sensors`),children:Fn(s)}),f&&e(d,{children:[e($,{label:c(`cameras.configBlocks.motionStream`,`Motion stream`),overridden:r.overriddenKeys.has(`motionStreamProfile`),children:[r.motionStreamProfile??`—`,u!==void 0&&` · ${u.width}×${u.height} ${u.codec}`]}),e($,{label:c(`cameras.configBlocks.motionFps`,`Motion FPS`),overridden:r.overriddenKeys.has(`motionFps`),children:[Io(r.motionFps),o!==null&&` · ${c(`cameras.configBlocks.liveFps`,{fps:o.toFixed(1)})}`]})]}),i($,{label:c(`cameras.configBlocks.cooldown`,`Cooldown`),overridden:r.overriddenKeys.has(`motionCooldownMs`),children:r.motionCooldownMs===null?c(`cameras.configBlocks.defaultValue`):`${r.motionCooldownMs/1e3}s`}),i(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:t.length===0?i(jo,{children:c(`cameras.configBlocks.noStreamsRegistered`,`No streams registered`)}):t.map(t=>e(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:t.camStreamId,children:[i(`span`,{className:`text-foreground-muted`,children:t.kind}),` `,Po(t)]},t.camStreamId))})]})}function Ro({steps:t,audioModelId:n,audioEnabled:r,audioMode:a}){let{t:o}=X();return e(Q,{title:o(`cameras.configBlocks.pipelineSteps`,`Pipeline steps`),children:[t===void 0?i(jo,{children:o(`cameras.configBlocks.resolving`,`Resolving…`)}):t.length===0?i(jo,{children:o(`cameras.configBlocks.noStepsConfigured`,`No steps configured`)}):i(`div`,{className:`flex flex-wrap gap-1`,children:t.map((t,n)=>i(Ao,{tone:t.enabled&&t.depth===0?`info`:`neutral`,title:t.modelId??t.addonId,children:e(`span`,{className:t.enabled?``:`line-through opacity-60`,children:[t.depth>0&&i(`span`,{className:`opacity-50`,children:`↳ `}),t.addonId,t.modelId!==null&&e(`span`,{className:`font-mono opacity-75`,children:[` · `,t.modelId]})]})},`${t.addonId}-${n}`))}),i(`div`,{className:`mt-1`,children:e($,{label:o(`cameras.configBlocks.audioClass`,`Audio class.`),children:[a??`—`,r!==null&&` · ${o(r?`cameras.configBlocks.running`:`cameras.configBlocks.off`)}`,n!==null&&` · ${n}`]})})]})}var zo={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function Bo({detection:t,live:n,detectionMode:r,modeOverridden:a}){let o=I(),{t:s}=X();if(t===null)return e(Q,{title:s(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[i($,{label:s(`cameras.runtimeBlocks.mode`,`Mode`),overridden:a,children:r??`—`}),i(jo,{children:s(`cameras.runtimeBlocks.detectionStageInactiveOrUnreachable`,`Detection stage inactive or unreachable`)})]});let c=n?.phase??t.phase,l=n?.actualFps??t.actualFps,u=n?.configuredFps??t.configuredFps,d=n?.avgInferenceTimeMs??t.avgInferenceMs,f=n?.queueDepth??t.queueDepth,p=Nt(c,o),m=c===`active`&&l===0;return e(Q,{title:s(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[e(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[e(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider ${p.badgeClass}`,children:[i(Vt,{phase:c,className:`h-2.5 w-2.5`}),p.label]}),n!==void 0&&i(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:s(`common.live`)})]}),i($,{label:s(`cameras.runtimeBlocks.mode`,`Mode`),overridden:a,children:r??`—`}),e($,{label:`FPS`,children:[i(`span`,{className:m?`text-danger font-semibold`:``,children:l.toFixed(1)}),i(`span`,{className:`ml-1 text-foreground-subtle`,children:s(`cameras.runtimeBlocks.configuredFps`,{fps:u.toFixed(0)})})]}),e($,{label:s(`cameras.runtimeBlocks.inference`,`Inference`),children:[d.toFixed(0),` ms`,f>0&&i(`span`,{className:`ml-1 text-warning`,children:s(`cameras.runtimeBlocks.queue`,{depth:f})}),n!==void 0&&n.droppedFrames>0&&i(`span`,{className:`ml-1 text-warning`,children:s(`cameras.runtimeBlocks.drops`,{count:n.droppedFrames})})]}),e($,{label:s(`cameras.runtimeBlocks.engine`,`Engine`),children:[t.engine.backend,` · `,t.engine.device]}),e($,{label:s(`cameras.runtimeBlocks.provisioning`,`Provisioning`),children:[i(Ao,{tone:zo[t.provisioning.state]??`neutral`,children:t.provisioning.state}),t.provisioning.error!==void 0&&e(`span`,{className:`text-danger text-[10px]`,children:[` `,t.provisioning.error]})]})]})}function Vo({broker:t}){let{t:n}=X();return t===null?i(Q,{title:n(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:i(jo,{children:n(`cameras.runtimeBlocks.brokerStageInactiveOrUnreachable`,`Broker stage inactive or unreachable`)})}):e(Q,{title:n(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:[t.profiles.length===0?i(jo,{children:n(`cameras.runtimeBlocks.noBrokerProfiles`,`No broker profiles`)}):i(`div`,{className:`flex flex-col gap-1`,children:t.profiles.map(t=>{let r=t.status===`streaming`,a=r&&t.inFps===0;return e(`div`,{className:`flex items-center gap-2 text-[11px] font-mono tabular-nums min-w-0`,children:[i(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full shrink-0 ${a?`bg-danger`:r?`bg-success animate-pulse`:`bg-border`}`,title:t.status}),i(`span`,{className:`text-foreground w-10 shrink-0 truncate`,title:t.profile,children:t.profile}),e(`span`,{className:`text-foreground-subtle truncate`,children:[t.width,`×`,t.height,` `,t.codec]}),i(`span`,{className:`ml-auto shrink-0 ${a?`text-danger`:`text-foreground`}`,children:n(`cameras.runtimeBlocks.fpsValue`,{value:t.inFps===null?`—`:t.inFps.toFixed(0)})}),e(`span`,{className:`text-foreground-subtle shrink-0`,title:n(`cameras.runtimeBlocks.subscribers`,`Subscribers`),children:[`×`,t.subscribers]})]},t.profile)})}),e(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[i(Ao,{tone:t.webrtcSessions>0?`info`:`neutral`,children:n(`cameras.runtimeBlocks.webrtc`,{count:t.webrtcSessions})}),i(Ao,{tone:t.rtspRestream?`success`:`neutral`,children:t.rtspRestream?n(`cameras.runtimeBlocks.restreamOn`):n(`cameras.runtimeBlocks.restreamOff`)})]})]})}function Ho({decoder:e}){let{t}=X();return e===null?i(Q,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:i(jo,{children:t(`cameras.runtimeBlocks.decoderStageInactiveOrUnreachable`,`Decoder stage inactive or unreachable`)})}):i(Q,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:i($,{label:t(`cameras.runtimeBlocks.node`,`Node`),children:e.nodeId})})}s();var Uo=`pipeline-orchestrator`,Wo={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},Go={healthy:`pipeline.cameraPipelineCard.healthHealthy`,idle:`pipeline.cameraPipelineCard.healthIdle`,error:`pipeline.cameraPipelineCard.healthError`};function Ko({problems:t}){return i(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:t.map(t=>e(`div`,{className:`flex items-start gap-2 px-4 py-1.5 text-[11px] font-medium ${t.severity===`error`?`bg-danger/10 text-danger`:`bg-warning/10 text-warning`}`,children:[i(N,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),i(`span`,{className:`min-w-0`,children:t.message})]},t.code))})}function qo({deviceId:t,name:r,online:a,status:o,live:s,onlineNodes:c}){let{t:u}=X(),d=l(),{data:f}=Xe({addonId:Uo,deviceId:t,nodeId:`hub`},{staleTime:3e4}),{data:p}=et({deviceId:t},{staleTime:3e4}),m=n(()=>Gn(f),[f]),h=n(()=>p===void 0?void 0:Kn(p.steps),[p]),g=n(()=>o===void 0?[]:kn(o),[o]),_=()=>{d.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),d.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},v=Rt({onSuccess:_}),y=Re({onSuccess:_}),b=e=>{e===`auto`?y.mutate({deviceId:t}):v.mutate({deviceId:t,agentNodeId:e})},x=o===void 0?`idle`:jn(o),S=g.some(e=>e.severity===`error`),C=g.length>0,w=S?`border-danger/50`:C?`border-warning/40`:`border-border`;return e(`article`,{"aria-label":u(`cameras.cameraPipelineCard.pipelineStatus`,`{{name}} pipeline status`,{name:r}),className:`rounded-lg border ${w} bg-background overflow-hidden`,children:[e(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[i(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${S?`bg-danger`:Wo[x]}`,title:S?u(`common.error`,`Error`):u(Go[x]),"aria-label":S?u(`common.error`,`Error`):u(Go[x]),role:`img`}),i(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:r,children:r}),e(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,t]}),!a&&i(Ao,{tone:`danger`,children:u(`common.offline`)}),e(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[m.detectionMode!==null&&i(Ao,{tone:m.detectionMode===`disabled`?`warning`:m.detectionMode===`always-on`?`info`:`neutral`,title:u(`cameras.cameraPipelineCard.objectDetectionMode`,`Object detection mode`),children:m.detectionMode===`disabled`?u(`cameras.cameraPipelineCard.detectionOff`,`detection off`):m.detectionMode}),o?.recording!=null&&(o.recording.active?e(Ao,{tone:`danger`,title:u(`cameras.cameraPipelineCard.recording`,`Recording ({{mode}})`,{mode:o.recording.mode}),children:[i(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):o.recording.mode!==`off`&&i(Ao,{tone:`neutral`,title:u(`cameras.cameraPipelineCard.recordingMode`,`Recording mode`),children:u(`pipeline.cameraPipelineCard.recMode`,{mode:o.recording.mode})}))]})]}),g.length>0&&i(Ko,{problems:g}),o===void 0?i(`div`,{className:`px-4 py-5 text-[11px] text-foreground-subtle italic`,children:u(`cameras.cameraPipelineCard.noPipelineStatusYetThe`,`No pipeline status yet — the orchestrator has not composed a snapshot for this camera.`)}):e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[i(No,{assignment:o.assignment,settings:m,onlineNodes:c,pinPending:v.isPending||y.isPending,onDetectionPinChange:b}),i(Bo,{detection:o.detection,live:s,detectionMode:m.detectionMode,modeOverridden:m.overriddenKeys.has(`detectionMode`)}),i(Ro,{steps:h,audioModelId:p?.audio?.modelId??null,audioEnabled:o.audio?.enabled??p?.audio?.enabled??null,audioMode:m.audioMode}),i(Lo,{streams:o.source.streams,brokerProfiles:o.broker?.profiles,settings:m,motionEnabled:o.motion?.enabled??null,motionFpsLive:o.motion?.fps??null,cameraSensors:o.cameraSensors}),i(Vo,{broker:o.broker}),i(Ho,{decoder:o.decoder})]})]})}s();var Jo=5e3,Yo=1e4,Xo=5e3;function Zo(e){let t=l(),{data:r,isLoading:i}=wn(),{data:s,isLoading:c}=Pt({},{refetchInterval:Jo}),{nodes:u}=K();a(()=>{e!==0&&t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,t]);let[d,f]=o(new Map);$e(he.PipelineCameraMetricsSnapshot,e=>{let t=e.data;typeof t.deviceId==`number`&&f(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})}),a(()=>{if(d.size===0)return;let e=setInterval(()=>{f(e=>{let t=Date.now()-Yo,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},Xo);return()=>clearInterval(e)},[d.size]);let p=n(()=>{let e=new Map;for(let t of s??[])e.set(t.deviceId,t);return e},[s]);return{rows:n(()=>(r??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,online:e.online,status:p.get(e.id)})).sort((e,t)=>e.name.localeCompare(t.name)),[r,p]),liveMetrics:d,onlineNodes:n(()=>(u??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[u]),isLoading:i||c}}s();function Qo({refreshToken:t}){let{t:r}=X(),{rows:a,liveMetrics:o,onlineNodes:s,isLoading:c}=Zo(t),l=n(()=>[...a.map(e=>{let t=e.status===void 0?[]:kn(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),[a]),u=n(()=>{let e=0,t=0;for(let n of l)(n.errorCount>0||n.warningCount>0)&&(t+=1),(o.get(n.row.deviceId)?.phase??n.row.status?.detection?.phase)===`active`&&(e+=1);return{total:l.length,active:e,issues:t}},[l,o]);return c&&a.length===0?i(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:r(`cameras.camerasOverview.loadingCameraPipelines`,`Loading camera pipelines…`)}):a.length===0?i(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:r(`cameras.camerasOverview.noCamerasFound`,`No cameras found`)}):i(`div`,{className:`h-full overflow-y-auto`,children:e(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[e(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[i(`span`,{children:i(En,{i18nKey:`pipeline.camerasOverview.camerasTotal`,values:{count:u.total},components:{b:i(`span`,{className:`font-semibold text-foreground`})}})}),i(`span`,{children:i(En,{i18nKey:`pipeline.camerasOverview.activelyInferring`,values:{count:u.active},components:{b:i(`span`,{className:`font-semibold text-success`})}})}),e(`span`,{children:[i(`span`,{className:`font-semibold ${u.issues>0?`text-danger`:`text-foreground`}`,children:u.issues}),` `,r(`cameras.camerasOverview.withIssues`,`with issues`)]}),i(`span`,{className:`ml-auto hidden sm:inline text-[10px]`,children:r(`cameras.camerasOverview.polledEvery5SDetection`,`polled every 5 s · detection metrics live at 1 Hz`)})]}),l.map(({row:e})=>i(qo,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:o.get(e.deviceId),onlineNodes:s},e.deviceId))]})})}s();var $o=`__cluster__`;function es(e){return e===`cameras`?`cameras`:`nodes`}function ts({viewMode:t,onNodes:n,onCameras:r}){let{t:a}=X();return e(`div`,{className:`flex items-center gap-1 rounded-lg border border-border bg-surface p-0.5`,role:`tablist`,"aria-label":a(`pipeline.pipelineView`,`Pipeline view`),children:[i(`button`,{type:`button`,role:`tab`,"aria-selected":t===`nodes`,onClick:n,className:[`rounded-md px-3 py-1 text-[11px] font-medium transition-colors`,t===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:a(`pipeline.nodes`,`Nodes`)}),i(`button`,{type:`button`,role:`tab`,"aria-selected":t===`cameras`,onClick:r,className:[`rounded-md px-3 py-1 text-[11px] font-medium transition-colors`,t===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:a(`pipeline.cameras`,`Cameras`)})]})}function ns(){let{t}=X(),[n,r]=Dn(),s=es(n.get(`view`)),c=n.get(`node`)??`__cluster__`,[l,u]=o(0),[f,p]=o(!1);return a(()=>{s===`nodes`&&!n.get(`node`)&&r(e=>{let t=new URLSearchParams(e);return t.set(`view`,`nodes`),t.set(`node`,$o),t},{replace:!0})},[s,n,r]),e(pn,{icon:ke,title:t(`pipeline.pipeline`,`Pipeline`),subtitle:t(`pipeline.detectionPlacementLoadAndPer`,`Detection placement, load and per-camera runtime across the cluster.`),actions:e(G,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>u(e=>e+1),title:t(`common.refresh`,`Refresh`),children:[i(ee,{className:`h-3.5 w-3.5`}),t(`common.refresh`,`Refresh`)]}),nav:i(ts,{viewMode:s,onNodes:()=>{r({view:`nodes`,node:c},{replace:!0})},onCameras:()=>{r({view:`cameras`},{replace:!0})}}),className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[s===`nodes`&&e(G,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>p(e=>!e),"aria-expanded":f,className:`flex w-full shrink-0 justify-between border-b border-border md:hidden`,children:[i(`span`,{children:t(f?`pipeline.hideNodeList`:`pipeline.showNodeList`)}),i(De,{className:[`h-4 w-4 transition-transform`,f?`rotate-180`:``].join(` `)})]}),i(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden md:flex-row`,children:s===`nodes`?e(d,{children:[i(`aside`,{className:[f?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b border-border md:border-b-0 md:border-r`,`max-h-[60vh] overflow-y-auto md:max-h-none`].join(` `),children:i(mr,{selectedNodeId:c,onSelect:e=>{r({view:`nodes`,node:e},{replace:!0}),p(!1)},refreshToken:l})}),i(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:c===`__cluster__`?i(Do,{refreshToken:l}):i(Vi,{nodeId:c,refreshToken:l})})]}):i(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:i(Qo,{refreshToken:l})})})]})}export{ns as PipelinePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,x as ee}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$a as te,K as ne,Tr as re,U as ie,X as ae,Xa as oe,gi as se,mn as ce,n as le,tn as ue,yt as de,z as c}from"./player-overlays-6CqWKNYt.js";import{n as fe,t as pe}from"./mic-off-BIQ5bbUV.js";import{MaskShapeCanvas as me}from"./MaskShapeCanvas-CkL1-Z2p.js";s();var l=`Microphone`,u=`The camera encodes no audio at all — live view, recordings, exports and the audio analyzer are all silent.`;function he(e){let t=e.supportsAudioMute===!0,n=t?e.audioEnabled:null,r=e.pendingOn??null;return{label:l,supported:t,on:n===null?null:r??n,available:t&&n!==null,costWhenOff:u}}function ge(e){return!e.available||e.on===null?null:{enabled:!e.on}}var d=120,_e=`privacy-mask`,f=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,p=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`;function m(e){return e.kind===`rect`||e.kind===`polygon`?e:null}function ve(e){let t=new Set(e.map(e=>e.id)),n=0;for(;t.has(n);)n+=1;return n}function ye(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(JSON.stringify(e[n])!==JSON.stringify(t[n]))return!1;return!0}function h({deviceId:s}){let l=te(),u=ne(de().trpcClient,s),[h,g]=o(null),[_,v]=o(!1),[y,b]=o(!1),[x,S]=o(null),[C,w]=o(null),[T,E]=o(!1),[D,O]=o(!1),[k,A]=o(null),[j,M]=o(null),[N,P]=o(null),[F,I]=o(null),[L,R]=o(null),z=t(!1);a(()=>{if(!u)return;let e=!1;return z.current=!1,g(null),v(!1),b(!1),S(null),w(null),O(!1),A(null),M(null),P(null),I(null),R(null),(async()=>{try{let t=await u.privacyMask?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(g(t),z.current)return;let n=await u.privacyMask?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);if(n.regions===null){b(!0),P(n.audioEnabled);return}z.current=!0;let r={enabled:n.enabled,regions:n.regions};w(r),S(r),P(n.audioEnabled)}catch(t){if(e)return;ie(t)?v(!0):console.error(`Privacy Mask load failed`,t)}})(),()=>{e=!0}},[u]);let B=n(()=>x!==null&&C!==null&&(x.enabled!==C.enabled||!ye(x.regions,C.regions)),[x,C]),V=x?x.regions.length:0,H=h?h.maxRegions:0,U=t(0);a(()=>{U.current=H},[H]);let W=H>0&&V>=H,be=r(()=>{S(e=>e&&{...e,enabled:!e.enabled})},[]),G=r(e=>{A(typeof e==`number`?e:null)},[]),K=n(()=>x?x.regions.map(e=>({id:e.id,shape:e.shape,enabled:e.enabled,label:l(`uiLibrary.privacyMaskSettings.zoneN`,`Zone {{id}}`,{id:e.id})})):[],[x,l]),q=r((e,t)=>{let n=m(t);n&&S(t=>t&&{...t,regions:t.regions.map(t=>t.id===e?{...t,shape:n}:t)})},[]),J=r(e=>{let t=m(e);t&&(M(null),S(e=>{if(!e)return e;let n=U.current;if(n>0&&e.regions.length>=n)return e;let r=ve(e.regions),i={id:r,enabled:!0,shape:t};return A(r),{...e,regions:[...e.regions,i]}}))},[]),Y=r(e=>{O(!0),A(null),M(e)},[]),xe=r(e=>{O(!0),M(null),A(e)},[]),Se=r(e=>{A(t=>t===e?null:t),S(t=>t&&{...t,regions:t.regions.filter(t=>t.id!==e)})},[]),Ce=r(()=>{M(null),A(null),C&&S({enabled:C.enabled,regions:C.regions})},[C]),we=r(async()=>{if(!(!u||!x)){E(!0);try{await u.privacyMask?.setMask({patch:{enabled:x.enabled,regions:[...x.regions]}});let e=await u.privacyMask?.getStatus({});if(e&&e.regions!==null){let t={enabled:e.enabled,regions:e.regions};w(t),S(t)}}catch(e){console.error(`Privacy Mask save failed`,e)}finally{E(!1)}}},[u,x]),X=he({supportsAudioMute:h===null?null:h.supportsAudioMute,audioEnabled:N,pendingOn:F}),Z=r(async()=>{let e=ge(X);if(!(!u||e===null)){I(e.enabled),R(null);try{await u.privacyMask?.setAudioEnabled(e);let t=await u.privacyMask?.getStatus({});t&&P(t.audioEnabled)}catch(e){console.error(`Privacy microphone write failed — reverting`,e),R(e instanceof Error?e.message:String(e))}finally{I(null)}}},[u,X]),Te=r(()=>{O(e=>(e&&(M(null),A(null)),!e))},[]),Q=h?.supportedShapes??[];le(n(()=>D&&!_&&h&&x?{id:_e,order:d,node:i(me,{transparent:!0,items:K,supportedShapes:Q,polygonVertices:h.polygonVertices,selectedId:k,onSelect:G,onShapeChange:q,onDrawComplete:J,drawingKind:j})}:null,[D,_,h,x,K,Q,k,G,q,J,j]));let Ee=h?.supportedShapes.includes(`rect`)??!1,De=h?.supportedShapes.includes(`polygon`)??!1,$=h!==null&&(h.maxRegions<=0||h.supportedShapes.length===0),Oe=!_&&!$&&!y&&h!==null&&x!==null;return u?i(ae,{title:l(`uiLibrary.privacyMaskSettings.title`,`Privacy Mask`),icon:i(se,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:e(`div`,{className:`flex flex-col gap-3`,children:[_||$?i(`p`,{className:`${c} leading-relaxed`,children:l(`uiLibrary.privacyMaskSettings.unsupported`,`This camera doesn't support an on-board privacy mask.`)}):y?i(`p`,{className:`${c} leading-relaxed`,children:l(`uiLibrary.privacyMaskSettings.unreadable`,`This camera hasn't answered, so what it currently masks is unknown — the editor stays closed rather than showing an empty frame you could save over. A battery camera answers once it wakes; otherwise check that it is reachable.`)}):Oe?e(ee,{children:[i(`p`,{className:`${c} leading-relaxed`,children:i(oe,{uiKey:`uiLibrary.privacyMaskSettings.help`,fallback:`Toggle <0>Edit mask</0> to draw blanked-out zones on the live frame, then <1>Save</1> to push them to the camera. Drag a rectangle to move, its corner to resize; drag polygon vertices, click an edge midpoint to add one, or right-click a vertex to remove it.`,components:[i(`strong`,{className:`text-foreground`},`edit`),i(`strong`,{className:`text-foreground`},`save`)]})}),e(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[i(`button`,{type:`button`,onClick:Te,disabled:T,"aria-pressed":D,className:D?p:f,children:D?l(`uiLibrary.privacyMaskSettings.doneEditing`,`Done editing`):l(`uiLibrary.privacyMaskSettings.editMask`,`Edit mask`)}),i(`button`,{type:`button`,onClick:be,disabled:T,"aria-pressed":x.enabled,className:x.enabled?p:f,children:x.enabled?l(`uiLibrary.privacyMaskSettings.maskOn`,`Mask on`):l(`uiLibrary.privacyMaskSettings.maskOff`,`Mask off`)}),Ee&&i(`button`,{type:`button`,onClick:()=>Y(`rect`),disabled:T||W,"aria-pressed":j===`rect`,className:j===`rect`?p:f,title:W?l(`uiLibrary.privacyMaskSettings.maxZones`,`Maximum zones reached`):l(`uiLibrary.privacyMaskSettings.addRect`,`Add a rectangle zone`),children:l(`uiLibrary.privacyMaskSettings.rectButton`,`+ Rect`)}),De&&i(`button`,{type:`button`,onClick:()=>Y(`polygon`),disabled:T||W,"aria-pressed":j===`polygon`,className:j===`polygon`?p:f,title:W?l(`uiLibrary.privacyMaskSettings.maxZones`,`Maximum zones reached`):l(`uiLibrary.privacyMaskSettings.addPolygon`,`Add a polygon zone`),children:l(`uiLibrary.privacyMaskSettings.polygonButton`,`+ Polygon`)}),i(`span`,{className:`${c} ml-1 tabular-nums`,children:l(`uiLibrary.privacyMaskSettings.zoneCount`,`{{active}} / {{max}} zones`,{active:V,max:H})}),i(`span`,{className:`flex-1`}),i(`button`,{type:`button`,onClick:Ce,disabled:T||!B,className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,children:l(`uiLibrary.privacyMaskSettings.revert`,`Revert`)}),i(`button`,{type:`button`,onClick:()=>void we(),disabled:T||!B,className:p,children:T?l(`uiLibrary.privacyMaskSettings.saving`,`Saving…`):l(`uiLibrary.privacyMaskSettings.save`,`Save`)})]}),V>0?i(`div`,{className:`flex flex-col gap-1`,children:x.regions.map(t=>{let n=k===t.id,r=t.shape.kind===`polygon`?fe:ce;return e(`div`,{className:`flex items-center gap-2 rounded-md border px-2 py-1 transition-colors ${n?`border-primary/50 bg-primary/10`:`border-border bg-surface`}`,children:[e(`button`,{type:`button`,onClick:()=>xe(t.id),disabled:T,className:`flex flex-1 items-center gap-2 text-left text-[11px] font-medium text-foreground-subtle hover:text-foreground disabled:opacity-40 transition-colors`,children:[i(r,{className:`h-3.5 w-3.5 shrink-0`}),i(`span`,{children:l(`uiLibrary.privacyMaskSettings.zoneN`,`Zone {{id}}`,{id:t.id})}),i(`span`,{className:`text-foreground-faint capitalize`,children:t.shape.kind})]}),i(`button`,{type:`button`,onClick:()=>Se(t.id),disabled:T,"aria-label":l(`uiLibrary.privacyMaskSettings.deleteZoneN`,`Delete zone {{id}}`,{id:t.id}),title:l(`uiLibrary.privacyMaskSettings.deleteZone`,`Delete zone`),className:`inline-flex h-6 w-6 items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:border-red-400/40 hover:bg-red-500/10 hover:text-red-400 disabled:opacity-40 transition-colors`,children:i(ue,{className:`h-3.5 w-3.5`})})]},t.id)})}):null]}):i(`p`,{className:`${c} leading-relaxed`,children:l(`uiLibrary.privacyMaskSettings.loading`,`Loading the camera's privacy mask…`)}),X.supported&&e(`div`,{className:`flex items-start gap-3 rounded-md border border-border bg-surface px-2 py-2`,children:[i(`button`,{type:`button`,role:`switch`,"aria-label":X.label,"aria-checked":X.on===!0,disabled:!X.available||F!==null,onClick:()=>void Z(),title:X.on===null?l(`uiLibrary.privacyMaskSettings.micTitleUnknown`,`Microphone — state unknown; the camera did not answer.`):X.on?l(`uiLibrary.privacyMaskSettings.micTitleOn`,`The camera is capturing sound. Turning it off: {{cost}}`,{cost:X.costWhenOff}):l(`uiLibrary.privacyMaskSettings.micTitleOff`,`The camera is silent. {{cost}}`,{cost:X.costWhenOff}),className:X.on===!1||X.on===null?f:p,children:e(`span`,{className:`inline-flex items-center gap-1.5`,children:[X.on===!1?i(pe,{className:`h-3.5 w-3.5`}):i(re,{className:`h-3.5 w-3.5`}),X.on===null?l(`uiLibrary.privacyMaskSettings.micUnknown`,`Microphone unknown`):X.on?l(`uiLibrary.privacyMaskSettings.micOn`,`Microphone on`):l(`uiLibrary.privacyMaskSettings.micOff`,`Microphone off`)]})}),i(`p`,{className:`text-[10px] text-foreground-subtle flex-1 leading-relaxed`,children:L===null?X.on===null?l(`uiLibrary.privacyMaskSettings.micNotReported`,`The camera did not report its microphone, so this state is unknown.`):X.costWhenOff:l(`uiLibrary.privacyMaskSettings.writeFailed`,`Write failed: {{reason}}`,{reason:L})})]})]})}):null}export{h as PrivacyMaskSettings};
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,x as ee}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{K as te,Tr as ne,U as re,X as ie,Za as ae,eo as oe,gi as se,mn as ce,n as le,tn as ue,yt as de,z as c}from"./player-overlays-BF9w4QU-.js";import{n as fe,t as pe}from"./mic-off-BIQ5bbUV.js";import{MaskShapeCanvas as me}from"./MaskShapeCanvas-_BFcQxc-.js";s();var l=`Microphone`,u=`The camera encodes no audio at all — live view, recordings, exports and the audio analyzer are all silent.`;function he(e){let t=e.supportsAudioMute===!0,n=t?e.audioEnabled:null,r=e.pendingOn??null;return{label:l,supported:t,on:n===null?null:r??n,available:t&&n!==null,costWhenOff:u}}function ge(e){return!e.available||e.on===null?null:{enabled:!e.on}}var d=120,_e=`privacy-mask`,f=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,p=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`;function m(e){return e.kind===`rect`||e.kind===`polygon`?e:null}function ve(e){let t=new Set(e.map(e=>e.id)),n=0;for(;t.has(n);)n+=1;return n}function ye(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(JSON.stringify(e[n])!==JSON.stringify(t[n]))return!1;return!0}function h({deviceId:s}){let l=oe(),u=te(de().trpcClient,s),[h,g]=o(null),[_,v]=o(!1),[y,b]=o(!1),[x,S]=o(null),[C,w]=o(null),[T,E]=o(!1),[D,O]=o(!1),[k,A]=o(null),[j,M]=o(null),[N,P]=o(null),[F,I]=o(null),[L,R]=o(null),z=t(!1);a(()=>{if(!u)return;let e=!1;return z.current=!1,g(null),v(!1),b(!1),S(null),w(null),O(!1),A(null),M(null),P(null),I(null),R(null),(async()=>{try{let t=await u.privacyMask?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(g(t),z.current)return;let n=await u.privacyMask?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);if(n.regions===null){b(!0),P(n.audioEnabled);return}z.current=!0;let r={enabled:n.enabled,regions:n.regions};w(r),S(r),P(n.audioEnabled)}catch(t){if(e)return;re(t)?v(!0):console.error(`Privacy Mask load failed`,t)}})(),()=>{e=!0}},[u]);let B=n(()=>x!==null&&C!==null&&(x.enabled!==C.enabled||!ye(x.regions,C.regions)),[x,C]),V=x?x.regions.length:0,H=h?h.maxRegions:0,U=t(0);a(()=>{U.current=H},[H]);let W=H>0&&V>=H,be=r(()=>{S(e=>e&&{...e,enabled:!e.enabled})},[]),G=r(e=>{A(typeof e==`number`?e:null)},[]),K=n(()=>x?x.regions.map(e=>({id:e.id,shape:e.shape,enabled:e.enabled,label:l(`uiLibrary.privacyMaskSettings.zoneN`,`Zone {{id}}`,{id:e.id})})):[],[x,l]),q=r((e,t)=>{let n=m(t);n&&S(t=>t&&{...t,regions:t.regions.map(t=>t.id===e?{...t,shape:n}:t)})},[]),J=r(e=>{let t=m(e);t&&(M(null),S(e=>{if(!e)return e;let n=U.current;if(n>0&&e.regions.length>=n)return e;let r=ve(e.regions),i={id:r,enabled:!0,shape:t};return A(r),{...e,regions:[...e.regions,i]}}))},[]),Y=r(e=>{O(!0),A(null),M(e)},[]),xe=r(e=>{O(!0),M(null),A(e)},[]),Se=r(e=>{A(t=>t===e?null:t),S(t=>t&&{...t,regions:t.regions.filter(t=>t.id!==e)})},[]),Ce=r(()=>{M(null),A(null),C&&S({enabled:C.enabled,regions:C.regions})},[C]),we=r(async()=>{if(!(!u||!x)){E(!0);try{await u.privacyMask?.setMask({patch:{enabled:x.enabled,regions:[...x.regions]}});let e=await u.privacyMask?.getStatus({});if(e&&e.regions!==null){let t={enabled:e.enabled,regions:e.regions};w(t),S(t)}}catch(e){console.error(`Privacy Mask save failed`,e)}finally{E(!1)}}},[u,x]),X=he({supportsAudioMute:h===null?null:h.supportsAudioMute,audioEnabled:N,pendingOn:F}),Z=r(async()=>{let e=ge(X);if(!(!u||e===null)){I(e.enabled),R(null);try{await u.privacyMask?.setAudioEnabled(e);let t=await u.privacyMask?.getStatus({});t&&P(t.audioEnabled)}catch(e){console.error(`Privacy microphone write failed — reverting`,e),R(e instanceof Error?e.message:String(e))}finally{I(null)}}},[u,X]),Te=r(()=>{O(e=>(e&&(M(null),A(null)),!e))},[]),Q=h?.supportedShapes??[];le(n(()=>D&&!_&&h&&x?{id:_e,order:d,node:i(me,{transparent:!0,items:K,supportedShapes:Q,polygonVertices:h.polygonVertices,selectedId:k,onSelect:G,onShapeChange:q,onDrawComplete:J,drawingKind:j})}:null,[D,_,h,x,K,Q,k,G,q,J,j]));let Ee=h?.supportedShapes.includes(`rect`)??!1,De=h?.supportedShapes.includes(`polygon`)??!1,$=h!==null&&(h.maxRegions<=0||h.supportedShapes.length===0),Oe=!_&&!$&&!y&&h!==null&&x!==null;return u?i(ie,{title:l(`uiLibrary.privacyMaskSettings.title`,`Privacy Mask`),icon:i(se,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:e(`div`,{className:`flex flex-col gap-3`,children:[_||$?i(`p`,{className:`${c} leading-relaxed`,children:l(`uiLibrary.privacyMaskSettings.unsupported`,`This camera doesn't support an on-board privacy mask.`)}):y?i(`p`,{className:`${c} leading-relaxed`,children:l(`uiLibrary.privacyMaskSettings.unreadable`,`This camera hasn't answered, so what it currently masks is unknown — the editor stays closed rather than showing an empty frame you could save over. A battery camera answers once it wakes; otherwise check that it is reachable.`)}):Oe?e(ee,{children:[i(`p`,{className:`${c} leading-relaxed`,children:i(ae,{uiKey:`uiLibrary.privacyMaskSettings.help`,fallback:`Toggle <0>Edit mask</0> to draw blanked-out zones on the live frame, then <1>Save</1> to push them to the camera. Drag a rectangle to move, its corner to resize; drag polygon vertices, click an edge midpoint to add one, or right-click a vertex to remove it.`,components:[i(`strong`,{className:`text-foreground`},`edit`),i(`strong`,{className:`text-foreground`},`save`)]})}),e(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[i(`button`,{type:`button`,onClick:Te,disabled:T,"aria-pressed":D,className:D?p:f,children:D?l(`uiLibrary.privacyMaskSettings.doneEditing`,`Done editing`):l(`uiLibrary.privacyMaskSettings.editMask`,`Edit mask`)}),i(`button`,{type:`button`,onClick:be,disabled:T,"aria-pressed":x.enabled,className:x.enabled?p:f,children:x.enabled?l(`uiLibrary.privacyMaskSettings.maskOn`,`Mask on`):l(`uiLibrary.privacyMaskSettings.maskOff`,`Mask off`)}),Ee&&i(`button`,{type:`button`,onClick:()=>Y(`rect`),disabled:T||W,"aria-pressed":j===`rect`,className:j===`rect`?p:f,title:W?l(`uiLibrary.privacyMaskSettings.maxZones`,`Maximum zones reached`):l(`uiLibrary.privacyMaskSettings.addRect`,`Add a rectangle zone`),children:l(`uiLibrary.privacyMaskSettings.rectButton`,`+ Rect`)}),De&&i(`button`,{type:`button`,onClick:()=>Y(`polygon`),disabled:T||W,"aria-pressed":j===`polygon`,className:j===`polygon`?p:f,title:W?l(`uiLibrary.privacyMaskSettings.maxZones`,`Maximum zones reached`):l(`uiLibrary.privacyMaskSettings.addPolygon`,`Add a polygon zone`),children:l(`uiLibrary.privacyMaskSettings.polygonButton`,`+ Polygon`)}),i(`span`,{className:`${c} ml-1 tabular-nums`,children:l(`uiLibrary.privacyMaskSettings.zoneCount`,`{{active}} / {{max}} zones`,{active:V,max:H})}),i(`span`,{className:`flex-1`}),i(`button`,{type:`button`,onClick:Ce,disabled:T||!B,className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,children:l(`uiLibrary.privacyMaskSettings.revert`,`Revert`)}),i(`button`,{type:`button`,onClick:()=>void we(),disabled:T||!B,className:p,children:T?l(`uiLibrary.privacyMaskSettings.saving`,`Saving…`):l(`uiLibrary.privacyMaskSettings.save`,`Save`)})]}),V>0?i(`div`,{className:`flex flex-col gap-1`,children:x.regions.map(t=>{let n=k===t.id,r=t.shape.kind===`polygon`?fe:ce;return e(`div`,{className:`flex items-center gap-2 rounded-md border px-2 py-1 transition-colors ${n?`border-primary/50 bg-primary/10`:`border-border bg-surface`}`,children:[e(`button`,{type:`button`,onClick:()=>xe(t.id),disabled:T,className:`flex flex-1 items-center gap-2 text-left text-[11px] font-medium text-foreground-subtle hover:text-foreground disabled:opacity-40 transition-colors`,children:[i(r,{className:`h-3.5 w-3.5 shrink-0`}),i(`span`,{children:l(`uiLibrary.privacyMaskSettings.zoneN`,`Zone {{id}}`,{id:t.id})}),i(`span`,{className:`text-foreground-faint capitalize`,children:t.shape.kind})]}),i(`button`,{type:`button`,onClick:()=>Se(t.id),disabled:T,"aria-label":l(`uiLibrary.privacyMaskSettings.deleteZoneN`,`Delete zone {{id}}`,{id:t.id}),title:l(`uiLibrary.privacyMaskSettings.deleteZone`,`Delete zone`),className:`inline-flex h-6 w-6 items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:border-red-400/40 hover:bg-red-500/10 hover:text-red-400 disabled:opacity-40 transition-colors`,children:i(ue,{className:`h-3.5 w-3.5`})})]},t.id)})}):null]}):i(`p`,{className:`${c} leading-relaxed`,children:l(`uiLibrary.privacyMaskSettings.loading`,`Loading the camera's privacy mask…`)}),X.supported&&e(`div`,{className:`flex items-start gap-3 rounded-md border border-border bg-surface px-2 py-2`,children:[i(`button`,{type:`button`,role:`switch`,"aria-label":X.label,"aria-checked":X.on===!0,disabled:!X.available||F!==null,onClick:()=>void Z(),title:X.on===null?l(`uiLibrary.privacyMaskSettings.micTitleUnknown`,`Microphone — state unknown; the camera did not answer.`):X.on?l(`uiLibrary.privacyMaskSettings.micTitleOn`,`The camera is capturing sound. Turning it off: {{cost}}`,{cost:X.costWhenOff}):l(`uiLibrary.privacyMaskSettings.micTitleOff`,`The camera is silent. {{cost}}`,{cost:X.costWhenOff}),className:X.on===!1||X.on===null?f:p,children:e(`span`,{className:`inline-flex items-center gap-1.5`,children:[X.on===!1?i(pe,{className:`h-3.5 w-3.5`}):i(ne,{className:`h-3.5 w-3.5`}),X.on===null?l(`uiLibrary.privacyMaskSettings.micUnknown`,`Microphone unknown`):X.on?l(`uiLibrary.privacyMaskSettings.micOn`,`Microphone on`):l(`uiLibrary.privacyMaskSettings.micOff`,`Microphone off`)]})}),i(`p`,{className:`text-[10px] text-foreground-subtle flex-1 leading-relaxed`,children:L===null?X.on===null?l(`uiLibrary.privacyMaskSettings.micNotReported`,`The camera did not report its microphone, so this state is unknown.`):X.costWhenOff:l(`uiLibrary.privacyMaskSettings.writeFailed`,`Write failed: {{reason}}`,{reason:L})})]})]})}):null}export{h as PrivacyMaskSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$a as l,G as u,Ga as d,J as f,Jn as p,Jr as m,K as h,Ka as g,Ln as _,Q as v,U as y,Xa as b,c as x,ct as S,d as C,f as w,ft as T,l as E,p as D,s as O,sa as ee,tn as k,yt as te,z as A}from"./player-overlays-6CqWKNYt.js";import{MaskShapeCanvas as ne}from"./MaskShapeCanvas-CkL1-Z2p.js";s();var j=v(`/addon/pipeline-analytics/event-media`);function M(e){return`${j}/m/${e}`}function N(e){let t=new Map;for(let n of e.states)n.references.forEach((e,r)=>{let i=t.get(e.condition)??[];i.push({stateId:n.id,index:r,reference:e}),t.set(e.condition,i)});return[...t.entries()].map(([e,t])=>({condition:e,tiles:[...t].sort((e,t)=>t.reference.capturedAt-e.reference.capturedAt)})).sort((e,t)=>e.condition.localeCompare(t.condition))}function P(e){return e.states.reduce((e,t)=>e+t.references.length,0)}var F=`rounded border border-danger/50 bg-danger/10 px-1 py-0.5 text-[10px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`;function I({monitor:t,disabled:n,onDelete:r}){let a=l(),o=N(t),s=P(t),c=S();return o.length===0?i(`p`,{className:`${A} leading-relaxed`,children:a(`uiLibrary.sceneReferenceGallery.empty`,`No photographs captured yet. Press “Capture daylight” to take the one this scene will judge everything against.`)}):i(`div`,{className:`flex flex-col gap-2`,children:o.map(t=>e(`div`,{className:`flex flex-col gap-1`,children:[e(`p`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:[D(t.condition,a),` · `,t.tiles.length]}),i(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.tiles.map(o=>{let l=`${o.stateId}:${String(o.index)}`,u=s===1;return e(`li`,{className:`flex w-24 flex-col gap-1 rounded-md border border-border p-1`,children:[i(L,{reference:o.reference}),i(`span`,{className:`${A} tabular-nums`,children:R(o.reference.capturedAt)}),e(`button`,{type:`button`,className:F,disabled:n,"aria-label":a(`uiLibrary.sceneReferenceGallery.deleteLabel`,`Delete the {{variant}} photograph from {{date}}`,{variant:D(t.condition,a).toLowerCase(),date:R(o.reference.capturedAt)}),onClick:()=>{(async()=>{u&&!await c({title:a(`uiLibrary.sceneReferenceGallery.deleteTitle`,`Delete the only photograph?`),message:a(`uiLibrary.sceneReferenceGallery.lastWarning`,`This is the only photograph this scene has. Delete it and the scene no longer knows what normal looks like — it stops judging until you capture again.`),confirmLabel:a(`uiLibrary.sceneReferenceGallery.delete`,`Delete`),variant:`danger`})||r({stateId:o.stateId,index:o.index})})()},children:[i(k,{className:`mr-1 inline h-3 w-3`}),a(`uiLibrary.sceneReferenceGallery.delete`,`Delete`)]})]},l)})})]},t.condition))})}function L({reference:t}){let n=l(),[r,a]=o(!1),s=t.thumbnailMediaId;return s===void 0||r?e(`div`,{className:`flex h-16 w-full flex-col items-center justify-center gap-0.5 rounded bg-surface text-foreground-subtle`,title:n(`uiLibrary.sceneReferenceGallery.missingPicture`,`The picture for this reference is no longer stored. The reference itself is intact and still being scored against.`),children:[i(m,{className:`h-4 w-4`}),i(`span`,{className:`text-[9px]`,children:n(`uiLibrary.sceneReferenceGallery.noPicture`,`no picture`)})]}):i(`img`,{src:M(s),alt:``,loading:`lazy`,className:`h-16 w-full rounded object-cover`,onError:()=>a(!0)})}function R(e){let t=new Date(e);return`${t.toLocaleDateString()} ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`}s();var z=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,B=`text-[10px] font-medium text-foreground-subtle`,V=`flex flex-col gap-2 rounded-md border border-border bg-surface/40 p-2`,H=`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,U=5,W=3600;function G(e,t){switch(e){case`periodic`:return t(`uiLibrary.sceneSettingsForm.triggerHintPeriodic`,`Only on the clock. Predictable, and it notices a change even on a camera nothing ever moves in front of.`);case`on-motion`:return t(`uiLibrary.sceneSettingsForm.triggerHintOnMotion`,`Only after the camera has been still again for the quiet window below. Cheapest, but a change nobody walks past is never seen.`);case`both`:return t(`uiLibrary.sceneSettingsForm.triggerHintBoth`,`Both — the clock is the safety net that lets the motion path miss. This is the right answer for almost every scene.`)}}function K(e,t){switch(e){case`skip`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintSkip`,`Sit that light out. No verdict, no alarm, no flag touched — it picks itself back up when a light it knows returns. This is why the night capture is optional.`);case`judge-anyway`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintJudge`,`Compare against the references you do have. Only correct when the two lights genuinely look alike (a floodlit driveway, an indoor lamp) — against a real infrared frame it will report a change that did not happen.`)}}function q(e){return{label:e.label,checkIntervalSec:e.checkIntervalSec??60,threshold:e.check.mode===`similarity`?e.check.threshold:.8,hysteresisCount:e.check.hysteresisCount,quietSeconds:e.quietSeconds,minObservationSpacingSec:e.minObservationSpacingSec,confirmPrompt:e.confirm?.prompt??``}}function re({monitor:t,disabled:n,onPatch:r}){let s=l(),[u,f]=o(()=>q(t)),[p,m]=o(!1);a(()=>{p||f(q(t))},[t,p]);let h=e=>{m(!1),r(e)},_=e=>t.check.mode===`similarity`?{mode:`similarity`,threshold:e.threshold??t.check.threshold,hysteresisCount:e.hysteresisCount??t.check.hysteresisCount}:{...t.check,hysteresisCount:e.hysteresisCount??t.check.hysteresisCount},v=t.confirm?.enabled===!0,y=t.check.mode===`similarity`?t.check.threshold:null;return e(`div`,{className:`flex flex-col gap-2`,children:[e(`div`,{className:V,children:[i(`p`,{className:H,children:s(`uiLibrary.sceneSettingsForm.whatItWatches`,`What it watches`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.name`,`Name`)}),i(`input`,{type:`text`,value:u.label,disabled:n,className:z,onFocus:()=>m(!0),onChange:e=>f(t=>({...t,label:e.target.value})),onBlur:()=>{let e=u.label.trim();e.length>0&&e!==t.label?h({label:e}):m(!1)}})]}),e(`label`,{className:`flex items-center gap-2`,children:[i(d,{checked:t.enabled,disabled:n,onChange:e=>h({enabled:e.target.checked})}),i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.watching`,`Watching`)})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.watchingHint`,`Turned off, the scene keeps its region, its references and its flag — it simply stops checking. Nothing is lost by pausing one for a while.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.whenToLook`,`When to look`)}),e(T,{value:t.triggerMode,disabled:n,className:z,onChange:e=>{let t=e.target.value;(t===`periodic`||t===`on-motion`||t===`both`)&&h({triggerMode:t})},children:[i(`option`,{value:`both`,children:s(`uiLibrary.sceneSettingsForm.triggerBoth`,`On the clock and after motion settles`)}),i(`option`,{value:`periodic`,children:s(`uiLibrary.sceneSettingsForm.triggerPeriodic`,`On the clock only`)}),i(`option`,{value:`on-motion`,children:s(`uiLibrary.sceneSettingsForm.triggerOnMotion`,`After motion settles only`)})]})]}),i(`p`,{className:A,children:G(t.triggerMode,s)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.checkEvery`,`Check every (seconds)`)}),i(`input`,{type:`number`,min:U,max:W,value:u.checkIntervalSec,disabled:n,className:z,onFocus:()=>m(!0),onChange:e=>f(t=>({...t,checkIntervalSec:Number(e.target.value)||0})),onBlur:()=>{let e=J(u.checkIntervalSec,U,W);e===t.checkIntervalSec?m(!1):h({checkIntervalSec:e})}})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.intervalHint`,`60 s suits “is the bin still out”. Every check costs one photograph and one encode, so going below about 30 s buys latency you almost never need and multiplies the cost by the number of scenes you own.`)})]}),e(`div`,{className:V,children:[i(`p`,{className:H,children:s(`uiLibrary.sceneSettingsForm.howSure`,`How sure it has to be`)}),t.check.mode===`similarity`&&e(c,{children:[e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:i(b,{uiKey:`uiLibrary.sceneSettingsForm.matchThreshold`,fallback:`Match threshold — <0>{{value}}</0>`,components:[i(`span`,{className:`tabular-nums`},`value`)],values:{value:u.threshold.toFixed(2)}})}),i(g,{min:.3,max:.99,step:.01,value:u.threshold,disabled:n,onFocus:()=>m(!0),onChange:e=>f(t=>({...t,threshold:Number(e.target.value)})),onMouseUp:()=>{u.threshold===y?m(!1):h({check:_({threshold:u.threshold})})},onBlur:()=>{u.threshold===y?m(!1):h({check:_({threshold:u.threshold})})}})]}),i(`p`,{className:`text-[10px] text-foreground-subtle`,children:s(`uiLibrary.sceneSettingsForm.thresholdHint`,`How closely the region still has to resemble the photograph to count as unchanged. Higher means fussier: at 0.95 a passing cloud can read as a change; at 0.60 the bin can be taken and the scene will shrug. 0.80 is a sensible start — if it cries wolf, lower it; if it misses the thing you care about, raise it.`)})]}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.agreeingChecks`,`Agreeing checks before it changes its mind`)}),i(`input`,{type:`number`,min:1,max:10,value:u.hysteresisCount,disabled:n,className:z,onFocus:()=>m(!0),onChange:e=>f(t=>({...t,hysteresisCount:Number(e.target.value)||1})),onBlur:()=>{let e=J(u.hysteresisCount,1,10);e===t.check.hysteresisCount?m(!1):h({check:_({hysteresisCount:e})})}})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.agreeingHint`,`One bad photograph must never be able to flip a scene. 3 agreeing checks at 60 s is about four minutes of latency and is what makes the answer trustworthy — leaving a state costs exactly the same as entering one.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.quietFor`,`Quiet for (seconds) before a check counts`)}),i(`input`,{type:`number`,min:0,max:3600,value:u.quietSeconds,disabled:n,className:z,onFocus:()=>m(!0),onChange:e=>f(t=>({...t,quietSeconds:Number(e.target.value)||0})),onBlur:()=>{let e=J(u.quietSeconds,0,3600);e===t.quietSeconds?m(!1):h({quietSeconds:e})}})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.quietHint`,`A check taken while something is moving is a photograph of the van parked in front of the bin, so it is discarded rather than merely delayed. 0 disables the gate.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.minGap`,`Minimum gap between counted checks (seconds)`)}),i(`input`,{type:`number`,min:0,max:3600,value:u.minObservationSpacingSec,disabled:n,className:z,onFocus:()=>m(!0),onChange:e=>f(t=>({...t,minObservationSpacingSec:Number(e.target.value)||0})),onBlur:()=>{let e=J(u.minObservationSpacingSec,0,3600);e===t.minObservationSpacingSec?m(!1):h({minObservationSpacingSec:e})}})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.minGapHint`,`Spreads the agreeing checks over real time instead of letting three adjacent polls inside one long occlusion be mistaken for three independent opinions.`)})]}),e(`div`,{className:V,children:[i(`p`,{className:H,children:s(`uiLibrary.sceneSettingsForm.lighting`,`Lighting`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.noReference`,`When a light has no reference of its own`)}),e(T,{value:t.onUncoveredCondition,disabled:n,className:z,onChange:e=>{let t=e.target.value;(t===`skip`||t===`judge-anyway`)&&h({onUncoveredCondition:t})},children:[i(`option`,{value:`skip`,children:s(`uiLibrary.sceneSettingsForm.uncoveredSkip`,`Skip the check (recommended)`)}),i(`option`,{value:`judge-anyway`,children:s(`uiLibrary.sceneSettingsForm.uncoveredJudge`,`Judge against the other light anyway`)})]})]}),i(`p`,{className:A,children:K(t.onUncoveredCondition,s)})]}),e(`div`,{className:V,children:[i(`p`,{className:H,children:s(`uiLibrary.sceneSettingsForm.whatYouGetTold`,`What you get told`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.notificationsFollow`,`Notifications follow`)}),e(T,{value:t.emit,disabled:n,className:z,onChange:e=>{let t=e.target.value;(t===`latched`||t===`live`)&&h({emit:t})},children:[i(`option`,{value:`latched`,children:s(`uiLibrary.sceneSettingsForm.emitLatched`,`The flag — told once, still visible at breakfast`)}),i(`option`,{value:`live`,children:s(`uiLibrary.sceneSettingsForm.emitLive`,`The live state — follows the region as it changes`)})]})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.emitHint`,`“Is the bin gone” is a flag: you want to be told once and still see it later. “Is the gate open” is a live state.`)}),e(`label`,{className:`flex items-center gap-2`,children:[i(d,{checked:t.autoRestore,disabled:n,onChange:e=>h({autoRestore:e.target.checked})}),i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.autoRestore`,`Clear the flag by itself when things look normal again`)})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.autoRestoreHint`,`Off by default, so an alarm never silently clears itself. The “back to normal” moment is recorded either way, so an automation can still react to it.`)})]}),e(`div`,{className:V,children:[i(`p`,{className:H,children:s(`uiLibrary.sceneSettingsForm.aiDoubleCheck`,`AI double-check`)}),e(`label`,{className:`flex items-center gap-2`,children:[i(d,{checked:v,disabled:n||u.confirmPrompt.trim().length===0,onChange:e=>h(e.target.checked?{confirm:{...Y(u.confirmPrompt.trim()),enabled:!0}}:{confirm:null})}),i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.askVision`,`Ask a vision model before changing the answer`)})]}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.question`,`The question to ask`)}),i(`input`,{type:`text`,value:u.confirmPrompt,placeholder:s(`uiLibrary.sceneSettingsForm.questionPlaceholder`,`e.g. Is the wheelie bin still there?`),disabled:n,className:z,onFocus:()=>m(!0),onChange:e=>f(t=>({...t,confirmPrompt:e.target.value})),onBlur:()=>{let e=u.confirmPrompt.trim();e.length>0&&e!==t.confirm?.prompt?h({confirm:{...Y(e),enabled:v}}):m(!1)}})]}),i(`p`,{className:A,children:i(b,{uiKey:`uiLibrary.sceneSettingsForm.confirmHint`,fallback:`The model is asked <0>only</0> when the region has already changed enough to flip the answer — roughly twice a week for a bin, not once a minute. It reasons about the object rather than the pixels, so rain, shadows and a repositioned bin stop counting as the thing being taken. If it cannot be reached, the change is held rather than announced.`,components:[i(`strong`,{},`only`)]})})]})]})}function J(e,t,n){return Math.min(n,Math.max(t,e))}function Y(e){return{enabled:!1,prompt:e,timeoutMs:8e3,maxImagePx:448,onTimeout:`hold`}}s();var X=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,Z=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`,ie=`rounded-md border border-danger/50 bg-danger/10 px-2 py-1 text-[11px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`,ae={alarm:`border-danger/50 bg-danger/15 text-danger`,ok:`border-success/50 bg-success/15 text-success`,unknown:`border-border bg-surface text-foreground-subtle`},oe=.8,se=3;function Q({deviceId:s}){let d=l(),m=h(te().trpcClient,s),g=f(m?.state.sceneMonitor),v=u(s,{width:640}),[b,S]=o(null),[T,j]=o(!1),[M,N]=o(null),[P,F]=o(null),[L,R]=o(null),[z,B]=o(null),[V,H]=o(!1),[U,W]=o(null),[G,K]=o(``),q=t(!0);a(()=>(q.current=!0,()=>{q.current=!1}),[]);let J=r(async()=>{if(m)try{let e=await m.sceneMonitor?.listScenes({});if(!q.current)return;e&&S(e)}catch(e){if(!q.current)return;y(e)?j(!0):F(e instanceof Error?e.message:String(e))}},[m]);a(()=>{S(null),j(!1),F(null),J()},[J]);let Y=g?.monitors??b?.monitors??[],Q=Date.now(),$=r(async(e,t)=>{N(e),F(null);try{await t(),await J()}catch(e){q.current&&F(e instanceof Error?e.message:String(e))}finally{q.current&&N(null)}},[J]),ce=n(()=>{let e=Y.map(e=>({id:e.id,shape:e.roi,label:e.label,enabled:e.enabled}));return U===null?e:[...e,{id:`__draft__`,shape:U,label:d(`uiLibrary.sceneMonitor.newSceneLabel`,`New scene`)}]},[Y,U,d]),le=r((e,t)=>{if(t.kind===`rect`){if(e===`__draft__`){W(t);return}$(`roi-${String(e)}`,async()=>m?.sceneMonitor?.updateScene({monitorId:String(e),patch:{roi:t}}))}},[m,$]),ue=r(e=>{e.kind===`rect`&&W(e)},[]),de=r(async()=>{U===null||G.trim().length===0||(await $(`create`,async()=>{await m?.sceneMonitor?.createScene({label:G.trim(),roi:U,check:{mode:`similarity`,threshold:oe,hysteresisCount:se}})}),W(null),K(``),H(!1))},[m,U,G,$]);return m?i(`div`,{className:`flex flex-col gap-3`,children:T?i(`p`,{className:`${A} leading-relaxed`,children:d(`uiLibrary.sceneMonitor.unsupported`,`Scene monitoring is not available for this camera.`)}):e(c,{children:[i(`p`,{className:`${A} leading-relaxed`,children:d(`uiLibrary.sceneMonitor.intro`,`A scene watches one region of this camera and tells you when it stops looking like the picture you captured. Draw a box around the thing you care about — a wheelie bin, a gate, a parking space — then capture what “normal” looks like. Daylight is enough to start: the night reference is optional, and without it the scene simply sits the infrared hours out instead of reporting a problem.`)}),i(`div`,{className:`relative overflow-hidden rounded-md border border-border`,children:i(ne,{items:ce,supportedShapes:[`rect`],selectedId:L??(U===null?null:`__draft__`),onSelect:e=>R(e===null?null:String(e)),onShapeChange:le,onDrawComplete:ue,drawingKind:V&&U===null?`rect`:null,backdrop:v.src===null?null:i(`img`,{src:v.src,alt:``,className:`h-full w-full object-contain`,draggable:!1})})}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`button`,{type:`button`,className:V?Z:X,"aria-pressed":V,onClick:()=>{H(e=>!e),W(null)},disabled:M!==null,children:V?d(`uiLibrary.sceneMonitor.cancel`,`Cancel`):d(`uiLibrary.sceneMonitor.newScene`,`+ New scene`)}),i(`button`,{type:`button`,className:X,onClick:v.refresh,disabled:M!==null,children:d(`uiLibrary.sceneMonitor.refresh`,`Refresh frame`)})]}),V&&e(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-2`,children:[i(`p`,{className:`text-[10px] text-foreground-subtle`,children:U===null?d(`uiLibrary.sceneMonitor.draftHint`,`Click on the frame to drop a box, then drag its corner to fit it around the thing you want watched.`):d(`uiLibrary.sceneMonitor.nameHint`,`Name it, then create. You capture what “normal” looks like next.`)}),U!==null&&C(U)&&i(`p`,{className:`text-[11px] leading-relaxed text-warning`,children:d(`uiLibrary.sceneMonitor.tooLarge`,`That box covers most of the frame. A scene that big is dominated by the weather, the sky and passing cars — it will quietly stop noticing the thing you actually care about. Draw it tighter.`)}),e(`div`,{className:`flex items-center gap-2`,children:[i(`input`,{type:`text`,value:G,onChange:e=>K(e.target.value),placeholder:d(`uiLibrary.sceneMonitor.placeholder`,`e.g. Immondizia prelevata`),className:`flex-1 rounded-md border border-border bg-surface px-2 py-1 text-[12px] text-foreground`}),i(`button`,{type:`button`,className:Z,onClick:()=>void de(),disabled:U===null||G.trim().length===0||M!==null,children:d(`uiLibrary.sceneMonitor.create`,`Create`)})]})]}),P!==null&&i(`p`,{className:`text-[11px] leading-relaxed text-danger`,children:P}),Y.length===0?i(`p`,{className:`${A} leading-relaxed`,children:d(`uiLibrary.sceneMonitor.empty`,`No scenes on this camera yet.`)}):i(`ul`,{className:`flex flex-col gap-2`,children:Y.map(t=>{let n=x(t,d);return e(`li`,{className:`flex flex-col gap-1.5 rounded-md border p-2 ${L===t.id?`border-primary/50`:`border-border`}`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{type:`button`,className:`flex-1 text-left text-[12px] font-medium text-foreground`,onClick:()=>R(t.id),children:t.label}),i(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium ${ae[n.tone]}`,children:n.text})]}),i(`p`,{className:`${A} leading-relaxed`,children:w(t,Q,d)}),i(`p`,{className:`${A} tabular-nums`,children:E(t,d)}),i(I,{monitor:t,disabled:M!==null,onDelete:({stateId:e,index:n})=>void $(`refdel-${t.id}-${e}-${String(n)}`,async()=>m.sceneMonitor?.deleteReference({monitorId:t.id,stateId:e,index:n}))}),e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[O.map(n=>{let r=n===`ir`;return e(`button`,{type:`button`,className:X,disabled:M!==null,title:r?d(`uiLibrary.sceneMonitor.optionalTitle`,`Optional. Without a night reference the checks in infrared are simply skipped — the scene keeps working in daylight and nothing is reported as broken.`):d(`uiLibrary.sceneMonitor.captureTitle`,`Take a fresh photo now and store it as the {{variant}} reference`,{variant:D(n,d).toLowerCase()}),onClick:()=>void $(`cap-${t.id}-${n}`,async()=>m.sceneMonitor?.captureReference({monitorId:t.id,condition:n})),children:[i(ee,{className:`mr-1 inline h-3 w-3`}),d(`uiLibrary.sceneMonitor.capture`,`Capture {{variant}}`,{variant:D(n,d).toLowerCase()}),r&&i(`span`,{className:`ml-1 text-foreground-subtle/70`,children:d(`uiLibrary.sceneMonitor.optional`,`(optional)`)})]},n)}),e(`button`,{type:`button`,className:Z,disabled:M!==null||t.states.length===0,title:d(`uiLibrary.sceneMonitor.resetTitle`,`Clear the flag and re-photograph what normal looks like right now`),onClick:()=>void $(`reset-${t.id}`,async()=>m.sceneMonitor?.resetScene({monitorId:t.id})),children:[i(p,{className:`mr-1 inline h-3 w-3`}),d(`uiLibrary.sceneMonitor.reset`,`Reset`)]}),i(`button`,{type:`button`,className:X,disabled:M!==null,onClick:()=>void $(`check-${t.id}`,async()=>m.sceneMonitor?.recheckNow({monitorId:t.id})),children:d(`uiLibrary.sceneMonitor.checkNow`,`Check now`)}),e(`button`,{type:`button`,className:z===t.id?Z:X,"aria-pressed":z===t.id,"aria-label":d(`uiLibrary.sceneMonitor.settingsFor`,`Settings for {{label}}`,{label:t.label}),disabled:M!==null,onClick:()=>B(e=>e===t.id?null:t.id),children:[i(_,{className:`mr-1 inline h-3 w-3`}),d(`uiLibrary.sceneMonitor.settings`,`Settings`)]}),i(`button`,{type:`button`,className:ie,disabled:M!==null,onClick:()=>void $(`del-${t.id}`,async()=>m.sceneMonitor?.deleteScene({monitorId:t.id})),children:i(k,{className:`h-3 w-3`})})]}),z===t.id&&i(re,{monitor:t,disabled:M!==null,onPatch:e=>void $(`tune-${t.id}`,async()=>m.sceneMonitor?.updateScene({monitorId:t.id,patch:e}))})]},t.id)})})]})}):null}export{Q as SceneMonitorEditor};
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{G as l,J as u,Jn as d,Jr as f,K as p,Ka as m,Ln as h,Q as g,U as _,Za as v,c as ee,ca as te,ct as y,d as b,eo as x,f as S,ft as C,l as w,p as T,qa as E,s as D,tn as O,yt as k,z as A}from"./player-overlays-BF9w4QU-.js";import{MaskShapeCanvas as ne}from"./MaskShapeCanvas-_BFcQxc-.js";s();var j=g(`/addon/pipeline-analytics/event-media`);function M(e){return`${j}/m/${e}`}function N(e){let t=new Map;for(let n of e.states)n.references.forEach((e,r)=>{let i=t.get(e.condition)??[];i.push({stateId:n.id,index:r,reference:e}),t.set(e.condition,i)});return[...t.entries()].map(([e,t])=>({condition:e,tiles:[...t].sort((e,t)=>t.reference.capturedAt-e.reference.capturedAt)})).sort((e,t)=>e.condition.localeCompare(t.condition))}function P(e){return e.states.reduce((e,t)=>e+t.references.length,0)}var F=`rounded border border-danger/50 bg-danger/10 px-1 py-0.5 text-[10px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`;function I({monitor:t,disabled:n,onDelete:r}){let a=x(),o=N(t),s=P(t),c=y();return o.length===0?i(`p`,{className:`${A} leading-relaxed`,children:a(`uiLibrary.sceneReferenceGallery.empty`,`No photographs captured yet. Press “Capture daylight” to take the one this scene will judge everything against.`)}):i(`div`,{className:`flex flex-col gap-2`,children:o.map(t=>e(`div`,{className:`flex flex-col gap-1`,children:[e(`p`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:[T(t.condition,a),` · `,t.tiles.length]}),i(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.tiles.map(o=>{let l=`${o.stateId}:${String(o.index)}`,u=s===1;return e(`li`,{className:`flex w-24 flex-col gap-1 rounded-md border border-border p-1`,children:[i(L,{reference:o.reference}),i(`span`,{className:`${A} tabular-nums`,children:R(o.reference.capturedAt)}),e(`button`,{type:`button`,className:F,disabled:n,"aria-label":a(`uiLibrary.sceneReferenceGallery.deleteLabel`,`Delete the {{variant}} photograph from {{date}}`,{variant:T(t.condition,a).toLowerCase(),date:R(o.reference.capturedAt)}),onClick:()=>{(async()=>{u&&!await c({title:a(`uiLibrary.sceneReferenceGallery.deleteTitle`,`Delete the only photograph?`),message:a(`uiLibrary.sceneReferenceGallery.lastWarning`,`This is the only photograph this scene has. Delete it and the scene no longer knows what normal looks like — it stops judging until you capture again.`),confirmLabel:a(`uiLibrary.sceneReferenceGallery.delete`,`Delete`),variant:`danger`})||r({stateId:o.stateId,index:o.index})})()},children:[i(O,{className:`mr-1 inline h-3 w-3`}),a(`uiLibrary.sceneReferenceGallery.delete`,`Delete`)]})]},l)})})]},t.condition))})}function L({reference:t}){let n=x(),[r,a]=o(!1),s=t.thumbnailMediaId;return s===void 0||r?e(`div`,{className:`flex h-16 w-full flex-col items-center justify-center gap-0.5 rounded bg-surface text-foreground-subtle`,title:n(`uiLibrary.sceneReferenceGallery.missingPicture`,`The picture for this reference is no longer stored. The reference itself is intact and still being scored against.`),children:[i(f,{className:`h-4 w-4`}),i(`span`,{className:`text-[9px]`,children:n(`uiLibrary.sceneReferenceGallery.noPicture`,`no picture`)})]}):i(`img`,{src:M(s),alt:``,loading:`lazy`,className:`h-16 w-full rounded object-cover`,onError:()=>a(!0)})}function R(e){let t=new Date(e);return`${t.toLocaleDateString()} ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`}s();var z=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,B=`text-[10px] font-medium text-foreground-subtle`,V=`flex flex-col gap-2 rounded-md border border-border bg-surface/40 p-2`,H=`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,U=5,W=3600;function G(e,t){switch(e){case`periodic`:return t(`uiLibrary.sceneSettingsForm.triggerHintPeriodic`,`Only on the clock. Predictable, and it notices a change even on a camera nothing ever moves in front of.`);case`on-motion`:return t(`uiLibrary.sceneSettingsForm.triggerHintOnMotion`,`Only after the camera has been still again for the quiet window below. Cheapest, but a change nobody walks past is never seen.`);case`both`:return t(`uiLibrary.sceneSettingsForm.triggerHintBoth`,`Both — the clock is the safety net that lets the motion path miss. This is the right answer for almost every scene.`)}}function K(e,t){switch(e){case`skip`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintSkip`,`Sit that light out. No verdict, no alarm, no flag touched — it picks itself back up when a light it knows returns. This is why the night capture is optional.`);case`judge-anyway`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintJudge`,`Compare against the references you do have. Only correct when the two lights genuinely look alike (a floodlit driveway, an indoor lamp) — against a real infrared frame it will report a change that did not happen.`)}}function q(e){return{label:e.label,checkIntervalSec:e.checkIntervalSec??60,threshold:e.check.mode===`similarity`?e.check.threshold:.8,hysteresisCount:e.check.hysteresisCount,quietSeconds:e.quietSeconds,minObservationSpacingSec:e.minObservationSpacingSec,confirmPrompt:e.confirm?.prompt??``}}function re({monitor:t,disabled:n,onPatch:r}){let s=x(),[l,u]=o(()=>q(t)),[d,f]=o(!1);a(()=>{d||u(q(t))},[t,d]);let p=e=>{f(!1),r(e)},h=e=>t.check.mode===`similarity`?{mode:`similarity`,threshold:e.threshold??t.check.threshold,hysteresisCount:e.hysteresisCount??t.check.hysteresisCount}:{...t.check,hysteresisCount:e.hysteresisCount??t.check.hysteresisCount},g=t.confirm?.enabled===!0,_=t.check.mode===`similarity`?t.check.threshold:null;return e(`div`,{className:`flex flex-col gap-2`,children:[e(`div`,{className:V,children:[i(`p`,{className:H,children:s(`uiLibrary.sceneSettingsForm.whatItWatches`,`What it watches`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.name`,`Name`)}),i(`input`,{type:`text`,value:l.label,disabled:n,className:z,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,label:e.target.value})),onBlur:()=>{let e=l.label.trim();e.length>0&&e!==t.label?p({label:e}):f(!1)}})]}),e(`label`,{className:`flex items-center gap-2`,children:[i(m,{checked:t.enabled,disabled:n,onChange:e=>p({enabled:e.target.checked})}),i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.watching`,`Watching`)})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.watchingHint`,`Turned off, the scene keeps its region, its references and its flag — it simply stops checking. Nothing is lost by pausing one for a while.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.whenToLook`,`When to look`)}),e(C,{value:t.triggerMode,disabled:n,className:z,onChange:e=>{let t=e.target.value;(t===`periodic`||t===`on-motion`||t===`both`)&&p({triggerMode:t})},children:[i(`option`,{value:`both`,children:s(`uiLibrary.sceneSettingsForm.triggerBoth`,`On the clock and after motion settles`)}),i(`option`,{value:`periodic`,children:s(`uiLibrary.sceneSettingsForm.triggerPeriodic`,`On the clock only`)}),i(`option`,{value:`on-motion`,children:s(`uiLibrary.sceneSettingsForm.triggerOnMotion`,`After motion settles only`)})]})]}),i(`p`,{className:A,children:G(t.triggerMode,s)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.checkEvery`,`Check every (seconds)`)}),i(`input`,{type:`number`,min:U,max:W,value:l.checkIntervalSec,disabled:n,className:z,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,checkIntervalSec:Number(e.target.value)||0})),onBlur:()=>{let e=J(l.checkIntervalSec,U,W);e===t.checkIntervalSec?f(!1):p({checkIntervalSec:e})}})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.intervalHint`,`60 s suits “is the bin still out”. Every check costs one photograph and one encode, so going below about 30 s buys latency you almost never need and multiplies the cost by the number of scenes you own.`)})]}),e(`div`,{className:V,children:[i(`p`,{className:H,children:s(`uiLibrary.sceneSettingsForm.howSure`,`How sure it has to be`)}),t.check.mode===`similarity`&&e(c,{children:[e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:i(v,{uiKey:`uiLibrary.sceneSettingsForm.matchThreshold`,fallback:`Match threshold — <0>{{value}}</0>`,components:[i(`span`,{className:`tabular-nums`},`value`)],values:{value:l.threshold.toFixed(2)}})}),i(E,{min:.3,max:.99,step:.01,value:l.threshold,disabled:n,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,threshold:Number(e.target.value)})),onMouseUp:()=>{l.threshold===_?f(!1):p({check:h({threshold:l.threshold})})},onBlur:()=>{l.threshold===_?f(!1):p({check:h({threshold:l.threshold})})}})]}),i(`p`,{className:`text-[10px] text-foreground-subtle`,children:s(`uiLibrary.sceneSettingsForm.thresholdHint`,`How closely the region still has to resemble the photograph to count as unchanged. Higher means fussier: at 0.95 a passing cloud can read as a change; at 0.60 the bin can be taken and the scene will shrug. 0.80 is a sensible start — if it cries wolf, lower it; if it misses the thing you care about, raise it.`)})]}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.agreeingChecks`,`Agreeing checks before it changes its mind`)}),i(`input`,{type:`number`,min:1,max:10,value:l.hysteresisCount,disabled:n,className:z,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,hysteresisCount:Number(e.target.value)||1})),onBlur:()=>{let e=J(l.hysteresisCount,1,10);e===t.check.hysteresisCount?f(!1):p({check:h({hysteresisCount:e})})}})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.agreeingHint`,`One bad photograph must never be able to flip a scene. 3 agreeing checks at 60 s is about four minutes of latency and is what makes the answer trustworthy — leaving a state costs exactly the same as entering one.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.quietFor`,`Quiet for (seconds) before a check counts`)}),i(`input`,{type:`number`,min:0,max:3600,value:l.quietSeconds,disabled:n,className:z,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,quietSeconds:Number(e.target.value)||0})),onBlur:()=>{let e=J(l.quietSeconds,0,3600);e===t.quietSeconds?f(!1):p({quietSeconds:e})}})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.quietHint`,`A check taken while something is moving is a photograph of the van parked in front of the bin, so it is discarded rather than merely delayed. 0 disables the gate.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.minGap`,`Minimum gap between counted checks (seconds)`)}),i(`input`,{type:`number`,min:0,max:3600,value:l.minObservationSpacingSec,disabled:n,className:z,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,minObservationSpacingSec:Number(e.target.value)||0})),onBlur:()=>{let e=J(l.minObservationSpacingSec,0,3600);e===t.minObservationSpacingSec?f(!1):p({minObservationSpacingSec:e})}})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.minGapHint`,`Spreads the agreeing checks over real time instead of letting three adjacent polls inside one long occlusion be mistaken for three independent opinions.`)})]}),e(`div`,{className:V,children:[i(`p`,{className:H,children:s(`uiLibrary.sceneSettingsForm.lighting`,`Lighting`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.noReference`,`When a light has no reference of its own`)}),e(C,{value:t.onUncoveredCondition,disabled:n,className:z,onChange:e=>{let t=e.target.value;(t===`skip`||t===`judge-anyway`)&&p({onUncoveredCondition:t})},children:[i(`option`,{value:`skip`,children:s(`uiLibrary.sceneSettingsForm.uncoveredSkip`,`Skip the check (recommended)`)}),i(`option`,{value:`judge-anyway`,children:s(`uiLibrary.sceneSettingsForm.uncoveredJudge`,`Judge against the other light anyway`)})]})]}),i(`p`,{className:A,children:K(t.onUncoveredCondition,s)})]}),e(`div`,{className:V,children:[i(`p`,{className:H,children:s(`uiLibrary.sceneSettingsForm.whatYouGetTold`,`What you get told`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.notificationsFollow`,`Notifications follow`)}),e(C,{value:t.emit,disabled:n,className:z,onChange:e=>{let t=e.target.value;(t===`latched`||t===`live`)&&p({emit:t})},children:[i(`option`,{value:`latched`,children:s(`uiLibrary.sceneSettingsForm.emitLatched`,`The flag — told once, still visible at breakfast`)}),i(`option`,{value:`live`,children:s(`uiLibrary.sceneSettingsForm.emitLive`,`The live state — follows the region as it changes`)})]})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.emitHint`,`“Is the bin gone” is a flag: you want to be told once and still see it later. “Is the gate open” is a live state.`)}),e(`label`,{className:`flex items-center gap-2`,children:[i(m,{checked:t.autoRestore,disabled:n,onChange:e=>p({autoRestore:e.target.checked})}),i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.autoRestore`,`Clear the flag by itself when things look normal again`)})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.autoRestoreHint`,`Off by default, so an alarm never silently clears itself. The “back to normal” moment is recorded either way, so an automation can still react to it.`)})]}),e(`div`,{className:V,children:[i(`p`,{className:H,children:s(`uiLibrary.sceneSettingsForm.aiDoubleCheck`,`AI double-check`)}),e(`label`,{className:`flex items-center gap-2`,children:[i(m,{checked:g,disabled:n||l.confirmPrompt.trim().length===0,onChange:e=>p(e.target.checked?{confirm:{...Y(l.confirmPrompt.trim()),enabled:!0}}:{confirm:null})}),i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.askVision`,`Ask a vision model before changing the answer`)})]}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.question`,`The question to ask`)}),i(`input`,{type:`text`,value:l.confirmPrompt,placeholder:s(`uiLibrary.sceneSettingsForm.questionPlaceholder`,`e.g. Is the wheelie bin still there?`),disabled:n,className:z,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,confirmPrompt:e.target.value})),onBlur:()=>{let e=l.confirmPrompt.trim();e.length>0&&e!==t.confirm?.prompt?p({confirm:{...Y(e),enabled:g}}):f(!1)}})]}),i(`p`,{className:A,children:i(v,{uiKey:`uiLibrary.sceneSettingsForm.confirmHint`,fallback:`The model is asked <0>only</0> when the region has already changed enough to flip the answer — roughly twice a week for a bin, not once a minute. It reasons about the object rather than the pixels, so rain, shadows and a repositioned bin stop counting as the thing being taken. If it cannot be reached, the change is held rather than announced.`,components:[i(`strong`,{},`only`)]})})]})]})}function J(e,t,n){return Math.min(n,Math.max(t,e))}function Y(e){return{enabled:!1,prompt:e,timeoutMs:8e3,maxImagePx:448,onTimeout:`hold`}}s();var X=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,Z=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`,ie=`rounded-md border border-danger/50 bg-danger/10 px-2 py-1 text-[11px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`,ae={alarm:`border-danger/50 bg-danger/15 text-danger`,ok:`border-success/50 bg-success/15 text-success`,unknown:`border-border bg-surface text-foreground-subtle`},oe=.8,se=3;function Q({deviceId:s}){let f=x(),m=p(k().trpcClient,s),g=u(m?.state.sceneMonitor),v=l(s,{width:640}),[y,C]=o(null),[E,j]=o(!1),[M,N]=o(null),[P,F]=o(null),[L,R]=o(null),[z,B]=o(null),[V,H]=o(!1),[U,W]=o(null),[G,K]=o(``),q=t(!0);a(()=>(q.current=!0,()=>{q.current=!1}),[]);let J=r(async()=>{if(m)try{let e=await m.sceneMonitor?.listScenes({});if(!q.current)return;e&&C(e)}catch(e){if(!q.current)return;_(e)?j(!0):F(e instanceof Error?e.message:String(e))}},[m]);a(()=>{C(null),j(!1),F(null),J()},[J]);let Y=g?.monitors??y?.monitors??[],Q=Date.now(),$=r(async(e,t)=>{N(e),F(null);try{await t(),await J()}catch(e){q.current&&F(e instanceof Error?e.message:String(e))}finally{q.current&&N(null)}},[J]),ce=n(()=>{let e=Y.map(e=>({id:e.id,shape:e.roi,label:e.label,enabled:e.enabled}));return U===null?e:[...e,{id:`__draft__`,shape:U,label:f(`uiLibrary.sceneMonitor.newSceneLabel`,`New scene`)}]},[Y,U,f]),le=r((e,t)=>{if(t.kind===`rect`){if(e===`__draft__`){W(t);return}$(`roi-${String(e)}`,async()=>m?.sceneMonitor?.updateScene({monitorId:String(e),patch:{roi:t}}))}},[m,$]),ue=r(e=>{e.kind===`rect`&&W(e)},[]),de=r(async()=>{U===null||G.trim().length===0||(await $(`create`,async()=>{await m?.sceneMonitor?.createScene({label:G.trim(),roi:U,check:{mode:`similarity`,threshold:oe,hysteresisCount:se}})}),W(null),K(``),H(!1))},[m,U,G,$]);return m?i(`div`,{className:`flex flex-col gap-3`,children:E?i(`p`,{className:`${A} leading-relaxed`,children:f(`uiLibrary.sceneMonitor.unsupported`,`Scene monitoring is not available for this camera.`)}):e(c,{children:[i(`p`,{className:`${A} leading-relaxed`,children:f(`uiLibrary.sceneMonitor.intro`,`A scene watches one region of this camera and tells you when it stops looking like the picture you captured. Draw a box around the thing you care about — a wheelie bin, a gate, a parking space — then capture what “normal” looks like. Daylight is enough to start: the night reference is optional, and without it the scene simply sits the infrared hours out instead of reporting a problem.`)}),i(`div`,{className:`relative overflow-hidden rounded-md border border-border`,children:i(ne,{items:ce,supportedShapes:[`rect`],selectedId:L??(U===null?null:`__draft__`),onSelect:e=>R(e===null?null:String(e)),onShapeChange:le,onDrawComplete:ue,drawingKind:V&&U===null?`rect`:null,backdrop:v.src===null?null:i(`img`,{src:v.src,alt:``,className:`h-full w-full object-contain`,draggable:!1})})}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`button`,{type:`button`,className:V?Z:X,"aria-pressed":V,onClick:()=>{H(e=>!e),W(null)},disabled:M!==null,children:V?f(`uiLibrary.sceneMonitor.cancel`,`Cancel`):f(`uiLibrary.sceneMonitor.newScene`,`+ New scene`)}),i(`button`,{type:`button`,className:X,onClick:v.refresh,disabled:M!==null,children:f(`uiLibrary.sceneMonitor.refresh`,`Refresh frame`)})]}),V&&e(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-2`,children:[i(`p`,{className:`text-[10px] text-foreground-subtle`,children:U===null?f(`uiLibrary.sceneMonitor.draftHint`,`Click on the frame to drop a box, then drag its corner to fit it around the thing you want watched.`):f(`uiLibrary.sceneMonitor.nameHint`,`Name it, then create. You capture what “normal” looks like next.`)}),U!==null&&b(U)&&i(`p`,{className:`text-[11px] leading-relaxed text-warning`,children:f(`uiLibrary.sceneMonitor.tooLarge`,`That box covers most of the frame. A scene that big is dominated by the weather, the sky and passing cars — it will quietly stop noticing the thing you actually care about. Draw it tighter.`)}),e(`div`,{className:`flex items-center gap-2`,children:[i(`input`,{type:`text`,value:G,onChange:e=>K(e.target.value),placeholder:f(`uiLibrary.sceneMonitor.placeholder`,`e.g. Immondizia prelevata`),className:`flex-1 rounded-md border border-border bg-surface px-2 py-1 text-[12px] text-foreground`}),i(`button`,{type:`button`,className:Z,onClick:()=>void de(),disabled:U===null||G.trim().length===0||M!==null,children:f(`uiLibrary.sceneMonitor.create`,`Create`)})]})]}),P!==null&&i(`p`,{className:`text-[11px] leading-relaxed text-danger`,children:P}),Y.length===0?i(`p`,{className:`${A} leading-relaxed`,children:f(`uiLibrary.sceneMonitor.empty`,`No scenes on this camera yet.`)}):i(`ul`,{className:`flex flex-col gap-2`,children:Y.map(t=>{let n=ee(t,f);return e(`li`,{className:`flex flex-col gap-1.5 rounded-md border p-2 ${L===t.id?`border-primary/50`:`border-border`}`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{type:`button`,className:`flex-1 text-left text-[12px] font-medium text-foreground`,onClick:()=>R(t.id),children:t.label}),i(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium ${ae[n.tone]}`,children:n.text})]}),i(`p`,{className:`${A} leading-relaxed`,children:S(t,Q,f)}),i(`p`,{className:`${A} tabular-nums`,children:w(t,f)}),i(I,{monitor:t,disabled:M!==null,onDelete:({stateId:e,index:n})=>void $(`refdel-${t.id}-${e}-${String(n)}`,async()=>m.sceneMonitor?.deleteReference({monitorId:t.id,stateId:e,index:n}))}),e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[D.map(n=>{let r=n===`ir`;return e(`button`,{type:`button`,className:X,disabled:M!==null,title:r?f(`uiLibrary.sceneMonitor.optionalTitle`,`Optional. Without a night reference the checks in infrared are simply skipped — the scene keeps working in daylight and nothing is reported as broken.`):f(`uiLibrary.sceneMonitor.captureTitle`,`Take a fresh photo now and store it as the {{variant}} reference`,{variant:T(n,f).toLowerCase()}),onClick:()=>void $(`cap-${t.id}-${n}`,async()=>m.sceneMonitor?.captureReference({monitorId:t.id,condition:n})),children:[i(te,{className:`mr-1 inline h-3 w-3`}),f(`uiLibrary.sceneMonitor.capture`,`Capture {{variant}}`,{variant:T(n,f).toLowerCase()}),r&&i(`span`,{className:`ml-1 text-foreground-subtle/70`,children:f(`uiLibrary.sceneMonitor.optional`,`(optional)`)})]},n)}),e(`button`,{type:`button`,className:Z,disabled:M!==null||t.states.length===0,title:f(`uiLibrary.sceneMonitor.resetTitle`,`Clear the flag and re-photograph what normal looks like right now`),onClick:()=>void $(`reset-${t.id}`,async()=>m.sceneMonitor?.resetScene({monitorId:t.id})),children:[i(d,{className:`mr-1 inline h-3 w-3`}),f(`uiLibrary.sceneMonitor.reset`,`Reset`)]}),i(`button`,{type:`button`,className:X,disabled:M!==null,onClick:()=>void $(`check-${t.id}`,async()=>m.sceneMonitor?.recheckNow({monitorId:t.id})),children:f(`uiLibrary.sceneMonitor.checkNow`,`Check now`)}),e(`button`,{type:`button`,className:z===t.id?Z:X,"aria-pressed":z===t.id,"aria-label":f(`uiLibrary.sceneMonitor.settingsFor`,`Settings for {{label}}`,{label:t.label}),disabled:M!==null,onClick:()=>B(e=>e===t.id?null:t.id),children:[i(h,{className:`mr-1 inline h-3 w-3`}),f(`uiLibrary.sceneMonitor.settings`,`Settings`)]}),i(`button`,{type:`button`,className:ie,disabled:M!==null,onClick:()=>void $(`del-${t.id}`,async()=>m.sceneMonitor?.deleteScene({monitorId:t.id})),children:i(O,{className:`h-3 w-3`})})]}),z===t.id&&i(re,{monitor:t,disabled:M!==null,onPatch:e=>void $(`tune-${t.id}`,async()=>m.sceneMonitor?.updateScene({monitorId:t.id,patch:e}))})]},t.id)})})]})}):null}export{Q as SceneMonitorEditor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,J as t,S as n,V as r,Y as i,et as a}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{t as o}from"./terminal-
|
|
1
|
+
import{C as e,J as t,S as n,V as r,Y as i,et as a}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{t as o}from"./terminal-Dgb4lrgM.js";import{$f as s,Ap as c,Df as l,Of as u,_a as d,ba as f,ct as p,ea as m,jf as h,jp as g,wf as _}from"./src-D9hgltMI.js";import{t as v}from"./useTranslation-BJr-n0es.js";import{_i as y,mi as b,vi as x}from"./index-DPyWa2vo.js";import{t as S}from"./AdminPage-z8USGyNk.js";import{t as C}from"./TerminalPanel-BeJx-I2E.js";a();var w=`terminal-session`,T=`server-shell`,E=120,D=32;function O(){let{t:a}=v(),O=y(),{nodeId:k=``,sessionId:A}=x(),j=g(w),M=c(w),N=k===``?`absent`:M.onNode(k),P=j===`present`&&N===`present`,F=u(),I=_(),L=l({nodeId:k},{enabled:P&&A===void 0}),R=h({nodeId:k},{enabled:P}),[z,B]=i(null),V=t(null),H=t(F.mutateAsync);H.current=F.mutateAsync,r(()=>{if(!P||A!==void 0||R.data?.enabled!==!0||L.data===void 0||V.current===k)return;V.current=k;let e=L.data.find(e=>e.profileId===T);if(e){O(`/system/terminal/${k}/${e.sessionId}`,{replace:!0});return}H.current({nodeId:k,profileId:T,cols:E,rows:D}).then(e=>{O(`/system/terminal/${k}/${e.sessionId}`,{replace:!0})}).catch(e=>{V.current=null,B(e instanceof Error?e.message:String(e))})},[P,A,R.data,L.data,k,O]);let U=a(`terminalPage.serverShell`,`Server shell`),W=n(p,{selectedNodeId:k,onSelect:e=>{V.current=null,B(null),O(`/system/terminal/${e}`)},requiresCapability:w,alwaysShow:!0});if(j===`pending`||N===`pending`)return n(S,{icon:o,title:U,nav:W,children:n(`div`,{"aria-busy":`true`,"aria-label":a(`terminalPage.serverShellLoading`,`Checking which nodes run a terminal`),children:n(f,{className:`h-40 w-full`})})});if(j===`unknown`||N===`unknown`)return n(S,{icon:o,title:U,nav:W,children:n(d,{message:a(`terminalPage.serverShellUnknown`,`The terminal registry did not answer. Try again in a moment.`)})});if(j===`absent`||N===`absent`)return n(S,{icon:o,title:U,nav:W,children:n(m,{icon:o,title:a(`terminalPage.serverShellAbsent`,`Terminal is not installed on this node`)})});let G=R.data?.enabled===!1?R.data.refusal:null;return e(S,{icon:o,title:U,subtitle:a(`terminalPage.serverShellSubtitle`,`A login shell in this node’s data directory. It stays open after you leave, and closes when it sits idle.`),nav:W,actions:n(s,{variant:`outline`,onClick:()=>O(`/system/terminal`),children:a(`terminalPage.backToTerminals`,`Terminals`)}),children:[R.isPending&&n(f,{className:`h-16 w-full`}),G&&n(d,{variant:`warning`,title:a(`terminalPage.serverShellOff`,`Server shell is off`),message:G.message,action:n(b,{className:`text-sm text-primary underline`,to:`/system/terminal`,children:a(`terminalPage.serverShellSettings`,`Turn it on in Terminal settings`)})}),z&&n(d,{message:z}),A&&e(`div`,{className:`flex h-[70vh] min-h-64 flex-col`,children:[n(`div`,{className:`mb-2 flex justify-end`,children:n(s,{size:`sm`,variant:`outline`,disabled:I.isPending,onClick:()=>{I.mutateAsync({nodeId:k,sessionId:A}).then(()=>O(`/system/terminal/${k}`,{replace:!0}))},children:a(`common.close`,`Close`)})}),n(C,{fill:!0,nodeId:k,sessionId:A})]})]})}export{O as ServerShellPage};
|