@camstack/addon-admin-ui 1.1.31 → 1.1.32
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-CoTQ1C0P.js → AddLocationWizard-B49NZRL3.js} +1 -1
- package/dist/assets/{AddonCollectionPage-Br_mtznf.js → AddonCollectionPage-D6WEaUrV.js} +1 -1
- package/dist/assets/{Addons-BW1fbKyX.js → Addons-C7wjP72v.js} +1 -1
- package/dist/assets/{AdminTabs-65LS38O7.js → AdminTabs-ByKyAQ9o.js} +1 -1
- package/dist/assets/{BrokerForm-CJOIbxU1.js → BrokerForm-D7z9SPAh.js} +1 -1
- package/dist/assets/{Capabilities-DVCIj63p.js → Capabilities-BBmYPVBS.js} +1 -1
- package/dist/assets/{CapabilityBadges-DHKu7X9M.js → CapabilityBadges-DW98scbL.js} +1 -1
- package/dist/assets/{Cluster-DXsPIAud.js → Cluster-CKbkQBJg.js} +1 -1
- package/dist/assets/{Dashboard-DoGVZOeG.js → Dashboard-BIveE3fe.js} +1 -1
- package/dist/assets/{Data-AE4ujje6.js → Data-CG1ffVYI.js} +1 -1
- package/dist/assets/{DetectionIntelligence-9Y96FdEf.js → DetectionIntelligence-m3Gblh62.js} +1 -1
- package/dist/assets/{DeviceDetail-PQfHJrSX.js → DeviceDetail-CxJp1Pzo.js} +2 -2
- package/dist/assets/{Devices-CNp9pqiU.js → Devices-ll8M1Ncu.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-BY1XGljW.js → EmbedPlayerPage--mX_qWe2.js} +1 -1
- package/dist/assets/{FormBuilder-CPSLjDeb.js → FormBuilder-BOR8MwQh.js} +1 -1
- package/dist/assets/{Identity-Bsaqp7-s.js → Identity-03jTBtOY.js} +1 -1
- package/dist/assets/{IntegrationDetail-Cvr_93Re.js → IntegrationDetail-CrMY_tqZ.js} +1 -1
- package/dist/assets/{Integrations-BuPQK_EH.js → Integrations-BbLuZkw-.js} +1 -1
- package/dist/assets/{Integrations-Y0ziVjly.js → Integrations-DTB0Q8Iq.js} +1 -1
- package/dist/assets/{Logs-DkqRdR14.js → Logs-CaepNhYY.js} +1 -1
- package/dist/assets/{MotionZonesSettings-BtVUNK7D.js → MotionZonesSettings-Ben395kc.js} +1 -1
- package/dist/assets/{MyAccess-C6qT1LES.js → MyAccess-CzSk-u6_.js} +1 -1
- package/dist/assets/{Network-Cj8f56PJ.js → Network-D3Sgp6jH.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-CaMCtRtL.js → NodeAddonsSettingsPanel-B6PqT-t7.js} +1 -1
- package/dist/assets/{NotificationTargets-DO6tp_-o.js → NotificationTargets-DJG6lTeh.js} +1 -1
- package/dist/assets/Pipeline-BDZ0jYN9.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-DfGtcPz_.js → PrivacyMaskSettings-DcbT3P11.js} +1 -1
- package/dist/assets/{ProviderIcon-B7VHX4h5.js → ProviderIcon-BAt5zH7S.js} +1 -1
- package/dist/assets/{ScanNetworkModal-k76UGIG5.js → ScanNetworkModal-CDsYObTW.js} +1 -1
- package/dist/assets/{Settings-B6QqX2do.js → Settings-CfIfwWWT.js} +1 -1
- package/dist/assets/{Showroom-Cwko7Yni.js → Showroom-Bqct8dz-.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-pD0FKW7m.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C98kaHYZ.js} +1 -1
- package/dist/assets/{build-cluster-graph-Ci-E0Tjd.js → build-cluster-graph-rMGHm8c-.js} +1 -1
- package/dist/assets/circle-check-big-DQ3guN_r.js +1 -0
- package/dist/assets/{copy-BqJTD0NL.js → copy-CiComBfB.js} +1 -1
- package/dist/assets/dist-B6KoWNcX.js +7 -0
- package/dist/assets/{dist-Bs1zChcu.js → dist-BQHV09qT.js} +1 -1
- package/dist/assets/{download-DRBhCGtf.js → download-BuqeRkSg.js} +1 -1
- package/dist/assets/{hostInit-Dmv2Dz_q.js → hostInit-CLd0-6Wi.js} +1 -1
- package/dist/assets/{index-CukLUOO-.js → index-Cc9fD-gx.js} +3 -3
- package/dist/assets/index-CdGv2Hwk.css +2 -0
- package/dist/assets/{key-round-92fgndyk.js → key-round-eOR5havz.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-5e99685c.js → mf-entry-bootstrap-0-f3c297a2.js} +2 -2
- package/dist/assets/{pencil-GseW53Af.js → pencil-Ba6F99Ky.js} +1 -1
- package/dist/assets/{player-overlays-DACImv1W.js → player-overlays-CTSvk_LT.js} +1 -1
- package/dist/assets/plus-CE0W2UFU.js +1 -0
- package/dist/assets/{radio-BDUnjOmb.js → radio-J1OjdHB9.js} +1 -1
- package/dist/assets/{refresh-cw-TV5MkG3n.js → refresh-cw-CqOhKMTh.js} +1 -1
- package/dist/assets/remoteEntry-DAiYaCUD.js +1 -0
- package/dist/assets/{rotate-ccw-DvDKOoJk.js → rotate-ccw-BCts0SIy.js} +1 -1
- package/dist/assets/rotate-cw-BCnMfcJH.js +1 -0
- package/dist/assets/search-DKGrktz2.js +1 -0
- package/dist/assets/{server-BrxSxrRc.js → server-C-bvt-pD.js} +1 -1
- package/dist/assets/{sparkles-BLSwH3NZ.js → sparkles-DjNz_0u-.js} +1 -1
- package/dist/assets/square-CUAs3tdB.js +1 -0
- package/dist/assets/{square-check-big-DZGG97xQ.js → square-check-big-DwJspzeZ.js} +1 -1
- package/dist/assets/src-DOrkbNeH.js +7 -0
- package/dist/assets/{src-3NEgkLWp.js → src-DdZmgXMF.js} +10 -10
- package/dist/assets/{upload-UD1RyugS.js → upload-CKV8eS2H.js} +1 -1
- package/dist/assets/useDevice-CXedlGPP.js +1 -0
- package/dist/assets/{useEventInvalidation-C6mDyTBx.js → useEventInvalidation-CaNVSWxK.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CZAUwRYb.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-B1Emnhxt.js} +2 -2
- package/dist/assets/{wifi-Bzb_4egH.js → wifi-CUZMfwFz.js} +1 -1
- package/dist/assets/{zap-ps4S9uq0.js → zap-aXoc7k_J.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/server/addon.js +248 -4
- package/package.json +1 -1
- package/dist/assets/Pipeline-Bq-_taoo.js +0 -1
- package/dist/assets/circle-check-big-uwi7M0FF.js +0 -1
- package/dist/assets/dist-DozEYSra.js +0 -7
- package/dist/assets/index-7ucUNPxm.css +0 -2
- package/dist/assets/plus-D1FskUey.js +0 -1
- package/dist/assets/remoteEntry-Ci-8NIZN.js +0 -1
- package/dist/assets/rotate-cw-Dv3oho6L.js +0 -1
- package/dist/assets/search-CvffVaTb.js +0 -1
- package/dist/assets/square-D5hZ81IL.js +0 -1
- package/dist/assets/src-DAcus8MI.js +0 -7
- package/dist/assets/useDevice-B_z2JZ7g.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$i as e,Aa as t,Dr as n,Er as r,Ni as i,Sr as a,Tr as o,_r as s,br as c,fa as l,gr as u,hr as d,ht as f,ja as p,ka as m,mr as h,mt as g,pr as ee,vr as _,xr as v,yr as y}from"./src-3NEgkLWp.js";import{I as b,Q as x,S,W as C,b as w,o as T,q as E,x as D,z as te}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 O,s as k}from"./src-DAcus8MI.js";import{p as A}from"./player-overlays-DACImv1W.js";import{n as j,t as ne}from"./rotate-ccw-DvDKOoJk.js";import{t as M}from"./copy-BqJTD0NL.js";import{n as re,t as N}from"./AddonCollectionPage-Br_mtznf.js";import{t as ie}from"./refresh-cw-TV5MkG3n.js";import{t as P}from"./server-BrxSxrRc.js";import{t as ae}from"./sparkles-BLSwH3NZ.js";import{t as oe}from"./square-D5hZ81IL.js";import{t as se}from"./wifi-Bzb_4egH.js";import{D as F,F as ce,V as I,_ as L,b as le,i as ue,o as R,w as z,x as B,y as V}from"./index-CukLUOO-.js";import{t as H}from"./AdminPage-BwmGKnRf.js";import{t as U}from"./AdminTabs-65LS38O7.js";var de=I(`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`}]]),fe=I(`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=I(`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`}]]);x();var G=5e3,pe={connected:!1,endpoint:null};function me(e){let t=new Map;for(let n of e){let e=n?.manifest;e?.id&&t.set(e.id,e.packageDisplayName??e.name??e.id)}return t}function he(){let e=T(),t=f({capName:`network-access`},{refetchInterval:G}),i=g(void 0,{refetchInterval:G}),a=C(()=>me(i.data??[]),[i.data]),o=C(()=>(t.data??[]).map(e=>({addonId:e.addonId,displayName:a.get(e.addonId)??e.addonId,isActive:e.isActive})),[t.data,a]),[s,c]=E(null),[l,u]=E({}),d=(t,n)=>{let r=n?.addonId;e.invalidateQueries({queryKey:[[`networkAccess`,`getStatus`],{input:{addonId:r},type:`query`}]}),c(null),u(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);u(e=>({...e,[n]:r}))},m=r({onSuccess:d,onError:p}),h=n({onSuccess:d,onError:p});return D(N,{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:z,itemIcon:z,capability:`network-access`,installButtonLabel:`Add tunnel`,items:o,isLoading:t.isLoading,emptyTitle:`No remote-access providers installed`,emptyDescription:`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`,renderStatusBadges:e=>D(ge,{addonId:e.addonId}),itemError:e=>l[e.addonId]??null,renderPrimaryAction:e=>D(_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}=o({addonId:e},{refetchInterval:G,retry:!1}),n=t?k.safeParse(t):null;return n?.success?n.data:pe}function ge({addonId:e}){let t=K(e);return S(w,{children:[D(`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&&S(`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:[D(F,{className:`h-3 w-3`}),t.endpoint.url]})]})}function _e({addonId:e,busyId:t,onStart:n,onStop:r}){let i=K(e),a=t===e;return i.connected?S(p,{size:`sm`,variant:`secondary`,disabled:a,onClick:()=>r(e),children:[a?D(B,{className:`h-3 w-3 animate-spin`}):D(oe,{className:`h-3 w-3`}),`Stop`]}):S(p,{size:`sm`,variant:`primary`,disabled:a,onClick:()=>n(e),children:[a?D(B,{className:`h-3 w-3 animate-spin`}):D(re,{className:`h-3 w-3`}),`Start`]})}x();var q=3e4;function ve(e){let t=new Map;for(let n of e){let e=n?.manifest;e?.id&&t.set(e.id,e.packageDisplayName??e.name??e.id)}return t}function ye(e){let t=[];for(let n of e)typeof n.urls==`string`?t.push(n.urls):t.push(...n.urls);return t}function be(){let e=f({capName:`turn-provider`},{refetchInterval:q}),t=g(void 0,{refetchInterval:q}),n=i(),r=n.data??[],a=C(()=>ve(t.data??[]),[t.data]);return D(N,{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:L,itemIcon:L,capability:`turn-provider`,installButtonLabel:`Add provider`,items:C(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:a.get(e.addonId)??e.addonId,isActive:e.isActive})),[e.data,a]),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=>D(xe,{addonId:e.addonId,enabled:e.isActive}),trailing:S(m,{children:[S(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between`,children:[S(`div`,{children:[D(`div`,{className:`text-sm font-semibold`,children:`Combined ICE server list`}),D(`div`,{className:`text-xs text-foreground-subtle`,children:`What the WebRTC layer fetches per-session.`})]}),D(p,{size:`sm`,variant:`secondary`,onClick:()=>n.refetch(),disabled:n.isFetching,children:`Refresh`})]}),D(`div`,{className:`p-4`,children:r.length===0?D(`div`,{className:`text-xs text-foreground-subtle`,children:`No servers from enabled providers.`}):D(`div`,{className:`flex flex-col gap-3`,children:r.map((e,t)=>{let n=Array.isArray(e.urls)?e.urls:[e.urls];return S(`div`,{className:`rounded border border-border bg-surface`,children:[(e.username||e.credential)&&S(`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&&S(`span`,{children:[D(`span`,{className:`text-foreground-subtle`,children:`user:`}),` `,D(`span`,{className:`text-foreground`,children:e.username})]}),e.credential&&S(`span`,{children:[D(`span`,{className:`text-foreground-subtle`,children:`credential:`}),` `,D(`span`,{className:`text-foreground`,children:`••••••••`})]})]}),D(`ul`,{className:`divide-y divide-border`,children:n.map(e=>D(`li`,{className:`px-3 py-1.5 font-mono text-xs text-foreground break-all`,children:e},e))})]},t)})})})]})})}function xe({addonId:e,enabled:t}){let n=i({addonId:e},{enabled:t,retry:!1}),r=C(()=>ye(n.data??[]),[n.data]);return!t||r.length===0?null:S(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[S(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Discovered ICE servers (`,r.length,`)`]}),D(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>D(`span`,{className:`inline-block rounded px-1.5 py-0.5 text-[10px] font-mono bg-foreground-subtle/10 text-foreground`,children:e},e))})]})}x();var Se={lan:L,wifi:se,docker:j,vpn:le,loopback:P,other:P},Ce={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},we=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function Te(e){let{interfaces:t,disabled:n,hideLoopback:r,ipv4Only:i,emptyMessage:a}=e,o=C(()=>t.filter(e=>!(r&&e.kind===`loopback`||i&&e.family!==`IPv4`)),[t,r,i]),s=C(()=>{let e=new Map;for(let t of o){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return we.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?D(`div`,{className:`text-xs text-foreground-subtle italic`,children:a??`No addresses available.`}):D(`div`,{className:`flex flex-col gap-3`,children:s.map(({kind:t,items:r})=>S(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[S(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[D(Se[t]??P,{className:`h-3.5 w-3.5 text-foreground-subtle`}),D(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:Ce[t]??t}),S(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,r.length]})]}),D(`ul`,{className:`divide-y divide-border`,children:r.map(t=>{let r=c(t.address),i=t.kind===`loopback`,a=!t.plausible&&!i;return S(`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:[D(`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&&D(ce,{className:`h-3 w-3`})}),S(`div`,{className:`flex-1 min-w-0 ${a?`text-foreground-subtle`:``}`,children:[S(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[D(`span`,{className:`font-mono text-xs font-semibold ${a?`text-foreground-subtle`:`text-foreground`}`,children:t.name}),D(`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&&D(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:`Auto-preferred`}),i&&D(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:`Always included`}),a&&S(`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:[D(R,{className:`h-2.5 w-2.5`}),`Unlikely usable`]})]}),S(`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))})}x();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 Ee(){let e=T(),t=A(),n=d(void 0,{refetchInterval:3e4}),r=ee(void 0),i=s({onSuccess:()=>{e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),a=u({onSuccess:t=>{f(t.addresses),e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),o=C(()=>n.data?.interfaces??[],[n.data]),c=h({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}),[l,f]=E([]),[g,_]=E(!1);te(()=>{!g&&r.data&&(f(r.data.addresses),_(!0))},[r.data,g]);let v=r.data?.addresses??[],y=C(()=>{if(l.length!==v.length)return!0;let e=[...l].toSorted(),t=[...v].toSorted();return e.some((e,n)=>e!==t[n])},[l,v]),b=()=>{i.mutate({addresses:[...l]})},x=()=>{f(v)},w=()=>{f([])},O=()=>{n.refetch(),c.refetch(),r.refetch()},k=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)}},j=c.data?.endpoints??[];return S(H,{children:[S(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[D(`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.`}),S(`div`,{className:`flex items-center gap-2 shrink-0`,children:[S(p,{size:`sm`,variant:`secondary`,onClick:O,disabled:n.isLoading,children:[D(ie,{className:`h-3 w-3 ${n.isLoading?`animate-spin`:``}`}),`Refresh`]}),D(p,{size:`sm`,variant:`secondary`,onClick:k,children:`Probe race`})]})]}),S(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[S(m,{children:[S(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between`,children:[S(`div`,{children:[D(`div`,{className:`text-sm font-semibold`,children:`Allowed addresses`}),D(`div`,{className:`text-xs text-foreground-subtle`,children:l.length===0?`Auto — every non-loopback / non-link-local interface participates.`:`${l.length} pinned`})]}),S(`div`,{className:`flex items-center gap-1`,children:[S(p,{size:`sm`,variant:`secondary`,onClick:()=>a.mutate(void 0),disabled:a.isPending||i.isPending,title:`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`,children:[D(ae,{className:`h-3 w-3`}),a.isPending?`Detecting…`:`Best match`]}),S(p,{size:`sm`,variant:`secondary`,onClick:w,disabled:l.length===0||i.isPending,children:[D(ne,{className:`h-3 w-3`}),`Clear`]}),y&&D(p,{size:`sm`,variant:`secondary`,onClick:x,disabled:i.isPending,children:`Discard`}),S(p,{size:`sm`,variant:`primary`,onClick:b,disabled:!y||i.isPending,children:[D(fe,{className:`h-3 w-3`}),i.isPending?`Saving…`:`Save`]})]})]}),D(`div`,{className:`p-4`,children:D(Te,{mode:`multiple`,interfaces:o,value:l,onChange:f,disabled:i.isPending,emptyMessage:n.isLoading?`Loading interfaces…`:`No interfaces detected.`})})]}),S(m,{children:[S(`div`,{className:`px-4 py-3 border-b border-border`,children:[D(`div`,{className:`text-sm font-semibold`,children:`Connection endpoints — priority order`}),D(`div`,{className:`text-xs text-foreground-subtle`,children:`Live preview of the ranked candidate list the SDK would race against. Updates with each Save.`})]}),D(`div`,{className:`p-4`,children:j.length===0?D(`div`,{className:`text-xs text-foreground-subtle italic`,children:c.isLoading?`Loading…`:`No endpoints available.`}):D(`ul`,{className:`space-y-1 text-xs`,children:j.map(e=>S(`li`,{className:`flex items-center gap-2 flex-wrap ${e.plausible?``:`opacity-80`}`,children:[D(`span`,{className:`font-mono text-[10px] w-10 text-foreground-subtle`,children:String(e.priority).padStart(4,`0`)}),D(`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`&&D(`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`&&S(`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:[D(R,{className:`h-2.5 w-2.5`}),`Unlikely usable`]}),D(`span`,{className:`font-mono break-all ${e.plausible?`text-foreground`:`text-foreground-subtle`}`,children:e.baseUrl}),S(`span`,{className:`text-foreground-subtle`,children:[`— `,e.label]})]},`${e.priority}-${e.baseUrl}`))})})]})]})]})}x();var De={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,Oe=3e4,ke={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function Ae(e){let t=new Map;for(let n of e){let e=n?.manifest;e?.id&&t.set(e.id,e.packageDisplayName??e.name??e.id)}return t}function je(){let e=f({capName:`mesh-network`},{refetchInterval:Y}),t=g(void 0,{refetchInterval:Y}),n=C(()=>Ae(t.data??[]),[t.data]);return D(N,{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:j,itemIcon:L,capability:`mesh-network`,installButtonLabel:`Add mesh`,items:C(()=>(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=>D(Me,{addonId:e.addonId}),renderPrimaryAction:e=>D(Z,{addonId:e.addonId}),renderExpandedPanel:e=>D(Ne,{addonId:e.addonId})})}function X(e){let{data:t,isLoading:n}=_({addonId:e},{refetchInterval:Y,retry:!1}),r=t?O.safeParse(t):null;return{status:r?.success?r.data:ke,isLoading:n}}function Me({addonId:e}){let{status:t}=X(e);return S(w,{children:[D(`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&&S(`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 Z({addonId:e}){let t=T(),[n,r]=E(!1),[i,o]=E(null),s=A(),{status:c}=X(e),l=b(()=>{t.invalidateQueries({queryKey:[[`meshNetwork`]]})},[t]),u=a(),d=y({onSuccess:l}),f=v({onSuccess:l}),m=b(async()=>{r(!0);let t={cancelled:!1};o(t);try{let n=await u.mutateAsync({addonId:e});if(t.cancelled)return;n.loginUrl&&window.open(n.loginUrl,`_blank`,`noopener,noreferrer`);let r=Date.now();for(;!t.cancelled&&(await Re(2e3),!t.cancelled);){let t=await s.trpcClient.meshNetwork.getStatus.query({addonId:e}).catch(()=>null),n=t?O.safeParse(t):null;if(n?.success&&n.data.joined){l();break}if(Date.now()-r>6e5)break}}finally{r(!1),o(null)}},[e,l,u,s]),h=b(()=>{i&&(i.cancelled=!0),r(!1),o(null)},[i]);return D(w,{children:c.joined?S(w,{children:[S(p,{size:`sm`,variant:`secondary`,disabled:d.isPending,onClick:()=>d.mutate({addonId:e}),children:[d.isPending?D(B,{className:`h-3 w-3 animate-spin`}):D(V,{className:`h-3 w-3`}),`Disconnect`]}),S(p,{size:`sm`,variant:`ghost`,disabled:f.isPending,onClick:()=>f.mutate({addonId:e}),children:[f.isPending?D(B,{className:`h-3 w-3 animate-spin`}):D(W,{className:`h-3 w-3`}),`Log out`]})]}):n?S(p,{size:`sm`,variant:`ghost`,onClick:h,children:[D(ue,{className:`h-3 w-3 mr-1`}),` Cancel`]}):S(w,{children:[S(p,{size:`sm`,variant:`primary`,onClick:()=>void m(),children:[D(de,{className:`h-3 w-3`}),`Connect`]}),S(p,{size:`sm`,variant:`ghost`,disabled:f.isPending,onClick:()=>f.mutate({addonId:e}),children:[f.isPending?D(B,{className:`h-3 w-3 animate-spin`}):D(W,{className:`h-3 w-3`}),`Log out`]})]})})}function Ne({addonId:t}){let{status:n}=X(t),r=c({addonId:t},{refetchInterval:Oe,retry:!1});return S(`div`,{className:`rounded-lg border border-border bg-surface`,children:[S(`div`,{className:`p-4 space-y-4`,children:[n.error&&D(e,{message:n.error}),D(Pe,{status:n}),n.endpoints.length>0&&S(`div`,{className:`space-y-1.5`,children:[D(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:`Endpoints`}),n.endpoints.map(e=>S(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[S(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${De[e.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[e.scope===`public`?D(z,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,e.label]}),S(`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:[D(F,{className:`h-3 w-3 shrink-0`}),e.url]})]},e.id))]})]}),D(`div`,{className:`border-t border-border`,children:D(Ie,{peers:r.data?.peers??[],loading:r.isLoading})})]})}function Pe({status:e}){return D(`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?Fe(e.keyExpiry):`—`}].map(e=>S(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[D(`span`,{className:`text-foreground-subtle shrink-0`,children:e.label}),D(`span`,{className:`text-foreground truncate ${e.mono?`font-mono`:``}`,children:e.value})]},e.label))})}function Fe(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 Ie({peers:e,loading:n}){let r=C(()=>e.map(e=>({...e,_id:e.id})),[e]),i=b(e=>{e&&navigator.clipboard?.writeText(e)},[]),a=C(()=>[{key:`hostname`,header:`Hostname`,render:e=>S(`div`,{className:`flex flex-col`,children:[S(`div`,{className:`flex items-center gap-1.5`,children:[D(`span`,{className:`font-medium text-foreground`,children:e.hostname||`(unknown)`}),e.isSelf&&D(t,{variant:`info`,children:`self`}),e.exitNodeOption&&D(t,{variant:`warning`,children:`exit-node`})]}),e.userLogin&&D(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.userLogin})]})},{key:`magicDns`,header:`MagicDNS`,render:e=>e.magicDns?S(`div`,{className:`flex items-center gap-1`,children:[D(`span`,{className:`font-mono text-xs truncate`,children:e.magicDns}),D(`button`,{onClick:()=>i(e.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":`Copy MagicDNS`,children:D(M,{className:`h-3 w-3 text-foreground-subtle`})})]}):D(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:e=>{let t=e.addresses[0]??``;return t?S(`div`,{className:`flex items-center gap-1`,children:[D(`span`,{className:`font-mono text-xs`,children:t}),D(`button`,{onClick:()=>i(t),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":`Copy IP`,children:D(M,{className:`h-3 w-3 text-foreground-subtle`})})]}):D(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:`Connection`,render:e=>S(`div`,{className:`flex items-center gap-1.5`,children:[D(t,{variant:Le(e.connection),children:e.connection}),e.relay&&D(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.relay})]})},{key:`routes`,header:`Routes`,render:e=>e.advertisedRoutes.length>0?D(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):D(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:`TX / RX`,render:e=>S(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,Q(e.txBytes),` · ↓ `,Q(e.rxBytes)]})},{key:`lastSeen`,header:`Last seen`,render:e=>D(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?$(e.lastSeenMs):`—`})}],[i]);return n&&e.length===0?S(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[D(B,{className:`h-3 w-3 animate-spin inline mr-1`}),` Loading peers…`]}):e.length===0?D(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:`No peers visible — your tailnet may be empty or the host is not joined.`}):D(`div`,{className:`p-4`,children:D(l,{columns:a,rows:r,rowKey:e=>e._id,minWidthPx:820})})}function Le(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 Re(e){return new Promise(t=>setTimeout(t,e))}function ze(){return D(`div`,{className:`flex flex-col p-4`,children:D(U,{tabs:[{id:`addresses`,label:`Network Addresses`,icon:P,content:D(Ee,{})},{id:`remote-access`,label:`Remote Access`,icon:z,content:D(he,{})},{id:`mesh`,label:`Mesh Networks`,icon:j,content:D(je,{})},{id:`turn`,label:`TURN Servers`,icon:L,content:D(be,{})}]})})}export{ze as NetworkPage};
|
|
1
|
+
import{$i as e,Aa as t,Dr as n,Er as r,Ni as i,Sr as a,Tr as o,_r as s,br as c,fa as l,gr as u,hr as d,ht as f,ja as p,ka as m,mr as h,mt as g,pr as ee,vr as _,xr as v,yr as y}from"./src-DdZmgXMF.js";import{I as b,Q as x,S,W as C,b as w,o as T,q as E,x as D,z as te}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 O,s as k}from"./src-DOrkbNeH.js";import{p as A}from"./player-overlays-CTSvk_LT.js";import{n as j,t as ne}from"./rotate-ccw-BCts0SIy.js";import{t as M}from"./copy-CiComBfB.js";import{n as re,t as N}from"./AddonCollectionPage-D6WEaUrV.js";import{t as ie}from"./refresh-cw-CqOhKMTh.js";import{t as P}from"./server-C-bvt-pD.js";import{t as ae}from"./sparkles-DjNz_0u-.js";import{t as oe}from"./square-CUAs3tdB.js";import{t as se}from"./wifi-CUZMfwFz.js";import{D as F,F as ce,V as I,_ as L,b as le,i as ue,o as R,w as z,x as B,y as V}from"./index-Cc9fD-gx.js";import{t as H}from"./AdminPage-BwmGKnRf.js";import{t as U}from"./AdminTabs-ByKyAQ9o.js";var de=I(`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`}]]),fe=I(`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=I(`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`}]]);x();var G=5e3,pe={connected:!1,endpoint:null};function me(e){let t=new Map;for(let n of e){let e=n?.manifest;e?.id&&t.set(e.id,e.packageDisplayName??e.name??e.id)}return t}function he(){let e=T(),t=f({capName:`network-access`},{refetchInterval:G}),i=g(void 0,{refetchInterval:G}),a=C(()=>me(i.data??[]),[i.data]),o=C(()=>(t.data??[]).map(e=>({addonId:e.addonId,displayName:a.get(e.addonId)??e.addonId,isActive:e.isActive})),[t.data,a]),[s,c]=E(null),[l,u]=E({}),d=(t,n)=>{let r=n?.addonId;e.invalidateQueries({queryKey:[[`networkAccess`,`getStatus`],{input:{addonId:r},type:`query`}]}),c(null),u(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);u(e=>({...e,[n]:r}))},m=r({onSuccess:d,onError:p}),h=n({onSuccess:d,onError:p});return D(N,{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:z,itemIcon:z,capability:`network-access`,installButtonLabel:`Add tunnel`,items:o,isLoading:t.isLoading,emptyTitle:`No remote-access providers installed`,emptyDescription:`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`,renderStatusBadges:e=>D(ge,{addonId:e.addonId}),itemError:e=>l[e.addonId]??null,renderPrimaryAction:e=>D(_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}=o({addonId:e},{refetchInterval:G,retry:!1}),n=t?k.safeParse(t):null;return n?.success?n.data:pe}function ge({addonId:e}){let t=K(e);return S(w,{children:[D(`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&&S(`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:[D(F,{className:`h-3 w-3`}),t.endpoint.url]})]})}function _e({addonId:e,busyId:t,onStart:n,onStop:r}){let i=K(e),a=t===e;return i.connected?S(p,{size:`sm`,variant:`secondary`,disabled:a,onClick:()=>r(e),children:[a?D(B,{className:`h-3 w-3 animate-spin`}):D(oe,{className:`h-3 w-3`}),`Stop`]}):S(p,{size:`sm`,variant:`primary`,disabled:a,onClick:()=>n(e),children:[a?D(B,{className:`h-3 w-3 animate-spin`}):D(re,{className:`h-3 w-3`}),`Start`]})}x();var q=3e4;function ve(e){let t=new Map;for(let n of e){let e=n?.manifest;e?.id&&t.set(e.id,e.packageDisplayName??e.name??e.id)}return t}function ye(e){let t=[];for(let n of e)typeof n.urls==`string`?t.push(n.urls):t.push(...n.urls);return t}function be(){let e=f({capName:`turn-provider`},{refetchInterval:q}),t=g(void 0,{refetchInterval:q}),n=i(),r=n.data??[],a=C(()=>ve(t.data??[]),[t.data]);return D(N,{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:L,itemIcon:L,capability:`turn-provider`,installButtonLabel:`Add provider`,items:C(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:a.get(e.addonId)??e.addonId,isActive:e.isActive})),[e.data,a]),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=>D(xe,{addonId:e.addonId,enabled:e.isActive}),trailing:S(m,{children:[S(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between`,children:[S(`div`,{children:[D(`div`,{className:`text-sm font-semibold`,children:`Combined ICE server list`}),D(`div`,{className:`text-xs text-foreground-subtle`,children:`What the WebRTC layer fetches per-session.`})]}),D(p,{size:`sm`,variant:`secondary`,onClick:()=>n.refetch(),disabled:n.isFetching,children:`Refresh`})]}),D(`div`,{className:`p-4`,children:r.length===0?D(`div`,{className:`text-xs text-foreground-subtle`,children:`No servers from enabled providers.`}):D(`div`,{className:`flex flex-col gap-3`,children:r.map((e,t)=>{let n=Array.isArray(e.urls)?e.urls:[e.urls];return S(`div`,{className:`rounded border border-border bg-surface`,children:[(e.username||e.credential)&&S(`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&&S(`span`,{children:[D(`span`,{className:`text-foreground-subtle`,children:`user:`}),` `,D(`span`,{className:`text-foreground`,children:e.username})]}),e.credential&&S(`span`,{children:[D(`span`,{className:`text-foreground-subtle`,children:`credential:`}),` `,D(`span`,{className:`text-foreground`,children:`••••••••`})]})]}),D(`ul`,{className:`divide-y divide-border`,children:n.map(e=>D(`li`,{className:`px-3 py-1.5 font-mono text-xs text-foreground break-all`,children:e},e))})]},t)})})})]})})}function xe({addonId:e,enabled:t}){let n=i({addonId:e},{enabled:t,retry:!1}),r=C(()=>ye(n.data??[]),[n.data]);return!t||r.length===0?null:S(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[S(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Discovered ICE servers (`,r.length,`)`]}),D(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>D(`span`,{className:`inline-block rounded px-1.5 py-0.5 text-[10px] font-mono bg-foreground-subtle/10 text-foreground`,children:e},e))})]})}x();var Se={lan:L,wifi:se,docker:j,vpn:le,loopback:P,other:P},Ce={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},we=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function Te(e){let{interfaces:t,disabled:n,hideLoopback:r,ipv4Only:i,emptyMessage:a}=e,o=C(()=>t.filter(e=>!(r&&e.kind===`loopback`||i&&e.family!==`IPv4`)),[t,r,i]),s=C(()=>{let e=new Map;for(let t of o){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return we.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?D(`div`,{className:`text-xs text-foreground-subtle italic`,children:a??`No addresses available.`}):D(`div`,{className:`flex flex-col gap-3`,children:s.map(({kind:t,items:r})=>S(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[S(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[D(Se[t]??P,{className:`h-3.5 w-3.5 text-foreground-subtle`}),D(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:Ce[t]??t}),S(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,r.length]})]}),D(`ul`,{className:`divide-y divide-border`,children:r.map(t=>{let r=c(t.address),i=t.kind===`loopback`,a=!t.plausible&&!i;return S(`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:[D(`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&&D(ce,{className:`h-3 w-3`})}),S(`div`,{className:`flex-1 min-w-0 ${a?`text-foreground-subtle`:``}`,children:[S(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[D(`span`,{className:`font-mono text-xs font-semibold ${a?`text-foreground-subtle`:`text-foreground`}`,children:t.name}),D(`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&&D(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:`Auto-preferred`}),i&&D(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:`Always included`}),a&&S(`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:[D(R,{className:`h-2.5 w-2.5`}),`Unlikely usable`]})]}),S(`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))})}x();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 Ee(){let e=T(),t=A(),n=d(void 0,{refetchInterval:3e4}),r=ee(void 0),i=s({onSuccess:()=>{e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),a=u({onSuccess:t=>{f(t.addresses),e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),o=C(()=>n.data?.interfaces??[],[n.data]),c=h({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}),[l,f]=E([]),[g,_]=E(!1);te(()=>{!g&&r.data&&(f(r.data.addresses),_(!0))},[r.data,g]);let v=r.data?.addresses??[],y=C(()=>{if(l.length!==v.length)return!0;let e=[...l].toSorted(),t=[...v].toSorted();return e.some((e,n)=>e!==t[n])},[l,v]),b=()=>{i.mutate({addresses:[...l]})},x=()=>{f(v)},w=()=>{f([])},O=()=>{n.refetch(),c.refetch(),r.refetch()},k=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)}},j=c.data?.endpoints??[];return S(H,{children:[S(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[D(`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.`}),S(`div`,{className:`flex items-center gap-2 shrink-0`,children:[S(p,{size:`sm`,variant:`secondary`,onClick:O,disabled:n.isLoading,children:[D(ie,{className:`h-3 w-3 ${n.isLoading?`animate-spin`:``}`}),`Refresh`]}),D(p,{size:`sm`,variant:`secondary`,onClick:k,children:`Probe race`})]})]}),S(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[S(m,{children:[S(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between`,children:[S(`div`,{children:[D(`div`,{className:`text-sm font-semibold`,children:`Allowed addresses`}),D(`div`,{className:`text-xs text-foreground-subtle`,children:l.length===0?`Auto — every non-loopback / non-link-local interface participates.`:`${l.length} pinned`})]}),S(`div`,{className:`flex items-center gap-1`,children:[S(p,{size:`sm`,variant:`secondary`,onClick:()=>a.mutate(void 0),disabled:a.isPending||i.isPending,title:`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`,children:[D(ae,{className:`h-3 w-3`}),a.isPending?`Detecting…`:`Best match`]}),S(p,{size:`sm`,variant:`secondary`,onClick:w,disabled:l.length===0||i.isPending,children:[D(ne,{className:`h-3 w-3`}),`Clear`]}),y&&D(p,{size:`sm`,variant:`secondary`,onClick:x,disabled:i.isPending,children:`Discard`}),S(p,{size:`sm`,variant:`primary`,onClick:b,disabled:!y||i.isPending,children:[D(fe,{className:`h-3 w-3`}),i.isPending?`Saving…`:`Save`]})]})]}),D(`div`,{className:`p-4`,children:D(Te,{mode:`multiple`,interfaces:o,value:l,onChange:f,disabled:i.isPending,emptyMessage:n.isLoading?`Loading interfaces…`:`No interfaces detected.`})})]}),S(m,{children:[S(`div`,{className:`px-4 py-3 border-b border-border`,children:[D(`div`,{className:`text-sm font-semibold`,children:`Connection endpoints — priority order`}),D(`div`,{className:`text-xs text-foreground-subtle`,children:`Live preview of the ranked candidate list the SDK would race against. Updates with each Save.`})]}),D(`div`,{className:`p-4`,children:j.length===0?D(`div`,{className:`text-xs text-foreground-subtle italic`,children:c.isLoading?`Loading…`:`No endpoints available.`}):D(`ul`,{className:`space-y-1 text-xs`,children:j.map(e=>S(`li`,{className:`flex items-center gap-2 flex-wrap ${e.plausible?``:`opacity-80`}`,children:[D(`span`,{className:`font-mono text-[10px] w-10 text-foreground-subtle`,children:String(e.priority).padStart(4,`0`)}),D(`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`&&D(`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`&&S(`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:[D(R,{className:`h-2.5 w-2.5`}),`Unlikely usable`]}),D(`span`,{className:`font-mono break-all ${e.plausible?`text-foreground`:`text-foreground-subtle`}`,children:e.baseUrl}),S(`span`,{className:`text-foreground-subtle`,children:[`— `,e.label]})]},`${e.priority}-${e.baseUrl}`))})})]})]})]})}x();var De={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,Oe=3e4,ke={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function Ae(e){let t=new Map;for(let n of e){let e=n?.manifest;e?.id&&t.set(e.id,e.packageDisplayName??e.name??e.id)}return t}function je(){let e=f({capName:`mesh-network`},{refetchInterval:Y}),t=g(void 0,{refetchInterval:Y}),n=C(()=>Ae(t.data??[]),[t.data]);return D(N,{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:j,itemIcon:L,capability:`mesh-network`,installButtonLabel:`Add mesh`,items:C(()=>(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=>D(Me,{addonId:e.addonId}),renderPrimaryAction:e=>D(Z,{addonId:e.addonId}),renderExpandedPanel:e=>D(Ne,{addonId:e.addonId})})}function X(e){let{data:t,isLoading:n}=_({addonId:e},{refetchInterval:Y,retry:!1}),r=t?O.safeParse(t):null;return{status:r?.success?r.data:ke,isLoading:n}}function Me({addonId:e}){let{status:t}=X(e);return S(w,{children:[D(`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&&S(`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 Z({addonId:e}){let t=T(),[n,r]=E(!1),[i,o]=E(null),s=A(),{status:c}=X(e),l=b(()=>{t.invalidateQueries({queryKey:[[`meshNetwork`]]})},[t]),u=a(),d=y({onSuccess:l}),f=v({onSuccess:l}),m=b(async()=>{r(!0);let t={cancelled:!1};o(t);try{let n=await u.mutateAsync({addonId:e});if(t.cancelled)return;n.loginUrl&&window.open(n.loginUrl,`_blank`,`noopener,noreferrer`);let r=Date.now();for(;!t.cancelled&&(await Re(2e3),!t.cancelled);){let t=await s.trpcClient.meshNetwork.getStatus.query({addonId:e}).catch(()=>null),n=t?O.safeParse(t):null;if(n?.success&&n.data.joined){l();break}if(Date.now()-r>6e5)break}}finally{r(!1),o(null)}},[e,l,u,s]),h=b(()=>{i&&(i.cancelled=!0),r(!1),o(null)},[i]);return D(w,{children:c.joined?S(w,{children:[S(p,{size:`sm`,variant:`secondary`,disabled:d.isPending,onClick:()=>d.mutate({addonId:e}),children:[d.isPending?D(B,{className:`h-3 w-3 animate-spin`}):D(V,{className:`h-3 w-3`}),`Disconnect`]}),S(p,{size:`sm`,variant:`ghost`,disabled:f.isPending,onClick:()=>f.mutate({addonId:e}),children:[f.isPending?D(B,{className:`h-3 w-3 animate-spin`}):D(W,{className:`h-3 w-3`}),`Log out`]})]}):n?S(p,{size:`sm`,variant:`ghost`,onClick:h,children:[D(ue,{className:`h-3 w-3 mr-1`}),` Cancel`]}):S(w,{children:[S(p,{size:`sm`,variant:`primary`,onClick:()=>void m(),children:[D(de,{className:`h-3 w-3`}),`Connect`]}),S(p,{size:`sm`,variant:`ghost`,disabled:f.isPending,onClick:()=>f.mutate({addonId:e}),children:[f.isPending?D(B,{className:`h-3 w-3 animate-spin`}):D(W,{className:`h-3 w-3`}),`Log out`]})]})})}function Ne({addonId:t}){let{status:n}=X(t),r=c({addonId:t},{refetchInterval:Oe,retry:!1});return S(`div`,{className:`rounded-lg border border-border bg-surface`,children:[S(`div`,{className:`p-4 space-y-4`,children:[n.error&&D(e,{message:n.error}),D(Pe,{status:n}),n.endpoints.length>0&&S(`div`,{className:`space-y-1.5`,children:[D(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:`Endpoints`}),n.endpoints.map(e=>S(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[S(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${De[e.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[e.scope===`public`?D(z,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,e.label]}),S(`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:[D(F,{className:`h-3 w-3 shrink-0`}),e.url]})]},e.id))]})]}),D(`div`,{className:`border-t border-border`,children:D(Ie,{peers:r.data?.peers??[],loading:r.isLoading})})]})}function Pe({status:e}){return D(`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?Fe(e.keyExpiry):`—`}].map(e=>S(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[D(`span`,{className:`text-foreground-subtle shrink-0`,children:e.label}),D(`span`,{className:`text-foreground truncate ${e.mono?`font-mono`:``}`,children:e.value})]},e.label))})}function Fe(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 Ie({peers:e,loading:n}){let r=C(()=>e.map(e=>({...e,_id:e.id})),[e]),i=b(e=>{e&&navigator.clipboard?.writeText(e)},[]),a=C(()=>[{key:`hostname`,header:`Hostname`,render:e=>S(`div`,{className:`flex flex-col`,children:[S(`div`,{className:`flex items-center gap-1.5`,children:[D(`span`,{className:`font-medium text-foreground`,children:e.hostname||`(unknown)`}),e.isSelf&&D(t,{variant:`info`,children:`self`}),e.exitNodeOption&&D(t,{variant:`warning`,children:`exit-node`})]}),e.userLogin&&D(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.userLogin})]})},{key:`magicDns`,header:`MagicDNS`,render:e=>e.magicDns?S(`div`,{className:`flex items-center gap-1`,children:[D(`span`,{className:`font-mono text-xs truncate`,children:e.magicDns}),D(`button`,{onClick:()=>i(e.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":`Copy MagicDNS`,children:D(M,{className:`h-3 w-3 text-foreground-subtle`})})]}):D(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:e=>{let t=e.addresses[0]??``;return t?S(`div`,{className:`flex items-center gap-1`,children:[D(`span`,{className:`font-mono text-xs`,children:t}),D(`button`,{onClick:()=>i(t),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":`Copy IP`,children:D(M,{className:`h-3 w-3 text-foreground-subtle`})})]}):D(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:`Connection`,render:e=>S(`div`,{className:`flex items-center gap-1.5`,children:[D(t,{variant:Le(e.connection),children:e.connection}),e.relay&&D(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.relay})]})},{key:`routes`,header:`Routes`,render:e=>e.advertisedRoutes.length>0?D(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):D(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:`TX / RX`,render:e=>S(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,Q(e.txBytes),` · ↓ `,Q(e.rxBytes)]})},{key:`lastSeen`,header:`Last seen`,render:e=>D(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?$(e.lastSeenMs):`—`})}],[i]);return n&&e.length===0?S(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[D(B,{className:`h-3 w-3 animate-spin inline mr-1`}),` Loading peers…`]}):e.length===0?D(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:`No peers visible — your tailnet may be empty or the host is not joined.`}):D(`div`,{className:`p-4`,children:D(l,{columns:a,rows:r,rowKey:e=>e._id,minWidthPx:820})})}function Le(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 Re(e){return new Promise(t=>setTimeout(t,e))}function ze(){return D(`div`,{className:`flex flex-col p-4`,children:D(U,{tabs:[{id:`addresses`,label:`Network Addresses`,icon:P,content:D(Ee,{})},{id:`remote-access`,label:`Remote Access`,icon:z,content:D(he,{})},{id:`mesh`,label:`Mesh Networks`,icon:j,content:D(je,{})},{id:`turn`,label:`TURN Servers`,icon:L,content:D(be,{})}]})})}export{ze as NetworkPage};
|
package/dist/assets/{NodeAddonsSettingsPanel-CaMCtRtL.js → NodeAddonsSettingsPanel-B6PqT-t7.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ft as e,Wr as t,at as n,mt as r,nn as i,ot as a}from"./src-
|
|
1
|
+
import{Ft as e,Wr as t,at as n,mt as r,nn as i,ot as a}from"./src-DdZmgXMF.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-DOrkbNeH.js";import{p as ee}from"./player-overlays-CTSvk_LT.js";import{n as te,r as x,t as ne}from"./SchemaTabBar-DhsmEGyn.js";import{t as S}from"./FormBuilder-BOR8MwQh.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=a(),A=n(),j=t(),M=i(),N=e(),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}=r(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-3NEgkLWp.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-DACImv1W.js";import{t as y}from"./circle-check-big-uwi7M0FF.js";import{t as b}from"./pencil-GseW53Af.js";import{t as x}from"./plus-D1FskUey.js";import{t as S}from"./search-CvffVaTb.js";import{R as C,V as w,j as T,s as E,x as D}from"./index-CukLUOO-.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{$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-DdZmgXMF.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-CTSvk_LT.js";import{t as y}from"./circle-check-big-DQ3guN_r.js";import{t as b}from"./pencil-Ba6F99Ky.js";import{t as x}from"./plus-CE0W2UFU.js";import{t as S}from"./search-DKGrktz2.js";import{R as C,V as w,j as T,s as E,x as D}from"./index-Cc9fD-gx.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Aa as e,Br as t,C as n,Ci as r,Di as i,Ei as a,Fr as o,Gr as s,Hr as c,Ia as l,Jr as u,Kr as d,Lr as f,Qi as p,Qr as m,Ra as h,Rr as g,T as _,Ti as v,Ur as y,Vr as b,Xr as x,Zr as S,_ as C,aa as w,ai as T,bi as E,ca as D,ci as O,da as k,di as A,ei as j,fi as M,ia as N,it as P,ki as ee,na as F,oi as I,ot as te,pi as ne,qr as re,ra as ie,ri as ae,sa as oe,si as se,ti as ce,ua as le,ui as ue,vi as de,xi as fe,yi as pe,zr as me}from"./src-DdZmgXMF.js";import{I as he,K as ge,Q as L,S as R,T as _e,W as z,a as ve,b as B,o as V,q as H,x as U,z as W}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{L as G,R as ye}from"./src-DOrkbNeH.js";import{p as be}from"./player-overlays-CTSvk_LT.js";import{t as xe}from"./download-BuqeRkSg.js";import{i as Se,n as Ce,r as we,t as Te}from"./AddLocationWizard-B49NZRL3.js";import{n as Ee,r as De,t as Oe}from"./zap-aXoc7k_J.js";import{i as ke,r as Ae}from"./useDevice-CXedlGPP.js";import{t as je}from"./pencil-Ba6F99Ky.js";import{t as Me}from"./plus-CE0W2UFU.js";import{t as Ne}from"./refresh-cw-CqOhKMTh.js";import{t as Pe}from"./search-DKGrktz2.js";import{t as Fe}from"./server-C-bvt-pD.js";import{t as Ie}from"./square-check-big-DwJspzeZ.js";import{t as Le}from"./square-CUAs3tdB.js";import{A as Re,F as ze,G as Be,M as Ve,P as He,V as Ue,i as We,j as Ge,k as K,o as Ke,s as qe,w as Je,x as q}from"./index-Cc9fD-gx.js";import{t as Ye}from"./AdminPage-BwmGKnRf.js";import{t as J}from"./useEventInvalidation-CaNVSWxK.js";import{a as Xe,c as Y,i as Ze,l as Qe,n as $e,o as X,r as et,s as tt,t as nt}from"./build-cluster-graph-rMGHm8c-.js";import{n as rt}from"./format-size-CO9d3C3-.js";import{t as it}from"./NodeAddonsSettingsPanel-B6PqT-t7.js";var at=Ue(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),ot=Ue(`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`}]]),st=Ue(`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`}]]),ct=Ue(`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`}]]);L();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{decode:dt(ut(e,`decode`),t),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:t,onSelect:n,refreshToken:r}){let{data:i}=o(void 0),{data:a}=T(void 0),{data:s}=I(void 0),c=new Map;for(let e of a??[])c.set(e.agentNodeId,(c.get(e.agentNodeId)??0)+1);let l=i??[],u=l.filter(e=>e.isOnline).length,d=l.filter(e=>!e.isOnline).length;return R(`div`,{className:`flex flex-col h-full`,children:[R(`button`,{type:`button`,onClick:()=>n(Pr),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${t===`__cluster__`?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[U(Je,{className:`h-4 w-4 flex-shrink-0`}),R(`div`,{className:`min-w-0 flex-1`,children:[U(`div`,{className:`text-xs font-semibold truncate`,children:`Cluster`}),U(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Balancer + failover + assignments`})]})]}),U(`div`,{className:`flex-1 overflow-y-auto`,children:l.map(r=>{let i=t===r.id,a=c.get(r.id)??0,o=r.isHub?Fe:K,l=pt(s,r.id,r.isHub),u=r.isOnline?null:h(Qe(r.lastSeen));return R(`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:[U(o,{className:`h-4 w-4 flex-shrink-0`}),R(`div`,{className:`min-w-0 flex-1`,children:[R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`text-xs font-semibold truncate`,children:r.name}),r.isHub&&U(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`}),!r.isOnline&&U(`span`,{className:`h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0`}),r.isOnline&&U(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),R(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[R(`span`,{children:[r.cpuCores,` cores`]}),U(`span`,{children:`•`}),R(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),a>0&&R(B,{children:[U(`span`,{children:`•`}),R(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[U(Ee,{className:`h-2.5 w-2.5`}),a]})]}),!r.isOnline&&R(B,{children:[U(`span`,{children:`•`}),R(`span`,{className:`text-destructive`,children:[`offline`,u===null?``:` · ${u}`]})]})]}),R(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[U(e,{variant:l.decode?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.decode?`Decode: enabled`:`Decode: not enabled (agent capability)`,children:`Dec`}),U(e,{variant:l.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.pipeline?`Pipeline: enabled`:`Pipeline: not enabled (agent capability)`,children:`Pipe`}),U(e,{variant:l.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.audio?`Audio: enabled`:`Audio: not enabled (agent capability)`,children:`Aud`})]})]})]},r.id)})}),R(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[R(`span`,{children:[u,` online`]}),d>0&&R(`span`,{className:`text-destructive`,children:[d,` offline`]})]})]})}function ht({nodeId:e,refreshToken:t}){let{data:n}=o(void 0),r=n?.find(t=>t.id===e),i=ie(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return r?R(`div`,{className:`px-6 py-4 border-b border-border`,children:[R(`div`,{className:`flex items-center gap-2 mb-1`,children:[U(`h2`,{className:`text-base font-semibold text-foreground`,children:r.name}),r.isOnline?U(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:`online`}):U(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`}),r.isHub&&U(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`})]}),R(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[U(`span`,{children:r.cpuModel??`CPU`}),U(`span`,{children:`•`}),R(`span`,{children:[r.cpuCores,` cores`]}),U(`span`,{children:`•`}),R(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),i&&R(B,{children:[U(`span`,{children:`•`}),R(`span`,{children:[i.attachedCameras,` cameras (`,i.activeCameras,` active)`]}),U(`span`,{children:`•`}),R(`span`,{children:[i.avgInferenceTimeMs.toFixed(0),`ms avg inference`]}),U(`span`,{children:`•`}),R(`span`,{children:[`queue `,i.queueDepthTotal]}),i.hardware.hasGpu&&R(B,{children:[U(`span`,{children:`•`}),U(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):U(`div`,{className:`px-6 py-4 border-b border-border`,children:R(`div`,{className:`text-xs text-foreground-subtle`,children:[`Node not found: `,e]})})}function gt({refreshToken:e,nodeId:t}){let[n,r]=H(new Map),{nodes:i}=F();w(`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}=m(void 0),o=z(()=>{let e=new Map;for(let t of a??[])e.set(t.nodeId,t.deviceCount);return e},[a]),s=z(()=>{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=z(()=>{let e=new Map;for(let t of i)e.set(t.id,t.shortName);return e},[i]),l=z(()=>{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 R(`div`,{className:`@container/liveload`,children:[U(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),R(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[U(Z,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),U(Z,{label:`Cameras`,value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),U(Z,{label:`Avg infer ms`,value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),U(Z,{label:`Queue`,value:e?String(e.queueDepth):`—`}),U(Z,{label:`Audio`,value:String(o.get(t)??`—`)})]})]})}let u=[...s.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return R(`div`,{className:`@container/liveload`,children:[U(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),R(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[U(Z,{label:`Total agents`,value:`${l.onlineAgents}/${l.totalAgents}`}),U(Z,{label:`Cameras`,value:`${l.activeCameras}/${l.attachedCameras}`}),U(Z,{label:`Total FPS`,value:l.totalFps.toFixed(1)}),U(Z,{label:`Avg inference ms`,value:l.avgInferenceTimeMs.toFixed(0)}),U(Z,{label:`Queue depth`,value:String(l.queueDepth)})]}),U(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:R(`table`,{className:`w-full text-xs min-w-[480px]`,children:[U(`thead`,{className:`bg-surface`,children:R(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[U(`th`,{className:`text-left px-3 py-2`,children:`Agent`}),U(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),U(`th`,{className:`text-right px-3 py-2`,children:`Cameras`}),U(`th`,{className:`text-right px-3 py-2`,children:`Inference ms`}),U(`th`,{className:`text-right px-3 py-2`,children:`Queue`}),U(`th`,{className:`text-right px-3 py-2`,children:`Audio`})]})}),R(`tbody`,{children:[u.map(([e,t])=>R(`tr`,{className:`border-t border-border`,children:[U(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:c.get(e)??e}),U(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.totalFps.toFixed(1)}),U(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras}),U(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),U(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.queueDepth}),U(`td`,{className:`px-3 py-2 text-right text-foreground`,children:o.get(e)??`—`})]},e)),u.length===0&&U(`tr`,{children:U(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No camera metrics received yet`})})]})]})})]})}function Z({label:e,value:t}){return R(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[U(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:e}),U(`div`,{className:`text-lg font-semibold text-foreground`,children:t})]})}L();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:K,decoder:ot,audio:De},bt={pipeline:`Pipeline`,decoder:`Decoder`,audio:`Audio`};function xt({mode:e,nodeId:t,compact:n=!1}){if(e===`agent`&&!t)throw Error(`CameraAssignmentsTable: nodeId is required when mode === "agent"`);let r=V(),[i,a]=H(null),[o,c]=H(null),[l,u]=H(new Map);J([`pipelineOrchestrator`,`getPipelineAssignments`],vt),J([`pipelineOrchestrator`,`getDecoderAssignments`],vt),J([`pipelineOrchestrator`,`getAudioAssignments`],vt);let{data:f}=T(void 0),{data:p}=ae(void 0),{data:m}=S(void 0),{nodes:h}=F(),{data:g}=Ae();w(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t.deviceId==`number`&&u(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})}),W(()=>{if(l.size===0)return;let e=setInterval(()=>{u(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)},[l.size]);let v=z(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.name);return e},[g]),y=z(()=>{let n=new Map,r=e=>{let t=n.get(e);if(t)return t;let r={deviceId:e,deviceName:v.get(e)??`Device ${e}`,pipeline:_t,decoder:_t,audio:_t};return n.set(e,r),r};for(let i of f??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,pipeline:{active:e===`cluster`?!0:i.agentNodeId===t,pinned:i.pinned,nodeId:i.agentNodeId,reason:i.reason??``}})}for(let i of p??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,decoder:{active:e===`cluster`?!0:i.decoderNodeId===t,pinned:i.pinned,nodeId:i.decoderNodeId,reason:i.reason??``}})}for(let i of m??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,audio:{active:e===`cluster`?!0:i.nodeId===t,pinned:i.pinned,nodeId:i.nodeId,reason:`capacity`}})}let i=[...n.values()];return e===`agent`&&(i=i.filter(e=>e.pipeline.active||e.decoder.active||e.audio.active)),i.sort((e,t)=>e.deviceId-t.deviceId),i},[f,p,m,v,e,t]),b=z(()=>(h??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[h]),x=()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getDecoderAssignments`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})},C=re({onSuccess:x}),D=E({onSuccess:x}),O=d({onSuccess:x}),k=pe({onSuccess:x}),A=s({onSuccess:x}),j=de({onSuccess:x}),M=(e,t,n)=>{t===`pipeline`?C.mutate({deviceId:e,agentNodeId:n}):t===`decoder`?O.mutate({deviceId:e,nodeId:n}):A.mutate({deviceId:e,nodeId:n}),a(null)},N=(e,t)=>{t===`pipeline`?D.mutate({deviceId:e}):t===`decoder`?k.mutate({deviceId:e}):j.mutate({deviceId:e}),a(null)};return U(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:R(`table`,{className:`w-full text-xs min-w-[640px] table-fixed`,children:[U(`thead`,{className:`bg-surface`,children:R(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[!n&&U(`th`,{className:`w-10`}),U(`th`,{className:`text-left px-3 py-2 align-middle`,children:`Camera`}),e===`cluster`?R(B,{children:[U(`th`,{className:`w-[168px] text-left px-3 py-2 align-middle`,children:`Auto | Pin`}),U(`th`,{className:`w-[188px] text-left px-3 py-2 align-middle`,children:`Resolved placement`})]}):R(B,{children:[U(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Pipeline`}),U(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Decoder`}),U(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Audio`})]}),U(`th`,{className:`w-[132px] text-left px-3 py-2 align-middle`,children:`Status`})]})}),R(`tbody`,{children:[y.map(t=>{let r=l.get(t.deviceId),s=o===t.deviceId;return R(_e.Fragment,{children:[R(`tr`,{className:`border-t border-border align-middle relative`,children:[!n&&U(`td`,{className:`px-2 py-2 align-middle`,children:U(`button`,{type:`button`,onClick:()=>c(s?null:t.deviceId),className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":s?`Collapse broker details`:`Expand broker details`,children:U(s?He:Ve,{className:`h-3.5 w-3.5`})})}),R(`td`,{className:`px-3 py-2 align-middle min-w-0`,children:[U(`div`,{className:`text-foreground font-medium leading-tight truncate`,title:t.deviceName,children:t.deviceName}),R(`div`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[`#`,t.deviceId]})]}),e===`cluster`?R(B,{children:[U(`td`,{className:`px-3 py-2 align-middle`,children:U(St,{state:t.pipeline,onlineNodes:b,pending:C.isPending||D.isPending,onChange:e=>{e===`auto`?N(t.deviceId,`pipeline`):M(t.deviceId,`pipeline`,e)}})}),U(`td`,{className:`px-3 py-2 align-middle`,children:U(Ct,{state:t.pipeline})})]}):R(B,{children:[U(wt,{role:`pipeline`,state:t.pipeline,mode:e,deviceId:t.deviceId,onlineNodes:b,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`pipeline`,onToggleMenu:()=>a(i?.deviceId===t.deviceId&&i.role===`pipeline`?null:{deviceId:t.deviceId,role:`pipeline`}),onCloseMenu:()=>a(null),onMove:e=>M(t.deviceId,`pipeline`,e),onUnpin:()=>N(t.deviceId,`pipeline`)}),U(wt,{role:`decoder`,state:t.decoder,mode:e,deviceId:t.deviceId,onlineNodes:b,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`decoder`,onToggleMenu:()=>a(i?.deviceId===t.deviceId&&i.role===`decoder`?null:{deviceId:t.deviceId,role:`decoder`}),onCloseMenu:()=>a(null),onMove:e=>M(t.deviceId,`decoder`,e),onUnpin:()=>N(t.deviceId,`decoder`)}),U(wt,{role:`audio`,state:t.audio,mode:e,deviceId:t.deviceId,onlineNodes:b,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`audio`,onToggleMenu:()=>a(i?.deviceId===t.deviceId&&i.role===`audio`?null:{deviceId:t.deviceId,role:`audio`}),onCloseMenu:()=>a(null),onMove:e=>M(t.deviceId,`audio`,e),onUnpin:()=>N(t.deviceId,`audio`)})]}),U(`td`,{className:`px-3 py-2 align-middle`,children:U(Dt,{snap:r})})]}),s&&!n&&R(`tr`,{className:`bg-surface/50`,children:[U(`td`,{}),U(`td`,{colSpan:e===`cluster`?4:5,className:`px-3 py-2`,children:U(_,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:t.deviceId,instanceId:`pipeline-row/${t.deviceId}`,config:{variant:`compact`,title:`Stream brokers & clients`}})})]})]},t.deviceId)}),y.length===0&&U(`tr`,{children:U(`td`,{colSpan:n?e===`cluster`?4:5:e===`cluster`?5:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:e===`agent`?`No cameras assigned to this node`:`No cameras currently assigned`})})]})]})})}function 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 R(`select`,{value:i,disabled:n,"aria-label":`Pipeline placement pin`,onChange:e=>r(e.target.value),className:`rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground`,children:[U(`option`,{value:`auto`,children:`Auto`}),a.map(e=>R(`option`,{value:e,children:[`Pin → `,t.find(t=>t.id===e)?.name??e]},e))]})}function Ct({state:e}){if(!e.active||!e.nodeId)return U(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`});let t=e.pinned?`pinned · manual`:`auto · ${e.reason||`capacity`}`;return R(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[U(`span`,{className:`font-mono text-[11px] text-foreground truncate`,title:e.nodeId,children:e.nodeId}),U(`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,isMenuOpen:i,onToggleMenu:a,onCloseMenu:o,onMove:s,onUnpin:c}){let l=yt[e],u=r.filter(e=>e.id!==(t.nodeId??``)),d=(t.active||n===`cluster`)&&(u.length>0||t.pinned);return R(`td`,{className:`px-3 py-2 align-middle relative min-w-0`,children:[R(`div`,{className:`flex items-center gap-2 min-w-0`,children:[U(n===`agent`?Tt:Et,{state:t,Icon:l}),U(`div`,{className:`ml-auto shrink-0`,children:d&&U(`button`,{type:`button`,onClick:a,className:`p-1 rounded hover:bg-surface-hover`,"aria-label":`${bt[e]} actions`,children:U(at,{className:`h-3 w-3 text-foreground-subtle`})})})]}),i&&d&&U(Ot,{title:bt[e],targets:u,pinned:t.pinned,onMove:s,onUnpin:c,onClose:o})]})}function Tt({state:e,Icon:t}){return R(`div`,{className:`flex items-center gap-1.5`,children:[U(e.active?Ie:Le,{className:`h-3.5 w-3.5 ${e.active?`text-success`:`text-foreground-subtle/50`}`}),U(t,{className:`h-3 w-3 ${e.active?`text-foreground-subtle`:`text-foreground-subtle/40`}`}),e.pinned&&U(ct,{className:`h-2.5 w-2.5 text-amber-400`})]})}function Et({state:e,Icon:t}){return!e.active||!e.nodeId?R(`div`,{className:`flex items-center gap-1.5 text-foreground-subtle/60`,children:[U(t,{className:`h-3 w-3`}),U(`span`,{className:`text-[10px] italic`,children:`—`})]}):R(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[U(t,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),R(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[U(`span`,{className:`font-mono text-[11px] text-foreground truncate`,children:e.nodeId}),U(`span`,{className:`flex items-center gap-1 text-[10px]`,children:e.pinned?R(`span`,{className:`inline-flex items-center gap-0.5 text-amber-400`,children:[U(ct,{className:`h-2.5 w-2.5`}),` manual`]}):R(`span`,{className:`text-foreground-subtle truncate`,children:[`auto · `,e.reason||`capacity`]})})]})]})}function Dt({snap:e}){if(!e)return U(`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=l(t);return R(`div`,{className:`flex flex-col gap-0.5 font-mono text-[10px] tabular-nums leading-tight min-w-0`,children:[R(`span`,{className:`inline-flex items-center gap-1 min-w-0 ${s.textColor}`,children:[U(C,{phase:t,className:`h-2.5 w-2.5 shrink-0`}),U(`span`,{className:`font-semibold uppercase tracking-wider truncate`,children:s.label})]}),R(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[U(`span`,{className:`text-foreground`,children:n.toFixed(1)}),R(`span`,{children:[`/`,a.toFixed(0),` fps`]})]}),R(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[U(`span`,{className:`text-foreground`,children:r.toFixed(0)}),U(`span`,{children:` ms`}),i>0&&R(`span`,{className:`text-warning ml-1`,children:[`q`,i]})]}),R(`span`,{className:`whitespace-nowrap truncate ${o>0?`text-warning`:`text-foreground-subtle`}`,children:[`drops `,U(`span`,{className:`text-foreground`,children:o})]})]})}function Ot({title:e,targets:t,pinned:n,onMove:r,onUnpin:i,onClose:a}){let o=ge(null);return W(()=>{let e=e=>{o.current?.contains(e.target)||a()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[a]),R(`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:[U(`div`,{className:`px-3 py-1 text-[9px] uppercase tracking-wider text-foreground-subtle border-b border-border`,children:e}),t.length>0&&U(`div`,{className:`py-1`,children:t.map(e=>R(`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&&R(`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&&U(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle italic`,children:`Already auto · no other nodes online`})]})}function kt({nodeId:e,refreshToken:t}){return R(`div`,{className:`space-y-6`,children:[U(gt,{refreshToken:t,nodeId:e}),R(`div`,{children:[U(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Cameras on this node`}),R(`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.`]})]}),U(xt,{mode:`agent`,nodeId:e,compact:!0})]})}L();function At(e,t){let n=Math.max(0,t-e);return`${Math.floor(e/1e3)}s idle · ${Math.floor(n/1e3)}s left`}function jt({nodeId:e,refreshToken:t}){let n=V(),i=c({onSettled:()=>{n.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:a}=y({nodeId:e}),o=ie(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??a??null,s=o===null;J([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:l}=r({nodeId:e}),{values:u}=N(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),d=z(()=>u.filter(e=>e.metrics.phase===`active`).length,[u]),f=t=>{let n=l??[];n.length>0&&!window.confirm(`${n.length} camera(s) are dispatching through this engine. Killing it forces a respawn on the next frame. Continue?`)||i.mutate({nodeId:e,engine:t,force:n.length>0})};return R(`div`,{className:`space-y-6`,children:[R(`div`,{children:[U(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Inference engines on this node`}),R(`p`,{className:`text-[11px] text-foreground-subtle`,children:[(o??[]).length,` engine(s) resident in RAM. `,(l??[]).length,` `,`camera(s) attached, `,d,` actively dispatching frames. Refreshes every 5s.`]})]}),U(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:R(`table`,{className:`w-full text-xs min-w-[640px]`,children:[U(`thead`,{className:`bg-surface`,children:R(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[U(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Kind`}),U(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Runtime / Backend / Device`}),U(`th`,{className:`text-left px-3 py-2`,children:`Models`}),U(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Pool PID`}),U(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Auto-kill`}),U(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`In use`}),U(`th`,{className:`w-20`})]})}),R(`tbody`,{children:[s&&U(`tr`,{children:U(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`Loading…`})}),!s&&(o??[]).map(e=>{let t=e.kind===`warm-override`;return R(`tr`,{className:`border-t border-border ${t?`bg-amber-500/5`:``}`,children:[U(`td`,{className:`px-3 py-2`,children:R(`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:[U(t?st:K,{className:`h-3 w-3`}),t?`warm`:`runtime`]})}),U(`td`,{className:`px-3 py-2`,children:R(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[U(Oe,{className:`h-3 w-3`}),e.engine.runtime,`/`,e.engine.backend,e.engine.device?`/${e.engine.device}`:``,e.engine.format?` · ${e.engine.format}`:``]})}),U(`td`,{className:`px-3 py-2`,children:e.modelsLoaded.length===0?U(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):U(`div`,{className:`flex flex-wrap gap-1`,children:e.modelsLoaded.map(e=>U(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),U(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.poolPid??`—`}),U(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:e.idleMs!==null&&e.idleTtlMs!==null?U(`span`,{className:`text-foreground-subtle`,children:At(e.idleMs,e.idleTtlMs)}):U(`span`,{className:`text-foreground-subtle/50`,children:`never`})}),U(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t?`—`:(l??[]).length}),U(`td`,{className:`px-3 py-2 text-right`,children:R(`button`,{type:`button`,disabled:i.isPending,onClick:()=>f(e.engine),className:`inline-flex items-center gap-1 px-2 py-1 rounded border border-destructive/30 text-destructive text-[11px] hover:bg-destructive/10 disabled:opacity-50`,children:[U(qe,{className:`h-3 w-3`}),`Kill`]})})]},e.engineKey)}),!s&&(o??[]).length===0&&U(`tr`,{children:U(`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.`})})]})]})}),R(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:[U(`strong`,{className:`text-foreground`,children:`runtime`}),`: main camera-serving engine; never auto-killed while cameras attached. `,U(`strong`,{className:`text-foreground`,children:`warm`}),`: benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL.`]}),i.isError&&R(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[`Kill failed:`,` `,i.error instanceof Error?i.error.message:`unknown`]})]})}L();var Mt=new Set(ye);function Nt(e){return Mt.has(e)}function Pt(e,t,n){return`${e}/${t}/${n}`}function Ft(e){return{coreml:`CoreML`,openvino:`OpenVINO`,onnx:`ONNX`}[e.format]??e.format.toUpperCase()}function It(e){return{coreml:`Apple Neural Engine / GPU — .mlpackage`,openvino:`Intel CPU / GPU / NPU — .xml`,onnx:`CPU, CUDA, Node.js — .onnx`}[e.format]??`.${e.format}`}function Q(e){return e.format}function Lt(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 Rt({addonId:e,model:t,format:n,isActive:r,progress:i,errorMsg:a,onDownload:o,onDelete:s}){let c=t.formats[n];return c?R(`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:[U(`div`,{className:`h-2 w-2 rounded-full shrink-0 ${c.downloaded?`bg-success`:`bg-foreground-subtle/30`}`}),R(`div`,{className:`flex-1 min-w-0`,children:[R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`text-sm font-medium text-foreground`,children:t.name}),R(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`(`,t.id,`)`]})]}),i&&i.progress>=0&&i.progress<100&&R(`div`,{className:`mt-1.5 flex items-center gap-2 max-w-xs`,children:[U(`div`,{className:`flex-1 h-1 bg-surface-hover rounded-full overflow-hidden`,children:U(`div`,{className:`bg-primary h-full rounded-full transition-all duration-300`,style:{width:`${i.progress}%`}})}),R(`span`,{className:`text-[9px] text-primary font-mono tabular-nums shrink-0`,children:[Math.round(i.progress),`%`]})]})]}),U(`span`,{className:`text-xs text-foreground-subtle tabular-nums shrink-0`,children:rt(c.sizeMB)}),a&&R(`span`,{className:`flex items-center gap-1 text-[10px] text-danger max-w-[160px] truncate shrink-0`,title:a,children:[U(Ge,{className:`h-3 w-3 shrink-0`}),a]}),c.downloaded?R(`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?U(q,{className:`h-3 w-3 animate-spin`}):U(qe,{className:`h-3 w-3`}),r?`Deleting...`:`Delete`]}):R(`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?U(q,{className:`h-3 w-3 animate-spin`}):U(xe,{className:`h-3 w-3`}),r?`Downloading...`:`Download`]})]}):null}function zt({engines:e,activeEngine:t,viewEngine:n,onSelect:r}){let[i,a]=H(!1);return R(`div`,{className:`relative`,children:[R(`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:[U(K,{className:`h-4 w-4 text-primary shrink-0`}),R(`div`,{className:`flex-1 min-w-0`,children:[R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`text-sm font-medium text-foreground`,children:Ft(n)}),Q(n)===Q(t)&&U(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),U(`div`,{className:`text-[10px] text-foreground-subtle`,children:It(n)})]}),U(He,{className:`h-4 w-4 text-foreground-subtle transition-transform ${i?`rotate-180`:``}`})]}),i&&U(`div`,{className:`absolute top-full left-0 right-0 mt-1 rounded-lg border border-border bg-surface shadow-lg z-50 overflow-hidden`,children:e.map(e=>{let i=Q(e)===Q(n),o=Q(e)===Q(t);return R(`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:[U(K,{className:`h-4 w-4 shrink-0 ${i?`text-primary`:`text-foreground-subtle`}`}),R(`div`,{className:`flex-1`,children:[R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`text-sm font-medium ${i?`text-primary`:`text-foreground`}`,children:Ft(e)}),o&&U(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),U(`div`,{className:`text-[10px] text-foreground-subtle`,children:It(e)})]}),i&&U(Re,{className:`h-4 w-4 text-primary shrink-0`})]},Q(e))})})]})}function Bt({embedded:e=!1,nodeId:n}={}){let r=V(),i=n??`hub`,[a,o]=H(null),[s,c]=H(new Set),[l,u]=H(new Map),[d,p]=H(new Map),[m,h]=H(``),{data:_=[]}=me({nodeId:i}),v=_.filter((e,t,n)=>n.findIndex(t=>t.format===e.format)===t),{data:y}=b({nodeId:i}),x=y,{data:S,isLoading:C}=t({nodeId:i}),T=g(),E=f();w(`model.download.progress`,e=>{let t=e.data,n=typeof t.modelId==`string`?t.modelId:void 0,i=typeof t.progress==`number`?t.progress:void 0,a=typeof t.totalMB==`number`?t.totalMB:0;n===void 0||i===void 0||(u(e=>{let t=new Map(e);return i===100||i===-1?t.delete(n):t.set(n,{modelId:n,progress:i,totalMB:a}),t}),i===100&&r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]}))});let D=x??{runtime:`node`,backend:`cpu`,format:`onnx`},O=v.find(e=>e.format===a)??D,k=O.format,A=S?.slots??[],j=A.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(e=>e.formats[k]!==void 0)})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0),M=Lt(j,k),N=he(async(e,t,n)=>{if(!Nt(n))return;let a=Pt(e,t,n);c(e=>new Set([...e,a])),p(e=>{let t=new Map(e);return t.delete(a),t});try{await T.mutateAsync({addonId:e,modelId:t,format:n,nodeId:i}),r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){p(t=>new Map([...t,[a,e instanceof Error?e.message:`Download failed`]]))}finally{c(e=>{let t=new Set(e);return t.delete(a),t})}},[T,r,i]),P=he(async(e,t,n)=>{if(!Nt(n))return;let a=Pt(e,t,n);c(e=>new Set([...e,a])),p(e=>{let t=new Map(e);return t.delete(a),t});try{await E.mutateAsync({addonId:e,modelId:t,format:n,nodeId:i}),r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){p(t=>new Map([...t,[a,e instanceof Error?e.message:`Delete failed`]]))}finally{c(e=>{let t=new Set(e);return t.delete(a),t})}},[E,r,i]),ee=he(e=>{o(e.format)},[]),F=m.trim()?j.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(t=>t.name.toLowerCase().includes(m.toLowerCase())||t.id.toLowerCase().includes(m.toLowerCase())||e.name.toLowerCase().includes(m.toLowerCase()))})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0):j,I=R(B,{children:[C&&U(`div`,{className:`flex items-center justify-center py-16`,children:U(q,{className:`h-5 w-5 animate-spin text-foreground-subtle`})}),!C&&A.length===0&&R(`div`,{className:`flex flex-col items-center justify-center py-16 text-foreground-subtle`,children:[U(Se,{className:`h-8 w-8 mb-3 opacity-30`}),U(`span`,{className:`text-sm`,children:`No pipeline steps available`}),U(`span`,{className:`text-xs mt-1`,children:`Configure the detection pipeline to see available models.`})]}),!C&&A.length>0&&R(B,{children:[U(zt,{engines:v,activeEngine:D,viewEngine:O,onSelect:ee}),R(`div`,{className:`flex items-center gap-4 text-xs text-foreground-subtle`,children:[R(`span`,{children:[U(`span`,{className:`font-semibold text-foreground tabular-nums`,children:M.total}),U(`span`,{className:`ml-1`,children:`compatible models`})]}),U(`span`,{className:`text-border`,children:`|`}),R(`span`,{children:[U(`span`,{className:`font-semibold text-success tabular-nums`,children:M.downloaded}),U(`span`,{className:`ml-1`,children:`downloaded`})]}),U(`span`,{className:`text-border`,children:`|`}),R(`span`,{className:`tabular-nums`,children:[rt(M.downloadedSizeMB),U(`span`,{className:`ml-1`,children:`on disk`})]})]}),M.total>5&&R(`div`,{className:`relative`,children:[U(Pe,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),U(`input`,{type:`text`,value:m,onChange:e=>h(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`})]}),F.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[k]?.downloaded).length,0);return R(`div`,{children:[R(`div`,{className:`flex items-center gap-2 mb-2`,children:[U(`h2`,{className:`text-sm font-semibold text-foreground`,children:e.label}),U(`div`,{className:`flex-1 h-px bg-border`}),R(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[n,`/`,t]})]}),U(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:e.addons.map(e=>e.models.map(t=>{let n=Pt(e.id,t.id,k);return U(Rt,{addonId:e.id,model:t,format:k,isActive:s.has(n),progress:l.get(t.id),errorMsg:d.get(n),onDownload:()=>N(e.id,t.id,k),onDelete:()=>P(e.id,t.id,k)},`${e.id}/${t.id}`)}))})]},e.id)}),F.length===0&&U(`div`,{className:`text-center py-8 text-sm text-foreground-subtle`,children:m.trim()?R(B,{children:[`No models matching “`,m,`”`]}):R(B,{children:[`No models available for `,Ft(O),` format`]})})]})]});return e?U(`div`,{className:`space-y-4`,children:I}):U(Ye,{children:I})}function Vt({nodeId:e,refreshToken:t}){return U(Bt,{embedded:!0,nodeId:e})}var Ht=[{concern:`pipeline`,label:`Pipeline`,advisory:!1},{concern:`audio`,label:`Audio`,advisory:!1},{concern:`decode`,label:`Decode`,advisory:!0,advisoryNote:`Advisory: decode currently runs co-located with the stream source (hub). Pins are stored and take effect with Phase-2 stream load-balancing.`}];function Ut(e,t){return e.filter(e=>e.currentNodeId!==t)}var Wt=`This node is not decoder-enabled (enabledDecoderNodes). Pinning detection here strands frames (0 fps) until frame-source-aware placement ships. Enable decode on this node first, or pick a decoder-enabled node.`;function Gt(e,t,n){return t.includes(e)?{verdict:`ok`}:n?{verdict:`warn`,reason:Wt}:{verdict:`block`,reason:Wt}}L();var Kt=`pipeline-orchestrator`,qt=`enabledDecoderNodes`;function Jt(e,t){if(!e||typeof e!=`object`)return;let n=e.sections;if(Array.isArray(n))for(let e of n){if(!e||typeof e!=`object`)continue;let n=e.fields;if(Array.isArray(n))for(let e of n){if(!e||typeof e!=`object`)continue;let n=e;if(n.key!==t)continue;let r=n.value;return Array.isArray(r)&&r.every(e=>typeof e==`string`)?r:void 0}}}function Yt({nodeId:e,nodeName:t,concern:n,open:r,onClose:i}){let a=V(),o=Ae(),c=T(void 0),l=ae(void 0),u=S(void 0),f=P({addonId:Kt}),p=re(),m=d(),h=s(),[g,_]=H(new Set),[v,y]=H(!1),[b,x]=H(null),[C,w]=H([]),[E,D]=H(null),O=Ht.find(e=>e.concern===n),k=z(()=>{let e=new Map;if(n===`pipeline`)for(let t of c.data??[])e.set(t.deviceId,t.agentNodeId);else if(n===`decode`)for(let t of l.data??[])e.set(t.deviceId,t.decoderNodeId);else for(let t of u.data??[])e.set(t.deviceId,t.nodeId);return e},[n,c.data,l.data,u.data]),A=z(()=>(o.data??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,currentNodeId:k.get(e.id)??null})),[o.data,k]),j=z(()=>Ut(A,e),[A,e]),M=Jt(f.data,qt),N=n===`pipeline`?Gt(e,M??[],!1):{verdict:`ok`},[ee,F]=H(!1);if(!r)return null;let I=N.verdict===`block`,te=N.verdict===`warn`&&!ee,ne=g.size>0&&!v&&!I&&!te,ie=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},oe=j.length>0&&j.every(e=>g.has(e.deviceId)),se=()=>{_(oe?new Set:new Set(j.map(e=>e.deviceId)))},ce=async t=>{n===`pipeline`?await p.mutateAsync({deviceId:t,agentNodeId:e}):n===`decode`?await m.mutateAsync({deviceId:t,nodeId:e}):await h.mutateAsync({deviceId:t,nodeId:e})},le=new Map(A.map(e=>[e.deviceId,e.name]));return R(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[U(`div`,{className:`absolute inset-0 bg-black/60`,onClick:i}),R(`div`,{className:`relative z-10 flex w-full max-w-2xl flex-col h-[80vh] rounded-xl border border-border bg-background shadow-2xl`,children:[R(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[R(`div`,{className:`min-w-0`,children:[R(`h2`,{className:`text-sm font-semibold text-foreground`,children:[`Batch assign `,O?.label??n,` → `,t]}),R(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:[`Pick the cameras whose `,O?.label.toLowerCase()??n,` should run on this node.`]})]}),U(`button`,{type:`button`,onClick:i,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,"aria-label":`Close`,children:U(We,{className:`h-4 w-4`})})]}),R(`div`,{className:`flex-1 min-h-0 px-5 py-3 flex flex-col gap-2 overflow-hidden`,children:[O?.advisory&&O.advisoryNote&&U(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 px-3 py-2 shrink-0`,children:R(`div`,{className:`flex items-start gap-2`,children:[U(Ke,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),U(`p`,{className:`text-[11px] text-warning`,children:O.advisoryNote})]})}),N.verdict!==`ok`&&U(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2 shrink-0`,children:R(`div`,{className:`flex items-start gap-2`,children:[U(Ke,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),R(`div`,{className:`min-w-0`,children:[U(`p`,{className:`text-[11px] text-destructive`,children:N.reason}),N.verdict===`warn`&&R(`label`,{className:`mt-1 flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[U(`input`,{type:`checkbox`,checked:ee,onChange:e=>F(e.target.checked),className:`accent-primary`}),`I understand — assign anyway`]})]})]})}),j.length>0&&R(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle shrink-0`,children:[U(`input`,{type:`checkbox`,"aria-label":`Select all`,checked:oe,onChange:se,className:`accent-primary`}),`Select all (`,j.length,`)`]}),U(`div`,{className:`flex-1 min-h-0 overflow-y-auto rounded-lg border border-border divide-y divide-border`,children:j.length===0?R(`div`,{className:`px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:[`No eligible cameras — all cameras are already assigned to `,t,`.`]}):j.map(e=>R(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground hover:bg-surface-hover cursor-pointer`,children:[U(`input`,{type:`checkbox`,"aria-label":`Select ${e.name}`,checked:g.has(e.deviceId),onChange:()=>ie(e.deviceId),className:`accent-primary`}),U(`span`,{className:`truncate`,children:e.name}),e.currentNodeId&&R(`span`,{className:`ml-auto text-[10px] text-foreground-subtle shrink-0`,children:[`on `,e.currentNodeId]})]},e.deviceId))}),(E!==null||C.length>0)&&R(`div`,{className:`space-y-1 text-[10px] shrink-0`,children:[E!==null&&E>0&&R(`p`,{className:`text-success`,children:[`Assigned `,E,` camera(s) to `,t,`.`]}),C.map(e=>R(`p`,{className:`text-destructive`,children:[e.name,`: `,e.message]},e.deviceId))]})]}),R(`div`,{className:`flex items-center justify-between border-t border-border px-5 py-3 shrink-0`,children:[U(`span`,{className:`text-[10px] text-foreground-subtle`,children:v&&b?`${b.done} / ${b.total}…`:``}),R(`div`,{className:`flex items-center gap-2`,children:[U(`button`,{type:`button`,onClick:i,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground`,children:`Close`}),R(`button`,{type:`button`,onClick:async()=>{let e=[...g];if(e.length===0)return;y(!0),w([]),D(null),x({done:0,total:e.length});let t=[],n=0;for(let r=0;r<e.length;r+=1){let i=e[r];try{await ce(i),n+=1}catch(e){t.push({deviceId:i,name:le.get(i)??String(i),message:e instanceof Error?e.message:String(e)})}x({done:r+1,total:e.length})}y(!1),w(t),D(n),_(new Set),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getDecoderAssignments`]]}),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})},disabled:!ne,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50 disabled:cursor-not-allowed`,children:[v&&U(q,{className:`h-3.5 w-3.5 animate-spin`}),`Assign `,g.size,` to `,t]})]})]})]})]})}L();function Xt({nodeId:e,title:t}){let{data:n}=Ae(),{data:r}=T(void 0),i=z(()=>{let e=new Map;for(let t of n??[])e.set(t.id,t.name);return e},[n]),a=z(()=>{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]=H(new Map);w(`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}))}),W(()=>{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=z(()=>{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?R(`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`]}):R(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[R(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[U(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??`Cameras`}),U(`span`,{className:`text-[10px] text-foreground-subtle`,children:c.length})]}),U(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map(e=>{let t=i.get(e.deviceId)??`#${e.deviceId}`,n=l(e.metrics.phase);return R(`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:[U(C,{phase:e.metrics.phase,className:`h-2.5 w-2.5`}),U(`span`,{className:`font-medium text-foreground/90 max-w-[120px] truncate`,children:t}),U(`span`,{className:`font-mono tabular-nums`,children:e.metrics.actualFps.toFixed(1)}),U(`span`,{className:`opacity-60`,children:`fps`})]},e.deviceId)})})]})}var Zt={key:`maxCameras`,type:`slider`,label:`Max cameras`,description:`Hard cap on cameras the balancer may assign to this node.`,min:1,max:64,step:1,showValue:!0,showStepper:!0,nullable:!0,nullLabel:`Unlimited`};L();var Qt=350;function $t(e){return typeof e==`number`&&e>0?Math.floor(e):null}function en({value:e,pending:t,errorMessage:r,onCommit:i}){let[a,o]=H(e);W(()=>{o(e)},[e]);let s=ge(i);return s.current=i,W(()=>{if(a===e)return;let t=setTimeout(()=>s.current(a),Qt);return()=>clearTimeout(t)},[a,e]),R(`div`,{className:`flex items-center gap-3 text-xs text-foreground`,children:[U(`div`,{className:`max-w-md flex-1`,children:U(n,{field:Zt,values:{maxCameras:a},disabled:t,onChange:(e,t)=>o($t(t))})}),t&&U(`span`,{className:`text-[10px] text-muted-foreground animate-pulse`,children:`Saving…`}),r&&R(`span`,{className:`text-[10px] text-destructive`,children:[`Save failed: `,r]})]})}L();var tn=[`pipeline-orchestrator`],nn=[`decoder`];function rn(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 an({nodeId:e,refreshToken:n}){let r=V(),[i,a]=H(null),[s,c]=H(null),[l,u]=H(null),d=(o(void 0).data??[]).find(t=>t.id===e)?.name??e,f=t({nodeId:e},{refetchOnMount:`always`}),p=x({agentNodeId:e},{refetchOnMount:`always`}),m=()=>{r.invalidateQueries({queryKey:[[`addonSettings`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]}),r.invalidateQueries({queryKey:[[`pipelineExecutor`]]})},h=ue({onSuccess:m}),g=ne({onSuccess:m}),_=f.data??null,v=p.data,y=_?.selectedEngine.format??`coreml`,b=z(()=>_?le(_):[],[_]),S=z(()=>[{agentNodeId:e,engineLabel:y}],[e,y]),C=(e,t)=>{let n=v?.addonDefaults[e];return!rn(_,e)?.models.some(e=>!!e.formats[y])||!n?{kind:`na`}:n.enabled?{kind:`enabled`,modelId:n.modelId}:{kind:`disabled`}},w=i&&_?rn(_,i.addonId):null,T=t=>{let n=v?.addonDefaults[t]??null;a({addonId:t,agentNodeId:e}),c(n)},E=(t,n)=>{if(!v)return;let r=v.addonDefaults[t],i=rn(_,t);if(!r&&!i)return;let a={enabled:n,modelId:r?.modelId??i?.defaultModelId??``,settings:r?.settings??{}};h.mutate({agentNodeId:e,defaults:{...v.addonDefaults,[t]:a}})},O=()=>{a(null),c(null)},A=()=>{!s||!i||!v||h.mutate({agentNodeId:e,defaults:{...v.addonDefaults,[i.addonId]:s}},{onSuccess:O})};if(f.isLoading||p.isLoading)return U(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading pipeline…`});if(f.error)return R(`div`,{className:`text-xs text-red-400`,children:[`Failed to load catalog: `,String(f.error)]});if(!_)return U(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog unavailable for this node (runner offline?).`});let j=i!==null&&w!==null&&s!==null,M=p.data?.maxCameras??null;return R(`div`,{className:`relative h-full w-full space-y-3`,children:[U(Xt,{nodeId:e}),U(en,{value:M,pending:g.isPending,errorMessage:g.isError?g.error instanceof Error?g.error.message:`Unknown error`:null,onCommit:t=>g.mutate({agentNodeId:e,maxCameras:t})}),U(it,{nodeId:e,addonIds:tn,level:`global`,sectionIds:nn}),R(`div`,{className:`flex items-center gap-2 text-xs`,children:[U(`span`,{className:`font-medium text-muted-foreground`,children:`Batch assign:`}),U(`button`,{type:`button`,onClick:()=>u(`pipeline`),className:`rounded border border-border bg-surface px-2 py-0.5 text-xs hover:bg-surface-hover`,children:`Pipeline…`}),U(`button`,{type:`button`,onClick:()=>u(`audio`),className:`rounded border border-border bg-surface px-2 py-0.5 text-xs hover:bg-surface-hover`,children:`Audio…`}),U(`button`,{type:`button`,onClick:()=>u(`decode`),className:`rounded border border-border bg-surface px-2 py-0.5 text-xs text-foreground-subtle hover:bg-surface-hover`,children:`Decode… (advisory)`})]}),l&&U(Yt,{nodeId:e,nodeName:d,concern:l,open:l!==null,onClose:()=>u(null)}),U(`div`,{className:j?`pr-[360px]`:``,children:b.length>0?U(oe,{tree:b,agents:S,getCellState:C,onCellClick:T,selectedCell:i,onToggleEnabled:E}):U(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),U(k,{open:j,onClose:O,title:w?.name??``,subtitle:i?`${i.agentNodeId} · ${y}`:``,footer:R(B,{children:[U(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:O,children:`Cancel`}),U(`button`,{type:`button`,disabled:!s||!i||h.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:A,children:h.isPending?`Saving…`:`Save`})]}),children:w&&s&&i&&U(D,{mode:`agent`,addon:w,agentDefault:s,agentNodeId:i.agentNodeId,engineFormat:y,onChangeAgentConfig:e=>c(e)})})]})}var on=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],sn=`decoder-nodeav`;function cn({nodeId:e,refreshToken:t}){let{data:n}=o(void 0),r=n?.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.id??sn,i=[...on,r];return R(`div`,{className:`flex flex-col h-full`,children:[U(ht,{nodeId:e,refreshToken:t}),U(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-6`,children:U(it,{nodeId:e,addonIds:i,level:`global`,extraTabs:[{id:`assignments`,label:`Assignments`,order:-10,content:U(kt,{nodeId:e,refreshToken:t})},{id:`tree`,label:`Pipeline`,order:39,content:U(an,{nodeId:e,refreshToken:t})},{id:`engines`,label:`Warm instances`,order:180,content:U(jt,{nodeId:e,refreshToken:t})},{id:`models`,label:`Models`,order:200,content:U(Vt,{nodeId:e,refreshToken:t})}]})})]})}var ln=`pipeline-orchestrator`,un=`recorder`,dn=`recordingNodeId`,fn=[`ingestNode`,`recordingNode`,`audioNode`],pn=[{key:`detect`,label:`Detect`,hint:`Runs the detection pipeline for assigned cameras`},{key:`decode`,label:`Decode`,hint:`Decodes video frames locally (advisory placement)`},{key:`audio`,label:`Audio`,hint:`Handles audio codec + analysis work`},{key:`ingest`,label:`Ingest`,hint:`Terminates camera ingest streams`}];function mn(e,t){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t)return e.value}function hn(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function gn(e,t,n){let r=mn(e,t);return typeof r==`string`&&r.length>0?r:n}function _n(e,t,n){let r=mn(e,t);return typeof r==`number`&&Number.isFinite(r)?r:n}function vn(e,t){let n=hn(e,t);return typeof n==`number`&&Number.isFinite(n)?n:null}function yn(e){return e===`ingestNode`?`Ingest`:e===`recordingNode`?`Recording`:`Audio`}function bn(e){return e===`ingestNode`?`Node that terminates default camera ingest`:e===`recordingNode`?`Node that owns the recorder (recording-node)`:`Node that runs singleton audio work`}function xn(e,t){return t===`detect`?e.pipeline:e[t]}function Sn(e){e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listAgentSettings`]]}),e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]}),e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}function Cn({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?ze:ke;return R(`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:[U(u,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":`true`}),U(`span`,{children:t})]})}L();function wn({nodeId:e,value:t,pending:n,onCommit:r}){let[i,a]=H(t===null?``:String(t));W(()=>{a(t===null?``:String(t))},[t]);let o=()=>{let t=Number(i);r(e,Number.isFinite(t)&&t>0?Math.floor(t):null)};return U(`input`,{"aria-label":`Max cameras for ${e}`,type:`number`,min:0,step:1,placeholder:`∞`,value:i,disabled:n,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`&&o()},className:`w-20 rounded-md border border-border bg-background px-2.5 py-1.5 text-sm text-foreground focus:border-primary focus:outline-none disabled:opacity-50`})}function Tn({node:t,emphasis:n=!1}){let r=t.isHub?Fe:K;return R(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[U(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${t.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),U(r,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),R(`div`,{className:`min-w-0`,children:[R(`div`,{className:`flex items-center gap-1.5 ${n?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[U(`span`,{className:`truncate`,children:t.name}),t.isHub&&U(e,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`hub`}),!t.isOnline&&U(e,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`offline`})]}),U(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:t.id})]})]})}L();function En({nodeId:e,weight:t,totalWeight:n,pending:r,onCommit:i}){let[a,o]=H(String(t));W(()=>{o(String(t))},[t]);let s=n>0?t/n:0,c=2*Math.PI*15,l=c*s,u=()=>{let t=Number(a);i(e,Number.isFinite(t)&&t>0?t:null)};return R(`div`,{className:`flex items-center gap-3`,children:[R(`svg`,{viewBox:`0 0 40 40`,className:`h-11 w-11 shrink-0`,"aria-hidden":`true`,children:[U(`circle`,{cx:`20`,cy:`20`,r:15,fill:`none`,className:`stroke-border`,strokeWidth:`4`}),U(`circle`,{cx:`20`,cy:`20`,r:15,fill:`none`,className:`stroke-primary transition-all`,strokeWidth:`4`,strokeDasharray:`${l} ${c-l}`,strokeLinecap:`round`,transform:`rotate(-90 20 20)`}),R(`text`,{x:`20`,y:`23`,textAnchor:`middle`,className:`fill-foreground text-[9px] font-bold`,children:[Math.round(s*100),`%`]})]}),U(`input`,{"aria-label":`Detect weight for ${e}`,type:`number`,min:0,step:.25,value:a,disabled:r,onChange:e=>o(e.target.value),onBlur:u,onKeyDown:e=>{e.key===`Enter`&&u()},className:`w-20 rounded-md border border-border bg-background px-2.5 py-1.5 text-sm text-foreground focus:border-primary focus:outline-none disabled:opacity-50`})]})}function Dn({label:e,children:t}){return R(`div`,{className:`flex items-center justify-between gap-3`,children:[U(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-foreground-subtle`,children:e}),t]})}function On({node:e,actions:t}){return R(`div`,{className:`rounded-xl border border-border bg-background p-4 space-y-4 ${e.isOnline?``:`opacity-60`}`,children:[U(Tn,{node:e,emphasis:!0}),U(`div`,{className:`grid grid-cols-2 gap-2`,children:pn.map(n=>U(Cn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:xn(e.effective,n.key),pending:t.capabilityPending,layout:`card`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)},n.key))}),R(`div`,{className:`space-y-3 border-t border-border pt-3`,children:[U(Dn,{label:`Detect weight`,children:e.effective.pipeline?U(En,{nodeId:e.id,weight:e.weight,totalWeight:t.totalWeight,pending:t.weightPending,onCommit:t.onCommitWeight}):U(`span`,{className:`text-[11px] italic text-foreground-subtle`,children:`Detect off`})}),U(Dn,{label:`Max cameras`,children:U(wn,{nodeId:e.id,value:e.maxCameras,pending:t.maxCamerasPending,onCommit:t.onCommitMaxCameras})})]})]})}function kn(){return R(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-foreground-subtle`,children:[R(`span`,{className:`inline-flex items-center gap-1.5`,children:[U(`span`,{className:`h-2.5 w-2.5 rounded-full border border-success/30 bg-success/15`}),`Active capability`]}),R(`span`,{className:`inline-flex items-center gap-1.5`,children:[U(`span`,{className:`h-2.5 w-2.5 rounded-full border border-border bg-surface-hover`}),`Idle`]}),R(`span`,{className:`inline-flex items-center gap-1.5`,children:[U(`span`,{className:`h-2 w-2 rounded-full bg-success`}),`Node online`]}),R(`span`,{className:`inline-flex items-center gap-1.5`,children:[U(`span`,{className:`h-2 w-2 rounded-full bg-danger`}),`Node offline`]})]})}function An({nodes:e,actions:t}){return U(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:R(`table`,{className:`w-full min-w-[720px] border-collapse text-sm`,children:[U(`thead`,{children:R(`tr`,{className:`border-b border-border bg-background text-[10px] uppercase tracking-wider text-foreground-subtle`,children:[U(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Node`}),pn.map(e=>U(`th`,{className:`px-3 py-3 text-center font-semibold`,children:e.label},e.key)),U(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Detect weight`}),U(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Max cameras`})]})}),U(`tbody`,{children:e.map(e=>R(`tr`,{className:`border-b border-border last:border-b-0 transition-colors hover:bg-surface-hover/40 ${e.isOnline?``:`opacity-60`}`,children:[U(`td`,{className:`px-4 py-3 align-middle`,children:U(Tn,{node:e})}),pn.map(n=>U(`td`,{className:`px-3 py-3 text-center align-middle`,children:U(Cn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:xn(e.effective,n.key),pending:t.capabilityPending,layout:`cell`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)})},n.key)),U(`td`,{className:`px-4 py-3 align-middle`,children:e.effective.pipeline?U(En,{nodeId:e.id,weight:e.weight,totalWeight:t.totalWeight,pending:t.weightPending,onCommit:t.onCommitWeight}):U(`span`,{className:`text-[11px] italic text-foreground-subtle`,children:`Detect off`})}),U(`td`,{className:`px-4 py-3 align-middle`,children:U(wn,{nodeId:e.id,value:e.maxCameras,pending:t.maxCamerasPending,onCommit:t.onCommitMaxCameras})})]},e.id))})]})})}function jn({role:e,value:t,options:n,pending:r,onChange:i}){return R(`label`,{className:`flex flex-col gap-1.5 rounded-lg border border-border bg-background p-3`,children:[U(`span`,{className:`text-xs font-semibold text-foreground`,children:yn(e)}),U(`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=>U(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),U(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:bn(e)})]})}function Mn({roleValues:e,options:t,pending:n,lowFpsEnabled:r,fpsMinThreshold:i,onRoleChange:a,onLowFpsToggle:o}){return R(`div`,{className:`grid gap-3 @lg/clustertab:grid-cols-2 @3xl/clustertab:grid-cols-4`,children:[fn.map(r=>U(jn,{role:r,value:e[r],options:t,pending:n,onChange:a},r)),R(`label`,{className:`flex items-start gap-2.5 rounded-lg border border-border bg-background p-3 text-sm text-foreground`,children:[U(`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`}),R(`span`,{className:`flex flex-col gap-0.5`,children:[U(`span`,{className:`text-xs font-semibold`,children:`Low-fps relocate/shed`}),R(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:[`fpsMinThreshold `,r?`${i} fps`:`disabled`]})]})]})]})}L();function Nn(){let e=V(),{nodes:t}=F(),n=I(void 0),r=P({addonId:ln}),i=P({addonId:un}),a=()=>Sn(e),o=A({onSuccess:a}),s=M({onSuccess:a}),c=ne({onSuccess:a}),l=te({onSuccess:a}),u=z(()=>{let e=new Map;for(let t of n.data??[])e.set(t.nodeId,t.settings);return e},[n.data]),d=z(()=>t.map(e=>{let t=u.get(e.id),n=ft(t,e.isHub),r=vn(t,`detectWeight`);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n,weight:r??1,maxCameras:vn(t,`maxCameras`)}}),[t,u]),f=d.filter(e=>e.effective.pipeline).reduce((e,t)=>e+t.weight,0),p={ingestNode:gn(r.data,`ingestNode`,`hub`),recordingNode:gn(i.data,dn,`hub`),audioNode:gn(r.data,`audioNode`,`hub`)},m=z(()=>{let e=t.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,...fn.map(e=>p[e]),...e])].filter(e=>e.length>0)},[t,p]),h=_n(r.data,`fpsMinThreshold`,0),g=h>0,_=n.isLoading||r.isLoading||i.isLoading,v=(e,t,n)=>{o.mutate({agentNodeId:e,[t]:n})},y=(e,t)=>{if(e===`recordingNode`){l.mutate({addonId:un,patch:{[dn]:t}});return}l.mutate({addonId:ln,patch:{[e]:t}})},b=e=>{l.mutate({addonId:ln,patch:{fpsMinThreshold:e?Math.max(1,h):0}})},x={totalWeight:f,capabilityPending:o.isPending,weightPending:s.isPending,maxCamerasPending:c.isPending,onToggleCapability:v,onCommitWeight:(e,t)=>s.mutate({agentNodeId:e,detectWeight:t}),onCommitMaxCameras:(e,t)=>c.mutate({agentNodeId:e,maxCameras:t})};return R(`section`,{className:`rounded-xl border border-border bg-surface p-5 @3xl/clustertab:p-6 space-y-6`,children:[R(`header`,{className:`flex items-start justify-between gap-4`,children:[R(`div`,{className:`space-y-1`,children:[U(`h3`,{className:`text-base font-semibold text-foreground`,children:`Pipeline placement`}),U(`p`,{className:`max-w-prose text-xs leading-relaxed text-foreground-subtle`,children:`Toggle which node runs each pipeline capability, tune relative detection weights, set per-node camera ceilings, and choose the singleton cluster roles. Weights are relative shares across detect-capable nodes.`})]}),_&&U(q,{className:`h-5 w-5 shrink-0 animate-spin text-foreground-subtle`,"aria-label":`Loading`})]}),R(`div`,{className:`space-y-3`,children:[U(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Singleton cluster roles`}),U(Mn,{roleValues:p,options:m,pending:l.isPending,lowFpsEnabled:g,fpsMinThreshold:h,onRoleChange:y,onLowFpsToggle:b})]}),R(`div`,{className:`space-y-3`,children:[R(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[U(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Per-node capabilities`}),U(kn,{})]}),d.length===0?U(`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.`}):R(B,{children:[U(`div`,{className:`grid gap-4 @xl/clustertab:grid-cols-2 @3xl/clustertab:hidden`,children:d.map(e=>U(On,{node:e,actions:x},e.id))}),U(`div`,{className:`hidden @3xl/clustertab:block`,children:U(An,{nodes:d,actions:x})})]})]})]})}L();function Pn({refreshToken:e}){let t=V(),{data:n}=o(void 0),r=z(()=>nt(n??[]),[n]),i=O({onSuccess:()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getDecoderAssignments`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})}});return R(`div`,{className:`space-y-6`,children:[U(gt,{refreshToken:e}),U(Nn,{}),R(`section`,{className:`rounded-lg border border-border bg-surface p-4 space-y-3`,children:[R(`div`,{children:[U(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Cluster map`}),U(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`React Flow topology map retained as the visual placement map; use the table-board above as the control surface.`})]}),U(`div`,{className:`h-[360px] rounded-md border border-border overflow-hidden bg-background`,children:U($e,{graph:r})})]}),R(`div`,{className:`flex flex-col gap-3 @md/clustertab:flex-row @md/clustertab:items-center @md/clustertab:justify-between`,children:[R(`div`,{className:`min-w-0`,children:[U(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Placement matrix`}),U(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Pipeline · decoder · audio assignments per camera. Click the kebab to pin / unpin / move any role; expand the chevron for the per-camera broker drill-down.`})]}),R(`button`,{type:`button`,onClick:()=>i.mutate(void 0),disabled:i.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:[U(Oe,{className:`h-3.5 w-3.5`}),i.isPending?`Rebalancing…`:`Rebalance pipelines`]})]}),U(xt,{mode:`cluster`})]})}var Fn=[`pipeline-orchestrator`];function In({refreshToken:e}){return U(`div`,{className:`space-y-4 max-w-3xl`,children:U(it,{nodeId:`hub`,addonIds:Fn,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.`})})}L();function Ln({refreshToken:e}){let t=V(),{data:n,isLoading:r}=se(),[i,a]=H(null),[o,s]=H(``),[c,l]=H(``),d=()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listTemplates`]]})},f=fe({onSuccess:()=>{a(null),d()}}),p=u({onSuccess:d}),m=e=>{a(e.id),s(e.name),l(e.description??``)},h=()=>{a(null),s(``),l(``)},g=()=>{if(!i)return;let e=c.trim();f.mutate({id:i,name:o.trim()||`Untitled`,...e?{description:e}:{}})};if(r)return U(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading templates…`});let _=[...n??[]].toSorted((e,t)=>e.name.localeCompare(t.name));return U(`div`,{className:`space-y-6 max-w-4xl`,children:R(`section`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[R(`div`,{className:`border-b border-border px-4 py-3 flex items-center justify-between`,children:[R(`div`,{children:[U(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Templates`}),U(`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.`})]}),R(`div`,{className:`text-[11px] text-foreground-subtle`,children:[_.length,` template`,_.length===1?``:`s`]})]}),_.length===0?R(`div`,{className:`px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2`,children:[U(Me,{className:`h-6 w-6 opacity-40`}),U(`div`,{children:`No templates yet. Create one from a device Pipeline tab ("Save as template").`})]}):U(`ul`,{className:`divide-y divide-border`,children:_.map(e=>{let t=i===e.id;return U(`li`,{className:`px-4 py-3 text-xs`,children:R(`div`,{className:`flex items-start gap-3`,children:[U(`div`,{className:`flex-1 min-w-0`,children:t?R(`div`,{className:`space-y-2`,children:[U(`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:o,onChange:e=>s(e.target.value),placeholder:`Template name`,autoFocus:!0}),U(`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:c,onChange:e=>l(e.target.value),placeholder:`Description (optional)`})]}):R(B,{children:[U(`div`,{className:`font-medium text-foreground`,children:e.name}),e.description&&U(`div`,{className:`text-foreground-subtle mt-0.5`,children:e.description}),R(`div`,{className:`mt-1 font-mono text-[10px] text-foreground-subtle`,children:[`engine `,e.config.engine.runtime,`/`,e.config.engine.backend,` ·`,` `,e.config.steps.length,` step(s)`,e.config.audio?.enabled?` · audio`:``,R(`span`,{className:`ml-2`,children:[`updated `,new Date(e.updatedAt).toLocaleString()]})]})]})}),U(`div`,{className:`flex items-center gap-1 shrink-0`,children:t?R(B,{children:[R(`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:[U(ze,{className:`h-3 w-3`}),`Save`]}),R(`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:[U(We,{className:`h-3 w-3`}),`Cancel`]})]}):R(B,{children:[U(`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:U(je,{className:`h-3 w-3`})}),U(`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:U(qe,{className:`h-3 w-3`})})]})})]})},e.id)})})]})})}L();function Rn(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 zn({nodeId:e,refreshToken:n}){let r=V(),i=be().trpcClient,[a,s]=H(null),[c,l]=H(null),u=I(void 0,{refetchOnMount:`always`});J([`nodes`,`topology`],[`agent.online`,`agent.offline`,`agent.unregistered`,`addon.installed`,`addon.uninstalled`,`addon.updated`]);let d=o(void 0,{refetchOnMount:`always`}),f=z(()=>{let e=new Set;for(let t of d.data??[])t.isOnline&&e.add(t.id);return e},[d.data]),p=t({nodeId:e},{refetchOnMount:`always`}),m=z(()=>(u.data??[]).filter(e=>f.has(e.nodeId)).map(e=>e.nodeId),[u.data,f]),h=ve({enabled:m.length>0,queryKey:[[`pipelineExecutor`,`getSchema`],`schema-by-agent`,m.join(`,`),n],queryFn:async()=>{let e={};for(let t of m)try{e[t]=(await i.pipelineExecutor.getSchema.query({nodeId:t})).selectedEngine.format}catch{e[t]=`coreml`}return e}}),g=ue({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]}),r.invalidateQueries({queryKey:[[`pipelineExecutor`]]}),r.invalidateQueries({queryKey:[[`addonSettings`]]})}}),_=z(()=>p.data?le(p.data):[],[p.data]),v=z(()=>{let e=u.data??[],t=f;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)`}})},[u.data,h.data,f]),y=(e,t)=>{let n=(u.data?.find(e=>e.nodeId===t))?.settings.addonDefaults[e],r=h.data?.[t];return!Rn(p.data??null,e)?.models.some(e=>r!==void 0&&!!e.formats[r])||!n?{kind:`na`}:n.enabled?{kind:`enabled`,modelId:n.modelId}:{kind:`disabled`}},b=a?u.data?.find(e=>e.nodeId===a.agentNodeId)??null:null,x=a&&p.data?Rn(p.data,a.addonId):null,S=a?h.data?.[a.agentNodeId]??`coreml`:`coreml`,C=()=>{s(null),l(null)},w=(e,t)=>{let n=(u.data?.find(e=>e.nodeId===t))?.settings.addonDefaults[e]??null;s({addonId:e,agentNodeId:t}),l(n)},T=()=>{!c||!a||!b||g.mutate({agentNodeId:a.agentNodeId,defaults:{...b.settings.addonDefaults,[a.addonId]:c}},{onSuccess:C})};if(u.isLoading||p.isLoading)return U(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading agents…`});if(!p.data)return R(`div`,{className:`text-xs text-foreground-subtle`,children:[`Catalog unavailable for `,e,`.`]});let E=a!==null&&x!==null&&c!==null;return R(`div`,{className:`relative h-full w-full space-y-3`,children:[U(Xt,{title:`Cluster cameras`}),U(`div`,{className:E?`pr-[360px]`:``,children:_.length>0&&v.length>0?U(oe,{tree:_,agents:v,getCellState:y,onCellClick:w,selectedCell:a}):U(`div`,{className:`text-xs text-foreground-subtle`,children:`No agents or catalog empty.`})}),U(k,{open:E,onClose:C,title:x?.name??``,subtitle:a?`${a.agentNodeId} · ${S}`:``,footer:R(B,{children:[U(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:C,children:`Cancel`}),U(`button`,{type:`button`,disabled:!c||!a||g.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:T,children:g.isPending?`Saving…`:`Save`})]}),children:x&&c&&a&&U(D,{mode:`agent`,addon:x,agentDefault:c,agentNodeId:a.agentNodeId,engineFormat:S,onChangeAgentConfig:e=>l(e)})})]})}L();function Bn({types:e}){let t=V(),n=p(),{data:r}=i({}),o=a(),s=z(()=>o.data??[],[o.data]),[c,l]=H(null),[u,d]=H(null),f=()=>{t.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})},m=ee({onSuccess:f}),h=v({onSuccess:f}),g=z(()=>{let e=new Map;for(let t of r??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[r]),_=e=>{e.isDefault||m.mutate({id:e.id,type:e.type,providerId:e.providerId,displayName:e.displayName,config:e.config,isDefault:!0})},y=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`})&&h.mutate({id:e.id})},b=e.map(e=>s.find(t=>t.id===e)).filter(e=>e!==void 0);return R(`div`,{className:`space-y-3`,children:[b.length===0?U(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:`No storage locations declared for this purpose.`}):b.map(e=>U(we,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:g.get(e.id)??[],onAdd:e=>l(e),onEdit:e=>d(e),onDelete:e=>{y(e)},onSetDefault:e=>_(e)},e.id)),c!==null&&U(Te,{initialType:c,onClose:()=>l(null),onCreated:()=>{f(),l(null)}}),u!==null&&U(Ce,{location:u,onClose:()=>d(null),onSaved:()=>{f(),d(null)}})]})}L();var Vn=`pipeline-analytics`;function Hn(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 Un(){let e=V(),{data:t}=o(void 0),{data:n,isLoading:r}=P({addonId:Vn}),i=Hn(n),a=te({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),s=z(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,i,...e])].filter(Boolean)},[t,i]);return R(`div`,{className:`flex flex-col gap-6`,children:[R(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[U(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Post-processing node`}),U(`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.`}),R(`div`,{className:`mt-3 flex items-center gap-2`,children:[r?U(q,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):U(`select`,{value:i,onChange:e=>{e.target.value!==i&&a.mutate({addonId:Vn,patch:{postProcessingNodeId:e.target.value}})},disabled:a.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:s.map(e=>U(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),a.isPending&&U(q,{className:`h-4 w-4 animate-spin text-primary`})]})]}),R(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[U(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Events folder`}),U(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`}),U(Bn,{types:[`eventMedia`]})]})]})}L();var Wn=`recorder`;function Gn(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 Kn(){let e=V(),{data:t}=o(void 0),{data:n,isLoading:r}=P({addonId:Wn}),i=Gn(n,`recordingNodeId`,`hub`),a=te({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),s=z(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,i,...e])].filter(Boolean)},[t,i]);return R(`div`,{className:`flex flex-col gap-6`,children:[R(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[U(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Recording node`}),U(`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.`}),R(`div`,{className:`mt-3 flex items-center gap-2`,children:[r?U(q,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):U(`select`,{value:i,onChange:e=>{e.target.value!==i&&a.mutate({addonId:Wn,patch:{recordingNodeId:e.target.value}})},disabled:a.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:s.map(e=>U(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),a.isPending&&U(q,{className:`h-4 w-4 animate-spin text-primary`})]}),i!==`hub`&&R(`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`,` `,U(`span`,{className:`font-medium`,children:i}),`. If the auto-derived host doesn't work, set the recorder's`,U(`span`,{className:`font-medium`,children:` recordingHubHostname`}),` global setting.`]})]}),R(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[U(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Recordings folders`}),U(`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.`}),U(Bn,{types:[`recordings`,`recordingsLow`]})]})]})}L();var qn=[{id:`assignments`,label:`Assignments`},{id:`pipeline`,label:`Pipeline`},{id:`events`,label:`Events`},{id:`recording`,label:`Recording`},{id:`settings`,label:`Settings`},{id:`templates`,label:`Templates`}];function Jn({refreshToken:e}){let[t,n]=H(`assignments`),{data:r}=o(void 0),i=r?.find(e=>e.isHub&&e.isOnline)?.id??r?.find(e=>e.isOnline)?.id??null;return R(`div`,{className:`flex flex-col h-full`,children:[R(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[U(`h2`,{className:`text-base font-semibold text-foreground`,children:`Cluster Orchestration`}),U(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:`Assignments with live load, cluster-wide settings, pipeline template library, per-camera pipeline overrides.`})]}),U(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:qn.map(e=>U(`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))}),R(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[t===`assignments`&&U(Pn,{refreshToken:e}),t===`pipeline`&&(i?U(zn,{nodeId:i,refreshToken:e}):U(`div`,{className:`text-xs text-foreground-subtle`,children:`No online node available — schema unreachable.`})),t===`events`&&U(Un,{}),t===`recording`&&U(Kn,{}),t===`settings`&&U(In,{refreshToken:e}),t===`templates`&&U(Ln,{refreshToken:e})]})]})}function Yn(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`}L();var Xn={healthy:`bg-green-500`,idle:`bg-yellow-400`,error:`bg-red-500`},Zn={healthy:`Healthy`,idle:`Idle`,error:`Error`};function Qn({health:e}){return U(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${Xn[e]}`,title:Zn[e],"aria-label":Zn[e],role:`img`})}function $n({selectedDeviceId:e,onSelect:t}){let{data:n}=Ae(),{data:r}=ce({}),i=z(()=>{let e=new Map;for(let t of r??[])e.set(t.deviceId,t);return e},[r]),a=z(()=>(n??[]).filter(e=>e.isCamera).map(e=>{let t=i.get(e.id);return{deviceId:e.id,name:e.name,health:t===void 0?`idle`:Yn(t)}}),[n,i]);return a.length===0?U(`div`,{className:`px-4 py-6 text-center text-[11px] text-foreground-subtle italic`,children:`No cameras found`}):U(`ul`,{className:`divide-y divide-border`,children:a.map(n=>{let r=n.deviceId===e;return U(`li`,{children:R(`button`,{type:`button`,onClick:()=>t(n.deviceId),className:[`w-full flex items-center gap-2.5 px-4 py-3 text-left transition-colors`,r?`bg-surface-active text-foreground`:`hover:bg-surface-hover text-foreground-subtle hover:text-foreground`].join(` `),"aria-pressed":r,children:[U(Qn,{health:n.health}),R(`span`,{className:`flex-1 min-w-0`,children:[U(`span`,{className:`block truncate text-[12px] font-medium leading-tight`,children:n.name}),R(`span`,{className:`block text-[10px] text-foreground-subtle leading-tight mt-0.5`,children:[`#`,n.deviceId]})]})]})},n.deviceId)})})}var er=300,tr=158,nr={camera:0,source:1,broker:2,decoder:3,motion:4,detection:4,audio:4,recorder:4};function $(e){return nr[e]*er}function rr(e,t){return e===null||t===null?!1:e!==t}function ir(e){let t=e.profiles.reduce((e,t)=>e+t.subscribers,0),n=e.profiles.reduce((e,t)=>e+t.inFps,0),r=e.profiles.reduce((e,t)=>e+t.outFps,0);return`${t} subs · ${n.toFixed(1)}→${r.toFixed(1)} fps`}function ar(e){return`${e.actualFps.toFixed(1)} fps · q${e.queueDepth} · ${e.avgInferenceMs.toFixed(1)}ms`}function or(e){return`shm ${e.shm.getFrameHits+e.shm.getFrameMisses>0?Math.round(e.shm.getFrameHits/(e.shm.getFrameHits+e.shm.getFrameMisses)*100):0}% hit`}function sr(e){let t=[],n=[],r=e.decoder===null?0:[e.motion,e.detection,e.audio,e.recording].filter(e=>e!==null).length,i=r>1?(r-1)/2*tr:0,a={id:`camera`,kind:`camera`,nodeId:null,data:{deviceId:e.deviceId},position:{x:$(`camera`),y:i}};t.push(a);let o={id:`source`,kind:`source`,nodeId:null,data:{streams:e.source.streams},position:{x:$(`source`),y:i}};t.push(o),n.push({id:`camera->source`,source:`camera`,target:`source`,crossNode:!1});let s=e.broker;if(s!==null){let e={id:`broker`,kind:`broker`,nodeId:null,data:{profiles:s.profiles,webrtcSessions:s.webrtcSessions,rtspRestream:s.rtspRestream},position:{x:$(`broker`),y:i}};t.push(e),n.push({id:`source->broker`,source:`source`,target:`broker`,crossNode:!1})}let c=e.decoder;if(c!==null){let r={id:`decoder`,kind:`decoder`,nodeId:c.nodeId,data:{nodeId:c.nodeId,formats:c.formats,sessionCount:c.sessionCount,shm:c.shm},position:{x:$(`decoder`),y:i}};t.push(r);let a=s===null?`source`:`broker`,o=s===null?void 0:ir(s),l=s===null?or(c):o;n.push({id:`${a}->decoder`,source:a,target:`decoder`,crossNode:rr(null,c.nodeId),...l===void 0?{}:{label:l}});let u=0,d=e.motion;if(d!==null){let e={id:`motion`,kind:`motion`,nodeId:null,data:{enabled:d.enabled,fps:d.fps},position:{x:$(`motion`),y:u*tr}};t.push(e),n.push({id:`decoder->motion`,source:`decoder`,target:`motion`,crossNode:!1}),u++}let f=e.detection;if(f!==null){let e={id:`detection`,kind:`detection`,nodeId:f.nodeId,data:{nodeId:f.nodeId,engine:f.engine,phase:f.phase,configuredFps:f.configuredFps,actualFps:f.actualFps,queueDepth:f.queueDepth,avgInferenceMs:f.avgInferenceMs,provisioning:f.provisioning},position:{x:$(`detection`),y:u*tr}};t.push(e),n.push({id:`decoder->detection`,source:`decoder`,target:`detection`,crossNode:rr(c.nodeId,f.nodeId),label:ar(f)}),u++}let p=e.audio;if(p!==null){let e={id:`audio`,kind:`audio`,nodeId:p.nodeId,data:{nodeId:p.nodeId,enabled:p.enabled},position:{x:$(`audio`),y:u*tr}};t.push(e),n.push({id:`decoder->audio`,source:`decoder`,target:`audio`,crossNode:rr(c.nodeId,p.nodeId)}),u++}let m=e.recording;if(m!==null){let e={id:`recorder`,kind:`recorder`,nodeId:null,data:{mode:m.mode,active:m.active,storageBytes:m.storageBytes},position:{x:$(`recorder`),y:u*tr}};t.push(e),n.push({id:`decoder->recorder`,source:`decoder`,target:`recorder`,crossNode:!1})}}return{nodes:t,edges:n}}L();function cr(e){let{data:t,isLoading:n}=j({deviceId:e}),[r,i]=H(void 0);return W(()=>{t!==void 0&&i(t)},[t]),w(G.PipelineCameraMetricsSnapshot,t=>{let n=t.data;n.deviceId===e&&i(e=>e===void 0||e.detection===null?e:{...e,detection:{...e.detection,phase:n.metrics.phase,actualFps:n.metrics.actualFps,queueDepth:n.metrics.queueDepth,avgInferenceMs:n.metrics.avgInferenceTimeMs}})}),w(G.PipelineEngineProvisioning,e=>{let t=e.data;i(n=>{if(n===void 0||n.detection===null)return n;let r=n.detection.nodeId??n.assignment?.detectionNodeId??null;return r===null||e.source.type!==`node`||e.source.id!==r?n:{...n,detection:{...n.detection,provisioning:{state:t.state,error:t.error}}}})}),w(G.MotionAnalysis,t=>{t.source.type!==`device`||t.source.id!==e||i(e=>e===void 0||e.motion===null?e:{...e,motion:{...e.motion,enabled:!0}})}),w(G.StreamBrokerMetricsSnapshot,t=>{let n=t.data;n.deviceId===e&&i(e=>e===void 0||e.broker===null?e:{...e,broker:{...e.broker,profiles:e.broker.profiles.map(e=>e.profile===n.profile?{...e,subscribers:n.stats.encodedSubscribers+n.stats.decodedSubscribers,inFps:n.stats.inputFps,outFps:n.stats.decodeFps}:e)}})}),w(G.PipelineAudioInferenceResult,t=>{t.data.deviceId===e&&i(e=>e===void 0||e.audio===null?e:{...e,audio:{...e.audio,enabled:!0}})}),w(G.RecordingStarted,t=>{t.data.deviceId===e&&i(e=>e===void 0||e.recording===null?e:{...e,recording:{...e.recording,active:!0}})}),w(G.RecordingStopped,t=>{t.data.deviceId===e&&i(e=>e===void 0||e.recording===null?e:{...e,recording:{...e.recording,active:!1}})}),{status:r,isLoading:n}}function lr({data:e}){return R(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[U(X,{type:`source`,position:Y.Right}),R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`h-2 w-2 rounded-full bg-green-500 shrink-0`,"aria-label":`healthy`}),R(`span`,{className:`text-sm font-semibold truncate`,children:[`Camera #`,e.deviceId]})]}),U(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`source`})]})}function ur(e){return e>0?`bg-green-500`:`bg-yellow-500`}function dr({data:e}){let t=e.streams[0],n=e.streams.length;return R(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[U(X,{type:`target`,position:Y.Left}),U(X,{type:`source`,position:Y.Right}),R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${ur(n)}`,"aria-label":n>0?`healthy`:`idle`}),U(`span`,{className:`text-sm font-semibold`,children:`Source`}),R(`span`,{className:`text-xs text-muted-foreground`,children:[n,` streams`]})]}),t!==void 0&&R(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[t.codec,` `,t.width,`×`,t.height,` `,t.fps,`fps`]})]})}function fr(e){return e>0?`bg-green-500`:`bg-yellow-500`}function pr({data:e}){let t=e.profiles.reduce((e,t)=>e+t.subscribers,0),n=e.profiles.length;return R(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[U(X,{type:`target`,position:Y.Left}),U(X,{type:`source`,position:Y.Right}),R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${fr(t)}`,"aria-label":t>0?`healthy`:`idle`}),U(`span`,{className:`text-sm font-semibold`,children:`Broker`}),R(`span`,{className:`text-xs text-muted-foreground`,children:[n,` profiles`]})]}),R(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[t,` subs · WebRTC `,e.webrtcSessions,e.rtspRestream&&` · RTSP`]})]})}function mr(e){return e>0?`bg-green-500`:`bg-yellow-500`}function hr(e,t){let n=e+t;return n>0?Math.round(e/n*100):0}function gr({data:e}){let t=hr(e.shm.getFrameHits,e.shm.getFrameMisses),n=e.offline===!0;return R(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2${n?` opacity-50`:``}`,children:[U(X,{type:`target`,position:Y.Left}),U(X,{type:`source`,position:Y.Right}),R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${mr(e.sessionCount)}`,"aria-label":e.sessionCount>0?`healthy`:`idle`}),U(`span`,{className:`text-sm font-semibold`,children:`Decoder`}),R(`span`,{className:`text-xs text-muted-foreground`,children:[`@`,e.nodeId]}),n&&U(`span`,{className:`text-[9px] font-semibold px-1 py-0.5 rounded bg-destructive/10 text-destructive`,"aria-label":`offline`,children:`offline`})]}),R(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.formats.join(`, `),` · `,e.sessionCount,` sessions`]}),R(`div`,{className:`text-xs text-muted-foreground`,children:[`shm `,t,`% hit`]})]})}function _r(e){return e?`bg-green-500`:`bg-yellow-500`}function vr({data:e}){return R(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[U(X,{type:`target`,position:Y.Left}),R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${_r(e.enabled)}`,"aria-label":e.enabled?`enabled`:`disabled`}),U(`span`,{className:`text-sm font-semibold`,children:`Motion`})]}),R(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.enabled?`enabled`:`disabled`,` · `,e.fps,` fps`]})]})}function yr(e){return e.provisioning.state===`failed`?`bg-red-500`:e.phase===`active`?`bg-green-500`:(e.phase,`bg-yellow-500`)}function br(e){return e===`ready`?`bg-green-500 text-white`:e===`failed`?`bg-red-500 text-white`:`bg-yellow-500 text-white`}function xr({data:e}){let t=e.offline===!0;return R(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[180px] px-3 py-2${t?` opacity-50`:``}`,children:[U(X,{type:`target`,position:Y.Left}),R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${yr(e)}`,"aria-label":e.phase}),U(`span`,{className:`text-sm font-semibold`,children:`Detection`}),R(`span`,{className:`text-xs text-muted-foreground`,children:[`@`,e.nodeId]}),t&&U(`span`,{className:`text-[9px] font-semibold px-1 py-0.5 rounded bg-destructive/10 text-destructive`,"aria-label":`offline`,children:`offline`})]}),R(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.engine.backend,`·`,e.engine.device,` · `,e.phase]}),R(`div`,{className:`text-xs text-muted-foreground`,children:[e.actualFps.toFixed(1),`/`,e.configuredFps,` fps · q`,e.queueDepth,` ·`,` `,e.avgInferenceMs.toFixed(1),`ms`]}),R(`div`,{className:`flex items-center gap-1 mt-1`,children:[U(`span`,{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded ${br(e.provisioning.state)}`,"aria-label":`provisioning ${e.provisioning.state}`,children:e.provisioning.state}),e.provisioning.state===`failed`&&e.provisioning.error!==void 0&&U(`span`,{className:`text-[10px] text-red-500 truncate`,children:e.provisioning.error})]})]})}function Sr(e){return e?`bg-green-500`:`bg-yellow-500`}function Cr({data:e}){let t=e.offline===!0;return R(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2${t?` opacity-50`:``}`,children:[U(X,{type:`target`,position:Y.Left}),R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${Sr(e.enabled)}`,"aria-label":e.enabled?`enabled`:`disabled`}),U(`span`,{className:`text-sm font-semibold`,children:`Audio`}),R(`span`,{className:`text-xs text-muted-foreground`,children:[`@`,e.nodeId]}),t&&U(`span`,{className:`text-[9px] font-semibold px-1 py-0.5 rounded bg-destructive/10 text-destructive`,"aria-label":`offline`,children:`offline`})]}),U(`div`,{className:`text-xs text-muted-foreground mt-1`,children:e.enabled?`enabled`:`disabled`})]})}function wr(e){return e.mode===`off`?`bg-red-500`:e.active?`bg-green-500`:`bg-yellow-500`}function Tr(e){return e>=1073741824?`${(e/1073741824).toFixed(1)} GB`:`${(e/1048576).toFixed(1)} MB`}function Er({data:e}){return R(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[U(X,{type:`target`,position:Y.Left}),R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${wr(e)}`,"aria-label":e.active?`active`:e.mode===`off`?`off`:`inactive`}),U(`span`,{className:`text-sm font-semibold`,children:`Recorder`}),U(`span`,{className:`text-xs text-muted-foreground`,children:e.mode})]}),R(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.active?`active`:`inactive`,` · `,Tr(e.storageBytes)]})]})}L();var Dr={camera:lr,source:dr,broker:pr,decoder:gr,motion:vr,detection:xr,audio:Cr,recorder:Er},Or={stroke:`#f59e0b`,strokeWidth:2},kr={strokeWidth:1.5},Ar=`camstack-pipeline-flow-layout`,jr=`Camera → Source → Broker → Decoder → Motion · Detection · Audio · Recorder`,Mr={padding:.2};function Nr({deviceId:e}){let{status:t,isLoading:n}=cr(e),{data:r}=o(void 0),i=z(()=>{let e=new Set;for(let t of r??[])t.isOnline||e.add(t.id);return e},[r]),{computedNodes:a,rfEdges:s}=z(()=>{if(t===void 0)return{computedNodes:[],rfEdges:[]};let e=sr(t);return{computedNodes:e.nodes.map(e=>({id:e.id,type:e.kind,position:{x:e.position.x,y:e.position.y},data:{...e.data,offline:e.nodeId!==null&&i.has(e.nodeId)}})),rfEdges:e.edges.map(e=>({id:e.id,source:e.source,target:e.target,animated:e.crossNode,style:e.crossNode?Or:kr,label:e.label}))}},[t,i]),{nodes:c,onNodesChange:l,resetLayout:u}=et(`${Ar}:${e}`,a);return n?U(`div`,{className:`flex items-center justify-center h-full text-sm text-muted-foreground`,children:`Loading…`}):t===void 0?U(`div`,{className:`flex items-center justify-center h-full text-sm text-muted-foreground`,children:`No pipeline data`}):R(`div`,{className:`w-full h-full relative overflow-hidden`,children:[R(`div`,{className:`absolute top-2 left-2 z-10 max-w-[calc(100%-7rem)] rounded border border-border bg-background/90 px-2 py-1 backdrop-blur-sm`,children:[U(`div`,{className:`text-xs font-semibold text-foreground`,children:`Pipeline flow`}),U(`div`,{className:`text-[10px] text-muted-foreground truncate`,children:jr})]}),U(`button`,{type:`button`,onClick:u,className:`absolute top-2 right-2 z-10 text-xs px-2 py-1 rounded border border-border bg-background hover:bg-muted`,title:`Restore the automatic layout, discarding dragged positions`,children:`Reset layout`}),R(tt,{nodes:c,edges:s,onNodesChange:l,nodesDraggable:!0,nodeTypes:Dr,fitView:!0,fitViewOptions:Mr,minZoom:.2,proOptions:{hideAttribution:!0},children:[U(Ze,{gap:20,size:1}),U(Xe,{showInteractive:!1})]})]})}L();var Pr=`__cluster__`;function Fr(e){return e===`cameras`?`cameras`:`nodes`}function Ir(){let[e,t]=Be(),n=Fr(e.get(`view`)),r=e.get(`node`)??`__cluster__`,i=e.get(`camera`),a=i===null?null:parseInt(i,10),[o,s]=H(0),[c,l]=H(!1);return W(()=>{n===`nodes`&&!e.get(`node`)&&t({view:`nodes`,node:Pr},{replace:!0})},[n,e,t]),R(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[R(`div`,{className:`flex items-center justify-between gap-4 px-4 py-3 border-b border-border shrink-0`,children:[R(`div`,{className:`flex items-center gap-1 rounded-lg border border-border p-0.5 bg-surface`,children:[U(`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`}),U(`button`,{type:`button`,onClick:()=>{let e={view:`cameras`};a!==null&&(e.camera=String(a)),t(e,{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`})]}),R(`button`,{type:`button`,onClick:()=>s(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:[U(Ne,{className:`h-3.5 w-3.5`}),`Refresh`]})]}),R(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-expanded":c,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:[R(`span`,{children:[c?`Hide`:`Show`,` `,n===`nodes`?`node list`:`camera list`]}),U(He,{className:[`h-4 w-4 transition-transform`,c?`rotate-180`:``].join(` `)})]}),U(`div`,{className:`flex-1 flex flex-col md:flex-row overflow-hidden min-h-0`,children:n===`nodes`?R(B,{children:[U(`aside`,{className:[c?`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:U(mt,{selectedNodeId:r,onSelect:e=>{t({view:`nodes`,node:e},{replace:!0}),l(!1)},refreshToken:o})}),U(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:r===`__cluster__`?U(Jn,{refreshToken:o}):U(cn,{nodeId:r,refreshToken:o})})]}):R(B,{children:[U(`aside`,{className:[c?`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:U($n,{selectedDeviceId:a,onSelect:e=>{t({view:`cameras`,camera:String(e)},{replace:!0}),l(!1)}})}),U(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:a!==null&&Number.isFinite(a)&&!Number.isNaN(a)?U(Nr,{deviceId:a}):U(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`Select a camera to view its pipeline flow`})})]})})]})}export{Ir as PipelinePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ma as e,Na as t,Pa as n}from"./src-
|
|
1
|
+
import{Ma as e,Na as t,Pa as n}from"./src-DdZmgXMF.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-CTSvk_LT.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(n,{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(n=>{let r=I===n.id,i=n.shape.kind===`polygon`?ne:t;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(n.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 `,n.id]}),u(`span`,{className:`text-foreground-faint capitalize`,children:n.shape.kind})]}),u(`button`,{type:`button`,onClick:()=>ae(n.id),disabled:M,"aria-label":`Delete zone ${String(n.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(e,{className:`h-3.5 w-3.5`})})]},n.id)})}):null]}):u(`p`,{className:`${f} leading-relaxed`,children:`Loading the camera's privacy mask…`})})}):null}export{w as PrivacyMaskSettings};
|
|
@@ -1 +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-
|
|
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-J1OjdHB9.js";import{t as a}from"./server-C-bvt-pD.js";import{t as o}from"./wifi-CUZMfwFz.js";import{V as s}from"./index-Cc9fD-gx.js";var c=s(`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=s(`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:a,color:`#a855f7`,label:`Scrypted`},reolink:{icon:i,color:`#06b6d4`,label:`Reolink`},homeassistant:{icon:l,color:`#22d3ee`,label:`Home Assistant`},rtsp:{icon:o,color:`#78716c`,label:`RTSP`},onvif:{icon:o,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};
|