@camstack/addon-admin-ui 1.2.378 → 1.2.380

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 (110) hide show
  1. package/dist/assets/{AddonAssetIcon-Ag9UiFD6.js → AddonAssetIcon-Bb7Ct500.js} +1 -1
  2. package/dist/assets/AddonIntegrationBody-CrdlKSnw.js +1 -0
  3. package/dist/assets/Addons-D4PXlVuv.js +4 -0
  4. package/dist/assets/AdminPage-C4KFXhpL.js +1 -0
  5. package/dist/assets/{AdminTabs-CYT0Gfgp.js → AdminTabs-Xojn4om3.js} +1 -1
  6. package/dist/assets/AiProfiles-DfEnDqpl.js +3 -0
  7. package/dist/assets/{BrokerForm-AegeAXg9.js → BrokerForm-xfFhJuwh.js} +1 -1
  8. package/dist/assets/Build-DI9dJ9g7.js +40 -0
  9. package/dist/assets/{Calendars-VvqcFPuG.js → Calendars-Bnf06BwE.js} +1 -1
  10. package/dist/assets/Cluster-BEN0Ywsy.js +1 -0
  11. package/dist/assets/ClusterStepModel-CCQfGKgr.js +1 -0
  12. package/dist/assets/CompositionEditor-xfXmzLmy.js +1 -0
  13. package/dist/assets/{CompositionEditorPage-vgyZiJfZ.js → CompositionEditorPage-NiAGLAMP.js} +1 -1
  14. package/dist/assets/Data-BXsjqrpr.js +1 -0
  15. package/dist/assets/DeviceDetail-C6IJ8aPy.js +2 -0
  16. package/dist/assets/{DeviceDoActionFields-9IITqtOQ.js → DeviceDoActionFields-DrDGsYb9.js} +1 -1
  17. package/dist/assets/{Devices-Cyh6Qlqo.js → Devices-CbgpUN0n.js} +1 -1
  18. package/dist/assets/{EmbedPlayerPage-CdCpi5P_.js → EmbedPlayerPage-Chpa6jH3.js} +1 -1
  19. package/dist/assets/{HeaderPills-Bml4Qa81.js → HeaderPills-C_d5E3KJ.js} +1 -1
  20. package/dist/assets/Identity-BZRGZUJ4.js +1 -0
  21. package/dist/assets/IntegrationDetail-C0oNiuVo.js +1 -0
  22. package/dist/assets/Integrations-Bwsanjq9.js +1 -0
  23. package/dist/assets/Integrations-Cd2bBUEg.js +1 -0
  24. package/dist/assets/Library-u8upsMgy.js +1 -0
  25. package/dist/assets/Locations-EXGomHtI.js +3 -0
  26. package/dist/assets/{Logs-EXjQjLNI.js → Logs-CiMG3usl.js} +1 -1
  27. package/dist/assets/MotionZonesSettings-BbOnxwDN.js +1 -0
  28. package/dist/assets/MyAccess-D4Q373c8.js +2 -0
  29. package/dist/assets/Network-BDQLQavo.js +1 -0
  30. package/dist/assets/{NodeAddonsSettingsPanel-DsaDhenp.js → NodeAddonsSettingsPanel-BCBiWsXF.js} +1 -1
  31. package/dist/assets/Notifications-CJkHJwU9.js +1 -0
  32. package/dist/assets/{PrivacyMaskSettings-CeROKF6d.js → PrivacyMaskSettings-B8E2Jjy5.js} +1 -1
  33. package/dist/assets/Recordings-CY8GuLFY.js +1 -0
  34. package/dist/assets/{ScanNetworkModal-LKDbSzGe.js → ScanNetworkModal--HB0iAkv.js} +1 -1
  35. package/dist/assets/{SceneMonitorEditor-Dq2eAkcS.js → SceneMonitorEditor-BFZ3oTIz.js} +1 -1
  36. package/dist/assets/SessionsList-BKq4tUzz.js +2 -0
  37. package/dist/assets/{Showroom-Cpy2XosF.js → Showroom-BJ4Ky1Zs.js} +1 -1
  38. package/dist/assets/System-DD5PSmPJ.js +1 -0
  39. package/dist/assets/{Terminal-D0j2XTwz.js → Terminal-OuHg6Cs9.js} +5 -5
  40. package/dist/assets/{Viewer-BBKHaGnS.js → Viewer-DGVbUCuf.js} +1 -1
  41. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Bl9asTFj.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-mlNToqXX.js} +1 -1
  42. package/dist/assets/{archive-Ze9hhry4.js → archive-CJfmV07C.js} +1 -1
  43. package/dist/assets/{authed-media-BJ3V0Hsp.js → authed-media-CYbdebtY.js} +1 -1
  44. package/dist/assets/{boxes-EQnIjyQ5.js → boxes-X_rDWdou.js} +1 -1
  45. package/dist/assets/circle-slash-C9dO41QA.js +1 -0
  46. package/dist/assets/crop-o1ZnayCW.js +1 -0
  47. package/dist/assets/{device-integration-icon-CB229zfO.js → device-integration-icon-BeY56xYd.js} +1 -1
  48. package/dist/assets/device-picker-model-iv0LjZ9A.js +1 -0
  49. package/dist/assets/{format-size-FKMC8cpk.js → format-size-B4KE3z8i.js} +1 -1
  50. package/dist/assets/{history-COLYUTit.js → history-BVPkDM04.js} +1 -1
  51. package/dist/assets/{hostInit-BdS3Gpsj.js → hostInit-CA8QWnWz.js} +1 -1
  52. package/dist/assets/index-BG5-7hV8.js +4 -0
  53. package/dist/assets/index-spclGdc-.css +2 -0
  54. package/dist/assets/{layers-cPcnAaGd.js → layers-Bg9_2Fck.js} +1 -1
  55. package/dist/assets/location-owned-usage-Ynolakjx.js +1 -0
  56. package/dist/assets/{mf-entry-bootstrap-0-9976714b.js → mf-entry-bootstrap-0-5ba87861.js} +2 -2
  57. package/dist/assets/{monitor-smartphone-Dpm4bhCz.js → monitor-smartphone-5lHVpcLH.js} +1 -1
  58. package/dist/assets/mount-iv0LjZ9A.js +1 -0
  59. package/dist/assets/notification-schedule-field-DSZYumUK.js +1 -0
  60. package/dist/assets/{octagon-alert-C31Yg2_w.js → octagon-alert-Bn06fTVi.js} +1 -1
  61. package/dist/assets/player-overlays-Sm-ivm_8.js +1 -0
  62. package/dist/assets/remoteEntry-P_tn-U-H.js +1 -0
  63. package/dist/assets/{send-D7I4L3zS.js → send-TxnVMKnC.js} +1 -1
  64. package/dist/assets/{settings-2-ZWMbtxvo.js → settings-2-BAm45F1t.js} +1 -1
  65. package/dist/assets/src-wd4uG4SU.js +67 -0
  66. package/dist/assets/{use-scenes-feed-Dlji29sg.js → use-scenes-feed-DEo1hSFU.js} +1 -1
  67. package/dist/assets/{use-stationary-objects-wg1tYqCt.js → use-stationary-objects-RHZniR-r.js} +1 -1
  68. package/dist/assets/useEventInvalidation-iv0LjZ9A.js +1 -0
  69. package/dist/assets/{useNodeUrlSelection-CZ06zQfe.js → useNodeUrlSelection-BHkizaWO.js} +1 -1
  70. package/dist/assets/user-round-BLTQwaog.js +1 -0
  71. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DwpWTSeK.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CB7lihwK.js} +2 -2
  72. package/dist/index.html +7 -7
  73. package/dist/server/addon.js +1 -1
  74. package/package.json +1 -1
  75. package/dist/assets/AddonIntegrationBody-PmjCQ2Ms.js +0 -1
  76. package/dist/assets/Addons-Ch8IGQYU.js +0 -4
  77. package/dist/assets/AdminPage-BSFohA3i.js +0 -1
  78. package/dist/assets/AiProfiles-CvGjy2UD.js +0 -3
  79. package/dist/assets/Build-K_E6WPuU.js +0 -40
  80. package/dist/assets/Cluster-Dys62hM2.js +0 -1
  81. package/dist/assets/ClusterStepModel-B6kJx6hO.js +0 -1
  82. package/dist/assets/CompositionEditor-Djb_m0Fq.js +0 -1
  83. package/dist/assets/Data-bZQZDfmh.js +0 -1
  84. package/dist/assets/DeviceDetail-CZm2UKkP.js +0 -2
  85. package/dist/assets/Identity-C3msiWzK.js +0 -1
  86. package/dist/assets/IntegrationDetail-DTa_Z_Y8.js +0 -1
  87. package/dist/assets/Integrations-BUs8sF9z.js +0 -1
  88. package/dist/assets/Integrations-Blra3sWt.js +0 -1
  89. package/dist/assets/Library-DtHrSPqN.js +0 -1
  90. package/dist/assets/Locations-DljHAtnI.js +0 -3
  91. package/dist/assets/MotionZonesSettings-DzJiBfBH.js +0 -1
  92. package/dist/assets/MyAccess-CYEHE4Vt.js +0 -2
  93. package/dist/assets/Network-Cymq4f9k.js +0 -1
  94. package/dist/assets/Notifications-Airu5OeS.js +0 -1
  95. package/dist/assets/Recordings-q5golvzT.js +0 -1
  96. package/dist/assets/SessionsList-C_zY2zSb.js +0 -2
  97. package/dist/assets/System-WwGShHpN.js +0 -1
  98. package/dist/assets/circle-slash-BiNjJGqu.js +0 -1
  99. package/dist/assets/crop-ByWrrroC.js +0 -1
  100. package/dist/assets/device-picker-model-DARErQpp.js +0 -1
  101. package/dist/assets/index-4-wf2dZY.css +0 -2
  102. package/dist/assets/index-L63cSV_9.js +0 -4
  103. package/dist/assets/location-owned-usage-Bv-8M-2g.js +0 -1
  104. package/dist/assets/mount-DARErQpp.js +0 -1
  105. package/dist/assets/notification-schedule-field-55LldawV.js +0 -1
  106. package/dist/assets/player-overlays-EDVR7CqJ.js +0 -1
  107. package/dist/assets/remoteEntry-BG8uep-b.js +0 -1
  108. package/dist/assets/src-BEsQ_4LU.js +0 -67
  109. package/dist/assets/useEventInvalidation-DARErQpp.js +0 -1
  110. package/dist/assets/user-round-WIoRKO7A.js +0 -1
@@ -1 +0,0 @@
1
- import{I as e,K as t,Q as n,S as r,W as i,b as a,o,q as s,x as c,z as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{E as u,I as d,X as f,at as p,ct as m,lt as h,st as g,vt as _}from"./player-overlays-EDVR7CqJ.js";import{Ao as v,Bo as y,Co as b,Do as x,Ef as S,Fn as C,Fo as w,Ft as T,Go as E,Hu as D,Io as ee,Iu as te,Ku as ne,Ld as re,Ln as ie,Lo as ae,Lu as oe,Mn as O,Mo as se,No as ce,Nt as le,Oo as ue,Po as de,Pt as fe,Rn as k,Ro as pe,To as me,Tr as A,Ul as he,Uo as ge,Wd as _e,Wo as ve,Xu as ye,_d as j,au as be,bu as M,cu as xe,da as Se,hd as Ce,jo as we,jt as Te,ko as Ee,kt as De,ku as Oe,nd as ke,rd as Ae,rf as je,rn as Me,rr as N,sd as P,wo as Ne,wr as F,yl as Pe,zo as Fe}from"./src-BEsQ_4LU.js";import{t as I}from"./boxes-EQnIjyQ5.js";import{Gn as Ie,Kn as Le,Un as Re,yn as ze}from"./client-B2uiK_6q.js";import"./mount-DARErQpp.js";import{c as L,rt as R,s as z,tt as Be}from"./index-L63cSV_9.js";import{t as Ve}from"./AdminPage-BSFohA3i.js";import{t as He}from"./NodeAddonsSettingsPanel-DsaDhenp.js";import{t as Ue}from"./AdminTabs-CYT0Gfgp.js";import{n as We,r as B,t as Ge}from"./AddonIntegrationBody-PmjCQ2Ms.js";import{n as V,t as H}from"./addon-display-names-BkwMrExv.js";var Ke=_(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),qe=_(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]);n();var U=5e3,W=`network-access`,Je={connected:!1,endpoint:null};function Ye(){let e=o(),t=A({capName:`network-access`},{refetchInterval:U}),n=F(void 0,{refetchInterval:U}),r=i(()=>H(n.data??[]),[n.data]),a=i(()=>(t.data??[]).map(e=>({addonId:e.addonId,displayName:r.get(e.addonId)??e.addonId,isActive:e.isActive})),[t.data,r]),[l,u]=s(null),[d,f]=s({}),p=(t,n)=>{let r=n?.addonId;e.invalidateQueries({queryKey:[[`networkAccess`,`getStatus`],{input:{addonId:r},type:`query`}]}),u(null),f(e=>{if(r===void 0||!(r in e))return e;let t={...e};return delete t[r],t})},m=(e,t)=>{u(null);let n=t?.addonId;if(n===void 0)return;let r=e instanceof Error?e.message:String(e);f(e=>({...e,[n]:r}))},h=ve({onSuccess:p,onError:m}),g=E({onSuccess:p,onError:m});return c(B,{icon:R,title:`Remote Access`,subtitle:`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …).`,groups:[{id:W,label:`Remote access`,install:{capability:W,label:`Add tunnel`},entries:a.map(e=>({id:e.addonId,name:e.displayName,fallbackIcon:R,...V(e.isActive),render:()=>c(Ge,{addonId:e.addonId,displayName:e.displayName,capName:W,isActive:e.isActive,badges:c(Ze,{addonId:e.addonId}),error:d[e.addonId]??null,primaryAction:c(Qe,{addonId:e.addonId,busyId:l,onStart:e=>{u(e),h.mutate({addonId:e})},onStop:e=>{u(e),g.mutate({addonId:e})}})})}))}],isLoading:t.isLoading,emptyTitle:`No remote-access providers installed`,emptyDescription:`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`})}function Xe(e){let{data:t}=ge({addonId:e},{refetchInterval:U,retry:!1}),n=t?Re.safeParse(t):null;return n?.success?n.data:Je}function Ze({addonId:e}){let t=Xe(e);return r(a,{children:[c(N,{variant:t.connected?`success`:`default`,className:We,children:t.connected?`Connected`:`Disconnected`}),t.endpoint&&r(`a`,{href:t.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:[c(re,{className:`h-3 w-3`}),t.endpoint.url]})]})}function Qe({addonId:e,busyId:t,onStart:n,onStop:i}){let a=Xe(e),o=t===e;return a.connected?r(k,{size:`sm`,variant:`secondary`,disabled:o,onClick:()=>i(e),children:[o?c(j,{className:`h-3 w-3 animate-spin`}):c(m,{className:`h-3 w-3`}),`Stop`]}):r(k,{size:`sm`,variant:`primary`,disabled:o,onClick:()=>n(e),children:[o?c(j,{className:`h-3 w-3 animate-spin`}):c(Ae,{className:`h-3 w-3`}),`Start`]})}n();var $e=3e4,G=`turn-provider`;function et(e){let t=[];for(let n of e)typeof n.urls==`string`?t.push(n.urls):t.push(...n.urls);return t}function tt(){let e=A({capName:`turn-provider`},{refetchInterval:$e}),t=F(void 0,{refetchInterval:$e}),n=Pe(),a=n.data??[],o=i(()=>H(t.data??[]),[t.data]),s=i(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:o.get(e.addonId)??e.addonId,isActive:e.isActive})),[e.data,o]);return c(B,{icon:P,title:`TURN Servers`,subtitle:`ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.`,groups:[{id:G,label:`TURN providers`,install:{capability:G,label:`Add provider`},entries:s.map(e=>({id:e.addonId,name:e.displayName,fallbackIcon:P,...V(e.isActive),render:()=>c(Ge,{addonId:e.addonId,displayName:e.displayName,capName:G,isActive:e.isActive,panels:[{id:`ice-servers`,title:`Discovered ICE servers`,icon:P,content:c(nt,{addonId:e.addonId,enabled:e.isActive})}]})}))}],isLoading:e.isLoading,emptyTitle:`No TURN providers installed`,emptyDescription:`Install a TURN addon (e.g. @camstack/addon-cloudflare) to enable WebRTC behind restrictive NATs.`,trailing:c(fe,{headingId:`turn-combined-ice`,title:`Combined ICE server list — all enabled providers`,icon:P,actions:c(k,{size:`sm`,variant:`secondary`,onClick:()=>n.refetch(),disabled:n.isFetching,children:`Refresh`}),children:c(`div`,{className:u,children:a.length===0?c(`div`,{className:`text-xs text-foreground-subtle`,children:`No servers from enabled providers.`}):c(`div`,{className:`flex flex-col gap-3`,children:a.map((e,t)=>{let n=Array.isArray(e.urls)?e.urls:[e.urls];return r(`div`,{className:`rounded border border-border bg-surface`,children:[(e.username||e.credential)&&r(`div`,{className:`px-3 py-1.5 border-b border-border text-[10px] font-mono text-foreground-subtle flex items-center gap-3`,children:[e.username&&r(`span`,{children:[c(`span`,{className:`text-foreground-subtle`,children:`user:`}),` `,c(`span`,{className:`text-foreground`,children:e.username})]}),e.credential&&r(`span`,{children:[c(`span`,{className:`text-foreground-subtle`,children:`credential:`}),` `,c(`span`,{className:`text-foreground`,children:`••••••••`})]})]}),c(`ul`,{className:`divide-y divide-border`,children:n.map(e=>c(`li`,{className:`px-3 py-1.5 font-mono text-xs text-foreground break-all`,children:e},e))})]},t)})})})})})}function nt({addonId:e,enabled:t}){let n=Pe({addonId:e},{enabled:t,retry:!1}),r=i(()=>et(n.data??[]),[n.data]),a=t?n.isLoading?`Loading…`:r.length===0?`This provider returned no servers.`:null:`Disabled — enable the provider to fetch its servers.`;return c(`div`,{className:`rounded-lg border border-border bg-surface p-2 sm:p-3`,children:a===null?c(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>c(`span`,{className:`inline-block break-all rounded bg-foreground-subtle/10 px-1.5 py-0.5 font-mono text-[10px] text-foreground`,children:e},e))}):c(`div`,{className:`text-xs text-foreground-subtle`,children:a})})}n();var rt={lan:P,wifi:xe,docker:I,vpn:Ce,loopback:D,other:D},it={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},at=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function ot(e){let{interfaces:t,disabled:n,hideLoopback:a,ipv4Only:o,emptyMessage:s}=e,l=i(()=>t.filter(e=>!(a&&e.kind===`loopback`||o&&e.family!==`IPv4`)),[t,a,o]),u=i(()=>{let e=new Map;for(let t of l){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return at.filter(t=>e.has(t)).map(t=>({kind:t,items:e.get(t)}))},[l]),d=t=>e.mode===`single`?e.value===t:e.value.includes(t),f=t=>{if(n||t.kind===`loopback`)return;if(e.mode===`single`){e.onChange(e.value===t.address?null:t.address);return}let r=new Set(e.value);r.has(t.address)?r.delete(t.address):r.add(t.address),e.onChange([...r])};return l.length===0?c(`div`,{className:`text-xs text-foreground-subtle italic`,children:s??`No addresses available.`}):c(`div`,{className:`flex flex-col gap-3`,children:u.map(({kind:t,items:i})=>r(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[r(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[c(rt[t]??D,{className:`h-3.5 w-3.5 text-foreground-subtle`}),c(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:it[t]??t}),r(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,i.length]})]}),c(`ul`,{className:`divide-y divide-border`,children:i.map(t=>{let i=d(t.address),a=t.kind===`loopback`,o=!t.plausible&&!a;return r(`li`,{className:`flex items-center gap-3 px-3 py-2 ${a?`opacity-60 cursor-not-allowed`:n?`opacity-60`:o?`cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]`:`cursor-pointer hover:bg-surface-hover/30`}`,onClick:()=>f(t),children:[c(`span`,{className:`flex items-center justify-center h-4 w-4 rounded ${e.mode===`single`?`rounded-full`:`rounded`} border ${i?`border-primary bg-primary text-primary-foreground`:`border-border bg-surface`}`,children:i&&c(je,{className:`h-3 w-3`})}),r(`div`,{className:`flex-1 min-w-0 ${o?`text-foreground-subtle`:``}`,children:[r(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[c(`span`,{className:`font-mono text-xs font-semibold ${o?`text-foreground-subtle`:`text-foreground`}`,children:t.name}),c(`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&&c(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:`Auto-preferred`}),a&&c(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:`Always included`}),o&&r(`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:[c(M,{className:`h-2.5 w-2.5`}),`Unlikely usable`]})]}),r(`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`,title:`App connections`,single:!1,help:`Addresses the CamStack apps try when connecting; tick several. Automatic: LAN addresses plus your public tunnel.`},{role:`notificationTaps`,title:`Notification taps`,single:!0,help:`Only where tapping a notification opens; one address. Automatic: the CamStack app link (opens the app if installed, otherwise the web app).`},{role:`publicEndpoint`,title:`Public endpoint`,single:!0,help:`Every link that must work away from home: sign-in, single sign-on and account linking, passkeys, and the buttons, attachments and admin links in notifications; one address. Automatic: your public tunnel, then Tailscale, then the LAN. Changing it invalidates registered passkeys.`},{role:`internal`,title:`Internal`,single:!0,help:`Where other CamStack machines and LAN devices download addons, models and media from; one address. Automatic: the hub's LAN address.`}],st=`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 ct(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 lt(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`}})}n();var ut={"lan-ipv4":{label:`IPv4`,className:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`},"lan-ipv6":{label:`IPv6`,className:`bg-violet-500/15 text-violet-700 dark:text-violet-300`},public:{label:`Public`,className:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},"app-link":{label:`App link`,className:`bg-amber-500/15 text-amber-700 dark:text-amber-300`},custom:{label:`Custom`,className:`bg-sky-500/15 text-sky-700 dark:text-sky-300`},loopback:{label:`Loopback`,className:`bg-foreground-subtle/15 text-foreground-subtle`}};function dt({book:e,loading:t,saving:n,error:i,onSetRole:a,onAdd:o,onRemove:l}){let[u,d]=s(``),[f,p]=s(``),[m,h]=s(null),[_,v]=s(null),y=()=>{let e=Le(u);if(!e.ok){h(e.reason);return}h(null),d(``),p(``),o(e.baseUrl,f.trim())},b=(e,t)=>{let n=ct(e,t.role);if(n.kind!==`none`){if(n.kind===`confirm-http`){v({input:n.input,reason:n.reason});return}v(null),a(n.input)}},x=[{key:`url`,header:`Address`,render:t=>r(`div`,{className:`min-w-0 py-0.5`,children:[c(`div`,{className:`font-mono text-[12px] break-all ${t.plausible?`text-foreground`:`text-foreground-subtle`}`,children:t.baseUrl}),r(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[c(`span`,{children:t.label}),t.kind===`app-link`&&r(`span`,{className:`font-mono`,children:[`hub= `,e?.appLinkHub??`none (no tunnel or Tailscale)`]}),t.custom&&t.detected&&c(`span`,{children:`also added as a custom address`}),t.kind!==`custom`&&t.interfaceKind!==`lan`&&t.interfaceKind!==`public`&&t.interfaceKind!==`other`&&c(`span`,{className:`uppercase tracking-wide`,children:t.interfaceKind}),!t.plausible&&t.interfaceKind!==`loopback`&&r(`span`,{className:`inline-flex items-center gap-1 text-amber-700 dark:text-amber-300`,title:t.plausibleReason||void 0,children:[c(M,{className:`h-2.5 w-2.5`}),`Unlikely usable`]})]})]})},{key:`kind`,header:`Kind`,nowrap:!0,render:e=>{let t=ut[e.kind]??ut.loopback;return c(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.className}`,children:t.label})}},...K.map(e=>({key:e.role,headerRender:()=>c(`span`,{title:e.help,children:e.title}),align:`center`,nowrap:!0,width:`w-24`,render:t=>{let i=t.eligible.includes(e.role),a=t.flags.includes(e.role),o=q(t,e.role);return r(`label`,{className:`inline-flex items-center justify-center gap-1 ${i?`cursor-pointer`:`cursor-not-allowed opacity-40`}`,title:i?o&&!a?`${e.title}: in use automatically. ${e.help}`:e.help:`This address cannot be used for this.`,children:[c(Me,{checked:i&&o,disabled:!i||n,onChange:()=>b(t,e),"aria-label":`${e.title}: ${t.baseUrl}`}),o&&!a&&i&&c(`span`,{className:`text-[9px] text-foreground-subtle`,children:`auto`})]})}})),{key:`actions`,header:``,align:`right`,nowrap:!0,render:e=>e.custom?c(k,{size:`sm`,variant:`ghost`,disabled:n,onClick:()=>l(e.baseUrl),"aria-label":`Remove ${e.baseUrl}`,title:`Remove this custom address (its roles turn automatic)`,children:c(g,{className:`h-3 w-3`})}):null}],S=e===void 0?[]:lt(e);return r(O,{children:[r(`div`,{className:`px-4 py-3 border-b border-border flex flex-col gap-2`,children:[r(`div`,{children:[c(`div`,{className:`text-sm font-semibold`,children:`Addresses`}),c(`div`,{className:`text-xs text-foreground-subtle max-w-3xl`,children:`Every address this hub is reached at, detected or added by you. Tick what each one is used for.`}),r(`details`,{className:`mt-1.5 text-xs max-w-3xl`,"data-testid":`address-roles-help`,children:[c(`summary`,{className:`cursor-pointer select-none text-foreground-subtle hover:text-foreground`,children:`What are roles?`}),c(`dl`,{className:`mt-1.5 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1`,children:K.map(e=>r(`div`,{className:`contents`,children:[c(`dt`,{className:`font-medium`,children:e.title}),c(`dd`,{className:`text-foreground-subtle`,children:e.help})]},e.role))}),c(`p`,{className:`mt-1.5 text-foreground-subtle`,children:st})]})]}),S.length>0&&c(`div`,{className:`grid grid-cols-[auto_1fr_auto] gap-x-3 gap-y-1 items-baseline text-xs`,"data-testid":`address-roles-summary`,children:S.map(e=>r(`div`,{className:`contents`,children:[c(`span`,{className:`text-foreground-subtle`,children:e.title}),r(`span`,{className:`font-mono break-all`,"data-testid":`address-role-${e.role}`,children:[e.inUse,c(`span`,{className:`ml-1.5 font-sans text-foreground-subtle`,children:e.automatic?`(automatic)`:`(set by you)`})]}),e.automatic?c(`span`,{}):c(k,{size:`sm`,variant:`secondary`,disabled:n,onClick:()=>a({role:e.role,baseUrl:null,enabled:!1}),children:`Use automatic`})]},e.role))}),_!==null&&r(`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:[c(M,{className:`h-3.5 w-3.5 text-amber-600`}),c(`span`,{className:`flex-1 min-w-[220px]`,children:_.reason}),c(k,{size:`sm`,variant:`secondary`,onClick:()=>{a({..._.input,acceptInsecureHttp:!0}),v(null)},children:`Use http anyway`}),c(k,{size:`sm`,variant:`ghost`,onClick:()=>v(null),children:`Cancel`})]}),i!==null&&c(`div`,{className:`text-[11px] text-red-600 dark:text-red-400`,role:`alert`,children:i})]}),c(T,{columns:x,rows:e?.rows??[],rowKey:e=>`${e.kind}-${e.baseUrl}`,minWidthPx:760,bordered:!1,mobileMode:`scroll`,emptyMessage:t?`Loading…`:`No addresses available.`,rowClassName:e=>e.plausible?void 0:`opacity-80`}),r(`div`,{className:`px-4 py-3 border-t border-border flex flex-wrap items-start gap-2`,children:[r(`div`,{className:`flex-1 min-w-[220px]`,children:[c(he,{value:u,onChange:e=>{d(e.target.value),h(null)},placeholder:`https://cams.example.com or https://192.168.1.50:4443`,"aria-label":`Custom address`,disabled:n}),m!==null&&c(`div`,{className:`mt-1 text-[11px] text-red-600 dark:text-red-400`,children:m})]}),c(`div`,{className:`w-48`,children:c(he,{value:f,onChange:e=>p(e.target.value),placeholder:`Label (optional)`,"aria-label":`Custom address label`,maxLength:80,disabled:n})}),r(k,{size:`sm`,variant:`secondary`,disabled:n||u.trim()===``,onClick:y,children:[c(ke,{className:`h-3 w-3`}),`Add custom address`]})]})]})}n();function ft(){let e=o(),t=()=>{e.invalidateQueries({queryKey:[[`localNetwork`]]})},n=ue(void 0,{refetchInterval:3e4}),a=me(void 0),u=de({onSuccess:t}),d=we({onSuccess:e=>{C(e.addresses),t()}}),f=i(()=>n.data?.interfaces??[],[n.data]),p=Ne({scheme:typeof window<`u`&&window.location.protocol===`https:`?`https`:`http`},{refetchInterval:3e4}),m=ce({onSuccess:t}),g=b({onSuccess:t}),_=v({onSuccess:t}),y=m.error?.message??g.error?.message??_.error?.message??null,x=m.isPending||g.isPending||_.isPending,[S,C]=s([]),[w,T]=s(!1);l(()=>{!w&&a.data&&(C(a.data.addresses),T(!0))},[a.data,w]);let E=a.data?.addresses??[],D=i(()=>{if(S.length!==E.length)return!0;let e=[...S].toSorted(),t=[...E].toSorted();return e.some((e,n)=>e!==t[n])},[S,E]);return r(Ve,{children:[r(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[c(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:`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.`}),c(`div`,{className:`flex items-center gap-2 shrink-0`,children:r(k,{size:`sm`,variant:`secondary`,onClick:()=>{n.refetch(),a.refetch(),p.refetch()},disabled:n.isLoading,children:[c(ye,{className:`h-3 w-3 ${n.isLoading?`animate-spin`:``}`}),`Refresh`]})})]}),r(O,{children:[r(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between gap-3 flex-wrap`,children:[r(`div`,{children:[c(`div`,{className:`text-sm font-semibold`,children:`Allowed addresses`}),c(`div`,{className:`text-xs text-foreground-subtle`,children:S.length===0?`Auto — every non-loopback / non-link-local interface participates.`:`${S.length} pinned`})]}),r(`div`,{className:`flex items-center gap-1`,children:[r(k,{size:`sm`,variant:`secondary`,onClick:()=>d.mutate(void 0),disabled:d.isPending||u.isPending,title:`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`,children:[c(Oe,{className:`h-3 w-3`}),d.isPending?`Detecting…`:`Best match`]}),r(k,{size:`sm`,variant:`secondary`,onClick:()=>{C([])},disabled:S.length===0||u.isPending,children:[c(h,{className:`h-3 w-3`}),`Clear`]}),D&&c(k,{size:`sm`,variant:`secondary`,onClick:()=>{C(E)},disabled:u.isPending,children:`Discard`}),r(k,{size:`sm`,variant:`primary`,onClick:()=>{u.mutate({addresses:[...S]})},disabled:!D||u.isPending,children:[c(ne,{className:`h-3 w-3`}),u.isPending?`Saving…`:`Save`]})]})]}),c(`div`,{className:`p-4`,children:c(ot,{mode:`multiple`,interfaces:f,value:S,onChange:C,disabled:u.isPending,emptyMessage:n.isLoading?`Loading interfaces…`:`No interfaces detected.`})})]}),c(dt,{book:p.data,loading:p.isLoading,saving:x,error:y,onSetRole:e=>m.mutate({...e}),onAdd:(e,t)=>g.mutate({baseUrl:e,label:t}),onRemove:e=>_.mutate({baseUrl:e})})]})}n();var pt={mesh:`bg-violet-500/15 text-violet-700 dark:text-violet-300`,public:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},J=5e3,Y=`mesh-network`,mt=3e4,ht={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function gt(){let e=A({capName:`mesh-network`},{refetchInterval:J}),t=F(void 0,{refetchInterval:J}),n=i(()=>H(t.data??[]),[t.data]),r=i(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:n.get(e.addonId)??e.addonId,isActive:e.isActive})),[e.data,n]);return c(B,{icon:I,title:`Mesh Networks`,subtitle:`Private VPN meshes that connect CamStack to your other devices (Tailscale, Headscale, …). Each provider can also expose this hub publicly via its ingress (Tailscale Funnel).`,groups:[{id:Y,label:`Mesh networks`,install:{capability:Y,label:`Add mesh`},entries:r.map(e=>({id:e.addonId,name:e.displayName,fallbackIcon:P,...V(e.isActive),render:()=>c(Ge,{addonId:e.addonId,displayName:e.displayName,capName:Y,isActive:e.isActive,badges:c(_t,{addonId:e.addonId}),primaryAction:c(vt,{addonId:e.addonId}),panels:[{id:`status`,title:`Status`,icon:I,content:c(yt,{addonId:e.addonId})}]})}))}],isLoading:e.isLoading,emptyTitle:`No mesh-network providers installed`,emptyDescription:`Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.`})}function X(e){let{data:t,isLoading:n}=ee({addonId:e},{refetchInterval:J,retry:!1}),r=t?ze.safeParse(t):null;return{status:r?.success?r.data:ht,isLoading:n}}function _t({addonId:e}){let{status:t}=X(e);return r(a,{children:[c(N,{variant:t.joined?`success`:`default`,className:We,children:t.joined?`Joined`:`Not joined`}),t.joined&&r(N,{className:`text-[10px]`,children:[t.peerCount,` peer`,t.peerCount===1?``:`s`]})]})}function vt({addonId:t}){let n=o(),[i,l]=s(!1),[u,d]=s(null),f=p(),{status:m}=X(t),h=e(()=>{n.invalidateQueries({queryKey:[[`meshNetwork`]]})},[n]),g=y(),_=ae({onSuccess:h}),v=Fe({onSuccess:h}),b=e(async()=>{l(!0);let e={cancelled:!1};d(e);try{let n=await g.mutateAsync({addonId:t});if(e.cancelled)return;n.loginUrl&&window.open(n.loginUrl,`_blank`,`noopener,noreferrer`);let r=Date.now();for(;!e.cancelled&&(await Et(2e3),!e.cancelled);){let e=await f.trpcClient.meshNetwork.getStatus.query({addonId:t}).catch(()=>null),n=e?ze.safeParse(e):null;if(n?.success&&n.data.joined){h();break}if(Date.now()-r>6e5)break}}finally{l(!1),d(null)}},[t,h,g,f]),x=e(()=>{u&&(u.cancelled=!0),l(!1),d(null)},[u]);return c(a,{children:m.joined?r(a,{children:[r(k,{size:`sm`,variant:`secondary`,disabled:_.isPending,onClick:()=>_.mutate({addonId:t}),children:[_.isPending?c(j,{className:`h-3 w-3 animate-spin`}):c(Be,{className:`h-3 w-3`}),`Disconnect`]}),r(k,{size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>v.mutate({addonId:t}),children:[v.isPending?c(j,{className:`h-3 w-3 animate-spin`}):c(oe,{className:`h-3 w-3`}),`Log out`]})]}):i?r(k,{size:`sm`,variant:`ghost`,onClick:x,children:[c(be,{className:`h-3 w-3 mr-1`}),` Cancel`]}):r(a,{children:[r(k,{size:`sm`,variant:`primary`,onClick:()=>void b(),children:[c(qe,{className:`h-3 w-3`}),`Connect`]}),r(k,{size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>v.mutate({addonId:t}),children:[v.isPending?c(j,{className:`h-3 w-3 animate-spin`}):c(oe,{className:`h-3 w-3`}),`Log out`]})]})})}function yt({addonId:e}){let{status:t}=X(e),n=pe({addonId:e},{refetchInterval:mt,retry:!1});return r(`div`,{className:`rounded-lg border border-border bg-surface`,children:[r(`div`,{className:`space-y-4 p-2 sm:p-4`,children:[t.error&&c(C,{message:t.error}),c(bt,{status:t}),t.endpoints.length>0&&r(`div`,{className:`space-y-1.5`,children:[c(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:`Endpoints`}),t.endpoints.map(e=>r(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${pt[e.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[e.scope===`public`?c(R,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,e.label]}),r(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1`,children:[c(re,{className:`h-3 w-3 shrink-0`}),e.url]})]},e.id))]})]}),c(`div`,{className:`border-t border-border`,children:c(St,{peers:n.data?.peers??[],loading:n.isLoading})})]})}function bt({status:e}){return c(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5`,children:[{label:`Tenant`,value:e.tenantName||`—`},{label:`User`,value:e.userLogin??`—`},{label:`Control plane`,value:e.controlPlaneUrl||`—`},{label:`Mesh IP`,value:e.meshIp||`—`,mono:!0},{label:`MagicDNS`,value:e.magicDnsHostname||`—`,mono:!0},{label:`DNS suffix`,value:e.magicDnsSuffix||`—`,mono:!0},{label:`Peers`,value:String(e.peerCount)},{label:`Key expiry`,value:e.keyExpiry?xt(e.keyExpiry):`—`}].map(e=>r(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[c(`span`,{className:`text-foreground-subtle shrink-0`,children:e.label}),c(`span`,{className:`text-foreground truncate ${e.mono?`font-mono`:``}`,children:e.value})]},e.label))})}function xt(e){let t=e-Date.now();if(t<0)return`Expired ${Tt(e)}`;let n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return`in ${n} days`;let r=Math.floor(t/36e5);return r>1?`in ${r}h`:`in ${Math.max(1,Math.floor(t/6e4))} min`}function St({peers:t,loading:n}){let a=i(()=>t.map(e=>({...e,_id:e.id})),[t]),o=e(e=>{e&&navigator.clipboard?.writeText(e)},[]),s=i(()=>[{key:`hostname`,header:`Hostname`,render:e=>r(`div`,{className:`flex flex-col`,children:[r(`div`,{className:`flex items-center gap-1.5`,children:[c(`span`,{className:`font-medium text-foreground`,children:e.hostname||`(unknown)`}),e.isSelf&&c(N,{variant:`info`,children:`self`}),e.exitNodeOption&&c(N,{variant:`warning`,children:`exit-node`})]}),e.userLogin&&c(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.userLogin})]})},{key:`magicDns`,header:`MagicDNS`,render:e=>e.magicDns?r(`div`,{className:`flex items-center gap-1`,children:[c(`span`,{className:`font-mono text-xs truncate`,children:e.magicDns}),c(`button`,{onClick:()=>o(e.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":`Copy MagicDNS`,children:c(_e,{className:`h-3 w-3 text-foreground-subtle`})})]}):c(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:e=>{let t=e.addresses[0]??``;return t?r(`div`,{className:`flex items-center gap-1`,children:[c(`span`,{className:`font-mono text-xs`,children:t}),c(`button`,{onClick:()=>o(t),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":`Copy IP`,children:c(_e,{className:`h-3 w-3 text-foreground-subtle`})})]}):c(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:`Connection`,render:e=>r(`div`,{className:`flex items-center gap-1.5`,children:[c(N,{variant:Ct(e.connection),children:e.connection}),e.relay&&c(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.relay})]})},{key:`routes`,header:`Routes`,render:e=>e.advertisedRoutes.length>0?c(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):c(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:`TX / RX`,render:e=>r(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,wt(e.txBytes),` · ↓ `,wt(e.rxBytes)]})},{key:`lastSeen`,header:`Last seen`,render:e=>c(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?Tt(e.lastSeenMs):`—`})}],[o]);return n&&t.length===0?r(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[c(j,{className:`h-3 w-3 animate-spin inline mr-1`}),` Loading peers…`]}):t.length===0?c(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:`No peers visible — your tailnet may be empty or the host is not joined.`}):c(`div`,{className:`p-4`,children:c(T,{columns:s,rows:a,rowKey:e=>e._id,minWidthPx:820})})}function Ct(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function wt(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 Tt(e){let t=Date.now()-e;return t<6e4?`just now`:t<36e5?`${Math.round(t/6e4)}m ago`:t<864e5?`${Math.round(t/36e5)}h ago`:`${Math.round(t/864e5)}d ago`}function Et(e){return new Promise(t=>setTimeout(t,e))}var Dt=/-----BEGIN CERTIFICATE-----[\s\S]+?-----END CERTIFICATE-----/,Z=/-----BEGIN ((?:RSA |EC |ENCRYPTED )?PRIVATE KEY)-----[\s\S]+?-----END \1-----/,Ot={certificate:`.pem,.crt,.cer`,privateKey:`.pem,.key`,ca:`.pem,.crt,.cer`};function Q(e,t){if(t.trim()===``)return null;if(e===`privateKey`){let e=Z.exec(t);return e===null?Dt.test(t)?`This is a certificate, not a private key.`:`Not a PEM private key — expected -----BEGIN … PRIVATE KEY-----.`:e[1]===`ENCRYPTED PRIVATE KEY`?`The private key is password-protected. Export it without a passphrase.`:null}return Dt.test(t)?e===`certificate`&&Z.test(t)?`This file also contains a private key. Pick the certificate file, and the key in its own field.`:null:Z.test(t)?`This is a private key, not a certificate.`:`Not a PEM certificate — expected -----BEGIN CERTIFICATE-----.`}function kt(e){return e.text()}n();function $({kind:e,label:n,value:i,onChange:a,rows:o=6}){let l=t(null),[u,d]=s(null),[f,p]=s(null),m=f??Q(e,i),h=`pem-${e}`,g=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t!==void 0){d(t.name);try{let e=await kt(t);p(null),a(e)}catch(e){p(`Could not read ${t.name}: ${e instanceof Error?e.message:String(e)}`)}}};return r(`div`,{className:`space-y-1`,children:[r(`div`,{className:`flex items-center justify-between gap-2`,children:[c(`label`,{htmlFor:h,className:`text-[11px] text-foreground-subtle`,children:n}),r(`div`,{className:`flex min-w-0 items-center gap-2`,children:[u!==null&&c(`span`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,"data-testid":`${h}-file-name`,children:u}),c(`input`,{ref:l,type:`file`,accept:Ot[e],onChange:e=>void g(e),className:`hidden`,"data-testid":`${h}-file`}),r(k,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>l.current?.click(),children:[c(Ke,{className:`mr-1 h-3 w-3`}),`Choose file`]})]})]}),c(`textarea`,{id:h,value:i,onChange:e=>{d(null),p(null),a(e.target.value)},rows:o,"aria-invalid":m!==null,className:`w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`}),m!==null&&c(`p`,{className:`text-[11px] text-danger`,role:`alert`,children:m})]})}n();function At(e){if(e===null||e===``)return`—`;let t=e.replace(/:/g,``);return t.length<=16?e:`${t.slice(0,8)}…${t.slice(-8)}`}function jt(){let e=o(),t=x(void 0,{refetchInterval:15e3}),n=Ee({onSuccess:()=>void e.invalidateQueries({queryKey:[[`localNetwork`]]})}),i=se({onSuccess:()=>void e.invalidateQueries({queryKey:[[`localNetwork`]]})}),a=w({onSuccess:()=>{d(!1),p(``),h(``),_(``),e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),l=t.data,[u,d]=s(!1),[f,p]=s(``),[m,h]=s(``),[g,_]=s(``),v=()=>{if(!l?.caCertPem)return;let e=new Blob([l.caCertPem],{type:`application/x-pem-file`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`camstack-ca.crt`,n.click(),URL.revokeObjectURL(t)},y=l?.mode===`uploaded`?`Uploaded`:l?.mode===`generated`?`Generated local CA`:`TLS disabled`;return r(`div`,{className:`flex flex-col gap-4`,children:[c(He,{nodeId:`hub`,addonIds:[`local-network`],level:`global`,title:`LAN HTTP`,description:`Native apps on this Wi-Fi use http:// and skip the private certificate. The tunnel and this admin UI stay on HTTPS.`}),r(O,{className:`p-4 space-y-3`,children:[r(`div`,{className:`flex items-center gap-2`,children:[c(te,{className:`h-4 w-4 text-foreground-subtle`}),c(`h3`,{className:`text-sm font-semibold`,children:`Certificate`})]}),t.isError&&c(`p`,{className:`text-xs text-danger`,children:`Could not read TLS status.`}),l?.reissueError&&c(`p`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:l.reissueError}),l?.restartRequired&&c(`p`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:`The HTTPS listener still serves the previous certificate. Restart the hub to apply it.`}),r(`dl`,{className:`grid grid-cols-1 gap-2 text-xs sm:grid-cols-2`,children:[r(`div`,{children:[c(`dt`,{className:`text-foreground-subtle`,children:`Mode`}),c(`dd`,{className:`font-medium`,children:y})]}),r(`div`,{children:[c(`dt`,{className:`text-foreground-subtle`,children:`Valid to`}),c(`dd`,{className:`font-mono`,children:l?.validTo?new Date(l.validTo).toLocaleString():`—`})]}),r(`div`,{children:[c(`dt`,{className:`text-foreground-subtle`,children:`Leaf SHA-256`}),c(`dd`,{className:`font-mono`,title:l?.leafFingerprintSha256??void 0,children:At(l?.leafFingerprintSha256??null)})]}),r(`div`,{children:[c(`dt`,{className:`text-foreground-subtle`,children:`CA SHA-256`}),c(`dd`,{className:`font-mono`,title:l?.caFingerprintSha256??void 0,children:l?.mode===`uploaded`&&l.caFingerprintSha256===null?c(`span`,{className:`font-sans text-foreground-subtle`,children:`Issuer not included in the upload (not the local CA)`}):At(l?.caFingerprintSha256??null)})]})]}),l&&l.sans.length>0&&c(`div`,{className:`flex flex-wrap gap-1`,children:l.sans.map(e=>c(`span`,{className:`rounded border border-border bg-surface px-1.5 py-0.5 font-mono text-[10px] text-foreground-subtle`,children:e},e))}),r(`div`,{className:`flex flex-wrap gap-2`,children:[c(De,{label:`Regenerate`,title:`Issue a new leaf?`,description:`Issues a new leaf under the current local CA. Clients that trust the CA keep working. The HTTPS listener reloads.`,confirmLabel:`Regenerate`,disabled:l?.mode===`uploaded`||n.isPending,action:()=>n.mutateAsync({})}),c(k,{size:`sm`,variant:`outline`,onClick:()=>d(e=>!e),children:`Upload`}),l?.caCertPem&&c(k,{size:`sm`,variant:`outline`,onClick:v,children:`Download CA`}),l?.mode===`uploaded`&&c(De,{label:`Revert to generated`,title:`Drop the uploaded certificate?`,description:`Deletes the uploaded pair and returns to the generated local CA.`,confirmLabel:`Revert`,confirmVariant:`danger`,disabled:i.isPending,action:()=>i.mutateAsync({})})]}),u&&r(`div`,{className:`space-y-2 border-t border-border pt-3`,children:[c($,{kind:`certificate`,label:`Certificate or full chain (PEM)`,value:f,onChange:p}),c($,{kind:`privateKey`,label:`Private key (PEM)`,value:m,onChange:h}),c($,{kind:`ca`,label:`CA (PEM, optional)`,value:g,onChange:_,rows:4}),c(k,{size:`sm`,disabled:!f.trim()||!m.trim()||Q(`certificate`,f)!==null||Q(`privateKey`,m)!==null||Q(`ca`,g)!==null||a.isPending,onClick:()=>a.mutate({certPem:f,keyPem:m,...g.trim()?{caPem:g}:{}}),children:`Save certificate`}),a.isError&&c(`p`,{className:`text-xs text-danger`,children:a.error instanceof Error?a.error.message:`Upload failed`})]})]})]})}n();function Mt({value:e,onChange:t}){let{data:n}=Se({isCamera:!0,projection:`slim`}),a=i(()=>n===void 0?[{value:``,label:`Loading cameras…`}]:n.length===0?[{value:``,label:`No cameras`}]:[{value:``,label:`Pick a camera`},...n.toSorted((e,t)=>e.name.localeCompare(t.name)).map(e=>({value:String(e.id),label:`${e.name} (#${String(e.id)})`}))],[n]);return r(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[c(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Camera`}),c(ie,{value:e===null?``:String(e),disabled:n===void 0||n.length===0,onChange:e=>t(e.target.value===``?null:Number(e.target.value)),options:a})]})}function Nt(){let t=p(),[n,i]=s(null);return r(`div`,{className:d,"data-testid":`network-diagnostics`,children:[c(le,{loadServers:e(async()=>t.trpcClient.turnProvider.getTurnServers.query(),[t])}),c(Te,{trpc:t.trpcClient,serverUrl:f(),deviceId:n,cameraField:c(Mt,{value:n,onChange:i})})]})}function Pt(){return c(`div`,{className:`flex flex-col p-4`,children:c(Ue,{defaultTab:`addresses`,tabs:[{id:`local-access`,label:`Local access`,icon:xe,content:c(jt,{})},{id:`addresses`,label:`Network Addresses`,icon:D,content:c(ft,{})},{id:L.remoteAccess.tab,label:`Remote Access`,icon:R,content:c(Ye,{}),ownedParams:z},{id:L.mesh.tab,label:`Mesh Networks`,icon:I,content:c(gt,{}),ownedParams:z},{id:L.turn.tab,label:`TURN Servers`,icon:P,content:c(tt,{}),ownedParams:z},{id:`diagnostics`,label:`Diagnostics`,icon:S,content:c(Nt,{})}]})})}export{Pt as NetworkPage};