@camstack/addon-admin-ui 1.2.649 → 1.2.650

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.
Files changed (98) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/assets/{Addons-CIhFgQkc.js → Addons-66AtY5mu.js} +1 -1
  3. package/dist/assets/{AdminPage-a5x3JamG.js → AdminPage-tWFzmkA7.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-C_Xcom2n.js → AdminSectionedPage-D00S68ny.js} +1 -1
  5. package/dist/assets/{AiProfiles-C84EP_cC.js → AiProfiles-DoPAcfxw.js} +1 -1
  6. package/dist/assets/{BootstrapSettingsForm-gwEmOCOw.js → BootstrapSettingsForm-ObiD-4-l.js} +1 -1
  7. package/dist/assets/Build-MKmgkbmb.js +40 -0
  8. package/dist/assets/{Calendars-B71AHi8a.js → Calendars-D3mhCBNC.js} +1 -1
  9. package/dist/assets/{CameraGrids-BOvAtaoj.js → CameraGrids-C0n7qSaN.js} +1 -1
  10. package/dist/assets/{Cluster-CvA-GBsH.js → Cluster-x_aFWP8q.js} +1 -1
  11. package/dist/assets/CompositionBlockEditor-xMJURnzF.js +2 -0
  12. package/dist/assets/{CompositionEditorPage-BdTBwrAp.js → CompositionEditorPage-C1X6QW6w.js} +1 -1
  13. package/dist/assets/{Data-DViGCVbI.js → Data-DjvjUZ88.js} +1 -1
  14. package/dist/assets/DeviceDetail-DkfzIA36.js +2 -0
  15. package/dist/assets/{Devices-baYBN34H.js → Devices-CRz_XyZv.js} +1 -1
  16. package/dist/assets/{EmbedDevicePage-l8wAVLqx.js → EmbedDevicePage-BA8S4eB2.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-DhwYDIti.js → EmbedPlayerPage-DwvtigtA.js} +1 -1
  18. package/dist/assets/{History-BBHnnwco.js → History-Bbh7GyuR.js} +1 -1
  19. package/dist/assets/{Identity-BqSMytgc.js → Identity-BTU7dHsy.js} +1 -1
  20. package/dist/assets/{InstancesTable-Dzt_ZD_8.js → InstancesTable-D0ePlG0O.js} +1 -1
  21. package/dist/assets/{IntegrationDetail-BlIntnkm.js → IntegrationDetail-CNpwj5mL.js} +1 -1
  22. package/dist/assets/{IntegrationWizard-CuTjXuIh.js → IntegrationWizard-y3tDHsc8.js} +1 -1
  23. package/dist/assets/{Integrations-DTo3e0AL.js → Integrations-2rOn7RrQ.js} +1 -1
  24. package/dist/assets/{Integrations-B5pGLzkU.js → Integrations-BghPCCUX.js} +1 -1
  25. package/dist/assets/{Library-W3VA0vMC.js → Library-Durt7-NC.js} +1 -1
  26. package/dist/assets/{Locations-BvL1S_Yx.js → Locations-DYIW2-f6.js} +1 -1
  27. package/dist/assets/{Logs-CI_K8DdA.js → Logs-D72sIrph.js} +1 -1
  28. package/dist/assets/{MaskShapeCanvas-0z0o1CmM.js → MaskShapeCanvas-BxTTlAfh.js} +1 -1
  29. package/dist/assets/{MotionZonesSettings-BghbU1K3.js → MotionZonesSettings-ieLDWpte.js} +1 -1
  30. package/dist/assets/{MyAccess-8KqkNTje.js → MyAccess-BQTBSq6K.js} +1 -1
  31. package/dist/assets/{Network-D8ZwZsNt.js → Network-CwqR0gPE.js} +1 -1
  32. package/dist/assets/{NodeAddonsSettingsPanel-CT6b4R4c.js → NodeAddonsSettingsPanel-CgMvgFAN.js} +2 -2
  33. package/dist/assets/Notifications-DmJTTHb2.js +1 -0
  34. package/dist/assets/{Pipeline-CjQ_g5Ra.js → Pipeline-K1nNCknb.js} +1 -1
  35. package/dist/assets/{PrivacyMaskSettings-Kz5m0O7l.js → PrivacyMaskSettings-BmYR9i5a.js} +1 -1
  36. package/dist/assets/{Recordings-CtwtOGPM.js → Recordings-DFhEOydB.js} +1 -1
  37. package/dist/assets/{RemoteGrid-Dyh0od5O.js → RemoteGrid-CnvWN_Q7.js} +1 -1
  38. package/dist/assets/{ScanSubnetEditor-CjpZhe61.js → ScanSubnetEditor-COYKrOUZ.js} +1 -1
  39. package/dist/assets/{SceneMonitorEditor-BjJyeBEk.js → SceneMonitorEditor-DeQ9ymYM.js} +1 -1
  40. package/dist/assets/{SessionsList-C9ogUSGk.js → SessionsList-CchnaZDu.js} +1 -1
  41. package/dist/assets/{Showroom-D32EhuTm.js → Showroom-y8XDooe0.js} +1 -1
  42. package/dist/assets/{StorageLocationsTable-C64-zmrX.js → StorageLocationsTable-CEuzgMli.js} +1 -1
  43. package/dist/assets/{System-Bd2XMdpV.js → System-B5rn1ItC.js} +1 -1
  44. package/dist/assets/{Templates-BcASnjcc.js → Templates-Bk06ZJwK.js} +1 -1
  45. package/dist/assets/{Terminal-CX_P3djl.js → Terminal-CrDf4D63.js} +1 -1
  46. package/dist/assets/{TrainingProviders-Bm8VXCkV.js → TrainingProviders-DtxFhEAZ.js} +1 -1
  47. package/dist/assets/{Viewer-i95FQfUb.js → Viewer-Dod1J2kQ.js} +1 -1
  48. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DdrXO22M.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Ck0PhSCH.js} +1 -1
  49. package/dist/assets/{action-draft-CLxOlN3v.js → action-draft-CbHoxLjI.js} +1 -1
  50. package/dist/assets/{ai-page.helpers-BceORsq5.js → ai-page.helpers-C6ls8wz_.js} +1 -1
  51. package/dist/assets/{assignment-candidates-DsHDR5YQ.js → assignment-candidates-DWPnaRvD.js} +1 -1
  52. package/dist/assets/{authed-media-dm4GdCKO.js → authed-media-DSqxjKn1.js} +1 -1
  53. package/dist/assets/{board-model-CpYPkmlj.js → board-model-BjCZ9N9K.js} +1 -1
  54. package/dist/assets/{client-DM5tcoga.js → client-DLGNlJDt.js} +5 -5
  55. package/dist/assets/{command-vocab-Ch6bCpeT.js → command-vocab-D-Mb5eIw.js} +1 -1
  56. package/dist/assets/create-composition-Ds7Ik4DO.js +1 -0
  57. package/dist/assets/{device-detail-DRsIQkC1.js → device-detail-D8-PST69.js} +1 -1
  58. package/dist/assets/{device-integration-icon-C1tT_gx2.js → device-integration-icon-CIwY5XXY.js} +1 -1
  59. package/dist/assets/device-picker-model-DBhTfKm0.js +1 -0
  60. package/dist/assets/dist-1yU8tcrp.js +1114 -0
  61. package/dist/assets/{dist-XnvNJt1-.js → dist-hKqDc_W9.js} +1 -1
  62. package/dist/assets/{format-DWAycAFG.js → format-B7kl8sLY.js} +1 -1
  63. package/dist/assets/{hostInit-HrqqiwVG.js → hostInit-De1tBXdJ.js} +1 -1
  64. package/dist/assets/i18n-CcjpDLHK.js +1 -0
  65. package/dist/assets/{icons-Bu52cGsB.js → icons-B6WiLi5J.js} +1 -1
  66. package/dist/assets/index-DgOWypvk.js +4 -0
  67. package/dist/assets/{linked-devices-model-m9SG2P2S.js → linked-devices-model-eYoI_73X.js} +1 -1
  68. package/dist/assets/{mf-entry-bootstrap-0-2685693c.js → mf-entry-bootstrap-0-959d6f36.js} +2 -2
  69. package/dist/assets/mount-DBhTfKm0.js +1 -0
  70. package/dist/assets/{notification-rule-status-BUGrM94L.js → notification-rule-status-DkXZfwuk.js} +1 -1
  71. package/dist/assets/{player-overlays-C92tUBpz.js → player-overlays-BMit2yun.js} +1 -1
  72. package/dist/assets/remoteEntry-DCzIPVEe.js +1 -0
  73. package/dist/assets/src-Dg912oqK.js +250 -0
  74. package/dist/assets/{step-inspector-model-jqHTs0N6.js → step-inspector-model-BmSCuJai.js} +1 -1
  75. package/dist/assets/{use-scenes-feed-FsHwLqsd.js → use-scenes-feed-DBj0OZCW.js} +1 -1
  76. package/dist/assets/{use-stationary-objects-XLHAhwbH.js → use-stationary-objects-DtRd8lhr.js} +1 -1
  77. package/dist/assets/{useAdminDeviceRemoval-CRnQv6Iu.js → useAdminDeviceRemoval-d9P0Cpza.js} +1 -1
  78. package/dist/assets/useEventInvalidation-DBhTfKm0.js +1 -0
  79. package/dist/assets/{useNodeUrlSelection-DB-QVsC2.js → useNodeUrlSelection-Cut66SbO.js} +1 -1
  80. package/dist/assets/useTemplateSave-CEcw08D0.js +1 -0
  81. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CC-TW8gU.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DAlkrz1F.js} +2 -2
  82. package/dist/index.html +7 -7
  83. package/dist/server/addon.js +14 -2
  84. package/package.json +2 -2
  85. package/dist/assets/Build-CtavtCki.js +0 -40
  86. package/dist/assets/CompositionBlockEditor-Dxq0Hk8x.js +0 -2
  87. package/dist/assets/DeviceDetail-BjIgUxeI.js +0 -2
  88. package/dist/assets/Notifications-CxA4JqZI.js +0 -1
  89. package/dist/assets/create-composition-C2bdkjGW.js +0 -1
  90. package/dist/assets/device-picker-model-DdNgdYpo.js +0 -1
  91. package/dist/assets/dist-xzDYmBSA.js +0 -1114
  92. package/dist/assets/i18n-CwgPYzYg.js +0 -1
  93. package/dist/assets/index-Wmx2JgTc.js +0 -4
  94. package/dist/assets/mount-DdNgdYpo.js +0 -1
  95. package/dist/assets/remoteEntry-DwE_0hKK.js +0 -1
  96. package/dist/assets/src-wYH5IrPO.js +0 -250
  97. package/dist/assets/useEventInvalidation-DdNgdYpo.js +0 -1
  98. package/dist/assets/useTemplateSave-CzAC1u4c.js +0 -1
@@ -1 +1 @@
1
- import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{An as l,Bn as u,Cr as d,D as f,Da as p,Er as m,Et as h,Hi as g,Kt as _,L as v,Pn as y,St as b,Tn as x,Xn as S,Yn as C,Yt as w,Z as T,cn as E,gi as D,gt as O,ii as k,or as A,pn as ee,ut as te,zn as ne}from"./player-overlays-C92tUBpz.js";import{hi as re,mi as ie,ni as ae,pi as j}from"./client-DM5tcoga.js";import{t as oe}from"./boxes-k5PsZ3NR.js";import{c as se,f as M,s as ce}from"./video-De6y5yax.js";import{Dc as le,Ec as ue,Hd as de,Hn as fe,Lo as pe,Mc as me,Mr as he,Nc as ge,Oc as _e,Pc as ve,Tc as ye,Vn as be,Wd as N,Wn as P,cc as xe,cf as F,ef as I,ei as Se,gc as Ce,hc as we,kc as Te,lc as Ee,lf as L,pc as De,sc as Oe,vc as ke,yc as Ae,zn as je}from"./src-wYH5IrPO.js";import{t as R}from"./i18n-CwgPYzYg.js";import{t as z}from"./useTranslation-BJr-n0es.js";import"./mount-DdNgdYpo.js";import{Jr as Me,Qr as Ne,a as B,i as V,qr as Pe,x as Fe}from"./index-Wmx2JgTc.js";import{t as Ie}from"./AdminSectionedPage-C_Xcom2n.js";import{t as H}from"./AdminPage-a5x3JamG.js";import{r as U,t as W}from"./InstancesTable-Dzt_ZD_8.js";import{t as Le}from"./useInvalidateAddonSettings-CyofQfBo.js";o();var Re=5e3,ze=`network-access`,Be={connected:!1,endpoint:null};function Ve(){let{t:e}=z(),t=s(),[n,i]=a(null),[o,c]=a({}),l=(e,n)=>{let r=n?.addonId;t.invalidateQueries({queryKey:[[`networkAccess`,`getStatus`],{input:{addonId:r},type:`query`}]}),i(null),c(e=>{if(r===void 0||!(r in e))return e;let t={...e};return delete t[r],t})},u=(e,t)=>{i(null);let n=t?.addonId;if(n===void 0)return;let r=e instanceof Error?e.message:String(e);c(e=>({...e,[n]:r}))},d=ge({onSuccess:l,onError:u}),f=ve({onSuccess:l,onError:u}),p={key:`tunnel`,header:e(`system.remoteAccess.colTunnel`,`Tunnel`),notSortableReason:e(`system.remoteAccess.tunnelNotSortable`,`A live connection state is not a value to order by.`),render:e=>r(He,{addonId:e.addonId,error:o[e.addonId]})},m=e=>r(Ue,{addonId:e,busyId:n,onStart:e=>{i(e),d.mutate({addonId:e})},onStop:e=>{i(e),f.mutate({addonId:e})}});return r(W,{functionCap:ze,icon:M,title:e(`system.remoteAccess.remoteAccess2`,`Remote Access`),subtitle:e(`system.remoteAccess.publicFacingTunnelsThatExpose`,`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …).`),emptyTitle:e(`system.remoteAccess.noRemoteAccessProvidersInstalled`,`No remote-access providers installed`),emptyDescription:e(`system.remoteAccess.installATunnelAddonE`,`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`),addLabel:e(`system.remoteAccess.addTunnel`,`Add tunnel`),extraColumns:[p],rowActions:e=>m(e.addonId),fixedRowActions:e=>m(e.addonId)})}function G(e){let{data:t}=me({addonId:e},{refetchInterval:Re,retry:!1}),n=t?ae.safeParse(t):null;return n?.success?n.data:Be}function He({addonId:t,error:n}){let{t:i}=z(),a=G(t);return e(`span`,{className:`flex flex-col items-start gap-1`,children:[r(N,{variant:a.connected?`success`:`default`,className:U,children:a.connected?i(`system.remoteAccess.connected`,`Connected`):i(`system.remoteAccess.disconnected`,`Disconnected`)}),a.endpoint&&e(`a`,{href:a.endpoint.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-w-0 items-center gap-1 break-all text-[11px] text-success hover:underline`,children:[r(k,{className:`h-3 w-3`}),a.endpoint.url]}),n!==void 0&&r(`span`,{role:`alert`,className:`text-xs text-danger`,children:n})]})}function Ue({addonId:e,busyId:t,onStart:n,onStop:i}){let{t:a}=z(),o=G(e),s=t===e;return o.connected?r(L,{icon:s?m:E,variant:`ghost`,size:`sm`,"aria-label":a(`system.remoteAccess.stop`,`Stop`),disabled:s,onClick:()=>i(e)}):r(L,{icon:s?m:S,variant:`ghost`,size:`sm`,"aria-label":a(`system.remoteAccess.start`,`Start`),disabled:s,onClick:()=>n(e)})}function We(){let{t:e}=z();return r(W,{functionCap:`turn-provider`,icon:A,title:e(`system.turnServers.turnServers`,`TURN Servers`),subtitle:e(`system.turnServers.iceServersUsedForWebrtc`,`ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.`),emptyTitle:e(`system.turnServers.noTurnProvidersInstalled`,`No TURN providers installed`),emptyDescription:e(`system.turnServers.installATurnAddonE`,`Install a TURN addon (e.g. @camstack/addon-cloudflare) to enable WebRTC behind restrictive NATs.`),addLabel:e(`system.turnServers.addProvider`,`Add provider`)})}o();var Ge={lan:A,wifi:h,docker:oe,vpn:d,loopback:l,other:l},Ke={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},qe=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function Je(n){let{t:i}=z(),{interfaces:a,disabled:o,hideLoopback:s,ipv4Only:c,emptyMessage:u}=n,d=t(()=>a.filter(e=>!(s&&e.kind===`loopback`||c&&e.family!==`IPv4`)),[a,s,c]),f=t(()=>{let e=new Map;for(let t of d){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return qe.filter(t=>e.has(t)).map(t=>({kind:t,items:e.get(t)}))},[d]),p=e=>n.mode===`single`?n.value===e:n.value.includes(e),m=e=>{if(o||e.kind===`loopback`)return;if(n.mode===`single`){n.onChange(n.value===e.address?null:e.address);return}let t=new Set(n.value);t.has(e.address)?t.delete(e.address):t.add(e.address),n.onChange([...t])};return d.length===0?r(`div`,{className:`text-xs text-foreground-subtle italic`,children:u??i(`shared.addressSelector.noAddressesAvailable`,`No addresses available.`)}):r(`div`,{className:`flex flex-col gap-3`,children:f.map(({kind:t,items:a})=>e(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[e(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[r(Ge[t]??l,{className:`h-3.5 w-3.5 text-foreground-subtle`}),r(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:Ke[t]??t}),e(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,a.length]})]}),r(`ul`,{className:`divide-y divide-border`,children:a.map(t=>{let a=p(t.address),s=t.kind===`loopback`,c=!t.plausible&&!s;return e(`li`,{className:`flex items-center gap-3 px-3 py-2 ${s?`opacity-60 cursor-not-allowed`:o?`opacity-60`:c?`cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]`:`cursor-pointer hover:bg-surface-hover/30`}`,onClick:()=>m(t),children:[r(`span`,{className:`flex items-center justify-center h-4 w-4 rounded ${n.mode===`single`?`rounded-full`:`rounded`} border ${a?`border-primary bg-primary text-primary-foreground`:`border-border bg-surface`}`,children:a&&r(g,{className:`h-3 w-3`})}),e(`div`,{className:`flex-1 min-w-0 ${c?`text-foreground-subtle`:``}`,children:[e(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[r(`span`,{className:`font-mono text-xs font-semibold ${c?`text-foreground-subtle`:`text-foreground`}`,children:t.name}),r(`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&&r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:i(`shared.addressSelector.autoPreferred`,`Auto-preferred`)}),s&&r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:i(`shared.addressSelector.alwaysIncluded`,`Always included`)}),c&&e(`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:[r(_,{className:`h-2.5 w-2.5`}),i(`shared.addressSelector.unlikelyUsable`,`Unlikely usable`)]})]}),e(`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))})}var K=[{role:`appConnections`,get title(){return R.t(`helpers.addressTableModel.appConnectionsTitle`)},single:!1,get help(){return R.t(`helpers.addressTableModel.appConnectionsHelp`)}},{role:`notificationTaps`,get title(){return R.t(`helpers.addressTableModel.notificationTapsTitle`)},single:!0,get help(){return R.t(`helpers.addressTableModel.notificationTapsHelp`)}},{role:`publicEndpoint`,get title(){return R.t(`helpers.addressTableModel.publicEndpointTitle`)},single:!0,get help(){return R.t(`helpers.addressTableModel.publicEndpointHelp`)}},{role:`internal`,get title(){return R.t(`helpers.addressTableModel.internalTitle`)},single:!0,get help(){return R.t(`helpers.addressTableModel.internalHelp`)}}],Ye=`A role with nothing ticked is automatic. Add a custom address when the hub is reached at an address it cannot see itself (NAT, reverse proxy, VPN, Docker bridge).`;function q(e,t){return e.inUse.includes(t)}function Xe(e,t){if(!e.eligible.includes(t))return{kind:`none`};if(e.kind===`app-link`)return q(e,t)?{kind:`none`}:{kind:`set`,input:{role:t,baseUrl:null,enabled:!0}};if(e.flags.includes(t)||t===`appConnections`&&q(e,t))return{kind:`set`,input:{role:t,baseUrl:e.baseUrl,enabled:!1}};let n={role:t,baseUrl:e.baseUrl,enabled:!0};return t===`publicEndpoint`&&e.baseUrl.startsWith(`http:`)?{kind:`confirm-http`,input:n,reason:ie}:{kind:`set`,input:n}}function Ze(e){return K.map(({role:t,title:n})=>{if(t===`appConnections`){let r=e.roles.appConnections;return{role:t,title:n,inUse:r.resolved.length===0?`nothing reachable`:r.resolved.join(`, `),automatic:r.source!==`flagged`}}let r=e.roles[t];return{role:t,title:n,inUse:r.resolved===null?`nothing reachable`:t===`notificationTaps`&&r.source===`auto`?`CamStack app link`:r.resolved,automatic:r.source!==`flagged`}})}o();var J={"lan-ipv4":{labelKey:`system.addressesCard.kindIpv4`,className:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`},"lan-ipv6":{labelKey:`system.addressesCard.kindIpv6`,className:`bg-violet-500/15 text-violet-700 dark:text-violet-300`},public:{labelKey:`system.addressesCard.kindPublic`,className:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},"app-link":{labelKey:`system.addressesCard.kindAppLink`,className:`bg-amber-500/15 text-amber-700 dark:text-amber-300`},custom:{labelKey:`system.addressesCard.kindCustom`,className:`bg-sky-500/15 text-sky-700 dark:text-sky-300`},loopback:{labelKey:`system.addressesCard.kindLoopback`,className:`bg-foreground-subtle/15 text-foreground-subtle`}};function Qe({book:t,loading:n,saving:i,error:o,onSetRole:s,onAdd:c,onRemove:l}){let{t:u}=z(),[d,f]=a(``),[m,h]=a(``),[g,v]=a(null),[y,b]=a(null),x=()=>{let e=re(d);if(!e.ok){v(e.reason);return}v(null),f(``),h(``),c(e.baseUrl,m.trim())},S=(e,t)=>{let n=Xe(e,t.role);if(n.kind!==`none`){if(n.kind===`confirm-http`){b({input:n.input,reason:n.reason});return}b(null),s(n.input)}},T=[{key:`url`,header:u(`system.addressesCard.address`,`Address`),render:n=>e(`div`,{className:`min-w-0 py-0.5`,children:[r(`div`,{className:`font-mono text-[12px] break-all ${n.plausible?`text-foreground`:`text-foreground-subtle`}`,children:n.baseUrl}),e(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[r(`span`,{children:n.label}),n.kind===`app-link`&&e(`span`,{className:`font-mono`,children:[`hub=`,` `,t?.appLinkHub??u(`system.addressesCard.noneNoTunnelOrTailscale`,`none (no tunnel or Tailscale)`)]}),n.custom&&n.detected&&r(`span`,{children:u(`system.addressesCard.alsoAddedAsACustom`,`also added as a custom address`)}),n.kind!==`custom`&&n.interfaceKind!==`lan`&&n.interfaceKind!==`public`&&n.interfaceKind!==`other`&&r(`span`,{className:`uppercase tracking-wide`,children:n.interfaceKind}),!n.plausible&&n.interfaceKind!==`loopback`&&e(`span`,{className:`inline-flex items-center gap-1 text-amber-700 dark:text-amber-300`,title:n.plausibleReason||void 0,children:[r(_,{className:`h-2.5 w-2.5`}),u(`system.addressesCard.unlikelyUsable`,`Unlikely usable`)]})]})]})},{key:`kind`,header:u(`system.addressesCard.kind`,`Kind`),nowrap:!0,render:e=>{let t=J[e.kind]??J.loopback;return r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.className}`,children:u(t.labelKey)})}},...K.map(t=>({key:t.role,headerRender:()=>r(`span`,{title:t.help,children:t.title}),align:`center`,nowrap:!0,width:`w-24`,render:n=>{let a=n.eligible.includes(t.role),o=n.flags.includes(t.role),s=q(n,t.role);return e(`label`,{className:`inline-flex items-center justify-center gap-1 ${a?`cursor-pointer`:`cursor-not-allowed opacity-40`}`,title:a?s&&!o?u(`system.addressesCard.inUseAutomatically`,`{{title}}: in use automatically. {{help}}`,{title:t.title,help:t.help}):t.help:u(`system.addressesCard.thisAddressCannotBeUsed`,`This address cannot be used for this.`),children:[r(p,{checked:a&&s,disabled:!a||i,onChange:()=>S(n,t),"aria-label":`${t.title}: ${n.baseUrl}`}),s&&!o&&a&&r(`span`,{className:`text-[9px] text-foreground-subtle`,children:u(`common.auto`)})]})}})),{key:`actions`,header:``,align:`right`,nowrap:!0,render:e=>e.custom?r(I,{size:`sm`,variant:`ghost`,disabled:i,onClick:()=>l(e.baseUrl),"aria-label":u(`system.addressesCard.remove`,`Remove {{baseUrl}}`,{baseUrl:e.baseUrl}),title:u(`system.addressesCard.removeThisCustomAddressIts`,`Remove this custom address (its roles turn automatic)`),children:r(w,{className:`h-3 w-3`})}):null}],E=t===void 0?[]:Ze(t);return e(Se,{children:[e(`div`,{className:`px-4 py-3 border-b border-border flex flex-col gap-2`,children:[e(`div`,{children:[r(`div`,{className:`text-sm font-semibold`,children:u(`system.addressesCard.addresses`,`Addresses`)}),r(`div`,{className:`text-xs text-foreground-subtle max-w-3xl`,children:u(`system.addressesCard.everyAddressThisHubIs`,`Every address this hub is reached at, detected or added by you. Tick what each one is used for.`)}),e(`details`,{className:`mt-1.5 text-xs max-w-3xl`,"data-testid":`address-roles-help`,children:[r(`summary`,{className:`cursor-pointer select-none text-foreground-subtle hover:text-foreground`,children:u(`system.addressesCard.whatAreRoles`,`What are roles?`)}),r(`dl`,{className:`mt-1.5 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1`,children:K.map(t=>e(`div`,{className:`contents`,children:[r(`dt`,{className:`font-medium`,children:t.title}),r(`dd`,{className:`text-foreground-subtle`,children:t.help})]},t.role))}),r(`p`,{className:`mt-1.5 text-foreground-subtle`,children:Ye})]})]}),E.length>0&&r(`div`,{className:`grid grid-cols-[auto_1fr_auto] gap-x-3 gap-y-1 items-baseline text-xs`,"data-testid":`address-roles-summary`,children:E.map(t=>e(`div`,{className:`contents`,children:[r(`span`,{className:`text-foreground-subtle`,children:t.title}),e(`span`,{className:`font-mono break-all`,"data-testid":`address-role-${t.role}`,children:[t.inUse,r(`span`,{className:`ml-1.5 font-sans text-foreground-subtle`,children:t.automatic?u(`system.addressesCard.automatic`,`(automatic)`):u(`system.addressesCard.setByYou`,`(set by you)`)})]}),t.automatic?r(`span`,{}):r(I,{size:`sm`,variant:`secondary`,disabled:i,onClick:()=>s({role:t.role,baseUrl:null,enabled:!1}),children:u(`system.addressesCard.useAutomatic`,`Use automatic`)})]},t.role))}),y!==null&&e(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs flex flex-wrap items-center gap-2`,children:[r(_,{className:`h-3.5 w-3.5 text-amber-600`}),r(`span`,{className:`flex-1 min-w-[220px]`,children:y.reason}),r(I,{size:`sm`,variant:`secondary`,onClick:()=>{s({...y.input,acceptInsecureHttp:!0}),b(null)},children:u(`system.addressesCard.useHttpAnyway`,`Use http anyway`)}),r(I,{size:`sm`,variant:`ghost`,onClick:()=>b(null),children:u(`common.cancel`,`Cancel`)})]}),o!==null&&r(`div`,{className:`text-[11px] text-red-600 dark:text-red-400`,role:`alert`,children:o})]}),r(P,{columns:T,rows:t?.rows??[],rowKey:e=>`${e.kind}-${e.baseUrl}`,minWidthPx:760,bordered:!1,emptyMessage:n?u(`common.loading`,`Loading…`):u(`system.addressesCard.noAddressesAvailable`,`No addresses available.`),rowClassName:e=>e.plausible?void 0:`opacity-80`}),e(`div`,{className:`px-4 py-3 border-t border-border flex flex-wrap items-start gap-2`,children:[e(`div`,{className:`flex-1 min-w-[220px]`,children:[r(F,{value:d,onChange:e=>{f(e.target.value),v(null)},placeholder:`https://cams.example.com or https://192.0.2.20:4443`,"aria-label":u(`system.addressesCard.customAddress`,`Custom address`),disabled:i}),g!==null&&r(`div`,{className:`mt-1 text-[11px] text-red-600 dark:text-red-400`,children:g})]}),r(`div`,{className:`w-48`,children:r(F,{value:m,onChange:e=>h(e.target.value),placeholder:u(`system.addressesCard.labelOptional`,`Label (optional)`),"aria-label":u(`system.addressesCard.customAddressLabel`,`Custom address label`),maxLength:80,disabled:i})}),e(I,{size:`sm`,variant:`secondary`,disabled:i||d.trim()===``,onClick:x,children:[r(C,{className:`h-3 w-3`}),u(`system.addressesCard.addCustomAddress`,`Add custom address`)]})]})]})}o();function $e(){let{t:n}=z(),o=s(),c=()=>{o.invalidateQueries({queryKey:[[`localNetwork`]]})},l=De(void 0,{refetchInterval:3e4}),d=Ee(void 0),p=Ae({onSuccess:c}),m=Ce({onSuccess:e=>{w(e.addresses),c()}}),h=t(()=>l.data?.interfaces??[],[l.data]),g=xe({scheme:typeof window<`u`&&window.location.protocol===`https:`?`https`:`http`},{refetchInterval:3e4}),_=ke({onSuccess:c}),v=Oe({onSuccess:c}),b=we({onSuccess:c}),x=_.error?.message??v.error?.message??b.error?.message??null,S=_.isPending||v.isPending||b.isPending,[C,w]=a([]),[T,E]=a(!1);i(()=>{!T&&d.data&&(w(d.data.addresses),E(!0))},[d.data,T]);let D=d.data?.addresses??[],O=t(()=>{if(C.length!==D.length)return!0;let e=[...C].toSorted(),t=[...D].toSorted();return e.some((e,n)=>e!==t[n])},[C,D]);return e(H,{embedded:!0,children:[e(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[r(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:n(`system.networkAddresses.pinWhichHostInterfacesExist`,`Pin which host interfaces exist, then tick what each address is used for. Add a custom address when this hub is reached at one it cannot detect.`)}),r(`div`,{className:`flex items-center gap-2 shrink-0`,children:e(I,{size:`sm`,variant:`secondary`,onClick:()=>{l.refetch(),d.refetch(),g.refetch()},disabled:l.isLoading,children:[r(u,{className:`h-3 w-3 ${l.isLoading?`animate-spin`:``}`}),n(`common.refresh`,`Refresh`)]})})]}),r(fe,{headingId:`network-allowed-addresses`,title:n(`system.networkAddresses.allowedAddresses`,`Allowed addresses`),actions:e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[e(I,{size:`sm`,variant:`secondary`,onClick:()=>m.mutate(void 0),disabled:m.isPending||p.isPending,title:n(`system.networkAddresses.reRunTheAutoDetection`,`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`),children:[r(ee,{className:`h-3 w-3`}),m.isPending?n(`system.networkAddresses.detecting`,`Detecting…`):n(`system.networkAddresses.bestMatch`,`Best match`)]}),e(I,{size:`sm`,variant:`secondary`,onClick:()=>{w([])},disabled:C.length===0||p.isPending,children:[r(ne,{className:`h-3 w-3`}),n(`system.networkAddresses.clear`,`Clear`)]}),O&&r(I,{size:`sm`,variant:`secondary`,onClick:()=>{w(D)},disabled:p.isPending,children:n(`system.networkAddresses.discard`,`Discard`)}),e(I,{size:`sm`,variant:`primary`,onClick:()=>{p.mutate({addresses:[...C]})},disabled:!O||p.isPending,children:[r(y,{className:`h-3 w-3`}),p.isPending?n(`system.networkAddresses.saving`,`Saving…`):n(`common.save`,`Save`)]})]}),children:e(`div`,{className:f,children:[r(`p`,{className:`mb-3 text-xs text-foreground-subtle`,children:C.length===0?n(`system.networkAddresses.autoEveryNonLoopbackNon`,`Auto — every non-loopback / non-link-local interface participates.`):n(`system.networkAddresses.pinned`,`{{value1}} pinned`,{value1:String(C.length)})}),r(Je,{mode:`multiple`,interfaces:h,value:C,onChange:w,disabled:p.isPending,emptyMessage:l.isLoading?n(`system.networkAddresses.loadingInterfaces`,`Loading interfaces…`):n(`system.networkAddresses.noInterfacesDetected`,`No interfaces detected.`)})]})}),r(Qe,{book:g.data,loading:g.isLoading,saving:S,error:x,onSetRole:e=>_.mutate({...e}),onAdd:(e,t)=>v.mutate({baseUrl:e,label:t}),onRemove:e=>b.mutate({baseUrl:e})})]})}var et=5e3,tt={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function Y(e){let{data:t,isLoading:n}=ye({addonId:e},{refetchInterval:et,retry:!1}),r=t?j.safeParse(t):null;return{status:r?.success?r.data:tt,isLoading:n}}function X({addonId:t}){let{t:n}=z(),{status:i}=Y(t);return e(`span`,{className:`flex flex-wrap items-center gap-1`,children:[r(N,{variant:i.joined?`success`:`default`,className:U,children:i.joined?n(`system.meshNetworks.joined`,`Joined`):n(`system.meshNetworks.notJoined`,`Not joined`)}),i.joined&&r(N,{className:`text-[10px]`,children:n(`common.peers`,{count:i.peerCount})}),i.error!==void 0&&r(N,{variant:`danger`,className:`text-[10px]`,title:i.error,children:n(`system.meshNetworks.error`,`Error`)})]})}o();function nt({addonId:t}){return e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(X,{addonId:t}),r(rt,{addonId:t})]})}function rt({addonId:t}){let{t:i}=z(),o=s(),[l,u]=a(!1),[d,f]=a(null),p=O(),{status:h}=Y(t),g=n(()=>{o.invalidateQueries({queryKey:[[`meshNetwork`]]})},[o]),_=Te(),v=ue({onSuccess:g}),y=_e({onSuccess:g}),S=n(async()=>{u(!0);let e={cancelled:!1};f(e);try{let n=await _.mutateAsync({addonId:t});if(e.cancelled)return;n.loginUrl&&window.open(n.loginUrl,`_blank`,`noopener,noreferrer`);let r=Date.now();for(;!e.cancelled&&(await it(2e3),!e.cancelled);){let e=await p.trpcClient.meshNetwork.getStatus.query({addonId:t}).catch(()=>null),n=e?j.safeParse(e):null;if(n?.success&&n.data.joined){g();break}if(Date.now()-r>6e5)break}}finally{u(!1),f(null)}},[t,g,_,p]),C=n(()=>{d&&(d.cancelled=!0),u(!1),f(null)},[d]);return r(c,{children:h.joined?e(c,{children:[e(I,{size:`sm`,variant:`secondary`,disabled:v.isPending,onClick:()=>v.mutate({addonId:t}),children:[v.isPending?r(m,{className:`h-3 w-3 animate-spin`}):r(ce,{className:`h-3 w-3`}),i(`system.meshNetworks.disconnect`,`Disconnect`)]}),e(I,{size:`sm`,variant:`ghost`,disabled:y.isPending,onClick:()=>y.mutate({addonId:t}),children:[y.isPending?r(m,{className:`h-3 w-3 animate-spin`}):r(x,{className:`h-3 w-3`}),i(`system.meshNetworks.logOut`,`Log out`)]})]}):l?e(I,{size:`sm`,variant:`ghost`,onClick:C,children:[r(b,{className:`h-3 w-3 mr-1`}),` `,i(`common.cancel`)]}):e(c,{children:[e(I,{size:`sm`,variant:`primary`,onClick:()=>void S(),children:[r(se,{className:`h-3 w-3`}),i(`system.meshNetworks.connect`,`Connect`)]}),e(I,{size:`sm`,variant:`ghost`,disabled:y.isPending,onClick:()=>y.mutate({addonId:t}),children:[y.isPending?r(m,{className:`h-3 w-3 animate-spin`}):r(x,{className:`h-3 w-3`}),i(`system.meshNetworks.logOut`,`Log out`)]})]})})}function it(e){return new Promise(t=>setTimeout(t,e))}o();var at={mesh:`bg-info/15 text-info`,public:`bg-primary/15 text-primary`},ot=3e4;function st({addonId:t}){let{t:n}=z(),{status:i}=Y(t),a=le({addonId:t},{refetchInterval:ot,retry:!1});return e(`div`,{className:`rounded-lg border border-border bg-surface`,children:[e(`div`,{className:`space-y-4 p-2 sm:p-4`,children:[i.error&&r(de,{message:i.error}),r(ct,{status:i}),i.endpoints.length>0&&e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:n(`system.meshNetworks.endpoints`,`Endpoints`)}),i.endpoints.map(t=>e(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[e(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${at[t.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[t.scope===`public`?r(M,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,t.label]}),e(`a`,{href:t.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-success hover:underline break-all flex items-center gap-1`,children:[r(k,{className:`h-3 w-3 shrink-0`}),t.url]})]},t.id))]})]}),r(`div`,{className:`border-t border-border`,children:r(ut,{peers:a.data?.peers??[],loading:a.isLoading})})]})}function ct({status:t}){let{t:n}=z();return r(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5`,children:[{label:n(`system.meshNetworks.tenant`,`Tenant`),value:t.tenantName||`—`},{label:n(`system.meshNetworks.user`,`User`),value:t.userLogin??`—`},{label:n(`system.meshNetworks.controlPlane`,`Control plane`),value:t.controlPlaneUrl||`—`},{label:n(`system.meshNetworks.meshIp`,`Mesh IP`),value:t.meshIp||`—`,mono:!0},{label:n(`system.meshNetworks.magicdns`,`MagicDNS`),value:t.magicDnsHostname||`—`,mono:!0},{label:n(`system.meshNetworks.dnsSuffix`,`DNS suffix`),value:t.magicDnsSuffix||`—`,mono:!0},{label:n(`system.meshNetworks.peers`,`Peers`),value:String(t.peerCount)},{label:n(`system.meshNetworks.keyExpiry`,`Key expiry`),value:t.keyExpiry?lt(t.keyExpiry):`—`}].map(t=>e(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[r(`span`,{className:`text-foreground-subtle shrink-0`,children:t.label}),r(`span`,{className:`text-foreground truncate ${t.mono?`font-mono`:``}`,children:t.value})]},t.label))})}function lt(e){let t=e-Date.now();if(t<0)return R.t(`system.meshNetworks.expiredAgo`,{when:Q(e)});let n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return R.t(`system.meshNetworks.expiryDays`,{count:n});let r=Math.floor(t/36e5);return r>1?R.t(`system.meshNetworks.expiryHours`,{count:r}):R.t(`system.meshNetworks.expiryMin`,{count:Math.max(1,Math.floor(t/6e4))})}function ut({peers:i,loading:a}){let{t:o}=z(),s=t(()=>i.map(e=>({...e,_id:e.id})),[i]),c=n(e=>{e&&navigator.clipboard?.writeText(e)},[]),l=t(()=>[{key:`hostname`,header:o(`system.meshNetworks.hostname`,`Hostname`),render:t=>e(`div`,{className:`flex flex-col`,children:[e(`div`,{className:`flex items-center gap-1.5`,children:[r(`span`,{className:`font-medium text-foreground`,children:t.hostname||o(`system.meshNetworks.unknown`,`(unknown)`)}),t.isSelf&&r(N,{variant:`info`,children:o(`common.self`)}),t.exitNodeOption&&r(N,{variant:`warning`,children:`exit-node`})]}),t.userLogin&&r(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:t.userLogin})]})},{key:`magicDns`,header:o(`system.meshNetworks.magicdns`,`MagicDNS`),render:t=>t.magicDns?e(`div`,{className:`flex items-center gap-1`,children:[r(`span`,{className:`font-mono text-xs truncate`,children:t.magicDns}),r(I,{variant:`unstyled`,onClick:()=>c(t.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":o(`system.meshNetworks.copyMagicdns`,`Copy MagicDNS`),children:r(D,{className:`h-3 w-3 text-foreground-subtle`})})]}):r(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:t=>{let n=t.addresses[0]??``;return n?e(`div`,{className:`flex items-center gap-1`,children:[r(`span`,{className:`font-mono text-xs`,children:n}),r(I,{variant:`unstyled`,onClick:()=>c(n),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":o(`system.meshNetworks.copyIp`,`Copy IP`),children:r(D,{className:`h-3 w-3 text-foreground-subtle`})})]}):r(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:o(`system.meshNetworks.connection`,`Connection`),render:t=>e(`div`,{className:`flex items-center gap-1.5`,children:[r(N,{variant:dt(t.connection),children:t.connection}),t.relay&&r(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:t.relay})]})},{key:`routes`,header:o(`system.meshNetworks.routes`,`Routes`),render:e=>e.advertisedRoutes.length>0?r(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):r(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:o(`system.meshNetworks.txRx`,`TX / RX`),render:t=>e(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,Z(t.txBytes),` · ↓ `,Z(t.rxBytes)]})},{key:`lastSeen`,header:o(`system.meshNetworks.lastSeen`,`Last seen`),render:e=>r(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?Q(e.lastSeenMs):`—`})}],[c,o]);return a&&i.length===0?e(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[r(m,{className:`h-3 w-3 animate-spin inline mr-1`}),` `,o(`systemPage.meshNetworks.loadingPeers`)]}):i.length===0?r(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:o(`system.meshNetworks.noPeersVisibleYourTailnet`,`No peers visible — your tailnet may be empty or the host is not joined.`)}):r(`div`,{className:`p-4`,children:r(P,{columns:l,rows:s,rowKey:e=>e._id,minWidthPx:820})})}function dt(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function Z(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 Q(e){let t=Date.now()-e;return t<6e4?R.t(`system.meshNetworks.justNow`):t<36e5?R.t(`system.meshNetworks.agoMin`,{count:Math.round(t/6e4)}):t<864e5?R.t(`system.meshNetworks.agoHour`,{count:Math.round(t/36e5)}):R.t(`system.meshNetworks.agoDay`,{count:Math.round(t/864e5)})}var $=`mesh-network`;function ft(){let{t}=z();return r(W,{functionCap:$,icon:A,title:t(`system.meshNetworks.meshNetworks2`,`Mesh Networks`),subtitle:t(`system.meshNetworks.privateVpnMeshesThatConnect`,`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).`),emptyTitle:t(`system.meshNetworks.noMeshNetworkProvidersInstalled`,`No mesh-network providers installed`),emptyDescription:t(`system.meshNetworks.installAMeshAddonE`,`Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.`),addLabel:t(`system.meshNetworks.addMesh`,`Add mesh`),install:{capability:$,label:t(`system.meshNetworks.addMesh`,`Add mesh`)},extraColumns:[{key:`mesh-state`,header:t(`system.meshNetworks.connectionState`,`Mesh`),notSortableReason:t(`system.meshNetworks.connectionStateNotSortable`,`Live state of the tailnet, not a stored value.`),render:e=>r(X,{addonId:e.addonId})}],lead:t=>e(`div`,{className:`flex flex-col gap-3`,children:[r(nt,{addonId:t.addonId}),r(st,{addonId:t.addonId})]})})}var pt=`/system/identity?tab=certificates`;function mt(){let{t}=z(),n=O(),i=Le();return r(H,{embedded:!0,children:e(`div`,{className:v,children:[r(`p`,{className:`text-xs text-foreground-subtle`,children:t(`system.localAccess.nativeAppsOnThisWi`,`Native apps on this Wi-Fi use http:// and skip the private certificate. The tunnel and this admin UI stay on HTTPS.`)}),r(he,{trpc:n.trpcClient,addonId:`local-network`,cap:`local-network`,scope:`node`,nodeId:`hub`,onAfterChange:i,title:t(`system.localAccess.lanHttp`,`LAN HTTP`)}),e(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`https-certificate-hint`,children:[t(`system.localAccess.certificateMoved`,`The HTTPS certificate and the local CA are managed under`),` `,r(Pe,{className:`underline`,to:pt,children:t(`system.localAccess.certificateMovedLink`,`Identity → Certificates`)}),`.`]})]})})}o();function ht({value:n,onChange:i}){let{t:a}=z(),{data:o}=pe({isCamera:!0,projection:`slim`}),s=t(()=>o===void 0?[{value:``,label:a(`system.networkDiagnostics.loadingCameras`,`Loading cameras…`)}]:o.length===0?[{value:``,label:a(`system.networkDiagnostics.noCameras`,`No cameras`)}]:[{value:``,label:a(`system.networkDiagnostics.pickACamera`,`Pick a camera`)},...o.toSorted((e,t)=>e.name.localeCompare(t.name)).map(e=>({value:String(e.id),label:`${e.name} (#${String(e.id)})`}))],[o,a]);return e(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[r(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`system.networkDiagnostics.camera`,`Camera`)}),r(te,{value:n===null?``:String(n),disabled:o===void 0||o.length===0,onChange:e=>i(e.target.value===``?null:Number(e.target.value)),options:s})]})}function gt(){let t=O(),[i,o]=a(null);return r(H,{embedded:!0,children:e(`div`,{className:v,"data-testid":`network-diagnostics`,children:[r(be,{loadServers:n(async()=>t.trpcClient.turnProvider.getTurnServers.query(),[t])}),r(je,{trpc:t.trpcClient,serverUrl:T(),deviceId:i,cameraField:r(ht,{value:i,onChange:o})})]})})}var _t=[`certificate`,`certificates`,`https`];function vt(){let{t:e}=z(),[t]=Ne();if(_t.includes(t.get(`tab`)??``))return r(Me,{to:pt,replace:!0});let n=Fe(`/system/network`,{t:e,isAdmin:!0})??{icon:M,title:e(`system.network`,`Network`)};return r(Ie,{icon:n.icon,title:n.title,defaultSection:`addresses`,sectionsLabel:`${n.title} sections`,sections:[{id:`local-access`,label:e(`systemPage.network.localAccess`,`Local access`),content:r(mt,{})},{id:`addresses`,label:e(`systemPage.network.networkAddresses`,`Network Addresses`),content:r($e,{})},{id:B.remoteAccess.tab,label:e(`systemPage.network.remoteAccess`,`Remote Access`),content:r(Ve,{}),ownedParams:V},{id:B.mesh.tab,label:e(`systemPage.network.meshNetworks`,`Mesh Networks`),content:r(ft,{}),ownedParams:V},{id:B.turn.tab,label:e(`systemPage.network.turnServers`,`TURN Servers`),content:r(We,{}),ownedParams:V},{id:`diagnostics`,label:e(`systemPage.network.diagnostics`,`Diagnostics`),content:r(gt,{})}]})}export{vt as NetworkPage};
1
+ import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{An as l,Bn as u,Cr as d,D as f,Da as p,Er as m,Et as h,Hi as g,Kt as _,L as v,Pn as y,St as b,Tn as x,Xn as S,Yn as C,Yt as w,Z as T,cn as E,gi as D,gt as O,ii as k,or as A,pn as ee,ut as te,zn as ne}from"./player-overlays-BMit2yun.js";import{gi as re,hi as ie,mi as j,ri as ae}from"./client-DLGNlJDt.js";import{t as oe}from"./boxes-k5PsZ3NR.js";import{c as se,f as M,s as ce}from"./video-De6y5yax.js";import{Dc as le,Ec as ue,Hd as de,Hn as fe,Lo as pe,Mc as me,Mr as he,Nc as ge,Oc as _e,Pc as ve,Tc as ye,Vn as be,Wd as N,Wn as P,cc as xe,cf as F,ef as I,ei as Se,gc as Ce,hc as we,kc as Te,lc as Ee,lf as L,pc as De,sc as Oe,vc as ke,yc as Ae,zn as je}from"./src-Dg912oqK.js";import{t as R}from"./i18n-CcjpDLHK.js";import{t as z}from"./useTranslation-BJr-n0es.js";import"./mount-DBhTfKm0.js";import{Jr as Me,Qr as Ne,a as B,i as V,qr as Pe,x as Fe}from"./index-DgOWypvk.js";import{t as Ie}from"./AdminSectionedPage-D00S68ny.js";import{t as H}from"./AdminPage-tWFzmkA7.js";import{r as U,t as W}from"./InstancesTable-D0ePlG0O.js";import{t as Le}from"./useInvalidateAddonSettings-CyofQfBo.js";o();var Re=5e3,ze=`network-access`,Be={connected:!1,endpoint:null};function Ve(){let{t:e}=z(),t=s(),[n,i]=a(null),[o,c]=a({}),l=(e,n)=>{let r=n?.addonId;t.invalidateQueries({queryKey:[[`networkAccess`,`getStatus`],{input:{addonId:r},type:`query`}]}),i(null),c(e=>{if(r===void 0||!(r in e))return e;let t={...e};return delete t[r],t})},u=(e,t)=>{i(null);let n=t?.addonId;if(n===void 0)return;let r=e instanceof Error?e.message:String(e);c(e=>({...e,[n]:r}))},d=ge({onSuccess:l,onError:u}),f=ve({onSuccess:l,onError:u}),p={key:`tunnel`,header:e(`system.remoteAccess.colTunnel`,`Tunnel`),notSortableReason:e(`system.remoteAccess.tunnelNotSortable`,`A live connection state is not a value to order by.`),render:e=>r(He,{addonId:e.addonId,error:o[e.addonId]})},m=e=>r(Ue,{addonId:e,busyId:n,onStart:e=>{i(e),d.mutate({addonId:e})},onStop:e=>{i(e),f.mutate({addonId:e})}});return r(W,{functionCap:ze,icon:M,title:e(`system.remoteAccess.remoteAccess2`,`Remote Access`),subtitle:e(`system.remoteAccess.publicFacingTunnelsThatExpose`,`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …).`),emptyTitle:e(`system.remoteAccess.noRemoteAccessProvidersInstalled`,`No remote-access providers installed`),emptyDescription:e(`system.remoteAccess.installATunnelAddonE`,`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`),addLabel:e(`system.remoteAccess.addTunnel`,`Add tunnel`),extraColumns:[p],rowActions:e=>m(e.addonId),fixedRowActions:e=>m(e.addonId)})}function G(e){let{data:t}=me({addonId:e},{refetchInterval:Re,retry:!1}),n=t?ae.safeParse(t):null;return n?.success?n.data:Be}function He({addonId:t,error:n}){let{t:i}=z(),a=G(t);return e(`span`,{className:`flex flex-col items-start gap-1`,children:[r(N,{variant:a.connected?`success`:`default`,className:U,children:a.connected?i(`system.remoteAccess.connected`,`Connected`):i(`system.remoteAccess.disconnected`,`Disconnected`)}),a.endpoint&&e(`a`,{href:a.endpoint.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-w-0 items-center gap-1 break-all text-[11px] text-success hover:underline`,children:[r(k,{className:`h-3 w-3`}),a.endpoint.url]}),n!==void 0&&r(`span`,{role:`alert`,className:`text-xs text-danger`,children:n})]})}function Ue({addonId:e,busyId:t,onStart:n,onStop:i}){let{t:a}=z(),o=G(e),s=t===e;return o.connected?r(L,{icon:s?m:E,variant:`ghost`,size:`sm`,"aria-label":a(`system.remoteAccess.stop`,`Stop`),disabled:s,onClick:()=>i(e)}):r(L,{icon:s?m:S,variant:`ghost`,size:`sm`,"aria-label":a(`system.remoteAccess.start`,`Start`),disabled:s,onClick:()=>n(e)})}function We(){let{t:e}=z();return r(W,{functionCap:`turn-provider`,icon:A,title:e(`system.turnServers.turnServers`,`TURN Servers`),subtitle:e(`system.turnServers.iceServersUsedForWebrtc`,`ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.`),emptyTitle:e(`system.turnServers.noTurnProvidersInstalled`,`No TURN providers installed`),emptyDescription:e(`system.turnServers.installATurnAddonE`,`Install a TURN addon (e.g. @camstack/addon-cloudflare) to enable WebRTC behind restrictive NATs.`),addLabel:e(`system.turnServers.addProvider`,`Add provider`)})}o();var Ge={lan:A,wifi:h,docker:oe,vpn:d,loopback:l,other:l},Ke={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},qe=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function Je(n){let{t:i}=z(),{interfaces:a,disabled:o,hideLoopback:s,ipv4Only:c,emptyMessage:u}=n,d=t(()=>a.filter(e=>!(s&&e.kind===`loopback`||c&&e.family!==`IPv4`)),[a,s,c]),f=t(()=>{let e=new Map;for(let t of d){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return qe.filter(t=>e.has(t)).map(t=>({kind:t,items:e.get(t)}))},[d]),p=e=>n.mode===`single`?n.value===e:n.value.includes(e),m=e=>{if(o||e.kind===`loopback`)return;if(n.mode===`single`){n.onChange(n.value===e.address?null:e.address);return}let t=new Set(n.value);t.has(e.address)?t.delete(e.address):t.add(e.address),n.onChange([...t])};return d.length===0?r(`div`,{className:`text-xs text-foreground-subtle italic`,children:u??i(`shared.addressSelector.noAddressesAvailable`,`No addresses available.`)}):r(`div`,{className:`flex flex-col gap-3`,children:f.map(({kind:t,items:a})=>e(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[e(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[r(Ge[t]??l,{className:`h-3.5 w-3.5 text-foreground-subtle`}),r(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:Ke[t]??t}),e(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,a.length]})]}),r(`ul`,{className:`divide-y divide-border`,children:a.map(t=>{let a=p(t.address),s=t.kind===`loopback`,c=!t.plausible&&!s;return e(`li`,{className:`flex items-center gap-3 px-3 py-2 ${s?`opacity-60 cursor-not-allowed`:o?`opacity-60`:c?`cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]`:`cursor-pointer hover:bg-surface-hover/30`}`,onClick:()=>m(t),children:[r(`span`,{className:`flex items-center justify-center h-4 w-4 rounded ${n.mode===`single`?`rounded-full`:`rounded`} border ${a?`border-primary bg-primary text-primary-foreground`:`border-border bg-surface`}`,children:a&&r(g,{className:`h-3 w-3`})}),e(`div`,{className:`flex-1 min-w-0 ${c?`text-foreground-subtle`:``}`,children:[e(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[r(`span`,{className:`font-mono text-xs font-semibold ${c?`text-foreground-subtle`:`text-foreground`}`,children:t.name}),r(`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&&r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:i(`shared.addressSelector.autoPreferred`,`Auto-preferred`)}),s&&r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:i(`shared.addressSelector.alwaysIncluded`,`Always included`)}),c&&e(`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:[r(_,{className:`h-2.5 w-2.5`}),i(`shared.addressSelector.unlikelyUsable`,`Unlikely usable`)]})]}),e(`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))})}var K=[{role:`appConnections`,get title(){return R.t(`helpers.addressTableModel.appConnectionsTitle`)},single:!1,get help(){return R.t(`helpers.addressTableModel.appConnectionsHelp`)}},{role:`notificationTaps`,get title(){return R.t(`helpers.addressTableModel.notificationTapsTitle`)},single:!0,get help(){return R.t(`helpers.addressTableModel.notificationTapsHelp`)}},{role:`publicEndpoint`,get title(){return R.t(`helpers.addressTableModel.publicEndpointTitle`)},single:!0,get help(){return R.t(`helpers.addressTableModel.publicEndpointHelp`)}},{role:`internal`,get title(){return R.t(`helpers.addressTableModel.internalTitle`)},single:!0,get help(){return R.t(`helpers.addressTableModel.internalHelp`)}}],Ye=`A role with nothing ticked is automatic. Add a custom address when the hub is reached at an address it cannot see itself (NAT, reverse proxy, VPN, Docker bridge).`;function q(e,t){return e.inUse.includes(t)}function Xe(e,t){if(!e.eligible.includes(t))return{kind:`none`};if(e.kind===`app-link`)return q(e,t)?{kind:`none`}:{kind:`set`,input:{role:t,baseUrl:null,enabled:!0}};if(e.flags.includes(t)||t===`appConnections`&&q(e,t))return{kind:`set`,input:{role:t,baseUrl:e.baseUrl,enabled:!1}};let n={role:t,baseUrl:e.baseUrl,enabled:!0};return t===`publicEndpoint`&&e.baseUrl.startsWith(`http:`)?{kind:`confirm-http`,input:n,reason:ie}:{kind:`set`,input:n}}function Ze(e){return K.map(({role:t,title:n})=>{if(t===`appConnections`){let r=e.roles.appConnections;return{role:t,title:n,inUse:r.resolved.length===0?`nothing reachable`:r.resolved.join(`, `),automatic:r.source!==`flagged`}}let r=e.roles[t];return{role:t,title:n,inUse:r.resolved===null?`nothing reachable`:t===`notificationTaps`&&r.source===`auto`?`CamStack app link`:r.resolved,automatic:r.source!==`flagged`}})}o();var J={"lan-ipv4":{labelKey:`system.addressesCard.kindIpv4`,className:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`},"lan-ipv6":{labelKey:`system.addressesCard.kindIpv6`,className:`bg-violet-500/15 text-violet-700 dark:text-violet-300`},public:{labelKey:`system.addressesCard.kindPublic`,className:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},"app-link":{labelKey:`system.addressesCard.kindAppLink`,className:`bg-amber-500/15 text-amber-700 dark:text-amber-300`},custom:{labelKey:`system.addressesCard.kindCustom`,className:`bg-sky-500/15 text-sky-700 dark:text-sky-300`},loopback:{labelKey:`system.addressesCard.kindLoopback`,className:`bg-foreground-subtle/15 text-foreground-subtle`}};function Qe({book:t,loading:n,saving:i,error:o,onSetRole:s,onAdd:c,onRemove:l}){let{t:u}=z(),[d,f]=a(``),[m,h]=a(``),[g,v]=a(null),[y,b]=a(null),x=()=>{let e=re(d);if(!e.ok){v(e.reason);return}v(null),f(``),h(``),c(e.baseUrl,m.trim())},S=(e,t)=>{let n=Xe(e,t.role);if(n.kind!==`none`){if(n.kind===`confirm-http`){b({input:n.input,reason:n.reason});return}b(null),s(n.input)}},T=[{key:`url`,header:u(`system.addressesCard.address`,`Address`),render:n=>e(`div`,{className:`min-w-0 py-0.5`,children:[r(`div`,{className:`font-mono text-[12px] break-all ${n.plausible?`text-foreground`:`text-foreground-subtle`}`,children:n.baseUrl}),e(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[r(`span`,{children:n.label}),n.kind===`app-link`&&e(`span`,{className:`font-mono`,children:[`hub=`,` `,t?.appLinkHub??u(`system.addressesCard.noneNoTunnelOrTailscale`,`none (no tunnel or Tailscale)`)]}),n.custom&&n.detected&&r(`span`,{children:u(`system.addressesCard.alsoAddedAsACustom`,`also added as a custom address`)}),n.kind!==`custom`&&n.interfaceKind!==`lan`&&n.interfaceKind!==`public`&&n.interfaceKind!==`other`&&r(`span`,{className:`uppercase tracking-wide`,children:n.interfaceKind}),!n.plausible&&n.interfaceKind!==`loopback`&&e(`span`,{className:`inline-flex items-center gap-1 text-amber-700 dark:text-amber-300`,title:n.plausibleReason||void 0,children:[r(_,{className:`h-2.5 w-2.5`}),u(`system.addressesCard.unlikelyUsable`,`Unlikely usable`)]})]})]})},{key:`kind`,header:u(`system.addressesCard.kind`,`Kind`),nowrap:!0,render:e=>{let t=J[e.kind]??J.loopback;return r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.className}`,children:u(t.labelKey)})}},...K.map(t=>({key:t.role,headerRender:()=>r(`span`,{title:t.help,children:t.title}),align:`center`,nowrap:!0,width:`w-24`,render:n=>{let a=n.eligible.includes(t.role),o=n.flags.includes(t.role),s=q(n,t.role);return e(`label`,{className:`inline-flex items-center justify-center gap-1 ${a?`cursor-pointer`:`cursor-not-allowed opacity-40`}`,title:a?s&&!o?u(`system.addressesCard.inUseAutomatically`,`{{title}}: in use automatically. {{help}}`,{title:t.title,help:t.help}):t.help:u(`system.addressesCard.thisAddressCannotBeUsed`,`This address cannot be used for this.`),children:[r(p,{checked:a&&s,disabled:!a||i,onChange:()=>S(n,t),"aria-label":`${t.title}: ${n.baseUrl}`}),s&&!o&&a&&r(`span`,{className:`text-[9px] text-foreground-subtle`,children:u(`common.auto`)})]})}})),{key:`actions`,header:``,align:`right`,nowrap:!0,render:e=>e.custom?r(I,{size:`sm`,variant:`ghost`,disabled:i,onClick:()=>l(e.baseUrl),"aria-label":u(`system.addressesCard.remove`,`Remove {{baseUrl}}`,{baseUrl:e.baseUrl}),title:u(`system.addressesCard.removeThisCustomAddressIts`,`Remove this custom address (its roles turn automatic)`),children:r(w,{className:`h-3 w-3`})}):null}],E=t===void 0?[]:Ze(t);return e(Se,{children:[e(`div`,{className:`px-4 py-3 border-b border-border flex flex-col gap-2`,children:[e(`div`,{children:[r(`div`,{className:`text-sm font-semibold`,children:u(`system.addressesCard.addresses`,`Addresses`)}),r(`div`,{className:`text-xs text-foreground-subtle max-w-3xl`,children:u(`system.addressesCard.everyAddressThisHubIs`,`Every address this hub is reached at, detected or added by you. Tick what each one is used for.`)}),e(`details`,{className:`mt-1.5 text-xs max-w-3xl`,"data-testid":`address-roles-help`,children:[r(`summary`,{className:`cursor-pointer select-none text-foreground-subtle hover:text-foreground`,children:u(`system.addressesCard.whatAreRoles`,`What are roles?`)}),r(`dl`,{className:`mt-1.5 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1`,children:K.map(t=>e(`div`,{className:`contents`,children:[r(`dt`,{className:`font-medium`,children:t.title}),r(`dd`,{className:`text-foreground-subtle`,children:t.help})]},t.role))}),r(`p`,{className:`mt-1.5 text-foreground-subtle`,children:Ye})]})]}),E.length>0&&r(`div`,{className:`grid grid-cols-[auto_1fr_auto] gap-x-3 gap-y-1 items-baseline text-xs`,"data-testid":`address-roles-summary`,children:E.map(t=>e(`div`,{className:`contents`,children:[r(`span`,{className:`text-foreground-subtle`,children:t.title}),e(`span`,{className:`font-mono break-all`,"data-testid":`address-role-${t.role}`,children:[t.inUse,r(`span`,{className:`ml-1.5 font-sans text-foreground-subtle`,children:t.automatic?u(`system.addressesCard.automatic`,`(automatic)`):u(`system.addressesCard.setByYou`,`(set by you)`)})]}),t.automatic?r(`span`,{}):r(I,{size:`sm`,variant:`secondary`,disabled:i,onClick:()=>s({role:t.role,baseUrl:null,enabled:!1}),children:u(`system.addressesCard.useAutomatic`,`Use automatic`)})]},t.role))}),y!==null&&e(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs flex flex-wrap items-center gap-2`,children:[r(_,{className:`h-3.5 w-3.5 text-amber-600`}),r(`span`,{className:`flex-1 min-w-[220px]`,children:y.reason}),r(I,{size:`sm`,variant:`secondary`,onClick:()=>{s({...y.input,acceptInsecureHttp:!0}),b(null)},children:u(`system.addressesCard.useHttpAnyway`,`Use http anyway`)}),r(I,{size:`sm`,variant:`ghost`,onClick:()=>b(null),children:u(`common.cancel`,`Cancel`)})]}),o!==null&&r(`div`,{className:`text-[11px] text-red-600 dark:text-red-400`,role:`alert`,children:o})]}),r(P,{columns:T,rows:t?.rows??[],rowKey:e=>`${e.kind}-${e.baseUrl}`,minWidthPx:760,bordered:!1,emptyMessage:n?u(`common.loading`,`Loading…`):u(`system.addressesCard.noAddressesAvailable`,`No addresses available.`),rowClassName:e=>e.plausible?void 0:`opacity-80`}),e(`div`,{className:`px-4 py-3 border-t border-border flex flex-wrap items-start gap-2`,children:[e(`div`,{className:`flex-1 min-w-[220px]`,children:[r(F,{value:d,onChange:e=>{f(e.target.value),v(null)},placeholder:`https://cams.example.com or https://192.0.2.20:4443`,"aria-label":u(`system.addressesCard.customAddress`,`Custom address`),disabled:i}),g!==null&&r(`div`,{className:`mt-1 text-[11px] text-red-600 dark:text-red-400`,children:g})]}),r(`div`,{className:`w-48`,children:r(F,{value:m,onChange:e=>h(e.target.value),placeholder:u(`system.addressesCard.labelOptional`,`Label (optional)`),"aria-label":u(`system.addressesCard.customAddressLabel`,`Custom address label`),maxLength:80,disabled:i})}),e(I,{size:`sm`,variant:`secondary`,disabled:i||d.trim()===``,onClick:x,children:[r(C,{className:`h-3 w-3`}),u(`system.addressesCard.addCustomAddress`,`Add custom address`)]})]})]})}o();function $e(){let{t:n}=z(),o=s(),c=()=>{o.invalidateQueries({queryKey:[[`localNetwork`]]})},l=De(void 0,{refetchInterval:3e4}),d=Ee(void 0),p=Ae({onSuccess:c}),m=Ce({onSuccess:e=>{w(e.addresses),c()}}),h=t(()=>l.data?.interfaces??[],[l.data]),g=xe({scheme:typeof window<`u`&&window.location.protocol===`https:`?`https`:`http`},{refetchInterval:3e4}),_=ke({onSuccess:c}),v=Oe({onSuccess:c}),b=we({onSuccess:c}),x=_.error?.message??v.error?.message??b.error?.message??null,S=_.isPending||v.isPending||b.isPending,[C,w]=a([]),[T,E]=a(!1);i(()=>{!T&&d.data&&(w(d.data.addresses),E(!0))},[d.data,T]);let D=d.data?.addresses??[],O=t(()=>{if(C.length!==D.length)return!0;let e=[...C].toSorted(),t=[...D].toSorted();return e.some((e,n)=>e!==t[n])},[C,D]);return e(H,{embedded:!0,children:[e(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[r(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:n(`system.networkAddresses.pinWhichHostInterfacesExist`,`Pin which host interfaces exist, then tick what each address is used for. Add a custom address when this hub is reached at one it cannot detect.`)}),r(`div`,{className:`flex items-center gap-2 shrink-0`,children:e(I,{size:`sm`,variant:`secondary`,onClick:()=>{l.refetch(),d.refetch(),g.refetch()},disabled:l.isLoading,children:[r(u,{className:`h-3 w-3 ${l.isLoading?`animate-spin`:``}`}),n(`common.refresh`,`Refresh`)]})})]}),r(fe,{headingId:`network-allowed-addresses`,title:n(`system.networkAddresses.allowedAddresses`,`Allowed addresses`),actions:e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[e(I,{size:`sm`,variant:`secondary`,onClick:()=>m.mutate(void 0),disabled:m.isPending||p.isPending,title:n(`system.networkAddresses.reRunTheAutoDetection`,`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`),children:[r(ee,{className:`h-3 w-3`}),m.isPending?n(`system.networkAddresses.detecting`,`Detecting…`):n(`system.networkAddresses.bestMatch`,`Best match`)]}),e(I,{size:`sm`,variant:`secondary`,onClick:()=>{w([])},disabled:C.length===0||p.isPending,children:[r(ne,{className:`h-3 w-3`}),n(`system.networkAddresses.clear`,`Clear`)]}),O&&r(I,{size:`sm`,variant:`secondary`,onClick:()=>{w(D)},disabled:p.isPending,children:n(`system.networkAddresses.discard`,`Discard`)}),e(I,{size:`sm`,variant:`primary`,onClick:()=>{p.mutate({addresses:[...C]})},disabled:!O||p.isPending,children:[r(y,{className:`h-3 w-3`}),p.isPending?n(`system.networkAddresses.saving`,`Saving…`):n(`common.save`,`Save`)]})]}),children:e(`div`,{className:f,children:[r(`p`,{className:`mb-3 text-xs text-foreground-subtle`,children:C.length===0?n(`system.networkAddresses.autoEveryNonLoopbackNon`,`Auto — every non-loopback / non-link-local interface participates.`):n(`system.networkAddresses.pinned`,`{{value1}} pinned`,{value1:String(C.length)})}),r(Je,{mode:`multiple`,interfaces:h,value:C,onChange:w,disabled:p.isPending,emptyMessage:l.isLoading?n(`system.networkAddresses.loadingInterfaces`,`Loading interfaces…`):n(`system.networkAddresses.noInterfacesDetected`,`No interfaces detected.`)})]})}),r(Qe,{book:g.data,loading:g.isLoading,saving:S,error:x,onSetRole:e=>_.mutate({...e}),onAdd:(e,t)=>v.mutate({baseUrl:e,label:t}),onRemove:e=>b.mutate({baseUrl:e})})]})}var et=5e3,tt={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function Y(e){let{data:t,isLoading:n}=ye({addonId:e},{refetchInterval:et,retry:!1}),r=t?j.safeParse(t):null;return{status:r?.success?r.data:tt,isLoading:n}}function X({addonId:t}){let{t:n}=z(),{status:i}=Y(t);return e(`span`,{className:`flex flex-wrap items-center gap-1`,children:[r(N,{variant:i.joined?`success`:`default`,className:U,children:i.joined?n(`system.meshNetworks.joined`,`Joined`):n(`system.meshNetworks.notJoined`,`Not joined`)}),i.joined&&r(N,{className:`text-[10px]`,children:n(`common.peers`,{count:i.peerCount})}),i.error!==void 0&&r(N,{variant:`danger`,className:`text-[10px]`,title:i.error,children:n(`system.meshNetworks.error`,`Error`)})]})}o();function nt({addonId:t}){return e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(X,{addonId:t}),r(rt,{addonId:t})]})}function rt({addonId:t}){let{t:i}=z(),o=s(),[l,u]=a(!1),[d,f]=a(null),p=O(),{status:h}=Y(t),g=n(()=>{o.invalidateQueries({queryKey:[[`meshNetwork`]]})},[o]),_=Te(),v=ue({onSuccess:g}),y=_e({onSuccess:g}),S=n(async()=>{u(!0);let e={cancelled:!1};f(e);try{let n=await _.mutateAsync({addonId:t});if(e.cancelled)return;n.loginUrl&&window.open(n.loginUrl,`_blank`,`noopener,noreferrer`);let r=Date.now();for(;!e.cancelled&&(await it(2e3),!e.cancelled);){let e=await p.trpcClient.meshNetwork.getStatus.query({addonId:t}).catch(()=>null),n=e?j.safeParse(e):null;if(n?.success&&n.data.joined){g();break}if(Date.now()-r>6e5)break}}finally{u(!1),f(null)}},[t,g,_,p]),C=n(()=>{d&&(d.cancelled=!0),u(!1),f(null)},[d]);return r(c,{children:h.joined?e(c,{children:[e(I,{size:`sm`,variant:`secondary`,disabled:v.isPending,onClick:()=>v.mutate({addonId:t}),children:[v.isPending?r(m,{className:`h-3 w-3 animate-spin`}):r(ce,{className:`h-3 w-3`}),i(`system.meshNetworks.disconnect`,`Disconnect`)]}),e(I,{size:`sm`,variant:`ghost`,disabled:y.isPending,onClick:()=>y.mutate({addonId:t}),children:[y.isPending?r(m,{className:`h-3 w-3 animate-spin`}):r(x,{className:`h-3 w-3`}),i(`system.meshNetworks.logOut`,`Log out`)]})]}):l?e(I,{size:`sm`,variant:`ghost`,onClick:C,children:[r(b,{className:`h-3 w-3 mr-1`}),` `,i(`common.cancel`)]}):e(c,{children:[e(I,{size:`sm`,variant:`primary`,onClick:()=>void S(),children:[r(se,{className:`h-3 w-3`}),i(`system.meshNetworks.connect`,`Connect`)]}),e(I,{size:`sm`,variant:`ghost`,disabled:y.isPending,onClick:()=>y.mutate({addonId:t}),children:[y.isPending?r(m,{className:`h-3 w-3 animate-spin`}):r(x,{className:`h-3 w-3`}),i(`system.meshNetworks.logOut`,`Log out`)]})]})})}function it(e){return new Promise(t=>setTimeout(t,e))}o();var at={mesh:`bg-info/15 text-info`,public:`bg-primary/15 text-primary`},ot=3e4;function st({addonId:t}){let{t:n}=z(),{status:i}=Y(t),a=le({addonId:t},{refetchInterval:ot,retry:!1});return e(`div`,{className:`rounded-lg border border-border bg-surface`,children:[e(`div`,{className:`space-y-4 p-2 sm:p-4`,children:[i.error&&r(de,{message:i.error}),r(ct,{status:i}),i.endpoints.length>0&&e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:n(`system.meshNetworks.endpoints`,`Endpoints`)}),i.endpoints.map(t=>e(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[e(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${at[t.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[t.scope===`public`?r(M,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,t.label]}),e(`a`,{href:t.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-success hover:underline break-all flex items-center gap-1`,children:[r(k,{className:`h-3 w-3 shrink-0`}),t.url]})]},t.id))]})]}),r(`div`,{className:`border-t border-border`,children:r(ut,{peers:a.data?.peers??[],loading:a.isLoading})})]})}function ct({status:t}){let{t:n}=z();return r(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5`,children:[{label:n(`system.meshNetworks.tenant`,`Tenant`),value:t.tenantName||`—`},{label:n(`system.meshNetworks.user`,`User`),value:t.userLogin??`—`},{label:n(`system.meshNetworks.controlPlane`,`Control plane`),value:t.controlPlaneUrl||`—`},{label:n(`system.meshNetworks.meshIp`,`Mesh IP`),value:t.meshIp||`—`,mono:!0},{label:n(`system.meshNetworks.magicdns`,`MagicDNS`),value:t.magicDnsHostname||`—`,mono:!0},{label:n(`system.meshNetworks.dnsSuffix`,`DNS suffix`),value:t.magicDnsSuffix||`—`,mono:!0},{label:n(`system.meshNetworks.peers`,`Peers`),value:String(t.peerCount)},{label:n(`system.meshNetworks.keyExpiry`,`Key expiry`),value:t.keyExpiry?lt(t.keyExpiry):`—`}].map(t=>e(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[r(`span`,{className:`text-foreground-subtle shrink-0`,children:t.label}),r(`span`,{className:`text-foreground truncate ${t.mono?`font-mono`:``}`,children:t.value})]},t.label))})}function lt(e){let t=e-Date.now();if(t<0)return R.t(`system.meshNetworks.expiredAgo`,{when:Q(e)});let n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return R.t(`system.meshNetworks.expiryDays`,{count:n});let r=Math.floor(t/36e5);return r>1?R.t(`system.meshNetworks.expiryHours`,{count:r}):R.t(`system.meshNetworks.expiryMin`,{count:Math.max(1,Math.floor(t/6e4))})}function ut({peers:i,loading:a}){let{t:o}=z(),s=t(()=>i.map(e=>({...e,_id:e.id})),[i]),c=n(e=>{e&&navigator.clipboard?.writeText(e)},[]),l=t(()=>[{key:`hostname`,header:o(`system.meshNetworks.hostname`,`Hostname`),render:t=>e(`div`,{className:`flex flex-col`,children:[e(`div`,{className:`flex items-center gap-1.5`,children:[r(`span`,{className:`font-medium text-foreground`,children:t.hostname||o(`system.meshNetworks.unknown`,`(unknown)`)}),t.isSelf&&r(N,{variant:`info`,children:o(`common.self`)}),t.exitNodeOption&&r(N,{variant:`warning`,children:`exit-node`})]}),t.userLogin&&r(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:t.userLogin})]})},{key:`magicDns`,header:o(`system.meshNetworks.magicdns`,`MagicDNS`),render:t=>t.magicDns?e(`div`,{className:`flex items-center gap-1`,children:[r(`span`,{className:`font-mono text-xs truncate`,children:t.magicDns}),r(I,{variant:`unstyled`,onClick:()=>c(t.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":o(`system.meshNetworks.copyMagicdns`,`Copy MagicDNS`),children:r(D,{className:`h-3 w-3 text-foreground-subtle`})})]}):r(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:t=>{let n=t.addresses[0]??``;return n?e(`div`,{className:`flex items-center gap-1`,children:[r(`span`,{className:`font-mono text-xs`,children:n}),r(I,{variant:`unstyled`,onClick:()=>c(n),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":o(`system.meshNetworks.copyIp`,`Copy IP`),children:r(D,{className:`h-3 w-3 text-foreground-subtle`})})]}):r(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:o(`system.meshNetworks.connection`,`Connection`),render:t=>e(`div`,{className:`flex items-center gap-1.5`,children:[r(N,{variant:dt(t.connection),children:t.connection}),t.relay&&r(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:t.relay})]})},{key:`routes`,header:o(`system.meshNetworks.routes`,`Routes`),render:e=>e.advertisedRoutes.length>0?r(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):r(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:o(`system.meshNetworks.txRx`,`TX / RX`),render:t=>e(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,Z(t.txBytes),` · ↓ `,Z(t.rxBytes)]})},{key:`lastSeen`,header:o(`system.meshNetworks.lastSeen`,`Last seen`),render:e=>r(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?Q(e.lastSeenMs):`—`})}],[c,o]);return a&&i.length===0?e(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[r(m,{className:`h-3 w-3 animate-spin inline mr-1`}),` `,o(`systemPage.meshNetworks.loadingPeers`)]}):i.length===0?r(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:o(`system.meshNetworks.noPeersVisibleYourTailnet`,`No peers visible — your tailnet may be empty or the host is not joined.`)}):r(`div`,{className:`p-4`,children:r(P,{columns:l,rows:s,rowKey:e=>e._id,minWidthPx:820})})}function dt(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function Z(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 Q(e){let t=Date.now()-e;return t<6e4?R.t(`system.meshNetworks.justNow`):t<36e5?R.t(`system.meshNetworks.agoMin`,{count:Math.round(t/6e4)}):t<864e5?R.t(`system.meshNetworks.agoHour`,{count:Math.round(t/36e5)}):R.t(`system.meshNetworks.agoDay`,{count:Math.round(t/864e5)})}var $=`mesh-network`;function ft(){let{t}=z();return r(W,{functionCap:$,icon:A,title:t(`system.meshNetworks.meshNetworks2`,`Mesh Networks`),subtitle:t(`system.meshNetworks.privateVpnMeshesThatConnect`,`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).`),emptyTitle:t(`system.meshNetworks.noMeshNetworkProvidersInstalled`,`No mesh-network providers installed`),emptyDescription:t(`system.meshNetworks.installAMeshAddonE`,`Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.`),addLabel:t(`system.meshNetworks.addMesh`,`Add mesh`),install:{capability:$,label:t(`system.meshNetworks.addMesh`,`Add mesh`)},extraColumns:[{key:`mesh-state`,header:t(`system.meshNetworks.connectionState`,`Mesh`),notSortableReason:t(`system.meshNetworks.connectionStateNotSortable`,`Live state of the tailnet, not a stored value.`),render:e=>r(X,{addonId:e.addonId})}],lead:t=>e(`div`,{className:`flex flex-col gap-3`,children:[r(nt,{addonId:t.addonId}),r(st,{addonId:t.addonId})]})})}var pt=`/system/identity?tab=certificates`;function mt(){let{t}=z(),n=O(),i=Le();return r(H,{embedded:!0,children:e(`div`,{className:v,children:[r(`p`,{className:`text-xs text-foreground-subtle`,children:t(`system.localAccess.nativeAppsOnThisWi`,`Native apps on this Wi-Fi use http:// and skip the private certificate. The tunnel and this admin UI stay on HTTPS.`)}),r(he,{trpc:n.trpcClient,addonId:`local-network`,cap:`local-network`,scope:`node`,nodeId:`hub`,onAfterChange:i,title:t(`system.localAccess.lanHttp`,`LAN HTTP`)}),e(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`https-certificate-hint`,children:[t(`system.localAccess.certificateMoved`,`The HTTPS certificate and the local CA are managed under`),` `,r(Pe,{className:`underline`,to:pt,children:t(`system.localAccess.certificateMovedLink`,`Identity → Certificates`)}),`.`]})]})})}o();function ht({value:n,onChange:i}){let{t:a}=z(),{data:o}=pe({isCamera:!0,projection:`slim`}),s=t(()=>o===void 0?[{value:``,label:a(`system.networkDiagnostics.loadingCameras`,`Loading cameras…`)}]:o.length===0?[{value:``,label:a(`system.networkDiagnostics.noCameras`,`No cameras`)}]:[{value:``,label:a(`system.networkDiagnostics.pickACamera`,`Pick a camera`)},...o.toSorted((e,t)=>e.name.localeCompare(t.name)).map(e=>({value:String(e.id),label:`${e.name} (#${String(e.id)})`}))],[o,a]);return e(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[r(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`system.networkDiagnostics.camera`,`Camera`)}),r(te,{value:n===null?``:String(n),disabled:o===void 0||o.length===0,onChange:e=>i(e.target.value===``?null:Number(e.target.value)),options:s})]})}function gt(){let t=O(),[i,o]=a(null);return r(H,{embedded:!0,children:e(`div`,{className:v,"data-testid":`network-diagnostics`,children:[r(be,{loadServers:n(async()=>t.trpcClient.turnProvider.getTurnServers.query(),[t])}),r(je,{trpc:t.trpcClient,serverUrl:T(),deviceId:i,cameraField:r(ht,{value:i,onChange:o})})]})})}var _t=[`certificate`,`certificates`,`https`];function vt(){let{t:e}=z(),[t]=Ne();if(_t.includes(t.get(`tab`)??``))return r(Me,{to:pt,replace:!0});let n=Fe(`/system/network`,{t:e,isAdmin:!0})??{icon:M,title:e(`system.network`,`Network`)};return r(Ie,{icon:n.icon,title:n.title,defaultSection:`addresses`,sectionsLabel:`${n.title} sections`,sections:[{id:`local-access`,label:e(`systemPage.network.localAccess`,`Local access`),content:r(mt,{})},{id:`addresses`,label:e(`systemPage.network.networkAddresses`,`Network Addresses`),content:r($e,{})},{id:B.remoteAccess.tab,label:e(`systemPage.network.remoteAccess`,`Remote Access`),content:r(Ve,{}),ownedParams:V},{id:B.mesh.tab,label:e(`systemPage.network.meshNetworks`,`Mesh Networks`),content:r(ft,{}),ownedParams:V},{id:B.turn.tab,label:e(`systemPage.network.turnServers`,`TURN Servers`),content:r(We,{}),ownedParams:V},{id:`diagnostics`,label:e(`systemPage.network.diagnostics`,`Diagnostics`),content:r(gt,{})}]})}export{vt as NetworkPage};
@@ -1,2 +1,2 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,W as o,Y as s,a as c,et as l,i as u,j as d,o as f,p,t as m}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{gt as h}from"./player-overlays-C92tUBpz.js";import{$s as g,Qs as _}from"./client-DM5tcoga.js";import{Ui as v,Wi as y,ao as ee,ea as te,ef as b,et as ne,xa as re}from"./src-wYH5IrPO.js";import{t as ie}from"./useTranslation-BJr-n0es.js";import{F as x,N as ae,P as oe,dt as S}from"./index-Wmx2JgTc.js";l();var C=d(function({addonId:e,schema:s,serverValues:c,onImmediateSave:l,onStateChange:u,onAction:d,disabled:f},p){let m=x({schema:s,serverValues:c,onImmediateSave:r(t=>l(e,t),[e,l]),onDeferredSave:r(()=>{},[])});o(p,()=>({flush:()=>{let e={};for(let t of m.pendingKeys)e[t]=m.values[t];return m.handleDiscard(m.pendingKeys),e},discard:()=>m.resetAll()}),[m]);let h=m.pendingKeys,g=h.join(`|`),_=n(()=>h.map(e=>`${e}=${JSON.stringify(m.values[e])}`).join(`,`),[h,m.values]),v=t(u);a(()=>{v.current=u},[u]),a(()=>{let t={};for(let e of h)t[e]=m.values[e];v.current({addonId:e,pendingKeys:h,pendingValues:t})},[e,g,_]);let y=n(()=>{if(d)return(t,n,r)=>d(e,t,n,r)},[e,d]);return i(S,{schema:s,values:m.values,onChange:m.handleChange,disabled:f,onAction:y})});function w(e){return`perNode`in e&&e.perNode===!0}function T(e,t){if(e.type===`group`){let n=E(e.fields,t);return n.length>0?{...e,fields:n}:null}if(e.type===`sub-tabs`){let n=e.tabs.map(e=>({...e,fields:E(e.fields,t)})).filter(e=>e.fields.length>0);return n.length>0?{...e,tabs:n}:null}return w(e)===(t===`perNode`)?e:null}function E(e,t){let n=[];for(let r of e){let e=T(r,t);e!==null&&n.push(e)}return n}function se(e,t){let n=[];for(let r of e.sections){let e=E(r.fields,t);e.length!==0&&n.push({...r,fields:e})}return{...e,sections:n}}function D(e,t){return t===void 0?!0:t===`perNode`?e===`node`:e!==`node`}function ce(e){let t=e.allowSectionIds?new Set(e.allowSectionIds):null,n=e.omitSectionIds?new Set(e.omitSectionIds):null,r=new Set,i=[];for(let a of e.declarations){if(!D(a.scope,e.fieldScope)||e.capability!==void 0&&a.cap!==e.capability)continue;let o=a.sectionIds.filter(e=>r.has(e)||(r.add(e),t!==null&&!t.has(e))?!1:n===null||!n.has(e));o.length>0&&i.push({cap:a.cap,scope:a.scope,sectionIds:o})}return i}function le(e){let t=[],n=new Map,r={};for(let{declaration:i,form:a}of e){let e=new Set(i.sectionIds),o=a.sections.filter(t=>e.has(t.id));t.push(...o);for(let e of a.tabs??[])n.has(e.id)||n.set(e.id,e);for(let e of g({sections:o}).keys()){let t=r[e]??[];t.push({cap:i.cap,scope:i.scope}),r[e]=t}}return{form:{...n.size>0?{tabs:[...n.values()]}:{},sections:t},keyTargets:r}}function ue(e,t){let n=new Map,r=[];for(let[i,a]of Object.entries(e)){let e=t[i];if(e===void 0||e.length===0){r.push(i);continue}for(let t of e){let e=`${t.cap}\u0000${t.scope}`,r=n.get(e)??{target:t,patch:{}};r.patch[i]=a,n.set(e,r)}}return{groups:[...n.values()].map(e=>({...e.target,patch:e.patch})),unowned:r}}function de(e,t){let n=e??`general`;return t?.[n]??n}function O(e){return typeof e!=`object`||!e||!(`key`in e)?null:typeof e.key==`string`?e.key:null}function fe(e,t){let n=t.fieldKeys===void 0?null:new Set(t.fieldKeys),r=[];for(let i of e){let e=n===null?i.fields:i.fields.filter(e=>{let t=O(e);return t!==null&&n.has(t)});e.length!==0&&r.push({...i,fields:e,...t.tabAliases===void 0?{}:{tab:de(i.tab,t.tabAliases)},...t.hideSectionChrome===!0?{title:``,description:void 0}:{}})}return r}var k=`login-method`,A=`integration-instances`,j=new Set;function pe(e){return e.level===`global`&&e.capability===void 0&&e.sectionIds===void 0&&e.fieldScope===void 0&&e.fieldKeys===void 0}function me(e){let t=new Set([k]);for(let n of e)for(let e of n)t.add(e);return t}function M(e){return!e.isSuccess&&!e.isError}function N(e){return e instanceof Error&&e.message.length>0?e.message:`Could not list connection providers`}function P(e){if(!e.active)return{phase:`off`,caps:j,error:null};if(!e.canQuery)return{phase:`ready`,caps:j,error:null};if(M(e.holders))return{phase:`loading`,caps:j,error:null};if(e.holders.isError)return{phase:`ready`,caps:me([]),error:N(e.holders.error)};if(e.described.some(M))return{phase:`loading`,caps:j,error:null};let t=e.described.find(e=>e.isError);return{phase:`ready`,caps:me(e.described.flatMap(e=>e.data===void 0?[]:[e.data])),error:t===void 0?null:N(t.error)}}function F(e){if(typeof e!=`object`||!e||!(`addonId`in e))return null;let t=e.addonId;return typeof t==`string`&&t.length>0?t:null}async function I(e){let t=await e({capName:A});if(!Array.isArray(t))throw Error(`listCapabilityProviders did not answer with a list`);let n=[];for(let e of t){let t=F(e);t!==null&&n.push(t)}return n}function L(e){if(typeof e!=`object`||!e||!(`kinds`in e))return[];let t=e.kinds;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(typeof e!=`object`||!e||!(`functionCap`in e))continue;let t=e.functionCap;typeof t==`string`&&t.length>0&&n.push(t)}return n}function he(e){let t=h().trpcClient,n=t.addons.listCapabilityProviders?.query,r=t.integrationInstances?.describe?.query,i=n!==void 0&&r!==void 0,a=c({queryKey:[`settings`,`provider-page-holders`],enabled:e&&i,queryFn:()=>{if(n===void 0)throw Error(`listCapabilityProviders is not available`);return I(n)}});return P({active:e,canQuery:i,holders:a,described:u({queries:(a.data??[]).map(t=>({queryKey:[`settings`,`provider-page-kinds`,t],enabled:e&&i&&a.isSuccess,queryFn:async()=>{if(r===void 0)throw Error(`integrationInstances.describe is not available`);return L(await r({addonId:t}))}}))})})}l();function R(e,t){if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`){let n=e.fields.map(e=>R(e,t));return{...e,fields:n}}let n=e;t[e.key]=n.value;let{value:r,...i}=n;return i}function z(e,t){return{...e,fields:e.fields.map(e=>R(e,t))}}function ge(e){let t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>z(e,t))},values:t}}function B({nodeId:a,addonIds:o,level:c,deviceId:l,capability:d,sectionIds:g,omitSectionIds:b,fieldKeys:x,hideSectionChrome:S,tabAliases:C,tabLabelOverrides:w,sectionTab:T,fieldScope:E,emptyMessage:D,extraTabs:O,schemaTabExtras:k,title:A,description:j,selfTabbed:me,activeTab:M,onActiveTabChange:N}){let{t:P}=ie(),F=f(),I=h().trpcClient,L=y(),R=v(),z=ee(),B=re(),V=me===!0||!!(O&&O.length>0),[ve,ye]=s(null);if(c===`device`&&!l)throw Error(`NodeAddonsSettingsPanel: deviceId is required when level === "device"`);let H=a??`hub`,U=he(pe({level:c,...d===void 0?{}:{capability:d},...g===void 0?{}:{sectionIds:g},...E===void 0?{}:{fieldScope:E},...x===void 0?{}:{fieldKeys:x}})),be=U.phase===`ready`?[...U.caps].sort().join(`
2
- `):``,W=u({queries:o.map(e=>({queryKey:[[`addonSettings`,c===`global`?`listScopedSettings`:`getDeviceSettings`],{addonId:e,nodeId:H,deviceId:l??null,cap:d??null,scope:E??null,sections:[g??null,b??null],providerCaps:be}],enabled:U.phase!==`loading`,queryFn:async()=>{if(c===`global`){let t=await I.addonSettings.listScopedSettings.query({addonId:e,nodeId:H});if(t===null)return{addonId:e,result:null,keyTargets:{}};let n=ce({declarations:U.phase===`ready`?t.filter(e=>!U.caps.has(e.cap)):t,...E===void 0?{}:{fieldScope:E},...d===void 0?{}:{capability:d},...g===void 0?{}:{allowSectionIds:g},...b===void 0?{}:{omitSectionIds:b}}),r=await Promise.all(n.map(async t=>{let n=await I.addonSettings.getScopedSettings.query({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:H}:{}});return n===null?null:{declaration:t,form:n}})),i=r.filter(e=>e!==null);if(i.length!==r.length)return{addonId:e,result:null,keyTargets:{}};let a=le(i);return{addonId:e,result:a.form,keyTargets:a.keyTargets}}let t=await I.addonSettings.getDeviceSettings.query({addonId:e,deviceId:l,nodeId:H});return{addonId:e,result:t!==null&&E!==void 0?se(t,E):t,keyTargets:{}}},placeholderData:p}))}),xe=U.phase===`loading`||W.some(e=>e.isLoading),Se=W.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(`||`),G=n(()=>{let e=new Set;for(let t of W){let n=t.data?.result?.sections;if(n)for(let t of n)e.add(de(t.tab,C))}return[...e]},[C,Se+`::`+W.map(e=>(e.data?.result?.sections??[]).map(e=>e.tab??`general`).join(`,`)).join(`::`)]),K=n(()=>new Map((O??[]).map(e=>[e.id,e])),[O]),Ce=n(()=>{if(!V)return[];let e=[...new Set([...G,...(O??[]).map(e=>e.id),...(k??[]).map(e=>e.tabId)])],t=e=>{let t=K.get(e);if(t?.order!==void 0)return t.order;let n=_[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})},[V,G,O,K,k]),we=n(()=>{let e=new Map,t=e=>_[e]?.label??e.charAt(0).toUpperCase()+e.slice(1);for(let n of G)e.set(n,t(n));for(let n of k??[])e.has(n.tabId)||e.set(n.tabId,t(n.tabId));for(let t of O??[])e.set(t.id,t.label);for(let[t,n]of Object.entries(w??{}))e.set(t,n);return e},[G,O,k,w]),Te=M===void 0?ve:M,q=V?Te&&Ce.includes(Te)?Te:Ce[0]??null:null,Ee=e=>{ye(e),N?.(e)},De=q!==null&&K.has(q),J=V?q&&!De?q:void 0:T,{data:Oe}=te(void 0),ke=n(()=>{let e=new Map;for(let t of Oe??[]){let n=t.manifest?.id;if(!n)continue;let r=t.manifest?.name??t.manifest?.packageDisplayName??n;e.set(n,r)}return e},[Oe]),Ae=t(new Map),Y=n(()=>{let e=g?new Set(g):null,t=b?new Set(b):null,n=n=>!(e!==null&&!e.has(n)||t!==null&&t.has(n)),r=[];for(let e of W){if(!e.data)continue;e.data.result!==null&&Ae.current.set(e.data.addonId,{result:e.data.result,keyTargets:e.data.keyTargets});let t=Ae.current.get(e.data.addonId)??null;if(t===null)continue;let{result:i,keyTargets:a}=t,{schema:o,values:s}=ge(i),c={...x===void 0?{}:{fieldKeys:x},...S===void 0?{}:{hideSectionChrome:S},...C===void 0?{}:{tabAliases:C}},l=fe(o.sections.filter(e=>n(e.id)),c);if(l.length===0)continue;let u={...i,sections:fe(i.sections.filter(e=>n(e.id)),c)},d={...o,sections:l};r.push({addonId:e.data.addonId,schemaWithValues:u,schema:d,serverValues:s,keyTargets:a})}return r},[Se,g,b,x,S,C]),je=n(()=>W.flatMap(e=>c===`global`&&e.data!==void 0&&e.data.result===null&&!Ae.current.has(e.data.addonId)?[e.data.addonId]:[]),[Se,c]),[X,Me]=s(new Map),Ne=r(e=>{Me(t=>{let n=new Map(t);return n.set(e.addonId,e),n})},[]),Z=t(new Map),Pe=r(e=>t=>{t?Z.current.set(e,t):Z.current.delete(e)},[]),Fe=r(async(e,t)=>{if(c!==`global`){await R.mutateAsync({addonId:e,deviceId:l,nodeId:H,patch:t});return}let{groups:n,unowned:r}=ue(t,Y.find(t=>t.addonId===e)?.keyTargets??{});if(r.length>0)throw Error(`${e}: no scoped setting declares ${r.join(`, `)}`);let i=(await Promise.allSettled(n.map(t=>L.mutateAsync({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:H}:{},patch:t.patch})))).flatMap((e,t)=>{let r=n[t];if(e.status!==`rejected`||r===void 0)return[];let i=e.reason instanceof Error?e.reason.message:String(e.reason);return[`${r.cap}/${r.scope}: ${i}`]});if(i.length>0)throw F.invalidateQueries({queryKey:[[`addonSettings`]]}),Error(`${e}: not saved to ${i.join(`; `)}`)},[c,Y,L,R,F,H,l]),Ie=r(async(e,t)=>{await Fe(e,t),F.invalidateQueries({queryKey:[[`addonSettings`]]})},[Fe,F]),Le=r(async(e,t,n,r)=>{let i=H;try{switch(t){case`reprobe-hwaccel`:await z.mutateAsync({nodeId:i}),F.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-audio-engine`:await B.mutateAsync({nodeId:i}),F.invalidateQueries({queryKey:[[`addonSettings`]]});return;default:{let n=await I.addons.custom.mutate({addonId:e,action:t,input:r});return F.invalidateQueries({queryKey:[[`addonSettings`]]}),n}}}catch(n){throw console.error(`[NodeAddonsSettingsPanel] action failed`,{addonId:e,action:t,err:n}),n}},[z,B,H,F,I]),Re=r((e,t)=>{Ie(e,t)},[Ie]),Q=m({mutationFn:async()=>{let e=[];for(let t of Y){let n=X.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})=>(await Fe(e,t),e)))}},onSuccess:({saved:e})=>{for(let t of e)Z.current.get(t)?.discard();F.invalidateQueries({queryKey:[[`addonSettings`]]})}}),ze=r(()=>{for(let e of Z.current.values())e.discard()},[]),Be=n(()=>{let e=0;for(let t of Y){let n=X.get(t.addonId);n&&(e+=n.pendingKeys.length)}return e},[Y,X]),Ve=n(()=>{let e=new Map;for(let t of Y){let n=X.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},[Y,X]);if(xe)return i(`div`,{className:`h-24 rounded-lg border border-border bg-surface animate-pulse`});let He=q&&De?K.get(q):void 0,$=je.length>0?i(`div`,{className:`space-y-1 text-[11px] text-foreground-subtle`,role:`status`,children:je.map(e=>i(`div`,{children:P(`settings.nodeAddonsSettingsPanel.addonUnavailable`,`{{name}} not available.`,{name:ke.get(e)??e})},e))}):null;if(!V&&Y.length===0)return $===null?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:D??P(`settings.nodeAddonsSettingsPanel.noAddonsIn`,{scope:o.length>0?`[${o.join(`, `)}]`:P(`settings.nodeAddonsSettingsPanel.theCurrentSelection`,`the current selection`),level:c})}):$;let Ue=Q.isPending;return e(`div`,{className:`space-y-4`,children:[(A||j)&&e(`div`,{className:`border-b border-border pb-2`,children:[A&&i(`h2`,{className:`text-sm font-semibold text-foreground`,children:A}),j&&i(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:j})]}),Y.length>0||V?$:null,V&&i(ae,{tabs:Ce.map(e=>({id:e,label:we.get(e)??e})),activeId:q,onChange:Ee,pendingByTab:Ve}),U.error!==null&&i(`div`,{role:`alert`,className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:P(`settings.nodeAddonsSettingsPanel.providerPagesUnknown`,`Could not check which settings already live on a connection page: {{reason}}`,{reason:U.error})}),Q.isError&&e(`div`,{className:`rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400`,children:[P(`settings.nodeAddonsSettingsPanel.saveFailed`,`Save failed:`),` `,String(Q.error?.message??Q.error)]}),i(ne,{tabKey:He?`extra:${q??``}`:`tab:${q??``}`,children:He?He.content:(()=>{let t=J?Y.reduce((e,t)=>e+t.schemaWithValues.sections.filter(e=>(e.tab??`general`)===J).length,0):0,n=!!J&&t<=1,r=Y.map(e=>({...e,renderedWithValues:{...e.schemaWithValues,sections:e.schemaWithValues.sections.filter(e=>J?(e.tab??`general`)===J:!0).map(e=>n?{...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}),a=(k??[]).filter(e=>e.tabId===J),o=a.filter(e=>(e.placement??`before`)===`before`),s=a.filter(e=>e.placement===`after`);return r.length===0&&a.length===0?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:D??P(`settings.nodeAddonsSettingsPanel.nothingToConfigureHereFor`,`Nothing to configure here for this node.`)}):e(`div`,{className:`space-y-6`,children:[o.map((e,t)=>i(`div`,{children:e.content},`extra-before-${t}`)),r.length>0&&i(_e,{entries:r,paneStates:X,displayNames:ke,disabled:Ue,setPaneRef:Pe,onPaneStateChange:Ne,onImmediateSave:Re,onAction:Le,inline:V||!!T}),s.map((e,t)=>i(`div`,{children:e.content},`extra-after-${t}`))]})})()}),!xe&&i(oe,{pendingCount:Be,onSave:()=>Q.mutate(),onDiscard:ze,saving:Ue})]})}function _e({entries:t,paneStates:r,displayNames:o,disabled:c,setPaneRef:l,onPaneStateChange:u,onImmediateSave:d,onAction:f,inline:p}){let m=n(()=>[...t].toSorted((e,t)=>{let n=o.get(e.addonId)??e.addonId,r=o.get(t.addonId)??t.addonId;return n.localeCompare(r)}),[t,o]),[h,g]=s(m[0]?.addonId??``);a(()=>{m.length!==0&&(m.find(e=>e.addonId===h)||g(m[0].addonId))},[m,h]);let _=m.find(e=>e.addonId===h)??m[0];if(!_)return null;let v=n(()=>f?(e,t,n,r)=>f(e,t,n,r):void 0,[f]),y=e=>i(C,{ref:l(e.addonId),addonId:e.addonId,schema:e.renderedWithValues,serverValues:e.serverValues,onImmediateSave:d,onStateChange:u,onAction:v,disabled:c},e.addonId);return m.length===1||p?i(`div`,{className:`flex flex-col gap-4`,children:m.map(y)}):e(`div`,{className:`flex flex-col gap-3`,children:[i(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:m.map(t=>{let n=o.get(t.addonId)??t.addonId,a=t.addonId===_.addonId,s=(r.get(t.addonId)?.pendingKeys.length??0)>0;return e(b,{variant:`unstyled`,type:`button`,onClick:()=>g(t.addonId),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${a?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[n,s&&i(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400`})]},t.addonId)})}),i(`div`,{className:`space-y-2`,children:m.map(e=>i(`div`,{style:e.addonId===_.addonId?void 0:{display:`none`},children:y(e)},e.addonId))})]})}export{fe as n,B as t};
1
+ import{C as e,J as t,K as n,R as r,S as i,V as a,W as o,Y as s,a as c,et as l,i as u,j as d,o as f,p,t as m}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{gt as h}from"./player-overlays-BMit2yun.js";import{$s as g,ec as _}from"./client-DLGNlJDt.js";import{Ui as v,Wi as y,ao as ee,ea as te,ef as b,et as ne,xa as re}from"./src-Dg912oqK.js";import{t as ie}from"./useTranslation-BJr-n0es.js";import{F as x,N as ae,P as oe,dt as S}from"./index-DgOWypvk.js";l();var C=d(function({addonId:e,schema:s,serverValues:c,onImmediateSave:l,onStateChange:u,onAction:d,disabled:f},p){let m=x({schema:s,serverValues:c,onImmediateSave:r(t=>l(e,t),[e,l]),onDeferredSave:r(()=>{},[])});o(p,()=>({flush:()=>{let e={};for(let t of m.pendingKeys)e[t]=m.values[t];return m.handleDiscard(m.pendingKeys),e},discard:()=>m.resetAll()}),[m]);let h=m.pendingKeys,g=h.join(`|`),_=n(()=>h.map(e=>`${e}=${JSON.stringify(m.values[e])}`).join(`,`),[h,m.values]),v=t(u);a(()=>{v.current=u},[u]),a(()=>{let t={};for(let e of h)t[e]=m.values[e];v.current({addonId:e,pendingKeys:h,pendingValues:t})},[e,g,_]);let y=n(()=>{if(d)return(t,n,r)=>d(e,t,n,r)},[e,d]);return i(S,{schema:s,values:m.values,onChange:m.handleChange,disabled:f,onAction:y})});function w(e){return`perNode`in e&&e.perNode===!0}function T(e,t){if(e.type===`group`){let n=E(e.fields,t);return n.length>0?{...e,fields:n}:null}if(e.type===`sub-tabs`){let n=e.tabs.map(e=>({...e,fields:E(e.fields,t)})).filter(e=>e.fields.length>0);return n.length>0?{...e,tabs:n}:null}return w(e)===(t===`perNode`)?e:null}function E(e,t){let n=[];for(let r of e){let e=T(r,t);e!==null&&n.push(e)}return n}function se(e,t){let n=[];for(let r of e.sections){let e=E(r.fields,t);e.length!==0&&n.push({...r,fields:e})}return{...e,sections:n}}function D(e,t){return t===void 0?!0:t===`perNode`?e===`node`:e!==`node`}function ce(e){let t=e.allowSectionIds?new Set(e.allowSectionIds):null,n=e.omitSectionIds?new Set(e.omitSectionIds):null,r=new Set,i=[];for(let a of e.declarations){if(!D(a.scope,e.fieldScope)||e.capability!==void 0&&a.cap!==e.capability)continue;let o=a.sectionIds.filter(e=>r.has(e)||(r.add(e),t!==null&&!t.has(e))?!1:n===null||!n.has(e));o.length>0&&i.push({cap:a.cap,scope:a.scope,sectionIds:o})}return i}function le(e){let t=[],n=new Map,r={};for(let{declaration:i,form:a}of e){let e=new Set(i.sectionIds),o=a.sections.filter(t=>e.has(t.id));t.push(...o);for(let e of a.tabs??[])n.has(e.id)||n.set(e.id,e);for(let e of _({sections:o}).keys()){let t=r[e]??[];t.push({cap:i.cap,scope:i.scope}),r[e]=t}}return{form:{...n.size>0?{tabs:[...n.values()]}:{},sections:t},keyTargets:r}}function ue(e,t){let n=new Map,r=[];for(let[i,a]of Object.entries(e)){let e=t[i];if(e===void 0||e.length===0){r.push(i);continue}for(let t of e){let e=`${t.cap}\u0000${t.scope}`,r=n.get(e)??{target:t,patch:{}};r.patch[i]=a,n.set(e,r)}}return{groups:[...n.values()].map(e=>({...e.target,patch:e.patch})),unowned:r}}function de(e,t){let n=e??`general`;return t?.[n]??n}function O(e){return typeof e!=`object`||!e||!(`key`in e)?null:typeof e.key==`string`?e.key:null}function fe(e,t){let n=t.fieldKeys===void 0?null:new Set(t.fieldKeys),r=[];for(let i of e){let e=n===null?i.fields:i.fields.filter(e=>{let t=O(e);return t!==null&&n.has(t)});e.length!==0&&r.push({...i,fields:e,...t.tabAliases===void 0?{}:{tab:de(i.tab,t.tabAliases)},...t.hideSectionChrome===!0?{title:``,description:void 0}:{}})}return r}var k=`login-method`,A=`integration-instances`,j=new Set;function pe(e){return e.level===`global`&&e.capability===void 0&&e.sectionIds===void 0&&e.fieldScope===void 0&&e.fieldKeys===void 0}function me(e){let t=new Set([k]);for(let n of e)for(let e of n)t.add(e);return t}function M(e){return!e.isSuccess&&!e.isError}function N(e){return e instanceof Error&&e.message.length>0?e.message:`Could not list connection providers`}function P(e){if(!e.active)return{phase:`off`,caps:j,error:null};if(!e.canQuery)return{phase:`ready`,caps:j,error:null};if(M(e.holders))return{phase:`loading`,caps:j,error:null};if(e.holders.isError)return{phase:`ready`,caps:me([]),error:N(e.holders.error)};if(e.described.some(M))return{phase:`loading`,caps:j,error:null};let t=e.described.find(e=>e.isError);return{phase:`ready`,caps:me(e.described.flatMap(e=>e.data===void 0?[]:[e.data])),error:t===void 0?null:N(t.error)}}function F(e){if(typeof e!=`object`||!e||!(`addonId`in e))return null;let t=e.addonId;return typeof t==`string`&&t.length>0?t:null}async function I(e){let t=await e({capName:A});if(!Array.isArray(t))throw Error(`listCapabilityProviders did not answer with a list`);let n=[];for(let e of t){let t=F(e);t!==null&&n.push(t)}return n}function L(e){if(typeof e!=`object`||!e||!(`kinds`in e))return[];let t=e.kinds;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(typeof e!=`object`||!e||!(`functionCap`in e))continue;let t=e.functionCap;typeof t==`string`&&t.length>0&&n.push(t)}return n}function he(e){let t=h().trpcClient,n=t.addons.listCapabilityProviders?.query,r=t.integrationInstances?.describe?.query,i=n!==void 0&&r!==void 0,a=c({queryKey:[`settings`,`provider-page-holders`],enabled:e&&i,queryFn:()=>{if(n===void 0)throw Error(`listCapabilityProviders is not available`);return I(n)}});return P({active:e,canQuery:i,holders:a,described:u({queries:(a.data??[]).map(t=>({queryKey:[`settings`,`provider-page-kinds`,t],enabled:e&&i&&a.isSuccess,queryFn:async()=>{if(r===void 0)throw Error(`integrationInstances.describe is not available`);return L(await r({addonId:t}))}}))})})}l();function R(e,t){if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`){let n=e.fields.map(e=>R(e,t));return{...e,fields:n}}let n=e;t[e.key]=n.value;let{value:r,...i}=n;return i}function z(e,t){return{...e,fields:e.fields.map(e=>R(e,t))}}function ge(e){let t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>z(e,t))},values:t}}function B({nodeId:a,addonIds:o,level:c,deviceId:l,capability:d,sectionIds:_,omitSectionIds:b,fieldKeys:x,hideSectionChrome:S,tabAliases:C,tabLabelOverrides:w,sectionTab:T,fieldScope:E,emptyMessage:D,extraTabs:O,schemaTabExtras:k,title:A,description:j,selfTabbed:me,activeTab:M,onActiveTabChange:N}){let{t:P}=ie(),F=f(),I=h().trpcClient,L=y(),R=v(),z=ee(),B=re(),V=me===!0||!!(O&&O.length>0),[ve,ye]=s(null);if(c===`device`&&!l)throw Error(`NodeAddonsSettingsPanel: deviceId is required when level === "device"`);let H=a??`hub`,U=he(pe({level:c,...d===void 0?{}:{capability:d},..._===void 0?{}:{sectionIds:_},...E===void 0?{}:{fieldScope:E},...x===void 0?{}:{fieldKeys:x}})),be=U.phase===`ready`?[...U.caps].sort().join(`
2
+ `):``,W=u({queries:o.map(e=>({queryKey:[[`addonSettings`,c===`global`?`listScopedSettings`:`getDeviceSettings`],{addonId:e,nodeId:H,deviceId:l??null,cap:d??null,scope:E??null,sections:[_??null,b??null],providerCaps:be}],enabled:U.phase!==`loading`,queryFn:async()=>{if(c===`global`){let t=await I.addonSettings.listScopedSettings.query({addonId:e,nodeId:H});if(t===null)return{addonId:e,result:null,keyTargets:{}};let n=ce({declarations:U.phase===`ready`?t.filter(e=>!U.caps.has(e.cap)):t,...E===void 0?{}:{fieldScope:E},...d===void 0?{}:{capability:d},..._===void 0?{}:{allowSectionIds:_},...b===void 0?{}:{omitSectionIds:b}}),r=await Promise.all(n.map(async t=>{let n=await I.addonSettings.getScopedSettings.query({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:H}:{}});return n===null?null:{declaration:t,form:n}})),i=r.filter(e=>e!==null);if(i.length!==r.length)return{addonId:e,result:null,keyTargets:{}};let a=le(i);return{addonId:e,result:a.form,keyTargets:a.keyTargets}}let t=await I.addonSettings.getDeviceSettings.query({addonId:e,deviceId:l,nodeId:H});return{addonId:e,result:t!==null&&E!==void 0?se(t,E):t,keyTargets:{}}},placeholderData:p}))}),xe=U.phase===`loading`||W.some(e=>e.isLoading),Se=W.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(`||`),G=n(()=>{let e=new Set;for(let t of W){let n=t.data?.result?.sections;if(n)for(let t of n)e.add(de(t.tab,C))}return[...e]},[C,Se+`::`+W.map(e=>(e.data?.result?.sections??[]).map(e=>e.tab??`general`).join(`,`)).join(`::`)]),K=n(()=>new Map((O??[]).map(e=>[e.id,e])),[O]),Ce=n(()=>{if(!V)return[];let e=[...new Set([...G,...(O??[]).map(e=>e.id),...(k??[]).map(e=>e.tabId)])],t=e=>{let t=K.get(e);if(t?.order!==void 0)return t.order;let n=g[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})},[V,G,O,K,k]),we=n(()=>{let e=new Map,t=e=>g[e]?.label??e.charAt(0).toUpperCase()+e.slice(1);for(let n of G)e.set(n,t(n));for(let n of k??[])e.has(n.tabId)||e.set(n.tabId,t(n.tabId));for(let t of O??[])e.set(t.id,t.label);for(let[t,n]of Object.entries(w??{}))e.set(t,n);return e},[G,O,k,w]),Te=M===void 0?ve:M,q=V?Te&&Ce.includes(Te)?Te:Ce[0]??null:null,Ee=e=>{ye(e),N?.(e)},De=q!==null&&K.has(q),J=V?q&&!De?q:void 0:T,{data:Oe}=te(void 0),ke=n(()=>{let e=new Map;for(let t of Oe??[]){let n=t.manifest?.id;if(!n)continue;let r=t.manifest?.name??t.manifest?.packageDisplayName??n;e.set(n,r)}return e},[Oe]),Ae=t(new Map),Y=n(()=>{let e=_?new Set(_):null,t=b?new Set(b):null,n=n=>!(e!==null&&!e.has(n)||t!==null&&t.has(n)),r=[];for(let e of W){if(!e.data)continue;e.data.result!==null&&Ae.current.set(e.data.addonId,{result:e.data.result,keyTargets:e.data.keyTargets});let t=Ae.current.get(e.data.addonId)??null;if(t===null)continue;let{result:i,keyTargets:a}=t,{schema:o,values:s}=ge(i),c={...x===void 0?{}:{fieldKeys:x},...S===void 0?{}:{hideSectionChrome:S},...C===void 0?{}:{tabAliases:C}},l=fe(o.sections.filter(e=>n(e.id)),c);if(l.length===0)continue;let u={...i,sections:fe(i.sections.filter(e=>n(e.id)),c)},d={...o,sections:l};r.push({addonId:e.data.addonId,schemaWithValues:u,schema:d,serverValues:s,keyTargets:a})}return r},[Se,_,b,x,S,C]),je=n(()=>W.flatMap(e=>c===`global`&&e.data!==void 0&&e.data.result===null&&!Ae.current.has(e.data.addonId)?[e.data.addonId]:[]),[Se,c]),[X,Me]=s(new Map),Ne=r(e=>{Me(t=>{let n=new Map(t);return n.set(e.addonId,e),n})},[]),Z=t(new Map),Pe=r(e=>t=>{t?Z.current.set(e,t):Z.current.delete(e)},[]),Fe=r(async(e,t)=>{if(c!==`global`){await R.mutateAsync({addonId:e,deviceId:l,nodeId:H,patch:t});return}let{groups:n,unowned:r}=ue(t,Y.find(t=>t.addonId===e)?.keyTargets??{});if(r.length>0)throw Error(`${e}: no scoped setting declares ${r.join(`, `)}`);let i=(await Promise.allSettled(n.map(t=>L.mutateAsync({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:H}:{},patch:t.patch})))).flatMap((e,t)=>{let r=n[t];if(e.status!==`rejected`||r===void 0)return[];let i=e.reason instanceof Error?e.reason.message:String(e.reason);return[`${r.cap}/${r.scope}: ${i}`]});if(i.length>0)throw F.invalidateQueries({queryKey:[[`addonSettings`]]}),Error(`${e}: not saved to ${i.join(`; `)}`)},[c,Y,L,R,F,H,l]),Ie=r(async(e,t)=>{await Fe(e,t),F.invalidateQueries({queryKey:[[`addonSettings`]]})},[Fe,F]),Le=r(async(e,t,n,r)=>{let i=H;try{switch(t){case`reprobe-hwaccel`:await z.mutateAsync({nodeId:i}),F.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-audio-engine`:await B.mutateAsync({nodeId:i}),F.invalidateQueries({queryKey:[[`addonSettings`]]});return;default:{let n=await I.addons.custom.mutate({addonId:e,action:t,input:r});return F.invalidateQueries({queryKey:[[`addonSettings`]]}),n}}}catch(n){throw console.error(`[NodeAddonsSettingsPanel] action failed`,{addonId:e,action:t,err:n}),n}},[z,B,H,F,I]),Re=r((e,t)=>{Ie(e,t)},[Ie]),Q=m({mutationFn:async()=>{let e=[];for(let t of Y){let n=X.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})=>(await Fe(e,t),e)))}},onSuccess:({saved:e})=>{for(let t of e)Z.current.get(t)?.discard();F.invalidateQueries({queryKey:[[`addonSettings`]]})}}),ze=r(()=>{for(let e of Z.current.values())e.discard()},[]),Be=n(()=>{let e=0;for(let t of Y){let n=X.get(t.addonId);n&&(e+=n.pendingKeys.length)}return e},[Y,X]),Ve=n(()=>{let e=new Map;for(let t of Y){let n=X.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},[Y,X]);if(xe)return i(`div`,{className:`h-24 rounded-lg border border-border bg-surface animate-pulse`});let He=q&&De?K.get(q):void 0,$=je.length>0?i(`div`,{className:`space-y-1 text-[11px] text-foreground-subtle`,role:`status`,children:je.map(e=>i(`div`,{children:P(`settings.nodeAddonsSettingsPanel.addonUnavailable`,`{{name}} not available.`,{name:ke.get(e)??e})},e))}):null;if(!V&&Y.length===0)return $===null?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:D??P(`settings.nodeAddonsSettingsPanel.noAddonsIn`,{scope:o.length>0?`[${o.join(`, `)}]`:P(`settings.nodeAddonsSettingsPanel.theCurrentSelection`,`the current selection`),level:c})}):$;let Ue=Q.isPending;return e(`div`,{className:`space-y-4`,children:[(A||j)&&e(`div`,{className:`border-b border-border pb-2`,children:[A&&i(`h2`,{className:`text-sm font-semibold text-foreground`,children:A}),j&&i(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:j})]}),Y.length>0||V?$:null,V&&i(ae,{tabs:Ce.map(e=>({id:e,label:we.get(e)??e})),activeId:q,onChange:Ee,pendingByTab:Ve}),U.error!==null&&i(`div`,{role:`alert`,className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:P(`settings.nodeAddonsSettingsPanel.providerPagesUnknown`,`Could not check which settings already live on a connection page: {{reason}}`,{reason:U.error})}),Q.isError&&e(`div`,{className:`rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400`,children:[P(`settings.nodeAddonsSettingsPanel.saveFailed`,`Save failed:`),` `,String(Q.error?.message??Q.error)]}),i(ne,{tabKey:He?`extra:${q??``}`:`tab:${q??``}`,children:He?He.content:(()=>{let t=J?Y.reduce((e,t)=>e+t.schemaWithValues.sections.filter(e=>(e.tab??`general`)===J).length,0):0,n=!!J&&t<=1,r=Y.map(e=>({...e,renderedWithValues:{...e.schemaWithValues,sections:e.schemaWithValues.sections.filter(e=>J?(e.tab??`general`)===J:!0).map(e=>n?{...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}),a=(k??[]).filter(e=>e.tabId===J),o=a.filter(e=>(e.placement??`before`)===`before`),s=a.filter(e=>e.placement===`after`);return r.length===0&&a.length===0?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:D??P(`settings.nodeAddonsSettingsPanel.nothingToConfigureHereFor`,`Nothing to configure here for this node.`)}):e(`div`,{className:`space-y-6`,children:[o.map((e,t)=>i(`div`,{children:e.content},`extra-before-${t}`)),r.length>0&&i(_e,{entries:r,paneStates:X,displayNames:ke,disabled:Ue,setPaneRef:Pe,onPaneStateChange:Ne,onImmediateSave:Re,onAction:Le,inline:V||!!T}),s.map((e,t)=>i(`div`,{children:e.content},`extra-after-${t}`))]})})()}),!xe&&i(oe,{pendingCount:Be,onSave:()=>Q.mutate(),onDiscard:ze,saving:Ue})]})}function _e({entries:t,paneStates:r,displayNames:o,disabled:c,setPaneRef:l,onPaneStateChange:u,onImmediateSave:d,onAction:f,inline:p}){let m=n(()=>[...t].toSorted((e,t)=>{let n=o.get(e.addonId)??e.addonId,r=o.get(t.addonId)??t.addonId;return n.localeCompare(r)}),[t,o]),[h,g]=s(m[0]?.addonId??``);a(()=>{m.length!==0&&(m.find(e=>e.addonId===h)||g(m[0].addonId))},[m,h]);let _=m.find(e=>e.addonId===h)??m[0];if(!_)return null;let v=n(()=>f?(e,t,n,r)=>f(e,t,n,r):void 0,[f]),y=e=>i(C,{ref:l(e.addonId),addonId:e.addonId,schema:e.renderedWithValues,serverValues:e.serverValues,onImmediateSave:d,onStateChange:u,onAction:v,disabled:c},e.addonId);return m.length===1||p?i(`div`,{className:`flex flex-col gap-4`,children:m.map(y)}):e(`div`,{className:`flex flex-col gap-3`,children:[i(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:m.map(t=>{let n=o.get(t.addonId)??t.addonId,a=t.addonId===_.addonId,s=(r.get(t.addonId)?.pendingKeys.length??0)>0;return e(b,{variant:`unstyled`,type:`button`,onClick:()=>g(t.addonId),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${a?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[n,s&&i(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400`})]},t.addonId)})}),i(`div`,{className:`space-y-2`,children:m.map(e=>i(`div`,{style:e.addonId===_.addonId?void 0:{display:`none`},children:y(e)},e.addonId))})]})}export{fe as n,B as t};