@camstack/addon-admin-ui 1.1.38 → 1.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AddLocationWizard-6UQCTSu4.js → AddLocationWizard-DH1zgXau.js} +1 -1
- package/dist/assets/AddonCollectionPage-C8P99b0n.js +1 -0
- package/dist/assets/Addons-ql4qAeON.js +1 -0
- package/dist/assets/{AdminTabs-Bn5jDw8C.js → AdminTabs-BFmViSgF.js} +1 -1
- package/dist/assets/{BrokerForm-E7__Uhl9.js → BrokerForm-ClAXJAT9.js} +1 -1
- package/dist/assets/{Capabilities-DWu3W2I3.js → Capabilities-BUUnmipR.js} +1 -1
- package/dist/assets/{CapabilityBadges-D4uPGt_S.js → CapabilityBadges-DJ4Ez0Qj.js} +1 -1
- package/dist/assets/Cluster-_sIDv3Dx.js +1 -0
- package/dist/assets/{Dashboard-DRARX0g8.js → Dashboard-DkWFR-RK.js} +1 -1
- package/dist/assets/Data-B9S8aoV6.js +1 -0
- package/dist/assets/DetectionIntelligence-Db0D7-gq.js +1 -0
- package/dist/assets/DeviceDetail-MyRno8pF.js +2 -0
- package/dist/assets/{Devices-BFoz2HIh.js → Devices-CYdjYNMa.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-BY9eFyyg.js → EmbedPlayerPage-BxhfuZxm.js} +1 -1
- package/dist/assets/{FormBuilder-CJrUV3p4.js → FormBuilder-CzGQp2IN.js} +1 -1
- package/dist/assets/Identity-VBuwkiW_.js +1 -0
- package/dist/assets/IntegrationDetail-Bv6r0j-e.js +1 -0
- package/dist/assets/{Integrations-Bj35Jpxj.js → Integrations-34-SopSE.js} +1 -1
- package/dist/assets/Integrations-VR6uvQtU.js +1 -0
- package/dist/assets/{Logs-B2WAadmI.js → Logs-Bd6dsQiy.js} +1 -1
- package/dist/assets/{MotionZonesSettings-3tt6mBQ0.js → MotionZonesSettings-CblR7zDg.js} +1 -1
- package/dist/assets/MyAccess-D9wXYE6f.js +2 -0
- package/dist/assets/Network-B4UJnXGJ.js +1 -0
- package/dist/assets/{NodeAddonsSettingsPanel-DTzycFzS.js → NodeAddonsSettingsPanel-DTo_3cuU.js} +1 -1
- package/dist/assets/{NotificationTargets-C3VSwqNL.js → NotificationTargets-BgoTGaHZ.js} +1 -1
- package/dist/assets/Pipeline-0vYb0c3Q.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-temQSWYL.js → PrivacyMaskSettings-BvyW7gZf.js} +1 -1
- package/dist/assets/ProviderIcon-CS5qVLX5.js +1 -0
- package/dist/assets/{ScanNetworkModal-C6OLnfky.js → ScanNetworkModal-D8l7vvfO.js} +1 -1
- package/dist/assets/ServerManagement-CU7yGbqi.js +1 -0
- package/dist/assets/{Settings-BmZ2YcWY.js → Settings-afXspnHv.js} +1 -1
- package/dist/assets/{Showroom-CHFvHOSL.js → Showroom-ByFNrd3B.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-xXz7MEuT.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DmurZU5p.js} +1 -1
- package/dist/assets/addon-display-names-DvSEQty-.js +1 -0
- package/dist/assets/{build-cluster-graph-DIgt00ch.js → build-cluster-graph-BPT-sggI.js} +2 -2
- package/dist/assets/circle-check-big-CTwHEGsR.js +1 -0
- package/dist/assets/{copy-CpT57v81.js → copy-Dyvl96ei.js} +1 -1
- package/dist/assets/dist-ClgrIx6c.js +7 -0
- package/dist/assets/{dist-B8dNOlY9.js → dist-Udv3GGFK.js} +1 -1
- package/dist/assets/{download-fsWmKUMh.js → download-BFNY5_CW.js} +1 -1
- package/dist/assets/{hostInit-sp7Rf71V.js → hostInit-CagYACyE.js} +1 -1
- package/dist/assets/index-3DCschCe.js +4 -0
- package/dist/assets/index-BNTiPmxL.css +2 -0
- package/dist/assets/{key-round-0X280kmV.js → key-round-Bi4e5-k8.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-2b967ba8.js → mf-entry-bootstrap-0-b7b22ad0.js} +2 -2
- package/dist/assets/{pencil-BlQGw-pI.js → pencil-DedPunTk.js} +1 -1
- package/dist/assets/{player-overlays-CpsGl45o.js → player-overlays-BrMuuVRR.js} +1 -1
- package/dist/assets/plus-r3Kz9Nsb.js +1 -0
- package/dist/assets/{radio-DO0Dq2MF.js → radio-BM7T2fMm.js} +1 -1
- package/dist/assets/{refresh-cw-CMRlnF-M.js → refresh-cw-CC8OysCP.js} +1 -1
- package/dist/assets/remoteEntry-D9u56wxx.js +1 -0
- package/dist/assets/{rotate-ccw-CaH5zDeG.js → rotate-ccw-hTTLi20Q.js} +1 -1
- package/dist/assets/rotate-cw-BHsfPq8X.js +1 -0
- package/dist/assets/search-GJrj432A.js +1 -0
- package/dist/assets/{sparkles-D1oHkgOm.js → sparkles-DURbj_l0.js} +1 -1
- package/dist/assets/square-DXUXUdD9.js +1 -0
- package/dist/assets/{square-check-big-D7lGfpqc.js → square-check-big-B5WFnMH6.js} +1 -1
- package/dist/assets/src-D5vrhmeM.js +7 -0
- package/dist/assets/src-ojhqTnBF.js +67 -0
- package/dist/assets/{upload-7zSY3rlx.js → upload-DM5RHvd4.js} +1 -1
- package/dist/assets/{useDevice-BwzYPnLK.js → useDevice-BQkNwlm7.js} +1 -1
- package/dist/assets/{useEventInvalidation-CETyyXeZ.js → useEventInvalidation-BBDMvWpm.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DkH43QoX.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BbV1VRd0.js} +2 -2
- package/dist/assets/{wifi-BeF9XXWL.js → wifi-Cr9H7WCZ.js} +1 -1
- package/dist/assets/{zap-abOrEOMQ.js → zap-BWxQNiSd.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/server/addon.js +308 -92
- package/package.json +1 -1
- package/dist/assets/AddonCollectionPage-C7y1Xqv4.js +0 -1
- package/dist/assets/Addons-BMHA1UvX.js +0 -1
- package/dist/assets/Cluster-dHKbt5S3.js +0 -1
- package/dist/assets/Data-Cgi4uVIl.js +0 -1
- package/dist/assets/DetectionIntelligence-B-VvnmfI.js +0 -1
- package/dist/assets/DeviceDetail-DiuVtjgW.js +0 -2
- package/dist/assets/Identity-B0ygozcS.js +0 -1
- package/dist/assets/IntegrationDetail-Brj01VUG.js +0 -1
- package/dist/assets/Integrations-DpfC2qld.js +0 -1
- package/dist/assets/MyAccess-DXmHi-4Y.js +0 -2
- package/dist/assets/Network-CaKLSIvm.js +0 -1
- package/dist/assets/Pipeline-Cp7B8YFG.js +0 -1
- package/dist/assets/ProviderIcon-DwFpv01K.js +0 -1
- package/dist/assets/circle-check-big-wzEehng2.js +0 -1
- package/dist/assets/dist-DRenWL4F.js +0 -7
- package/dist/assets/index-CY52lvbZ.js +0 -4
- package/dist/assets/index-_8k1nh07.css +0 -2
- package/dist/assets/plus-DSiRMRVx.js +0 -1
- package/dist/assets/remoteEntry-BTav0B7H.js +0 -1
- package/dist/assets/rotate-cw-CCcZjC0U.js +0 -1
- package/dist/assets/search-CN_ccU_h.js +0 -1
- package/dist/assets/server-CaW_paWO.js +0 -1
- package/dist/assets/square-DWukmPnU.js +0 -1
- package/dist/assets/src-BXL7z3gT.js +0 -7
- package/dist/assets/src-BZ1dd5LI.js +0 -67
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,W as i,b as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{L as l,V as u,c as ee,g as d,n as f,p,s as m}from"./player-overlays-
|
|
1
|
+
import{I as e,K as t,Q as n,S as r,W as i,b as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{L as l,V as u,c as ee,g as d,n as f,p,s as m}from"./player-overlays-BrMuuVRR.js";import{MaskShapeCanvas as h}from"./MaskShapeCanvas-pGn6MKOi.js";var te=d(`grid-2x2`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]);n();var ne=110,g=`motion-zones`,_=0,re=[1,2,3],v=1,y=`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`,b=`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 x(e,t,n){let r=t*n,i=Array.from({length:r});for(let t=0;t<r;t+=1)i[t]=e[t]===!0;return i}function S(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function C(e,t){return Math.ceil(e/t)}function w(e,t,n){return Math.min(n-1,Math.floor((e+.5)/t*n))}function T(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array.from({length:i*a},()=>!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)e[r*t+n]===!0&&(o[s*i+w(n,t,i)]=!0)}return o}function E(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array.from({length:t*n},()=>!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)o[r*t+n]=e[s*i+w(n,t,i)]===!0}return o}function D({deviceId:n}){let d=ee(p().trpcClient,n),[w,D]=o(null),[O,k]=o(!1),[A,j]=o(null),[M,N]=o(null),[P,F]=o(v),[I,L]=o(!1),[R,z]=o(!1),B=t(!1);c(()=>{if(!d)return;let e=!1;return B.current=!1,D(null),k(!1),j(null),N(null),F(v),z(!1),(async()=>{try{let t=await d.motionZones?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(D(t),B.current)return;let n=await d.motionZones?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);B.current=!0;let r=n.regions.find(e=>e.shape.kind===`grid`),i=x(r?r.shape.cells:[],t.grid.width,t.grid.height);N(i),j(T(i,t.grid.width,t.grid.height,v))}catch(t){if(e)return;u(t)?k(!0):console.error(`Motion Zones load failed`,t)}})(),()=>{e=!0}},[d]);let V=w?w.grid.width:0,H=w?w.grid.height:0,U=C(V,P),W=C(H,P),G=i(()=>A&&w?E(A,V,H,P):null,[A,w,V,H,P]),K=i(()=>G!==null&&M!==null&&!S(G,M),[G,M]),q=i(()=>G?G.reduce((e,t)=>t?e+1:e,0):0,[G]),J=V*H,Y=U*W,X=e(e=>{Y>0&&j(Array.from({length:Y},()=>e))},[Y]),Z=e(()=>{j(e=>e&&e.map(e=>!e))},[]),ie=e(()=>{M&&w&&j(T(M,V,H,P))},[M,w,V,H,P]),ae=e(e=>{e===P||!w||j(t=>{if(!t)return F(e),t;let n=T(E(t,V,H,P),V,H,e);return F(e),n})},[P,w,V,H]),Q=i(()=>w&&A?[{id:_,shape:{kind:`grid`,gridWidth:U,gridHeight:W,cells:[...A]}}]:[],[w,A,U,W]),$=e((e,t)=>{t.kind===`grid`&&j(t.cells)},[]),oe=e(async()=>{if(!(!d||!A||!w)){L(!0);try{let e=E(A,w.grid.width,w.grid.height,P),t={kind:`grid`,gridWidth:w.grid.width,gridHeight:w.grid.height,cells:e};await d.motionZones?.setZone({patch:{regions:[{id:_,enabled:!0,shape:t}]}});let n=await d.motionZones?.getStatus({});if(n){let e=n.regions.find(e=>e.shape.kind===`grid`),t=x(e?e.shape.cells:[],w.grid.width,w.grid.height);N(t),j(T(t,w.grid.width,w.grid.height,P))}}catch(e){console.error(`Motion Zones save failed`,e)}finally{L(!1)}}},[d,A,w,P]);return f(i(()=>R&&!O&&w&&A?{id:g,order:ne,node:s(h,{transparent:!0,items:Q,supportedShapes:[`grid`],grid:{width:U,height:W},selectedId:_,onSelect:()=>{},onShapeChange:$,onDrawComplete:()=>{},drawingKind:null})}:null,[R,O,w,A,Q,$,U,W])),d?s(m,{title:`Motion Zones`,icon:s(te,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:s(`div`,{className:`flex flex-col gap-3`,children:O?s(`p`,{className:`${l} leading-relaxed`,children:`This camera doesn't expose an on-board motion zones grid.`}):!O&&w!==null&&A!==null?r(a,{children:[r(`p`,{className:`${l} leading-relaxed`,children:[`Toggle `,s(`strong`,{className:`text-foreground`,children:`Edit grid`}),` to paint the region directly on the live frame, then `,s(`strong`,{className:`text-foreground`,children:`Save`}),` to push the mask to the camera. Pick a bigger`,` `,s(`strong`,{className:`text-foreground`,children:`Cell size`}),` for quicker, broad-stroke painting — it's resampled to the camera's native `,w.grid.width,`×`,w.grid.height,` grid on save (×1 is the finest).`]}),r(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[s(`button`,{type:`button`,onClick:()=>z(e=>!e),disabled:I,"aria-pressed":R,className:R?b:y,children:R?`Done editing`:`Edit grid`}),s(`button`,{type:`button`,onClick:()=>X(!0),disabled:I,className:y,children:`All on`}),s(`button`,{type:`button`,onClick:()=>X(!1),disabled:I,className:y,children:`All off`}),s(`button`,{type:`button`,onClick:Z,disabled:I,className:y,children:`Invert`}),r(`div`,{className:`flex items-center gap-1 ml-1`,role:`group`,"aria-label":`Cell size`,children:[s(`span`,{className:`${l} mr-0.5`,children:`Cell size`}),re.map(e=>r(`button`,{type:`button`,onClick:()=>ae(e),disabled:I,"aria-pressed":P===e,title:e===1?`Camera grid ${V}×${H} (finest)`:`${C(V,e)}×${C(H,e)} painting grid · cells ×${e} bigger`,className:P===e?b:y,children:[`×`,e]},e))]}),r(`span`,{className:`${l} ml-1 tabular-nums`,children:[q,` / `,J,` cells · `,w.grid.width,`×`,w.grid.height,P===1?``:` · paint ${U}×${W}`]}),s(`span`,{className:`flex-1`}),s(`button`,{type:`button`,onClick:ie,disabled:I||!K,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:`Revert`}),s(`button`,{type:`button`,onClick:()=>void oe(),disabled:I||!K,className:b,children:I?`Saving…`:`Save`})]})]}):s(`p`,{className:`${l} leading-relaxed`,children:`Loading the camera's grid…`})})}):null}export{D as MotionZonesSettings};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browser-BHo8W_uH.js","assets/rolldown-runtime-Cyuzqnbw.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{t}from"./vite-preload-helper-zJ_50EbN.js";import{M as n,T as r}from"./src-ojhqTnBF.js";import{Q as i,S as a,W as o,a as s,b as c,q as l,t as u,x as d,z as f}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{p}from"./player-overlays-BrMuuVRR.js";import{t as m}from"./circle-check-big-CTwHEGsR.js";import{t as h}from"./copy-Dyvl96ei.js";import{t as g}from"./key-round-Bi4e5-k8.js";import{t as _}from"./pencil-DedPunTk.js";import{E as v,M as y,S as b,b as x,l as S,r as C,s as w,w as T,x as E}from"./index-3DCschCe.js";import{t as D}from"./AdminPage-BwmGKnRf.js";i();function O({value:n,size:r=192}){let[i,o]=l(null),[s,c]=l(null);if(f(()=>{let r=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(r)return;let t=e.create;if(typeof t!=`function`){c(`qrcode.create() unavailable in installed version`);return}try{let e=t(n,{errorCorrectionLevel:`M`});r||o(e)}catch(e){r||c(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1])).catch(()=>{r||c(`qrcode library not installed`)}),()=>{r=!0}},[n]),s)return d(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:r,height:r},children:`QR rendering unavailable — use the secret below.`});if(!i)return d(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:r,height:r},children:`Generating…`});let u=i.modules.size,p=r/u,m=[];for(let e=0;e<u;e++)for(let t=0;t<u;t++)i.modules.data[e*u+t]&&m.push(d(`rect`,{x:t*p,y:e*p,width:p,height:p,fill:`currentColor`},`${t}-${e}`));return a(`svg`,{width:r,height:r,viewBox:`0 0 ${r} ${r}`,className:`text-black`,children:[d(`rect`,{x:0,y:0,width:r,height:r,fill:`white`}),m]})}i();var k={view:{icon:v,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:_,cls:`bg-primary/15 text-primary`},delete:{icon:w,cls:`bg-danger/15 text-danger`}};function A(){let{user:e,logout:t}=C();if(!e)return d(D,{children:d(`div`,{className:`text-xs text-foreground-subtle`,children:`Not signed in.`})});let n=e.isAdmin,r=e.scopes??[];return a(D,{children:[a(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[d(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:e.username.slice(0,1).toUpperCase()}),a(`div`,{className:`flex-1 min-w-0`,children:[d(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),a(`div`,{className:`text-[11px] text-foreground-subtle`,children:[n?`Administrator`:`User`,` · session id`,` `,a(`span`,{className:`font-mono`,children:[e.id.slice(0,8),`…`]})]})]})]}),n&&a(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5`,children:[d(T,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),a(`div`,{children:[d(`div`,{className:`font-semibold text-foreground`,children:`Unrestricted access`}),d(`p`,{className:`text-foreground-subtle mt-0.5`,children:`Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below.`})]})]}),d(j,{}),d(N,{username:e.username}),d(P,{}),r.length>0&&a(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[a(`div`,{className:`px-4 py-2 border-b border-border`,children:[d(`div`,{className:`text-xs font-semibold text-foreground`,children:`Granted scopes`}),d(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Baked into your session token at login; sign out + back in to refresh after changes.`})]}),a(`div`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[d(`div`,{children:`Type`}),d(`div`,{children:`Target`}),d(`div`,{children:`Access`})]}),d(`ul`,{className:`divide-y divide-border`,children:r.map((e,t)=>a(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[d(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),d(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?e.targets.join(`, `):e.target}),d(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(t=>{let n=e.access.includes(t),{icon:r,cls:i}=k[t];return a(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${n?i:`bg-transparent text-foreground-subtle/40 line-through`}`,title:n?`Can ${t}`:`Cannot ${t}`,children:[d(r,{className:`h-3 w-3`}),t]},t)})})]},t))})]}),d(`div`,{className:`flex justify-end`,children:a(`button`,{onClick:t,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground transition-colors`,children:[d(x,{className:`h-3 w-3`}),`Sign out`]})})]})}function j(){let e=p(),[t,n]=l(``),[r,i]=l(``),[o,s]=l(``),[c,f]=l(null),h=u({mutationFn:t=>e.changeOwnPassword(t),onSuccess:()=>{f({kind:`success`,msg:`Password updated.`}),n(``),i(``),s(``)},onError:e=>{f({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),_=r.length>0&&o.length>0&&r!==o,v=r.length>0&&r.length<8,x=t.length>=1&&r.length>=8&&r===o;return a(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[a(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(g,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:`Change password`})]}),a(`div`,{className:`p-4 space-y-3`,children:[d(M,{label:`Current password`,value:t,onChange:n,autoComplete:`current-password`}),d(M,{label:`New password`,value:r,onChange:i,autoComplete:`new-password`,hint:`At least 8 characters.`}),d(M,{label:`Confirm new password`,value:o,onChange:s,autoComplete:`new-password`}),(_||v)&&d(`div`,{className:`text-[11px] text-danger`,children:_?`Passwords do not match.`:`New password must be at least 8 characters.`}),c&&a(`div`,{className:`text-[11px] flex items-center gap-1 ${c.kind===`success`?`text-emerald-500`:`text-danger`}`,children:[c.kind===`success`?d(m,{className:`h-3 w-3`}):d(y,{className:`h-3 w-3`}),c.msg]}),d(`div`,{className:`flex justify-end`,children:a(`button`,{onClick:()=>{f(null),h.mutate({currentPassword:t,newPassword:r})},disabled:!x||h.isPending,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[h.isPending?d(b,{className:`h-3 w-3 animate-spin`}):d(E,{className:`h-3 w-3`}),`Update password`]})})]})]})}function M({label:e,value:t,onChange:n,autoComplete:r,hint:i}){return a(`div`,{className:`space-y-1`,children:[d(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),d(`input`,{type:`password`,value:t,onChange:e=>n(e.target.value),autoComplete:r,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),i&&d(`div`,{className:`text-[10px] text-foreground-subtle`,children:i})]})}function N({username:e}){let t=p(),n=s({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>t.getOwnTotpStatus()}),r=n.data,[i,g]=l(null),[_,v]=l(``),[x,C]=l(null),[w,T]=l(!1),E=u({mutationFn:()=>t.setupOwnTotp(),onSuccess:e=>{g({secret:e.secret,otpauthUrl:e.otpauthUrl}),v(``),C(null)},onError:e=>C(e instanceof Error?e.message:`Setup failed`)}),D=u({mutationFn:e=>t.confirmOwnTotp(e),onSuccess:()=>{g(null),v(``),C(null),n.refetch()},onError:e=>C(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),k=u({mutationFn:()=>t.disableOwnTotp(),onSuccess:()=>{C(null),n.refetch()},onError:e=>C(e instanceof Error?e.message:`Disable failed`)});f(()=>{if(!w)return;let e=setTimeout(()=>T(!1),1500);return()=>clearTimeout(e)},[w]);let A=o(()=>n.isLoading?`loading`:i?`setup_in_progress`:r?.enabled?`enrolled`:`not_enrolled`,[n.isLoading,r?.enabled,i]);return a(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[a(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(S,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:`Two-factor authentication`})]}),a(`div`,{className:`p-4 space-y-3`,children:[A===`loading`&&a(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[d(b,{className:`h-3.5 w-3.5 animate-spin`}),`Checking status…`]}),A===`not_enrolled`&&a(c,{children:[d(`div`,{className:`text-xs text-foreground-subtle`,children:`2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login.`}),d(`div`,{className:`flex justify-end`,children:a(`button`,{onClick:()=>{C(null),E.mutate()},disabled:E.isPending,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[E.isPending?d(b,{className:`h-3 w-3 animate-spin`}):d(S,{className:`h-3 w-3`}),`Enable 2FA`]})})]}),A===`setup_in_progress`&&i&&a(c,{children:[a(`div`,{className:`text-[11px] text-foreground-subtle`,children:[`Scan the QR code (or enter the secret manually) into your authenticator app for`,` `,d(`span`,{className:`font-mono`,children:e}),`, then enter the 6-digit code below to confirm.`]}),a(`div`,{className:`flex flex-col items-center gap-3`,children:[d(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:d(O,{value:i.otpauthUrl,size:180})}),a(`div`,{className:`w-full`,children:[d(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:`Secret (manual entry)`}),a(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[d(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:i.secret}),a(`button`,{onClick:()=>{i&&navigator.clipboard.writeText(i.secret).then(()=>T(!0))},className:`inline-flex items-center gap-1 text-[10px] text-foreground-subtle hover:text-foreground`,children:[w?d(m,{className:`h-3 w-3 text-emerald-500`}):d(h,{className:`h-3 w-3`}),w?`Copied`:`Copy`]})]})]})]}),a(`div`,{className:`space-y-1`,children:[d(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),d(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:_,onChange:e=>v(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary`})]}),x&&a(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[d(y,{className:`h-3 w-3`}),x]}),a(`div`,{className:`flex justify-end gap-2`,children:[d(`button`,{onClick:()=>{g(null),C(null),v(``)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),a(`button`,{onClick:()=>{C(null),D.mutate({code:_})},disabled:D.isPending||_.length!==6,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[D.isPending?d(b,{className:`h-3 w-3 animate-spin`}):d(m,{className:`h-3 w-3`}),`Confirm`]})]})]}),A===`enrolled`&&r&&a(c,{children:[a(`div`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2.5 flex items-start gap-2.5`,children:[d(m,{className:`h-4 w-4 mt-0.5 text-emerald-500 shrink-0`}),a(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[d(`div`,{className:`font-medium`,children:`2FA is active`}),a(`div`,{className:`text-foreground-subtle`,children:[`Enrolled on`,` `,r.confirmedAt?new Date(r.confirmedAt).toLocaleString():`—`]})]})]}),x&&a(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[d(y,{className:`h-3 w-3`}),x]}),d(`div`,{className:`flex justify-end`,children:a(`button`,{onClick:()=>{C(null),k.mutate()},disabled:k.isPending,className:`rounded bg-danger px-3 py-1.5 text-xs font-medium text-white hover:bg-danger/90 disabled:opacity-50 inline-flex items-center gap-1`,children:[k.isPending?d(b,{className:`h-3 w-3 animate-spin`}):d(S,{className:`h-3 w-3`}),`Disable 2FA`]})})]})]})]})}function P(){return n(`auth-webauthn/passkey-enrollment`)?d(r,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}export{A as MyAccessPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Cr as e,Dr as t,Er as n,Fi as r,Ma as i,Na as a,Or as o,Sr as s,_r as c,_t as l,br as u,gr as d,hr as f,ja as p,ma as m,mr as h,ta as g,vr as _,vt as v,xr as y,yr as b}from"./src-ojhqTnBF.js";import{I as x,Q as S,S as C,W as w,b as T,o as E,q as D,x as O,z as ee}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{o as k,s as A}from"./src-D5vrhmeM.js";import{p as j}from"./player-overlays-BrMuuVRR.js";import{n as M,t as te}from"./rotate-ccw-hTTLi20Q.js";import{t as N}from"./copy-Dyvl96ei.js";import{n as ne,t as P}from"./AddonCollectionPage-C8P99b0n.js";import{t as re}from"./refresh-cw-CC8OysCP.js";import{t as ie}from"./sparkles-DURbj_l0.js";import{t as ae}from"./square-DXUXUdD9.js";import{t as oe}from"./wifi-Cr9H7WCZ.js";import{H as F,I as se,O as I,S as L,T as R,b as ce,i as le,o as z,p as B,v as V,x as ue}from"./index-3DCschCe.js";import{t as de}from"./AdminPage-BwmGKnRf.js";import{t as H}from"./AdminTabs-BFmViSgF.js";import{t as U}from"./addon-display-names-DvSEQty-.js";var fe=F(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),pe=F(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),W=F(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]);S();var G=5e3,me={connected:!1,endpoint:null};function he(){let e=E(),n=v({capName:`network-access`},{refetchInterval:G}),r=l(void 0,{refetchInterval:G}),i=w(()=>U(r.data??[]),[r.data]),a=w(()=>(n.data??[]).map(e=>({addonId:e.addonId,displayName:i.get(e.addonId)??e.addonId,isActive:e.isActive})),[n.data,i]),[s,c]=D(null),[u,d]=D({}),f=(t,n)=>{let r=n?.addonId;e.invalidateQueries({queryKey:[[`networkAccess`,`getStatus`],{input:{addonId:r},type:`query`}]}),c(null),d(e=>{if(r===void 0||!(r in e))return e;let t={...e};return delete t[r],t})},p=(e,t)=>{c(null);let n=t?.addonId;if(n===void 0)return;let r=e instanceof Error?e.message:String(e);d(e=>({...e,[n]:r}))},m=t({onSuccess:f,onError:p}),h=o({onSuccess:f,onError:p});return O(P,{title:`Remote Access`,subtitle:`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …). Settings, Logs and Events are docked under every provider.`,pageIcon:R,itemIcon:R,capability:`network-access`,installButtonLabel:`Add tunnel`,items:a,isLoading:n.isLoading,emptyTitle:`No remote-access providers installed`,emptyDescription:`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`,renderStatusBadges:e=>O(ge,{addonId:e.addonId}),itemError:e=>u[e.addonId]??null,renderPrimaryAction:e=>O(_e,{addonId:e.addonId,busyId:s,onStart:e=>{c(e),m.mutate({addonId:e})},onStop:e=>{c(e),h.mutate({addonId:e})}})})}function K(e){let{data:t}=n({addonId:e},{refetchInterval:G,retry:!1}),r=t?A.safeParse(t):null;return r?.success?r.data:me}function ge({addonId:e}){let t=K(e);return C(T,{children:[O(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.connected?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:`bg-foreground-subtle/15 text-foreground-subtle`}`,children:t.connected?`Connected`:`Disconnected`}),t.endpoint&&C(`a`,{href:t.endpoint.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`text-[10px] text-emerald-700 dark:text-emerald-300 hover:underline flex items-center gap-1`,children:[O(I,{className:`h-3 w-3`}),t.endpoint.url]})]})}function _e({addonId:e,busyId:t,onStart:n,onStop:r}){let i=K(e),o=t===e;return i.connected?C(a,{size:`sm`,variant:`secondary`,disabled:o,onClick:()=>r(e),children:[o?O(L,{className:`h-3 w-3 animate-spin`}):O(ae,{className:`h-3 w-3`}),`Stop`]}):C(a,{size:`sm`,variant:`primary`,disabled:o,onClick:()=>n(e),children:[o?O(L,{className:`h-3 w-3 animate-spin`}):O(ne,{className:`h-3 w-3`}),`Start`]})}S();var q=3e4;function ve(e){let t=[];for(let n of e)typeof n.urls==`string`?t.push(n.urls):t.push(...n.urls);return t}function ye(){let e=v({capName:`turn-provider`},{refetchInterval:q}),t=l(void 0,{refetchInterval:q}),n=r(),i=n.data??[],o=w(()=>U(t.data??[]),[t.data]);return O(P,{title:`TURN Servers`,subtitle:`ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.`,pageIcon:V,itemIcon:V,capability:`turn-provider`,installButtonLabel:`Add provider`,items:w(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:o.get(e.addonId)??e.addonId,isActive:e.isActive})),[e.data,o]),isLoading:e.isLoading,emptyTitle:`No TURN providers installed`,emptyDescription:`Install a TURN addon (e.g. @camstack/addon-cloudflare) to enable WebRTC behind restrictive NATs.`,renderExpandedPanel:e=>O(be,{addonId:e.addonId,enabled:e.isActive}),trailing:C(p,{children:[C(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between`,children:[C(`div`,{children:[O(`div`,{className:`text-sm font-semibold`,children:`Combined ICE server list`}),O(`div`,{className:`text-xs text-foreground-subtle`,children:`What the WebRTC layer fetches per-session.`})]}),O(a,{size:`sm`,variant:`secondary`,onClick:()=>n.refetch(),disabled:n.isFetching,children:`Refresh`})]}),O(`div`,{className:`p-4`,children:i.length===0?O(`div`,{className:`text-xs text-foreground-subtle`,children:`No servers from enabled providers.`}):O(`div`,{className:`flex flex-col gap-3`,children:i.map((e,t)=>{let n=Array.isArray(e.urls)?e.urls:[e.urls];return C(`div`,{className:`rounded border border-border bg-surface`,children:[(e.username||e.credential)&&C(`div`,{className:`px-3 py-1.5 border-b border-border text-[10px] font-mono text-foreground-subtle flex items-center gap-3`,children:[e.username&&C(`span`,{children:[O(`span`,{className:`text-foreground-subtle`,children:`user:`}),` `,O(`span`,{className:`text-foreground`,children:e.username})]}),e.credential&&C(`span`,{children:[O(`span`,{className:`text-foreground-subtle`,children:`credential:`}),` `,O(`span`,{className:`text-foreground`,children:`••••••••`})]})]}),O(`ul`,{className:`divide-y divide-border`,children:n.map(e=>O(`li`,{className:`px-3 py-1.5 font-mono text-xs text-foreground break-all`,children:e},e))})]},t)})})})]})})}function be({addonId:e,enabled:t}){let n=r({addonId:e},{enabled:t,retry:!1}),i=w(()=>ve(n.data??[]),[n.data]);return!t||i.length===0?null:C(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[C(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Discovered ICE servers (`,i.length,`)`]}),O(`div`,{className:`flex flex-wrap gap-1`,children:i.map(e=>O(`span`,{className:`inline-block rounded px-1.5 py-0.5 text-[10px] font-mono bg-foreground-subtle/10 text-foreground`,children:e},e))})]})}S();var xe={lan:V,wifi:oe,docker:M,vpn:ue,loopback:B,other:B},Se={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},Ce=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function we(e){let{interfaces:t,disabled:n,hideLoopback:r,ipv4Only:i,emptyMessage:a}=e,o=w(()=>t.filter(e=>!(r&&e.kind===`loopback`||i&&e.family!==`IPv4`)),[t,r,i]),s=w(()=>{let e=new Map;for(let t of o){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return Ce.filter(t=>e.has(t)).map(t=>({kind:t,items:e.get(t)}))},[o]),c=t=>e.mode===`single`?e.value===t:e.value.includes(t),l=t=>{if(n||t.kind===`loopback`)return;if(e.mode===`single`){e.onChange(e.value===t.address?null:t.address);return}let r=new Set(e.value);r.has(t.address)?r.delete(t.address):r.add(t.address),e.onChange([...r])};return o.length===0?O(`div`,{className:`text-xs text-foreground-subtle italic`,children:a??`No addresses available.`}):O(`div`,{className:`flex flex-col gap-3`,children:s.map(({kind:t,items:r})=>C(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[C(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[O(xe[t]??B,{className:`h-3.5 w-3.5 text-foreground-subtle`}),O(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:Se[t]??t}),C(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,r.length]})]}),O(`ul`,{className:`divide-y divide-border`,children:r.map(t=>{let r=c(t.address),i=t.kind===`loopback`,a=!t.plausible&&!i;return C(`li`,{className:`flex items-center gap-3 px-3 py-2 ${i?`opacity-60 cursor-not-allowed`:n?`opacity-60`:a?`cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]`:`cursor-pointer hover:bg-surface-hover/30`}`,onClick:()=>l(t),children:[O(`span`,{className:`flex items-center justify-center h-4 w-4 rounded ${e.mode===`single`?`rounded-full`:`rounded`} border ${r?`border-primary bg-primary text-primary-foreground`:`border-border bg-surface`}`,children:r&&O(se,{className:`h-3 w-3`})}),C(`div`,{className:`flex-1 min-w-0 ${a?`text-foreground-subtle`:``}`,children:[C(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[O(`span`,{className:`font-mono text-xs font-semibold ${a?`text-foreground-subtle`:`text-foreground`}`,children:t.name}),O(`span`,{className:`text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-mono`,children:t.family}),t.preferred&&O(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:`Auto-preferred`}),i&&O(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:`Always included`}),a&&C(`span`,{className:`inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300`,title:t.plausibleReason||void 0,children:[O(z,{className:`h-2.5 w-2.5`}),`Unlikely usable`]})]}),C(`div`,{className:`text-xs text-foreground-subtle mt-0.5 font-mono break-all`,children:[t.address,t.cidr&&t.cidr!==t.address?` (${t.cidr})`:``]})]})]},`${t.name}-${t.family}-${t.address}`)})})]},t))})}S();var J={"lan-ipv4":`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`,"lan-ipv6":`bg-violet-500/15 text-violet-700 dark:text-violet-300`,public:`bg-blue-500/15 text-blue-700 dark:text-blue-300`,loopback:`bg-foreground-subtle/15 text-foreground-subtle`};function Te(){let e=E(),t=j(),n=d(void 0,{refetchInterval:3e4}),r=h(void 0),i=_({onSuccess:()=>{e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),o=c({onSuccess:t=>{m(t.addresses),e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),s=w(()=>n.data?.interfaces??[],[n.data]),l=f({port:typeof window<`u`?Number(window.location.port)||(window.location.protocol===`https:`?443:80):4e3,scheme:typeof window<`u`&&window.location.protocol===`https:`?`https`:`http`},{refetchInterval:3e4}),[u,m]=D([]),[g,v]=D(!1);ee(()=>{!g&&r.data&&(m(r.data.addresses),v(!0))},[r.data,g]);let y=r.data?.addresses??[],b=w(()=>{if(u.length!==y.length)return!0;let e=[...u].toSorted(),t=[...y].toSorted();return e.some((e,n)=>e!==t[n])},[u,y]),x=()=>{i.mutate({addresses:[...u]})},S=()=>{m(y)},T=()=>{m([])},k=()=>{n.refetch(),l.refetch(),r.refetch()},A=async()=>{try{let e=await t.raceConnectionEndpoints({perCandidateTimeoutMs:1500});console.info(`[network-addresses] race result`,e)}catch(e){console.warn(`[network-addresses] race failed`,e)}},M=l.data?.endpoints??[];return C(de,{children:[C(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[O(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:`Pick the local addresses SDK clients should race for the fastest path to this hub. Empty selection (auto) lets every non-loopback / non-link-local interface participate.`}),C(`div`,{className:`flex items-center gap-2 shrink-0`,children:[C(a,{size:`sm`,variant:`secondary`,onClick:k,disabled:n.isLoading,children:[O(re,{className:`h-3 w-3 ${n.isLoading?`animate-spin`:``}`}),`Refresh`]}),O(a,{size:`sm`,variant:`secondary`,onClick:A,children:`Probe race`})]})]}),C(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[C(p,{children:[C(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between`,children:[C(`div`,{children:[O(`div`,{className:`text-sm font-semibold`,children:`Allowed addresses`}),O(`div`,{className:`text-xs text-foreground-subtle`,children:u.length===0?`Auto — every non-loopback / non-link-local interface participates.`:`${u.length} pinned`})]}),C(`div`,{className:`flex items-center gap-1`,children:[C(a,{size:`sm`,variant:`secondary`,onClick:()=>o.mutate(void 0),disabled:o.isPending||i.isPending,title:`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`,children:[O(ie,{className:`h-3 w-3`}),o.isPending?`Detecting…`:`Best match`]}),C(a,{size:`sm`,variant:`secondary`,onClick:T,disabled:u.length===0||i.isPending,children:[O(te,{className:`h-3 w-3`}),`Clear`]}),b&&O(a,{size:`sm`,variant:`secondary`,onClick:S,disabled:i.isPending,children:`Discard`}),C(a,{size:`sm`,variant:`primary`,onClick:x,disabled:!b||i.isPending,children:[O(pe,{className:`h-3 w-3`}),i.isPending?`Saving…`:`Save`]})]})]}),O(`div`,{className:`p-4`,children:O(we,{mode:`multiple`,interfaces:s,value:u,onChange:m,disabled:i.isPending,emptyMessage:n.isLoading?`Loading interfaces…`:`No interfaces detected.`})})]}),C(p,{children:[C(`div`,{className:`px-4 py-3 border-b border-border`,children:[O(`div`,{className:`text-sm font-semibold`,children:`Connection endpoints — priority order`}),O(`div`,{className:`text-xs text-foreground-subtle`,children:`Live preview of the ranked candidate list the SDK would race against. Updates with each Save.`})]}),O(`div`,{className:`p-4`,children:M.length===0?O(`div`,{className:`text-xs text-foreground-subtle italic`,children:l.isLoading?`Loading…`:`No endpoints available.`}):O(`ul`,{className:`space-y-1 text-xs`,children:M.map(e=>C(`li`,{className:`flex items-center gap-2 flex-wrap ${e.plausible?``:`opacity-80`}`,children:[O(`span`,{className:`font-mono text-[10px] w-10 text-foreground-subtle`,children:String(e.priority).padStart(4,`0`)}),O(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${J[e.kind]??J.loopback}`,children:e.kind}),e.interfaceKind!==`lan`&&e.interfaceKind!==`public`&&O(`span`,{className:`text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-medium uppercase`,children:e.interfaceKind}),!e.plausible&&e.interfaceKind!==`loopback`&&C(`span`,{className:`inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300`,title:e.plausibleReason||void 0,children:[O(z,{className:`h-2.5 w-2.5`}),`Unlikely usable`]}),O(`span`,{className:`font-mono break-all ${e.plausible?`text-foreground`:`text-foreground-subtle`}`,children:e.baseUrl}),C(`span`,{className:`text-foreground-subtle`,children:[`— `,e.label]})]},`${e.priority}-${e.baseUrl}`))})})]})]})]})}S();var Ee={mesh:`bg-violet-500/15 text-violet-700 dark:text-violet-300`,public:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},Y=5e3,De=3e4,Oe={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function ke(){let e=v({capName:`mesh-network`},{refetchInterval:Y}),t=l(void 0,{refetchInterval:Y}),n=w(()=>U(t.data??[]),[t.data]);return O(P,{title:`Mesh Networks`,subtitle:`Private VPN meshes that connect CamStack to your other devices (Tailscale, Headscale, …). Each provider can also expose this hub publicly via its ingress (Tailscale Funnel).`,pageIcon:M,itemIcon:V,capability:`mesh-network`,installButtonLabel:`Add mesh`,items:w(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:n.get(e.addonId)??e.addonId,isActive:e.isActive})),[e.data,n]),isLoading:e.isLoading,emptyTitle:`No mesh-network providers installed`,emptyDescription:`Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.`,renderStatusBadges:e=>O(Ae,{addonId:e.addonId}),renderPrimaryAction:e=>O(je,{addonId:e.addonId}),renderExpandedPanel:e=>O(Z,{addonId:e.addonId})})}function X(e){let{data:t,isLoading:n}=b({addonId:e},{refetchInterval:Y,retry:!1}),r=t?k.safeParse(t):null;return{status:r?.success?r.data:Oe,isLoading:n}}function Ae({addonId:e}){let{status:t}=X(e);return C(T,{children:[O(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.joined?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:`bg-foreground-subtle/15 text-foreground-subtle`}`,children:t.joined?`Joined`:`Not joined`}),t.joined&&C(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:[t.peerCount,` peer`,t.peerCount===1?``:`s`]})]})}function je({addonId:t}){let n=E(),[r,i]=D(!1),[o,c]=D(null),l=j(),{status:d}=X(t),f=x(()=>{n.invalidateQueries({queryKey:[[`meshNetwork`]]})},[n]),p=e(),m=u({onSuccess:f}),h=s({onSuccess:f}),g=x(async()=>{i(!0);let e={cancelled:!1};c(e);try{let n=await p.mutateAsync({addonId:t});if(e.cancelled)return;n.loginUrl&&window.open(n.loginUrl,`_blank`,`noopener,noreferrer`);let r=Date.now();for(;!e.cancelled&&(await Ie(2e3),!e.cancelled);){let e=await l.trpcClient.meshNetwork.getStatus.query({addonId:t}).catch(()=>null),n=e?k.safeParse(e):null;if(n?.success&&n.data.joined){f();break}if(Date.now()-r>6e5)break}}finally{i(!1),c(null)}},[t,f,p,l]),_=x(()=>{o&&(o.cancelled=!0),i(!1),c(null)},[o]);return O(T,{children:d.joined?C(T,{children:[C(a,{size:`sm`,variant:`secondary`,disabled:m.isPending,onClick:()=>m.mutate({addonId:t}),children:[m.isPending?O(L,{className:`h-3 w-3 animate-spin`}):O(ce,{className:`h-3 w-3`}),`Disconnect`]}),C(a,{size:`sm`,variant:`ghost`,disabled:h.isPending,onClick:()=>h.mutate({addonId:t}),children:[h.isPending?O(L,{className:`h-3 w-3 animate-spin`}):O(W,{className:`h-3 w-3`}),`Log out`]})]}):r?C(a,{size:`sm`,variant:`ghost`,onClick:_,children:[O(le,{className:`h-3 w-3 mr-1`}),` Cancel`]}):C(T,{children:[C(a,{size:`sm`,variant:`primary`,onClick:()=>void g(),children:[O(fe,{className:`h-3 w-3`}),`Connect`]}),C(a,{size:`sm`,variant:`ghost`,disabled:h.isPending,onClick:()=>h.mutate({addonId:t}),children:[h.isPending?O(L,{className:`h-3 w-3 animate-spin`}):O(W,{className:`h-3 w-3`}),`Log out`]})]})})}function Z({addonId:e}){let{status:t}=X(e),n=y({addonId:e},{refetchInterval:De,retry:!1});return C(`div`,{className:`rounded-lg border border-border bg-surface`,children:[C(`div`,{className:`p-4 space-y-4`,children:[t.error&&O(g,{message:t.error}),O(Me,{status:t}),t.endpoints.length>0&&C(`div`,{className:`space-y-1.5`,children:[O(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:`Endpoints`}),t.endpoints.map(e=>C(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[C(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${Ee[e.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[e.scope===`public`?O(R,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,e.label]}),C(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1`,children:[O(I,{className:`h-3 w-3 shrink-0`}),e.url]})]},e.id))]})]}),O(`div`,{className:`border-t border-border`,children:O(Pe,{peers:n.data?.peers??[],loading:n.isLoading})})]})}function Me({status:e}){return O(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5`,children:[{label:`Tenant`,value:e.tenantName||`—`},{label:`User`,value:e.userLogin??`—`},{label:`Control plane`,value:e.controlPlaneUrl||`—`},{label:`Mesh IP`,value:e.meshIp||`—`,mono:!0},{label:`MagicDNS`,value:e.magicDnsHostname||`—`,mono:!0},{label:`DNS suffix`,value:e.magicDnsSuffix||`—`,mono:!0},{label:`Peers`,value:String(e.peerCount)},{label:`Key expiry`,value:e.keyExpiry?Ne(e.keyExpiry):`—`}].map(e=>C(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[O(`span`,{className:`text-foreground-subtle shrink-0`,children:e.label}),O(`span`,{className:`text-foreground truncate ${e.mono?`font-mono`:``}`,children:e.value})]},e.label))})}function Ne(e){let t=e-Date.now();if(t<0)return`Expired ${$(e)}`;let n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return`in ${n} days`;let r=Math.floor(t/36e5);return r>1?`in ${r}h`:`in ${Math.max(1,Math.floor(t/6e4))} min`}function Pe({peers:e,loading:t}){let n=w(()=>e.map(e=>({...e,_id:e.id})),[e]),r=x(e=>{e&&navigator.clipboard?.writeText(e)},[]),a=w(()=>[{key:`hostname`,header:`Hostname`,render:e=>C(`div`,{className:`flex flex-col`,children:[C(`div`,{className:`flex items-center gap-1.5`,children:[O(`span`,{className:`font-medium text-foreground`,children:e.hostname||`(unknown)`}),e.isSelf&&O(i,{variant:`info`,children:`self`}),e.exitNodeOption&&O(i,{variant:`warning`,children:`exit-node`})]}),e.userLogin&&O(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.userLogin})]})},{key:`magicDns`,header:`MagicDNS`,render:e=>e.magicDns?C(`div`,{className:`flex items-center gap-1`,children:[O(`span`,{className:`font-mono text-xs truncate`,children:e.magicDns}),O(`button`,{onClick:()=>r(e.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":`Copy MagicDNS`,children:O(N,{className:`h-3 w-3 text-foreground-subtle`})})]}):O(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:e=>{let t=e.addresses[0]??``;return t?C(`div`,{className:`flex items-center gap-1`,children:[O(`span`,{className:`font-mono text-xs`,children:t}),O(`button`,{onClick:()=>r(t),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":`Copy IP`,children:O(N,{className:`h-3 w-3 text-foreground-subtle`})})]}):O(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:`Connection`,render:e=>C(`div`,{className:`flex items-center gap-1.5`,children:[O(i,{variant:Fe(e.connection),children:e.connection}),e.relay&&O(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.relay})]})},{key:`routes`,header:`Routes`,render:e=>e.advertisedRoutes.length>0?O(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):O(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:`TX / RX`,render:e=>C(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,Q(e.txBytes),` · ↓ `,Q(e.rxBytes)]})},{key:`lastSeen`,header:`Last seen`,render:e=>O(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?$(e.lastSeenMs):`—`})}],[r]);return t&&e.length===0?C(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[O(L,{className:`h-3 w-3 animate-spin inline mr-1`}),` Loading peers…`]}):e.length===0?O(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:`No peers visible — your tailnet may be empty or the host is not joined.`}):O(`div`,{className:`p-4`,children:O(m,{columns:a,rows:n,rowKey:e=>e._id,minWidthPx:820})})}function Fe(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function Q(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)}MB`:`${(e/1024/1024/1024).toFixed(2)}GB`}function $(e){let t=Date.now()-e;return t<6e4?`just now`:t<36e5?`${Math.round(t/6e4)}m ago`:t<864e5?`${Math.round(t/36e5)}h ago`:`${Math.round(t/864e5)}d ago`}function Ie(e){return new Promise(t=>setTimeout(t,e))}function Le(){return O(`div`,{className:`flex flex-col p-4`,children:O(H,{tabs:[{id:`addresses`,label:`Network Addresses`,icon:B,content:O(Te,{})},{id:`remote-access`,label:`Remote Access`,icon:R,content:O(he,{})},{id:`mesh`,label:`Mesh Networks`,icon:M,content:O(ke,{})},{id:`turn`,label:`TURN Servers`,icon:V,content:O(ye,{})}]})})}export{Le as NetworkPage};
|
package/dist/assets/{NodeAddonsSettingsPanel-DTzycFzS.js → NodeAddonsSettingsPanel-DTo_3cuU.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Gr as e,It as t,_t as n,ct as r,lt as i,rn as a}from"./src-ojhqTnBF.js";import{H as o,I as s,K as c,Q as l,S as u,W as d,i as f,k as p,o as m,p as h,q as g,t as _,x as v,z as y}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{I as b}from"./src-D5vrhmeM.js";import{p as ee}from"./player-overlays-BrMuuVRR.js";import{n as te,r as x,t as ne}from"./SchemaTabBar-DhsmEGyn.js";import{t as S}from"./FormBuilder-CzGQp2IN.js";l();var C=p(function({addonId:e,schema:t,serverValues:n,onImmediateSave:r,onStateChange:i,onAction:a,disabled:l},u){let f=x({schema:t,serverValues:n,onImmediateSave:s(t=>r(e,t),[e,r]),onDeferredSave:s(()=>{},[])});o(u,()=>({flush:()=>{let e={};for(let t of f.pendingKeys)e[t]=f.values[t];return f.handleDiscard(f.pendingKeys),e},discard:()=>f.resetAll()}),[f]);let p=f.pendingKeys,m=p.join(`|`),h=d(()=>p.map(e=>`${e}=${JSON.stringify(f.values[e])}`).join(`,`),[p,f.values]),g=c(i);y(()=>{g.current=i},[i]),y(()=>{let t={};for(let e of p)t[e]=f.values[e];g.current({addonId:e,pendingKeys:p,pendingValues:t})},[e,m,h]);let _=d(()=>{if(a)return(t,n,r)=>a(e,t,n,r)},[e,a]);return v(S,{schema:t,values:f.values,onChange:f.handleChange,disabled:l,onAction:_})});l();function w(e,t){if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`){let n=e.fields.map(e=>w(e,t));return{...e,fields:n}}let n=e;t[e.key]=n.value;let{value:r,...i}=n;return i}function T(e,t){return{...e,fields:e.fields.map(e=>w(e,t))}}function re(e){let t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>T(e,t))},values:t}}function E({nodeId:o,addonIds:l,level:p,deviceId:y,capability:x,sectionIds:S,sectionTab:C,extraTabs:w,title:T,description:E}){let D=m(),O=ee().trpcClient,k=i(),A=r(),j=e(),M=a(),N=t(),P=!!(w&&w.length>0),[F,ae]=g(null);if(p===`device`&&!y)throw Error(`NodeAddonsSettingsPanel: deviceId is required when level === "device"`);let I=o??`hub`,L=f({queries:l.map(e=>({queryKey:[[`addonSettings`,p===`global`?`getGlobalSettings`:`getDeviceSettings`],{addonId:e,nodeId:I,deviceId:y??null,cap:x??null}],queryFn:async()=>p===`global`?{addonId:e,result:await O.addonSettings.getGlobalSettings.query({addonId:e,nodeId:I,...x?{cap:x}:{}})}:{addonId:e,result:await O.addonSettings.getDeviceSettings.query({addonId:e,deviceId:y,nodeId:I})},placeholderData:h}))}),R=L.some(e=>e.isLoading),z=L.map(e=>{if(!e.data)return`-`;if(e.data.result===null)return`${e.data.addonId}:n`;let t=[];for(let n of e.data.result.sections){t.push(`s:${n.id}:${n.tab??`general`}`);for(let e of n.fields){if(!(`key`in e))continue;let n=`options`in e&&Array.isArray(e.options)?e.options.map(e=>e.value).join(`,`):``,r=e.value,i=r===void 0?``:typeof r==`string`?r:JSON.stringify(r);t.push(`f:${e.key}:${n}:${i}`)}}return`${e.data.addonId}:${t.join(`|`)}`}).join(`||`),B=d(()=>{let e=new Set;for(let t of L){let n=t.data?.result?.sections;if(n)for(let t of n)e.add(t.tab??`general`)}return[...e]},[z+`::`+L.map(e=>(e.data?.result?.sections??[]).map(e=>e.tab??`general`).join(`,`)).join(`::`)]),V=d(()=>new Map((w??[]).map(e=>[e.id,e])),[w]),H=d(()=>{if(!P)return[];let e=[...new Set([...B,...(w??[]).map(e=>e.id)])],t=e=>{let t=V.get(e);if(t?.order!==void 0)return t.order;let n=b[e];return n?n.order:50};return e.toSorted((e,n)=>{let r=t(e),i=t(n);return r===i?e.localeCompare(n):r-i})},[P,B,w,V]),oe=d(()=>{let e=new Map;for(let t of B){let n=b[t];e.set(t,n?.label??t.charAt(0).toUpperCase()+t.slice(1))}for(let t of w??[])e.set(t.id,t.label);return e},[B,w]),U=P?F&&H.includes(F)?F:H[0]??null:null,W=U!==null&&V.has(U),G=P?U&&!W?U:void 0:C,{data:K}=n(void 0),se=d(()=>{let e=new Map;for(let t of K??[]){let n=t.manifest?.id;if(!n)continue;let r=t.manifest?.name??t.manifest?.packageDisplayName??n;e.set(n,r)}return e},[K]),q=c(new Map),J=d(()=>{let e=S?new Set(S):null,t=[];for(let n of L){if(!n.data)continue;let r=n.data.result??q.current.get(n.data.addonId)??null;if(n.data.result!==null&&q.current.set(n.data.addonId,n.data.result),r===null)continue;let{schema:i,values:a}=re(r),o=i.sections.filter(t=>e?e.has(t.id):!0);if(o.length===0)continue;let s={...r,sections:r.sections.filter(t=>e?e.has(t.id):!0)},c={...i,sections:o};t.push({addonId:n.data.addonId,schemaWithValues:s,schema:c,serverValues:a})}return t},[z,S]),[Y,ce]=g(new Map),le=s(e=>{ce(t=>{let n=new Map(t);return n.set(e.addonId,e),n})},[]),X=c(new Map),ue=s(e=>t=>{t?X.current.set(e,t):X.current.delete(e)},[]),Z=s(async(e,t)=>{p===`global`?await k.mutateAsync({addonId:e,nodeId:I,patch:t}):await A.mutateAsync({addonId:e,deviceId:y,nodeId:I,patch:t}),D.invalidateQueries({queryKey:[[`addonSettings`]]})},[k,A,I,p,y,D]),de=s(async(e,t,n,r)=>{let i=I;try{switch(t){case`reprobe-engine`:await j.mutateAsync({nodeId:i}),D.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-hwaccel`:await M.mutateAsync({nodeId:i}),D.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-audio-engine`:await N.mutateAsync({nodeId:i}),D.invalidateQueries({queryKey:[[`addonSettings`]]});return;default:{let n=await O.addons.custom.mutate({addonId:e,action:t,input:r});return D.invalidateQueries({queryKey:[[`addonSettings`]]}),n}}}catch(n){throw console.error(`[NodeAddonsSettingsPanel] action failed`,{addonId:e,action:t,err:n}),n}},[j,M,N,I,D,O]),fe=s((e,t)=>{Z(e,t)},[Z]),Q=_({mutationFn:async()=>{let e=[];for(let t of J){let n=Y.get(t.addonId);!n||n.pendingKeys.length===0||e.push({addonId:t.addonId,patch:n.pendingValues})}return e.length===0?{saved:[]}:{saved:await Promise.all(e.map(async({addonId:e,patch:t})=>(p===`global`?await k.mutateAsync({addonId:e,nodeId:I,patch:t}):await A.mutateAsync({addonId:e,deviceId:y,nodeId:I,patch:t}),e)))}},onSuccess:({saved:e})=>{for(let t of e)X.current.get(t)?.discard();D.invalidateQueries({queryKey:[[`addonSettings`]]})}}),pe=s(()=>{for(let e of X.current.values())e.discard()},[]),me=d(()=>{let e=0;for(let t of J){let n=Y.get(t.addonId);n&&(e+=n.pendingKeys.length)}return e},[J,Y]),he=d(()=>{let e=new Map;for(let t of J){let n=Y.get(t.addonId);if(!n||n.pendingKeys.length===0)continue;let r=new Set(n.pendingKeys);for(let n of t.schema.sections){let t=n.tab??`general`;for(let i of n.fields)`key`in i&&r.has(i.key)&&e.set(t,(e.get(t)??0)+1)}}return e},[J,Y]);if(R)return v(`div`,{className:`h-24 rounded-lg border border-border bg-surface animate-pulse`});let $=U&&W?V.get(U):void 0;if(!P&&J.length===0)return u(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:[`No addons in `,l.length>0?`[${l.join(`, `)}]`:`the current selection`,` `,`expose `,p,`-level settings on this node.`]});let ge=Q.isPending;return u(`div`,{className:`space-y-4`,children:[(T||E)&&u(`div`,{className:`border-b border-border pb-2`,children:[T&&v(`h2`,{className:`text-sm font-semibold text-foreground`,children:T}),E&&v(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:E})]}),P&&v(ne,{tabs:H.map(e=>({id:e,label:oe.get(e)??e})),activeId:U,onChange:ae,pendingByTab:he}),Q.isError&&u(`div`,{className:`rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400`,children:[`Save failed: `,String(Q.error?.message??Q.error)]}),$?$.content:(()=>{let e=G?J.reduce((e,t)=>e+t.schemaWithValues.sections.filter(e=>(e.tab??`general`)===G).length,0):0,t=G!==null&&e<=1,n=J.map(e=>({...e,renderedWithValues:{...e.schemaWithValues,sections:e.schemaWithValues.sections.filter(e=>G?(e.tab??`general`)===G:!0).map(e=>t?{...e,title:``,description:void 0}:e)}})).filter(e=>e.renderedWithValues.sections.length>0).toSorted((e,t)=>{let n=e=>{let t=1/0;for(let n of e)typeof n.order==`number`&&n.order<t&&(t=n.order);return t},r=n(e.renderedWithValues.sections),i=n(t.renderedWithValues.sections);return r===i?0:r-i});return n.length===0?v(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:`Nothing to configure here for this node.`}):v(ie,{entries:n,paneStates:Y,displayNames:se,disabled:ge,setPaneRef:ue,onPaneStateChange:le,onImmediateSave:fe,onAction:de,inline:P||!!C})})(),!R&&v(te,{pendingCount:me,onSave:()=>Q.mutate(),onDiscard:pe,saving:ge})]})}function ie({entries:e,paneStates:t,displayNames:n,disabled:r,setPaneRef:i,onPaneStateChange:a,onImmediateSave:o,onAction:s,inline:c}){let l=d(()=>[...e].toSorted((e,t)=>{if(e.addonId===`system-config`)return-1;if(t.addonId===`system-config`)return 1;let r=n.get(e.addonId)??e.addonId,i=n.get(t.addonId)??t.addonId;return r.localeCompare(i)}),[e,n]),[f,p]=g(l[0]?.addonId??``);y(()=>{l.length!==0&&(l.find(e=>e.addonId===f)||p(l[0].addonId))},[l,f]);let m=l.find(e=>e.addonId===f)??l[0];if(!m)return null;let h=d(()=>s?(e,t,n,r)=>s(e,t,n,r):void 0,[s]),_=e=>v(C,{ref:i(e.addonId),addonId:e.addonId,schema:e.renderedWithValues,serverValues:e.serverValues,onImmediateSave:o,onStateChange:a,onAction:h,disabled:r},e.addonId);return l.length===1||c?v(`div`,{className:`flex flex-col gap-4`,children:l.map(_)}):u(`div`,{className:`flex flex-col gap-3`,children:[v(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:l.map(e=>{let r=n.get(e.addonId)??e.addonId,i=e.addonId===m.addonId,a=(t.get(e.addonId)?.pendingKeys.length??0)>0;return u(`button`,{type:`button`,onClick:()=>p(e.addonId),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${i?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[r,a&&v(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400`})]},e.addonId)})}),v(`div`,{className:`space-y-2`,children:l.map(e=>v(`div`,{style:e.addonId===m.addonId?void 0:{display:`none`},children:_(e)},e.addonId))})]})}export{E as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$i as e,Aa as t,Da as n,Ea as r,S as i,Sa as a,Ta as o,ja as s,ka as c,wa as l,xa as u}from"./src-BZ1dd5LI.js";import{Q as d,S as f,W as p,a as m,q as h,t as g,x as _}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{p as v}from"./player-overlays-CpsGl45o.js";import{t as y}from"./circle-check-big-wzEehng2.js";import{t as b}from"./pencil-BlQGw-pI.js";import{t as x}from"./plus-DSiRMRVx.js";import{t as S}from"./search-CN_ccU_h.js";import{R as C,V as w,j as T,s as E,x as D}from"./index-CY52lvbZ.js";import{t as O}from"./AdminPage-BwmGKnRf.js";var k=w(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]);d();var A=e=>typeof e==`string`&&e.length>0;function j(e){return{levels:e.levels,formats:e.format,bodyMaxLen:e.bodyMaxLen,attachmentSlots:e.attachments.mediaTypes,attachmentMode:e.attachments.mode,attachmentMax:e.attachments.max,attachmentMaxBytes:e.attachments.maxBytes,maxActions:e.actions,showActions:e.actions>0,showClickUrl:e.clickUrl,showSound:e.sound,showTtl:e.ttl,showTag:!0}}function M(e,t){return e.format.includes(t)?t:e.format[0]??`text`}function N(e,t){let n=[];for(let r of e.attachments.mediaTypes){if(n.length>=e.attachments.max)break;let i=t[r];A(i)&&n.push({mediaType:r,url:i})}return n}function P(e,t){if(e.actions<=0)return[];let n=[];for(let r of t){if(n.length>=e.actions)break;let t=A(r.label),i=A(r.url);!t&&!i||n.push({id:`test-${n.length+1}`,label:t?r.label:`Action ${n.length+1}`,...i?{url:r.url}:{}})}return n}function F(e,t){let n=e.levels.some(e=>e.id===t.level)?t.level:void 0,r=N(e,t.attachmentUrls),i=P(e,t.actions),a=e.ttl&&A(t.ttl)?Number(t.ttl):void 0;return{body:t.body,format:M(e,t.format),priority:I(t.priority),...A(t.title)?{title:t.title}:{},...n?{level:n}:{},...r.length>0?{attachments:r}:{},...i.length>0?{actions:i}:{},...e.clickUrl&&A(t.clickUrl)?{clickUrl:t.clickUrl}:{},...e.sound&&A(t.sound)?{sound:t.sound}:{},...a!==void 0&&Number.isFinite(a)?{ttl:a}:{},...A(t.tag)?{tag:t.tag}:{}}}function I(e){return Number.isFinite(e)?Math.min(5,Math.max(1,Math.round(e))):3}function L(e){return e.levels.find(e=>e.flags?.critical===!0)||e.levels.filter(e=>typeof e.ordinal==`number`).sort((e,t)=>t.ordinal-e.ordinal)[0]}function R(e){return{level:``,priority:3,format:e.format[0]??`text`,title:``,body:``,attachmentUrls:{},actions:[],clickUrl:``,sound:``,ttl:``,tag:``}}var z={image:`https://example.com/sample.jpg`,video:`https://example.com/sample.mp4`,gif:`https://example.com/sample.gif`,audio:`https://example.com/sample.mp3`,icon:`https://example.com/icon.png`};function B(e,t){let n=R(e);switch(t){case`minimal`:return{...n,body:`Test notification`};case`overflow`:return{...n,body:`X`.repeat(e.bodyMaxLen+50)};case`critical`:{let t=L(e);return{...n,body:`Critical test notification`,priority:5,level:t?.id??``}}case`everything`:{let t={},n=0;for(let r of e.attachments.mediaTypes){if(n>=e.attachments.max)break;t[r]=z[r],n+=1}let r=Array.from({length:e.actions},(e,t)=>({label:`Action ${t+1}`,url:`https://example.com/action/${t+1}`}));return{level:``,priority:4,format:e.format.includes(`markdown`)?`markdown`:e.format.includes(`html`)?`html`:e.format[0]??`text`,title:`Everything the kind supports`,body:`This sample fills every control the kind advertises.`,attachmentUrls:t,actions:r,clickUrl:e.clickUrl?`https://example.com/open`:``,sound:e.sound?`default`:``,ttl:e.ttl?`3600`:``,tag:`camstack-test`}}}}var V=[{id:`minimal`,label:`Minimal (body only)`},{id:`everything`,label:`Everything supported`},{id:`overflow`,label:`Overflow`},{id:`critical`,label:`Critical`}],H=`w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none`,U=`block text-[11px] font-medium text-foreground mb-1`;function W({target:e,kind:n,open:i,onClose:c}){let d=v(),m=p(()=>j(n.caps),[n.caps]),[y,b]=h(()=>R(n.caps)),[x,S]=h(null),C=p(()=>F(n.caps,y),[n.caps,y]),w=y.body.length,T=w>m.bodyMaxLen,E=e=>b(t=>({...t,...e})),O=g({mutationFn:()=>d.trpcClient.notificationOutput.testTarget.mutate({addonId:e.addonId,targetId:e.id,sample:F(n.caps,y)}),onMutate:()=>S(null),onSuccess:e=>S(e),onError:e=>S({success:!1,error:e instanceof Error?e.message:`Test failed`})}),A=e=>{b(B(n.caps,e)),S(null)},M=(e,t,n)=>{let r=y.actions.length>0?[...y.actions]:[];for(;r.length<=e;)r.push({label:``,url:``});r[e]={...r[e],[t]:n},E({actions:r})};return _(u,{open:i,onOpenChange:e=>!e&&c(),children:f(a,{width:`lg`,className:`!max-w-2xl`,children:[_(o,{children:f(r,{children:[`Test "`,e.name,`" (`,n.label,`)`]})}),f(`div`,{className:`space-y-4 max-h-[60vh] overflow-y-auto pr-1`,children:[_(`div`,{className:`flex flex-wrap gap-1.5`,children:V.map(e=>_(s,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>A(e.id),children:e.label},e.id))}),f(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[m.levels.length>0&&f(`div`,{children:[_(`label`,{className:U,children:`Level`}),f(`select`,{className:H,value:y.level,onChange:e=>E({level:e.target.value}),children:[_(`option`,{value:``,children:`— derive from priority —`}),m.levels.map(e=>f(`option`,{value:e.id,children:[e.label,e.ordinal===null?` (qualitative)`:` (p${e.ordinal})`]},e.id))]}),(()=>{let e=m.levels.find(e=>e.id===y.level);return e?f(`div`,{className:`mt-1 space-y-1`,children:[e.description&&_(`p`,{className:`text-[10px] text-foreground-subtle`,children:e.description}),f(`div`,{className:`flex flex-wrap gap-1`,children:[e.flags?.critical&&_(t,{variant:`danger`,"data-testid":`flag-critical`,children:`critical`}),e.flags?.silent&&_(t,{variant:`info`,children:`silent`}),e.flags?.noPush&&_(t,{variant:`warning`,children:`no-push`})]}),e.requires&&e.requires.length>0&&f(`p`,{className:`text-[10px] text-warning`,children:[`Requires target config: `,e.requires.join(`, `)]})]}):null})()]}),f(`div`,{children:[f(`label`,{className:U,children:[`Priority (ordinal): `,y.priority]}),_(`input`,{type:`range`,min:1,max:5,step:1,value:y.priority,onChange:e=>E({priority:Number(e.target.value)}),className:`w-full accent-primary`,"aria-label":`priority`})]})]}),m.formats.length>0&&f(`div`,{children:[_(`label`,{className:U,children:`Format`}),_(`div`,{className:`flex flex-wrap gap-2`,children:m.formats.map(e=>f(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[_(`input`,{type:`radio`,name:`format`,className:`accent-primary`,checked:y.format===e,onChange:()=>E({format:e})}),e]},e))})]}),f(`div`,{children:[_(`label`,{className:U,children:`Title`}),_(`input`,{className:H,value:y.title,onChange:e=>E({title:e.target.value})})]}),f(`div`,{children:[f(`label`,{className:U,children:[`Body`,` `,f(`span`,{className:T?`text-danger`:`text-foreground-subtle`,children:[`(`,w,`/`,m.bodyMaxLen,T?` — overflow`:``,`)`]})]}),_(`textarea`,{className:`${H} min-h-[80px] resize-y`,value:y.body,onChange:e=>E({body:e.target.value})})]}),m.attachmentSlots.length>0&&f(`div`,{children:[f(`label`,{className:U,children:[`Attachments`,` `,f(`span`,{className:`text-foreground-subtle`,children:[`(mode: `,m.attachmentMode,`, max `,m.attachmentMax,m.attachmentMaxBytes?`, ≤${Math.round(m.attachmentMaxBytes/1024/1024)}MB`:``,`)`]})]}),_(`div`,{className:`space-y-1.5`,children:m.attachmentSlots.map(e=>f(`div`,{className:`flex items-center gap-2`,children:[_(`span`,{className:`text-[10px] w-12 shrink-0 text-foreground-subtle`,children:e}),_(`input`,{className:H,placeholder:`${e} URL`,value:y.attachmentUrls[e]??``,onChange:t=>E({attachmentUrls:{...y.attachmentUrls,[e]:t.target.value}})})]},e))})]}),m.showActions&&f(`div`,{children:[f(`label`,{className:U,children:[`Actions (up to `,m.maxActions,`)`]}),_(`div`,{className:`space-y-1.5`,children:Array.from({length:Math.min(m.maxActions,3)},(e,t)=>f(`div`,{className:`flex items-center gap-2`,children:[_(`input`,{className:H,placeholder:`label`,value:y.actions[t]?.label??``,onChange:e=>M(t,`label`,e.target.value)}),_(`input`,{className:H,placeholder:`url`,value:y.actions[t]?.url??``,onChange:e=>M(t,`url`,e.target.value)})]},t))})]}),f(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[m.showClickUrl&&f(`div`,{children:[_(`label`,{className:U,children:`Click URL`}),_(`input`,{className:H,value:y.clickUrl,onChange:e=>E({clickUrl:e.target.value})})]}),m.showSound&&f(`div`,{children:[_(`label`,{className:U,children:`Sound`}),_(`input`,{className:H,value:y.sound,onChange:e=>E({sound:e.target.value})})]}),m.showTtl&&f(`div`,{children:[_(`label`,{className:U,children:`TTL (seconds)`}),_(`input`,{className:H,type:`number`,value:y.ttl,onChange:e=>E({ttl:e.target.value})})]}),m.showTag&&f(`div`,{children:[_(`label`,{className:U,children:`Tag`}),_(`input`,{className:H,value:y.tag,onChange:e=>E({tag:e.target.value})})]})]}),x&&_(G,{result:x}),f(`details`,{className:`text-[10px]`,children:[_(`summary`,{className:`cursor-pointer text-foreground-subtle`,children:`Payload preview`}),_(`pre`,{className:`mt-1 overflow-x-auto rounded bg-surface p-2 text-foreground-subtle`,children:JSON.stringify(C,null,2)})]})]}),f(l,{children:[_(s,{variant:`secondary`,size:`sm`,type:`button`,onClick:c,children:`Close`}),f(s,{size:`sm`,type:`button`,disabled:O.isPending||y.body.length===0,onClick:()=>O.mutate(),children:[O.isPending?_(D,{className:`h-3.5 w-3.5 animate-spin`}):_(k,{className:`h-3.5 w-3.5`}),`Send test`]})]})]})})}function G({result:e}){let t=e.renderedAs;return f(`div`,{className:`rounded-md border px-3 py-2 text-xs ${e.success?`border-success/40 bg-success/10`:`border-danger/40 bg-danger/10`}`,"data-testid":`test-result`,children:[f(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.success?_(y,{className:`h-3.5 w-3.5 text-success`}):_(T,{className:`h-3.5 w-3.5 text-danger`}),_(`span`,{children:e.success?`Delivered`:`Failed`})]}),e.error&&_(`p`,{className:`mt-1 text-danger`,children:e.error}),t&&f(`dl`,{className:`mt-2 grid grid-cols-2 gap-x-3 gap-y-0.5 text-[11px] text-foreground-subtle`,children:[_(`dt`,{children:`Resolved level`}),_(`dd`,{className:`text-foreground`,children:t.level}),_(`dt`,{children:`Format sent`}),_(`dd`,{className:`text-foreground`,children:t.format}),_(`dt`,{children:`Attachments sent`}),_(`dd`,{className:`text-foreground`,children:t.attachmentsSent}),_(`dt`,{children:`Actions sent`}),_(`dd`,{className:`text-foreground`,children:t.actionsSent}),_(`dt`,{children:`Truncated`}),_(`dd`,{className:`text-foreground`,children:t.truncated?`yes`:`no`}),_(`dt`,{children:`Dropped`}),_(`dd`,{className:`text-foreground`,children:t.dropped.length>0?t.dropped.join(`, `):`—`})]})]})}function K(e){let t=[],n=new Map;for(let r of e){let e=n.get(r.addonId);e?e.push(r):(n.set(r.addonId,[r]),t.push(r.addonId))}return t.map(e=>({addonId:e,kinds:n.get(e)??[]}))}function q(e){let t=[],n=e=>{for(let r of e){if(r.type===`password`){t.push(r.key);continue}if(r.type===`group`){n(r.fields);continue}if(r.type===`sub-tabs`)for(let e of r.tabs)n(e.fields)}};for(let t of e.sections)n(t.fields);return t}function J(e,t,n){let r=new Set(n),i={};for(let[n,a]of Object.entries(e)){if(!r.has(n)){i[n]=a;continue}a==null||a===``||a!==t[n]&&(i[n]=a)}return i}function Y(e,t){let n=new Set(t),r={};for(let[t,i]of Object.entries(e))r[t]=n.has(t)?``:i;return r}d();var X=[`notificationOutput`,`listTargets`],Z=[`notificationOutput`,`listTargetKinds`];function Q(){let r=v(),[i,a]=h({mode:`closed`}),[o,l]=h(null),u=m({queryKey:X,queryFn:()=>r.trpcClient.notificationOutput.listTargets.query({})}),d=m({queryKey:Z,queryFn:async()=>(await r.trpcClient.notificationOutput.listTargetKinds.query({})).map(e=>({...e,configSchema:e.configSchema}))}),y=p(()=>d.data??[],[d.data]),S=p(()=>{let e=new Map;for(let t of y)e.set(t.kind,t);return e},[y]),w=g({mutationFn:e=>r.trpcClient.notificationOutput.setTargetEnabled.mutate({addonId:e.target.addonId,targetId:e.target.id,enabled:e.enabled}),onSuccess:()=>void u.refetch()}),T=g({mutationFn:e=>r.trpcClient.notificationOutput.deleteTarget.mutate({addonId:e.addonId,targetId:e.id}),onSuccess:()=>void u.refetch()}),A=o?S.get(o.kind):void 0;return f(O,{icon:C,title:`Notification Targets`,subtitle:`Deliver notifications to ntfy, Pushover, Telegram, Home Assistant and more. Each target's kind declares its capabilities; the test panel shows exactly what a message degrades to.`,actions:f(s,{size:`sm`,type:`button`,onClick:()=>a({mode:`pick-kind`}),children:[_(x,{className:`h-3.5 w-3.5`}),`Add target`]}),children:[u.isLoading&&_(`div`,{className:`flex items-center justify-center py-16`,children:_(D,{className:`h-6 w-6 animate-spin text-primary`})}),u.isError&&!u.isLoading&&_(e,{title:`Failed to load targets`,message:u.error instanceof Error?u.error.message:`Unknown error`,onRetry:()=>void u.refetch()}),!u.isLoading&&!u.isError&&(u.data??[]).length===0&&_(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:`No notification targets yet. Click "Add target" to configure one.`}),(u.data??[]).length>0&&_(c,{children:_(`ul`,{className:`divide-y divide-border`,children:(u.data??[]).map(e=>{let r=S.get(e.kind);return f(`li`,{className:`flex items-center gap-3 px-4 py-2.5`,children:[_(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface text-xs`,title:r?.label??e.kind,children:r?.icon??`🔔`}),f(`div`,{className:`min-w-0 flex-1`,children:[_(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),_(`div`,{className:`text-[11px] text-foreground-subtle`,children:r?.label??e.kind})]}),!e.enabled&&_(t,{variant:`warning`,children:`disabled`}),_(n,{checked:e.enabled,onCheckedChange:t=>w.mutate({target:e,enabled:t}),"aria-label":`toggle ${e.name}`}),_(s,{size:`sm`,variant:`ghost`,type:`button`,disabled:!r,onClick:()=>l(e),title:`Test`,children:_(k,{className:`h-3.5 w-3.5`})}),_(s,{size:`sm`,variant:`ghost`,type:`button`,disabled:!r,onClick:()=>r&&a({mode:`form`,kind:r,target:e}),title:`Edit`,children:_(b,{className:`h-3.5 w-3.5`})}),_(s,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>T.mutate(e),title:`Delete`,children:_(E,{className:`h-3.5 w-3.5 text-danger`})})]},e.id)})})}),i.mode===`pick-kind`&&_($,{kinds:y,onCancel:()=>a({mode:`closed`}),onPick:e=>a({mode:`form`,kind:e,target:null})}),i.mode===`form`&&_(ee,{kind:i.kind,target:i.target,onCancel:()=>a({mode:`closed`}),onSaved:()=>{a({mode:`closed`}),u.refetch()}}),o&&A&&_(W,{target:o,kind:A,open:!0,onClose:()=>l(null)})]})}function $({kinds:e,onPick:n,onCancel:r}){let i=p(()=>K(e),[e]);return f(c,{className:`p-4 space-y-4`,children:[f(`div`,{className:`flex items-center justify-between`,children:[_(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Choose a notification kind`}),_(s,{size:`sm`,variant:`ghost`,type:`button`,onClick:r,children:`Cancel`})]}),i.length===0&&_(`p`,{className:`text-xs text-foreground-subtle`,children:`No notification providers are installed. Install the notifiers addon (or connect Home Assistant) to add targets.`}),i.map(e=>f(`div`,{children:[_(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1.5`,children:e.addonId}),_(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-2`,children:e.kinds.map(r=>f(`button`,{type:`button`,onClick:()=>n(r),className:`flex flex-col items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-3 text-xs hover:border-primary/50 hover:bg-surface-hover transition-colors`,children:[_(`span`,{className:`text-lg`,children:r.icon}),_(`span`,{className:`font-medium text-foreground`,children:r.label}),r.supportsDiscovery&&_(t,{variant:`info`,style:`outline`,children:`discover`})]},`${e.addonId}:${r.kind}`))})]},e.addonId))]})}function ee({kind:e,target:t,onSaved:n,onCancel:r}){let a=v(),o=p(()=>q(e.configSchema),[e.configSchema]),l=p(()=>t?.config??{},[t]),[u,d]=h(t?.name??e.label),[m,y]=h(()=>t?Y(t.config,o):{}),[b,x]=h(null),[C,w]=h(null),T=g({mutationFn:()=>a.trpcClient.notificationOutput.discoverTargets.query({addonId:e.addonId,kind:e.kind,config:m}),onSuccess:e=>x(e),onError:e=>w(e instanceof Error?e.message:`Discovery failed`)}),E=g({mutationFn:()=>{let n=J(m,l,o),r={id:t?.id??`${e.kind}-${Date.now()}`,name:u,kind:e.kind,addonId:e.addonId,enabled:t?.enabled??!0,config:n};return a.trpcClient.notificationOutput.upsertTarget.mutate({addonId:e.addonId,target:r})},onSuccess:n,onError:e=>w(e instanceof Error?e.message:`Save failed`)}),O=e=>{d(e.suggestedName),y(t=>({...t,...e.config})),x(null)};return f(c,{className:`p-4 space-y-4`,children:[f(`div`,{className:`flex items-center justify-between`,children:[f(`h3`,{className:`text-sm font-semibold text-foreground flex items-center gap-2`,children:[_(`span`,{className:`text-lg`,children:e.icon}),t?`Edit ${t.name}`:`Add ${e.label} target`]}),_(s,{size:`sm`,variant:`ghost`,type:`button`,onClick:r,children:`Cancel`})]}),C&&_(`div`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:C}),f(`div`,{children:[_(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Name`}),_(`input`,{className:`w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none`,value:u,onChange:e=>d(e.target.value)})]}),e.supportsDiscovery&&f(`div`,{className:`space-y-2`,children:[f(s,{size:`sm`,variant:`outline`,type:`button`,disabled:T.isPending,onClick:()=>{w(null),T.mutate()},children:[T.isPending?_(D,{className:`h-3.5 w-3.5 animate-spin`}):_(S,{className:`h-3.5 w-3.5`}),`Discover`]}),b&&b.length===0&&_(`p`,{className:`text-[11px] text-foreground-subtle`,children:`No candidates discovered.`}),b&&b.length>0&&_(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:b.map((e,t)=>f(`button`,{type:`button`,onClick:()=>O(e),className:`flex w-full items-center justify-between px-3 py-1.5 text-xs hover:bg-surface-hover`,children:[_(`span`,{className:`text-foreground`,children:e.suggestedName}),_(`span`,{className:`text-[10px] text-primary`,children:`use`})]},`${e.suggestedName}-${t}`))})]}),o.length>0&&t&&_(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Secret fields are hidden. Leave them blank to keep the stored value; type a new value to replace it.`}),_(i,{schema:e.configSchema,values:m,onChange:y}),f(`div`,{className:`flex justify-end gap-2`,children:[_(s,{variant:`secondary`,size:`sm`,type:`button`,onClick:r,children:`Cancel`}),f(s,{size:`sm`,type:`button`,disabled:E.isPending||u.trim().length===0,onClick:()=>{w(null),E.mutate()},children:[E.isPending&&_(D,{className:`h-3.5 w-3.5 animate-spin`}),t?`Save changes`:`Create target`]})]})]})}export{Q as NotificationTargetsPage,Q as default};
|
|
1
|
+
import{Ca as e,Da as t,Ea as n,Ma as r,Na as i,Oa as a,S as o,ja as s,ka as c,ta as l,wa as u}from"./src-ojhqTnBF.js";import{Q as d,S as f,W as p,a as m,q as h,t as g,x as _}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{p as v}from"./player-overlays-BrMuuVRR.js";import{t as y}from"./circle-check-big-CTwHEGsR.js";import{t as b}from"./pencil-DedPunTk.js";import{t as x}from"./plus-r3Kz9Nsb.js";import{t as S}from"./search-GJrj432A.js";import{H as C,M as w,S as T,s as E,z as D}from"./index-3DCschCe.js";import{t as O}from"./AdminPage-BwmGKnRf.js";var k=C(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]);d();var A=e=>typeof e==`string`&&e.length>0;function j(e){return{levels:e.levels,formats:e.format,bodyMaxLen:e.bodyMaxLen,attachmentSlots:e.attachments.mediaTypes,attachmentMode:e.attachments.mode,attachmentMax:e.attachments.max,attachmentMaxBytes:e.attachments.maxBytes,maxActions:e.actions,showActions:e.actions>0,showClickUrl:e.clickUrl,showSound:e.sound,showTtl:e.ttl,showTag:!0}}function M(e,t){return e.format.includes(t)?t:e.format[0]??`text`}function N(e,t){let n=[];for(let r of e.attachments.mediaTypes){if(n.length>=e.attachments.max)break;let i=t[r];A(i)&&n.push({mediaType:r,url:i})}return n}function P(e,t){if(e.actions<=0)return[];let n=[];for(let r of t){if(n.length>=e.actions)break;let t=A(r.label),i=A(r.url);!t&&!i||n.push({id:`test-${n.length+1}`,label:t?r.label:`Action ${n.length+1}`,...i?{url:r.url}:{}})}return n}function F(e,t){let n=e.levels.some(e=>e.id===t.level)?t.level:void 0,r=N(e,t.attachmentUrls),i=P(e,t.actions),a=e.ttl&&A(t.ttl)?Number(t.ttl):void 0;return{body:t.body,format:M(e,t.format),priority:I(t.priority),...A(t.title)?{title:t.title}:{},...n?{level:n}:{},...r.length>0?{attachments:r}:{},...i.length>0?{actions:i}:{},...e.clickUrl&&A(t.clickUrl)?{clickUrl:t.clickUrl}:{},...e.sound&&A(t.sound)?{sound:t.sound}:{},...a!==void 0&&Number.isFinite(a)?{ttl:a}:{},...A(t.tag)?{tag:t.tag}:{}}}function I(e){return Number.isFinite(e)?Math.min(5,Math.max(1,Math.round(e))):3}function L(e){return e.levels.find(e=>e.flags?.critical===!0)||e.levels.filter(e=>typeof e.ordinal==`number`).sort((e,t)=>t.ordinal-e.ordinal)[0]}function R(e){return{level:``,priority:3,format:e.format[0]??`text`,title:``,body:``,attachmentUrls:{},actions:[],clickUrl:``,sound:``,ttl:``,tag:``}}var z={image:`https://example.com/sample.jpg`,video:`https://example.com/sample.mp4`,gif:`https://example.com/sample.gif`,audio:`https://example.com/sample.mp3`,icon:`https://example.com/icon.png`};function B(e,t){let n=R(e);switch(t){case`minimal`:return{...n,body:`Test notification`};case`overflow`:return{...n,body:`X`.repeat(e.bodyMaxLen+50)};case`critical`:{let t=L(e);return{...n,body:`Critical test notification`,priority:5,level:t?.id??``}}case`everything`:{let t={},n=0;for(let r of e.attachments.mediaTypes){if(n>=e.attachments.max)break;t[r]=z[r],n+=1}let r=Array.from({length:e.actions},(e,t)=>({label:`Action ${t+1}`,url:`https://example.com/action/${t+1}`}));return{level:``,priority:4,format:e.format.includes(`markdown`)?`markdown`:e.format.includes(`html`)?`html`:e.format[0]??`text`,title:`Everything the kind supports`,body:`This sample fills every control the kind advertises.`,attachmentUrls:t,actions:r,clickUrl:e.clickUrl?`https://example.com/open`:``,sound:e.sound?`default`:``,ttl:e.ttl?`3600`:``,tag:`camstack-test`}}}}var V=[{id:`minimal`,label:`Minimal (body only)`},{id:`everything`,label:`Everything supported`},{id:`overflow`,label:`Overflow`},{id:`critical`,label:`Critical`}],H=`w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none`,U=`block text-[11px] font-medium text-foreground mb-1`;function W({target:o,kind:s,open:c,onClose:l}){let d=v(),m=p(()=>j(s.caps),[s.caps]),[y,b]=h(()=>R(s.caps)),[x,S]=h(null),C=p(()=>F(s.caps,y),[s.caps,y]),w=y.body.length,E=w>m.bodyMaxLen,D=e=>b(t=>({...t,...e})),O=g({mutationFn:()=>d.trpcClient.notificationOutput.testTarget.mutate({addonId:o.addonId,targetId:o.id,sample:F(s.caps,y)}),onMutate:()=>S(null),onSuccess:e=>S(e),onError:e=>S({success:!1,error:e instanceof Error?e.message:`Test failed`})}),A=e=>{b(B(s.caps,e)),S(null)},M=(e,t,n)=>{let r=y.actions.length>0?[...y.actions]:[];for(;r.length<=e;)r.push({label:``,url:``});r[e]={...r[e],[t]:n},D({actions:r})};return _(e,{open:c,onOpenChange:e=>!e&&l(),children:f(u,{width:`lg`,className:`!max-w-2xl`,children:[_(t,{children:f(a,{children:[`Test "`,o.name,`" (`,s.label,`)`]})}),f(`div`,{className:`space-y-4 max-h-[60vh] overflow-y-auto pr-1`,children:[_(`div`,{className:`flex flex-wrap gap-1.5`,children:V.map(e=>_(i,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>A(e.id),children:e.label},e.id))}),f(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[m.levels.length>0&&f(`div`,{children:[_(`label`,{className:U,children:`Level`}),f(`select`,{className:H,value:y.level,onChange:e=>D({level:e.target.value}),children:[_(`option`,{value:``,children:`— derive from priority —`}),m.levels.map(e=>f(`option`,{value:e.id,children:[e.label,e.ordinal===null?` (qualitative)`:` (p${e.ordinal})`]},e.id))]}),(()=>{let e=m.levels.find(e=>e.id===y.level);return e?f(`div`,{className:`mt-1 space-y-1`,children:[e.description&&_(`p`,{className:`text-[10px] text-foreground-subtle`,children:e.description}),f(`div`,{className:`flex flex-wrap gap-1`,children:[e.flags?.critical&&_(r,{variant:`danger`,"data-testid":`flag-critical`,children:`critical`}),e.flags?.silent&&_(r,{variant:`info`,children:`silent`}),e.flags?.noPush&&_(r,{variant:`warning`,children:`no-push`})]}),e.requires&&e.requires.length>0&&f(`p`,{className:`text-[10px] text-warning`,children:[`Requires target config: `,e.requires.join(`, `)]})]}):null})()]}),f(`div`,{children:[f(`label`,{className:U,children:[`Priority (ordinal): `,y.priority]}),_(`input`,{type:`range`,min:1,max:5,step:1,value:y.priority,onChange:e=>D({priority:Number(e.target.value)}),className:`w-full accent-primary`,"aria-label":`priority`})]})]}),m.formats.length>0&&f(`div`,{children:[_(`label`,{className:U,children:`Format`}),_(`div`,{className:`flex flex-wrap gap-2`,children:m.formats.map(e=>f(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[_(`input`,{type:`radio`,name:`format`,className:`accent-primary`,checked:y.format===e,onChange:()=>D({format:e})}),e]},e))})]}),f(`div`,{children:[_(`label`,{className:U,children:`Title`}),_(`input`,{className:H,value:y.title,onChange:e=>D({title:e.target.value})})]}),f(`div`,{children:[f(`label`,{className:U,children:[`Body`,` `,f(`span`,{className:E?`text-danger`:`text-foreground-subtle`,children:[`(`,w,`/`,m.bodyMaxLen,E?` — overflow`:``,`)`]})]}),_(`textarea`,{className:`${H} min-h-[80px] resize-y`,value:y.body,onChange:e=>D({body:e.target.value})})]}),m.attachmentSlots.length>0&&f(`div`,{children:[f(`label`,{className:U,children:[`Attachments`,` `,f(`span`,{className:`text-foreground-subtle`,children:[`(mode: `,m.attachmentMode,`, max `,m.attachmentMax,m.attachmentMaxBytes?`, ≤${Math.round(m.attachmentMaxBytes/1024/1024)}MB`:``,`)`]})]}),_(`div`,{className:`space-y-1.5`,children:m.attachmentSlots.map(e=>f(`div`,{className:`flex items-center gap-2`,children:[_(`span`,{className:`text-[10px] w-12 shrink-0 text-foreground-subtle`,children:e}),_(`input`,{className:H,placeholder:`${e} URL`,value:y.attachmentUrls[e]??``,onChange:t=>D({attachmentUrls:{...y.attachmentUrls,[e]:t.target.value}})})]},e))})]}),m.showActions&&f(`div`,{children:[f(`label`,{className:U,children:[`Actions (up to `,m.maxActions,`)`]}),_(`div`,{className:`space-y-1.5`,children:Array.from({length:Math.min(m.maxActions,3)},(e,t)=>f(`div`,{className:`flex items-center gap-2`,children:[_(`input`,{className:H,placeholder:`label`,value:y.actions[t]?.label??``,onChange:e=>M(t,`label`,e.target.value)}),_(`input`,{className:H,placeholder:`url`,value:y.actions[t]?.url??``,onChange:e=>M(t,`url`,e.target.value)})]},t))})]}),f(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[m.showClickUrl&&f(`div`,{children:[_(`label`,{className:U,children:`Click URL`}),_(`input`,{className:H,value:y.clickUrl,onChange:e=>D({clickUrl:e.target.value})})]}),m.showSound&&f(`div`,{children:[_(`label`,{className:U,children:`Sound`}),_(`input`,{className:H,value:y.sound,onChange:e=>D({sound:e.target.value})})]}),m.showTtl&&f(`div`,{children:[_(`label`,{className:U,children:`TTL (seconds)`}),_(`input`,{className:H,type:`number`,value:y.ttl,onChange:e=>D({ttl:e.target.value})})]}),m.showTag&&f(`div`,{children:[_(`label`,{className:U,children:`Tag`}),_(`input`,{className:H,value:y.tag,onChange:e=>D({tag:e.target.value})})]})]}),x&&_(G,{result:x}),f(`details`,{className:`text-[10px]`,children:[_(`summary`,{className:`cursor-pointer text-foreground-subtle`,children:`Payload preview`}),_(`pre`,{className:`mt-1 overflow-x-auto rounded bg-surface p-2 text-foreground-subtle`,children:JSON.stringify(C,null,2)})]})]}),f(n,{children:[_(i,{variant:`secondary`,size:`sm`,type:`button`,onClick:l,children:`Close`}),f(i,{size:`sm`,type:`button`,disabled:O.isPending||y.body.length===0,onClick:()=>O.mutate(),children:[O.isPending?_(T,{className:`h-3.5 w-3.5 animate-spin`}):_(k,{className:`h-3.5 w-3.5`}),`Send test`]})]})]})})}function G({result:e}){let t=e.renderedAs;return f(`div`,{className:`rounded-md border px-3 py-2 text-xs ${e.success?`border-success/40 bg-success/10`:`border-danger/40 bg-danger/10`}`,"data-testid":`test-result`,children:[f(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.success?_(y,{className:`h-3.5 w-3.5 text-success`}):_(w,{className:`h-3.5 w-3.5 text-danger`}),_(`span`,{children:e.success?`Delivered`:`Failed`})]}),e.error&&_(`p`,{className:`mt-1 text-danger`,children:e.error}),t&&f(`dl`,{className:`mt-2 grid grid-cols-2 gap-x-3 gap-y-0.5 text-[11px] text-foreground-subtle`,children:[_(`dt`,{children:`Resolved level`}),_(`dd`,{className:`text-foreground`,children:t.level}),_(`dt`,{children:`Format sent`}),_(`dd`,{className:`text-foreground`,children:t.format}),_(`dt`,{children:`Attachments sent`}),_(`dd`,{className:`text-foreground`,children:t.attachmentsSent}),_(`dt`,{children:`Actions sent`}),_(`dd`,{className:`text-foreground`,children:t.actionsSent}),_(`dt`,{children:`Truncated`}),_(`dd`,{className:`text-foreground`,children:t.truncated?`yes`:`no`}),_(`dt`,{children:`Dropped`}),_(`dd`,{className:`text-foreground`,children:t.dropped.length>0?t.dropped.join(`, `):`—`})]})]})}function K(e){let t=[],n=new Map;for(let r of e){let e=n.get(r.addonId);e?e.push(r):(n.set(r.addonId,[r]),t.push(r.addonId))}return t.map(e=>({addonId:e,kinds:n.get(e)??[]}))}function q(e){let t=[],n=e=>{for(let r of e){if(r.type===`password`){t.push(r.key);continue}if(r.type===`group`){n(r.fields);continue}if(r.type===`sub-tabs`)for(let e of r.tabs)n(e.fields)}};for(let t of e.sections)n(t.fields);return t}function J(e,t,n){let r=new Set(n),i={};for(let[n,a]of Object.entries(e)){if(!r.has(n)){i[n]=a;continue}a==null||a===``||a!==t[n]&&(i[n]=a)}return i}function Y(e,t){let n=new Set(t),r={};for(let[t,i]of Object.entries(e))r[t]=n.has(t)?``:i;return r}d();var X=[`notificationOutput`,`listTargets`],Z=[`notificationOutput`,`listTargetKinds`];function Q(){let e=v(),[t,n]=h({mode:`closed`}),[a,o]=h(null),u=m({queryKey:X,queryFn:()=>e.trpcClient.notificationOutput.listTargets.query({})}),d=m({queryKey:Z,queryFn:async()=>(await e.trpcClient.notificationOutput.listTargetKinds.query({})).map(e=>({...e,configSchema:e.configSchema}))}),y=p(()=>d.data??[],[d.data]),S=p(()=>{let e=new Map;for(let t of y)e.set(t.kind,t);return e},[y]),C=g({mutationFn:t=>e.trpcClient.notificationOutput.setTargetEnabled.mutate({addonId:t.target.addonId,targetId:t.target.id,enabled:t.enabled}),onSuccess:()=>void u.refetch()}),w=g({mutationFn:t=>e.trpcClient.notificationOutput.deleteTarget.mutate({addonId:t.addonId,targetId:t.id}),onSuccess:()=>void u.refetch()}),A=a?S.get(a.kind):void 0;return f(O,{icon:D,title:`Notification Targets`,subtitle:`Deliver notifications to ntfy, Pushover, Telegram, Home Assistant and more. Each target's kind declares its capabilities; the test panel shows exactly what a message degrades to.`,actions:f(i,{size:`sm`,type:`button`,onClick:()=>n({mode:`pick-kind`}),children:[_(x,{className:`h-3.5 w-3.5`}),`Add target`]}),children:[u.isLoading&&_(`div`,{className:`flex items-center justify-center py-16`,children:_(T,{className:`h-6 w-6 animate-spin text-primary`})}),u.isError&&!u.isLoading&&_(l,{title:`Failed to load targets`,message:u.error instanceof Error?u.error.message:`Unknown error`,onRetry:()=>void u.refetch()}),!u.isLoading&&!u.isError&&(u.data??[]).length===0&&_(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:`No notification targets yet. Click "Add target" to configure one.`}),(u.data??[]).length>0&&_(s,{children:_(`ul`,{className:`divide-y divide-border`,children:(u.data??[]).map(e=>{let t=S.get(e.kind);return f(`li`,{className:`flex items-center gap-3 px-4 py-2.5`,children:[_(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface text-xs`,title:t?.label??e.kind,children:t?.icon??`🔔`}),f(`div`,{className:`min-w-0 flex-1`,children:[_(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),_(`div`,{className:`text-[11px] text-foreground-subtle`,children:t?.label??e.kind})]}),!e.enabled&&_(r,{variant:`warning`,children:`disabled`}),_(c,{checked:e.enabled,onCheckedChange:t=>C.mutate({target:e,enabled:t}),"aria-label":`toggle ${e.name}`}),_(i,{size:`sm`,variant:`ghost`,type:`button`,disabled:!t,onClick:()=>o(e),title:`Test`,children:_(k,{className:`h-3.5 w-3.5`})}),_(i,{size:`sm`,variant:`ghost`,type:`button`,disabled:!t,onClick:()=>t&&n({mode:`form`,kind:t,target:e}),title:`Edit`,children:_(b,{className:`h-3.5 w-3.5`})}),_(i,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>w.mutate(e),title:`Delete`,children:_(E,{className:`h-3.5 w-3.5 text-danger`})})]},e.id)})})}),t.mode===`pick-kind`&&_($,{kinds:y,onCancel:()=>n({mode:`closed`}),onPick:e=>n({mode:`form`,kind:e,target:null})}),t.mode===`form`&&_(ee,{kind:t.kind,target:t.target,onCancel:()=>n({mode:`closed`}),onSaved:()=>{n({mode:`closed`}),u.refetch()}}),a&&A&&_(W,{target:a,kind:A,open:!0,onClose:()=>o(null)})]})}function $({kinds:e,onPick:t,onCancel:n}){let a=p(()=>K(e),[e]);return f(s,{className:`p-4 space-y-4`,children:[f(`div`,{className:`flex items-center justify-between`,children:[_(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Choose a notification kind`}),_(i,{size:`sm`,variant:`ghost`,type:`button`,onClick:n,children:`Cancel`})]}),a.length===0&&_(`p`,{className:`text-xs text-foreground-subtle`,children:`No notification providers are installed. Install the notifiers addon (or connect Home Assistant) to add targets.`}),a.map(e=>f(`div`,{children:[_(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1.5`,children:e.addonId}),_(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-2`,children:e.kinds.map(n=>f(`button`,{type:`button`,onClick:()=>t(n),className:`flex flex-col items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-3 text-xs hover:border-primary/50 hover:bg-surface-hover transition-colors`,children:[_(`span`,{className:`text-lg`,children:n.icon}),_(`span`,{className:`font-medium text-foreground`,children:n.label}),n.supportsDiscovery&&_(r,{variant:`info`,style:`outline`,children:`discover`})]},`${e.addonId}:${n.kind}`))})]},e.addonId))]})}function ee({kind:e,target:t,onSaved:n,onCancel:r}){let a=v(),c=p(()=>q(e.configSchema),[e.configSchema]),l=p(()=>t?.config??{},[t]),[u,d]=h(t?.name??e.label),[m,y]=h(()=>t?Y(t.config,c):{}),[b,x]=h(null),[C,w]=h(null),E=g({mutationFn:()=>a.trpcClient.notificationOutput.discoverTargets.query({addonId:e.addonId,kind:e.kind,config:m}),onSuccess:e=>x(e),onError:e=>w(e instanceof Error?e.message:`Discovery failed`)}),D=g({mutationFn:()=>{let n=J(m,l,c),r={id:t?.id??`${e.kind}-${Date.now()}`,name:u,kind:e.kind,addonId:e.addonId,enabled:t?.enabled??!0,config:n};return a.trpcClient.notificationOutput.upsertTarget.mutate({addonId:e.addonId,target:r})},onSuccess:n,onError:e=>w(e instanceof Error?e.message:`Save failed`)}),O=e=>{d(e.suggestedName),y(t=>({...t,...e.config})),x(null)};return f(s,{className:`p-4 space-y-4`,children:[f(`div`,{className:`flex items-center justify-between`,children:[f(`h3`,{className:`text-sm font-semibold text-foreground flex items-center gap-2`,children:[_(`span`,{className:`text-lg`,children:e.icon}),t?`Edit ${t.name}`:`Add ${e.label} target`]}),_(i,{size:`sm`,variant:`ghost`,type:`button`,onClick:r,children:`Cancel`})]}),C&&_(`div`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:C}),f(`div`,{children:[_(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Name`}),_(`input`,{className:`w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none`,value:u,onChange:e=>d(e.target.value)})]}),e.supportsDiscovery&&f(`div`,{className:`space-y-2`,children:[f(i,{size:`sm`,variant:`outline`,type:`button`,disabled:E.isPending,onClick:()=>{w(null),E.mutate()},children:[E.isPending?_(T,{className:`h-3.5 w-3.5 animate-spin`}):_(S,{className:`h-3.5 w-3.5`}),`Discover`]}),b&&b.length===0&&_(`p`,{className:`text-[11px] text-foreground-subtle`,children:`No candidates discovered.`}),b&&b.length>0&&_(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:b.map((e,t)=>f(`button`,{type:`button`,onClick:()=>O(e),className:`flex w-full items-center justify-between px-3 py-1.5 text-xs hover:bg-surface-hover`,children:[_(`span`,{className:`text-foreground`,children:e.suggestedName}),_(`span`,{className:`text-[10px] text-primary`,children:`use`})]},`${e.suggestedName}-${t}`))})]}),c.length>0&&t&&_(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Secret fields are hidden. Leave them blank to keep the stored value; type a new value to replace it.`}),_(o,{schema:e.configSchema,values:m,onChange:y}),f(`div`,{className:`flex justify-end gap-2`,children:[_(i,{variant:`secondary`,size:`sm`,type:`button`,onClick:r,children:`Cancel`}),f(i,{size:`sm`,type:`button`,disabled:D.isPending||u.trim().length===0,onClick:()=>{w(null),D.mutate()},children:[D.isPending&&_(T,{className:`h-3.5 w-3.5 animate-spin`}),t?`Save changes`:`Create target`]})]})]})}export{Q as NotificationTargetsPage,Q as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$r as e,Ba as t,Br as n,Di as r,Hr as i,Ir as a,Jr as o,Kr as s,Ma as c,Oi as l,Ra as u,Rr as d,T as f,Ur as p,Vr as m,Wr as h,Xr as g,Yr as _,Zr as v,_ as y,_i as b,aa as x,ai as S,bi as C,ci as w,di as T,ea as E,fa as D,g as O,gi as k,ia as A,ii as j,ji as ee,ki as te,la as ne,li as M,lt as N,ni as P,oa as re,oi as ie,ot as ae,pa as oe,qr as se,ri as ce,sa as le,si as ue,st as de,ua as fe,ui as pe,vi as me,zr as he}from"./src-ojhqTnBF.js";import{I as ge,K as _e,Q as F,S as I,T as ve,W as L,a as ye,b as R,o as z,q as B,x as V,z as H}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{H as be,L as xe,R as Se}from"./src-D5vrhmeM.js";import{p as Ce}from"./player-overlays-BrMuuVRR.js";import{t as we}from"./download-BFNY5_CW.js";import{i as Te,n as Ee,r as De,t as Oe}from"./AddLocationWizard-DH1zgXau.js";import{n as ke,r as Ae,t as je}from"./zap-BWxQNiSd.js";import{i as Me,r as Ne}from"./useDevice-BQkNwlm7.js";import{t as Pe}from"./pencil-DedPunTk.js";import{t as Fe}from"./plus-r3Kz9Nsb.js";import{t as Ie}from"./radio-BM7T2fMm.js";import{t as Le}from"./refresh-cw-CC8OysCP.js";import{t as Re}from"./search-GJrj432A.js";import{t as ze}from"./square-check-big-B5WFnMH6.js";import{t as Be}from"./square-DXUXUdD9.js";import{A as U,F as Ve,H as W,I as He,K as Ue,M as We,N as Ge,S as G,T as Ke,i as qe,j as Je,o as Ye,p as Xe,s as Ze,x as Qe}from"./index-3DCschCe.js";import{t as $e}from"./AdminPage-BwmGKnRf.js";import{t as K}from"./useEventInvalidation-BBDMvWpm.js";import{r as et,t as tt}from"./build-cluster-graph-BPT-sggI.js";import{n as nt}from"./format-size-CO9d3C3-.js";import{t as rt}from"./NodeAddonsSettingsPanel-DTo_3cuU.js";var it=W(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),at=W(`film`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M3 7.5h4`,key:`zfgn84`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`path`,{d:`M3 16.5h4`,key:`1230mu`}],[`path`,{d:`M17 3v18`,key:`in4fa5`}],[`path`,{d:`M17 7.5h4`,key:`myr1c1`}],[`path`,{d:`M17 16.5h4`,key:`go4c1d`}]]),ot=W(`flame`,[[`path`,{d:`M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z`,key:`96xj49`}]]),st=W(`lock-open`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`,key:`1mm8w8`}]]),ct=W(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]);F();function lt(e){return e}function ut(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function dt(e,t){return typeof e==`boolean`?e:lt(t)}function ft(e,t){return{pipeline:dt(ut(e,`detect`),t),audio:dt(ut(e,`audio`),t),ingest:dt(ut(e,`ingest`),t)}}function pt(e,t,n){let r=e?.find(e=>e.nodeId===t);return ft(r?.settings,n)}function mt({selectedNodeId:e,onSelect:n,refreshToken:r}){let{data:i}=a(void 0),{data:o}=P(void 0),{data:s}=ce(void 0),l=new Map;for(let e of o??[])l.set(e.agentNodeId,(l.get(e.agentNodeId)??0)+1);let u=i??[],d=u.filter(e=>e.isOnline).length,f=u.filter(e=>!e.isOnline).length;return I(`div`,{className:`flex flex-col h-full`,children:[I(`button`,{type:`button`,onClick:()=>n(kr),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${e===`__cluster__`?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[V(Ke,{className:`h-4 w-4 flex-shrink-0`}),I(`div`,{className:`min-w-0 flex-1`,children:[V(`div`,{className:`text-xs font-semibold truncate`,children:`Cluster`}),V(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Balancer + failover + assignments`})]})]}),V(`div`,{className:`flex-1 overflow-y-auto`,children:u.map(r=>{let i=e===r.id,a=l.get(r.id)??0,o=r.isHub?Xe:U,u=pt(s,r.id,r.isHub),d=r.isOnline?null:t(et(r.lastSeen));return I(`button`,{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 ${i?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${r.isOnline?``:` opacity-60`}`,children:[V(o,{className:`h-4 w-4 flex-shrink-0`}),I(`div`,{className:`min-w-0 flex-1`,children:[I(`div`,{className:`flex items-center gap-2`,children:[V(`span`,{className:`text-xs font-semibold truncate`,children:r.name}),r.isHub&&V(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`}),!r.isOnline&&V(`span`,{className:`h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0`}),r.isOnline&&V(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),I(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[I(`span`,{children:[r.cpuCores,` cores`]}),V(`span`,{children:`•`}),I(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),a>0&&I(R,{children:[V(`span`,{children:`•`}),I(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[V(ke,{className:`h-2.5 w-2.5`}),a]})]}),!r.isOnline&&I(R,{children:[V(`span`,{children:`•`}),I(`span`,{className:`text-destructive`,children:[`offline`,d===null?``:` · ${d}`]})]})]}),I(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[V(c,{variant:u.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:u.pipeline?`Pipeline: enabled`:`Pipeline: not enabled (agent capability)`,children:`Pipe`}),V(c,{variant:u.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:u.audio?`Audio: enabled`:`Audio: not enabled (agent capability)`,children:`Aud`})]})]})]},r.id)})}),I(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[I(`span`,{children:[d,` online`]}),f>0&&I(`span`,{className:`text-destructive`,children:[f,` offline`]})]})]})}function ht({nodeId:e,refreshToken:t}){let{data:n}=a(void 0),r=n?.find(t=>t.id===e),i=x(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return r?I(`div`,{className:`px-6 py-4 border-b border-border`,children:[I(`div`,{className:`flex items-center gap-2 mb-1`,children:[V(`h2`,{className:`text-base font-semibold text-foreground`,children:r.name}),r.isOnline?V(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:`online`}):V(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`}),r.isHub&&V(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`})]}),I(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[V(`span`,{children:r.cpuModel??`CPU`}),V(`span`,{children:`•`}),I(`span`,{children:[r.cpuCores,` cores`]}),V(`span`,{children:`•`}),I(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),i&&I(R,{children:[V(`span`,{children:`•`}),I(`span`,{children:[i.attachedCameras,` cameras (`,i.activeCameras,` active)`]}),V(`span`,{children:`•`}),I(`span`,{children:[i.avgInferenceTimeMs.toFixed(0),`ms avg inference`]}),V(`span`,{children:`•`}),I(`span`,{children:[`queue `,i.queueDepthTotal]}),i.hardware.hasGpu&&I(R,{children:[V(`span`,{children:`•`}),V(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):V(`div`,{className:`px-6 py-4 border-b border-border`,children:I(`div`,{className:`text-xs text-foreground-subtle`,children:[`Node not found: `,e]})})}function gt({refreshToken:e,nodeId:t}){let[n,r]=B(new Map),{nodes:i}=A();le(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&r(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:a}=v(void 0),o=L(()=>{let e=new Map;for(let t of a??[])e.set(t.nodeId,t.deviceCount);return e},[a]),s=L(()=>{let e=new Map,t=Date.now()-3e4;for(let r of n.values()){if(r.timestamp<t)continue;let n=r.nodeId??`hub`,i=e.get(n)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,r.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=r.metrics.actualFps,i.totalInferenceWeighted+=r.metrics.avgInferenceTimeMs,i.queueDepth+=r.metrics.queueDepth,e.set(n,i)}return e},[n]),c=L(()=>{let e=new Map;for(let t of i)e.set(t.id,t.shortName);return e},[i]),l=L(()=>{let e=0,t=0,n=0,r=0,a=0;for(let i of s.values())e+=i.attachedCameras,t+=i.activeCameras,n+=i.totalFps,r+=i.totalInferenceWeighted,a+=i.queueDepth;let o=e>0?r/e:0;return{totalAgents:i.length,onlineAgents:i.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:o,queueDepth:a,totalFps:n}},[s,i]);if(t){let e=s.get(t);return I(`div`,{className:`@container/liveload`,children:[V(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),I(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[V(q,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),V(q,{label:`Active / Attached`,value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),V(q,{label:`Avg infer ms`,value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),V(q,{label:`Queue`,value:e?String(e.queueDepth):`—`}),V(q,{label:`Audio`,value:String(o.get(t)??`—`)})]})]})}let u=[...s.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return I(`div`,{className:`@container/liveload`,children:[V(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),I(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[V(q,{label:`Total agents`,value:`${l.onlineAgents}/${l.totalAgents}`}),V(q,{label:`Active / Attached`,value:`${l.activeCameras}/${l.attachedCameras}`}),V(q,{label:`Total FPS`,value:l.totalFps.toFixed(1)}),V(q,{label:`Avg inference ms`,value:l.avgInferenceTimeMs.toFixed(0)}),V(q,{label:`Queue depth`,value:String(l.queueDepth)})]}),V(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:I(`table`,{className:`w-full text-xs min-w-[480px]`,children:[V(`thead`,{className:`bg-surface`,children:I(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[V(`th`,{className:`text-left px-3 py-2`,children:`Agent`}),V(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),V(`th`,{className:`text-right px-3 py-2`,children:`Cameras`}),V(`th`,{className:`text-right px-3 py-2`,children:`Inference ms`}),V(`th`,{className:`text-right px-3 py-2`,children:`Queue`}),V(`th`,{className:`text-right px-3 py-2`,children:`Audio`})]})}),I(`tbody`,{children:[u.map(([e,t])=>I(`tr`,{className:`border-t border-border`,children:[V(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:c.get(e)??e}),V(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.totalFps.toFixed(1)}),V(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras}),V(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),V(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.queueDepth}),V(`td`,{className:`px-3 py-2 text-right text-foreground`,children:o.get(e)??`—`})]},e)),u.length===0&&V(`tr`,{children:V(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No camera metrics received yet`})})]})]})})]})}function q({label:e,value:t}){return I(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[V(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:e}),V(`div`,{className:`text-lg font-semibold text-foreground`,children:t})]})}F();var _t={active:!1,pinned:!1,nodeId:null,reason:``},vt=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`],yt={pipeline:U,decoder:at,audio:Ae},bt={pipeline:`Pipeline`,decoder:`Decoder`,audio:`Audio`};function xt({mode:t,nodeId:n,compact:r=!1}){if(t===`agent`&&!n)throw Error(`CameraAssignmentsTable: nodeId is required when mode === "agent"`);let i=z(),[a,o]=B(null),[c,l]=B(null),[u,d]=B(new Map);K([`pipelineOrchestrator`,`getPipelineAssignments`],vt),K([`pipelineOrchestrator`,`getAudioAssignments`],vt),K([`pipelineOrchestrator`,`getCameraStatuses`],vt);let{data:p}=P(void 0),{data:m}=g(void 0),{data:h}=e({},{enabled:t===`agent`}),{nodes:_}=A(),{data:v}=Ne();le(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t.deviceId==`number`&&d(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})}),H(()=>{if(u.size===0)return;let e=setInterval(()=>{d(e=>{let t=Date.now()-1e4,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},5e3);return()=>clearInterval(e)},[u.size]);let y=L(()=>{let e=new Map;for(let t of v??[])e.set(t.id,t.name);return e},[v]),x=L(()=>{if(t===`agent`){let e=[];for(let t of h??[]){let r=t.assignment,i=(e,t,r)=>({active:e!==null&&e===n,pinned:t,nodeId:e,reason:r??``}),a=i(r.detectionNodeId,r.pinned.detection,r.reasons.detection),o=i(r.decoderNodeId,r.pinned.decoder,r.reasons.decoder),s=i(r.audioNodeId,r.pinned.audio,r.reasons.audio);!a.active&&!o.active&&!s.active||e.push({deviceId:t.deviceId,deviceName:y.get(t.deviceId)??`Device ${t.deviceId}`,pipeline:a,decoder:o,audio:s})}return e.sort((e,t)=>e.deviceId-t.deviceId),e}let e=new Map,r=t=>{let n=e.get(t);if(n)return n;let r={deviceId:t,deviceName:y.get(t)??`Device ${t}`,pipeline:_t,decoder:_t,audio:_t};return e.set(t,r),r};for(let i of p??[]){let a=r(i.deviceId);e.set(i.deviceId,{...a,pipeline:{active:!0,pinned:i.pinned,nodeId:i.agentNodeId,reason:i.reason??``},decoder:{active:t===`cluster`?!0:i.agentNodeId===n,pinned:!1,nodeId:i.agentNodeId,reason:`co-located`}})}for(let t of m??[]){let n=r(t.deviceId);e.set(t.deviceId,{...n,audio:{active:!0,pinned:t.pinned,nodeId:t.nodeId,reason:`capacity`}})}let i=[...e.values()];return i.sort((e,t)=>e.deviceId-t.deviceId),i},[p,m,h,y,t,n]),S=L(()=>(_??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[_]),C=()=>{i.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),i.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]}),i.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},w=se({onSuccess:C}),T=b({onSuccess:C}),E=s({onSuccess:C}),D=k({onSuccess:C}),O=(e,t,n)=>{t===`pipeline`?w.mutate({deviceId:e,agentNodeId:n}):E.mutate({deviceId:e,nodeId:n}),o(null)},j=(e,t)=>{t===`pipeline`?T.mutate({deviceId:e}):D.mutate({deviceId:e}),o(null)};return V(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:I(`table`,{className:`w-full text-xs min-w-[760px] table-fixed`,children:[V(`thead`,{className:`bg-surface`,children:I(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[!r&&V(`th`,{className:`w-10`}),V(`th`,{className:`min-w-[200px] text-left px-3 py-2 align-middle`,children:`Camera`}),t===`cluster`?I(R,{children:[V(`th`,{className:`w-[168px] text-left px-3 py-2 align-middle`,children:`Auto | Pin`}),V(`th`,{className:`w-[188px] text-left px-3 py-2 align-middle`,children:`Resolved placement`})]}):I(R,{children:[V(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Pipeline`}),V(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Decoder`}),V(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Audio`})]}),V(`th`,{className:`w-[132px] text-left px-3 py-2 align-middle`,children:`Status`})]})}),I(`tbody`,{children:[x.map(e=>{let n=u.get(e.deviceId),i=c===e.deviceId;return I(ve.Fragment,{children:[I(`tr`,{className:`border-t border-border align-middle relative`,children:[!r&&V(`td`,{className:`px-2 py-2 align-middle`,children:V(`button`,{type:`button`,onClick:()=>l(i?null:e.deviceId),className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":i?`Collapse broker details`:`Expand broker details`,children:V(i?Ve:Ge,{className:`h-3.5 w-3.5`})})}),I(`td`,{className:`px-3 py-2 align-middle min-w-0`,children:[V(`div`,{className:`text-foreground font-medium leading-tight line-clamp-2 break-words`,title:e.deviceName,children:e.deviceName}),I(`div`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[`#`,e.deviceId]})]}),t===`cluster`?I(R,{children:[V(`td`,{className:`px-3 py-2 align-middle`,children:V(St,{state:e.pipeline,onlineNodes:S,pending:w.isPending||T.isPending,onChange:t=>{t===`auto`?j(e.deviceId,`pipeline`):O(e.deviceId,`pipeline`,t)}})}),V(`td`,{className:`px-3 py-2 align-middle`,children:V(Ct,{state:e.pipeline})})]}):I(R,{children:[V(wt,{role:`pipeline`,state:e.pipeline,mode:t,deviceId:e.deviceId,onlineNodes:S,isMenuOpen:a?.deviceId===e.deviceId&&a.role===`pipeline`,onToggleMenu:()=>o(a?.deviceId===e.deviceId&&a.role===`pipeline`?null:{deviceId:e.deviceId,role:`pipeline`}),onCloseMenu:()=>o(null),onMove:t=>O(e.deviceId,`pipeline`,t),onUnpin:()=>j(e.deviceId,`pipeline`)}),V(wt,{role:`decoder`,state:e.decoder,mode:t,deviceId:e.deviceId,onlineNodes:S,readOnly:!0,isMenuOpen:!1,onToggleMenu:()=>void 0,onCloseMenu:()=>void 0,onMove:()=>void 0,onUnpin:()=>void 0}),V(wt,{role:`audio`,state:e.audio,mode:t,deviceId:e.deviceId,onlineNodes:S,isMenuOpen:a?.deviceId===e.deviceId&&a.role===`audio`,onToggleMenu:()=>o(a?.deviceId===e.deviceId&&a.role===`audio`?null:{deviceId:e.deviceId,role:`audio`}),onCloseMenu:()=>o(null),onMove:t=>O(e.deviceId,`audio`,t),onUnpin:()=>j(e.deviceId,`audio`)})]}),V(`td`,{className:`px-3 py-2 align-middle`,children:V(Ot,{snap:n})})]}),i&&!r&&I(`tr`,{className:`bg-surface/50`,children:[V(`td`,{}),V(`td`,{colSpan:t===`cluster`?4:5,className:`px-3 py-2`,children:V(f,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:e.deviceId,instanceId:`pipeline-row/${e.deviceId}`,config:{variant:`compact`,title:`Stream brokers & clients`}})})]})]},e.deviceId)}),x.length===0&&V(`tr`,{children:V(`td`,{colSpan:r?t===`cluster`?4:5:t===`cluster`?5:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:t===`agent`?`No cameras assigned to this node`:`No cameras currently assigned`})})]})]})})}function St({state:e,onlineNodes:t,pending:n,onChange:r}){let i=e.pinned&&e.nodeId?e.nodeId:`auto`,a=[...new Set([...e.nodeId?[e.nodeId]:[],...t.map(e=>e.id)])];return I(`select`,{value:i,disabled:n,"aria-label":`Pipeline placement pin`,onChange:e=>r(e.target.value),className:`w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground`,children:[V(`option`,{value:`auto`,children:`Auto`}),a.map(e=>I(`option`,{value:e,children:[`Pin → `,t.find(t=>t.id===e)?.name??e]},e))]})}function Ct({state:e}){if(!e.active||!e.nodeId)return V(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`});let t=e.pinned?`pinned · manual`:`auto · ${e.reason||`capacity`}`;return I(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[V(`span`,{className:`font-mono text-[11px] text-foreground truncate`,title:e.nodeId,children:e.nodeId}),V(`span`,{className:`truncate ${e.pinned?`text-amber-400 text-[10px]`:`text-foreground-subtle text-[10px]`}`,title:t,children:t})]})}function wt({role:e,state:t,mode:n,onlineNodes:r,readOnly:i=!1,isMenuOpen:a,onToggleMenu:o,onCloseMenu:s,onMove:c,onUnpin:l}){let u=yt[e],d=r.filter(e=>e.id!==(t.nodeId??``)),f=!i&&(t.active||n===`cluster`)&&(d.length>0||t.pinned);return I(`td`,{className:`px-3 py-2 align-middle relative min-w-0`,children:[I(`div`,{className:`flex items-center gap-2 min-w-0`,children:[V(n===`agent`?Tt:Et,{state:t,Icon:u}),V(`div`,{className:`ml-auto shrink-0`,children:f&&V(`button`,{type:`button`,onClick:o,className:`p-1 rounded hover:bg-surface-hover`,"aria-label":`${bt[e]} actions`,children:V(it,{className:`h-3 w-3 text-foreground-subtle`})})})]}),a&&f&&V(kt,{title:bt[e],targets:d,pinned:t.pinned,onMove:c,onUnpin:l,onClose:s})]})}function Tt({state:e,Icon:t}){return I(`div`,{className:`flex items-center gap-1.5`,children:[V(e.active?ze:Be,{className:`h-3.5 w-3.5 ${e.active?`text-success`:`text-foreground-subtle/50`}`}),V(t,{className:`h-3 w-3 ${e.active?`text-foreground-subtle`:`text-foreground-subtle/40`}`}),e.pinned&&V(ct,{className:`h-2.5 w-2.5 text-amber-400`})]})}function Et({state:e,Icon:t}){return!e.active||!e.nodeId?I(`div`,{className:`flex items-center gap-1.5 text-foreground-subtle/60`,children:[V(t,{className:`h-3 w-3`}),V(`span`,{className:`text-[10px] italic`,children:`—`})]}):I(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[V(t,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),I(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[V(`span`,{className:`font-mono text-[11px] text-foreground truncate`,children:e.nodeId}),V(`span`,{className:`flex items-center gap-1 text-[10px]`,children:e.pinned?I(`span`,{className:`inline-flex items-center gap-0.5 text-amber-400`,children:[V(ct,{className:`h-2.5 w-2.5`}),` manual`]}):I(`span`,{className:`text-foreground-subtle truncate`,children:[`auto · `,e.reason||`capacity`]})})]})]})}var Dt=`min-h-[3.25rem]`;function Ot({snap:e}){if(!e)return V(`div`,{className:`flex items-center ${Dt}`,children:V(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`})});let{phase:t,actualFps:n,avgInferenceTimeMs:r,queueDepth:i,configuredFps:a,droppedFrames:o}=e.metrics,s=u(t);return I(`div`,{className:`flex flex-col justify-center gap-0.5 font-mono text-[10px] tabular-nums leading-tight min-w-0 ${Dt}`,children:[I(`span`,{className:`inline-flex items-center gap-1 min-w-0 ${s.textColor}`,children:[V(y,{phase:t,className:`h-2.5 w-2.5 shrink-0`}),V(`span`,{className:`font-semibold uppercase tracking-wider truncate`,children:s.label})]}),I(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[V(`span`,{className:`text-foreground`,children:n.toFixed(1)}),I(`span`,{children:[`/`,a.toFixed(0),` fps`]})]}),I(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[V(`span`,{className:`text-foreground`,children:r.toFixed(0)}),V(`span`,{children:` ms`}),i>0&&I(`span`,{className:`text-warning ml-1`,children:[`q`,i]})]}),I(`span`,{className:`whitespace-nowrap truncate ${o>0?`text-warning`:`text-foreground-subtle`}`,children:[`drops `,V(`span`,{className:`text-foreground`,children:o})]})]})}function kt({title:e,targets:t,pinned:n,onMove:r,onUnpin:i,onClose:a}){let o=_e(null);return H(()=>{let e=e=>{o.current?.contains(e.target)||a()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[a]),I(`div`,{ref:o,className:`absolute right-2 top-full mt-1 w-48 rounded-lg border border-border bg-surface shadow-lg z-20 text-left`,children:[V(`div`,{className:`px-3 py-1 text-[9px] uppercase tracking-wider text-foreground-subtle border-b border-border`,children:e}),t.length>0&&V(`div`,{className:`py-1`,children:t.map(e=>I(`button`,{type:`button`,onClick:()=>r(e.id),className:`block w-full text-left px-3 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[`Move to `,e.name]},e.id))}),n&&I(`button`,{type:`button`,onClick:i,className:`block w-full text-left px-3 py-1.5 text-[11px] text-destructive hover:bg-destructive/10 border-t border-border`,children:[`Unpin `,e.toLowerCase()]}),t.length===0&&!n&&V(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle italic`,children:`Already auto · no other nodes online`})]})}function At({nodeId:e,refreshToken:t}){return I(`div`,{className:`space-y-6`,children:[V(gt,{refreshToken:t,nodeId:e}),I(`div`,{children:[V(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Cameras on this node`}),I(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`Checkboxes mark the roles currently running on `,e,`. Use the kebab to move a role to another node or unpin it; live KPIs come from the runner snapshot stream.`]})]}),V(xt,{mode:`agent`,nodeId:e,compact:!0})]})}F();function jt(e,t){let n=Math.max(0,t-e);return`${Math.floor(e/1e3)}s idle · ${Math.floor(n/1e3)}s left`}function Mt({nodeId:e,refreshToken:t}){let n=z(),r=p({onSettled:()=>{n.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:i}=h({nodeId:e}),a=x(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??i??null,o=a===null;K([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:s}=C({nodeId:e}),{values:c}=re(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),l=L(()=>c.filter(e=>e.metrics.phase===`active`).length,[c]),u=t=>{let n=s??[];n.length>0&&!window.confirm(`${n.length} camera(s) are dispatching through this engine. Killing it forces a respawn on the next frame. Continue?`)||r.mutate({nodeId:e,engine:t,force:n.length>0})};return I(`div`,{className:`space-y-6`,children:[I(`div`,{children:[V(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Inference engines on this node`}),I(`p`,{className:`text-[11px] text-foreground-subtle`,children:[(a??[]).length,` engine(s) resident in RAM. `,(s??[]).length,` `,`camera(s) attached, `,l,` actively dispatching frames. Refreshes every 5s.`]})]}),V(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:I(`table`,{className:`w-full text-xs min-w-[640px]`,children:[V(`thead`,{className:`bg-surface`,children:I(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[V(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Kind`}),V(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Runtime / Backend / Device`}),V(`th`,{className:`text-left px-3 py-2`,children:`Models`}),V(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Pool PID`}),V(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Auto-kill`}),V(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`In use`}),V(`th`,{className:`w-20`})]})}),I(`tbody`,{children:[o&&V(`tr`,{children:V(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`Loading…`})}),!o&&(a??[]).map(e=>{let t=e.kind===`warm-override`;return I(`tr`,{className:`border-t border-border ${t?`bg-amber-500/5`:``}`,children:[V(`td`,{className:`px-3 py-2`,children:I(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${t?`bg-amber-500/15 text-amber-400`:`bg-success/15 text-success`}`,children:[V(t?ot:U,{className:`h-3 w-3`}),t?`warm`:`runtime`]})}),V(`td`,{className:`px-3 py-2`,children:I(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[V(je,{className:`h-3 w-3`}),e.engine.runtime,`/`,e.engine.backend,e.engine.device?`/${e.engine.device}`:``,e.engine.format?` · ${e.engine.format}`:``]})}),V(`td`,{className:`px-3 py-2`,children:e.modelsLoaded.length===0?V(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):V(`div`,{className:`flex flex-wrap gap-1`,children:e.modelsLoaded.map(e=>V(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),V(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.poolPid??`—`}),V(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:e.idleMs!==null&&e.idleTtlMs!==null?V(`span`,{className:`text-foreground-subtle`,children:jt(e.idleMs,e.idleTtlMs)}):V(`span`,{className:`text-foreground-subtle/50`,children:`never`})}),V(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t?`—`:(s??[]).length}),V(`td`,{className:`px-3 py-2 text-right`,children:I(`button`,{type:`button`,disabled:r.isPending,onClick:()=>u(e.engine),className:`inline-flex items-center gap-1 px-2 py-1 rounded border border-destructive/30 text-destructive text-[11px] hover:bg-destructive/10 disabled:opacity-50`,children:[V(Ze,{className:`h-3 w-3`}),`Kill`]})})]},e.engineKey)}),!o&&(a??[]).length===0&&V(`tr`,{children:V(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No engines resident — the factory spins up on the first pipeline run.`})})]})]})}),I(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:[V(`strong`,{className:`text-foreground`,children:`runtime`}),`: main camera-serving engine; never auto-killed while cameras attached. `,V(`strong`,{className:`text-foreground`,children:`warm`}),`: benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL.`]}),r.isError&&I(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[`Kill failed:`,` `,r.error instanceof Error?r.error.message:`unknown`]})]})}F();var Nt=new Set(be);function Pt(e){return Nt.has(e)}function Ft(e,t,n){return`${e}/${t}/${n}`}function It(e){return{coreml:`CoreML`,openvino:`OpenVINO`,onnx:`ONNX`}[e.format]??e.format.toUpperCase()}function Lt(e){return{coreml:`Apple Neural Engine / GPU — .mlpackage`,openvino:`Intel CPU / GPU / NPU — .xml`,onnx:`CPU, CUDA, Node.js — .onnx`}[e.format]??`.${e.format}`}function J(e){return e.format}function Rt(e,t){let n=0,r=0,i=0;for(let a of e)for(let e of a.addons)for(let a of e.models){let e=a.formats[t];e&&(n++,e.downloaded&&(r++,i+=e.sizeMB))}return{total:n,downloaded:r,downloadedSizeMB:i}}function zt({addonId:e,model:t,format:n,isActive:r,progress:i,errorMsg:a,onDownload:o,onDelete:s}){let c=t.formats[n];return c?I(`div`,{className:`flex items-center gap-3 px-4 py-3 border-b border-border/50 last:border-b-0 hover:bg-surface-hover/30 transition-colors`,children:[V(`div`,{className:`h-2 w-2 rounded-full shrink-0 ${c.downloaded?`bg-success`:`bg-foreground-subtle/30`}`}),I(`div`,{className:`flex-1 min-w-0`,children:[I(`div`,{className:`flex items-center gap-2`,children:[V(`span`,{className:`text-sm font-medium text-foreground`,children:t.name}),I(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`(`,t.id,`)`]})]}),i&&i.progress>=0&&i.progress<100&&I(`div`,{className:`mt-1.5 flex items-center gap-2 max-w-xs`,children:[V(`div`,{className:`flex-1 h-1 bg-surface-hover rounded-full overflow-hidden`,children:V(`div`,{className:`bg-primary h-full rounded-full transition-all duration-300`,style:{width:`${i.progress}%`}})}),I(`span`,{className:`text-[9px] text-primary font-mono tabular-nums shrink-0`,children:[Math.round(i.progress),`%`]})]})]}),V(`span`,{className:`text-xs text-foreground-subtle tabular-nums shrink-0`,children:nt(c.sizeMB)}),a&&I(`span`,{className:`flex items-center gap-1 text-[10px] text-danger max-w-[160px] truncate shrink-0`,title:a,children:[V(We,{className:`h-3 w-3 shrink-0`}),a]}),c.downloaded?I(`button`,{onClick:s,disabled:r,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md border border-danger/30 text-danger hover:bg-danger/10 disabled:opacity-50 transition-colors shrink-0`,children:[r?V(G,{className:`h-3 w-3 animate-spin`}):V(Ze,{className:`h-3 w-3`}),r?`Deleting...`:`Delete`]}):I(`button`,{onClick:o,disabled:r,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0`,children:[r?V(G,{className:`h-3 w-3 animate-spin`}):V(we,{className:`h-3 w-3`}),r?`Downloading...`:`Download`]})]}):null}function Bt({engines:e,activeEngine:t,viewEngine:n,onSelect:r}){let[i,a]=B(!1);return I(`div`,{className:`relative`,children:[I(`button`,{type:`button`,onClick:()=>a(!i),className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-4 py-2.5 w-full text-left hover:bg-surface-hover transition-colors`,children:[V(U,{className:`h-4 w-4 text-primary shrink-0`}),I(`div`,{className:`flex-1 min-w-0`,children:[I(`div`,{className:`flex items-center gap-2`,children:[V(`span`,{className:`text-sm font-medium text-foreground`,children:It(n)}),J(n)===J(t)&&V(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),V(`div`,{className:`text-[10px] text-foreground-subtle`,children:Lt(n)})]}),V(Ve,{className:`h-4 w-4 text-foreground-subtle transition-transform ${i?`rotate-180`:``}`})]}),i&&V(`div`,{className:`absolute top-full left-0 right-0 mt-1 rounded-lg border border-border bg-surface shadow-lg z-50 overflow-hidden`,children:e.map(e=>{let i=J(e)===J(n),o=J(e)===J(t);return I(`button`,{type:`button`,onClick:()=>{r(e),a(!1)},className:`flex items-center gap-3 px-4 py-2.5 w-full text-left transition-colors ${i?`bg-primary/5`:`hover:bg-surface-hover`}`,children:[V(U,{className:`h-4 w-4 shrink-0 ${i?`text-primary`:`text-foreground-subtle`}`}),I(`div`,{className:`flex-1`,children:[I(`div`,{className:`flex items-center gap-2`,children:[V(`span`,{className:`text-sm font-medium ${i?`text-primary`:`text-foreground`}`,children:It(e)}),o&&V(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),V(`div`,{className:`text-[10px] text-foreground-subtle`,children:Lt(e)})]}),i&&V(Je,{className:`h-4 w-4 text-primary shrink-0`})]},J(e))})})]})}function Vt({embedded:e=!1,nodeId:t}={}){let r=z(),a=t??`hub`,[o,s]=B(null),[c,l]=B(new Set),[u,f]=B(new Map),[p,h]=B(new Map),[g,_]=B(``),{data:v=[]}=n({nodeId:a}),y=v.filter((e,t,n)=>n.findIndex(t=>t.format===e.format)===t),{data:b}=i({nodeId:a}),x=b,{data:S,isLoading:C}=m({nodeId:a}),w=he(),T=d();le(`model.download.progress`,e=>{let t=e.data,n=typeof t.modelId==`string`?t.modelId:void 0,i=typeof t.progress==`number`?t.progress:void 0,a=typeof t.totalMB==`number`?t.totalMB:0;n===void 0||i===void 0||(f(e=>{let t=new Map(e);return i===100||i===-1?t.delete(n):t.set(n,{modelId:n,progress:i,totalMB:a}),t}),i===100&&r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]}))});let E=x??{runtime:`node`,backend:`cpu`,format:`onnx`},D=y.find(e=>e.format===o)??E,O=D.format,k=S?.slots??[],A=k.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(e=>e.formats[O]!==void 0)})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0),j=Rt(A,O),ee=ge(async(e,t,n)=>{if(!Pt(n))return;let i=Ft(e,t,n);l(e=>new Set([...e,i])),h(e=>{let t=new Map(e);return t.delete(i),t});try{await w.mutateAsync({addonId:e,modelId:t,format:n,nodeId:a}),r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){h(t=>new Map([...t,[i,e instanceof Error?e.message:`Download failed`]]))}finally{l(e=>{let t=new Set(e);return t.delete(i),t})}},[w,r,a]),te=ge(async(e,t,n)=>{if(!Pt(n))return;let i=Ft(e,t,n);l(e=>new Set([...e,i])),h(e=>{let t=new Map(e);return t.delete(i),t});try{await T.mutateAsync({addonId:e,modelId:t,format:n,nodeId:a}),r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){h(t=>new Map([...t,[i,e instanceof Error?e.message:`Delete failed`]]))}finally{l(e=>{let t=new Set(e);return t.delete(i),t})}},[T,r,a]),ne=ge(e=>{s(e.format)},[]),M=g.trim()?A.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(t=>t.name.toLowerCase().includes(g.toLowerCase())||t.id.toLowerCase().includes(g.toLowerCase())||e.name.toLowerCase().includes(g.toLowerCase()))})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0):A,N=I(R,{children:[C&&V(`div`,{className:`flex items-center justify-center py-16`,children:V(G,{className:`h-5 w-5 animate-spin text-foreground-subtle`})}),!C&&k.length===0&&I(`div`,{className:`flex flex-col items-center justify-center py-16 text-foreground-subtle`,children:[V(Te,{className:`h-8 w-8 mb-3 opacity-30`}),V(`span`,{className:`text-sm`,children:`No pipeline steps available`}),V(`span`,{className:`text-xs mt-1`,children:`Configure the detection pipeline to see available models.`})]}),!C&&k.length>0&&I(R,{children:[V(Bt,{engines:y,activeEngine:E,viewEngine:D,onSelect:ne}),I(`div`,{className:`flex items-center gap-4 text-xs text-foreground-subtle`,children:[I(`span`,{children:[V(`span`,{className:`font-semibold text-foreground tabular-nums`,children:j.total}),V(`span`,{className:`ml-1`,children:`compatible models`})]}),V(`span`,{className:`text-border`,children:`|`}),I(`span`,{children:[V(`span`,{className:`font-semibold text-success tabular-nums`,children:j.downloaded}),V(`span`,{className:`ml-1`,children:`downloaded`})]}),V(`span`,{className:`text-border`,children:`|`}),I(`span`,{className:`tabular-nums`,children:[nt(j.downloadedSizeMB),V(`span`,{className:`ml-1`,children:`on disk`})]})]}),j.total>5&&I(`div`,{className:`relative`,children:[V(Re,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),V(`input`,{type:`text`,value:g,onChange:e=>_(e.target.value),placeholder:`Search models...`,className:`w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-border bg-surface text-foreground placeholder:text-foreground-subtle/50 focus:outline-none focus:ring-1 focus:ring-primary`})]}),M.map(e=>{let t=e.addons.reduce((e,t)=>e+t.models.length,0),n=e.addons.reduce((e,t)=>e+t.models.filter(e=>e.formats[O]?.downloaded).length,0);return I(`div`,{children:[I(`div`,{className:`flex items-center gap-2 mb-2`,children:[V(`h2`,{className:`text-sm font-semibold text-foreground`,children:e.label}),V(`div`,{className:`flex-1 h-px bg-border`}),I(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[n,`/`,t]})]}),V(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:e.addons.map(e=>e.models.map(t=>{let n=Ft(e.id,t.id,O);return V(zt,{addonId:e.id,model:t,format:O,isActive:c.has(n),progress:u.get(t.id),errorMsg:p.get(n),onDownload:()=>ee(e.id,t.id,O),onDelete:()=>te(e.id,t.id,O)},`${e.id}/${t.id}`)}))})]},e.id)}),M.length===0&&V(`div`,{className:`text-center py-8 text-sm text-foreground-subtle`,children:g.trim()?I(R,{children:[`No models matching “`,g,`”`]}):I(R,{children:[`No models available for `,It(D),` format`]})})]})]});return e?V(`div`,{className:`space-y-4`,children:N}):V($e,{children:N})}function Ht({nodeId:e,refreshToken:t}){return V(Vt,{embedded:!0,nodeId:e})}var Ut=`pipeline-runner`,Wt=200;function Gt({nodeId:e}){return I(`div`,{className:`flex flex-col gap-3`,children:[I(`div`,{children:[V(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Runner logs`}),I(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`pipeline-runner activity on `,e,` — camera attach/detach, engine phases and pipeline errors. Streaming live; the device chip on a line tells which camera it refers to.`]})]}),V(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:V(O,{agentId:e,addonId:Ut,limit:Wt,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}F(),F();function Kt({nodeId:e,title:t}){let{data:n}=Ne(),{data:r}=P(void 0),i=L(()=>{let e=new Map;for(let t of n??[])e.set(t.id,t.name);return e},[n]),a=L(()=>{if(!e)return null;let t=new Set;for(let n of r??[])n.agentNodeId===e&&t.add(n.deviceId);return t},[e,r]),[o,s]=B(new Map);le(`pipeline.camera-metrics-snapshot`,t=>{let n=t.data;typeof n.deviceId==`number`&&(e&&n.nodeId!==e||s(e=>{let t=new Map(e);return t.set(n.deviceId,n),t}))}),H(()=>{if(o.size===0)return;let e=setInterval(()=>{s(e=>{let t=Date.now()-1e4,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},5e3);return()=>clearInterval(e)},[o.size]);let c=L(()=>{let e=[];for(let t of o.values())a&&!a.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[o,a]);return c.length===0?I(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[t??`Cameras`,`: no live snapshots yet`]}):I(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[I(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[V(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??`Cameras`}),V(`span`,{className:`text-[10px] text-foreground-subtle`,children:c.length})]}),V(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map(e=>{let t=i.get(e.deviceId)??`#${e.deviceId}`,n=u(e.metrics.phase);return I(`div`,{title:`${t} · ${n.label} · ${e.metrics.actualFps.toFixed(1)} fps · ${e.metrics.avgInferenceTimeMs.toFixed(0)}ms infer · q=${e.metrics.queueDepth}`,className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${n.badgeClass}`,children:[V(y,{phase:e.metrics.phase,className:`h-2.5 w-2.5`}),V(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:t}),V(`span`,{className:`font-mono tabular-nums`,children:e.metrics.actualFps.toFixed(1)}),V(`span`,{className:`opacity-60`,children:`fps`})]},e.deviceId)})})]})}F();var qt=[`pipeline-orchestrator`],Jt=[`decoder`],Yt=!1;function Xt(e,t){if(!e)return null;for(let n of e.slots)for(let e of n.addons)if(e.id===t)return e;return null}function Zt({nodeId:e,refreshToken:t}){let n=z(),r=E(),[i,o]=B(null),[s,c]=B(null),[l,u]=B(null),[d,f]=B(null),p=(a(void 0).data??[]).find(t=>t.id===e)?.name??e,h=m({nodeId:e},{refetchOnMount:`always`}),g=_({agentNodeId:e},{refetchOnMount:`always`}),v=()=>{n.invalidateQueries({queryKey:[[`addonSettings`]]}),n.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]}),n.invalidateQueries({queryKey:[[`pipelineExecutor`]]})},y=w({onSuccess:v}),b=ie({onSuccess:e=>{v(),f(e.effectiveModelId===null?`Reset done — model pins cleared (node offline: effective model resolves on reconnect)`:`Reset done — effective detection model: ${e.effectiveModelId} (Auto)`)}}),x=async()=>{await r({title:`Reset ${p} to hardware-aware defaults?`,message:`This clears every model pin on this node (back to Auto) and every per-camera step override scoped to it. Existing per-camera customisations on this node are lost.`,confirmLabel:`Reset`,variant:`danger`})&&(f(null),b.mutate({agentNodeId:e}))},S=h.data??null,C=g.data,T=S?.selectedEngine.format??`coreml`,O=L(()=>S?D(S):[],[S]),k=L(()=>[{agentNodeId:e,engineLabel:T}],[e,T]),A=(e,t)=>{let n=C?.addonDefaults[e];return!Xt(S,e)?.models.some(e=>!!e.formats[T])||!n?{kind:`na`}:n.enabled?{kind:`enabled`,modelId:n.modelId??`Auto`}:{kind:`disabled`}},j=i&&S?Xt(S,i.addonId):null,ee=t=>{let n=C?.addonDefaults[t]??null;o({addonId:t,agentNodeId:e}),c(n)},te=(t,n)=>{if(!C)return;let r=C.addonDefaults[t],i=Xt(S,t);if(!r&&!i)return;let a={enabled:n,modelId:r?.modelId??i?.defaultModelId??``,settings:r?.settings??{}};y.mutate({agentNodeId:e,defaults:{...C.addonDefaults,[t]:a}})},M=()=>{o(null),c(null)},N=()=>{!s||!i||!C||y.mutate({agentNodeId:e,defaults:{...C.addonDefaults,[i.addonId]:s}},{onSuccess:M})};if(h.isLoading||g.isLoading)return V(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading pipeline…`});if(h.error)return I(`div`,{className:`text-xs text-red-400`,children:[`Failed to load catalog: `,String(h.error)]});if(!S)return V(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog unavailable for this node (runner offline?).`});let P=i!==null&&j!==null&&s!==null;return I(`div`,{className:`relative h-full w-full space-y-3`,children:[I(`div`,{className:`flex items-center justify-end gap-2 text-xs`,children:[d&&V(`span`,{className:`text-emerald-400`,children:d}),b.isError&&V(`span`,{className:`text-red-400`,children:b.error instanceof Error?b.error.message:`Reset failed`}),V(`button`,{type:`button`,onClick:()=>{x()},disabled:b.isPending,className:`rounded border border-amber-500/40 bg-surface px-2 py-0.5 text-amber-300 hover:bg-surface-hover disabled:opacity-50`,title:`Clear this node's model pins (back to Auto) + per-camera overrides scoped to this node`,children:b.isPending?`Resetting…`:`Reset to default`})]}),V(Kt,{nodeId:e}),V(rt,{nodeId:e,addonIds:qt,level:`global`,sectionIds:Jt}),Yt,Yt,V(`div`,{className:P?`pr-[360px]`:``,children:O.length>0?V(ne,{tree:O,agents:k,getCellState:A,onCellClick:ee,selectedCell:i,onToggleEnabled:te}):V(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),I(oe,{open:P,onClose:M,title:j?.name??``,subtitle:i?`${i.agentNodeId} · ${T}`:``,footer:I(R,{children:[V(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:M,children:`Cancel`}),V(`button`,{type:`button`,disabled:!s||!i||y.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:N,children:y.isPending?`Saving…`:`Save`})]}),children:[y.isError&&I(`div`,{className:`mb-3 rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400`,children:[`Save failed:`,` `,y.error instanceof Error?y.error.message:String(y.error)]}),j&&s&&i&&V(fe,{mode:`agent`,addon:j,agentDefault:s,agentNodeId:i.agentNodeId,engineFormat:T,onChangeAgentConfig:e=>c(e)})]})]})}var Qt=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],$t=`decoder-nodeav`;function en({nodeId:e,refreshToken:t}){let{data:n}=a(void 0),r=n?.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.id??$t,i=[...Qt,r];return I(`div`,{className:`flex flex-col h-full`,children:[V(ht,{nodeId:e,refreshToken:t}),V(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-6`,children:V(rt,{nodeId:e,addonIds:i,level:`global`,extraTabs:[{id:`assignments`,label:`Assignments`,order:-10,content:V(At,{nodeId:e,refreshToken:t})},{id:`tree`,label:`Pipeline`,order:39,content:V(Zt,{nodeId:e,refreshToken:t})},{id:`engines`,label:`Warm instances`,order:180,content:V(Mt,{nodeId:e,refreshToken:t})},{id:`models`,label:`Models`,order:200,content:V(Ht,{nodeId:e,refreshToken:t})},{id:`logs`,label:`Logs`,order:300,content:V(Gt,{nodeId:e})}]})})]})}var tn=`pipeline-orchestrator`,nn=`recorder`,rn=`recordingNodeId`,an=[`ingestNode`,`recordingNode`,`audioNode`,`motionNode`],on=[{key:`detect`,label:`Detect`,hint:`Runs the detection pipeline (decode + inference) for assigned cameras`}];function sn(e,t){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t)return e.value}function cn(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function ln(e,t,n){let r=sn(e,t);return typeof r==`string`&&r.length>0?r:n}function un(e,t,n){let r=sn(e,t);return typeof r==`number`&&Number.isFinite(r)?r:n}function dn(e,t){let n=cn(e,t);return typeof n==`number`&&Number.isFinite(n)?n:null}function fn(e,t){let n=cn(e,t);return typeof n==`string`&&n.length>0?n:null}function pn(e){return e===`ingestNode`?`Ingest`:e===`recordingNode`?`Recording`:e===`audioNode`?`Audio`:`Motion Node`}function mn(e){return e===`ingestNode`?`Node that terminates default camera ingest`:e===`recordingNode`?`Node that owns the recorder (recording-node)`:e===`audioNode`?`Node that runs singleton audio work`:`Runs software (analyzer) motion-watch. Onboard cameras are unaffected.`}function hn(e,t){switch(t){case`detect`:return e.pipeline}}function gn(e){return e instanceof Error?e.message:`Failed to save`}function _n(e){e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listAgentSettings`]]}),e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]}),e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}function vn({capability:e,label:t,hint:n,nodeId:r,active:i,pending:a,layout:o,onToggle:s}){let c=i?`border-success/30 bg-success/15 text-success hover:bg-success/25`:`border-border bg-surface-hover text-foreground-subtle hover:bg-surface hover:text-foreground`,l=o===`card`?`w-full justify-center px-3 py-2 text-xs`:`px-2.5 py-1 text-[11px]`,u=i?He:Me;return I(`button`,{type:`button`,role:`switch`,"aria-checked":i,"aria-label":`${t} capability for ${r}`,title:`${t} — ${n}`,disabled:a,onClick:()=>s(e,!i),className:`inline-flex items-center gap-1.5 rounded-full border font-medium transition-colors disabled:opacity-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 ${c} ${l}`,children:[V(u,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":`true`}),V(`span`,{children:t})]})}function yn({node:e,emphasis:t=!1}){let n=e.isHub?Xe:U;return I(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[V(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),V(n,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),I(`div`,{className:`min-w-0`,children:[I(`div`,{className:`flex items-center gap-1.5 ${t?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[V(`span`,{className:`truncate`,children:e.name}),e.isHub&&V(c,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`hub`}),!e.isOnline&&V(c,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`offline`})]}),V(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:e.id})]})]})}F();function bn({nodeId:e,value:t,detectedHosts:n,status:r,errorMessage:i,onCommit:a}){let[o,s]=B(t??``);H(()=>{s(t??``)},[t]);let c=n[0],l=c===void 0?`auto-detect`:`auto: ${c}`,u=r===`pending`,d=o.trim(),f=d!==(t??``),p=f&&!u,m=()=>{p&&a(e,d.length>0?d:null)};return I(`div`,{className:`flex items-center gap-1.5`,children:[V(`input`,{"aria-label":`Reachable host for ${e}`,type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:l,value:o,disabled:u,onChange:e=>s(e.target.value),onBlur:m,onKeyDown:e=>{e.key===`Enter`&&m(),e.key===`Escape`&&s(t??``)},className:`w-40 rounded-md border border-border bg-background px-2.5 py-1.5 text-sm text-foreground placeholder:text-foreground-subtle focus:border-primary focus:outline-none disabled:opacity-50`}),I(`button`,{type:`button`,onClick:m,disabled:!p,"aria-label":`Save reachable host for ${e}`,title:`Save reachable host`,className:`inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1.5 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed`,children:[u?V(G,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):V(He,{className:`h-3 w-3`,"aria-hidden":`true`}),`Save`]}),!f&&!u&&r===`success`&&V(He,{className:`h-3.5 w-3.5 shrink-0 text-emerald-400`,"aria-label":`Saved`,role:`img`}),r===`error`&&V(`span`,{title:i??`Failed to save reachable host`,children:V(We,{className:`h-3.5 w-3.5 shrink-0 text-red-400`,"aria-label":i??`Failed to save reachable host`,role:`img`})})]})}function xn({label:e,children:t}){return I(`div`,{className:`flex items-center justify-between gap-3`,children:[V(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-foreground-subtle`,children:e}),t]})}function Sn({node:e,actions:t}){return I(`div`,{className:`rounded-xl border border-border bg-background p-4 space-y-4 ${e.isOnline?``:`opacity-60`}`,children:[V(yn,{node:e,emphasis:!0}),V(`div`,{className:`grid grid-cols-2 gap-2`,children:on.map(n=>V(vn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:hn(e.effective,n.key),pending:t.capabilityPending,layout:`card`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)},n.key))}),V(`div`,{className:`space-y-3 border-t border-border pt-3`,children:V(xn,{label:`Reachable host`,children:V(bn,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,status:t.reachableHostStatus(e.id),errorMessage:t.reachableHostErrorMessage(e.id),onCommit:t.onCommitReachableHost})})})]})}function Cn(){return I(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-foreground-subtle`,children:[I(`span`,{className:`inline-flex items-center gap-1.5`,children:[V(`span`,{className:`h-2.5 w-2.5 rounded-full border border-success/30 bg-success/15`}),`Active capability`]}),I(`span`,{className:`inline-flex items-center gap-1.5`,children:[V(`span`,{className:`h-2.5 w-2.5 rounded-full border border-border bg-surface-hover`}),`Idle`]}),I(`span`,{className:`inline-flex items-center gap-1.5`,children:[V(`span`,{className:`h-2 w-2 rounded-full bg-success`}),`Node online`]}),I(`span`,{className:`inline-flex items-center gap-1.5`,children:[V(`span`,{className:`h-2 w-2 rounded-full bg-danger`}),`Node offline`]})]})}function wn({nodes:e,actions:t}){return V(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:I(`table`,{className:`w-full min-w-[720px] border-collapse text-sm`,children:[V(`thead`,{children:I(`tr`,{className:`border-b border-border bg-background text-[10px] uppercase tracking-wider text-foreground-subtle`,children:[V(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Node`}),on.map(e=>V(`th`,{className:`px-3 py-3 text-center font-semibold`,children:e.label},e.key)),V(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Reachable host`})]})}),V(`tbody`,{children:e.map(e=>I(`tr`,{className:`border-b border-border last:border-b-0 transition-colors hover:bg-surface-hover/40 ${e.isOnline?``:`opacity-60`}`,children:[V(`td`,{className:`px-4 py-3 align-middle`,children:V(yn,{node:e})}),on.map(n=>V(`td`,{className:`px-3 py-3 text-center align-middle`,children:V(vn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:hn(e.effective,n.key),pending:t.capabilityPending,layout:`cell`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)})},n.key)),V(`td`,{className:`px-4 py-3 align-middle`,children:V(bn,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,status:t.reachableHostStatus(e.id),errorMessage:t.reachableHostErrorMessage(e.id),onCommit:t.onCommitReachableHost})})]},e.id))})]})})}function Tn({role:e,value:t,options:n,pending:r,onChange:i}){return I(`label`,{className:`flex flex-col gap-1.5 rounded-lg border border-border bg-background p-3`,children:[V(`span`,{className:`text-xs font-semibold text-foreground`,children:pn(e)}),V(`select`,{value:t,disabled:r,onChange:t=>i(e,t.target.value),className:`rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,children:n.map(e=>V(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),V(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:mn(e)})]})}function En({roleValues:e,options:t,pending:n,lowFpsEnabled:r,fpsMinThreshold:i,onRoleChange:a,onLowFpsToggle:o}){return I(`div`,{className:`grid gap-3 @lg/clustertab:grid-cols-2 @3xl/clustertab:grid-cols-4`,children:[an.map(r=>V(Tn,{role:r,value:e[r],options:t,pending:n,onChange:a},r)),I(`label`,{className:`flex items-start gap-2.5 rounded-lg border border-border bg-background p-3 text-sm text-foreground`,children:[V(`input`,{type:`checkbox`,checked:r,disabled:n,onChange:e=>o(e.target.checked),className:`mt-0.5 h-4 w-4 shrink-0 accent-primary`}),I(`span`,{className:`flex flex-col gap-0.5`,children:[V(`span`,{className:`text-xs font-semibold`,children:`Low-fps relocate/shed`}),I(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:[`fpsMinThreshold `,r?`${i} fps`:`disabled`]})]})]})]})}F();function Dn(e,t,n){return Math.min(Math.max(e,t),n)}function On(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 kn(e,t,n,r,i){let a=Dn(n,0,100),o=i.filter(e=>e!==t&&!r.has(e)),s=Math.max(0,100-a),c={...e,[t]:a};if(o.length>0){let e=s/o.length;for(let t of o)c[t]=e}return c}function An({nodes:e,pending:t,onCommitWeights:n}){let[r,i]=B(()=>On(e)),[a,o]=B(new Set);H(()=>{i(On(e)),o(t=>new Set([...t].filter(t=>e.some(e=>e.id===t))))},[e.map(e=>`${e.id}:${e.weight}`).join(`|`)]);let s=e.map(e=>e.id),c=e=>{o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},l=(e,t)=>{i(n=>kn(n,e,t,a,s))},u=()=>{let t=e.filter(e=>Math.round(r[e.id]??0)!==e.weight).map(e=>e.id);if(t.length===0)return;let i=new Set([...t,...a]);n(e.filter(e=>i.has(e.id)).map(e=>({nodeId:e.id,weight:Math.round(r[e.id]??0)})))};if(e.length===0)return V(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No detect-enabled nodes. Enable “Detect” on a node above to distribute detection weight.`});let d=e.length===1;return I(`div`,{className:`space-y-3`,children:[e.map(e=>{let n=r[e.id]??0,i=a.has(e.id);return I(`div`,{className:`flex items-center gap-3`,children:[V(`span`,{className:`w-28 shrink-0 truncate text-xs font-medium text-foreground`,title:e.name,children:e.name}),V(`input`,{"aria-label":`Detection weight for ${e.name}`,type:`range`,min:0,max:100,step:1,value:Math.round(n),disabled:t||i||d,onChange:t=>l(e.id,Number(t.target.value)),onPointerUp:()=>u(),onKeyUp:()=>u(),className:`h-1.5 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50`}),I(`span`,{className:`w-10 shrink-0 text-right font-mono text-xs tabular-nums text-foreground`,children:[Math.round(n),`%`]}),V(`button`,{type:`button`,onClick:()=>c(e.id),disabled:t||d,"aria-pressed":i,title:i?`Unlock — allow rebalancing`:`Lock this share when others change`,className:`shrink-0 rounded p-1 hover:bg-surface-hover disabled:opacity-40 ${i?`text-amber-400`:`text-foreground-subtle`}`,children:V(i?Qe:st,{className:`h-3.5 w-3.5`})})]},e.id)}),V(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:`Dragging one slider splits the rest equally across the unlocked nodes; lock a node to pin its share as a fixed relative weight (pinned nodes stack on top, so the total can exceed 100%). Detection only distributes across nodes that can source a camera’s frames.`})]})}F();function jn(){let e=z(),{nodes:t}=A(),n=ce(void 0),r=de({addonId:tn}),i=de({addonId:nn}),a=()=>_n(e),o=M({onSuccess:a}),s=pe(),c=T({onSuccess:a}),l=N({onSuccess:a}),[u,d]=B(!1),f=L(()=>{let e=new Map;for(let t of n.data??[])e.set(t.nodeId,t.settings);return e},[n.data]),p=L(()=>t.map(e=>{let t=f.get(e.id),n=ft(t,e.isHub),r=dn(t,`detectWeight`);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n,weight:r??1,maxCameras:dn(t,`maxCameras`),reachableHost:fn(t,`reachableHost`),detectedHosts:e.localIps}}),[t,f]),m=p.filter(e=>e.effective.pipeline),h={ingestNode:ln(r.data,`ingestNode`,`hub`),recordingNode:ln(i.data,rn,`hub`),audioNode:ln(r.data,`audioNode`,`hub`),motionNode:ln(r.data,`motionNode`,`hub`)},g=L(()=>{let e=t.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,...an.map(e=>h[e]),...e])].filter(e=>e.length>0)},[t,h]),_=un(r.data,`fpsMinThreshold`,0),v=_>0,y=n.isLoading||r.isLoading||i.isLoading,b=(e,t,n)=>{o.mutate({agentNodeId:e,[t]:n})},x=(e,t)=>{if(e===`recordingNode`){l.mutate({addonId:nn,patch:{[rn]:t}});return}l.mutate({addonId:tn,patch:{[e]:t}})},S=e=>{l.mutate({addonId:tn,patch:{fpsMinThreshold:e?Math.max(1,_):0}})},C=e=>c.variables?.agentNodeId===e?c.isPending?`pending`:c.isError?`error`:c.isSuccess?`success`:`idle`:`idle`,w=e=>C(e)===`error`?gn(c.error):null,E=async e=>{d(!0);try{for(let t of e)await s.mutateAsync({agentNodeId:t.nodeId,detectWeight:t.weight})}finally{d(!1),a()}},D={capabilityPending:o.isPending,onToggleCapability:b,onCommitReachableHost:(e,t)=>c.mutate({agentNodeId:e,reachableHost:t}),reachableHostStatus:C,reachableHostErrorMessage:w};return I(`section`,{className:`rounded-xl border border-border bg-surface p-5 @3xl/clustertab:p-6 space-y-6`,children:[I(`header`,{className:`flex items-start justify-between gap-4`,children:[I(`div`,{className:`space-y-1`,children:[V(`h3`,{className:`text-base font-semibold text-foreground`,children:`Pipeline placement`}),V(`p`,{className:`max-w-prose text-xs leading-relaxed text-foreground-subtle`,children:`Toggle which node runs each pipeline capability, distribute detection weight across detect-capable nodes, and choose the singleton cluster roles.`})]}),y&&V(G,{className:`h-5 w-5 shrink-0 animate-spin text-foreground-subtle`,"aria-label":`Loading`})]}),I(`div`,{className:`space-y-3`,children:[V(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Singleton cluster roles`}),V(En,{roleValues:h,options:g,pending:l.isPending,lowFpsEnabled:v,fpsMinThreshold:_,onRoleChange:x,onLowFpsToggle:S})]}),I(`div`,{className:`space-y-3`,children:[I(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[V(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Per-node capabilities`}),V(Cn,{})]}),p.length===0?V(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No cluster nodes reporting yet.`}):I(R,{children:[V(`div`,{className:`grid gap-4 @xl/clustertab:grid-cols-2 @3xl/clustertab:hidden`,children:p.map(e=>V(Sn,{node:e,actions:D},e.id))}),V(`div`,{className:`hidden @3xl/clustertab:block`,children:V(wn,{nodes:p,actions:D})})]})]}),I(`div`,{className:`space-y-3`,children:[V(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Detection weight`}),V(An,{nodes:m,pending:u,onCommitWeights:e=>void E(e)})]})]})}F();var Mn=!1;function Nn({refreshToken:e}){let t=z(),{data:n}=a(void 0);L(()=>tt(n??[]),[n]);let r=S({onSuccess:()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})}});return I(`div`,{className:`space-y-6`,children:[V(gt,{refreshToken:e}),V(jn,{}),Mn,I(`div`,{className:`flex flex-col gap-3 @md/clustertab:flex-row @md/clustertab:items-center @md/clustertab:justify-between`,children:[I(`div`,{className:`min-w-0`,children:[V(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Placement matrix`}),V(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Pipeline · audio assignments per camera (decode always runs co-located with the pipeline). Click the kebab to pin / unpin / move a role; expand the chevron for the per-camera broker drill-down.`})]}),I(`button`,{type:`button`,onClick:()=>r.mutate(void 0),disabled:r.isPending,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-white hover:bg-primary/90 disabled:opacity-50 shrink-0 self-start @md/clustertab:self-auto whitespace-nowrap`,children:[V(je,{className:`h-3.5 w-3.5`}),r.isPending?`Rebalancing…`:`Rebalance pipelines`]})]}),V(xt,{mode:`cluster`})]})}var Pn=[`pipeline-orchestrator`];function Fn({refreshToken:e}){return V(`div`,{className:`space-y-4 max-w-3xl`,children:V(rt,{nodeId:`hub`,addonIds:Pn,level:`global`,title:`Cluster settings`,description:`Cluster-wide orchestration knobs: enabled nodes, load balancer thresholds, and failover policy. Per-camera pipelines live in Device Overrides; live cluster load is on the Assignments tab.`})})}F();function In({refreshToken:e}){let t=z(),{data:n,isLoading:r}=j(),[i,a]=B(null),[s,c]=B(``),[l,u]=B(``),d=()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listTemplates`]]})},f=me({onSuccess:()=>{a(null),d()}}),p=o({onSuccess:d}),m=e=>{a(e.id),c(e.name),u(e.description??``)},h=()=>{a(null),c(``),u(``)},g=()=>{if(!i)return;let e=l.trim();f.mutate({id:i,name:s.trim()||`Untitled`,...e?{description:e}:{}})};if(r)return V(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading templates…`});let _=[...n??[]].toSorted((e,t)=>e.name.localeCompare(t.name));return V(`div`,{className:`space-y-6 max-w-4xl`,children:I(`section`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[I(`div`,{className:`border-b border-border px-4 py-3 flex items-center justify-between`,children:[I(`div`,{children:[V(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Templates`}),V(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:`Curated pipeline presets operators can apply to any camera. Apply-time is a copy — future edits to a template don't retroactively change cameras that were seeded from it. Save a template from the device Pipeline tab.`})]}),I(`div`,{className:`text-[11px] text-foreground-subtle`,children:[_.length,` template`,_.length===1?``:`s`]})]}),_.length===0?I(`div`,{className:`px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2`,children:[V(Fe,{className:`h-6 w-6 opacity-40`}),V(`div`,{children:`No templates yet. Create one from a device Pipeline tab ("Save as template").`})]}):V(`ul`,{className:`divide-y divide-border`,children:_.map(e=>{let t=i===e.id;return V(`li`,{className:`px-4 py-3 text-xs`,children:I(`div`,{className:`flex items-start gap-3`,children:[V(`div`,{className:`flex-1 min-w-0`,children:t?I(`div`,{className:`space-y-2`,children:[V(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`,value:s,onChange:e=>c(e.target.value),placeholder:`Template name`,autoFocus:!0}),V(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary`,value:l,onChange:e=>u(e.target.value),placeholder:`Description (optional)`})]}):I(R,{children:[V(`div`,{className:`font-medium text-foreground`,children:e.name}),e.description&&V(`div`,{className:`text-foreground-subtle mt-0.5`,children:e.description}),I(`div`,{className:`mt-1 font-mono text-[10px] text-foreground-subtle`,children:[e.config.steps.length,` step(s)`,e.config.audio?.enabled?` · audio`:``,I(`span`,{className:`ml-2`,children:[`updated `,new Date(e.updatedAt).toLocaleString()]})]})]})}),V(`div`,{className:`flex items-center gap-1 shrink-0`,children:t?I(R,{children:[I(`button`,{type:`button`,onClick:g,disabled:f.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-50`,children:[V(He,{className:`h-3 w-3`}),`Save`]}),I(`button`,{type:`button`,onClick:h,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover`,children:[V(qe,{className:`h-3 w-3`}),`Cancel`]})]}):I(R,{children:[V(`button`,{type:`button`,onClick:()=>m(e),title:`Rename`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,children:V(Pe,{className:`h-3 w-3`})}),V(`button`,{type:`button`,onClick:()=>{confirm(`Delete template "${e.name}"?`)&&p.mutate({id:e.id})},disabled:p.isPending,title:`Delete`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-red-400 hover:bg-surface-hover disabled:opacity-50`,children:V(Ze,{className:`h-3 w-3`})})]})})]})},e.id)})})]})})}F();function Ln(e,t){if(!e)return null;for(let n of e.slots)for(let e of n.addons)if(e.id===t)return e;return null}function Rn({nodeId:e,refreshToken:t}){let n=z(),r=Ce().trpcClient,[i,o]=B(null),[s,c]=B(null),l=ce(void 0,{refetchOnMount:`always`});K([`nodes`,`topology`],[`agent.online`,`agent.offline`,`agent.unregistered`,`addon.installed`,`addon.uninstalled`,`addon.updated`]);let u=a(void 0,{refetchOnMount:`always`}),d=L(()=>{let e=new Set;for(let t of u.data??[])t.isOnline&&e.add(t.id);return e},[u.data]),f=m({nodeId:e},{refetchOnMount:`always`}),p=L(()=>(l.data??[]).filter(e=>d.has(e.nodeId)).map(e=>e.nodeId),[l.data,d]),h=ye({enabled:p.length>0,queryKey:[[`pipelineExecutor`,`getSchema`],`schema-by-agent`,p.join(`,`),t],queryFn:async()=>{let e={};for(let t of p)try{e[t]=(await r.pipelineExecutor.getSchema.query({nodeId:t})).selectedEngine.format}catch{e[t]=`coreml`}return e}}),g=w({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]}),n.invalidateQueries({queryKey:[[`pipelineExecutor`]]}),n.invalidateQueries({queryKey:[[`addonSettings`]]})}}),_=L(()=>f.data?D(f.data):[],[f.data]),v=L(()=>{let e=l.data??[],t=d;return(t.size===0?[]:e.filter(e=>t.has(e.nodeId))).map(e=>{let t=h.data?.[e.nodeId];return{agentNodeId:e.nodeId,engineLabel:t??`(engine unknown)`}})},[l.data,h.data,d]),y=(e,t)=>{let n=(l.data?.find(e=>e.nodeId===t))?.settings.addonDefaults[e],r=h.data?.[t];return!Ln(f.data??null,e)?.models.some(e=>r!==void 0&&!!e.formats[r])||!n?{kind:`na`}:n.enabled?{kind:`enabled`,modelId:n.modelId??`Auto`}:{kind:`disabled`}},b=i?l.data?.find(e=>e.nodeId===i.agentNodeId)??null:null,x=i&&f.data?Ln(f.data,i.addonId):null,S=i?h.data?.[i.agentNodeId]??`coreml`:`coreml`,C=()=>{o(null),c(null)},T=(e,t)=>{let n=(l.data?.find(e=>e.nodeId===t))?.settings.addonDefaults[e]??null;o({addonId:e,agentNodeId:t}),c(n)},E=()=>{!s||!i||!b||g.mutate({agentNodeId:i.agentNodeId,defaults:{...b.settings.addonDefaults,[i.addonId]:s}},{onSuccess:C})};if(l.isLoading||f.isLoading)return V(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading agents…`});if(!f.data)return I(`div`,{className:`text-xs text-foreground-subtle`,children:[`Catalog unavailable for `,e,`.`]});let O=i!==null&&x!==null&&s!==null;return I(`div`,{className:`relative h-full w-full space-y-3`,children:[V(Kt,{title:`Cluster cameras`}),V(`div`,{className:O?`pr-[360px]`:``,children:_.length>0&&v.length>0?V(ne,{tree:_,agents:v,getCellState:y,onCellClick:T,selectedCell:i}):V(`div`,{className:`text-xs text-foreground-subtle`,children:`No agents or catalog empty.`})}),I(oe,{open:O,onClose:C,title:x?.name??``,subtitle:i?`${i.agentNodeId} · ${S}`:``,footer:I(R,{children:[V(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:C,children:`Cancel`}),V(`button`,{type:`button`,disabled:!s||!i||g.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:E,children:g.isPending?`Saving…`:`Save`})]}),children:[g.isError&&I(`div`,{className:`mb-3 rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400`,children:[`Save failed:`,` `,g.error instanceof Error?g.error.message:String(g.error)]}),x&&s&&i&&V(fe,{mode:`agent`,addon:x,agentDefault:s,agentNodeId:i.agentNodeId,engineFormat:S,onChangeAgentConfig:e=>c(e)})]})]})}F();function zn({types:e}){let t=z(),n=E(),{data:i}=te({}),a=l(),o=L(()=>a.data??[],[a.data]),[s,c]=B(null),[u,d]=B(null),f=()=>{t.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})},p=ee({onSuccess:f}),m=r({onSuccess:f}),h=L(()=>{let e=new Map;for(let t of i??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[i]),g=e=>{e.isDefault||p.mutate({id:e.id,type:e.type,providerId:e.providerId,displayName:e.displayName,config:e.config,isDefault:!0})},_=async e=>{if(e.isDefault){await n({title:`Cannot delete default location`,message:`"${e.displayName}" is the default for type "${e.type}". Mark another as default first.`,confirmLabel:`OK`,variant:`warning`});return}await n({title:`Delete location "${e.displayName}"?`,message:`Removes the record; files on disk are untouched.`,confirmLabel:`Delete`,variant:`danger`})&&m.mutate({id:e.id})},v=e.map(e=>o.find(t=>t.id===e)).filter(e=>e!==void 0);return I(`div`,{className:`space-y-3`,children:[v.length===0?V(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:`No storage locations declared for this purpose.`}):v.map(e=>V(De,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:h.get(e.id)??[],onAdd:e=>c(e),onEdit:e=>d(e),onDelete:e=>{_(e)},onSetDefault:e=>g(e)},e.id)),s!==null&&V(Oe,{initialType:s,onClose:()=>c(null),onCreated:()=>{f(),c(null)}}),u!==null&&V(Ee,{location:u,onClose:()=>d(null),onSaved:()=>{f(),d(null)}})]})}F();var Bn=`pipeline-analytics`;function Vn(e){for(let t of e?.sections??[])for(let e of t.fields??[])if(e.key===`postProcessingNodeId`&&typeof e.value==`string`)return e.value;return`hub`}function Hn(){let e=z(),{data:t}=a(void 0),{data:n,isLoading:r}=de({addonId:Bn}),i=Vn(n),o=N({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),s=L(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,i,...e])].filter(Boolean)},[t,i]);return I(`div`,{className:`flex flex-col gap-6`,children:[I(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[V(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Post-processing node`}),V(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that runs detection post-processing (events, media, audio & motion). Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),I(`div`,{className:`mt-3 flex items-center gap-2`,children:[r?V(G,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):V(`select`,{value:i,onChange:e=>{e.target.value!==i&&o.mutate({addonId:Bn,patch:{postProcessingNodeId:e.target.value}})},disabled:o.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:s.map(e=>V(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),o.isPending&&V(G,{className:`h-4 w-4 animate-spin text-primary`})]})]}),I(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[V(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Events folder`}),V(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`}),V(zn,{types:[`eventMedia`]})]})]})}F();var Un=`recorder`;function Wn(e,t,n){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t&&typeof e.value==`string`)return e.value;return n}function Gn(){let e=z(),{data:t}=a(void 0),{data:n,isLoading:r}=de({addonId:Un}),i=Wn(n,`recordingNodeId`,`hub`),o=N({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),s=L(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,i,...e])].filter(Boolean)},[t,i]);return I(`div`,{className:`flex flex-col gap-6`,children:[I(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[V(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Recording node`}),V(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that records (continuous & events) and serves playback. Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),I(`div`,{className:`mt-3 flex items-center gap-2`,children:[r?V(G,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):V(`select`,{value:i,onChange:e=>{e.target.value!==i&&o.mutate({addonId:Un,patch:{recordingNodeId:e.target.value}})},disabled:o.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:s.map(e=>V(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),o.isPending&&V(G,{className:`h-4 w-4 animate-spin text-primary`})]}),i!==`hub`&&I(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:[`The stream-broker is hub-only — an agent recorder pulls streams from the hub over the network. The hub's RTSP restream port must be reachable from`,` `,V(`span`,{className:`font-medium`,children:i}),`. If the auto-derived host doesn't work, set the recorder's`,V(`span`,{className:`font-medium`,children:` recordingHubHostname`}),` global setting.`]})]}),I(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[V(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Recordings folders`}),V(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where recordings are stored. Multi-location collections — segments are split across the locations of a type. Add a location to grow capacity; mark one default per type.`}),V(zn,{types:[`recordings`,`recordingsLow`]})]})]})}var Kn=`pipeline-orchestrator`,qn=200;function Jn(){return I(`div`,{className:`flex flex-col gap-3`,children:[I(`div`,{children:[V(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Orchestrator logs`}),V(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Dispatch decisions, balancer moves and failover events from the pipeline orchestrator. Streaming live; the device chip on a line tells which camera it refers to.`})]}),V(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:V(O,{addonId:Kn,limit:qn,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}F();var Yn=[{id:`assignments`,label:`Assignments`},{id:`pipeline`,label:`Pipeline`},{id:`events`,label:`Events`},{id:`recording`,label:`Recording`},{id:`settings`,label:`Settings`},{id:`templates`,label:`Templates`},{id:`logs`,label:`Logs`}];function Xn({refreshToken:e}){let[t,n]=B(`assignments`),{data:r}=a(void 0),i=r?.find(e=>e.isHub&&e.isOnline)?.id??r?.find(e=>e.isOnline)?.id??null;return I(`div`,{className:`flex flex-col h-full`,children:[I(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[V(`h2`,{className:`text-base font-semibold text-foreground`,children:`Cluster Orchestration`}),V(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:`Assignments with live load, cluster-wide settings, pipeline template library, per-camera pipeline overrides.`})]}),V(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:Yn.map(e=>V(`button`,{type:`button`,onClick:()=>n(e.id),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${t===e.id?`border-primary text-primary`:`border-transparent text-foreground-subtle hover:text-foreground`}`,children:e.label},e.id))}),I(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[t===`assignments`&&V(Nn,{refreshToken:e}),t===`pipeline`&&(i?V(Rn,{nodeId:i,refreshToken:e}):V(`div`,{className:`text-xs text-foreground-subtle`,children:`No online node available — schema unreachable.`})),t===`events`&&V(Hn,{}),t===`recording`&&V(Gn,{}),t===`settings`&&V(Fn,{refreshToken:e}),t===`templates`&&V(In,{refreshToken:e}),t===`logs`&&V(Jn,{})]})]})}function Zn(e){let t=[],n=[],{assignment:r,detection:i,decoder:a,broker:o}=e;i!==null&&i.provisioning.state===`failed`&&t.push({code:`provisioning-failed`,severity:`error`,message:i.provisioning.error!==void 0&&i.provisioning.error.length>0?`Engine provisioning failed: ${i.provisioning.error}`:`Engine provisioning failed on the detection node`}),i!==null&&i.phase===`active`&&i.actualFps===0&&t.push({code:`detection-black-hole`,severity:`error`,message:`Detection phase is ACTIVE but 0 fps are being processed — frames are not reaching the detector (cross-node black-hole signature)`}),i!==null&&i.phase===`active`&&a!==null&&a.shm.framesWritten===0&&t.push({code:`decoder-black-hole`,severity:`error`,message:`Decoder on ${a.nodeId} has written 0 frames to the shared-memory plane while detection is active — the decode path is stalled`}),r.detectionNodeId===null&&i===null&&n.push({code:`unassigned`,severity:`warning`,message:`Not placed on any detection node — no pipeline is running for this camera`});for(let e of o?.profiles??[])e.status===`streaming`&&e.inFps===0&&n.push({code:`broker-stalled`,severity:`warning`,message:`Broker profile "${e.profile}" reports streaming but 0 in-fps — the source pull may be stalled`});return[...t,...n]}function Qn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e){return typeof e==`string`&&e.length>0?e:null}function $n(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function er(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function tr(e,t){return e==null?!1:JSON.stringify(e)!==JSON.stringify(t??null)}var nr={detectionMode:null,detectionStreamProfile:null,detectionFps:null,motionSources:[],motionFps:null,motionCooldownMs:null,motionStreamProfile:null,audioMode:null,pipelineNodeId:null,decoderNodeId:null,audioNodeId:null,overriddenKeys:new Set};function rr(e){if(!Qn(e)||!Array.isArray(e.sections))return nr;let t=xe(e),n=e=>{let n=t.get(e);if(n!==void 0)return n.value??n.default},r=new Set;for(let[e,n]of t)tr(n.value,n.default)&&r.add(e);return{detectionMode:Y(n(`detectionMode`)),detectionStreamProfile:Y(n(`detectionStreamProfile`)),detectionFps:$n(n(`detectionFps`)),motionSources:er(n(`motionSources`)),motionFps:$n(n(`motionFps`)),motionCooldownMs:$n(n(`motionCooldownMs`)),motionStreamProfile:Y(n(`motionStreamProfile`)),audioMode:Y(n(`audioMode`)),pipelineNodeId:Y(n(`pipelineNodeId`)),decoderNodeId:Y(n(`decoderNodeId`)),audioNodeId:Y(n(`audioNodeId`)),overriddenKeys:r}}function ir(e,t=0){let n=[];for(let r of e)n.push({addonId:r.addonId,modelId:r.modelId??null,enabled:r.enabled,depth:t}),r.children!==void 0&&r.children.length>0&&n.push(...ir(r.children,t+1));return n}function ar(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}function X({title:e,children:t}){return I(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[V(`div`,{className:`text-[9px] font-semibold uppercase tracking-[0.14em] text-foreground-subtle mb-2`,children:e}),V(`div`,{className:`flex flex-col gap-1 min-w-0`,children:t})]})}function Z({label:e,children:t,overridden:n=!1}){return I(`div`,{className:`flex items-baseline gap-2 text-[11px] leading-snug min-w-0`,children:[V(`span`,{className:`text-foreground-subtle shrink-0 w-24 truncate`,title:e,children:e}),V(`span`,{className:`font-mono tabular-nums text-foreground min-w-0 truncate flex-1`,children:t}),n&&V(or,{})]})}function or(){return V(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0 self-center`,title:`Device-level override active`,"aria-label":`Device-level override active`,role:`img`})}var sr={neutral:`border-border text-foreground-muted`,success:`border-success/40 text-success`,warning:`border-warning/40 text-warning`,danger:`border-danger/40 text-danger`,info:`border-info/40 text-info`};function Q({tone:e=`neutral`,children:t,title:n}){return V(`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 ${sr[e]}`,children:t})}function $({children:e}){return V(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function cr({icon:e,label:t,nodeId:n,pinned:r,reason:i,overridden:a}){return I(`div`,{className:`flex items-center gap-2 text-[11px] leading-snug min-w-0`,children:[V(e,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),V(`span`,{className:`text-foreground-subtle w-[4.5rem] shrink-0`,children:t}),n===null?V(`span`,{className:`text-foreground-subtle italic`,children:`unassigned`}):I(R,{children:[V(`span`,{className:`font-mono text-foreground truncate`,title:n,children:n}),r?I(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:`Manually pinned`,children:[V(ct,{className:`h-2.5 w-2.5`}),` manual`]}):I(`span`,{className:`text-[10px] text-foreground-subtle shrink-0 truncate`,children:[`auto · `,i!==void 0&&i.length>0?i:`capacity`]}),a&&V(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0`,title:`Persisted settings pin for this role`})]})]})}function lr({assignment:e,settings:t,onlineNodes:n,pinPending:r,onDetectionPinChange:i}){let a=e.pinned.detection&&e.detectionNodeId!==null?e.detectionNodeId:`auto`,o=[...new Set([...e.detectionNodeId===null?[]:[e.detectionNodeId],...n.map(e=>e.id)])];return I(X,{title:`Where it runs`,children:[V(cr,{icon:U,label:`Detection`,nodeId:e.detectionNodeId,pinned:e.pinned.detection,reason:e.reasons.detection,overridden:t.overriddenKeys.has(`pipelineNodeId`)}),V(cr,{icon:at,label:`Decoder`,nodeId:e.decoderNodeId,pinned:e.pinned.decoder,reason:e.reasons.decoder,overridden:t.overriddenKeys.has(`decoderNodeId`)}),V(cr,{icon:Ae,label:`Audio`,nodeId:e.audioNodeId,pinned:e.pinned.audio,reason:e.reasons.audio,overridden:t.overriddenKeys.has(`audioNodeId`)}),V(cr,{icon:Ie,label:`Source`,nodeId:e.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),V(`div`,{className:`mt-1.5`,children:I(`select`,{value:a,disabled:r,"aria-label":`Detection placement pin`,onChange:e=>i(e.target.value),className:`w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-[11px] text-foreground disabled:opacity-50`,children:[V(`option`,{value:`auto`,children:`Auto (load balanced)`}),o.map(e=>I(`option`,{value:e,children:[`Pin detection → `,n.find(t=>t.id===e)?.name??e]},e))]})})]})}function ur(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function dr(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function fr(e){return e===null?`default`:e===0?`native (no throttle)`:`${e} fps`}function pr({streams:e,brokerProfiles:t,settings:n,motionEnabled:r,motionFpsLive:i}){let a=dr(t,n.detectionStreamProfile),o=dr(t,n.motionStreamProfile),s=n.motionSources.includes(`analyzer`);return I(X,{title:`Streams & motion`,children:[I(Z,{label:`Detect stream`,overridden:n.overriddenKeys.has(`detectionStreamProfile`),children:[n.detectionStreamProfile??`—`,a!==void 0&&` · ${a.width}×${a.height} ${a.codec}`]}),V(Z,{label:`Detect FPS`,overridden:n.overriddenKeys.has(`detectionFps`),children:fr(n.detectionFps)}),I(Z,{label:`Motion src`,overridden:n.overriddenKeys.has(`motionSources`),children:[n.motionSources.length>0?n.motionSources.join(` + `):`none`,r===!1&&` · inactive`]}),s&&I(R,{children:[I(Z,{label:`Motion stream`,overridden:n.overriddenKeys.has(`motionStreamProfile`),children:[n.motionStreamProfile??`—`,o!==void 0&&` · ${o.width}×${o.height} ${o.codec}`]}),I(Z,{label:`Motion FPS`,overridden:n.overriddenKeys.has(`motionFps`),children:[fr(n.motionFps),i!==null&&` · live ${i.toFixed(1)}`]})]}),V(Z,{label:`Cooldown`,overridden:n.overriddenKeys.has(`motionCooldownMs`),children:n.motionCooldownMs===null?`default`:`${n.motionCooldownMs/1e3}s`}),V(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:e.length===0?V($,{children:`No streams registered`}):e.map(e=>I(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:e.camStreamId,children:[V(`span`,{className:`text-foreground-muted`,children:e.kind}),` `,ur(e)]},e.camStreamId))})]})}function mr({steps:e,audioModelId:t,audioEnabled:n,audioMode:r}){return I(X,{title:`Pipeline steps`,children:[e===void 0?V($,{children:`Resolving…`}):e.length===0?V($,{children:`No steps configured`}):V(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>V(Q,{tone:e.enabled&&e.depth===0?`info`:`neutral`,title:e.modelId??e.addonId,children:I(`span`,{className:e.enabled?``:`line-through opacity-60`,children:[e.depth>0&&V(`span`,{className:`opacity-50`,children:`↳ `}),e.addonId,e.modelId!==null&&I(`span`,{className:`font-mono opacity-75`,children:[` · `,e.modelId]})]})},`${e.addonId}-${t}`))}),V(`div`,{className:`mt-1`,children:I(Z,{label:`Audio class.`,children:[r??`—`,n!==null&&(n?` · running`:` · off`),t!==null&&` · ${t}`]})})]})}var hr={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function gr({detection:e,live:t,detectionMode:n,modeOverridden:r}){if(e===null)return I(X,{title:`Detection runtime`,children:[V(Z,{label:`Mode`,overridden:r,children:n??`—`}),V($,{children:`Detection stage inactive or unreachable`})]});let i=t?.phase??e.phase,a=t?.actualFps??e.actualFps,o=t?.configuredFps??e.configuredFps,s=t?.avgInferenceTimeMs??e.avgInferenceMs,c=t?.queueDepth??e.queueDepth,l=u(i),d=i===`active`&&a===0;return I(X,{title:`Detection runtime`,children:[I(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[I(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider ${l.badgeClass}`,children:[V(y,{phase:i,className:`h-2.5 w-2.5`}),l.label]}),t!==void 0&&V(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:`live`})]}),V(Z,{label:`Mode`,overridden:r,children:n??`—`}),I(Z,{label:`FPS`,children:[V(`span`,{className:d?`text-danger font-semibold`:``,children:a.toFixed(1)}),I(`span`,{className:`text-foreground-subtle`,children:[` / `,o.toFixed(0),` configured`]})]}),I(Z,{label:`Inference`,children:[s.toFixed(0),` ms`,c>0&&I(`span`,{className:`text-warning`,children:[` · queue `,c]}),t!==void 0&&t.droppedFrames>0&&I(`span`,{className:`text-warning`,children:[` · drops `,t.droppedFrames]})]}),I(Z,{label:`Engine`,children:[e.engine.backend,` · `,e.engine.device]}),I(Z,{label:`Provisioning`,children:[V(Q,{tone:hr[e.provisioning.state]??`neutral`,children:e.provisioning.state}),e.provisioning.error!==void 0&&I(`span`,{className:`text-danger text-[10px]`,children:[` `,e.provisioning.error]})]})]})}function _r({broker:e}){return e===null?V(X,{title:`Stream broker`,children:V($,{children:`Broker stage inactive or unreachable`})}):I(X,{title:`Stream broker`,children:[e.profiles.length===0?V($,{children:`No broker profiles`}):V(`div`,{className:`flex flex-col gap-1`,children:e.profiles.map(e=>{let t=e.status===`streaming`,n=t&&e.inFps===0;return I(`div`,{className:`flex items-center gap-2 text-[11px] font-mono tabular-nums min-w-0`,children:[V(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full shrink-0 ${n?`bg-danger`:t?`bg-success animate-pulse`:`bg-border`}`,title:e.status}),V(`span`,{className:`text-foreground w-10 shrink-0 truncate`,title:e.profile,children:e.profile}),I(`span`,{className:`text-foreground-subtle truncate`,children:[e.width,`×`,e.height,` `,e.codec]}),I(`span`,{className:`ml-auto shrink-0 ${n?`text-danger`:`text-foreground`}`,children:[e.inFps.toFixed(0),`→`,e.outFps.toFixed(0),`fps`]}),I(`span`,{className:`text-foreground-subtle shrink-0`,title:`Subscribers`,children:[`×`,e.subscribers]})]},e.profile)})}),I(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[I(Q,{tone:e.webrtcSessions>0?`info`:`neutral`,children:[`WebRTC `,e.webrtcSessions]}),I(Q,{tone:e.rtspRestream?`success`:`neutral`,children:[`restream `,e.rtspRestream?`on`:`off`]})]})]})}function vr({decoder:e,detectionActive:t}){if(e===null)return V(X,{title:`Decoder`,children:V($,{children:`Decoder stage inactive or unreachable`})});let n=t&&e.shm.framesWritten===0;return I(X,{title:`Decoder`,children:[V(Z,{label:`Node`,children:e.nodeId}),V(Z,{label:`Sessions`,children:e.sessionCount}),I(Z,{label:`SHM frames`,children:[V(`span`,{className:n?`text-danger font-semibold`:``,children:e.shm.framesWritten}),V(`span`,{className:`text-foreground-subtle`,children:` written`})]}),I(Z,{label:`SHM reads`,children:[e.shm.getFrameHits,` hits`,e.shm.getFrameMisses>0&&I(`span`,{className:`text-warning`,children:[` · `,e.shm.getFrameMisses,` misses`]})]}),I(Z,{label:`SHM budget`,children:[e.shm.budgetMb,` MB`]}),e.formats.length>0&&V(Z,{label:`Formats`,children:e.formats.join(`, `)})]})}F();var yr=`pipeline-orchestrator`,br={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},xr={healthy:`Healthy`,idle:`Idle`,error:`Error`};function Sr({problems:e}){return V(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:e.map(e=>I(`div`,{className:`flex items-start gap-2 px-4 py-1.5 text-[11px] font-medium ${e.severity===`error`?`bg-danger/10 text-danger`:`bg-warning/10 text-warning`}`,children:[V(Ye,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),V(`span`,{className:`min-w-0`,children:e.message})]},e.code))})}function Cr({deviceId:e,name:t,online:n,status:r,live:i,onlineNodes:a}){let o=z(),{data:s}=ae({addonId:yr,deviceId:e,nodeId:`hub`},{staleTime:3e4}),{data:c}=ue({deviceId:e},{staleTime:3e4}),l=L(()=>rr(s),[s]),u=L(()=>c===void 0?void 0:ir(c.steps),[c]),d=L(()=>r===void 0?[]:Zn(r),[r]),f=()=>{o.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),o.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},p=se({onSuccess:f}),m=b({onSuccess:f}),h=t=>{t===`auto`?m.mutate({deviceId:e}):p.mutate({deviceId:e,agentNodeId:t})},g=r===void 0?`idle`:ar(r),_=d.some(e=>e.severity===`error`),v=d.length>0,y=_?`border-danger/50`:v?`border-warning/40`:`border-border`;return I(`article`,{"aria-label":`${t} pipeline status`,className:`rounded-lg border ${y} bg-background overflow-hidden`,children:[I(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[V(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${_?`bg-danger`:br[g]}`,title:_?`Error`:xr[g],"aria-label":_?`Error`:xr[g],role:`img`}),V(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:t,children:t}),I(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,e]}),!n&&V(Q,{tone:`danger`,children:`offline`}),I(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[l.detectionMode!==null&&V(Q,{tone:l.detectionMode===`disabled`?`warning`:l.detectionMode===`always-on`?`info`:`neutral`,title:`Object detection mode`,children:l.detectionMode===`disabled`?`detection off`:l.detectionMode}),r?.recording!=null&&(r.recording.active?I(Q,{tone:`danger`,title:`Recording (${r.recording.mode})`,children:[V(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):r.recording.mode!==`off`&&I(Q,{tone:`neutral`,title:`Recording mode`,children:[`rec `,r.recording.mode]}))]})]}),d.length>0&&V(Sr,{problems:d}),r===void 0?V(`div`,{className:`px-4 py-5 text-[11px] text-foreground-subtle italic`,children:`No pipeline status yet — the orchestrator has not composed a snapshot for this camera.`}):I(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[V(lr,{assignment:r.assignment,settings:l,onlineNodes:a,pinPending:p.isPending||m.isPending,onDetectionPinChange:h}),V(gr,{detection:r.detection,live:i,detectionMode:l.detectionMode,modeOverridden:l.overriddenKeys.has(`detectionMode`)}),V(mr,{steps:u,audioModelId:c?.audio?.modelId??null,audioEnabled:r.audio?.enabled??c?.audio?.enabled??null,audioMode:l.audioMode}),V(pr,{streams:r.source.streams,brokerProfiles:r.broker?.profiles,settings:l,motionEnabled:r.motion?.enabled??null,motionFpsLive:r.motion?.fps??null}),V(_r,{broker:r.broker}),V(vr,{decoder:r.decoder,detectionActive:r.detection?.phase===`active`})]})]})}F();var wr=5e3,Tr=1e4,Er=5e3;function Dr(t){let n=z(),{data:r,isLoading:i}=Ne(),{data:a,isLoading:o}=e({},{refetchInterval:wr}),{nodes:s}=A();H(()=>{t!==0&&n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[t,n]);let[c,l]=B(new Map);le(Se.PipelineCameraMetricsSnapshot,e=>{let t=e.data;typeof t.deviceId==`number`&&l(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})}),H(()=>{if(c.size===0)return;let e=setInterval(()=>{l(e=>{let t=Date.now()-Tr,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},Er);return()=>clearInterval(e)},[c.size]);let u=L(()=>{let e=new Map;for(let t of a??[])e.set(t.deviceId,t);return e},[a]);return{rows:L(()=>(r??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,online:e.online,status:u.get(e.id)})).sort((e,t)=>e.name.localeCompare(t.name)),[r,u]),liveMetrics:c,onlineNodes:L(()=>(s??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[s]),isLoading:i||o}}F();function Or({refreshToken:e}){let{rows:t,liveMetrics:n,onlineNodes:r,isLoading:i}=Dr(e),a=L(()=>[...t.map(e=>{let t=e.status===void 0?[]:Zn(e.status);return{row:e,errorCount:t.filter(e=>e.severity===`error`).length,warningCount:t.filter(e=>e.severity===`warning`).length}})].sort((e,t)=>e.errorCount===t.errorCount?e.warningCount===t.warningCount?0:t.warningCount-e.warningCount:t.errorCount-e.errorCount),[t]),o=L(()=>{let e=0,t=0;for(let r of a)(r.errorCount>0||r.warningCount>0)&&(t+=1),(n.get(r.row.deviceId)?.phase??r.row.status?.detection?.phase)===`active`&&(e+=1);return{total:a.length,active:e,issues:t}},[a,n]);return i&&t.length===0?V(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`Loading camera pipelines…`}):t.length===0?V(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`No cameras found`}):V(`div`,{className:`h-full overflow-y-auto`,children:I(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[I(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[I(`span`,{children:[V(`span`,{className:`font-semibold text-foreground`,children:o.total}),` cameras`]}),I(`span`,{children:[V(`span`,{className:`font-semibold text-success`,children:o.active}),` actively inferring`]}),I(`span`,{children:[V(`span`,{className:`font-semibold ${o.issues>0?`text-danger`:`text-foreground`}`,children:o.issues}),` `,`with issues`]}),V(`span`,{className:`ml-auto hidden sm:inline text-[10px]`,children:`polled every 5 s · detection metrics live at 1 Hz`})]}),a.map(({row:e})=>V(Cr,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:n.get(e.deviceId),onlineNodes:r},e.deviceId))]})})}F();var kr=`__cluster__`;function Ar(e){return e===`cameras`?`cameras`:`nodes`}function jr(){let[e,t]=Ue(),n=Ar(e.get(`view`)),r=e.get(`node`)??`__cluster__`,[i,a]=B(0),[o,s]=B(!1);return H(()=>{n===`nodes`&&!e.get(`node`)&&t({view:`nodes`,node:kr},{replace:!0})},[n,e,t]),I(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[I(`div`,{className:`flex items-center justify-between gap-4 px-4 py-3 border-b border-border shrink-0`,children:[I(`div`,{className:`flex items-center gap-1 rounded-lg border border-border p-0.5 bg-surface`,children:[V(`button`,{type:`button`,onClick:()=>{t({view:`nodes`,node:r},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Nodes`}),V(`button`,{type:`button`,onClick:()=>{t({view:`cameras`},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Cameras`})]}),I(`button`,{type:`button`,onClick:()=>a(e=>e+1),title:`Refresh`,className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[V(Le,{className:`h-3.5 w-3.5`}),`Refresh`]})]}),n===`nodes`&&I(`button`,{type:`button`,onClick:()=>s(e=>!e),"aria-expanded":o,className:`md:hidden flex items-center justify-between gap-2 px-4 py-2 border-b border-border shrink-0 text-[11px] font-medium text-foreground-subtle hover:text-foreground transition-colors`,children:[I(`span`,{children:[o?`Hide`:`Show`,` node list`]}),V(Ve,{className:[`h-4 w-4 transition-transform`,o?`rotate-180`:``].join(` `)})]}),V(`div`,{className:`flex-1 flex flex-col md:flex-row overflow-hidden min-h-0`,children:n===`nodes`?I(R,{children:[V(`aside`,{className:[o?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border`,`max-h-[60vh] md:max-h-none overflow-y-auto`].join(` `),children:V(mt,{selectedNodeId:r,onSelect:e=>{t({view:`nodes`,node:e},{replace:!0}),s(!1)},refreshToken:i})}),V(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:r===`__cluster__`?V(Xn,{refreshToken:i}):V(en,{nodeId:r,refreshToken:i})})]}):V(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:V(Or,{refreshToken:i})})})]})}export{jr as PipelinePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Fa as e,Ia as t,Pa as n}from"./src-ojhqTnBF.js";import{I as r,K as i,Q as a,S as o,W as s,b as c,q as l,x as u,z as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{L as f,V as p,c as ee,g as m,n as h,p as g,s as te}from"./player-overlays-BrMuuVRR.js";import{MaskShapeCanvas as _}from"./MaskShapeCanvas-pGn6MKOi.js";var ne=m(`hexagon`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}]]);a();var v=120,y=`privacy-mask`,b=`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`,x=`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 S(e){return e.kind===`rect`||e.kind===`polygon`?e:null}function re(e){let t=new Set(e.map(e=>e.id)),n=0;for(;t.has(n);)n+=1;return n}function C(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 w({deviceId:a}){let m=ee(g().trpcClient,a),[w,T]=l(null),[E,D]=l(!1),[O,k]=l(null),[A,j]=l(null),[M,N]=l(!1),[P,F]=l(!1),[I,L]=l(null),[R,z]=l(null),B=i(!1);d(()=>{if(!m)return;let e=!1;return B.current=!1,T(null),D(!1),k(null),j(null),F(!1),L(null),z(null),(async()=>{try{let t=await m.privacyMask?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(T(t),B.current)return;let n=await m.privacyMask?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);B.current=!0;let r={enabled:n.enabled,regions:n.regions};j(r),k(r)}catch(t){if(e)return;p(t)?D(!0):console.error(`Privacy Mask load failed`,t)}})(),()=>{e=!0}},[m]);let V=s(()=>O!==null&&A!==null&&(O.enabled!==A.enabled||!C(O.regions,A.regions)),[O,A]),H=O?O.regions.length:0,U=w?w.maxRegions:0,W=i(0);d(()=>{W.current=U},[U]);let G=U>0&&H>=U,K=r(()=>{k(e=>e&&{...e,enabled:!e.enabled})},[]),q=r(e=>{L(typeof e==`number`?e:null)},[]),J=s(()=>O?O.regions.map(e=>({id:e.id,shape:e.shape,enabled:e.enabled,label:`Zone ${String(e.id)}`})):[],[O]),Y=r((e,t)=>{let n=S(t);n&&k(t=>t&&{...t,regions:t.regions.map(t=>t.id===e?{...t,shape:n}:t)})},[]),X=r(e=>{let t=S(e);t&&(z(null),k(e=>{if(!e)return e;let n=W.current;if(n>0&&e.regions.length>=n)return e;let r=re(e.regions),i={id:r,enabled:!0,shape:t};return L(r),{...e,regions:[...e.regions,i]}}))},[]),Z=r(e=>{F(!0),L(null),z(e)},[]),ie=r(e=>{F(!0),z(null),L(e)},[]),ae=r(e=>{L(t=>t===e?null:t),k(t=>t&&{...t,regions:t.regions.filter(t=>t.id!==e)})},[]),oe=r(()=>{z(null),L(null),A&&k({enabled:A.enabled,regions:A.regions})},[A]),se=r(async()=>{if(!(!m||!O)){N(!0);try{await m.privacyMask?.setMask({patch:{enabled:O.enabled,regions:[...O.regions]}});let e=await m.privacyMask?.getStatus({});if(e){let t={enabled:e.enabled,regions:e.regions};j(t),k(t)}}catch(e){console.error(`Privacy Mask save failed`,e)}finally{N(!1)}}},[m,O]),ce=r(()=>{F(e=>(e&&(z(null),L(null)),!e))},[]),Q=w?.supportedShapes??[];h(s(()=>P&&!E&&w&&O?{id:y,order:v,node:u(_,{transparent:!0,items:J,supportedShapes:Q,polygonVertices:w.polygonVertices,selectedId:I,onSelect:q,onShapeChange:Y,onDrawComplete:X,drawingKind:R})}:null,[P,E,w,O,J,Q,I,q,Y,X,R]));let le=w?.supportedShapes.includes(`rect`)??!1,ue=w?.supportedShapes.includes(`polygon`)??!1,$=w!==null&&(w.maxRegions<=0||w.supportedShapes.length===0);return m?u(te,{title:`Privacy Mask`,icon:u(t,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:u(`div`,{className:`flex flex-col gap-3`,children:E||$?u(`p`,{className:`${f} leading-relaxed`,children:`This camera doesn't support an on-board privacy mask.`}):!E&&!$&&w!==null&&O!==null?o(c,{children:[o(`p`,{className:`${f} leading-relaxed`,children:[`Toggle `,u(`strong`,{className:`text-foreground`,children:`Edit mask`}),` to draw blanked-out zones on the live frame, then `,u(`strong`,{className:`text-foreground`,children:`Save`}),` 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.`]}),o(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[u(`button`,{type:`button`,onClick:ce,disabled:M,"aria-pressed":P,className:P?x:b,children:P?`Done editing`:`Edit mask`}),u(`button`,{type:`button`,onClick:K,disabled:M,"aria-pressed":O.enabled,className:O.enabled?x:b,children:O.enabled?`Mask on`:`Mask off`}),le&&u(`button`,{type:`button`,onClick:()=>Z(`rect`),disabled:M||G,"aria-pressed":R===`rect`,className:R===`rect`?x:b,title:G?`Maximum zones reached`:`Add a rectangle zone`,children:`+ Rect`}),ue&&u(`button`,{type:`button`,onClick:()=>Z(`polygon`),disabled:M||G,"aria-pressed":R===`polygon`,className:R===`polygon`?x:b,title:G?`Maximum zones reached`:`Add a polygon zone`,children:`+ Polygon`}),o(`span`,{className:`${f} ml-1 tabular-nums`,children:[H,` / `,U,` zones`]}),u(`span`,{className:`flex-1`}),u(`button`,{type:`button`,onClick:oe,disabled:M||!V,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:`Revert`}),u(`button`,{type:`button`,onClick:()=>void se(),disabled:M||!V,className:x,children:M?`Saving…`:`Save`})]}),H>0?u(`div`,{className:`flex flex-col gap-1`,children:O.regions.map(t=>{let r=I===t.id,i=t.shape.kind===`polygon`?ne:e;return o(`div`,{className:`flex items-center gap-2 rounded-md border px-2 py-1 transition-colors ${r?`border-primary/50 bg-primary/10`:`border-border bg-surface`}`,children:[o(`button`,{type:`button`,onClick:()=>ie(t.id),disabled:M,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:[u(i,{className:`h-3.5 w-3.5 shrink-0`}),o(`span`,{children:[`Zone `,t.id]}),u(`span`,{className:`text-foreground-faint capitalize`,children:t.shape.kind})]}),u(`button`,{type:`button`,onClick:()=>ae(t.id),disabled:M,"aria-label":`Delete zone ${String(t.id)}`,title:`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:u(n,{className:`h-3.5 w-3.5`})})]},t.id)})}):null]}):u(`p`,{className:`${f} leading-relaxed`,children:`Loading the camera's privacy mask…`})})}):null}export{w as PrivacyMaskSettings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Q as e,S as t,q as n,x as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{t as i}from"./radio-BM7T2fMm.js";import{t as a}from"./wifi-Cr9H7WCZ.js";import{H as o,p as s}from"./index-3DCschCe.js";var c=o(`cctv`,[[`path`,{d:`M16.75 12h3.632a1 1 0 0 1 .894 1.447l-2.034 4.069a1 1 0 0 1-1.708.134l-2.124-2.97`,key:`ir91b5`}],[`path`,{d:`M17.106 9.053a1 1 0 0 1 .447 1.341l-3.106 6.211a1 1 0 0 1-1.342.447L3.61 12.3a2.92 2.92 0 0 1-1.3-3.91L3.69 5.6a2.92 2.92 0 0 1 3.92-1.3z`,key:`jlp8i1`}],[`path`,{d:`M2 19h3.76a2 2 0 0 0 1.8-1.1L9 15`,key:`19bib8`}],[`path`,{d:`M2 21v-4`,key:`l40lih`}],[`path`,{d:`M7 9h.01`,key:`19b3jx`}]]),l=o(`house`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`1d0kgt`}]]);e();var u={frigate:{icon:c,color:`#3b82f6`,label:`Frigate`},scrypted:{icon:s,color:`#a855f7`,label:`Scrypted`},reolink:{icon:i,color:`#06b6d4`,label:`Reolink`},homeassistant:{icon:l,color:`#22d3ee`,label:`Home Assistant`},rtsp:{icon:a,color:`#78716c`,label:`RTSP`},onvif:{icon:a,color:`#78716c`,label:`ONVIF`}},d={sm:`h-4 w-4`,md:`h-5 w-5`,lg:`h-6 w-6`},f={sm:`h-7 w-7`,md:`h-8 w-8`,lg:`h-10 w-10`};function p(e){let t=e.toLowerCase();return t.startsWith(`provider-`)?t.slice(9):t}function m(e){return u[p(e)]??{icon:c,color:`#78716c`,label:e}}function h(e){let t=p(e);return`/api/addon-assets/${e.toLowerCase().startsWith(`provider-`)?e:`provider-${t}`}/assets/icon.svg`}function g({type:e,size:i=`md`,showLabel:a}){let o=m(e),s=o.icon,[c,l]=n(!1),u=h(e);return t(`div`,{className:`flex items-center gap-2`,children:[r(`div`,{className:`flex items-center justify-center rounded-lg ${f[i]}`,style:{backgroundColor:`${o.color}15`},children:c?r(s,{className:d[i],style:{color:o.color}}):r(`img`,{src:u,alt:o.label,className:d[i],onError:()=>l(!0)})}),a&&r(`span`,{className:`text-xs font-medium text-foreground-subtle`,children:o.label})]})}export{g as t};
|