@camstack/addon-admin-ui 1.2.394 → 1.2.395

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 (105) hide show
  1. package/dist/assets/{AddonAssetIcon-PX0PCLUm.js → AddonAssetIcon-FEGKo28x.js} +1 -1
  2. package/dist/assets/{AddonIntegrationBody-BgNzJfzz.js → AddonIntegrationBody-CZ_SMYjZ.js} +1 -1
  3. package/dist/assets/Addons-dEYeo7li.js +4 -0
  4. package/dist/assets/{AdminPage-Ccko8XOt.js → AdminPage-B7I2XO2q.js} +1 -1
  5. package/dist/assets/{AdminSectionedPage-BqT-O1Ug.js → AdminSectionedPage-C7anFHfv.js} +1 -1
  6. package/dist/assets/AiProfiles-CBu3vQeN.js +3 -0
  7. package/dist/assets/{BrokerForm-CpcSsQ4A.js → BrokerForm-DpBUImR2.js} +1 -1
  8. package/dist/assets/Build-E8TQPXfd.js +40 -0
  9. package/dist/assets/{Calendars-C1eiaJQQ.js → Calendars-DreZgwDO.js} +1 -1
  10. package/dist/assets/Cluster-DhnCX88J.js +1 -0
  11. package/dist/assets/ClusterStepModel-J4nDcf59.js +1 -0
  12. package/dist/assets/CompositionEditor-DK3yjuNm.js +1 -0
  13. package/dist/assets/{CompositionEditorPage-Bmewszxx.js → CompositionEditorPage-DHv2e06Y.js} +1 -1
  14. package/dist/assets/Data-DrJMlo9o.js +1 -0
  15. package/dist/assets/DeviceDetail-C4qvSMLv.js +2 -0
  16. package/dist/assets/{DeviceDoActionFields-CpQQLEo3.js → DeviceDoActionFields-CBUTSIW-.js} +1 -1
  17. package/dist/assets/{Devices-Rda31uPt.js → Devices-6y1s1r-T.js} +1 -1
  18. package/dist/assets/{EmbedPlayerPage-81ABVyUx.js → EmbedPlayerPage-Bladso_c.js} +1 -1
  19. package/dist/assets/Identity-tRJdTJFN.js +1 -0
  20. package/dist/assets/IntegrationDetail-VaUgudpQ.js +1 -0
  21. package/dist/assets/{Integrations-BBABh2Sq.js → Integrations-CJ0F5ZD7.js} +1 -1
  22. package/dist/assets/Integrations-CY0E5kJ1.js +1 -0
  23. package/dist/assets/Library-r83QKIKQ.js +1 -0
  24. package/dist/assets/Locations-8EWTyXEb.js +3 -0
  25. package/dist/assets/{Logs-DN3WcfRH.js → Logs-DRzfpDLQ.js} +1 -1
  26. package/dist/assets/{MotionZonesSettings-DFhkBHHi.js → MotionZonesSettings-BQocc7WN.js} +1 -1
  27. package/dist/assets/MyAccess-CSqoH_mI.js +2 -0
  28. package/dist/assets/Network-Bma8q14Y.js +1 -0
  29. package/dist/assets/{NodeAddonsSettingsPanel-gVh6goGP.js → NodeAddonsSettingsPanel-BLMQKF0T.js} +1 -1
  30. package/dist/assets/Notifications-ynDs0ycO.js +1 -0
  31. package/dist/assets/{PrivacyMaskSettings-CsUxVJgb.js → PrivacyMaskSettings-CIOFdwm5.js} +1 -1
  32. package/dist/assets/Recordings-BZvCmChu.js +1 -0
  33. package/dist/assets/{ScanNetworkModal-ByT_uvZs.js → ScanNetworkModal-DGWOoMeh.js} +1 -1
  34. package/dist/assets/{SceneMonitorEditor-Di3PrRej.js → SceneMonitorEditor-B4Xa4X5o.js} +1 -1
  35. package/dist/assets/SessionsList-DIVp5W-M.js +2 -0
  36. package/dist/assets/{Showroom-CNtcbY0o.js → Showroom-CqBL5kcD.js} +1 -1
  37. package/dist/assets/System-DcV7OF-e.js +1 -0
  38. package/dist/assets/{Terminal-BMZSMqYb.js → Terminal-BLww-Pey.js} +3 -3
  39. package/dist/assets/{Viewer-D4GsLVhJ.js → Viewer-B4tfa9_m.js} +1 -1
  40. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CFI31sbl.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CCX4N_tI.js} +1 -1
  41. package/dist/assets/{archive-Cq7Q671I.js → archive-C3YvN3bo.js} +1 -1
  42. package/dist/assets/{authed-media-CISY9dK4.js → authed-media-Dsm5tJaX.js} +1 -1
  43. package/dist/assets/{boxes-Ce8hfJ-o.js → boxes-I78qynMn.js} +1 -1
  44. package/dist/assets/circle-slash-C5FeKGvp.js +1 -0
  45. package/dist/assets/client-D5nV-lIF.js +357 -0
  46. package/dist/assets/crop-GRVPmcCZ.js +1 -0
  47. package/dist/assets/{device-integration-icon-C1oZIVhF.js → device-integration-icon-CPSRSU_Z.js} +1 -1
  48. package/dist/assets/device-picker-model-Bmmfvons.js +1 -0
  49. package/dist/assets/{dist-CupWZjfQ.js → dist-BXnRXTui.js} +1 -1
  50. package/dist/assets/dist-CgEPs7ts.js +357 -0
  51. package/dist/assets/{format-size-D_6sdKDR.js → format-size-D8E_VMta.js} +1 -1
  52. package/dist/assets/{history-CLsNYHLd.js → history-GFLGqkV_.js} +1 -1
  53. package/dist/assets/{hostInit-BWjHlc06.js → hostInit-Cx87lec5.js} +1 -1
  54. package/dist/assets/index-CennI0xU.js +4 -0
  55. package/dist/assets/{layers-YRqpOayh.js → layers-D5TeeKqH.js} +1 -1
  56. package/dist/assets/{location-owned-usage-B3ZO__Bi.js → location-owned-usage-CSkMjjDS.js} +1 -1
  57. package/dist/assets/{mf-entry-bootstrap-0-2fa138d2.js → mf-entry-bootstrap-0-e66fcc21.js} +2 -2
  58. package/dist/assets/{monitor-smartphone-C2NdwxYA.js → monitor-smartphone-CEvv3FjX.js} +1 -1
  59. package/dist/assets/mount-Bmmfvons.js +1 -0
  60. package/dist/assets/notification-schedule-field-BkGcrBEQ.js +1 -0
  61. package/dist/assets/{octagon-alert-C5RXFyhj.js → octagon-alert-bX5m_c3-.js} +1 -1
  62. package/dist/assets/{player-overlays-CBTVvmtR.js → player-overlays-mP7nvLXZ.js} +1 -1
  63. package/dist/assets/remoteEntry-CSjqSCSq.js +1 -0
  64. package/dist/assets/{send-Czk7WmfN.js → send-3vh-Sv9u.js} +1 -1
  65. package/dist/assets/{settings-2-Dd3PO3xO.js → settings-2-CIYonoB2.js} +1 -1
  66. package/dist/assets/{src-BKb_GHfb.js → src-BxKcTTXr.js} +17 -17
  67. package/dist/assets/{use-scenes-feed-C4gT7pmA.js → use-scenes-feed-vbRcJK3J.js} +1 -1
  68. package/dist/assets/{use-stationary-objects-B3RmpT6r.js → use-stationary-objects-C6ZG9dij.js} +1 -1
  69. package/dist/assets/useEventInvalidation-Bmmfvons.js +1 -0
  70. package/dist/assets/{useNodeUrlSelection-C2Dxs6t6.js → useNodeUrlSelection-BkPpkeyo.js} +1 -1
  71. package/dist/assets/user-round-D2N1DqIB.js +1 -0
  72. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DBIfxGgj.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Bren3gP2.js} +2 -2
  73. package/dist/index.html +7 -7
  74. package/dist/server/addon.js +90 -5
  75. package/package.json +1 -1
  76. package/dist/assets/Addons-ciobVr5M.js +0 -4
  77. package/dist/assets/AiProfiles-tG6rXUH4.js +0 -3
  78. package/dist/assets/Build-55tKM9Wz.js +0 -40
  79. package/dist/assets/Cluster-Ccf2IjzA.js +0 -1
  80. package/dist/assets/ClusterStepModel-CNfhTaBP.js +0 -1
  81. package/dist/assets/CompositionEditor-C4snHgsF.js +0 -1
  82. package/dist/assets/Data-BzOjum8b.js +0 -1
  83. package/dist/assets/DeviceDetail-ChPGcn07.js +0 -2
  84. package/dist/assets/Identity-BJsl2-Wp.js +0 -1
  85. package/dist/assets/IntegrationDetail-D1MuLzod.js +0 -1
  86. package/dist/assets/Integrations-DB4KVFwu.js +0 -1
  87. package/dist/assets/Library-DCifUT3C.js +0 -1
  88. package/dist/assets/Locations-DZruUFrD.js +0 -3
  89. package/dist/assets/MyAccess-Cr69geQV.js +0 -2
  90. package/dist/assets/Network-BdbxHiSg.js +0 -1
  91. package/dist/assets/Notifications-C2oGyYcG.js +0 -1
  92. package/dist/assets/Recordings-DoAlF0Z0.js +0 -1
  93. package/dist/assets/SessionsList-ePFiMCWf.js +0 -2
  94. package/dist/assets/System-C9QZlKzX.js +0 -1
  95. package/dist/assets/circle-slash-CfpZBSNu.js +0 -1
  96. package/dist/assets/client-xvFMsLS8.js +0 -357
  97. package/dist/assets/crop-COex1hdf.js +0 -1
  98. package/dist/assets/device-picker-model-DxC8Nuyz.js +0 -1
  99. package/dist/assets/dist-DNQmiuXZ.js +0 -357
  100. package/dist/assets/index-C2Rnaj3T.js +0 -4
  101. package/dist/assets/mount-DxC8Nuyz.js +0 -1
  102. package/dist/assets/notification-schedule-field-BDktK0jx.js +0 -1
  103. package/dist/assets/remoteEntry-B1tiLlqM.js +0 -1
  104. package/dist/assets/useEventInvalidation-DxC8Nuyz.js +0 -1
  105. package/dist/assets/user-round-DECuoAzZ.js +0 -1
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./browser-BHo8W_uH.js","./rolldown-runtime-Cyuzqnbw.js"])))=>i.map(i=>d[i]);
2
- import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{t}from"./vite-preload-helper-kNaey6uv.js";import{K as n,Q as r,S as i,W as a,a as o,b as s,q as c,t as l,x as u,z as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Q as f,ct as p,ot as m}from"./player-overlays-CBTVvmtR.js";import{Ad as h,Bu as g,Cd as _,Dd as v,Ft as y,Gn as b,No as x,On as S,Ou as C,Qd as w,Td as T,Wd as E,Wn as D,Yn as O,Z as k,cf as A,du as j,jd as ee,jo as te,kn as ne,nr as M,pd as N,sf as P}from"./src-BKb_GHfb.js";import{t as F}from"./monitor-smartphone-C2NdwxYA.js";import{a as I,b as L,i as R,r as re,t as ie}from"./SessionsList-ePFiMCWf.js";import{Jn as ae,qn as oe}from"./client-xvFMsLS8.js";import{t as z}from"./useTranslation-Bc5yH9V9.js";import"./mount-DxC8Nuyz.js";import{R as B,i as V,n as H,r as U,t as W,tt as G}from"./index-C2Rnaj3T.js";import{t as K}from"./AdminPage-Ccko8XOt.js";r();function q({value:n,size:r=192}){let[a,o]=c(null),[s,l]=c(null);if(d(()=>{let r=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(r)return;let t=e.create;if(typeof t!=`function`){l(`qrcode.create() unavailable in installed version`);return}try{let e=t(n,{errorCorrectionLevel:`M`});r||o(e)}catch(e){r||l(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{r||l(`qrcode library not installed`)}),()=>{r=!0}},[n]),s)return u(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:r,height:r},children:`QR rendering unavailable — use the secret below.`});if(!a)return u(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:r,height:r},children:`Generating…`});let f=a.modules.size,p=r/f,m=[];for(let e=0;e<f;e++)for(let t=0;t<f;t++)a.modules.data[e*f+t]&&m.push(u(`rect`,{x:t*p,y:e*p,width:p,height:p,fill:`currentColor`},`${t}-${e}`));return i(`svg`,{width:r,height:r,viewBox:`0 0 ${r} ${r}`,className:`text-black`,children:[u(`rect`,{x:0,y:0,width:r,height:r,fill:`white`}),m]})}var se=`${oe}/connect`,J={public:0,mesh:1,lan:2,"lan-ipv6":3};function ce(e){switch(e.kind){case`public`:return e.interfaceKind===`vpn`?`mesh`:`public`;case`lan-ipv4`:return`lan`;case`lan-ipv6`:return`lan-ipv6`;case`custom`:return`public`;case`loopback`:case`app-link`:return null}}function Y(e){return ae(e)}function le(e){return e.startsWith(`https://`)}function ue(e){let t=e.flatMap(e=>{let t=ce(e),n=Y(e.baseUrl);return t===null||n===null?[]:[{endpoint:e,tier:t,origin:n}]}).toSorted((e,t)=>J[e.tier]-J[t.tier]||Number(t.endpoint.plausible)-Number(e.endpoint.plausible)||e.endpoint.priority-t.endpoint.priority),n=new Set;return t.flatMap(({endpoint:e,tier:t,origin:r})=>n.has(r)?[]:(n.add(r),[{origin:r,label:e.label,tier:t,secure:le(r),plausible:e.plausible}]))}function de(e,t,n=null){for(let r of[t,n]){if(r===null)continue;let t=Y(r),n=e.find(e=>e.origin===t);if(n!==void 0)return n}return e[0]??null}function fe(e){let t=new URL(se);return t.searchParams.set(`hub`,e),t.toString()}r();var pe=176,X={scheme:`https`};function me(){let{t:e}=z(),t=x(X),n=te(X).data?.roles.publicEndpoint.resolved??null;return i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[i(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[u(g,{className:`h-3.5 w-3.5 text-foreground-subtle`}),u(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`connectPhone.title`)})]}),i(`div`,{className:`p-4 space-y-3`,children:[u(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`connectPhone.description`)}),t.isPending?i(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[u(T,{className:`h-3.5 w-3.5 animate-spin`}),e(`connectPhone.loading`)]}):t.isError?i(`div`,{className:`flex items-start gap-2 text-[11px] text-danger`,children:[u(C,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),i(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[u(`div`,{className:`break-words`,children:e(`connectPhone.error`,{message:t.error.message})}),u(b,{size:`sm`,variant:`ghost`,onClick:()=>void t.refetch(),children:e(`connectPhone.retry`)})]})]}):u(he,{candidates:ue(t.data.endpoints),preferredOrigin:n})]})]})}function he({candidates:e,preferredOrigin:t}){let{t:n}=z(),[r,o]=c(null),s=de(e,r,t),l=a(()=>s?fe(s.origin):null,[s]);if(s===null||l===null)return u(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`connectPhone.empty`)});let d=e=>n(`connectPhone.tier.${e}`),f=e.map(e=>({value:e.origin,label:`${d(e.tier)} — ${e.origin}`}));return i(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:[u(S,{value:l,size:pe,alt:n(`connectPhone.qrAlt`),className:`self-start`}),i(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[i(`label`,{className:`block space-y-1`,children:[u(`span`,{className:`text-[11px] font-medium text-foreground`,children:n(`connectPhone.addressLabel`)}),u(D,{value:s.origin,options:f,onChange:e=>o(e.target.value)}),i(`span`,{className:`block text-[10px] text-foreground-subtle`,children:[d(s.tier),` · `,s.label]})]}),!s.secure&&u(Z,{text:n(`connectPhone.insecure`)}),!s.plausible&&u(Z,{text:n(`connectPhone.implausible`)}),i(`div`,{className:`space-y-1`,children:[u(`span`,{className:`text-[11px] font-medium text-foreground`,children:n(`connectPhone.linkLabel`)}),i(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[u(`code`,{className:`flex-1 min-w-0 font-mono text-[11px] text-foreground break-all select-all`,children:l}),u(y,{value:l,srLabel:n(`connectPhone.linkLabel`)})]})]}),u(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`connectPhone.signInHint`)})]})]})}function Z({text:e}){return i(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-1.5 text-[11px] text-foreground`,children:[u(C,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),u(`span`,{children:e})]})}r();function ge(e){return new Date(e).toLocaleDateString()}function _e(){let e=M(),t=j.useUtils(),r=j.auth.listLinkableProviders.useQuery(),a=j.auth.listOwnExternalIdentities.useQuery(),[o,s]=c(null),[l,p]=c(()=>V(window.location.search)),m=n(null),h=R(`Linking a sign-in account`),g=n(null);d(()=>()=>g.current?.(),[]);let[_,y]=c(null);d(()=>{if(l===null)return;let e=new URL(window.location.href);e.searchParams.delete(`linked`),e.searchParams.delete(`linkError`),window.history.replaceState({},``,e.pathname+e.search+e.hash)},[l]);let b=j.auth.beginExternalLink.useMutation({onSuccess:({url:e})=>{let n=m.current;if(m.current=null,n===null||n.closed){window.location.assign(e);return}let r=e=>{y(null),p(V(`?${e}`)),t.auth.listOwnExternalIdentities.invalidate()};g.current?.(),g.current=H(n,{onReturn:e=>{e.target===`profile`&&r(e.query)},onDone:e=>{e.target===`profile`&&r(e.query)},onClosed:()=>{g.current?.(),g.current=null,t.auth.listOwnExternalIdentities.invalidate()}}),n.location.href=f(U(e))},onError:e=>{m.current?.close(),m.current=null,y(null),s(e.message)}}),x=j.auth.unlinkOwnExternalIdentity.useMutation({onSuccess:()=>void t.auth.listOwnExternalIdentities.invalidate(),onError:e=>s(e.message)}),S=r.data??[],C=a.data??[],w=_!==null&&C.some(e=>e.provider===_);if(d(()=>{!w||_===null||(y(null),p({kind:`linked`,provider:_}))},[w,_]),S.length===0&&C.length===0)return null;let E=new Set(C.map(e=>e.provider)),D=e=>S.find(t=>t.provider===e)?.label??e,O=async(t,n)=>{await e({title:`Unlink sign-in account`,message:`Stop signing in with this ${n} account?`,confirmLabel:`Unlink`,variant:`danger`})&&(s(null),x.mutate({provider:t.provider,subject:t.subject}))};return i(`div`,{"data-testid":`linked-sign-ins`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[h.dialog,i(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[u(v,{className:`h-3.5 w-3.5 text-foreground-subtle`}),u(`div`,{className:`text-xs font-semibold text-foreground`,children:`Linked sign-in accounts`})]}),i(`div`,{className:`p-4 space-y-3`,children:[u(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Sign in with an external account instead of your password. Only accounts you link here can sign you in; your two-factor authentication still applies.`}),l?.kind===`linked`&&i(`div`,{className:`flex items-center gap-2 rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2 text-xs text-foreground`,children:[u(P,{className:`h-3.5 w-3.5 text-emerald-500 shrink-0`}),`Linked your `,D(l.provider),` account.`]}),(l?.kind===`error`||o)&&i(`div`,{className:`flex items-center gap-2 rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[u(A,{className:`h-3.5 w-3.5 shrink-0`}),o??(l?.kind===`error`?l.message:``)]}),C.length>0&&u(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:C.map(e=>{let t=e.providerLabel??e.provider;return i(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`font-medium text-foreground truncate`,children:[t,!e.available&&u(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:`provider unavailable`})]}),i(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:[e.label??e.subject,` · linked `,ge(e.linkedAt)]})]}),i(`button`,{onClick:()=>void O(e,t),disabled:x.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[u(L,{className:`h-3 w-3`}),`Unlink`]})]},`${e.provider}|${e.subject}`)})}),u(`div`,{className:`flex flex-wrap gap-2`,children:S.filter(e=>!E.has(e.provider)).map(e=>i(`button`,{onClick:()=>{s(null),p(null),h.requestProof().then(t=>{t!==null&&(m.current=W(null),y(m.current===null?null:e.provider),b.mutate({provider:e.provider,reauthToken:t}))})},disabled:b.isPending,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[b.isPending&&b.variables?.provider===e.provider?u(T,{className:`h-3 w-3 animate-spin`}):u(v,{className:`h-3 w-3`}),`Link `,e.label]},e.provider))})]})]})}r();function Q(e){return e.message.length>0?e.message:`Request failed`}function ve(){let{logout:e}=B(),t=M(),n=j.useUtils(),r=j.auth.listOwnSessions.useQuery(),[a,o]=c(null),s=j.auth.revokeOwnSession.useMutation({onSuccess:()=>void n.auth.listOwnSessions.invalidate(),onError:e=>o(`Sign out failed: ${Q(e)}`)}),l=j.auth.logout.useMutation({onSuccess:()=>e(),onError:e=>o(`Sign out failed: ${Q(e)}`)}),d=async e=>{await t({title:`Sign out this session`,message:`${I(e.client).label} will have to sign in again.`,confirmLabel:`Sign out`,variant:`danger`})&&(o(null),s.mutate({id:e.id}))},f=async()=>{await t({title:`Sign out everywhere`,message:`Every session of your account ends, this browser included: you will be signed out here too and every device has to sign in again.`,confirmLabel:`Sign out everywhere`,variant:`danger`})&&(o(null),l.mutate({everywhere:!0}))};return i(`div`,{"data-testid":`my-sessions`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[i(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[u(F,{className:`h-3.5 w-3.5 text-foreground-subtle`}),u(`div`,{className:`text-xs font-semibold text-foreground`,children:`Active sessions`})]}),i(`div`,{className:`p-4 space-y-3`,children:[u(`p`,{className:`text-[11px] text-foreground-subtle`,children:`The browsers and apps signed in to your account. Signing one out ends it at once.`}),a!==null&&u(`div`,{className:`text-[11px] text-danger`,children:a}),u(ie,{sessions:r.data??[],isLoading:r.isLoading,loadError:r.isError?r.error?.message??`Request failed`:null,emptyText:`No active sessions.`,onRevoke:e=>void d(e),revokingId:s.isPending?s.variables?.id??null:null}),u(`div`,{className:`flex justify-end`,children:i(`button`,{onClick:()=>void f(),disabled:l.isPending,className:`inline-flex items-center gap-1.5 rounded border border-danger/40 px-2.5 py-1 text-[11px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,children:[l.isPending?u(T,{className:`h-3 w-3 animate-spin`}):u(G,{className:`h-3 w-3`}),`Sign out everywhere`]})})]})]})}r();var ye={view:{icon:E,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:N,cls:`bg-primary/15 text-primary`},delete:{icon:p,cls:`bg-danger/15 text-danger`}};function be(){let{user:e,logout:t}=B();if(!e)return u(K,{children:u(`div`,{className:`text-xs text-foreground-subtle`,children:`Not signed in.`})});let n=e.isAdmin,r=e.scopes??[];return i(K,{children:[i(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[u(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:e.username.slice(0,1).toUpperCase()}),i(`div`,{className:`flex-1 min-w-0`,children:[u(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),i(`div`,{className:`text-[11px] text-foreground-subtle`,children:[n?`Administrator`:`User`,` · session id`,` `,i(`span`,{className:`font-mono`,children:[e.id.slice(0,8),`…`]})]})]})]}),n&&i(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5`,children:[u(ee,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),i(`div`,{children:[u(`div`,{className:`font-semibold text-foreground`,children:`Unrestricted access`}),u(`p`,{className:`text-foreground-subtle mt-0.5`,children:`Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below.`})]})]}),u(xe,{}),u(Se,{username:e.username}),u(Ce,{}),u(_e,{}),u(re,{}),u(ve,{}),u(me,{}),r.length>0&&i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[i(`div`,{className:`px-4 py-2 border-b border-border`,children:[u(`div`,{className:`text-xs font-semibold text-foreground`,children:`Granted scopes`}),u(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Baked into your session token at login; sign out + back in to refresh after changes.`})]}),i(`div`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[u(`div`,{children:`Type`}),u(`div`,{children:`Target`}),u(`div`,{children:`Access`})]}),u(`ul`,{className:`divide-y divide-border`,children:r.map((e,t)=>i(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[u(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),u(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?k(e.selector):e.target}),u(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(t=>{let n=e.access.includes(t),{icon:r,cls:a}=ye[t];return i(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${n?a:`bg-transparent text-foreground-subtle/40 line-through`}`,title:n?`Can ${t}`:`Cannot ${t}`,children:[u(r,{className:`h-3 w-3`}),t]},t)})})]},t))})]}),u(`div`,{className:`flex justify-end`,children:i(`button`,{onClick:t,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground transition-colors`,children:[u(G,{className:`h-3 w-3`}),`Sign out`]})})]})}function xe(){let e=m(),[t,n]=c(``),[r,a]=c(``),[o,s]=c(``),[d,f]=c(null),p=l({mutationFn:t=>e.changeOwnPassword(t),onSuccess:()=>{f({kind:`success`,msg:`Password updated.`}),n(``),a(``),s(``)},onError:e=>{f({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),g=r.length>0&&o.length>0&&r!==o,v=r.length>0&&r.length<8,y=t.length>=1&&r.length>=8&&r===o;return i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[i(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[u(h,{className:`h-3.5 w-3.5 text-foreground-subtle`}),u(`div`,{className:`text-xs font-semibold text-foreground`,children:`Change password`})]}),i(`div`,{className:`p-4 space-y-3`,children:[u($,{label:`Current password`,value:t,onChange:n,autoComplete:`current-password`}),u($,{label:`New password`,value:r,onChange:a,autoComplete:`new-password`,hint:`At least 8 characters.`}),u($,{label:`Confirm new password`,value:o,onChange:s,autoComplete:`new-password`}),(g||v)&&u(`div`,{className:`text-[11px] text-danger`,children:g?`Passwords do not match.`:`New password must be at least 8 characters.`}),d&&i(`div`,{className:`text-[11px] flex items-center gap-1 ${d.kind===`success`?`text-emerald-500`:`text-danger`}`,children:[d.kind===`success`?u(P,{className:`h-3 w-3`}):u(A,{className:`h-3 w-3`}),d.msg]}),u(`div`,{className:`flex justify-end`,children:i(`button`,{onClick:()=>{f(null),p.mutate({currentPassword:t,newPassword:r})},disabled:!y||p.isPending,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[p.isPending?u(T,{className:`h-3 w-3 animate-spin`}):u(_,{className:`h-3 w-3`}),`Update password`]})})]})]})}function $({label:e,value:t,onChange:n,autoComplete:r,hint:a}){return i(`div`,{className:`space-y-1`,children:[u(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),u(`input`,{type:`password`,value:t,onChange:e=>n(e.target.value),autoComplete:r,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),a&&u(`div`,{className:`text-[10px] text-foreground-subtle`,children:a})]})}function Se({username:e}){let t=m(),n=o({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>t.getOwnTotpStatus()}),r=n.data,[f,p]=c(null),[h,_]=c(``),[v,y]=c(null),[b,x]=c(!1),S=l({mutationFn:()=>t.setupOwnTotp(),onSuccess:e=>{p({secret:e.secret,otpauthUrl:e.otpauthUrl}),_(``),y(null)},onError:e=>y(e instanceof Error?e.message:`Setup failed`)}),C=l({mutationFn:e=>t.confirmOwnTotp(e),onSuccess:()=>{p(null),_(``),y(null),n.refetch()},onError:e=>y(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),E=R(`Turning off two-factor authentication`),D=l({mutationFn:async()=>{let e=await E.requestProof();return e===null?null:t.disableOwnTotp({reauthToken:e})},onSuccess:()=>{y(null),n.refetch()},onError:e=>y(e instanceof Error?e.message:`Disable failed`)});d(()=>{if(!b)return;let e=setTimeout(()=>x(!1),1500);return()=>clearTimeout(e)},[b]);let O=a(()=>n.isLoading?`loading`:f?`setup_in_progress`:r?.enabled?`enrolled`:`not_enrolled`,[n.isLoading,r?.enabled,f]);return i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[E.dialog,i(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[u(g,{className:`h-3.5 w-3.5 text-foreground-subtle`}),u(`div`,{className:`text-xs font-semibold text-foreground`,children:`Two-factor authentication`})]}),i(`div`,{className:`p-4 space-y-3`,children:[O===`loading`&&i(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[u(T,{className:`h-3.5 w-3.5 animate-spin`}),`Checking status…`]}),O===`not_enrolled`&&i(s,{children:[u(`div`,{className:`text-xs text-foreground-subtle`,children:`2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login.`}),u(`div`,{className:`flex justify-end`,children:i(`button`,{onClick:()=>{y(null),S.mutate()},disabled:S.isPending,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[S.isPending?u(T,{className:`h-3 w-3 animate-spin`}):u(g,{className:`h-3 w-3`}),`Enable 2FA`]})})]}),O===`setup_in_progress`&&f&&i(s,{children:[i(`div`,{className:`text-[11px] text-foreground-subtle`,children:[`Scan the QR code (or enter the secret manually) into your authenticator app for`,` `,u(`span`,{className:`font-mono`,children:e}),`, then enter the 6-digit code below to confirm.`]}),i(`div`,{className:`flex flex-col items-center gap-3`,children:[u(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:u(q,{value:f.otpauthUrl,size:180})}),i(`div`,{className:`w-full`,children:[u(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:`Secret (manual entry)`}),i(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[u(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:f.secret}),i(`button`,{onClick:()=>{f&&navigator.clipboard.writeText(f.secret).then(()=>x(!0))},className:`inline-flex items-center gap-1 text-[10px] text-foreground-subtle hover:text-foreground`,children:[b?u(P,{className:`h-3 w-3 text-emerald-500`}):u(w,{className:`h-3 w-3`}),b?`Copied`:`Copy`]})]})]})]}),i(`div`,{className:`space-y-1`,children:[u(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),u(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:h,onChange:e=>_(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary`})]}),v&&i(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[u(A,{className:`h-3 w-3`}),v]}),i(`div`,{className:`flex justify-end gap-2`,children:[u(`button`,{onClick:()=>{p(null),y(null),_(``)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),i(`button`,{onClick:()=>{y(null),C.mutate({code:h})},disabled:C.isPending||h.length!==6,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[C.isPending?u(T,{className:`h-3 w-3 animate-spin`}):u(P,{className:`h-3 w-3`}),`Confirm`]})]})]}),O===`enrolled`&&r&&i(s,{children:[i(`div`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2.5 flex items-start gap-2.5`,children:[u(P,{className:`h-4 w-4 mt-0.5 text-emerald-500 shrink-0`}),i(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[u(`div`,{className:`font-medium`,children:`2FA is active`}),i(`div`,{className:`text-foreground-subtle`,children:[`Enrolled on`,` `,r.confirmedAt?new Date(r.confirmedAt).toLocaleString():`—`]})]})]}),v&&i(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[u(A,{className:`h-3 w-3`}),v]}),u(`div`,{className:`flex justify-end`,children:i(`button`,{onClick:()=>{y(null),D.mutate()},disabled:D.isPending,className:`rounded bg-danger px-3 py-1.5 text-xs font-medium text-white hover:bg-danger/90 disabled:opacity-50 inline-flex items-center gap-1`,children:[D.isPending?u(T,{className:`h-3 w-3 animate-spin`}):u(g,{className:`h-3 w-3`}),`Disable 2FA`]})})]})]})]})}function Ce(){return O(`auth-webauthn/passkey-enrollment`)?u(ne,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}export{be as MyAccessPage};
@@ -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{D as u,L as d,Z as f,ct as p,lt as m,ot as h,ut as g,yt as _}from"./player-overlays-CBTVvmtR.js";import{Ao as v,Bo as y,Bt as b,Cd as x,El as S,Fo as ee,Gd as C,Gn as w,Go as T,Gu as E,Hn as D,Ho as O,Ht as k,Io as te,It as ne,Ko as re,Lo as ie,Lu as ae,Mo as oe,Mr as A,Ou as j,Po as se,Qd as ce,Qo as le,Ro as ue,Rt as de,Td as M,Uo as fe,Vo as pe,Vt as N,Wn as me,Wo as he,Wu as ge,Xo as _e,Xu as P,Zl as ve,Zo as ye,dd as be,df as xe,ed as Se,gu as Ce,hd as F,id as we,jo as Te,jr as I,pu as Ee,qo as De,ud as Oe,un as ke,ur as L,va as Ae,zn as je,zo as Me}from"./src-BKb_GHfb.js";import{t as R}from"./boxes-Ce8hfJ-o.js";import{Gn as Ne,Kn as Pe,Un as Fe,yn as Ie}from"./client-xvFMsLS8.js";import{t as Le}from"./useTranslation-Bc5yH9V9.js";import"./mount-DxC8Nuyz.js";import{C as Re,c as z,rt as B,s as V,tt as ze}from"./index-C2Rnaj3T.js";import{t as Be}from"./AdminSectionedPage-BqT-O1Ug.js";import{t as H}from"./AdminPage-Ccko8XOt.js";import{t as Ve}from"./NodeAddonsSettingsPanel-gVh6goGP.js";import{n as He,r as U,t as W}from"./AddonIntegrationBody-BgNzJfzz.js";import{n as G,t as K}from"./addon-display-names-BkwMrExv.js";var Ue=_(`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`}]]),We=_(`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 q=5e3,J=`network-access`,Ge={connected:!1,endpoint:null};function Ke(){let e=o(),t=A({capName:`network-access`},{refetchInterval:q}),n=I(void 0,{refetchInterval:q}),r=i(()=>K(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=ye({onSuccess:p,onError:m}),g=le({onSuccess:p,onError:m});return c(U,{embedded:!0,icon:B,title:`Remote Access`,subtitle:`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …).`,groups:[{id:J,label:`Remote access`,install:{capability:J,label:`Add tunnel`},entries:a.map(e=>({id:e.addonId,name:e.displayName,fallbackIcon:B,...G(e.isActive),render:()=>c(W,{addonId:e.addonId,displayName:e.displayName,capName:J,isActive:e.isActive,badges:c(Je,{addonId:e.addonId}),error:d[e.addonId]??null,primaryAction:c(Ye,{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 qe(e){let{data:t}=_e({addonId:e},{refetchInterval:q,retry:!1}),n=t?Fe.safeParse(t):null;return n?.success?n.data:Ge}function Je({addonId:e}){let t=qe(e);return r(a,{children:[c(L,{variant:t.connected?`success`:`default`,className:He,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(C,{className:`h-3 w-3`}),t.endpoint.url]})]})}function Ye({addonId:e,busyId:t,onStart:n,onStop:i}){let a=qe(e),o=t===e;return a.connected?r(w,{size:`sm`,variant:`secondary`,disabled:o,onClick:()=>i(e),children:[o?c(M,{className:`h-3 w-3 animate-spin`}):c(m,{className:`h-3 w-3`}),`Stop`]}):r(w,{size:`sm`,variant:`primary`,disabled:o,onClick:()=>n(e),children:[o?c(M,{className:`h-3 w-3 animate-spin`}):c(be,{className:`h-3 w-3`}),`Start`]})}n();var Xe=3e4,Y=`turn-provider`;function Ze(e){let t=[];for(let n of e)typeof n.urls==`string`?t.push(n.urls):t.push(...n.urls);return t}function Qe(){let e=A({capName:`turn-provider`},{refetchInterval:Xe}),t=I(void 0,{refetchInterval:Xe}),n=S(),a=n.data??[],o=i(()=>K(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(U,{embedded:!0,icon:F,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:Y,label:`TURN providers`,install:{capability:Y,label:`Add provider`},entries:s.map(e=>({id:e.addonId,name:e.displayName,fallbackIcon:F,...G(e.isActive),render:()=>c(W,{addonId:e.addonId,displayName:e.displayName,capName:Y,isActive:e.isActive,panels:[{id:`ice-servers`,title:`Discovered ICE servers`,icon:F,content:c($e,{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(N,{headingId:`turn-combined-ice`,title:`Combined ICE server list — all enabled providers`,icon:F,actions:c(w,{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 $e({addonId:e,enabled:t}){let n=S({addonId:e},{enabled:t,retry:!1}),r=i(()=>Ze(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 et={lan:F,wifi:Ce,docker:R,vpn:x,loopback:P,other:P},tt={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},nt=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function rt(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 nt.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(et[t]??P,{className:`h-3.5 w-3.5 text-foreground-subtle`}),c(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:tt[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(xe,{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(j,{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 X=[{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.`}],it=`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 Z(e,t){return e.inUse.includes(t)}function at(e,t){if(!e.eligible.includes(t))return{kind:`none`};if(e.kind===`app-link`)return Z(e,t)?{kind:`none`}:{kind:`set`,input:{role:t,baseUrl:null,enabled:!0}};if(e.flags.includes(t)||t===`appConnections`&&Z(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:Ne}:{kind:`set`,input:n}}function ot(e){return X.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 st={"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 ct({book:e,loading:t,saving:n,error:i,onSetRole:a,onAdd:o,onRemove:l}){let[u,d]=s(``),[f,m]=s(``),[h,g]=s(null),[_,v]=s(null),y=()=>{let e=Pe(u);if(!e.ok){g(e.reason);return}g(null),d(``),m(``),o(e.baseUrl,f.trim())},b=(e,t)=>{let n=at(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(j,{className:`h-2.5 w-2.5`}),`Unlikely usable`]})]})]})},{key:`kind`,header:`Kind`,nowrap:!0,render:e=>{let t=st[e.kind]??st.loopback;return c(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.className}`,children:t.label})}},...X.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=Z(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(ke,{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(w,{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(p,{className:`h-3 w-3`})}):null}],S=e===void 0?[]:ot(e);return r(je,{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:X.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:it})]})]}),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(w,{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(j,{className:`h-3.5 w-3.5 text-amber-600`}),c(`span`,{className:`flex-1 min-w-[220px]`,children:_.reason}),c(w,{size:`sm`,variant:`secondary`,onClick:()=>{a({..._.input,acceptInsecureHttp:!0}),v(null)},children:`Use http anyway`}),c(w,{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(k,{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(ve,{value:u,onChange:e=>{d(e.target.value),g(null)},placeholder:`https://cams.example.com or https://192.168.1.50:4443`,"aria-label":`Custom address`,disabled:n}),h!==null&&c(`div`,{className:`mt-1 text-[11px] text-red-600 dark:text-red-400`,children:h})]}),c(`div`,{className:`w-48`,children:c(ve,{value:f,onChange:e=>m(e.target.value),placeholder:`Label (optional)`,"aria-label":`Custom address label`,maxLength:80,disabled:n})}),r(w,{size:`sm`,variant:`secondary`,disabled:n||u.trim()===``,onClick:y,children:[c(Oe,{className:`h-3 w-3`}),`Add custom address`]})]})]})}n();function lt(){let e=o(),t=()=>{e.invalidateQueries({queryKey:[[`localNetwork`]]})},n=ee(void 0,{refetchInterval:3e4}),a=oe(void 0),d=pe({onSuccess:t}),f=ue({onSuccess:e=>{T(e.addresses),t()}}),p=i(()=>n.data?.interfaces??[],[n.data]),m=Te({scheme:typeof window<`u`&&window.location.protocol===`https:`?`https`:`http`},{refetchInterval:3e4}),h=y({onSuccess:t}),_=v({onSuccess:t}),b=ie({onSuccess:t}),x=h.error?.message??_.error?.message??b.error?.message??null,S=h.isPending||_.isPending||b.isPending,[C,T]=s([]),[E,D]=s(!1);l(()=>{!E&&a.data&&(T(a.data.addresses),D(!0))},[a.data,E]);let O=a.data?.addresses??[],k=i(()=>{if(C.length!==O.length)return!0;let e=[...C].toSorted(),t=[...O].toSorted();return e.some((e,n)=>e!==t[n])},[C,O]);return r(H,{embedded:!0,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(w,{size:`sm`,variant:`secondary`,onClick:()=>{n.refetch(),a.refetch(),m.refetch()},disabled:n.isLoading,children:[c(we,{className:`h-3 w-3 ${n.isLoading?`animate-spin`:``}`}),`Refresh`]})})]}),c(N,{headingId:`network-allowed-addresses`,title:`Allowed addresses`,actions:r(`div`,{className:`flex flex-wrap items-center gap-1`,children:[r(w,{size:`sm`,variant:`secondary`,onClick:()=>f.mutate(void 0),disabled:f.isPending||d.isPending,title:`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`,children:[c(ae,{className:`h-3 w-3`}),f.isPending?`Detecting…`:`Best match`]}),r(w,{size:`sm`,variant:`secondary`,onClick:()=>{T([])},disabled:C.length===0||d.isPending,children:[c(g,{className:`h-3 w-3`}),`Clear`]}),k&&c(w,{size:`sm`,variant:`secondary`,onClick:()=>{T(O)},disabled:d.isPending,children:`Discard`}),r(w,{size:`sm`,variant:`primary`,onClick:()=>{d.mutate({addresses:[...C]})},disabled:!k||d.isPending,children:[c(Se,{className:`h-3 w-3`}),d.isPending?`Saving…`:`Save`]})]}),children:r(`div`,{className:u,children:[c(`p`,{className:`mb-3 text-xs text-foreground-subtle`,children:C.length===0?`Auto — every non-loopback / non-link-local interface participates.`:`${String(C.length)} pinned`}),c(rt,{mode:`multiple`,interfaces:p,value:C,onChange:T,disabled:d.isPending,emptyMessage:n.isLoading?`Loading interfaces…`:`No interfaces detected.`})]})}),c(ct,{book:m.data,loading:m.isLoading,saving:S,error:x,onSetRole:e=>h.mutate({...e}),onAdd:(e,t)=>_.mutate({baseUrl:e,label:t}),onRemove:e=>b.mutate({baseUrl:e})})]})}n();var ut={mesh:`bg-violet-500/15 text-violet-700 dark:text-violet-300`,public:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},Q=5e3,dt=`mesh-network`,ft=3e4,pt={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function mt(){let e=A({capName:`mesh-network`},{refetchInterval:Q}),t=I(void 0,{refetchInterval:Q}),n=i(()=>K(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(U,{embedded:!0,icon:R,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:dt,label:`Mesh networks`,install:{capability:dt,label:`Add mesh`},entries:r.map(e=>({id:e.addonId,name:e.displayName,fallbackIcon:F,...G(e.isActive),render:()=>c(W,{addonId:e.addonId,displayName:e.displayName,capName:dt,isActive:e.isActive,badges:c(gt,{addonId:e.addonId}),primaryAction:c(_t,{addonId:e.addonId}),panels:[{id:`status`,title:`Status`,icon:R,content:c(vt,{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 ht(e){let{data:t,isLoading:n}=fe({addonId:e},{refetchInterval:Q,retry:!1}),r=t?Ie.safeParse(t):null;return{status:r?.success?r.data:pt,isLoading:n}}function gt({addonId:e}){let{status:t}=ht(e);return r(a,{children:[c(L,{variant:t.joined?`success`:`default`,className:He,children:t.joined?`Joined`:`Not joined`}),t.joined&&r(L,{className:`text-[10px]`,children:[t.peerCount,` peer`,t.peerCount===1?``:`s`]})]})}function _t({addonId:t}){let n=o(),[i,l]=s(!1),[u,d]=s(null),f=h(),{status:p}=ht(t),m=e(()=>{n.invalidateQueries({queryKey:[[`meshNetwork`]]})},[n]),g=De(),_=he({onSuccess:m}),v=re({onSuccess:m}),y=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 Tt(2e3),!e.cancelled);){let e=await f.trpcClient.meshNetwork.getStatus.query({addonId:t}).catch(()=>null),n=e?Ie.safeParse(e):null;if(n?.success&&n.data.joined){m();break}if(Date.now()-r>6e5)break}}finally{l(!1),d(null)}},[t,m,g,f]),b=e(()=>{u&&(u.cancelled=!0),l(!1),d(null)},[u]);return c(a,{children:p.joined?r(a,{children:[r(w,{size:`sm`,variant:`secondary`,disabled:_.isPending,onClick:()=>_.mutate({addonId:t}),children:[_.isPending?c(M,{className:`h-3 w-3 animate-spin`}):c(ze,{className:`h-3 w-3`}),`Disconnect`]}),r(w,{size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>v.mutate({addonId:t}),children:[v.isPending?c(M,{className:`h-3 w-3 animate-spin`}):c(E,{className:`h-3 w-3`}),`Log out`]})]}):i?r(w,{size:`sm`,variant:`ghost`,onClick:b,children:[c(Ee,{className:`h-3 w-3 mr-1`}),` Cancel`]}):r(a,{children:[r(w,{size:`sm`,variant:`primary`,onClick:()=>void y(),children:[c(We,{className:`h-3 w-3`}),`Connect`]}),r(w,{size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>v.mutate({addonId:t}),children:[v.isPending?c(M,{className:`h-3 w-3 animate-spin`}):c(E,{className:`h-3 w-3`}),`Log out`]})]})})}function vt({addonId:e}){let{status:t}=ht(e),n=T({addonId:e},{refetchInterval:ft,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(D,{message:t.error}),c(yt,{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 ${ut[e.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[e.scope===`public`?c(B,{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(C,{className:`h-3 w-3 shrink-0`}),e.url]})]},e.id))]})]}),c(`div`,{className:`border-t border-border`,children:c(xt,{peers:n.data?.peers??[],loading:n.isLoading})})]})}function yt({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?bt(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 bt(e){let t=e-Date.now();if(t<0)return`Expired ${wt(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 xt({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(L,{variant:`info`,children:`self`}),e.exitNodeOption&&c(L,{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(ce,{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(ce,{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(L,{variant:St(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:[`↑ `,Ct(e.txBytes),` · ↓ `,Ct(e.rxBytes)]})},{key:`lastSeen`,header:`Last seen`,render:e=>c(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?wt(e.lastSeenMs):`—`})}],[o]);return n&&t.length===0?r(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[c(M,{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(k,{columns:s,rows:a,rowKey:e=>e._id,minWidthPx:820})})}function St(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function Ct(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 wt(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 Tt(e){return new Promise(t=>setTimeout(t,e))}var Et=/-----BEGIN CERTIFICATE-----[\s\S]+?-----END CERTIFICATE-----/,Dt=/-----BEGIN ((?:RSA |EC |ENCRYPTED )?PRIVATE KEY)-----[\s\S]+?-----END \1-----/,Ot={certificate:`.pem,.crt,.cer`,privateKey:`.pem,.key`,ca:`.pem,.crt,.cer`};function $(e,t){if(t.trim()===``)return null;if(e===`privateKey`){let e=Dt.exec(t);return e===null?Et.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 Et.test(t)?e===`certificate`&&Dt.test(t)?`This file also contains a private key. Pick the certificate file, and the key in its own field.`:null:Dt.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 At({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??$(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(w,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>l.current?.click(),children:[c(Ue,{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 jt(e){if(e===null||e===``)return`—`;let t=e.replace(/:/g,``);return t.length<=16?e:`${t.slice(0,8)}…${t.slice(-8)}`}function Mt(){let e=o(),t=se(void 0,{refetchInterval:15e3}),n=te({onSuccess:()=>void e.invalidateQueries({queryKey:[[`localNetwork`]]})}),i=Me({onSuccess:()=>void e.invalidateQueries({queryKey:[[`localNetwork`]]})}),a=O({onSuccess:()=>{p(!1),h(``),_(``),y(``),e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),l=t.data,[f,p]=s(!1),[m,h]=s(``),[g,_]=s(``),[v,y]=s(``),b=()=>{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)},x=l?.mode===`uploaded`?`Uploaded`:l?.mode===`generated`?`Generated local CA`:`TLS disabled`;return c(H,{embedded:!0,children:r(`div`,{className:d,children:[c(Ve,{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.`}),c(N,{headingId:`local-access-certificate`,title:`Certificate`,icon:ge,children:r(`div`,{className:`${u} space-y-3`,children:[t.isError&&c(`p`,{className:`text-xs text-danger`,children:`Could not read TLS status.`}),l?.reissueError&&c(D,{variant:`warning`,title:`Certificate reissue`,message:l.reissueError}),l?.restartRequired&&c(D,{variant:`warning`,title:`Restart required`,message:`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:x})]}),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:jt(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)`}):jt(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(ne,{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(w,{size:`sm`,variant:`outline`,onClick:()=>p(e=>!e),children:`Upload`}),l?.caCertPem&&c(w,{size:`sm`,variant:`outline`,onClick:b,children:`Download CA`}),l?.mode===`uploaded`&&c(ne,{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({})})]}),f&&r(`div`,{className:`space-y-2 border-t border-border pt-3`,children:[c(At,{kind:`certificate`,label:`Certificate or full chain (PEM)`,value:m,onChange:h}),c(At,{kind:`privateKey`,label:`Private key (PEM)`,value:g,onChange:_}),c(At,{kind:`ca`,label:`CA (PEM, optional)`,value:v,onChange:y,rows:4}),c(w,{size:`sm`,disabled:!m.trim()||!g.trim()||$(`certificate`,m)!==null||$(`privateKey`,g)!==null||$(`ca`,v)!==null||a.isPending,onClick:()=>a.mutate({certPem:m,keyPem:g,...v.trim()?{caPem:v}:{}}),children:`Save certificate`}),a.isError&&c(`p`,{className:`text-xs text-danger`,children:a.error instanceof Error?a.error.message:`Upload failed`})]})]})})]})})}n();function Nt({value:e,onChange:t}){let{data:n}=Ae({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(me,{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 Pt(){let t=h(),[n,i]=s(null);return c(H,{embedded:!0,children:r(`div`,{className:d,"data-testid":`network-diagnostics`,children:[c(b,{loadServers:e(async()=>t.trpcClient.turnProvider.getTurnServers.query(),[t])}),c(de,{trpc:t.trpcClient,serverUrl:f(),deviceId:n,cameraField:c(Nt,{value:n,onChange:i})})]})})}function Ft(){let{t:e}=Le(),t=Re(`/system/network`,{t:e,isAdmin:!0})??{icon:B,title:e(`system.network`,`Network`)};return c(Be,{icon:t.icon,title:t.title,defaultSection:`addresses`,sectionsLabel:`${t.title} sections`,sections:[{id:`local-access`,label:`Local access`,content:c(Mt,{})},{id:`addresses`,label:`Network Addresses`,content:c(lt,{})},{id:z.remoteAccess.tab,label:`Remote Access`,content:c(Ke,{}),ownedParams:V},{id:z.mesh.tab,label:`Mesh Networks`,content:c(mt,{}),ownedParams:V},{id:z.turn.tab,label:`TURN Servers`,content:c(Qe,{}),ownedParams:V},{id:`diagnostics`,label:`Diagnostics`,content:c(Pt,{})}]})}export{Ft as NetworkPage};