@camstack/addon-admin-ui 1.2.181 → 1.2.183
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AddonCollectionPage-DJd0G561.js → AddonCollectionPage-DwDJOFcL.js} +1 -1
- package/dist/assets/{Addons-B9oEehiz.js → Addons-DDgC9FD-.js} +1 -1
- package/dist/assets/{AdminTabs-DUSbhirs.js → AdminTabs-B4GGMxRz.js} +1 -1
- package/dist/assets/{AiProfiles-DS_qCfyh.js → AiProfiles-CR9oxC8h.js} +1 -1
- package/dist/assets/{BrokerForm-B_J_UL0W.js → BrokerForm-BHUwTLLB.js} +1 -1
- package/dist/assets/{Build-Co3eNCT4.js → Build-f_1u4WFv.js} +4 -4
- package/dist/assets/{Capabilities-C48-krU8.js → Capabilities-RvtHAT_T.js} +1 -1
- package/dist/assets/{CapabilityBadges-Bl8JQUQr.js → CapabilityBadges-IB_h9qda.js} +1 -1
- package/dist/assets/{Cluster-BJ8jpAsh.js → Cluster-C9BEXmwP.js} +1 -1
- package/dist/assets/{Data-CTgs0K6f.js → Data-BpDCDX6A.js} +1 -1
- package/dist/assets/{DetectionIntelligence-4UTyckKL.js → DetectionIntelligence-zPhopJKC.js} +1 -1
- package/dist/assets/{DeviceAggregateSection-DXU4IgUx.js → DeviceAggregateSection-BRusipZp.js} +1 -1
- package/dist/assets/{DeviceDetail-jV91edQI.js → DeviceDetail-DHUjDgDI.js} +2 -2
- package/dist/assets/{Devices-TuM5Y4CA.js → Devices-Kt8t-U1T.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-CacpkWdR.js → EmbedPlayerPage-yMkiMevj.js} +1 -1
- package/dist/assets/Events-BWJj26yH.js +1 -0
- package/dist/assets/{FormBuilder-CpdMn4hO.js → FormBuilder-j23rGTmj.js} +1 -1
- package/dist/assets/{Identity-DccPstNt.js → Identity-BbH4N3ls.js} +1 -1
- package/dist/assets/{IntegrationDetail-DqQ46kTk.js → IntegrationDetail-C-2iPJLh.js} +1 -1
- package/dist/assets/{Integrations-BpC_0Ori.js → Integrations-36RwnM2W.js} +1 -1
- package/dist/assets/{Integrations-bqPp2Asv.js → Integrations-B2ODlpqX.js} +1 -1
- package/dist/assets/{Locations-_V2xUV_m.js → Locations-D4Xsj5LF.js} +1 -1
- package/dist/assets/{Logs-qRgWArT0.js → Logs-D2WiTgJp.js} +1 -1
- package/dist/assets/{MotionZonesSettings-D8VKOXWT.js → MotionZonesSettings-MuTTyBWY.js} +1 -1
- package/dist/assets/{MyAccess-C_Lqhtp6.js → MyAccess-Cnee6p_G.js} +1 -1
- package/dist/assets/{Network-CLU9pz2F.js → Network-Cd2ZePrQ.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-BGnTKNTC.js → NodeAddonsSettingsPanel-BlZbeN2Z.js} +1 -1
- package/dist/assets/{NodeInferenceDevices-COEEBYQZ.js → NodeInferenceDevices-I1_uPt2b.js} +1 -1
- package/dist/assets/Notifications-DwEtDT_l.js +1 -0
- package/dist/assets/{Pipeline-VwlltOl_.js → Pipeline-WWlQuB3Q.js} +1 -1
- package/dist/assets/{Plates-DqQqsqek.js → Plates-BS6TmAmt.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-DJOVa6ie.js → PrivacyMaskSettings-BpCcBGIH.js} +1 -1
- package/dist/assets/{ProviderIcon-C8_JXI4r.js → ProviderIcon-CNufGvWr.js} +1 -1
- package/dist/assets/{Recordings-ChT5HLhb.js → Recordings-CBqVhZii.js} +1 -1
- package/dist/assets/{ScanNetworkModal-Ds9Ujyss.js → ScanNetworkModal-DRcWDlfZ.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-Nj4V9mEW.js → SceneMonitorEditor-B_T951ld.js} +1 -1
- package/dist/assets/{Scenes-Czo8-9HJ.js → Scenes-DMIvg_xr.js} +1 -1
- package/dist/assets/{Settings-Bt8qWgaY.js → Settings-B0G6mumO.js} +1 -1
- package/dist/assets/{Showroom-DbzjAJ5K.js → Showroom-CUnnK9jp.js} +1 -1
- package/dist/assets/{StorageLocationsPanel-Gli46LO3.js → StorageLocationsPanel-gyN2eOAh.js} +1 -1
- package/dist/assets/{Terminal-C2znJyh5.js → Terminal-DL0pk1Yh.js} +1 -1
- package/dist/assets/{Viewer-BTIHvb5g.js → Viewer-p7bHegjM.js} +1 -1
- package/dist/assets/_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CytyhLaf.js +1 -0
- package/dist/assets/{authed-media-JFPl7HRk.js → authed-media-DK9gXwSO.js} +1 -1
- package/dist/assets/{bell-off-BzqSLdYZ.js → bell-off-DvjhA5yz.js} +1 -1
- package/dist/assets/{bell-ring-D6RgrV33.js → bell-ring-C7bMrYRU.js} +1 -1
- package/dist/assets/{boxes-Di4H7szx.js → boxes-DUWmFsrP.js} +1 -1
- package/dist/assets/circle-check-big-UUTDxFnK.js +1 -0
- package/dist/assets/circle-dot-CzW0cNTB.js +1 -0
- package/dist/assets/circle-slash-CaR9akZn.js +1 -0
- package/dist/assets/{circle-x-DFeAzRym.js → circle-x-BVeWtyWa.js} +1 -1
- package/dist/assets/clock-BcJxzq7C.js +1 -0
- package/dist/assets/{copy-HKHON4wK.js → copy-Clr1lTje.js} +1 -1
- package/dist/assets/{debounced-invalidate-DEob-KJB.js → debounced-invalidate-BaUUaOIe.js} +1 -1
- package/dist/assets/{dist-Cjqh0Wan.js → dist-B5mS_AVj.js} +1 -1
- package/dist/assets/dist-Cd33cSZb.js +349 -0
- package/dist/assets/{download-BjcTAzIe.js → download-B6F7in4f.js} +1 -1
- package/dist/assets/{face-bbox-GrU8Bm42.js → face-bbox-BHQ2kPlZ.js} +1 -1
- package/dist/assets/{flame-COul3umE.js → flame-WU7l8HOV.js} +1 -1
- package/dist/assets/{format-size-C9Wam9GG.js → format-size-BmviP3wi.js} +1 -1
- package/dist/assets/{hard-drive-DPc0W5g5.js → hard-drive-XE3emw6S.js} +1 -1
- package/dist/assets/hostInit-upQrb-ke.js +1 -0
- package/dist/assets/{index-YqMXmKC_.js → index-DL2yqdrc.js} +3 -3
- package/dist/assets/{key-round-D15z3uvv.js → key-round-DsG9cNQv.js} +1 -1
- package/dist/assets/{layers-DZ5ZWJK2.js → layers-CWHzy2IP.js} +1 -1
- package/dist/assets/{location-owned-usage-Cmw1H2ky.js → location-owned-usage-BdIJhCaK.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-94c8e721.js → mf-entry-bootstrap-0-a8ba3fb3.js} +2 -2
- package/dist/assets/{pencil-DRBv7Lne.js → pencil-DICsE4Gy.js} +1 -1
- package/dist/assets/play-Bc0Mbg1N.js +1 -0
- package/dist/assets/{player-overlays-CoerrptV.js → player-overlays-DVo2KR_t.js} +1 -1
- package/dist/assets/plus-BhEMDQtU.js +1 -0
- package/dist/assets/power-B3EaHOez.js +1 -0
- package/dist/assets/{radio-DRQV-atC.js → radio-Dlzurs1x.js} +1 -1
- package/dist/assets/{refresh-cw-DUVLNAWK.js → refresh-cw-Bk9SNV20.js} +1 -1
- package/dist/assets/remoteEntry-CtfxvtyJ.js +1 -0
- package/dist/assets/rotate-ccw-C4cPfNFW.js +1 -0
- package/dist/assets/rotate-cw-B1uedsyY.js +1 -0
- package/dist/assets/{send-BbpuXZ3P.js → send-CITynaYq.js} +1 -1
- package/dist/assets/{server-K4C9yQfR.js → server-C4WwnByv.js} +1 -1
- package/dist/assets/{shield-Dw3zZIWI.js → shield-BF2zMD3h.js} +1 -1
- package/dist/assets/{shield-alert-4RXP2qu7.js → shield-alert-DvcWv6qf.js} +1 -1
- package/dist/assets/square-C8DJ0ohY.js +1 -0
- package/dist/assets/{square-check-big-Bu8N6Tcy.js → square-check-big-Bm7xPVTE.js} +1 -1
- package/dist/assets/src-CLAf92SY.js +67 -0
- package/dist/assets/src-e8CzBBHU.js +349 -0
- package/dist/assets/{undo-2-VDdKzlFl.js → undo-2-B94PbyBv.js} +1 -1
- package/dist/assets/{use-scenes-feed-GLnt3J9R.js → use-scenes-feed-BaWfN-lO.js} +1 -1
- package/dist/assets/useEventInvalidation-Bqc9UKUF.js +1 -0
- package/dist/assets/{useNodeUrlSelection-Py2d-E1q.js → useNodeUrlSelection-QH8LW_MZ.js} +1 -1
- package/dist/assets/user-round-CssMH_tg.js +1 -0
- package/dist/assets/{video-D8YrEcPQ.js → video-BQp9auCL.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BUYfVBry.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BkrkrKOR.js} +2 -2
- package/dist/assets/{wifi-CEFpiBjp.js → wifi-DKocxMvb.js} +1 -1
- package/dist/assets/{zap-DmoickfW.js → zap-D5PZRv07.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/server/addon.js +248 -6
- package/package.json +1 -1
- package/dist/assets/Events-Vhs6Ka45.js +0 -1
- package/dist/assets/Notifications-CrJJ3noY.js +0 -1
- package/dist/assets/_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Ba6ePIt-.js +0 -1
- package/dist/assets/circle-check-big-Ckfr2nS1.js +0 -1
- package/dist/assets/circle-dot-Bynvvq-p.js +0 -1
- package/dist/assets/circle-slash-Bq9YB7rl.js +0 -1
- package/dist/assets/clock-DOdZD0B9.js +0 -1
- package/dist/assets/dist-BPfNrxiG.js +0 -349
- package/dist/assets/hostInit-1argaRxT.js +0 -1
- package/dist/assets/play-DJ__jbgT.js +0 -1
- package/dist/assets/plus-Bn6mAUY6.js +0 -1
- package/dist/assets/power-ZJUNhMVg.js +0 -1
- package/dist/assets/remoteEntry-Dpe5ejW8.js +0 -1
- package/dist/assets/rotate-ccw-BaeY9e6c.js +0 -1
- package/dist/assets/rotate-cw-CQFP4L_-.js +0 -1
- package/dist/assets/square-CURysUVy.js +0 -1
- package/dist/assets/src-71h6VhtY.js +0 -349
- package/dist/assets/src-BLs3JnCT.js +0 -67
- package/dist/assets/useEventInvalidation-XSNpux9c.js +0 -1
- package/dist/assets/user-round-DhK29-A9.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as e,Q as t,S as n,W as r,b as i,o as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{at as l}from"./player-overlays-CoerrptV.js";import{Er as u,Jr as d,Lr as f,Oi as p,T as m,Ti as h,gn as g,ji as _,r as v,w as y,yn as ee}from"./src-BLs3JnCT.js";import{t as b}from"./ProviderIcon-C8_JXI4r.js";import{t as x}from"./plus-Bn6mAUY6.js";import{i as te,n as ne,r as re,t as S}from"./ScanNetworkModal-Ds9Ujyss.js";import{t as C}from"./refresh-cw-DUVLNAWK.js";import{B as w,H as T,L as E,Q as D,X as O,f as k,r as ie,t as A,v as j,w as M,z as ae}from"./index-YqMXmKC_.js";import{t as oe}from"./AdminPage-CiKtOLQm.js";import"./useEventInvalidation-XSNpux9c.js";import{t as N}from"./StatusBadge-CeptlsPG.js";import{t as P}from"./useBodyScrollLock-BDocajQE.js";t();function F(e,t){let[n,r]=o(!1);return c(()=>{if(!e){r(!1);return}r(!1);let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}t();function I({providerId:e,onImport:t,onSkip:r}){let{t:i}=A(),[a,l]=o(new Set),u=f(),d=u.data,p=u.isPending||!u.data&&!u.isError;c(()=>{e&&(u.isPending||u.data||u.mutate({addonId:e}))},[e,u]);function m(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(p)return n(`div`,{className:`flex flex-col items-center py-12`,children:[s(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),s(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:i(`integrations.searchingDevices`)})]});let h=d??[];return n(`div`,{className:`space-y-4`,children:[s(`p`,{className:`text-xs text-foreground-subtle`,children:h.length>0?i(`integrations.foundDevices`,{count:h.length}):i(`integrations.noDevicesFound`)}),h.length>0&&s(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:h.map(e=>{let t=e.stableId,r=e.suggestedName??t,o=a.has(t),c=e.alreadyOnboarded===!0;return n(`button`,{onClick:()=>{c||m(t)},disabled:c,title:c?i(`integrations.alreadyAddedHint`,{defaultValue:`Already added as "{{name}}" — re-adding would overwrite its settings.`,name:e.onboardedName??r}):void 0,className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${c?`border-border bg-surface opacity-60 cursor-not-allowed`:o?`border-primary/40 bg-primary/5`:`border-border bg-surface hover:border-foreground-subtle/30`}`,children:[s(`div`,{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${o&&!c?`border-primary bg-primary`:`border-border`}`,children:o&&!c&&s(w,{className:`h-3 w-3 text-primary-foreground`})}),s(T,{className:`h-3.5 w-3.5 text-foreground-subtle flex-shrink-0`}),s(`span`,{className:`text-xs font-medium text-foreground truncate`,children:r}),c&&s(`span`,{className:`ml-auto flex-shrink-0 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:i(`integrations.alreadyAdded`,{defaultValue:`Already added`})})]},t)})}),n(`div`,{className:`flex items-center justify-between pt-2`,children:[s(`button`,{onClick:r,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:i(`integrations.skip`)}),h.length>0&&n(`button`,{onClick:()=>t(Array.from(a)),disabled:a.size===0,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:[i(`integrations.importSelected`),` (`,a.size,`)`]})]})]})}function L({onSelect:e,onClose:t,pendingAddonId:r=null}){let{t:i}=A(),a=O(),{data:o,isLoading:c}=p();if(c)return s(`div`,{className:`space-y-2 p-2`,children:[1,2,3].map(e=>s(`div`,{className:`h-14 rounded-lg bg-surface animate-pulse`},e))});let l=r!==null;return n(`div`,{className:`space-y-2`,children:[(o??[]).map(o=>{let c=o.instanceMode===`unique`&&o.existingInstances.length>0,u=r===o.addonId,d=l;return n(`button`,{disabled:d,onClick:()=>{if(!d)if(c){let e=o.existingInstances[0].id;t(),a(`/integrations/${e}`)}else e(o.addonId,o.instanceMode,o.discoveryMode,o.name,o.kind,o.brokerKind,o.mode,o.canTest)},className:`flex w-full items-center gap-3 rounded-lg border border-border bg-surface p-3 text-left hover:border-foreground-subtle/30 transition-colors disabled:opacity-60 disabled:cursor-not-allowed disabled:hover:border-border`,children:[o.iconUrl?s(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${o.color}15`},children:s(`img`,{src:o.iconUrl,alt:``,className:`h-5 w-5`})}):s(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${o.color}15`},children:s(`span`,{className:`text-sm`,style:{color:o.color},children:`◉`})}),n(`div`,{className:`flex-1 min-w-0`,children:[s(`p`,{className:`text-xs font-semibold text-foreground`,children:o.name}),o.description&&s(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5 truncate`,children:o.description})]}),u?s(M,{className:`h-4 w-4 animate-spin text-primary flex-shrink-0`}):c?n(`span`,{className:`flex items-center gap-1 text-[10px] font-medium text-foreground-subtle`,children:[s(k,{className:`h-3 w-3`}),i(`integrations.manage`)]}):s(E,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},o.addonId)}),(o??[]).length===0&&s(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:i(`integrations.noProviders`)})]})}t();function se(e){let t=e=>{if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`)return{...e,fields:e.fields.map(e=>t(e))};let{value:n,...r}=e;return r};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>({...e,fields:e.fields.map(t)}))}}var R=2e4;function ce({open:e,onClose:t}){let{t:l}=A(),d=O(),p=a(),[m,g]=o(`picker`),[_,v]=o(null),[y,b]=o(null),[x,te]=o(`manual`),[S,C]=o(null),[w,T]=o(``),[E,D]=o(null),[k,j]=o(null),[ae,oe]=o(!1),{data:N}=ee({addonId:_??``,nodeId:`hub`},{enabled:_!=null}),ce=r(()=>N?se(N):null,[N]),z=h({onSuccess:()=>p.invalidateQueries({queryKey:[[`integrations`]]})}),B=f(),le=B.data;c(()=>{m!==`discovery`||!y||!_||B.isPending||B.data||B.mutate({addonId:_})},[m,y,_,B]);let V=u({onSuccess:()=>p.invalidateQueries({queryKey:[[`deviceManager`]]})});function H(e,t,n,r,i,a,o,s){if(!z.isPending){if(v(e),oe(s),te(n),T(r),j(null),o===`broker`){if(!a){j(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}C(a),g(`broker`);return}if(o===`account`){g(`config`);return}U(e,r)}}async function U(e,n){try{let r=await z.mutateAsync({addonId:e,name:n,settings:{}});t(),q(),d(`/integrations/${r.id}?add=1`)}catch{}}async function W(e){if(_)try{let t=await z.mutateAsync({addonId:_,name:e.name,settings:e.config});b(t.id),x===`auto`||x===`both`?g(`discovery`):K(t.id)}catch{}}async function G(e){if(_)try{let t=await z.mutateAsync({addonId:_,name:w,settings:{brokerId:e}});D(t.id),b(t.id),K(t.id)}catch{}}async function ue(e){if(_){for(let t of e){let e=le?.find(e=>e.stableId===t);e&&await V.mutateAsync({addonId:_,candidate:e,...E===null?{}:{integrationId:E}})}K()}}function K(e){let n=e??y??_;t(),q(),n&&d(`/integrations/${n}`)}function q(){g(`picker`),v(null),b(null),te(`manual`),C(null),T(``),D(null),j(null),oe(!1)}function J(){t(),q()}P(e);let Y=z.isPending,X=F(Y,R);if(!e)return null;let Z={picker:l(`integrations.newIntegration`),config:l(`integrations.configureIntegration`),discovery:l(`integrations.importDevices`),broker:l(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},Q=Y?_:null,$=z.error,de=Y&&!X;return n(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[s(`div`,{className:`absolute inset-0 bg-black/60`,onClick:de?void 0:J}),n(`div`,{className:`relative z-10 w-full max-w-lg max-h-[calc(85dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl flex flex-col overflow-hidden`,children:[n(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 flex-shrink-0`,children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:Z[m]}),s(`button`,{onClick:J,disabled:de,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:s(ie,{className:`h-4 w-4`})})]}),n(`div`,{className:`px-5 py-4 flex-1 overflow-y-auto overscroll-contain`,children:[$&&!Y&&s(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:$ instanceof Error?$.message:String($)}),m===`picker`&&n(i,{children:[k&&s(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:k}),s(L,{onSelect:H,onClose:J,pendingAddonId:Q})]}),m===`config`&&_&&s(ne,{addonId:_,configSchema:ce??null,canTest:ae,onSave:W,onBack:()=>g(`picker`)}),m===`broker`&&S&&s(re,{kind:S,onResolved:e=>{G(e)},onBack:()=>g(`picker`)}),m===`discovery`&&y&&s(I,{providerId:y,onImport:ue,onSkip:K})]}),Y&&n(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-xl bg-background/85 backdrop-blur-sm px-6 text-center`,children:[s(M,{className:`h-6 w-6 animate-spin text-primary`}),s(`p`,{className:`text-xs font-medium text-foreground`,children:l(`integrations.creating`,{defaultValue:`Creating integration…`})}),!X&&s(`p`,{className:`text-[10px] text-foreground-subtle`,children:l(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),X&&n(i,{children:[s(`p`,{className:`text-[10px] text-foreground-subtle max-w-xs`,children:l(`integrations.creatingOverdue`,{defaultValue:`This is taking longer than expected. The integration may already have been created — close this dialog and refresh to check.`})}),s(`button`,{onClick:J,className:`mt-1 rounded-md border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:l(`integrations.closeAndRefresh`,{defaultValue:`Close`})})]})]})]})]})}function z({integration:e,expanded:t,onToggleExpand:r}){return n(`div`,{className:`flex items-center gap-2.5`,children:[s(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r(e.addonId)},"aria-label":t?`Collapse`:`Expand`,"aria-expanded":t,className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:s(t?ae:E,{className:`h-3.5 w-3.5`})}),s(b,{type:e.addonId,size:`sm`}),n(`div`,{className:`flex min-w-0 flex-col`,children:[s(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:e.name}),s(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:e.addonId})]})]})}function B(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:`Integration`,headerClassName:`w-[55%]`,cell:e=>s(z,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:`Devices`,headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>`${e.deviceCount} device${e.deviceCount===1?``:`s`}`},{key:`status`,header:`Status`,headerClassName:`w-[15%]`,cell:e=>s(N,{status:e.status})}]}t();function le(e){if(!e.enabled)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var V=`expand`;function H(){let{t}=A(),a=O(),c=l(),[u]=D(),[f,p]=o(!1),h=e(()=>p(!0),[]),ee=e(()=>p(!1),[]),[ne,re]=o(!1),w=e(()=>re(!0),[]),T=e(()=>re(!1),[]);v([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),v([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:E,isLoading:k,refetch:ie}=_(void 0),{data:M,isLoading:ae,refetch:N}=d({projection:`slim`}),P=r(()=>M??[],[M]),F=r(()=>E??[],[E]),I=r(()=>{let e=new Map;for(let t of P)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[P]),L=r(()=>{let e=new Map;for(let t of m(P)){let n=t.addonId??``;n&&e.set(n,(e.get(n)??0)+1)}return e},[P]),se=r(()=>F.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:le(e),deviceCount:L.get(e.addonId)??0})),[F,L]),R=u.get(V),z=e(e=>{let t=new URLSearchParams(window.location.search);t.get(V)===e?t.delete(V):t.set(V,e);let n=t.toString(),r=`${window.location.pathname}${n?`?${n}`:``}${window.location.hash}`;window.history.replaceState(window.history.state,``,r),window.dispatchEvent(new PopStateEvent(`popstate`))},[]),H=e(e=>a(`/integrations/${e.id}`),[a]),U=e(e=>I.get(e)??null,[I]),W=e(e=>s(b,{type:e,size:`sm`}),[]),G=e(e=>a(`/devices/${String(e)}`),[a]),ue=e(e=>s(y,{context:`integration-detail`,devices:P,trpc:c.trpcClient,forceAddon:e.addonId,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:W,resolveParent:U,onNavigate:G}),[P,c.trpcClient,W,U,G]),K=e(e=>R===e.addonId,[R]),q=r(()=>B({isExpanded:K,onToggleExpand:z}),[K,z]),J=e(e=>`${e.name} ${e.addonId}`,[]),Y=e(e=>e.addonId,[]),X=e(()=>{ie(),N()},[ie,N]),Z=k||ae,Q=F.length>0;return n(oe,{icon:j,title:t(`nav.integrations`,`Integrations`),actions:n(i,{children:[s(`button`,{onClick:X,disabled:Z,className:`flex items-center gap-1 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,title:`Refresh`,children:s(C,{className:g(`h-3.5 w-3.5`,Z&&`animate-spin`)})}),n(`button`,{onClick:w,className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:`Scan the local network for devices`,children:[s(te,{className:`h-3.5 w-3.5`}),`Scan network`]}),n(`button`,{onClick:h,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm`,children:[s(x,{className:`h-3.5 w-3.5`}),`New Integration`]})]}),children:[Z&&s(`div`,{className:`space-y-2`,children:[1,2,3].map(e=>s(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!Z&&!Q&&n(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[s(`p`,{className:`text-sm`,children:`No integrations configured.`}),s(`p`,{className:`text-xs mt-1`,children:`Click "New Integration" to connect cameras and devices.`})]}),!Z&&Q&&s(y,{mode:`generic`,items:se,getKey:Y,getSearchText:J,columns:q,onRowClick:H,isExpanded:K,renderExpanded:ue,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),s(ce,{open:f,onClose:ee}),s(S,{open:ne,onClose:T})]})}export{H as IntegrationsPage};
|
|
1
|
+
import{I as e,Q as t,S as n,W as r,b as i,o as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{at as l}from"./player-overlays-DVo2KR_t.js";import{Er as u,Jr as d,Lr as f,Oi as p,T as m,Ti as h,gn as g,ji as _,r as v,w as y,yn as ee}from"./src-CLAf92SY.js";import{t as b}from"./ProviderIcon-CNufGvWr.js";import{t as x}from"./plus-BhEMDQtU.js";import{i as te,n as ne,r as re,t as S}from"./ScanNetworkModal-DRcWDlfZ.js";import{t as C}from"./refresh-cw-Bk9SNV20.js";import{B as w,H as T,L as E,Q as D,X as O,f as k,r as ie,t as A,v as j,w as M,z as ae}from"./index-DL2yqdrc.js";import{t as oe}from"./AdminPage-CiKtOLQm.js";import"./useEventInvalidation-Bqc9UKUF.js";import{t as N}from"./StatusBadge-CeptlsPG.js";import{t as P}from"./useBodyScrollLock-BDocajQE.js";t();function F(e,t){let[n,r]=o(!1);return c(()=>{if(!e){r(!1);return}r(!1);let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}t();function I({providerId:e,onImport:t,onSkip:r}){let{t:i}=A(),[a,l]=o(new Set),u=f(),d=u.data,p=u.isPending||!u.data&&!u.isError;c(()=>{e&&(u.isPending||u.data||u.mutate({addonId:e}))},[e,u]);function m(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(p)return n(`div`,{className:`flex flex-col items-center py-12`,children:[s(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),s(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:i(`integrations.searchingDevices`)})]});let h=d??[];return n(`div`,{className:`space-y-4`,children:[s(`p`,{className:`text-xs text-foreground-subtle`,children:h.length>0?i(`integrations.foundDevices`,{count:h.length}):i(`integrations.noDevicesFound`)}),h.length>0&&s(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:h.map(e=>{let t=e.stableId,r=e.suggestedName??t,o=a.has(t),c=e.alreadyOnboarded===!0;return n(`button`,{onClick:()=>{c||m(t)},disabled:c,title:c?i(`integrations.alreadyAddedHint`,{defaultValue:`Already added as "{{name}}" — re-adding would overwrite its settings.`,name:e.onboardedName??r}):void 0,className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${c?`border-border bg-surface opacity-60 cursor-not-allowed`:o?`border-primary/40 bg-primary/5`:`border-border bg-surface hover:border-foreground-subtle/30`}`,children:[s(`div`,{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${o&&!c?`border-primary bg-primary`:`border-border`}`,children:o&&!c&&s(w,{className:`h-3 w-3 text-primary-foreground`})}),s(T,{className:`h-3.5 w-3.5 text-foreground-subtle flex-shrink-0`}),s(`span`,{className:`text-xs font-medium text-foreground truncate`,children:r}),c&&s(`span`,{className:`ml-auto flex-shrink-0 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:i(`integrations.alreadyAdded`,{defaultValue:`Already added`})})]},t)})}),n(`div`,{className:`flex items-center justify-between pt-2`,children:[s(`button`,{onClick:r,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:i(`integrations.skip`)}),h.length>0&&n(`button`,{onClick:()=>t(Array.from(a)),disabled:a.size===0,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:[i(`integrations.importSelected`),` (`,a.size,`)`]})]})]})}function L({onSelect:e,onClose:t,pendingAddonId:r=null}){let{t:i}=A(),a=O(),{data:o,isLoading:c}=p();if(c)return s(`div`,{className:`space-y-2 p-2`,children:[1,2,3].map(e=>s(`div`,{className:`h-14 rounded-lg bg-surface animate-pulse`},e))});let l=r!==null;return n(`div`,{className:`space-y-2`,children:[(o??[]).map(o=>{let c=o.instanceMode===`unique`&&o.existingInstances.length>0,u=r===o.addonId,d=l;return n(`button`,{disabled:d,onClick:()=>{if(!d)if(c){let e=o.existingInstances[0].id;t(),a(`/integrations/${e}`)}else e(o.addonId,o.instanceMode,o.discoveryMode,o.name,o.kind,o.brokerKind,o.mode,o.canTest)},className:`flex w-full items-center gap-3 rounded-lg border border-border bg-surface p-3 text-left hover:border-foreground-subtle/30 transition-colors disabled:opacity-60 disabled:cursor-not-allowed disabled:hover:border-border`,children:[o.iconUrl?s(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${o.color}15`},children:s(`img`,{src:o.iconUrl,alt:``,className:`h-5 w-5`})}):s(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${o.color}15`},children:s(`span`,{className:`text-sm`,style:{color:o.color},children:`◉`})}),n(`div`,{className:`flex-1 min-w-0`,children:[s(`p`,{className:`text-xs font-semibold text-foreground`,children:o.name}),o.description&&s(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5 truncate`,children:o.description})]}),u?s(M,{className:`h-4 w-4 animate-spin text-primary flex-shrink-0`}):c?n(`span`,{className:`flex items-center gap-1 text-[10px] font-medium text-foreground-subtle`,children:[s(k,{className:`h-3 w-3`}),i(`integrations.manage`)]}):s(E,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},o.addonId)}),(o??[]).length===0&&s(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:i(`integrations.noProviders`)})]})}t();function se(e){let t=e=>{if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`)return{...e,fields:e.fields.map(e=>t(e))};let{value:n,...r}=e;return r};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>({...e,fields:e.fields.map(t)}))}}var R=2e4;function ce({open:e,onClose:t}){let{t:l}=A(),d=O(),p=a(),[m,g]=o(`picker`),[_,v]=o(null),[y,b]=o(null),[x,te]=o(`manual`),[S,C]=o(null),[w,T]=o(``),[E,D]=o(null),[k,j]=o(null),[ae,oe]=o(!1),{data:N}=ee({addonId:_??``,nodeId:`hub`},{enabled:_!=null}),ce=r(()=>N?se(N):null,[N]),z=h({onSuccess:()=>p.invalidateQueries({queryKey:[[`integrations`]]})}),B=f(),le=B.data;c(()=>{m!==`discovery`||!y||!_||B.isPending||B.data||B.mutate({addonId:_})},[m,y,_,B]);let V=u({onSuccess:()=>p.invalidateQueries({queryKey:[[`deviceManager`]]})});function H(e,t,n,r,i,a,o,s){if(!z.isPending){if(v(e),oe(s),te(n),T(r),j(null),o===`broker`){if(!a){j(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}C(a),g(`broker`);return}if(o===`account`){g(`config`);return}U(e,r)}}async function U(e,n){try{let r=await z.mutateAsync({addonId:e,name:n,settings:{}});t(),q(),d(`/integrations/${r.id}?add=1`)}catch{}}async function W(e){if(_)try{let t=await z.mutateAsync({addonId:_,name:e.name,settings:e.config});b(t.id),x===`auto`||x===`both`?g(`discovery`):K(t.id)}catch{}}async function G(e){if(_)try{let t=await z.mutateAsync({addonId:_,name:w,settings:{brokerId:e}});D(t.id),b(t.id),K(t.id)}catch{}}async function ue(e){if(_){for(let t of e){let e=le?.find(e=>e.stableId===t);e&&await V.mutateAsync({addonId:_,candidate:e,...E===null?{}:{integrationId:E}})}K()}}function K(e){let n=e??y??_;t(),q(),n&&d(`/integrations/${n}`)}function q(){g(`picker`),v(null),b(null),te(`manual`),C(null),T(``),D(null),j(null),oe(!1)}function J(){t(),q()}P(e);let Y=z.isPending,X=F(Y,R);if(!e)return null;let Z={picker:l(`integrations.newIntegration`),config:l(`integrations.configureIntegration`),discovery:l(`integrations.importDevices`),broker:l(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},Q=Y?_:null,$=z.error,de=Y&&!X;return n(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[s(`div`,{className:`absolute inset-0 bg-black/60`,onClick:de?void 0:J}),n(`div`,{className:`relative z-10 w-full max-w-lg max-h-[calc(85dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl flex flex-col overflow-hidden`,children:[n(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 flex-shrink-0`,children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:Z[m]}),s(`button`,{onClick:J,disabled:de,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:s(ie,{className:`h-4 w-4`})})]}),n(`div`,{className:`px-5 py-4 flex-1 overflow-y-auto overscroll-contain`,children:[$&&!Y&&s(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:$ instanceof Error?$.message:String($)}),m===`picker`&&n(i,{children:[k&&s(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:k}),s(L,{onSelect:H,onClose:J,pendingAddonId:Q})]}),m===`config`&&_&&s(ne,{addonId:_,configSchema:ce??null,canTest:ae,onSave:W,onBack:()=>g(`picker`)}),m===`broker`&&S&&s(re,{kind:S,onResolved:e=>{G(e)},onBack:()=>g(`picker`)}),m===`discovery`&&y&&s(I,{providerId:y,onImport:ue,onSkip:K})]}),Y&&n(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-xl bg-background/85 backdrop-blur-sm px-6 text-center`,children:[s(M,{className:`h-6 w-6 animate-spin text-primary`}),s(`p`,{className:`text-xs font-medium text-foreground`,children:l(`integrations.creating`,{defaultValue:`Creating integration…`})}),!X&&s(`p`,{className:`text-[10px] text-foreground-subtle`,children:l(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),X&&n(i,{children:[s(`p`,{className:`text-[10px] text-foreground-subtle max-w-xs`,children:l(`integrations.creatingOverdue`,{defaultValue:`This is taking longer than expected. The integration may already have been created — close this dialog and refresh to check.`})}),s(`button`,{onClick:J,className:`mt-1 rounded-md border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:l(`integrations.closeAndRefresh`,{defaultValue:`Close`})})]})]})]})]})}function z({integration:e,expanded:t,onToggleExpand:r}){return n(`div`,{className:`flex items-center gap-2.5`,children:[s(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r(e.addonId)},"aria-label":t?`Collapse`:`Expand`,"aria-expanded":t,className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:s(t?ae:E,{className:`h-3.5 w-3.5`})}),s(b,{type:e.addonId,size:`sm`}),n(`div`,{className:`flex min-w-0 flex-col`,children:[s(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:e.name}),s(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:e.addonId})]})]})}function B(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:`Integration`,headerClassName:`w-[55%]`,cell:e=>s(z,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:`Devices`,headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>`${e.deviceCount} device${e.deviceCount===1?``:`s`}`},{key:`status`,header:`Status`,headerClassName:`w-[15%]`,cell:e=>s(N,{status:e.status})}]}t();function le(e){if(!e.enabled)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var V=`expand`;function H(){let{t}=A(),a=O(),c=l(),[u]=D(),[f,p]=o(!1),h=e(()=>p(!0),[]),ee=e(()=>p(!1),[]),[ne,re]=o(!1),w=e(()=>re(!0),[]),T=e(()=>re(!1),[]);v([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),v([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:E,isLoading:k,refetch:ie}=_(void 0),{data:M,isLoading:ae,refetch:N}=d({projection:`slim`}),P=r(()=>M??[],[M]),F=r(()=>E??[],[E]),I=r(()=>{let e=new Map;for(let t of P)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[P]),L=r(()=>{let e=new Map;for(let t of m(P)){let n=t.addonId??``;n&&e.set(n,(e.get(n)??0)+1)}return e},[P]),se=r(()=>F.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:le(e),deviceCount:L.get(e.addonId)??0})),[F,L]),R=u.get(V),z=e(e=>{let t=new URLSearchParams(window.location.search);t.get(V)===e?t.delete(V):t.set(V,e);let n=t.toString(),r=`${window.location.pathname}${n?`?${n}`:``}${window.location.hash}`;window.history.replaceState(window.history.state,``,r),window.dispatchEvent(new PopStateEvent(`popstate`))},[]),H=e(e=>a(`/integrations/${e.id}`),[a]),U=e(e=>I.get(e)??null,[I]),W=e(e=>s(b,{type:e,size:`sm`}),[]),G=e(e=>a(`/devices/${String(e)}`),[a]),ue=e(e=>s(y,{context:`integration-detail`,devices:P,trpc:c.trpcClient,forceAddon:e.addonId,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:W,resolveParent:U,onNavigate:G}),[P,c.trpcClient,W,U,G]),K=e(e=>R===e.addonId,[R]),q=r(()=>B({isExpanded:K,onToggleExpand:z}),[K,z]),J=e(e=>`${e.name} ${e.addonId}`,[]),Y=e(e=>e.addonId,[]),X=e(()=>{ie(),N()},[ie,N]),Z=k||ae,Q=F.length>0;return n(oe,{icon:j,title:t(`nav.integrations`,`Integrations`),actions:n(i,{children:[s(`button`,{onClick:X,disabled:Z,className:`flex items-center gap-1 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,title:`Refresh`,children:s(C,{className:g(`h-3.5 w-3.5`,Z&&`animate-spin`)})}),n(`button`,{onClick:w,className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:`Scan the local network for devices`,children:[s(te,{className:`h-3.5 w-3.5`}),`Scan network`]}),n(`button`,{onClick:h,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm`,children:[s(x,{className:`h-3.5 w-3.5`}),`New Integration`]})]}),children:[Z&&s(`div`,{className:`space-y-2`,children:[1,2,3].map(e=>s(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!Z&&!Q&&n(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[s(`p`,{className:`text-sm`,children:`No integrations configured.`}),s(`p`,{className:`text-xs mt-1`,children:`Click "New Integration" to connect cameras and devices.`})]}),!Z&&Q&&s(y,{mode:`generic`,items:se,getKey:Y,getSearchText:J,columns:q,onRowClick:H,isExpanded:K,renderExpanded:ue,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),s(ce,{open:f,onClose:ee}),s(S,{open:ne,onClose:T})]})}export{H as IntegrationsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Q as e,S as t,W as n,b as r,o as i,q as a,x as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{C as s,_r as c,dr as l,fr as u,gr as d,hr as f,jn as p,mr as m,sn as h,vr as g,wr as _,yr as v}from"./src-BLs3JnCT.js";import{H as y,pt as b,ut as x}from"./src-71h6VhtY.js";import{t as S}from"./pencil-DRBv7Lne.js";import{t as C}from"./plus-Bn6mAUY6.js";import{t as w}from"./radio-DRQV-atC.js";import{t as T}from"./wifi-CEFpiBjp.js";import{J as E,X as D,o as O,r as k,v as ee,w as A}from"./index-YqMXmKC_.js";import{t as j}from"./AdminPage-CiKtOLQm.js";import{t as M}from"./AdminTabs-DUSbhirs.js";import{t as N}from"./BrokerForm-B_J_UL0W.js";import{t as P}from"./useBodyScrollLock-BDocajQE.js";import{t as F}from"./AddonCollectionPage-DJd0G561.js";var I=E(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),L=E(`share-2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]);e();var R={"home-assistant":`Home Assistant`,mqtt:`MQTT`};function z(e){return R[e]??e}function B(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}var V={connected:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`,connecting:`bg-amber-500/15 text-amber-700 dark:text-amber-300`,disconnected:`bg-foreground-subtle/15 text-foreground-subtle`,"auth-failed":`bg-danger/15 text-danger`,unreachable:`bg-danger/15 text-danger`,error:`bg-danger/15 text-danger`};function H({status:e}){return o(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${V[e]}`,children:e})}function U(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function W({title:e,subtitle:n,onClose:r,children:i}){return P(),o(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:r,children:t(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[t(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[t(`div`,{className:`space-y-0.5`,children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),n&&o(`p`,{className:`text-xs text-foreground-subtle`,children:n})]}),o(`button`,{onClick:r,className:`text-foreground-subtle hover:text-foreground`,children:o(k,{className:`h-4 w-4`})})]}),o(`div`,{className:`p-4 max-h-[70vh] overflow-y-auto overscroll-contain`,children:i})]})})}function G({kinds:e,onClose:n,onDone:s}){let c=i(),u=e=>`${e.addonId??``}::${e.kind}`,[d,f]=a(e[0]?u(e[0]):``),[p,m]=a(``),[h,g]=a(!1),[_,v]=a(``),y=e.find(e=>u(e)===d)??e[0],b=y?.kind??``,x=y?.addonId,S=l({onSuccess:()=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]}),s()}}),C=e=>{if(!b||p.trim().length===0)return;let t=h?_.trim():``;h&&t===``||S.mutate({kind:b,name:p.trim(),settings:e,...t===``?{}:{id:t},...x===void 0?{}:{addonId:x}})};return o(W,{title:`Add broker`,subtitle:`Register a message broker for exporters and automations.`,onClose:S.isPending?()=>{}:n,children:t(`div`,{className:`space-y-3`,children:[t(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Kind`}),o(`select`,{value:d,onChange:e=>f(e.target.value),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`,children:e.map(e=>o(`option`,{value:u(e),children:e.label},u(e)))})]}),t(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Name`}),o(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:`My Home Assistant`,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`})]}),t(`div`,{className:`space-y-1 rounded border border-border px-3 py-2`,children:[t(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground`,children:[o(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked)}),`Restore a broker that was removed, under its original id`]}),h&&t(r,{children:[o(`input`,{type:`text`,value:_,onChange:e=>v(e.target.value),placeholder:`ha_004`,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`}),o(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Devices remember the broker id they were discovered under, so restoring the original id reconnects them instead of needing re-discovery. An id that is still in use is refused.`})]})]}),S.isError&&o(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:S.error instanceof Error?S.error.message:String(S.error)}),b&&o(N,{kind:b,...x===void 0?{}:{addonId:x},onSubmit:C,onCancel:n,submitLabel:S.isPending?`Adding…`:`Add broker`,disabled:S.isPending}),p.trim().length===0&&o(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Enter a name before saving.`}),h&&_.trim().length===0&&o(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Enter the original id, or clear the checkbox to create a new broker.`})]})})}function K({broker:e,onClose:r,onDone:a}){let s=i(),c=u({id:e.id,addonId:e.addonId}),l=g({onSuccess:()=>{s.invalidateQueries({queryKey:[[`broker`,`list`]]}),s.invalidateQueries({queryKey:[[`broker`,`getSettings`],{input:{id:e.id,addonId:e.addonId}}]}),a()}}),d=n(()=>{let e=c.data;return e&&typeof e==`object`?{...e}:{}},[c.data]);return o(W,{title:`Edit ${e.name}`,subtitle:`${z(e.kind)} · ${e.id}`,onClose:l.isPending?()=>{}:r,children:c.isLoading?t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[o(A,{className:`h-3.5 w-3.5 animate-spin`}),` Loading settings…`]}):c.isError?t(`div`,{className:`space-y-3`,children:[t(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:[`Failed to load settings:`,` `,c.error instanceof Error?c.error.message:`Unknown error`]}),o(`div`,{className:`flex justify-end`,children:o(`button`,{type:`button`,onClick:r,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Close`})})]}):t(`div`,{className:`space-y-3`,children:[l.isError&&o(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:l.error instanceof Error?l.error.message:String(l.error)}),o(N,{kind:e.kind,addonId:e.addonId,initialValues:d,onSubmit:t=>{l.mutate({id:e.id,settings:t,addonId:e.addonId})},onCancel:r,submitLabel:l.isPending?`Saving…`:`Save`,disabled:l.isPending})]})})}function q({broker:e,onEdit:n}){let r=i(),s=h(),[l,u]=a(null),d=v({onSuccess:e=>u(e.ok?{ok:!0}:{ok:!1,error:e.error}),onError:e=>u({ok:!1,error:e instanceof Error?e.message:String(e)})}),f=c({onSuccess:()=>{r.invalidateQueries({queryKey:[[`broker`,`list`]]})}}),p=async()=>{await s({title:`Delete broker`,message:`Delete broker "${e.name}"? Integrations that depend on it will stop working.`,confirmLabel:`Delete`,variant:`danger`})&&f.mutate({id:e.id,addonId:e.addonId})};return t(`tr`,{className:`border-b border-border last:border-0`,children:[o(`td`,{className:`px-3 py-2 text-xs text-foreground font-medium`,children:e.name}),o(`td`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:z(e.kind)}),t(`td`,{className:`px-3 py-2`,children:[o(H,{status:e.status}),l&&o(`span`,{className:`ml-2 text-[10px] ${l.ok?`text-success`:`text-danger`}`,children:l.ok?`OK`:l.error??`failed`})]}),o(`td`,{className:`px-3 py-2`,children:t(`div`,{className:`flex items-center justify-end gap-1.5`,children:[t(`button`,{type:`button`,onClick:()=>d.mutate({id:e.id,addonId:e.addonId}),disabled:d.isPending,title:`Test connection`,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-primary/10 disabled:opacity-50`,children:[d.isPending?o(A,{className:`h-3 w-3 animate-spin`}):o(T,{className:`h-3 w-3`}),`Test`]}),t(`button`,{type:`button`,onClick:()=>n(e),title:`Edit`,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-primary/10`,children:[o(S,{className:`h-3 w-3`}),` Edit`]}),t(`button`,{type:`button`,onClick:()=>{p()},disabled:f.isPending,title:`Delete`,className:`inline-flex items-center gap-1 rounded border border-danger/40 px-2 py-1 text-[11px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[f.isPending?o(A,{className:`h-3 w-3 animate-spin`}):o(O,{className:`h-3 w-3`}),`Delete`]})]})})]})}function J(){let e=f({}),r=d(),i=n(()=>U(e.data),[e.data]),[s,c]=a(!1),[l,u]=a(null),p=n(()=>{let e=new Map;for(let t of B(r.data))for(let n of t.kinds)e.set(`${t.addonId}::${n.kind}`,{addonId:t.addonId,kind:n.kind,label:n.label});for(let t of i)[...e.values()].some(e=>e.kind===t.kind)||e.set(`::${t.kind}`,{kind:t.kind,label:z(t.kind)});return[...e.values()]},[i,r.data]);return t(`div`,{className:`space-y-3`,children:[o(`div`,{className:`flex items-center justify-end`,children:t(`button`,{type:`button`,onClick:()=>c(!0),disabled:p.length===0,title:p.length===0?`No broker providers available`:void 0,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed`,children:[o(C,{className:`h-3.5 w-3.5`}),` Add broker`]})}),o(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:t(`table`,{className:`w-full min-w-[36rem] border-collapse`,children:[o(`thead`,{children:t(`tr`,{className:`border-b border-border bg-background/50`,children:[o(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:`Name`}),o(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:`Kind`}),o(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:`Status`}),o(`th`,{className:`px-3 py-2 text-right text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:`Actions`})]})}),t(`tbody`,{children:[e.isLoading&&o(`tr`,{children:t(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:[o(A,{className:`inline h-4 w-4 animate-spin`}),` Loading brokers…`]})}),e.isError&&o(`tr`,{children:t(`td`,{colSpan:4,className:`px-3 py-4 text-center text-xs text-danger`,children:[`Failed to load brokers:`,` `,e.error instanceof Error?e.error.message:`Unknown error`]})}),!e.isLoading&&!e.isError&&i.length===0&&o(`tr`,{children:o(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:`No brokers registered yet. Add one to publish device events for downstream automations.`})}),i.map(e=>o(q,{broker:e,onEdit:u},e.id))]})]})}),s&&o(G,{kinds:p,onClose:()=>c(!1),onDone:()=>c(!1)}),l&&o(K,{broker:l,onClose:()=>u(null),onDone:()=>u(null)})]})}var Y=[{kind:`device-export`,tabId:`device-export`,title:`Device export`,subtitle:`Outbound exporters that publish CamStack devices to other ecosystems (HomeAssistant, HomeKit, Alexa, …).`,icon:L,emptyTitle:`No device-export providers installed`,emptyDescription:`Install an export addon (e.g. @camstack/addon-export-ha-mqtt) to surface your CamStack devices in HomeAssistant, HomeKit, …`,addLabel:`Add export`},{kind:`email`,tabId:`email`,title:`Email providers`,subtitle:`Outbound email relays used for magic-link login, notifications, and alerts (SMTP today, future SendGrid, …).`,icon:I,emptyTitle:`No email providers installed`,emptyDescription:`Install an email-provider addon (e.g. @camstack/addon-smtp) so the hub can deliver magic-link logins and notifications.`,addLabel:`Add email provider`},{kind:`broker`,tabId:`broker`,title:`Brokers`,subtitle:`Message brokers consumed by exporters and downstream automations (MQTT today, future Kafka, …).`,icon:w,emptyTitle:`No brokers installed`,emptyDescription:`Install a broker addon (e.g. @camstack/addon-mqtt-broker) to publish device events for downstream automations.`,addLabel:`Add broker`}];function X(e){if(typeof e==`string`)return e;if(e&&typeof e==`object`){let t=e.name;if(typeof t==`string`)return t}return null}function Z(e){let t=e,n=t?.manifest;if(!n?.id)return null;let r=[];for(let e of n.capabilities??[]){let t=X(e);t!==null&&r.push(t)}let i=n.packageDisplayName??n.name??n.id,a=t?.process?.state??null;return{addonId:n.id,displayName:i,isActive:a===`running`,packageName:n.packageName??`@camstack/addon-${n.id}`,capNames:r,processState:a}}function Q(e,t){let n=new Set(t);return e.filter(e=>e.capNames.some(e=>n.has(e)))}function te(e){for(let[t,n]of Object.entries(y))if(n===e)return t;return null}function ne(e){return e===`running`?{label:`Running`,className:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`}:e===`crashed`||e===`failed`?{label:e===`failed`?`Failed`:`Crashed`,className:`bg-danger/15 text-danger`}:e===`stopped`||e===`disabled`?{label:`Stopped`,className:`bg-foreground-subtle/15 text-foreground-subtle`}:{label:e??`Unknown`,className:`bg-foreground-subtle/15 text-foreground-subtle`}}function $({label:e,className:t}){return o(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t}`,children:e})}function re({addonId:e}){let{data:t,isLoading:n}=m({addonId:e},{refetchInterval:1e4,retry:!1});if(n||!t)return null;let r=b.safeParse(t);if(!r.success)return null;let i=r.data;return o($,{label:`${i.brokerCount} broker${i.brokerCount===1?``:`s`}${i.connectedCount>0?` • ${i.connectedCount} connected`:``}`,className:`bg-primary/10 text-primary`})}function ie({addonId:e}){let{data:t,isLoading:n}=_({addonId:e},{refetchInterval:1e4,retry:!1});if(n||!t)return null;let r=x.safeParse(t);if(!r.success)return null;let i=r.data,a=i.linkState===`linked`?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:i.linkState===`error`?`bg-danger/15 text-danger`:`bg-foreground-subtle/15 text-foreground-subtle`;return o($,{label:`${i.linkState} • ${i.exposedDeviceCount} exposed`,className:a})}function ae({kind:e,addonId:t}){return e===`broker`?o(re,{addonId:t}):e===`device-export`?o(ie,{addonId:t}):null}function oe({descriptor:e,rows:n,isLoading:i}){let a=te(e.kind),c=e.kind===`device-export`,l=D();return o(F,{title:e.title,subtitle:e.subtitle,pageIcon:e.icon,itemIcon:e.icon,capability:a??e.kind,installButtonLabel:e.addLabel,items:n,isLoading:i,emptyTitle:e.emptyTitle,emptyDescription:e.emptyDescription,renderStatusBadges:n=>{let i=ne(n.processState);return t(r,{children:[o($,{label:i.label,className:i.className}),o(ae,{kind:e.kind,addonId:n.addonId})]})},renderExpandedPanel:c?e=>o(s,{addonId:e.addonId,onOpenDevice:e=>l(`/devices/${e}`)}):void 0,showChrome:!0})}function se(){let e=p(void 0,{refetchInterval:1e4}),t=(e.data??[]).map(Z).filter(e=>e!==null);return o(j,{icon:ee,title:`External systems`,subtitle:`External systems this hub talks to — device exporters, email relays, and message brokers. Settings, Logs and Events are docked under every provider.`,children:o(M,{tabs:Y.map(n=>{let r=Object.entries(y).filter(([,e])=>e===n.kind).map(([e])=>e),i=n.kind===`broker`?o(J,{}):o(oe,{descriptor:n,rows:Q(t,r),isLoading:e.isLoading});return{id:n.tabId,label:n.title,icon:n.icon,content:i}})})})}export{se as IntegrationsPage};
|
|
1
|
+
import{Q as e,S as t,W as n,b as r,o as i,q as a,x as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{C as s,_r as c,dr as l,fr as u,gr as d,hr as f,jn as p,mr as m,sn as h,vr as g,wr as _,yr as v}from"./src-CLAf92SY.js";import{U as y,dt as b,mt as x}from"./src-e8CzBBHU.js";import{t as S}from"./pencil-DICsE4Gy.js";import{t as C}from"./plus-BhEMDQtU.js";import{t as w}from"./radio-Dlzurs1x.js";import{t as T}from"./wifi-DKocxMvb.js";import{J as E,X as D,o as O,r as k,v as ee,w as A}from"./index-DL2yqdrc.js";import{t as j}from"./AdminPage-CiKtOLQm.js";import{t as M}from"./AdminTabs-B4GGMxRz.js";import{t as N}from"./BrokerForm-BHUwTLLB.js";import{t as P}from"./useBodyScrollLock-BDocajQE.js";import{t as F}from"./AddonCollectionPage-DwDJOFcL.js";var I=E(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),L=E(`share-2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]);e();var R={"home-assistant":`Home Assistant`,mqtt:`MQTT`};function z(e){return R[e]??e}function B(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}var V={connected:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`,connecting:`bg-amber-500/15 text-amber-700 dark:text-amber-300`,disconnected:`bg-foreground-subtle/15 text-foreground-subtle`,"auth-failed":`bg-danger/15 text-danger`,unreachable:`bg-danger/15 text-danger`,error:`bg-danger/15 text-danger`};function H({status:e}){return o(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${V[e]}`,children:e})}function U(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function W({title:e,subtitle:n,onClose:r,children:i}){return P(),o(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:r,children:t(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[t(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[t(`div`,{className:`space-y-0.5`,children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),n&&o(`p`,{className:`text-xs text-foreground-subtle`,children:n})]}),o(`button`,{onClick:r,className:`text-foreground-subtle hover:text-foreground`,children:o(k,{className:`h-4 w-4`})})]}),o(`div`,{className:`p-4 max-h-[70vh] overflow-y-auto overscroll-contain`,children:i})]})})}function G({kinds:e,onClose:n,onDone:s}){let c=i(),u=e=>`${e.addonId??``}::${e.kind}`,[d,f]=a(e[0]?u(e[0]):``),[p,m]=a(``),[h,g]=a(!1),[_,v]=a(``),y=e.find(e=>u(e)===d)??e[0],b=y?.kind??``,x=y?.addonId,S=l({onSuccess:()=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]}),s()}}),C=e=>{if(!b||p.trim().length===0)return;let t=h?_.trim():``;h&&t===``||S.mutate({kind:b,name:p.trim(),settings:e,...t===``?{}:{id:t},...x===void 0?{}:{addonId:x}})};return o(W,{title:`Add broker`,subtitle:`Register a message broker for exporters and automations.`,onClose:S.isPending?()=>{}:n,children:t(`div`,{className:`space-y-3`,children:[t(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Kind`}),o(`select`,{value:d,onChange:e=>f(e.target.value),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`,children:e.map(e=>o(`option`,{value:u(e),children:e.label},u(e)))})]}),t(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Name`}),o(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:`My Home Assistant`,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`})]}),t(`div`,{className:`space-y-1 rounded border border-border px-3 py-2`,children:[t(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground`,children:[o(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked)}),`Restore a broker that was removed, under its original id`]}),h&&t(r,{children:[o(`input`,{type:`text`,value:_,onChange:e=>v(e.target.value),placeholder:`ha_004`,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`}),o(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Devices remember the broker id they were discovered under, so restoring the original id reconnects them instead of needing re-discovery. An id that is still in use is refused.`})]})]}),S.isError&&o(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:S.error instanceof Error?S.error.message:String(S.error)}),b&&o(N,{kind:b,...x===void 0?{}:{addonId:x},onSubmit:C,onCancel:n,submitLabel:S.isPending?`Adding…`:`Add broker`,disabled:S.isPending}),p.trim().length===0&&o(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Enter a name before saving.`}),h&&_.trim().length===0&&o(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Enter the original id, or clear the checkbox to create a new broker.`})]})})}function K({broker:e,onClose:r,onDone:a}){let s=i(),c=u({id:e.id,addonId:e.addonId}),l=g({onSuccess:()=>{s.invalidateQueries({queryKey:[[`broker`,`list`]]}),s.invalidateQueries({queryKey:[[`broker`,`getSettings`],{input:{id:e.id,addonId:e.addonId}}]}),a()}}),d=n(()=>{let e=c.data;return e&&typeof e==`object`?{...e}:{}},[c.data]);return o(W,{title:`Edit ${e.name}`,subtitle:`${z(e.kind)} · ${e.id}`,onClose:l.isPending?()=>{}:r,children:c.isLoading?t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[o(A,{className:`h-3.5 w-3.5 animate-spin`}),` Loading settings…`]}):c.isError?t(`div`,{className:`space-y-3`,children:[t(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:[`Failed to load settings:`,` `,c.error instanceof Error?c.error.message:`Unknown error`]}),o(`div`,{className:`flex justify-end`,children:o(`button`,{type:`button`,onClick:r,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Close`})})]}):t(`div`,{className:`space-y-3`,children:[l.isError&&o(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:l.error instanceof Error?l.error.message:String(l.error)}),o(N,{kind:e.kind,addonId:e.addonId,initialValues:d,onSubmit:t=>{l.mutate({id:e.id,settings:t,addonId:e.addonId})},onCancel:r,submitLabel:l.isPending?`Saving…`:`Save`,disabled:l.isPending})]})})}function q({broker:e,onEdit:n}){let r=i(),s=h(),[l,u]=a(null),d=v({onSuccess:e=>u(e.ok?{ok:!0}:{ok:!1,error:e.error}),onError:e=>u({ok:!1,error:e instanceof Error?e.message:String(e)})}),f=c({onSuccess:()=>{r.invalidateQueries({queryKey:[[`broker`,`list`]]})}}),p=async()=>{await s({title:`Delete broker`,message:`Delete broker "${e.name}"? Integrations that depend on it will stop working.`,confirmLabel:`Delete`,variant:`danger`})&&f.mutate({id:e.id,addonId:e.addonId})};return t(`tr`,{className:`border-b border-border last:border-0`,children:[o(`td`,{className:`px-3 py-2 text-xs text-foreground font-medium`,children:e.name}),o(`td`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:z(e.kind)}),t(`td`,{className:`px-3 py-2`,children:[o(H,{status:e.status}),l&&o(`span`,{className:`ml-2 text-[10px] ${l.ok?`text-success`:`text-danger`}`,children:l.ok?`OK`:l.error??`failed`})]}),o(`td`,{className:`px-3 py-2`,children:t(`div`,{className:`flex items-center justify-end gap-1.5`,children:[t(`button`,{type:`button`,onClick:()=>d.mutate({id:e.id,addonId:e.addonId}),disabled:d.isPending,title:`Test connection`,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-primary/10 disabled:opacity-50`,children:[d.isPending?o(A,{className:`h-3 w-3 animate-spin`}):o(T,{className:`h-3 w-3`}),`Test`]}),t(`button`,{type:`button`,onClick:()=>n(e),title:`Edit`,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-primary/10`,children:[o(S,{className:`h-3 w-3`}),` Edit`]}),t(`button`,{type:`button`,onClick:()=>{p()},disabled:f.isPending,title:`Delete`,className:`inline-flex items-center gap-1 rounded border border-danger/40 px-2 py-1 text-[11px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[f.isPending?o(A,{className:`h-3 w-3 animate-spin`}):o(O,{className:`h-3 w-3`}),`Delete`]})]})})]})}function J(){let e=f({}),r=d(),i=n(()=>U(e.data),[e.data]),[s,c]=a(!1),[l,u]=a(null),p=n(()=>{let e=new Map;for(let t of B(r.data))for(let n of t.kinds)e.set(`${t.addonId}::${n.kind}`,{addonId:t.addonId,kind:n.kind,label:n.label});for(let t of i)[...e.values()].some(e=>e.kind===t.kind)||e.set(`::${t.kind}`,{kind:t.kind,label:z(t.kind)});return[...e.values()]},[i,r.data]);return t(`div`,{className:`space-y-3`,children:[o(`div`,{className:`flex items-center justify-end`,children:t(`button`,{type:`button`,onClick:()=>c(!0),disabled:p.length===0,title:p.length===0?`No broker providers available`:void 0,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed`,children:[o(C,{className:`h-3.5 w-3.5`}),` Add broker`]})}),o(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:t(`table`,{className:`w-full min-w-[36rem] border-collapse`,children:[o(`thead`,{children:t(`tr`,{className:`border-b border-border bg-background/50`,children:[o(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:`Name`}),o(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:`Kind`}),o(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:`Status`}),o(`th`,{className:`px-3 py-2 text-right text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:`Actions`})]})}),t(`tbody`,{children:[e.isLoading&&o(`tr`,{children:t(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:[o(A,{className:`inline h-4 w-4 animate-spin`}),` Loading brokers…`]})}),e.isError&&o(`tr`,{children:t(`td`,{colSpan:4,className:`px-3 py-4 text-center text-xs text-danger`,children:[`Failed to load brokers:`,` `,e.error instanceof Error?e.error.message:`Unknown error`]})}),!e.isLoading&&!e.isError&&i.length===0&&o(`tr`,{children:o(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:`No brokers registered yet. Add one to publish device events for downstream automations.`})}),i.map(e=>o(q,{broker:e,onEdit:u},e.id))]})]})}),s&&o(G,{kinds:p,onClose:()=>c(!1),onDone:()=>c(!1)}),l&&o(K,{broker:l,onClose:()=>u(null),onDone:()=>u(null)})]})}var Y=[{kind:`device-export`,tabId:`device-export`,title:`Device export`,subtitle:`Outbound exporters that publish CamStack devices to other ecosystems (HomeAssistant, HomeKit, Alexa, …).`,icon:L,emptyTitle:`No device-export providers installed`,emptyDescription:`Install an export addon (e.g. @camstack/addon-export-ha-mqtt) to surface your CamStack devices in HomeAssistant, HomeKit, …`,addLabel:`Add export`},{kind:`email`,tabId:`email`,title:`Email providers`,subtitle:`Outbound email relays used for magic-link login, notifications, and alerts (SMTP today, future SendGrid, …).`,icon:I,emptyTitle:`No email providers installed`,emptyDescription:`Install an email-provider addon (e.g. @camstack/addon-smtp) so the hub can deliver magic-link logins and notifications.`,addLabel:`Add email provider`},{kind:`broker`,tabId:`broker`,title:`Brokers`,subtitle:`Message brokers consumed by exporters and downstream automations (MQTT today, future Kafka, …).`,icon:w,emptyTitle:`No brokers installed`,emptyDescription:`Install a broker addon (e.g. @camstack/addon-mqtt-broker) to publish device events for downstream automations.`,addLabel:`Add broker`}];function X(e){if(typeof e==`string`)return e;if(e&&typeof e==`object`){let t=e.name;if(typeof t==`string`)return t}return null}function Z(e){let t=e,n=t?.manifest;if(!n?.id)return null;let r=[];for(let e of n.capabilities??[]){let t=X(e);t!==null&&r.push(t)}let i=n.packageDisplayName??n.name??n.id,a=t?.process?.state??null;return{addonId:n.id,displayName:i,isActive:a===`running`,packageName:n.packageName??`@camstack/addon-${n.id}`,capNames:r,processState:a}}function Q(e,t){let n=new Set(t);return e.filter(e=>e.capNames.some(e=>n.has(e)))}function te(e){for(let[t,n]of Object.entries(y))if(n===e)return t;return null}function ne(e){return e===`running`?{label:`Running`,className:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`}:e===`crashed`||e===`failed`?{label:e===`failed`?`Failed`:`Crashed`,className:`bg-danger/15 text-danger`}:e===`stopped`||e===`disabled`?{label:`Stopped`,className:`bg-foreground-subtle/15 text-foreground-subtle`}:{label:e??`Unknown`,className:`bg-foreground-subtle/15 text-foreground-subtle`}}function $({label:e,className:t}){return o(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t}`,children:e})}function re({addonId:e}){let{data:t,isLoading:n}=m({addonId:e},{refetchInterval:1e4,retry:!1});if(n||!t)return null;let r=x.safeParse(t);if(!r.success)return null;let i=r.data;return o($,{label:`${i.brokerCount} broker${i.brokerCount===1?``:`s`}${i.connectedCount>0?` • ${i.connectedCount} connected`:``}`,className:`bg-primary/10 text-primary`})}function ie({addonId:e}){let{data:t,isLoading:n}=_({addonId:e},{refetchInterval:1e4,retry:!1});if(n||!t)return null;let r=b.safeParse(t);if(!r.success)return null;let i=r.data,a=i.linkState===`linked`?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:i.linkState===`error`?`bg-danger/15 text-danger`:`bg-foreground-subtle/15 text-foreground-subtle`;return o($,{label:`${i.linkState} • ${i.exposedDeviceCount} exposed`,className:a})}function ae({kind:e,addonId:t}){return e===`broker`?o(re,{addonId:t}):e===`device-export`?o(ie,{addonId:t}):null}function oe({descriptor:e,rows:n,isLoading:i}){let a=te(e.kind),c=e.kind===`device-export`,l=D();return o(F,{title:e.title,subtitle:e.subtitle,pageIcon:e.icon,itemIcon:e.icon,capability:a??e.kind,installButtonLabel:e.addLabel,items:n,isLoading:i,emptyTitle:e.emptyTitle,emptyDescription:e.emptyDescription,renderStatusBadges:n=>{let i=ne(n.processState);return t(r,{children:[o($,{label:i.label,className:i.className}),o(ae,{kind:e.kind,addonId:n.addonId})]})},renderExpandedPanel:c?e=>o(s,{addonId:e.addonId,onOpenDevice:e=>l(`/devices/${e}`)}):void 0,showChrome:!0})}function se(){let e=p(void 0,{refetchInterval:1e4}),t=(e.data??[]).map(Z).filter(e=>e!==null);return o(j,{icon:ee,title:`External systems`,subtitle:`External systems this hub talks to — device exporters, email relays, and message brokers. Settings, Logs and Events are docked under every provider.`,children:o(M,{tabs:Y.map(n=>{let r=Object.entries(y).filter(([,e])=>e===n.kind).map(([e])=>e),i=n.kind===`broker`?o(J,{}):o(oe,{descriptor:n,rows:Q(t,r),isLoading:e.isLoading});return{id:n.tabId,label:n.title,icon:n.icon,content:i}})})})}export{se as IntegrationsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Q as e,S as t,W as n,b as r,o as i,q as a,x as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Jr as s,Tr as c,Xr as l,_ as u,ai as d,jt as f,ni as p,nt as m,ti as h}from"./src-BLs3JnCT.js";import{t as g}from"./bell-ring-D6RgrV33.js";import{t as _}from"./boxes-Di4H7szx.js";import{t as v}from"./circle-dot-Bynvvq-p.js";import{t as y}from"./flame-COul3umE.js";import{t as b}from"./pencil-DRBv7Lne.js";import{t as x}from"./plus-Bn6mAUY6.js";import{t as S}from"./shield-alert-4RXP2qu7.js";import{t as C}from"./user-round-DhK29-A9.js";import{t as w}from"./zap-DmoickfW.js";import{C as T,H as E,J as D,L as O,Q as ee,W as k,Y as A,m as j,o as M,p as te,q as N,r as P,u as F,x as ne,z as I}from"./index-YqMXmKC_.js";import{t as re}from"./AdminPage-CiKtOLQm.js";import{i as ie}from"./rule-device-filter-BucaBSBx.js";var L=D(`air-vent`,[[`path`,{d:`M18 17.5a2.5 2.5 0 1 1-4 2.03V12`,key:`yd12zl`}],[`path`,{d:`M6 12H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2`,key:`larmp2`}],[`path`,{d:`M6 8h12`,key:`6g4wlu`}],[`path`,{d:`M6.6 15.572A2 2 0 1 0 10 17v-5`,key:`1x1kqn`}]]),R=D(`alarm-smoke`,[[`path`,{d:`M11 21c0-2.5 2-2.5 2-5`,key:`1sicvv`}],[`path`,{d:`M16 21c0-2.5 2-2.5 2-5`,key:`1o3eny`}],[`path`,{d:`m19 8-.8 3a1.25 1.25 0 0 1-1.2 1H7a1.25 1.25 0 0 1-1.2-1L5 8`,key:`1bvca4`}],[`path`,{d:`M21 3a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a1 1 0 0 1 1-1z`,key:`x3qr1j`}],[`path`,{d:`M6 21c0-2.5 2-2.5 2-5`,key:`i3w1gp`}]]),z=D(`blinds`,[[`path`,{d:`M3 3h18`,key:`o7r712`}],[`path`,{d:`M20 7H8`,key:`gd2fo2`}],[`path`,{d:`M20 11H8`,key:`1ynp89`}],[`path`,{d:`M10 19h10`,key:`19hjk5`}],[`path`,{d:`M8 15h12`,key:`1yqzne`}],[`path`,{d:`M4 3v14`,key:`fggqzn`}],[`circle`,{cx:`4`,cy:`19`,r:`2`,key:`p3m9r0`}]]),B=D(`circle-arrow-up`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]),ae=D(`cloud-sun`,[[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}],[`path`,{d:`M15.947 12.65a4 4 0 0 0-5.925-4.128`,key:`dpwdj0`}],[`path`,{d:`M13 22H7a5 5 0 1 1 4.9-6H13a3 3 0 0 1 0 6Z`,key:`s09mg5`}]]),oe=D(`droplet`,[[`path`,{d:`M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z`,key:`c7niix`}]]),V=D(`droplets`,[[`path`,{d:`M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z`,key:`1ptgy4`}],[`path`,{d:`M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97`,key:`1sl1rz`}]]),H=D(`fan`,[[`path`,{d:`M10.827 16.379a6.082 6.082 0 0 1-8.618-7.002l5.412 1.45a6.082 6.082 0 0 1 7.002-8.618l-1.45 5.412a6.082 6.082 0 0 1 8.618 7.002l-5.412-1.45a6.082 6.082 0 0 1-7.002 8.618l1.45-5.412Z`,key:`484a7f`}],[`path`,{d:`M12 12v.01`,key:`u5ubse`}]]),U=D(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),W=D(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),G=D(`router`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,key:`w68u3i`}],[`path`,{d:`M6.01 18H6`,key:`19vcac`}],[`path`,{d:`M10.01 18H10`,key:`uamcmx`}],[`path`,{d:`M15 10v4`,key:`qjz1xs`}],[`path`,{d:`M17.84 7.17a4 4 0 0 0-5.66 0`,key:`1rif40`}],[`path`,{d:`M20.66 4.34a8 8 0 0 0-11.31 0`,key:`6a5xfq`}]]),K=D(`siren`,[[`path`,{d:`M7 18v-6a5 5 0 1 1 10 0v6`,key:`pcx96s`}],[`path`,{d:`M5 21a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2z`,key:`1b4s83`}],[`path`,{d:`M21 12h1`,key:`jtio3y`}],[`path`,{d:`M18.5 4.5 18 5`,key:`g5sp9y`}],[`path`,{d:`M2 12h1`,key:`1uaihz`}],[`path`,{d:`M12 2v1`,key:`11qlp1`}],[`path`,{d:`m4.929 4.929.707.707`,key:`1i51kw`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}]]),q=D(`speaker`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,key:`1nb95v`}],[`path`,{d:`M12 6h.01`,key:`1vi96p`}],[`circle`,{cx:`12`,cy:`14`,r:`4`,key:`1jruaj`}],[`path`,{d:`M12 14h.01`,key:`1etili`}]]),se=D(`thermometer`,[[`path`,{d:`M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z`,key:`17jzev`}]]),ce=D(`toggle-right`,[[`circle`,{cx:`15`,cy:`12`,r:`3`,key:`1afu0r`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`7`,key:`g7kal2`}]]),le=D(`tractor`,[[`path`,{d:`m10 11 11 .9a1 1 0 0 1 .8 1.1l-.665 4.158a1 1 0 0 1-.988.842H20`,key:`she1j9`}],[`path`,{d:`M16 18h-5`,key:`bq60fd`}],[`path`,{d:`M18 5a1 1 0 0 0-1 1v5.573`,key:`1kv8ia`}],[`path`,{d:`M3 4h8.129a1 1 0 0 1 .99.863L13 11.246`,key:`1q1ert`}],[`path`,{d:`M4 11V4`,key:`9ft8pt`}],[`path`,{d:`M7 15h.01`,key:`k5ht0j`}],[`path`,{d:`M8 10.1V4`,key:`1jgyzo`}],[`circle`,{cx:`18`,cy:`18`,r:`2`,key:`1emm8v`}],[`circle`,{cx:`7`,cy:`15`,r:`5`,key:`ddtuc`}]]),ue=D(`workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]);e();var de={camera:E,hub:G,container:_,light:W,siren:K,switch:ce,sensor:N,thermostat:se,climate:L,button:v,"event-emitter":w,update:B,notifier:g,script:j,automation:ue,lock:T,cover:z,valve:oe,humidifier:V,"water-heater":y,fan:H,"media-player":q,"alarm-panel":S,control:F,presence:C,weather:ae,vacuum:k,"lawn-mower":le,image:U,smoke:R};function J({type:e,className:t}){return o(de[e]??v,{"aria-hidden":`true`,className:t??`h-3.5 w-3.5 shrink-0 text-foreground-subtle`})}function Y({online:e,deviceName:t}){return o(`span`,{className:e?`inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500`:`inline-block h-1.5 w-1.5 shrink-0 rounded-full border border-foreground-subtle`,role:`img`,"aria-label":`${t}: ${e?`online`:`offline`}`,title:e?`online`:`offline`})}function X(e){if(e==null)return null;let t=e.trim();return t.length===0?null:t.toLowerCase()}function Z(e,t){let n=X(t);return n===null?[]:e.filter(e=>X(e.location)===n)}function fe(e,t){let n=Z(e,t),r=new Set(n.map(e=>e.id));return n.filter(e=>e.parentDeviceId===null||!r.has(e.parentDeviceId))}function pe(e,t){let n=X(e.location);return n===null||new Set(t.map(e=>X(e))).has(n)?null:e.location?.trim()??null}function Q(e,t){let n=X(e.location);return n!==null&&t.has(n)}function me(e,t){let n=new Set(t.map(e=>X(e))),r=new Set(e.filter(e=>Q(e,n)).map(e=>e.id));return e.filter(e=>!(Q(e,n)||e.parentDeviceId!==null&&r.has(e.parentDeviceId)))}function he(e,t){return me(e,t).filter(e=>e.parentDeviceId===null)}function ge(e,t){let n=new Map;for(let t of e){if(t.parentDeviceId===null)continue;let e=n.get(t.parentDeviceId);e?e.push(t):n.set(t.parentDeviceId,[t])}let r=[],i=new Set([t]),a=[t];for(;a.length>0;){let e=[];for(let t of a)for(let a of n.get(t)??[])i.has(a.id)||(i.add(a.id),r.push(a),e.push(a.id));a=e}return r}function _e(e,t){return ge(e,t).length}function ve(e,t){return e.filter(e=>!e.isCamera&&e.parentDeviceId===t)}function ye(e,t){return t.map(t=>({name:t,members:fe(e,t)}))}var be={search:``,types:[]};function $(e,t){let n=t.search.trim().toLowerCase(),r=new Set(t.types);return e.filter(e=>!(r.size>0&&!r.has(e.type)||n!==``&&!e.name.toLowerCase().includes(n)))}function xe({name:e,members:n,devices:i,busy:s,onRename:c,onDelete:l}){let[d,f]=a(!1),[p,m]=a(e),h=()=>{m(e),f(!1)},g=async()=>{let t=p.trim();if(t.length===0||t===e){h();return}await c(t),f(!1)};return t(`section`,{className:`min-w-0 rounded-md border border-border bg-surface`,children:[o(`header`,{className:`flex items-center gap-1.5 border-b border-border px-3 py-1.5`,children:d?t(r,{children:[o(`input`,{value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&g(),e.key===`Escape`&&h()},"aria-label":`Rename ${e}`,className:`min-w-0 flex-1 rounded border border-border bg-background px-1.5 py-0.5 text-sm font-semibold text-foreground`,autoFocus:!0}),o(`button`,{type:`button`,onClick:()=>void g(),className:`text-[11px] text-foreground-subtle hover:text-foreground`,children:`Save`}),o(`button`,{type:`button`,onClick:h,"aria-label":`Cancel rename`,className:`p-0.5 text-foreground-subtle hover:text-foreground`,children:o(P,{className:`h-3.5 w-3.5`})})]}):t(r,{children:[o(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:e}),o(u,{items:[{id:`rename`,label:`Rename`,icon:b,disabled:s,onClick:()=>{m(e),f(!0)}},{id:`delete`,label:`Delete`,icon:M,danger:!0,separatorBefore:!0,disabled:s,onClick:()=>void l()}],title:`Actions for ${e}`,triggerClassName:`p-1`})]})}),n.length===0?o(`p`,{className:`px-3 py-3 text-[11px] text-foreground-subtle`,children:`Nothing here yet — assign a device from the table below.`}):o(`ul`,{className:`py-0.5`,children:n.map(e=>o(Se,{device:e,accessories:ve(i,e.id)},e.id))})]})}function Se({device:e,accessories:n}){let[r,i]=a(!1),s=r?I:O;return t(`li`,{className:`px-3 py-0.5`,children:[t(`div`,{className:`flex items-center gap-1.5`,children:[n.length>0?t(`button`,{type:`button`,onClick:()=>i(e=>!e),"aria-expanded":r,"aria-label":`${r?`Collapse`:`Expand`} ${String(n.length)} companion device(s) of ${e.name}`,className:`flex shrink-0 items-center gap-0.5 rounded p-0.5 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:[o(s,{className:`h-3 w-3`}),o(`span`,{className:`text-[10px] tabular-nums`,children:n.length})]}):o(`span`,{"aria-hidden":`true`,className:`w-[1.35rem] shrink-0`}),o(J,{type:e.type}),o(A,{to:`/devices/${String(e.id)}`,className:`min-w-0 flex-1 truncate text-xs text-foreground hover:underline`,children:e.name}),o(Y,{online:e.online,deviceName:e.name})]}),n.length>0&&r&&o(`ul`,{className:`pl-4`,children:n.map(e=>t(`li`,{className:`flex items-center gap-1.5 py-0.5`,children:[o(`span`,{"aria-hidden":`true`,className:`text-[10px] text-foreground-subtle`,children:`└`}),o(J,{type:e.type,className:`h-3 w-3 shrink-0 text-foreground-subtle`}),o(A,{to:`/devices/${String(e.id)}`,className:`min-w-0 flex-1 truncate text-[11px] text-foreground-muted hover:underline`,children:e.name}),o(Y,{online:e.online,deviceName:e.name})]},e.id))})]})}e();function Ce({busy:e,onCreate:n}){let[r,i]=a(!1),[s,c]=a(``),l=()=>{c(``),i(!1)},u=async()=>{let e=s.trim();e.length!==0&&(await n(e),l())};return r?t(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),u()},children:[o(`input`,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Escape`&&l()},placeholder:`Ingresso, Salone, Cucina…`,"aria-label":`New location name`,className:`min-w-[16rem] flex-1 rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,autoFocus:!0}),t(`button`,{type:`submit`,disabled:s.trim().length===0||e,className:`inline-flex items-center gap-1 rounded border border-border bg-surface px-2 py-1.5 text-xs font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[o(x,{className:`h-3.5 w-3.5`}),`Add`]}),o(`button`,{type:`button`,onClick:l,"aria-label":`Cancel new location`,className:`p-1 text-foreground-subtle hover:text-foreground`,children:o(P,{className:`h-3.5 w-3.5`})})]}):t(`button`,{type:`button`,onClick:()=>i(!0),className:`inline-flex w-fit items-center gap-1 rounded border border-border bg-surface px-2 py-1.5 text-xs font-medium text-foreground hover:bg-surface-hover`,children:[o(x,{className:`h-3.5 w-3.5`}),`New location`]})}e();function we({rows:e,fleet:r,locations:i,busy:s,emptyMessage:c,onAssign:l}){let[u,d]=a([]),[p,h]=a(``),g=n(()=>e.map(e=>e.id),[e]),_=n(()=>u.filter(e=>g.includes(e)),[u,g]),v=e.length>0&&_.length===e.length,y=n(()=>{let t=new Map;for(let n of e)t.set(n.id,_e(r,n.id));return t},[e,r]),b=_.reduce((e,t)=>e+(y.get(t)??0),0),x=e=>d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),S=()=>d(v?[]:g);return t(`section`,{className:`space-y-2`,children:[t(`header`,{className:`flex flex-wrap items-baseline gap-2`,children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Not in a room`}),o(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Top-level devices only — accessories move with their parent.`})]}),_.length>0&&t(`div`,{role:`group`,"aria-label":`Bulk assignment`,className:`flex flex-wrap items-center gap-2 rounded border border-primary/40 bg-primary/5 px-2 py-1.5`,children:[t(`span`,{className:`text-[11px] text-foreground`,children:[_.length,` selected`,b>0&&` · ${String(b)} accessories in tow`]}),t(`select`,{"aria-label":`Assign selected devices to`,value:p,onChange:e=>h(e.target.value),className:`rounded border border-border bg-background px-1.5 py-0.5 text-[11px] text-foreground`,children:[o(`option`,{value:``,children:`Assign to…`}),i.map(e=>o(`option`,{value:e,children:e},e))]}),o(`button`,{type:`button`,onClick:()=>{p.length===0||_.length===0||(l(_,p),d([]),h(``))},disabled:s||p.length===0,className:`rounded border border-border bg-surface px-2 py-0.5 text-[11px] font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:`Assign`}),o(`button`,{type:`button`,onClick:()=>d([]),className:`text-[11px] text-foreground-subtle hover:text-foreground`,children:`Clear`})]}),o(m,{columns:[{key:`select`,width:`w-8`,headerRender:()=>o(f,{checked:v,onChange:S,"aria-label":v?`Clear selection`:`Select all unassigned devices`}),render:e=>o(f,{checked:_.includes(e.id),onChange:()=>x(e.id),"aria-label":`Select ${e.name}`})},{key:`name`,header:`Device`,sortValue:e=>e.name.toLowerCase(),render:e=>{let n=pe(e,i);return t(`span`,{className:`flex items-center gap-1.5`,children:[o(J,{type:e.type}),o(A,{to:`/devices/${String(e.id)}`,className:`truncate text-xs text-foreground hover:underline`,children:e.name}),n!==null&&t(`span`,{className:`rounded-full border border-warning/40 px-1.5 py-px text-[10px] text-warning`,children:[`unknown room “`,n,`”`]})]})}},{key:`type`,header:`Type`,sortValue:e=>e.type,render:e=>o(`span`,{className:`text-[11px] text-foreground-muted`,children:e.type})},{key:`status`,header:`Status`,sortValue:e=>+!!e.online,render:e=>t(`span`,{className:`flex items-center gap-1.5`,children:[o(Y,{online:e.online,deviceName:e.name}),o(`span`,{className:`text-[11px] text-foreground-muted`,children:e.online?`online`:`offline`})]})},{key:`followers`,header:`Accessories in tow`,align:`right`,sortValue:e=>y.get(e.id)??0,render:e=>o(`span`,{className:`tabular-nums text-[11px] text-foreground-muted`,children:y.get(e.id)??0})},{key:`assign`,header:`Assign to`,align:`right`,notSortableReason:`This column is a control, not a value.`,render:e=>t(`select`,{"aria-label":`Location for ${e.name}`,value:``,disabled:s||i.length===0,onChange:t=>{let n=t.target.value;n.length!==0&&l([e.id],n)},className:`max-w-[11rem] rounded border border-border bg-background px-1.5 py-0.5 text-[11px] text-foreground disabled:opacity-50`,children:[o(`option`,{value:``,children:`—`}),i.map(e=>o(`option`,{value:e,children:e},e))]})}],rows:e,rowKey:e=>e.id,minWidthPx:720,mobileMode:`scroll`,emptyMessage:c})]})}e();function Te(){let e=i(),{data:r,isLoading:u}=l(),{data:f,isLoading:m}=s({projection:`slim`}),[g,_]=a(be),v=()=>{e.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]}),e.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]})},y=c({onSuccess:v}),b=h({onSuccess:v}),x=d({onSuccess:v}),S=p({onSuccess:v}),C=n(()=>(f??[]).map(e=>({id:e.id,name:e.name,location:e.location??null,type:String(e.type),isCamera:e.isCamera,parentDeviceId:e.parentDeviceId,online:e.online,role:e.role??null})),[f]),w=n(()=>ie(C),[C]),T=n(()=>$(C,g),[C,g]),E=r??[],D=n(()=>ye(T,E),[T,E]),[O,k]=ee(),A=O.get(`room`),j=A!==null&&D.some(e=>e.name===A)?A:D[0]?.name??null,M=D.find(e=>e.name===j)??null,N=e=>{k(t=>{let n=new URLSearchParams(t);return n.set(`room`,e),n},{replace:!0})},P=n(()=>he(T,E),[T,E]),F=u||m,I=x.isPending||b.isPending||y.isPending,L=e=>_(t=>({...t,types:t.types.includes(e)?t.types.filter(t=>t!==e):[...t.types,e]})),R=async e=>{await y.mutateAsync({name:e})},z=async(e,t)=>{let n=t.trim();n.length===0||n===e||await S.mutateAsync({from:e,to:n})},B=async(e,t)=>{let n=t>0?` ${String(t)} device(s) will become unassigned.`:``;window.confirm(`Delete location “${e}”?${n}`)&&await b.mutateAsync({name:e,cascade:!0})};return t(re,{icon:ne,title:`Locations`,subtitle:`Rooms and areas of the site. Assign any device here — storage disks are under Data → Storage.`,children:[o(Ce,{busy:y.isPending,onCreate:R}),o(`div`,{className:`flex flex-wrap items-center gap-2`,children:t(`label`,{className:`relative min-w-[12rem] flex-1`,children:[o(te,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`}),o(`input`,{value:g.search,onChange:e=>_(t=>({...t,search:e.target.value})),placeholder:`Search devices by name…`,"aria-label":`Search devices by name`,className:`w-full rounded border border-border bg-background py-1.5 pl-7 pr-2 text-xs text-foreground`})]})}),w.length>0&&o(`div`,{className:`flex flex-wrap gap-1`,children:w.map(e=>t(`button`,{type:`button`,onClick:()=>L(e.type),"aria-pressed":g.types.includes(e.type),className:g.types.includes(e.type)?`rounded-full border border-primary bg-primary/10 px-2 py-0.5 text-[10px] text-foreground`:`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-muted hover:bg-surface-hover`,children:[e.type,` `,o(`span`,{className:`text-foreground-subtle`,children:e.count})]},e.type))}),F&&o(`p`,{className:`text-xs text-foreground-subtle`,children:`Loading locations and devices…`}),D.length>0&&o(`div`,{role:`tablist`,"aria-label":`Locations`,className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,children:D.map(e=>{let n=e.name===j;return t(`button`,{type:`button`,role:`tab`,"aria-selected":n,onClick:()=>N(e.name),className:n?`shrink-0 whitespace-nowrap rounded-full border border-primary bg-primary/10 px-3 py-1 text-xs text-foreground`:`shrink-0 whitespace-nowrap rounded-full border border-border px-3 py-1 text-xs text-foreground-muted hover:bg-surface-hover`,children:[e.name,` `,o(`span`,{className:`text-foreground-subtle tabular-nums`,children:e.members.length})]},e.name)})}),M!==null&&o(xe,{name:M.name,members:M.members,devices:T,busy:I,onRename:e=>z(M.name,e),onDelete:()=>B(M.name,Z(C,M.name).length)},M.name),E.length===0&&!F&&o(`p`,{className:`text-xs text-foreground-subtle`,children:`No locations yet. Add Ingresso, Salone, Cucina…`}),o(we,{rows:P,fleet:C,locations:E,busy:I,emptyMessage:F?`Loading…`:`Every top-level device has a room.`,onAssign:(e,t)=>{for(let n of e)x.mutate({deviceId:n,location:t})}})]})}export{Te as LocationsPage};
|
|
1
|
+
import{Q as e,S as t,W as n,b as r,o as i,q as a,x as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Jr as s,Tr as c,Xr as l,_ as u,ai as d,jt as f,ni as p,nt as m,ti as h}from"./src-CLAf92SY.js";import{t as g}from"./bell-ring-C7bMrYRU.js";import{t as _}from"./boxes-DUWmFsrP.js";import{t as v}from"./circle-dot-CzW0cNTB.js";import{t as y}from"./flame-WU7l8HOV.js";import{t as b}from"./pencil-DICsE4Gy.js";import{t as x}from"./plus-BhEMDQtU.js";import{t as S}from"./shield-alert-DvcWv6qf.js";import{t as C}from"./user-round-CssMH_tg.js";import{t as w}from"./zap-D5PZRv07.js";import{C as T,H as E,J as D,L as O,Q as ee,W as k,Y as A,m as j,o as M,p as te,q as N,r as P,u as F,x as ne,z as I}from"./index-DL2yqdrc.js";import{t as re}from"./AdminPage-CiKtOLQm.js";import{i as ie}from"./rule-device-filter-BucaBSBx.js";var L=D(`air-vent`,[[`path`,{d:`M18 17.5a2.5 2.5 0 1 1-4 2.03V12`,key:`yd12zl`}],[`path`,{d:`M6 12H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2`,key:`larmp2`}],[`path`,{d:`M6 8h12`,key:`6g4wlu`}],[`path`,{d:`M6.6 15.572A2 2 0 1 0 10 17v-5`,key:`1x1kqn`}]]),R=D(`alarm-smoke`,[[`path`,{d:`M11 21c0-2.5 2-2.5 2-5`,key:`1sicvv`}],[`path`,{d:`M16 21c0-2.5 2-2.5 2-5`,key:`1o3eny`}],[`path`,{d:`m19 8-.8 3a1.25 1.25 0 0 1-1.2 1H7a1.25 1.25 0 0 1-1.2-1L5 8`,key:`1bvca4`}],[`path`,{d:`M21 3a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a1 1 0 0 1 1-1z`,key:`x3qr1j`}],[`path`,{d:`M6 21c0-2.5 2-2.5 2-5`,key:`i3w1gp`}]]),z=D(`blinds`,[[`path`,{d:`M3 3h18`,key:`o7r712`}],[`path`,{d:`M20 7H8`,key:`gd2fo2`}],[`path`,{d:`M20 11H8`,key:`1ynp89`}],[`path`,{d:`M10 19h10`,key:`19hjk5`}],[`path`,{d:`M8 15h12`,key:`1yqzne`}],[`path`,{d:`M4 3v14`,key:`fggqzn`}],[`circle`,{cx:`4`,cy:`19`,r:`2`,key:`p3m9r0`}]]),B=D(`circle-arrow-up`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]),ae=D(`cloud-sun`,[[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}],[`path`,{d:`M15.947 12.65a4 4 0 0 0-5.925-4.128`,key:`dpwdj0`}],[`path`,{d:`M13 22H7a5 5 0 1 1 4.9-6H13a3 3 0 0 1 0 6Z`,key:`s09mg5`}]]),oe=D(`droplet`,[[`path`,{d:`M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z`,key:`c7niix`}]]),V=D(`droplets`,[[`path`,{d:`M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z`,key:`1ptgy4`}],[`path`,{d:`M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97`,key:`1sl1rz`}]]),H=D(`fan`,[[`path`,{d:`M10.827 16.379a6.082 6.082 0 0 1-8.618-7.002l5.412 1.45a6.082 6.082 0 0 1 7.002-8.618l-1.45 5.412a6.082 6.082 0 0 1 8.618 7.002l-5.412-1.45a6.082 6.082 0 0 1-7.002 8.618l1.45-5.412Z`,key:`484a7f`}],[`path`,{d:`M12 12v.01`,key:`u5ubse`}]]),U=D(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),W=D(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),G=D(`router`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,key:`w68u3i`}],[`path`,{d:`M6.01 18H6`,key:`19vcac`}],[`path`,{d:`M10.01 18H10`,key:`uamcmx`}],[`path`,{d:`M15 10v4`,key:`qjz1xs`}],[`path`,{d:`M17.84 7.17a4 4 0 0 0-5.66 0`,key:`1rif40`}],[`path`,{d:`M20.66 4.34a8 8 0 0 0-11.31 0`,key:`6a5xfq`}]]),K=D(`siren`,[[`path`,{d:`M7 18v-6a5 5 0 1 1 10 0v6`,key:`pcx96s`}],[`path`,{d:`M5 21a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2z`,key:`1b4s83`}],[`path`,{d:`M21 12h1`,key:`jtio3y`}],[`path`,{d:`M18.5 4.5 18 5`,key:`g5sp9y`}],[`path`,{d:`M2 12h1`,key:`1uaihz`}],[`path`,{d:`M12 2v1`,key:`11qlp1`}],[`path`,{d:`m4.929 4.929.707.707`,key:`1i51kw`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}]]),q=D(`speaker`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,key:`1nb95v`}],[`path`,{d:`M12 6h.01`,key:`1vi96p`}],[`circle`,{cx:`12`,cy:`14`,r:`4`,key:`1jruaj`}],[`path`,{d:`M12 14h.01`,key:`1etili`}]]),se=D(`thermometer`,[[`path`,{d:`M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z`,key:`17jzev`}]]),ce=D(`toggle-right`,[[`circle`,{cx:`15`,cy:`12`,r:`3`,key:`1afu0r`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`7`,key:`g7kal2`}]]),le=D(`tractor`,[[`path`,{d:`m10 11 11 .9a1 1 0 0 1 .8 1.1l-.665 4.158a1 1 0 0 1-.988.842H20`,key:`she1j9`}],[`path`,{d:`M16 18h-5`,key:`bq60fd`}],[`path`,{d:`M18 5a1 1 0 0 0-1 1v5.573`,key:`1kv8ia`}],[`path`,{d:`M3 4h8.129a1 1 0 0 1 .99.863L13 11.246`,key:`1q1ert`}],[`path`,{d:`M4 11V4`,key:`9ft8pt`}],[`path`,{d:`M7 15h.01`,key:`k5ht0j`}],[`path`,{d:`M8 10.1V4`,key:`1jgyzo`}],[`circle`,{cx:`18`,cy:`18`,r:`2`,key:`1emm8v`}],[`circle`,{cx:`7`,cy:`15`,r:`5`,key:`ddtuc`}]]),ue=D(`workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]);e();var de={camera:E,hub:G,container:_,light:W,siren:K,switch:ce,sensor:N,thermostat:se,climate:L,button:v,"event-emitter":w,update:B,notifier:g,script:j,automation:ue,lock:T,cover:z,valve:oe,humidifier:V,"water-heater":y,fan:H,"media-player":q,"alarm-panel":S,control:F,presence:C,weather:ae,vacuum:k,"lawn-mower":le,image:U,smoke:R};function J({type:e,className:t}){return o(de[e]??v,{"aria-hidden":`true`,className:t??`h-3.5 w-3.5 shrink-0 text-foreground-subtle`})}function Y({online:e,deviceName:t}){return o(`span`,{className:e?`inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500`:`inline-block h-1.5 w-1.5 shrink-0 rounded-full border border-foreground-subtle`,role:`img`,"aria-label":`${t}: ${e?`online`:`offline`}`,title:e?`online`:`offline`})}function X(e){if(e==null)return null;let t=e.trim();return t.length===0?null:t.toLowerCase()}function Z(e,t){let n=X(t);return n===null?[]:e.filter(e=>X(e.location)===n)}function fe(e,t){let n=Z(e,t),r=new Set(n.map(e=>e.id));return n.filter(e=>e.parentDeviceId===null||!r.has(e.parentDeviceId))}function pe(e,t){let n=X(e.location);return n===null||new Set(t.map(e=>X(e))).has(n)?null:e.location?.trim()??null}function Q(e,t){let n=X(e.location);return n!==null&&t.has(n)}function me(e,t){let n=new Set(t.map(e=>X(e))),r=new Set(e.filter(e=>Q(e,n)).map(e=>e.id));return e.filter(e=>!(Q(e,n)||e.parentDeviceId!==null&&r.has(e.parentDeviceId)))}function he(e,t){return me(e,t).filter(e=>e.parentDeviceId===null)}function ge(e,t){let n=new Map;for(let t of e){if(t.parentDeviceId===null)continue;let e=n.get(t.parentDeviceId);e?e.push(t):n.set(t.parentDeviceId,[t])}let r=[],i=new Set([t]),a=[t];for(;a.length>0;){let e=[];for(let t of a)for(let a of n.get(t)??[])i.has(a.id)||(i.add(a.id),r.push(a),e.push(a.id));a=e}return r}function _e(e,t){return ge(e,t).length}function ve(e,t){return e.filter(e=>!e.isCamera&&e.parentDeviceId===t)}function ye(e,t){return t.map(t=>({name:t,members:fe(e,t)}))}var be={search:``,types:[]};function $(e,t){let n=t.search.trim().toLowerCase(),r=new Set(t.types);return e.filter(e=>!(r.size>0&&!r.has(e.type)||n!==``&&!e.name.toLowerCase().includes(n)))}function xe({name:e,members:n,devices:i,busy:s,onRename:c,onDelete:l}){let[d,f]=a(!1),[p,m]=a(e),h=()=>{m(e),f(!1)},g=async()=>{let t=p.trim();if(t.length===0||t===e){h();return}await c(t),f(!1)};return t(`section`,{className:`min-w-0 rounded-md border border-border bg-surface`,children:[o(`header`,{className:`flex items-center gap-1.5 border-b border-border px-3 py-1.5`,children:d?t(r,{children:[o(`input`,{value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&g(),e.key===`Escape`&&h()},"aria-label":`Rename ${e}`,className:`min-w-0 flex-1 rounded border border-border bg-background px-1.5 py-0.5 text-sm font-semibold text-foreground`,autoFocus:!0}),o(`button`,{type:`button`,onClick:()=>void g(),className:`text-[11px] text-foreground-subtle hover:text-foreground`,children:`Save`}),o(`button`,{type:`button`,onClick:h,"aria-label":`Cancel rename`,className:`p-0.5 text-foreground-subtle hover:text-foreground`,children:o(P,{className:`h-3.5 w-3.5`})})]}):t(r,{children:[o(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:e}),o(u,{items:[{id:`rename`,label:`Rename`,icon:b,disabled:s,onClick:()=>{m(e),f(!0)}},{id:`delete`,label:`Delete`,icon:M,danger:!0,separatorBefore:!0,disabled:s,onClick:()=>void l()}],title:`Actions for ${e}`,triggerClassName:`p-1`})]})}),n.length===0?o(`p`,{className:`px-3 py-3 text-[11px] text-foreground-subtle`,children:`Nothing here yet — assign a device from the table below.`}):o(`ul`,{className:`py-0.5`,children:n.map(e=>o(Se,{device:e,accessories:ve(i,e.id)},e.id))})]})}function Se({device:e,accessories:n}){let[r,i]=a(!1),s=r?I:O;return t(`li`,{className:`px-3 py-0.5`,children:[t(`div`,{className:`flex items-center gap-1.5`,children:[n.length>0?t(`button`,{type:`button`,onClick:()=>i(e=>!e),"aria-expanded":r,"aria-label":`${r?`Collapse`:`Expand`} ${String(n.length)} companion device(s) of ${e.name}`,className:`flex shrink-0 items-center gap-0.5 rounded p-0.5 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:[o(s,{className:`h-3 w-3`}),o(`span`,{className:`text-[10px] tabular-nums`,children:n.length})]}):o(`span`,{"aria-hidden":`true`,className:`w-[1.35rem] shrink-0`}),o(J,{type:e.type}),o(A,{to:`/devices/${String(e.id)}`,className:`min-w-0 flex-1 truncate text-xs text-foreground hover:underline`,children:e.name}),o(Y,{online:e.online,deviceName:e.name})]}),n.length>0&&r&&o(`ul`,{className:`pl-4`,children:n.map(e=>t(`li`,{className:`flex items-center gap-1.5 py-0.5`,children:[o(`span`,{"aria-hidden":`true`,className:`text-[10px] text-foreground-subtle`,children:`└`}),o(J,{type:e.type,className:`h-3 w-3 shrink-0 text-foreground-subtle`}),o(A,{to:`/devices/${String(e.id)}`,className:`min-w-0 flex-1 truncate text-[11px] text-foreground-muted hover:underline`,children:e.name}),o(Y,{online:e.online,deviceName:e.name})]},e.id))})]})}e();function Ce({busy:e,onCreate:n}){let[r,i]=a(!1),[s,c]=a(``),l=()=>{c(``),i(!1)},u=async()=>{let e=s.trim();e.length!==0&&(await n(e),l())};return r?t(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),u()},children:[o(`input`,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Escape`&&l()},placeholder:`Ingresso, Salone, Cucina…`,"aria-label":`New location name`,className:`min-w-[16rem] flex-1 rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,autoFocus:!0}),t(`button`,{type:`submit`,disabled:s.trim().length===0||e,className:`inline-flex items-center gap-1 rounded border border-border bg-surface px-2 py-1.5 text-xs font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[o(x,{className:`h-3.5 w-3.5`}),`Add`]}),o(`button`,{type:`button`,onClick:l,"aria-label":`Cancel new location`,className:`p-1 text-foreground-subtle hover:text-foreground`,children:o(P,{className:`h-3.5 w-3.5`})})]}):t(`button`,{type:`button`,onClick:()=>i(!0),className:`inline-flex w-fit items-center gap-1 rounded border border-border bg-surface px-2 py-1.5 text-xs font-medium text-foreground hover:bg-surface-hover`,children:[o(x,{className:`h-3.5 w-3.5`}),`New location`]})}e();function we({rows:e,fleet:r,locations:i,busy:s,emptyMessage:c,onAssign:l}){let[u,d]=a([]),[p,h]=a(``),g=n(()=>e.map(e=>e.id),[e]),_=n(()=>u.filter(e=>g.includes(e)),[u,g]),v=e.length>0&&_.length===e.length,y=n(()=>{let t=new Map;for(let n of e)t.set(n.id,_e(r,n.id));return t},[e,r]),b=_.reduce((e,t)=>e+(y.get(t)??0),0),x=e=>d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),S=()=>d(v?[]:g);return t(`section`,{className:`space-y-2`,children:[t(`header`,{className:`flex flex-wrap items-baseline gap-2`,children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Not in a room`}),o(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Top-level devices only — accessories move with their parent.`})]}),_.length>0&&t(`div`,{role:`group`,"aria-label":`Bulk assignment`,className:`flex flex-wrap items-center gap-2 rounded border border-primary/40 bg-primary/5 px-2 py-1.5`,children:[t(`span`,{className:`text-[11px] text-foreground`,children:[_.length,` selected`,b>0&&` · ${String(b)} accessories in tow`]}),t(`select`,{"aria-label":`Assign selected devices to`,value:p,onChange:e=>h(e.target.value),className:`rounded border border-border bg-background px-1.5 py-0.5 text-[11px] text-foreground`,children:[o(`option`,{value:``,children:`Assign to…`}),i.map(e=>o(`option`,{value:e,children:e},e))]}),o(`button`,{type:`button`,onClick:()=>{p.length===0||_.length===0||(l(_,p),d([]),h(``))},disabled:s||p.length===0,className:`rounded border border-border bg-surface px-2 py-0.5 text-[11px] font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:`Assign`}),o(`button`,{type:`button`,onClick:()=>d([]),className:`text-[11px] text-foreground-subtle hover:text-foreground`,children:`Clear`})]}),o(m,{columns:[{key:`select`,width:`w-8`,headerRender:()=>o(f,{checked:v,onChange:S,"aria-label":v?`Clear selection`:`Select all unassigned devices`}),render:e=>o(f,{checked:_.includes(e.id),onChange:()=>x(e.id),"aria-label":`Select ${e.name}`})},{key:`name`,header:`Device`,sortValue:e=>e.name.toLowerCase(),render:e=>{let n=pe(e,i);return t(`span`,{className:`flex items-center gap-1.5`,children:[o(J,{type:e.type}),o(A,{to:`/devices/${String(e.id)}`,className:`truncate text-xs text-foreground hover:underline`,children:e.name}),n!==null&&t(`span`,{className:`rounded-full border border-warning/40 px-1.5 py-px text-[10px] text-warning`,children:[`unknown room “`,n,`”`]})]})}},{key:`type`,header:`Type`,sortValue:e=>e.type,render:e=>o(`span`,{className:`text-[11px] text-foreground-muted`,children:e.type})},{key:`status`,header:`Status`,sortValue:e=>+!!e.online,render:e=>t(`span`,{className:`flex items-center gap-1.5`,children:[o(Y,{online:e.online,deviceName:e.name}),o(`span`,{className:`text-[11px] text-foreground-muted`,children:e.online?`online`:`offline`})]})},{key:`followers`,header:`Accessories in tow`,align:`right`,sortValue:e=>y.get(e.id)??0,render:e=>o(`span`,{className:`tabular-nums text-[11px] text-foreground-muted`,children:y.get(e.id)??0})},{key:`assign`,header:`Assign to`,align:`right`,notSortableReason:`This column is a control, not a value.`,render:e=>t(`select`,{"aria-label":`Location for ${e.name}`,value:``,disabled:s||i.length===0,onChange:t=>{let n=t.target.value;n.length!==0&&l([e.id],n)},className:`max-w-[11rem] rounded border border-border bg-background px-1.5 py-0.5 text-[11px] text-foreground disabled:opacity-50`,children:[o(`option`,{value:``,children:`—`}),i.map(e=>o(`option`,{value:e,children:e},e))]})}],rows:e,rowKey:e=>e.id,minWidthPx:720,mobileMode:`scroll`,emptyMessage:c})]})}e();function Te(){let e=i(),{data:r,isLoading:u}=l(),{data:f,isLoading:m}=s({projection:`slim`}),[g,_]=a(be),v=()=>{e.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]}),e.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]})},y=c({onSuccess:v}),b=h({onSuccess:v}),x=d({onSuccess:v}),S=p({onSuccess:v}),C=n(()=>(f??[]).map(e=>({id:e.id,name:e.name,location:e.location??null,type:String(e.type),isCamera:e.isCamera,parentDeviceId:e.parentDeviceId,online:e.online,role:e.role??null})),[f]),w=n(()=>ie(C),[C]),T=n(()=>$(C,g),[C,g]),E=r??[],D=n(()=>ye(T,E),[T,E]),[O,k]=ee(),A=O.get(`room`),j=A!==null&&D.some(e=>e.name===A)?A:D[0]?.name??null,M=D.find(e=>e.name===j)??null,N=e=>{k(t=>{let n=new URLSearchParams(t);return n.set(`room`,e),n},{replace:!0})},P=n(()=>he(T,E),[T,E]),F=u||m,I=x.isPending||b.isPending||y.isPending,L=e=>_(t=>({...t,types:t.types.includes(e)?t.types.filter(t=>t!==e):[...t.types,e]})),R=async e=>{await y.mutateAsync({name:e})},z=async(e,t)=>{let n=t.trim();n.length===0||n===e||await S.mutateAsync({from:e,to:n})},B=async(e,t)=>{let n=t>0?` ${String(t)} device(s) will become unassigned.`:``;window.confirm(`Delete location “${e}”?${n}`)&&await b.mutateAsync({name:e,cascade:!0})};return t(re,{icon:ne,title:`Locations`,subtitle:`Rooms and areas of the site. Assign any device here — storage disks are under Data → Storage.`,children:[o(Ce,{busy:y.isPending,onCreate:R}),o(`div`,{className:`flex flex-wrap items-center gap-2`,children:t(`label`,{className:`relative min-w-[12rem] flex-1`,children:[o(te,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`}),o(`input`,{value:g.search,onChange:e=>_(t=>({...t,search:e.target.value})),placeholder:`Search devices by name…`,"aria-label":`Search devices by name`,className:`w-full rounded border border-border bg-background py-1.5 pl-7 pr-2 text-xs text-foreground`})]})}),w.length>0&&o(`div`,{className:`flex flex-wrap gap-1`,children:w.map(e=>t(`button`,{type:`button`,onClick:()=>L(e.type),"aria-pressed":g.types.includes(e.type),className:g.types.includes(e.type)?`rounded-full border border-primary bg-primary/10 px-2 py-0.5 text-[10px] text-foreground`:`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-muted hover:bg-surface-hover`,children:[e.type,` `,o(`span`,{className:`text-foreground-subtle`,children:e.count})]},e.type))}),F&&o(`p`,{className:`text-xs text-foreground-subtle`,children:`Loading locations and devices…`}),D.length>0&&o(`div`,{role:`tablist`,"aria-label":`Locations`,className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,children:D.map(e=>{let n=e.name===j;return t(`button`,{type:`button`,role:`tab`,"aria-selected":n,onClick:()=>N(e.name),className:n?`shrink-0 whitespace-nowrap rounded-full border border-primary bg-primary/10 px-3 py-1 text-xs text-foreground`:`shrink-0 whitespace-nowrap rounded-full border border-border px-3 py-1 text-xs text-foreground-muted hover:bg-surface-hover`,children:[e.name,` `,o(`span`,{className:`text-foreground-subtle tabular-nums`,children:e.members.length})]},e.name)})}),M!==null&&o(xe,{name:M.name,members:M.members,devices:T,busy:I,onRename:e=>z(M.name,e),onDelete:()=>B(M.name,Z(C,M.name).length)},M.name),E.length===0&&!F&&o(`p`,{className:`text-xs text-foreground-subtle`,children:`No locations yet. Add Ingresso, Salone, Cucina…`}),o(we,{rows:P,fleet:C,locations:E,busy:I,emptyMessage:F?`Loading…`:`Every top-level device has a room.`,onAssign:(e,t)=>{for(let n of e)x.mutate({deviceId:n,location:t})}})]})}export{Te as LocationsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Q as e,S as t,W as n,q as r,x as i}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Mn as a,Qs as o,Y as s,gs as c,jn as l,vs as u}from"./src-BLs3JnCT.js";import{t as d}from"./layers-DZ5ZWJK2.js";import{B as f,H as p,J as m,m as h,q as g,s as _,t as v,w as y}from"./index-YqMXmKC_.js";import{t as b}from"./AdminPage-CiKtOLQm.js";import{t as x}from"./AdminTabs-DUSbhirs.js";import{t as S}from"./AddonCollectionPage-DJd0G561.js";import{t as C}from"./addon-display-names-DvSEQty-.js";var w=m(`file-text`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),T=m(`timer-reset`,[[`path`,{d:`M10 2h4`,key:`n1abiw`}],[`path`,{d:`M12 14v-4`,key:`1evpnu`}],[`path`,{d:`M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6`,key:`1ts96g`}],[`path`,{d:`M9 17H4v5`,key:`8t5av`}]]);e();var E=5e3,D={"winston-logging":`Rotated log files on this node’s disk.`,"console-logging":`stdout / stderr of the node process.`,"loki-logging":`Pushes to a Grafana Loki instance. Off until enabled with a URL.`,"hub-forwarder":`Agent-only — forwards this node’s entries to the hub.`};function O(){let e=a({capName:`log-destination`},{refetchInterval:E}),t=l(void 0,{refetchInterval:E}),r=n(()=>C(t.data??[]),[t.data]),o=n(()=>{let e=new Map;for(let n of t.data??[]){let t=n.description,r=n.id;typeof r==`string`&&typeof t==`string`&&t.length>0&&e.set(r,t)}return e},[t.data]);return i(S,{title:`Logging`,subtitle:`Every registered log destination. Entries are fanned to all enabled destinations at once — enabling one does not disable another. Each destination's own configuration is docked under it.`,pageIcon:h,itemIcon:w,capability:`log-destination`,installButtonLabel:`Add destination`,items:n(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:r.get(e.addonId)??e.addonId,isActive:e.isActive,caption:o.get(e.addonId)??D[e.addonId]??``})),[e.data,r,o]),isLoading:e.isLoading,emptyTitle:`No log destinations registered`,emptyDescription:`This should not happen — the console and rotated-file destinations are builtins. If the list is empty, the node is still booting.`,renderStatusBadges:e=>e.caption.length>0?i(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.caption}):null})}e();var k=[12e4,3e5,6e5,18e5],A={"request-census":`Counts every tRPC call by TRANSPORT PLANE — http, ws, mesh — and by procedure, caller, address and user-agent. Subscriptions are counted apart from calls, so a long-lived stream cannot pass for a storm. Arm it, then restart: the deadline is persisted, so the window is still running when clients reconnect.`};function j(){let{t:e}=v(),n=c({},{refetchInterval:5e3}),a=u(),[o,s]=r(null),l=(e,t)=>{s(e),a.mutate({patch:{diagnostics:[{id:e,armMs:t}]}},{onSettled:()=>{s(null),n.refetch()}})},d=n.data?.activeWindows??[],f=n.data?.channels??[],p=n.data?.activeChannels??[],m=(e,t,r)=>{s(e),a.mutate({patch:{channels:[{channel:e,armMs:t,deviceIds:r}]}},{onSettled:()=>{s(null),n.refetch()}})};return t(b,{icon:g,title:e(`logging.diagnostics.title`,`Diagnostics`),subtitle:e(`logging.diagnostics.subtitle`,`Diagnostics are armed for a window, never switched on. Each carries a deadline and expires by itself — one left running is an incident of its own.`),children:[n.isLoading?t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(y,{className:`h-3.5 w-3.5 animate-spin`}),e(`common.loading`,`Loading…`)]}):i(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:d.map(e=>i(N,{window:e,busy:o===e.id,onArm:t=>l(e.id,t)},e.id))}),i(`h3`,{className:`mt-6 text-sm font-medium text-foreground`,children:e(`logging.diagnostics.channels`,`Component channels`)}),i(`p`,{className:`mb-2 max-w-3xl text-[11px] text-foreground-subtle`,children:e(`logging.diagnostics.channelsSubtitle`,`Declared by the addons that own them — this list is not maintained by hand. Arming a channel opens a window with a deadline; it closes by itself.`)}),f.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`logging.diagnostics.noChannels`,`No addon on this cluster declares a log channel, or none could be reached right now.`)}):i(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:f.map(e=>i(M,{channel:e,state:p.find(t=>t.channel===e.name),busy:o===e.name,onArm:(t,n)=>m(e.name,t,n)},e.name))})]})}function M({channel:e,state:n,busy:a,onArm:o}){let{t:s}=v(),[c,l]=r(``),u=n?.armed===!0,d=()=>{let e=c.split(/[\s,+]+/).filter(e=>/^\d+$/.test(e)).map(e=>Number(e));return e.length>0?e:null};return t(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[t(`div`,{className:`min-w-0`,children:[t(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:e.name}),u?t(`span`,{className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-[10px] font-semibold text-warning`,children:[i(T,{className:`h-3 w-3`}),s(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:P(n?.remainingMs??0)})]}):i(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:s(`logging.diagnostics.disarmed`,`disarmed`)}),u&&n?.deviceIds!==null&&n?.deviceIds!==void 0&&t(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary`,children:[i(p,{className:`h-3 w-3`}),n.deviceIds.join(`, `)]}),!e.perDevice&&i(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:s(`logging.diagnostics.notPerCamera`,`not filterable per camera`)})]}),i(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:e.description})]}),t(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[e.perDevice&&i(`input`,{type:`text`,inputMode:`numeric`,value:c,disabled:a,onChange:e=>l(e.target.value),placeholder:s(`logging.diagnostics.camerasPlaceholder`,`all cameras`),className:`w-28 rounded border border-border bg-surface px-2 py-1 text-[11px] text-foreground`}),k.map(e=>i(`button`,{type:`button`,disabled:a,onClick:()=>o(e,d()),className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:P(e)},e)),i(`button`,{type:`button`,disabled:a||!u,onClick:()=>o(0,null),className:`rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-40`,children:s(`logging.diagnostics.disarm`,`Disarm`)})]})]})}function N({window:e,busy:n,onArm:r}){let{t:a}=v();return t(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[t(`div`,{className:`min-w-0`,children:[t(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:e.id}),e.armed?t(`span`,{className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-[10px] font-semibold text-warning`,children:[i(T,{className:`h-3 w-3`}),a(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:P(e.remainingMs)})]}):i(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:a(`logging.diagnostics.disarmed`,`disarmed`)}),e.armed&&!e.persisted&&i(`span`,{className:`text-[10px] text-warning`,children:a(`logging.diagnostics.notPersisted`,`not persisted — will not survive a restart`)})]}),i(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:A[e.id]??``})]}),t(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[k.map(e=>i(`button`,{type:`button`,disabled:n,onClick:()=>r(e),className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:P(e)},e)),i(`button`,{type:`button`,disabled:n||!e.armed,onClick:()=>r(0),className:`rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-40`,children:a(`logging.diagnostics.disarm`,`Disarm`)})]})]})}function P(e){let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:r===0?`${n}m`:`${n}m ${r}s`}e();var F=[`debug`,`info`,`warn`,`error`],I=``,L=``;function R(){let{t:e}=v(),[a,s]=r(I),[l,f]=r(L),{nodes:p}=o(),m=n(()=>p.map(e=>({id:e.id,label:e.name||e.id})),[p]),h=c({...a===I?{}:{scopeNodeId:a},...l===L?{}:{scopeComponent:l}},{refetchInterval:15e3}),g=u(),_=h.data,x=g.isPending||h.isFetching,S=_?.channels??[],C=(e,t)=>{g.mutate({...e.nodeId===null?{}:{scopeNodeId:e.nodeId},...e.component===null?{}:{scopeComponent:e.component},patch:{level:t}},{onSuccess:()=>void h.refetch()})};return i(b,{icon:d,title:e(`logging.levels.title`,`Levels`),subtitle:e(`logging.levels.subtitle`,`Cluster → node, most specific wins. The floor gates what reaches the log destinations; the in-memory viewer keeps every line either way.`),actions:t(`div`,{className:`flex flex-wrap items-center gap-3`,children:[t(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[e(`logging.levels.scope`,`Scope`),t(`select`,{className:`rounded border border-border bg-surface px-2 py-1 text-xs text-foreground disabled:opacity-50`,value:a,disabled:l!==L,onChange:e=>s(e.target.value),children:[i(`option`,{value:I,children:e(`logging.levels.cluster`,`Cluster`)}),m.map(e=>i(`option`,{value:e.id,children:e.label},e.id))]})]}),t(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[e(`logging.levels.component`,`Component`),t(`select`,{className:`rounded border border-border bg-surface px-2 py-1 text-xs text-foreground`,value:l,onChange:e=>f(e.target.value),children:[i(`option`,{value:L,children:e(`logging.levels.noComponent`,`None`)}),S.map(e=>i(`option`,{value:e.name,children:e.name},e.name))]})]})]}),children:h.isLoading||_===void 0?t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(y,{className:`h-3.5 w-3.5 animate-spin`}),e(`common.loading`,`Loading…`)]}):t(`div`,{className:`space-y-3`,children:[i(z,{level:_.effective.level,source:_.effective.levelSource,persisted:_.persisted}),i(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:_.explicit.layers.map(e=>i(B,{layer:e,inForce:e.scope===_.effective.levelSource,busy:x,onSet:t=>C(e,t),onClear:()=>C(e,null)},`${e.scope}:${e.nodeId??e.component??`cluster`}`))}),l!==L&&i(`p`,{className:`text-[11px] text-foreground-subtle`,children:S.find(e=>e.name===l)?.description??``}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`logging.levels.componentNote`,`A component is a log channel an addon declared. Its level is cluster-wide and beats both the node and the cluster layer.`)})]})})}function z({level:e,source:n,persisted:r}){let{t:a}=v();return t(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[t(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-xs text-foreground-subtle`,children:a(`logging.levels.effective`,`In force here`)}),i(`span`,{className:`rounded bg-primary/10 px-2 py-0.5 text-xs font-semibold text-primary`,children:e}),i(`span`,{className:`text-[11px] text-foreground-subtle`,children:n==="default"?a(`logging.levels.fromDefault`,`nothing is set anywhere — this is the default`):a(`logging.levels.fromLayer`,`decided by the {{source}} layer`,{source:n})})]}),!r&&i(`p`,{className:`mt-1 text-[11px] text-warning`,children:a(`logging.levels.notPersisted`,`The settings store could not be read or written — what you see is live, but it would not survive a restart.`)})]})}function B({layer:e,inForce:n,busy:r,onSet:a,onClear:o}){let{t:s}=v();return t(`div`,{className:`flex flex-col gap-2 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[t(`div`,{className:`min-w-0`,children:[t(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:e.scope===`cluster`?s(`logging.levels.cluster`,`Cluster`):e.scope===`component`?e.component??``:e.nodeId??``}),n&&t(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary`,children:[i(f,{className:`h-3 w-3`}),s(`logging.levels.inForce`,`in force`)]})]}),i(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:e.level===null?s(`logging.levels.inherits`,`inherits — nothing set at this layer`):s(`logging.levels.setHere`,`set here: {{level}}`,{level:e.level})})]}),t(`div`,{className:`flex shrink-0 items-center gap-1`,children:[F.map(t=>i(`button`,{type:`button`,disabled:r,onClick:()=>a(t),className:`rounded px-2 py-1 text-[11px] font-medium transition-colors disabled:opacity-50 ${e.level===t?`bg-primary text-primary-foreground`:`border border-border text-foreground-subtle hover:text-foreground`}`,children:t},t)),i(`button`,{type:`button`,disabled:r||e.level===null,onClick:o,className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-40`,children:s(`logging.levels.clear`,`Clear`)})]})]})}function V(){return i(b,{children:i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:i(s,{limit:500,maxHeight:`max-h-[calc(100vh-310px)]`,showScope:!0,showFilters:!0})})})}function H(){return i(`div`,{className:`flex flex-col p-4`,children:i(x,{tabs:[{id:`viewer`,label:`Viewer`,icon:_,content:i(V,{})},{id:`destinations`,label:`Destinations`,icon:h,content:i(O,{})},{id:`levels`,label:`Levels`,icon:d,content:i(R,{})},{id:`diagnostics`,label:`Diagnostics`,icon:g,content:i(j,{})}]})})}export{H as LogsPage};
|
|
1
|
+
import{Q as e,S as t,W as n,q as r,x as i}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Mn as a,Qs as o,Y as s,gs as c,jn as l,vs as u}from"./src-CLAf92SY.js";import{t as d}from"./layers-CWHzy2IP.js";import{B as f,H as p,J as m,m as h,q as g,s as _,t as v,w as y}from"./index-DL2yqdrc.js";import{t as b}from"./AdminPage-CiKtOLQm.js";import{t as x}from"./AdminTabs-B4GGMxRz.js";import{t as S}from"./AddonCollectionPage-DwDJOFcL.js";import{t as C}from"./addon-display-names-DvSEQty-.js";var w=m(`file-text`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),T=m(`timer-reset`,[[`path`,{d:`M10 2h4`,key:`n1abiw`}],[`path`,{d:`M12 14v-4`,key:`1evpnu`}],[`path`,{d:`M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6`,key:`1ts96g`}],[`path`,{d:`M9 17H4v5`,key:`8t5av`}]]);e();var E=5e3,D={"winston-logging":`Rotated log files on this node’s disk.`,"console-logging":`stdout / stderr of the node process.`,"loki-logging":`Pushes to a Grafana Loki instance. Off until enabled with a URL.`,"hub-forwarder":`Agent-only — forwards this node’s entries to the hub.`};function O(){let e=a({capName:`log-destination`},{refetchInterval:E}),t=l(void 0,{refetchInterval:E}),r=n(()=>C(t.data??[]),[t.data]),o=n(()=>{let e=new Map;for(let n of t.data??[]){let t=n.description,r=n.id;typeof r==`string`&&typeof t==`string`&&t.length>0&&e.set(r,t)}return e},[t.data]);return i(S,{title:`Logging`,subtitle:`Every registered log destination. Entries are fanned to all enabled destinations at once — enabling one does not disable another. Each destination's own configuration is docked under it.`,pageIcon:h,itemIcon:w,capability:`log-destination`,installButtonLabel:`Add destination`,items:n(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:r.get(e.addonId)??e.addonId,isActive:e.isActive,caption:o.get(e.addonId)??D[e.addonId]??``})),[e.data,r,o]),isLoading:e.isLoading,emptyTitle:`No log destinations registered`,emptyDescription:`This should not happen — the console and rotated-file destinations are builtins. If the list is empty, the node is still booting.`,renderStatusBadges:e=>e.caption.length>0?i(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.caption}):null})}e();var k=[12e4,3e5,6e5,18e5],A={"request-census":`Counts every tRPC call by TRANSPORT PLANE — http, ws, mesh — and by procedure, caller, address and user-agent. Subscriptions are counted apart from calls, so a long-lived stream cannot pass for a storm. Arm it, then restart: the deadline is persisted, so the window is still running when clients reconnect.`};function j(){let{t:e}=v(),n=c({},{refetchInterval:5e3}),a=u(),[o,s]=r(null),l=(e,t)=>{s(e),a.mutate({patch:{diagnostics:[{id:e,armMs:t}]}},{onSettled:()=>{s(null),n.refetch()}})},d=n.data?.activeWindows??[],f=n.data?.channels??[],p=n.data?.activeChannels??[],m=(e,t,r)=>{s(e),a.mutate({patch:{channels:[{channel:e,armMs:t,deviceIds:r}]}},{onSettled:()=>{s(null),n.refetch()}})};return t(b,{icon:g,title:e(`logging.diagnostics.title`,`Diagnostics`),subtitle:e(`logging.diagnostics.subtitle`,`Diagnostics are armed for a window, never switched on. Each carries a deadline and expires by itself — one left running is an incident of its own.`),children:[n.isLoading?t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(y,{className:`h-3.5 w-3.5 animate-spin`}),e(`common.loading`,`Loading…`)]}):i(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:d.map(e=>i(N,{window:e,busy:o===e.id,onArm:t=>l(e.id,t)},e.id))}),i(`h3`,{className:`mt-6 text-sm font-medium text-foreground`,children:e(`logging.diagnostics.channels`,`Component channels`)}),i(`p`,{className:`mb-2 max-w-3xl text-[11px] text-foreground-subtle`,children:e(`logging.diagnostics.channelsSubtitle`,`Declared by the addons that own them — this list is not maintained by hand. Arming a channel opens a window with a deadline; it closes by itself.`)}),f.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`logging.diagnostics.noChannels`,`No addon on this cluster declares a log channel, or none could be reached right now.`)}):i(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:f.map(e=>i(M,{channel:e,state:p.find(t=>t.channel===e.name),busy:o===e.name,onArm:(t,n)=>m(e.name,t,n)},e.name))})]})}function M({channel:e,state:n,busy:a,onArm:o}){let{t:s}=v(),[c,l]=r(``),u=n?.armed===!0,d=()=>{let e=c.split(/[\s,+]+/).filter(e=>/^\d+$/.test(e)).map(e=>Number(e));return e.length>0?e:null};return t(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[t(`div`,{className:`min-w-0`,children:[t(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:e.name}),u?t(`span`,{className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-[10px] font-semibold text-warning`,children:[i(T,{className:`h-3 w-3`}),s(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:P(n?.remainingMs??0)})]}):i(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:s(`logging.diagnostics.disarmed`,`disarmed`)}),u&&n?.deviceIds!==null&&n?.deviceIds!==void 0&&t(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary`,children:[i(p,{className:`h-3 w-3`}),n.deviceIds.join(`, `)]}),!e.perDevice&&i(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:s(`logging.diagnostics.notPerCamera`,`not filterable per camera`)})]}),i(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:e.description})]}),t(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[e.perDevice&&i(`input`,{type:`text`,inputMode:`numeric`,value:c,disabled:a,onChange:e=>l(e.target.value),placeholder:s(`logging.diagnostics.camerasPlaceholder`,`all cameras`),className:`w-28 rounded border border-border bg-surface px-2 py-1 text-[11px] text-foreground`}),k.map(e=>i(`button`,{type:`button`,disabled:a,onClick:()=>o(e,d()),className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:P(e)},e)),i(`button`,{type:`button`,disabled:a||!u,onClick:()=>o(0,null),className:`rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-40`,children:s(`logging.diagnostics.disarm`,`Disarm`)})]})]})}function N({window:e,busy:n,onArm:r}){let{t:a}=v();return t(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[t(`div`,{className:`min-w-0`,children:[t(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:e.id}),e.armed?t(`span`,{className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-[10px] font-semibold text-warning`,children:[i(T,{className:`h-3 w-3`}),a(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:P(e.remainingMs)})]}):i(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:a(`logging.diagnostics.disarmed`,`disarmed`)}),e.armed&&!e.persisted&&i(`span`,{className:`text-[10px] text-warning`,children:a(`logging.diagnostics.notPersisted`,`not persisted — will not survive a restart`)})]}),i(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:A[e.id]??``})]}),t(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[k.map(e=>i(`button`,{type:`button`,disabled:n,onClick:()=>r(e),className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:P(e)},e)),i(`button`,{type:`button`,disabled:n||!e.armed,onClick:()=>r(0),className:`rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-40`,children:a(`logging.diagnostics.disarm`,`Disarm`)})]})]})}function P(e){let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:r===0?`${n}m`:`${n}m ${r}s`}e();var F=[`debug`,`info`,`warn`,`error`],I=``,L=``;function R(){let{t:e}=v(),[a,s]=r(I),[l,f]=r(L),{nodes:p}=o(),m=n(()=>p.map(e=>({id:e.id,label:e.name||e.id})),[p]),h=c({...a===I?{}:{scopeNodeId:a},...l===L?{}:{scopeComponent:l}},{refetchInterval:15e3}),g=u(),_=h.data,x=g.isPending||h.isFetching,S=_?.channels??[],C=(e,t)=>{g.mutate({...e.nodeId===null?{}:{scopeNodeId:e.nodeId},...e.component===null?{}:{scopeComponent:e.component},patch:{level:t}},{onSuccess:()=>void h.refetch()})};return i(b,{icon:d,title:e(`logging.levels.title`,`Levels`),subtitle:e(`logging.levels.subtitle`,`Cluster → node, most specific wins. The floor gates what reaches the log destinations; the in-memory viewer keeps every line either way.`),actions:t(`div`,{className:`flex flex-wrap items-center gap-3`,children:[t(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[e(`logging.levels.scope`,`Scope`),t(`select`,{className:`rounded border border-border bg-surface px-2 py-1 text-xs text-foreground disabled:opacity-50`,value:a,disabled:l!==L,onChange:e=>s(e.target.value),children:[i(`option`,{value:I,children:e(`logging.levels.cluster`,`Cluster`)}),m.map(e=>i(`option`,{value:e.id,children:e.label},e.id))]})]}),t(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[e(`logging.levels.component`,`Component`),t(`select`,{className:`rounded border border-border bg-surface px-2 py-1 text-xs text-foreground`,value:l,onChange:e=>f(e.target.value),children:[i(`option`,{value:L,children:e(`logging.levels.noComponent`,`None`)}),S.map(e=>i(`option`,{value:e.name,children:e.name},e.name))]})]})]}),children:h.isLoading||_===void 0?t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(y,{className:`h-3.5 w-3.5 animate-spin`}),e(`common.loading`,`Loading…`)]}):t(`div`,{className:`space-y-3`,children:[i(z,{level:_.effective.level,source:_.effective.levelSource,persisted:_.persisted}),i(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:_.explicit.layers.map(e=>i(B,{layer:e,inForce:e.scope===_.effective.levelSource,busy:x,onSet:t=>C(e,t),onClear:()=>C(e,null)},`${e.scope}:${e.nodeId??e.component??`cluster`}`))}),l!==L&&i(`p`,{className:`text-[11px] text-foreground-subtle`,children:S.find(e=>e.name===l)?.description??``}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`logging.levels.componentNote`,`A component is a log channel an addon declared. Its level is cluster-wide and beats both the node and the cluster layer.`)})]})})}function z({level:e,source:n,persisted:r}){let{t:a}=v();return t(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[t(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-xs text-foreground-subtle`,children:a(`logging.levels.effective`,`In force here`)}),i(`span`,{className:`rounded bg-primary/10 px-2 py-0.5 text-xs font-semibold text-primary`,children:e}),i(`span`,{className:`text-[11px] text-foreground-subtle`,children:n==="default"?a(`logging.levels.fromDefault`,`nothing is set anywhere — this is the default`):a(`logging.levels.fromLayer`,`decided by the {{source}} layer`,{source:n})})]}),!r&&i(`p`,{className:`mt-1 text-[11px] text-warning`,children:a(`logging.levels.notPersisted`,`The settings store could not be read or written — what you see is live, but it would not survive a restart.`)})]})}function B({layer:e,inForce:n,busy:r,onSet:a,onClear:o}){let{t:s}=v();return t(`div`,{className:`flex flex-col gap-2 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[t(`div`,{className:`min-w-0`,children:[t(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:e.scope===`cluster`?s(`logging.levels.cluster`,`Cluster`):e.scope===`component`?e.component??``:e.nodeId??``}),n&&t(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary`,children:[i(f,{className:`h-3 w-3`}),s(`logging.levels.inForce`,`in force`)]})]}),i(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:e.level===null?s(`logging.levels.inherits`,`inherits — nothing set at this layer`):s(`logging.levels.setHere`,`set here: {{level}}`,{level:e.level})})]}),t(`div`,{className:`flex shrink-0 items-center gap-1`,children:[F.map(t=>i(`button`,{type:`button`,disabled:r,onClick:()=>a(t),className:`rounded px-2 py-1 text-[11px] font-medium transition-colors disabled:opacity-50 ${e.level===t?`bg-primary text-primary-foreground`:`border border-border text-foreground-subtle hover:text-foreground`}`,children:t},t)),i(`button`,{type:`button`,disabled:r||e.level===null,onClick:o,className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-40`,children:s(`logging.levels.clear`,`Clear`)})]})]})}function V(){return i(b,{children:i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:i(s,{limit:500,maxHeight:`max-h-[calc(100vh-310px)]`,showScope:!0,showFilters:!0})})})}function H(){return i(`div`,{className:`flex flex-col p-4`,children:i(x,{tabs:[{id:`viewer`,label:`Viewer`,icon:_,content:i(V,{})},{id:`destinations`,label:`Destinations`,icon:h,content:i(O,{})},{id:`levels`,label:`Levels`,icon:d,content:i(R,{})},{id:`diagnostics`,label:`Diagnostics`,icon:g,content:i(j,{})}]})})}export{H as LogsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,W as i,b as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{G as l,M as u,W as ee,Y as d,at as f,gt as p,n as m}from"./player-overlays-
|
|
1
|
+
import{I as e,K as t,Q as n,S as r,W as i,b as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{G as l,M as u,W as ee,Y as d,at as f,gt as p,n as m}from"./player-overlays-DVo2KR_t.js";import{MaskShapeCanvas as h}from"./MaskShapeCanvas-Dcpby34M.js";var te=p(`grid-2x2`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]);n();var ne=110,g=`motion-zones`,_=0,re=[1,2,3],v=1,y=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,b=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`;function x(e,t,n){let r=t*n,i=Array.from({length:r});for(let t=0;t<r;t+=1)i[t]=e[t]===!0;return i}function S(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function C(e,t){return Math.ceil(e/t)}function w(e,t,n){return Math.min(n-1,Math.floor((e+.5)/t*n))}function T(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array.from({length:i*a},()=>!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)e[r*t+n]===!0&&(o[s*i+w(n,t,i)]=!0)}return o}function E(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array.from({length:t*n},()=>!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)o[r*t+n]=e[s*i+w(n,t,i)]===!0}return o}function D({deviceId:n}){let p=l(f().trpcClient,n),[w,D]=o(null),[O,k]=o(!1),[A,j]=o(null),[M,N]=o(null),[P,F]=o(v),[I,L]=o(!1),[R,z]=o(!1),B=t(!1);c(()=>{if(!p)return;let e=!1;return B.current=!1,D(null),k(!1),j(null),N(null),F(v),z(!1),(async()=>{try{let t=await p.motionZones?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(D(t),B.current)return;let n=await p.motionZones?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);B.current=!0;let r=n.regions.find(e=>e.shape.kind===`grid`),i=x(r?r.shape.cells:[],t.grid.width,t.grid.height);N(i),j(T(i,t.grid.width,t.grid.height,v))}catch(t){if(e)return;ee(t)?k(!0):console.error(`Motion Zones load failed`,t)}})(),()=>{e=!0}},[p]);let V=w?w.grid.width:0,H=w?w.grid.height:0,U=C(V,P),W=C(H,P),G=i(()=>A&&w?E(A,V,H,P):null,[A,w,V,H,P]),K=i(()=>G!==null&&M!==null&&!S(G,M),[G,M]),q=i(()=>G?G.reduce((e,t)=>t?e+1:e,0):0,[G]),J=V*H,Y=U*W,X=e(e=>{Y>0&&j(Array.from({length:Y},()=>e))},[Y]),Z=e(()=>{j(e=>e&&e.map(e=>!e))},[]),ie=e(()=>{M&&w&&j(T(M,V,H,P))},[M,w,V,H,P]),ae=e(e=>{e===P||!w||j(t=>{if(!t)return F(e),t;let n=T(E(t,V,H,P),V,H,e);return F(e),n})},[P,w,V,H]),Q=i(()=>w&&A?[{id:_,shape:{kind:`grid`,gridWidth:U,gridHeight:W,cells:[...A]}}]:[],[w,A,U,W]),$=e((e,t)=>{t.kind===`grid`&&j(t.cells)},[]),oe=e(async()=>{if(!(!p||!A||!w)){L(!0);try{let e=E(A,w.grid.width,w.grid.height,P),t={kind:`grid`,gridWidth:w.grid.width,gridHeight:w.grid.height,cells:e};await p.motionZones?.setZone({patch:{regions:[{id:_,enabled:!0,shape:t}]}});let n=await p.motionZones?.getStatus({});if(n){let e=n.regions.find(e=>e.shape.kind===`grid`),t=x(e?e.shape.cells:[],w.grid.width,w.grid.height);N(t),j(T(t,w.grid.width,w.grid.height,P))}}catch(e){console.error(`Motion Zones save failed`,e)}finally{L(!1)}}},[p,A,w,P]);return m(i(()=>R&&!O&&w&&A?{id:g,order:ne,node:s(h,{transparent:!0,items:Q,supportedShapes:[`grid`],grid:{width:U,height:W},selectedId:_,onSelect:()=>{},onShapeChange:$,onDrawComplete:()=>{},drawingKind:null})}:null,[R,O,w,A,Q,$,U,W])),p?s(d,{title:`Motion Zones`,icon:s(te,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:s(`div`,{className:`flex flex-col gap-3`,children:O?s(`p`,{className:`${u} leading-relaxed`,children:`This camera doesn't expose an on-board motion zones grid.`}):!O&&w!==null&&A!==null?r(a,{children:[r(`p`,{className:`${u} leading-relaxed`,children:[`Toggle `,s(`strong`,{className:`text-foreground`,children:`Edit grid`}),` to paint the region directly on the live frame, then `,s(`strong`,{className:`text-foreground`,children:`Save`}),` to push the mask to the camera. Pick a bigger`,` `,s(`strong`,{className:`text-foreground`,children:`Cell size`}),` for quicker, broad-stroke painting — it's resampled to the camera's native `,w.grid.width,`×`,w.grid.height,` grid on save (×1 is the finest).`]}),r(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[s(`button`,{type:`button`,onClick:()=>z(e=>!e),disabled:I,"aria-pressed":R,className:R?b:y,children:R?`Done editing`:`Edit grid`}),s(`button`,{type:`button`,onClick:()=>X(!0),disabled:I,className:y,children:`All on`}),s(`button`,{type:`button`,onClick:()=>X(!1),disabled:I,className:y,children:`All off`}),s(`button`,{type:`button`,onClick:Z,disabled:I,className:y,children:`Invert`}),r(`div`,{className:`flex items-center gap-1 ml-1`,role:`group`,"aria-label":`Cell size`,children:[s(`span`,{className:`${u} mr-0.5`,children:`Cell size`}),re.map(e=>r(`button`,{type:`button`,onClick:()=>ae(e),disabled:I,"aria-pressed":P===e,title:e===1?`Camera grid ${V}×${H} (finest)`:`${C(V,e)}×${C(H,e)} painting grid · cells ×${e} bigger`,className:P===e?b:y,children:[`×`,e]},e))]}),r(`span`,{className:`${u} ml-1 tabular-nums`,children:[q,` / `,J,` cells · `,w.grid.width,`×`,w.grid.height,P===1?``:` · paint ${U}×${W}`]}),s(`span`,{className:`flex-1`}),s(`button`,{type:`button`,onClick:ie,disabled:I||!K,className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,children:`Revert`}),s(`button`,{type:`button`,onClick:()=>void oe(),disabled:I||!K,className:b,children:I?`Saving…`:`Save`})]})]}):s(`p`,{className:`${u} leading-relaxed`,children:`Loading the camera's grid…`})})}):null}export{D as MotionZonesSettings};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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{Q as n,S as r,W as i,a,b as o,q as s,t as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{at as d}from"./player-overlays-CoerrptV.js";import{S as f,qt as p,tn as m}from"./src-BLs3JnCT.js";import{t as h}from"./circle-check-big-Ckfr2nS1.js";import{t as g}from"./copy-HKHON4wK.js";import{t as _}from"./key-round-D15z3uvv.js";import{t as v}from"./pencil-DRBv7Lne.js";import{A as y,C as b,I as x,S,T as C,l as w,n as T,o as E,w as D}from"./index-YqMXmKC_.js";import{t as O}from"./AdminPage-CiKtOLQm.js";n();function k({value:n,size:i=192}){let[a,o]=s(null),[c,d]=s(null);if(u(()=>{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`){d(`qrcode.create() unavailable in installed version`);return}try{let e=t(n,{errorCorrectionLevel:`M`});r||o(e)}catch(e){r||d(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{r||d(`qrcode library not installed`)}),()=>{r=!0}},[n]),c)return l(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:`QR rendering unavailable — use the secret below.`});if(!a)return l(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:`Generating…`});let f=a.modules.size,p=i/f,m=[];for(let e=0;e<f;e++)for(let t=0;t<f;t++)a.modules.data[e*f+t]&&m.push(l(`rect`,{x:t*p,y:e*p,width:p,height:p,fill:`currentColor`},`${t}-${e}`));return r(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[l(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),m]})}n();var A={view:{icon:y,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:v,cls:`bg-primary/15 text-primary`},delete:{icon:E,cls:`bg-danger/15 text-danger`}};function j(){let{user:e,logout:t}=T();if(!e)return l(O,{children:l(`div`,{className:`text-xs text-foreground-subtle`,children:`Not signed in.`})});let n=e.isAdmin,i=e.scopes??[];return r(O,{children:[r(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[l(`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()}),r(`div`,{className:`flex-1 min-w-0`,children:[l(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),r(`div`,{className:`text-[11px] text-foreground-subtle`,children:[n?`Administrator`:`User`,` · session id`,` `,r(`span`,{className:`font-mono`,children:[e.id.slice(0,8),`…`]})]})]})]}),n&&r(`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:[l(C,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),r(`div`,{children:[l(`div`,{className:`font-semibold text-foreground`,children:`Unrestricted access`}),l(`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.`})]})]}),l(M,{}),l(P,{username:e.username}),l(F,{}),i.length>0&&r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`px-4 py-2 border-b border-border`,children:[l(`div`,{className:`text-xs font-semibold text-foreground`,children:`Granted scopes`}),l(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Baked into your session token at login; sign out + back in to refresh after changes.`})]}),r(`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:[l(`div`,{children:`Type`}),l(`div`,{children:`Target`}),l(`div`,{children:`Access`})]}),l(`ul`,{className:`divide-y divide-border`,children:i.map((e,t)=>r(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[l(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),l(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?f(e.selector):e.target}),l(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(t=>{let n=e.access.includes(t),{icon:i,cls:a}=A[t];return r(`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:[l(i,{className:`h-3 w-3`}),t]},t)})})]},t))})]}),l(`div`,{className:`flex justify-end`,children:r(`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:[l(S,{className:`h-3 w-3`}),`Sign out`]})})]})}function M(){let e=d(),[t,n]=s(``),[i,a]=s(``),[o,u]=s(``),[f,p]=s(null),m=c({mutationFn:t=>e.changeOwnPassword(t),onSuccess:()=>{p({kind:`success`,msg:`Password updated.`}),n(``),a(``),u(``)},onError:e=>{p({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),g=i.length>0&&o.length>0&&i!==o,v=i.length>0&&i.length<8,y=t.length>=1&&i.length>=8&&i===o;return r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[l(_,{className:`h-3.5 w-3.5 text-foreground-subtle`}),l(`div`,{className:`text-xs font-semibold text-foreground`,children:`Change password`})]}),r(`div`,{className:`p-4 space-y-3`,children:[l(N,{label:`Current password`,value:t,onChange:n,autoComplete:`current-password`}),l(N,{label:`New password`,value:i,onChange:a,autoComplete:`new-password`,hint:`At least 8 characters.`}),l(N,{label:`Confirm new password`,value:o,onChange:u,autoComplete:`new-password`}),(g||v)&&l(`div`,{className:`text-[11px] text-danger`,children:g?`Passwords do not match.`:`New password must be at least 8 characters.`}),f&&r(`div`,{className:`text-[11px] flex items-center gap-1 ${f.kind===`success`?`text-emerald-500`:`text-danger`}`,children:[f.kind===`success`?l(h,{className:`h-3 w-3`}):l(x,{className:`h-3 w-3`}),f.msg]}),l(`div`,{className:`flex justify-end`,children:r(`button`,{onClick:()=>{p(null),m.mutate({currentPassword:t,newPassword:i})},disabled:!y||m.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:[m.isPending?l(D,{className:`h-3 w-3 animate-spin`}):l(b,{className:`h-3 w-3`}),`Update password`]})})]})]})}function N({label:e,value:t,onChange:n,autoComplete:i,hint:a}){return r(`div`,{className:`space-y-1`,children:[l(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),l(`input`,{type:`password`,value:t,onChange:e=>n(e.target.value),autoComplete:i,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&&l(`div`,{className:`text-[10px] text-foreground-subtle`,children:a})]})}function P({username:e}){let t=d(),n=a({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>t.getOwnTotpStatus()}),f=n.data,[p,m]=s(null),[_,v]=s(``),[y,b]=s(null),[S,C]=s(!1),T=c({mutationFn:()=>t.setupOwnTotp(),onSuccess:e=>{m({secret:e.secret,otpauthUrl:e.otpauthUrl}),v(``),b(null)},onError:e=>b(e instanceof Error?e.message:`Setup failed`)}),E=c({mutationFn:e=>t.confirmOwnTotp(e),onSuccess:()=>{m(null),v(``),b(null),n.refetch()},onError:e=>b(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),O=c({mutationFn:()=>t.disableOwnTotp(),onSuccess:()=>{b(null),n.refetch()},onError:e=>b(e instanceof Error?e.message:`Disable failed`)});u(()=>{if(!S)return;let e=setTimeout(()=>C(!1),1500);return()=>clearTimeout(e)},[S]);let A=i(()=>n.isLoading?`loading`:p?`setup_in_progress`:f?.enabled?`enrolled`:`not_enrolled`,[n.isLoading,f?.enabled,p]);return r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[l(w,{className:`h-3.5 w-3.5 text-foreground-subtle`}),l(`div`,{className:`text-xs font-semibold text-foreground`,children:`Two-factor authentication`})]}),r(`div`,{className:`p-4 space-y-3`,children:[A===`loading`&&r(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[l(D,{className:`h-3.5 w-3.5 animate-spin`}),`Checking status…`]}),A===`not_enrolled`&&r(o,{children:[l(`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.`}),l(`div`,{className:`flex justify-end`,children:r(`button`,{onClick:()=>{b(null),T.mutate()},disabled:T.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:[T.isPending?l(D,{className:`h-3 w-3 animate-spin`}):l(w,{className:`h-3 w-3`}),`Enable 2FA`]})})]}),A===`setup_in_progress`&&p&&r(o,{children:[r(`div`,{className:`text-[11px] text-foreground-subtle`,children:[`Scan the QR code (or enter the secret manually) into your authenticator app for`,` `,l(`span`,{className:`font-mono`,children:e}),`, then enter the 6-digit code below to confirm.`]}),r(`div`,{className:`flex flex-col items-center gap-3`,children:[l(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:l(k,{value:p.otpauthUrl,size:180})}),r(`div`,{className:`w-full`,children:[l(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:`Secret (manual entry)`}),r(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[l(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:p.secret}),r(`button`,{onClick:()=>{p&&navigator.clipboard.writeText(p.secret).then(()=>C(!0))},className:`inline-flex items-center gap-1 text-[10px] text-foreground-subtle hover:text-foreground`,children:[S?l(h,{className:`h-3 w-3 text-emerald-500`}):l(g,{className:`h-3 w-3`}),S?`Copied`:`Copy`]})]})]})]}),r(`div`,{className:`space-y-1`,children:[l(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),l(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:_,onChange:e=>v(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary`})]}),y&&r(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[l(x,{className:`h-3 w-3`}),y]}),r(`div`,{className:`flex justify-end gap-2`,children:[l(`button`,{onClick:()=>{m(null),b(null),v(``)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),r(`button`,{onClick:()=>{b(null),E.mutate({code:_})},disabled:E.isPending||_.length!==6,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[E.isPending?l(D,{className:`h-3 w-3 animate-spin`}):l(h,{className:`h-3 w-3`}),`Confirm`]})]})]}),A===`enrolled`&&f&&r(o,{children:[r(`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:[l(h,{className:`h-4 w-4 mt-0.5 text-emerald-500 shrink-0`}),r(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[l(`div`,{className:`font-medium`,children:`2FA is active`}),r(`div`,{className:`text-foreground-subtle`,children:[`Enrolled on`,` `,f.confirmedAt?new Date(f.confirmedAt).toLocaleString():`—`]})]})]}),y&&r(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[l(x,{className:`h-3 w-3`}),y]}),l(`div`,{className:`flex justify-end`,children:r(`button`,{onClick:()=>{b(null),O.mutate()},disabled:O.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:[O.isPending?l(D,{className:`h-3 w-3 animate-spin`}):l(w,{className:`h-3 w-3`}),`Disable 2FA`]})})]})]})]})}function F(){return m(`auth-webauthn/passkey-enrollment`)?l(p,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}export{j as MyAccessPage};
|
|
2
|
+
import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{t}from"./vite-preload-helper-kNaey6uv.js";import{Q as n,S as r,W as i,a,b as o,q as s,t as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{at as d}from"./player-overlays-DVo2KR_t.js";import{S as f,qt as p,tn as m}from"./src-CLAf92SY.js";import{t as h}from"./circle-check-big-UUTDxFnK.js";import{t as g}from"./copy-Clr1lTje.js";import{t as _}from"./key-round-DsG9cNQv.js";import{t as v}from"./pencil-DICsE4Gy.js";import{A as y,C as b,I as x,S,T as C,l as w,n as T,o as E,w as D}from"./index-DL2yqdrc.js";import{t as O}from"./AdminPage-CiKtOLQm.js";n();function k({value:n,size:i=192}){let[a,o]=s(null),[c,d]=s(null);if(u(()=>{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`){d(`qrcode.create() unavailable in installed version`);return}try{let e=t(n,{errorCorrectionLevel:`M`});r||o(e)}catch(e){r||d(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{r||d(`qrcode library not installed`)}),()=>{r=!0}},[n]),c)return l(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:`QR rendering unavailable — use the secret below.`});if(!a)return l(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:`Generating…`});let f=a.modules.size,p=i/f,m=[];for(let e=0;e<f;e++)for(let t=0;t<f;t++)a.modules.data[e*f+t]&&m.push(l(`rect`,{x:t*p,y:e*p,width:p,height:p,fill:`currentColor`},`${t}-${e}`));return r(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[l(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),m]})}n();var A={view:{icon:y,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:v,cls:`bg-primary/15 text-primary`},delete:{icon:E,cls:`bg-danger/15 text-danger`}};function j(){let{user:e,logout:t}=T();if(!e)return l(O,{children:l(`div`,{className:`text-xs text-foreground-subtle`,children:`Not signed in.`})});let n=e.isAdmin,i=e.scopes??[];return r(O,{children:[r(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[l(`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()}),r(`div`,{className:`flex-1 min-w-0`,children:[l(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),r(`div`,{className:`text-[11px] text-foreground-subtle`,children:[n?`Administrator`:`User`,` · session id`,` `,r(`span`,{className:`font-mono`,children:[e.id.slice(0,8),`…`]})]})]})]}),n&&r(`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:[l(C,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),r(`div`,{children:[l(`div`,{className:`font-semibold text-foreground`,children:`Unrestricted access`}),l(`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.`})]})]}),l(M,{}),l(P,{username:e.username}),l(F,{}),i.length>0&&r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`px-4 py-2 border-b border-border`,children:[l(`div`,{className:`text-xs font-semibold text-foreground`,children:`Granted scopes`}),l(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Baked into your session token at login; sign out + back in to refresh after changes.`})]}),r(`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:[l(`div`,{children:`Type`}),l(`div`,{children:`Target`}),l(`div`,{children:`Access`})]}),l(`ul`,{className:`divide-y divide-border`,children:i.map((e,t)=>r(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[l(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),l(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?f(e.selector):e.target}),l(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(t=>{let n=e.access.includes(t),{icon:i,cls:a}=A[t];return r(`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:[l(i,{className:`h-3 w-3`}),t]},t)})})]},t))})]}),l(`div`,{className:`flex justify-end`,children:r(`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:[l(S,{className:`h-3 w-3`}),`Sign out`]})})]})}function M(){let e=d(),[t,n]=s(``),[i,a]=s(``),[o,u]=s(``),[f,p]=s(null),m=c({mutationFn:t=>e.changeOwnPassword(t),onSuccess:()=>{p({kind:`success`,msg:`Password updated.`}),n(``),a(``),u(``)},onError:e=>{p({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),g=i.length>0&&o.length>0&&i!==o,v=i.length>0&&i.length<8,y=t.length>=1&&i.length>=8&&i===o;return r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[l(_,{className:`h-3.5 w-3.5 text-foreground-subtle`}),l(`div`,{className:`text-xs font-semibold text-foreground`,children:`Change password`})]}),r(`div`,{className:`p-4 space-y-3`,children:[l(N,{label:`Current password`,value:t,onChange:n,autoComplete:`current-password`}),l(N,{label:`New password`,value:i,onChange:a,autoComplete:`new-password`,hint:`At least 8 characters.`}),l(N,{label:`Confirm new password`,value:o,onChange:u,autoComplete:`new-password`}),(g||v)&&l(`div`,{className:`text-[11px] text-danger`,children:g?`Passwords do not match.`:`New password must be at least 8 characters.`}),f&&r(`div`,{className:`text-[11px] flex items-center gap-1 ${f.kind===`success`?`text-emerald-500`:`text-danger`}`,children:[f.kind===`success`?l(h,{className:`h-3 w-3`}):l(x,{className:`h-3 w-3`}),f.msg]}),l(`div`,{className:`flex justify-end`,children:r(`button`,{onClick:()=>{p(null),m.mutate({currentPassword:t,newPassword:i})},disabled:!y||m.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:[m.isPending?l(D,{className:`h-3 w-3 animate-spin`}):l(b,{className:`h-3 w-3`}),`Update password`]})})]})]})}function N({label:e,value:t,onChange:n,autoComplete:i,hint:a}){return r(`div`,{className:`space-y-1`,children:[l(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),l(`input`,{type:`password`,value:t,onChange:e=>n(e.target.value),autoComplete:i,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&&l(`div`,{className:`text-[10px] text-foreground-subtle`,children:a})]})}function P({username:e}){let t=d(),n=a({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>t.getOwnTotpStatus()}),f=n.data,[p,m]=s(null),[_,v]=s(``),[y,b]=s(null),[S,C]=s(!1),T=c({mutationFn:()=>t.setupOwnTotp(),onSuccess:e=>{m({secret:e.secret,otpauthUrl:e.otpauthUrl}),v(``),b(null)},onError:e=>b(e instanceof Error?e.message:`Setup failed`)}),E=c({mutationFn:e=>t.confirmOwnTotp(e),onSuccess:()=>{m(null),v(``),b(null),n.refetch()},onError:e=>b(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),O=c({mutationFn:()=>t.disableOwnTotp(),onSuccess:()=>{b(null),n.refetch()},onError:e=>b(e instanceof Error?e.message:`Disable failed`)});u(()=>{if(!S)return;let e=setTimeout(()=>C(!1),1500);return()=>clearTimeout(e)},[S]);let A=i(()=>n.isLoading?`loading`:p?`setup_in_progress`:f?.enabled?`enrolled`:`not_enrolled`,[n.isLoading,f?.enabled,p]);return r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[l(w,{className:`h-3.5 w-3.5 text-foreground-subtle`}),l(`div`,{className:`text-xs font-semibold text-foreground`,children:`Two-factor authentication`})]}),r(`div`,{className:`p-4 space-y-3`,children:[A===`loading`&&r(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[l(D,{className:`h-3.5 w-3.5 animate-spin`}),`Checking status…`]}),A===`not_enrolled`&&r(o,{children:[l(`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.`}),l(`div`,{className:`flex justify-end`,children:r(`button`,{onClick:()=>{b(null),T.mutate()},disabled:T.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:[T.isPending?l(D,{className:`h-3 w-3 animate-spin`}):l(w,{className:`h-3 w-3`}),`Enable 2FA`]})})]}),A===`setup_in_progress`&&p&&r(o,{children:[r(`div`,{className:`text-[11px] text-foreground-subtle`,children:[`Scan the QR code (or enter the secret manually) into your authenticator app for`,` `,l(`span`,{className:`font-mono`,children:e}),`, then enter the 6-digit code below to confirm.`]}),r(`div`,{className:`flex flex-col items-center gap-3`,children:[l(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:l(k,{value:p.otpauthUrl,size:180})}),r(`div`,{className:`w-full`,children:[l(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:`Secret (manual entry)`}),r(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[l(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:p.secret}),r(`button`,{onClick:()=>{p&&navigator.clipboard.writeText(p.secret).then(()=>C(!0))},className:`inline-flex items-center gap-1 text-[10px] text-foreground-subtle hover:text-foreground`,children:[S?l(h,{className:`h-3 w-3 text-emerald-500`}):l(g,{className:`h-3 w-3`}),S?`Copied`:`Copy`]})]})]})]}),r(`div`,{className:`space-y-1`,children:[l(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),l(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:_,onChange:e=>v(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary`})]}),y&&r(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[l(x,{className:`h-3 w-3`}),y]}),r(`div`,{className:`flex justify-end gap-2`,children:[l(`button`,{onClick:()=>{m(null),b(null),v(``)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),r(`button`,{onClick:()=>{b(null),E.mutate({code:_})},disabled:E.isPending||_.length!==6,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[E.isPending?l(D,{className:`h-3 w-3 animate-spin`}):l(h,{className:`h-3 w-3`}),`Confirm`]})]})]}),A===`enrolled`&&f&&r(o,{children:[r(`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:[l(h,{className:`h-4 w-4 mt-0.5 text-emerald-500 shrink-0`}),r(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[l(`div`,{className:`font-medium`,children:`2FA is active`}),r(`div`,{className:`text-foreground-subtle`,children:[`Enrolled on`,` `,f.confirmedAt?new Date(f.confirmedAt).toLocaleString():`—`]})]})]}),y&&r(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[l(x,{className:`h-3 w-3`}),y]}),l(`div`,{className:`flex justify-end`,children:r(`button`,{onClick:()=>{b(null),O.mutate()},disabled:O.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:[O.isPending?l(D,{className:`h-3 w-3 animate-spin`}):l(w,{className:`h-3 w-3`}),`Disable 2FA`]})})]})]})]})}function F(){return m(`auth-webauthn/passkey-enrollment`)?l(p,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}export{j as MyAccessPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as e,Q as t,S as n,W as r,b as i,o as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{at as l}from"./player-overlays-CoerrptV.js";import{$i as u,Bi as d,Fs as f,Ft as p,Gi as m,Hi as h,It as g,Ji as _,Jt as v,Ki as y,Mn as b,Pt as x,Qi as S,Ri as ee,Ui as te,Vi as C,Wi as ne,Xi as w,Yi as re,Zi as T,aa as E,ea as ie,ia as ae,it as D,jn as O,jt as oe,nt as se,oa as k,qi as ce,ta as A,zi as le}from"./src-BLs3JnCT.js";import{ct as j,rt as M}from"./src-71h6VhtY.js";import{t as N}from"./boxes-Di4H7szx.js";import{t as P}from"./copy-HKHON4wK.js";import{t as F}from"./play-DJ__jbgT.js";import{t as ue}from"./refresh-cw-DUVLNAWK.js";import{t as de}from"./rotate-ccw-BaeY9e6c.js";import{t as I}from"./server-K4C9yQfR.js";import{t as L}from"./shield-Dw3zZIWI.js";import{t as R}from"./square-CURysUVy.js";import{t as z}from"./wifi-CEFpiBjp.js";import{B,C as V,D as H,J as U,M as W,S as fe,a as pe,c as me,r as he,w as G,y as K}from"./index-YqMXmKC_.js";import{t as ge}from"./AdminPage-CiKtOLQm.js";import{t as _e}from"./AdminTabs-DUSbhirs.js";import{t as ve}from"./NodeAddonsSettingsPanel-BGnTKNTC.js";import{t as q}from"./AddonCollectionPage-DJd0G561.js";import{t as J}from"./addon-display-names-DvSEQty-.js";var ye=U(`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`}]]),be=U(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),xe=U(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]);t();var Y=5e3,Se={connected:!1,endpoint:null};function Ce(){let e=a(),t=b({capName:`network-access`},{refetchInterval:Y}),n=O(void 0,{refetchInterval:Y}),i=r(()=>J(n.data??[]),[n.data]),c=r(()=>(t.data??[]).map(e=>({addonId:e.addonId,displayName:i.get(e.addonId)??e.addonId,isActive:e.isActive})),[t.data,i]),[l,u]=o(null),[d,f]=o({}),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=E({onSuccess:p,onError:m}),g=k({onSuccess:p,onError:m});return s(q,{title:`Remote Access`,subtitle:`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …). Settings, Logs and Events are docked under every provider.`,pageIcon:H,itemIcon:H,capability:`network-access`,installButtonLabel:`Add tunnel`,items:c,isLoading:t.isLoading,emptyTitle:`No remote-access providers installed`,emptyDescription:`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`,renderStatusBadges:e=>s(Te,{addonId:e.addonId}),itemError:e=>d[e.addonId]??null,renderPrimaryAction:e=>s(Ee,{addonId:e.addonId,busyId:l,onStart:e=>{u(e),h.mutate({addonId:e})},onStop:e=>{u(e),g.mutate({addonId:e})}})})}function we(e){let{data:t}=ae({addonId:e},{refetchInterval:Y,retry:!1}),n=t?j.safeParse(t):null;return n?.success?n.data:Se}function Te({addonId:e}){let t=we(e);return n(i,{children:[s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.connected?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:`bg-foreground-subtle/15 text-foreground-subtle`}`,children:t.connected?`Connected`:`Disconnected`}),t.endpoint&&n(`a`,{href:t.endpoint.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`text-[10px] text-emerald-700 dark:text-emerald-300 hover:underline flex items-center gap-1`,children:[s(W,{className:`h-3 w-3`}),t.endpoint.url]})]})}function Ee({addonId:e,busyId:t,onStart:r,onStop:i}){let a=we(e),o=t===e;return a.connected?n(g,{size:`sm`,variant:`secondary`,disabled:o,onClick:()=>i(e),children:[o?s(G,{className:`h-3 w-3 animate-spin`}):s(R,{className:`h-3 w-3`}),`Stop`]}):n(g,{size:`sm`,variant:`primary`,disabled:o,onClick:()=>r(e),children:[o?s(G,{className:`h-3 w-3 animate-spin`}):s(F,{className:`h-3 w-3`}),`Start`]})}t();var De=3e4;function Oe(e){let t=[];for(let n of e)typeof n.urls==`string`?t.push(n.urls):t.push(...n.urls);return t}function ke(){let e=b({capName:`turn-provider`},{refetchInterval:De}),t=O(void 0,{refetchInterval:De}),i=f(),a=i.data??[],o=r(()=>J(t.data??[]),[t.data]);return s(q,{title:`TURN Servers`,subtitle:`ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.`,pageIcon:K,itemIcon:K,capability:`turn-provider`,installButtonLabel:`Add provider`,items:r(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:o.get(e.addonId)??e.addonId,isActive:e.isActive})),[e.data,o]),isLoading:e.isLoading,emptyTitle:`No TURN providers installed`,emptyDescription:`Install a TURN addon (e.g. @camstack/addon-cloudflare) to enable WebRTC behind restrictive NATs.`,renderExpandedPanel:e=>s(Ae,{addonId:e.addonId,enabled:e.isActive}),trailing:n(x,{children:[n(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between`,children:[n(`div`,{children:[s(`div`,{className:`text-sm font-semibold`,children:`Combined ICE server list`}),s(`div`,{className:`text-xs text-foreground-subtle`,children:`What the WebRTC layer fetches per-session.`})]}),s(g,{size:`sm`,variant:`secondary`,onClick:()=>i.refetch(),disabled:i.isFetching,children:`Refresh`})]}),s(`div`,{className:`p-4`,children:a.length===0?s(`div`,{className:`text-xs text-foreground-subtle`,children:`No servers from enabled providers.`}):s(`div`,{className:`flex flex-col gap-3`,children:a.map((e,t)=>{let r=Array.isArray(e.urls)?e.urls:[e.urls];return n(`div`,{className:`rounded border border-border bg-surface`,children:[(e.username||e.credential)&&n(`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&&n(`span`,{children:[s(`span`,{className:`text-foreground-subtle`,children:`user:`}),` `,s(`span`,{className:`text-foreground`,children:e.username})]}),e.credential&&n(`span`,{children:[s(`span`,{className:`text-foreground-subtle`,children:`credential:`}),` `,s(`span`,{className:`text-foreground`,children:`••••••••`})]})]}),s(`ul`,{className:`divide-y divide-border`,children:r.map(e=>s(`li`,{className:`px-3 py-1.5 font-mono text-xs text-foreground break-all`,children:e},e))})]},t)})})})]})})}function Ae({addonId:e,enabled:t}){let i=f({addonId:e},{enabled:t,retry:!1}),a=r(()=>Oe(i.data??[]),[i.data]);return!t||a.length===0?null:n(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[n(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Discovered ICE servers (`,a.length,`)`]}),s(`div`,{className:`flex flex-wrap gap-1`,children:a.map(e=>s(`span`,{className:`inline-block rounded px-1.5 py-0.5 text-[10px] font-mono bg-foreground-subtle/10 text-foreground`,children:e},e))})]})}t();var je={lan:K,wifi:z,docker:N,vpn:V,loopback:I,other:I},Me={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},Ne=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function Pe(e){let{interfaces:t,disabled:i,hideLoopback:a,ipv4Only:o,emptyMessage:c}=e,l=r(()=>t.filter(e=>!(a&&e.kind===`loopback`||o&&e.family!==`IPv4`)),[t,a,o]),u=r(()=>{let e=new Map;for(let t of l){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return Ne.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(i||t.kind===`loopback`)return;if(e.mode===`single`){e.onChange(e.value===t.address?null:t.address);return}let n=new Set(e.value);n.has(t.address)?n.delete(t.address):n.add(t.address),e.onChange([...n])};return l.length===0?s(`div`,{className:`text-xs text-foreground-subtle italic`,children:c??`No addresses available.`}):s(`div`,{className:`flex flex-col gap-3`,children:u.map(({kind:t,items:r})=>n(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[n(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[s(je[t]??I,{className:`h-3.5 w-3.5 text-foreground-subtle`}),s(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:Me[t]??t}),n(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,r.length]})]}),s(`ul`,{className:`divide-y divide-border`,children:r.map(t=>{let r=d(t.address),a=t.kind===`loopback`,o=!t.plausible&&!a;return n(`li`,{className:`flex items-center gap-3 px-3 py-2 ${a?`opacity-60 cursor-not-allowed`:i?`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:[s(`span`,{className:`flex items-center justify-center h-4 w-4 rounded ${e.mode===`single`?`rounded-full`:`rounded`} border ${r?`border-primary bg-primary text-primary-foreground`:`border-border bg-surface`}`,children:r&&s(B,{className:`h-3 w-3`})}),n(`div`,{className:`flex-1 min-w-0 ${o?`text-foreground-subtle`:``}`,children:[n(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[s(`span`,{className:`font-mono text-xs font-semibold ${o?`text-foreground-subtle`:`text-foreground`}`,children:t.name}),s(`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&&s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:`Auto-preferred`}),a&&s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:`Always included`}),o&&n(`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:[s(pe,{className:`h-2.5 w-2.5`}),`Unlikely usable`]})]}),n(`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))})}t();var Fe={"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`},loopback:{label:`Loopback`,className:`bg-foreground-subtle/15 text-foreground-subtle`}};function X(e){return e.kind!==`loopback`}function Ie(e){return e.kind!==`loopback`}function Le(){let e=a(),t=l(),i=te(void 0,{refetchInterval:3e4}),u=ee(void 0),f=ce({onSuccess:()=>{e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),p=m({onSuccess:t=>{S(t.addresses),e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),v=r(()=>i.data?.interfaces??[],[i.data]),y=le({port:typeof window<`u`?Number(window.location.port)||(window.location.protocol===`https:`?443:80):4e3,scheme:typeof window<`u`&&window.location.protocol===`https:`?`https`:`http`},{refetchInterval:3e4}),[b,S]=o([]),[C,ne]=o(!1);c(()=>{!C&&u.data&&(S(u.data.addresses),ne(!0))},[u.data,C]);let w=u.data?.addresses??[],T=r(()=>{if(b.length!==w.length)return!0;let e=[...b].toSorted(),t=[...w].toSorted();return e.some((e,n)=>e!==t[n])},[b,w]),E=()=>{f.mutate({addresses:[...b]})},ie=()=>{S(w)},ae=()=>{S([])},D=()=>{i.refetch(),y.refetch(),u.refetch(),k.refetch(),j.refetch()},O=async()=>{try{let e=await t.raceConnectionEndpoints({perCandidateTimeoutMs:1500});console.info(`[network-addresses] race result`,e)}catch(e){console.warn(`[network-addresses] race failed`,e)}},k=d(),A=_({onSuccess:()=>void k.refetch()}),j=h(),M=re({onSuccess:()=>void j.refetch()}),N=y.data?.endpoints??[],P=k.data?.baseUrl??null,F=k.data?.resolved??null,I=j.data?.baseUrls??[],L=I.length===0,R=P===null,z=e=>L?e.kind===`lan-ipv4`||e.kind===`public`&&e.interfaceKind===`public`:I.includes(e.baseUrl),B=e=>P===null?F===e.baseUrl:P===e.baseUrl,V=e=>{if(!X(e))return;let t=L?N.filter(e=>X(e)&&z(e)).map(e=>e.baseUrl):[...I],n=t.includes(e.baseUrl)?t.filter(t=>t!==e.baseUrl):[...t,e.baseUrl];M.mutate({baseUrls:n})},H=e=>{if(Ie(e)){if(B(e)){R||A.mutate({baseUrl:null});return}A.mutate({baseUrl:e.baseUrl})}},U=r(()=>[{key:`url`,header:`Endpoint`,render:e=>n(`div`,{className:`min-w-0 py-0.5`,children:[s(`div`,{className:`font-mono text-[12px] break-all ${e.plausible?`text-foreground`:`text-foreground-subtle`}`,children:e.baseUrl}),n(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[s(`span`,{children:e.label}),e.interfaceKind!==`lan`&&e.interfaceKind!==`public`&&s(`span`,{className:`uppercase tracking-wide`,children:e.interfaceKind}),!e.plausible&&e.interfaceKind!==`loopback`&&n(`span`,{className:`inline-flex items-center gap-1 text-amber-700 dark:text-amber-300`,title:e.plausibleReason||void 0,children:[s(pe,{className:`h-2.5 w-2.5`}),`Unlikely usable`]})]})]})},{key:`kind`,header:`Kind`,nowrap:!0,render:e=>{let t=Fe[e.kind]??Fe.loopback;return s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.className}`,children:t.label})}},{key:`viewer`,headerRender:()=>n(`span`,{className:`inline-flex items-center gap-1`,children:[`Viewer`,L?s(`span`,{className:`text-[10px] font-normal normal-case text-foreground-subtle`,children:`auto`}):null]}),align:`center`,nowrap:!0,width:`w-24`,render:e=>{let t=X(e);return s(`label`,{className:`inline-flex justify-center ${t?`cursor-pointer`:`cursor-not-allowed opacity-40`}`,title:e.kind===`loopback`?`Loopback is not a client route.`:`Use this URL in the API / viewer race.`,children:s(oe,{checked:t&&z(e),disabled:!t||M.isPending,onChange:()=>V(e),"aria-label":`Viewer: ${e.baseUrl}`})})}},{key:`notifications`,headerRender:()=>n(`span`,{className:`inline-flex items-center gap-1`,children:[`Notifications`,R?s(`span`,{className:`text-[10px] font-normal normal-case text-foreground-subtle`,children:`auto`}):null]}),align:`center`,nowrap:!0,width:`w-28`,render:e=>{let t=Ie(e);return s(`label`,{className:`inline-flex justify-center ${t?`cursor-pointer`:`cursor-not-allowed opacity-40`}`,title:t?`Notification links and deep links use this address.`:`Loopback is not a client route.`,children:s(oe,{checked:t&&B(e),disabled:!t||A.isPending,onChange:()=>H(e),"aria-label":`Notifications: ${e.baseUrl}`})})}}],[L,R,I,P,F,M.isPending,A.isPending,N]);return n(ge,{children:[n(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[s(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:`Pin which host addresses exist, then tick the destinations each URL should serve. Viewer auto is IPv4 + public; every other row (including IPv6) can be ticked on.`}),n(`div`,{className:`flex items-center gap-2 shrink-0`,children:[n(g,{size:`sm`,variant:`secondary`,onClick:D,disabled:i.isLoading,children:[s(ue,{className:`h-3 w-3 ${i.isLoading?`animate-spin`:``}`}),`Refresh`]}),s(g,{size:`sm`,variant:`secondary`,onClick:O,children:`Probe race`})]})]}),n(x,{children:[n(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between gap-3 flex-wrap`,children:[n(`div`,{children:[s(`div`,{className:`text-sm font-semibold`,children:`Allowed addresses`}),s(`div`,{className:`text-xs text-foreground-subtle`,children:b.length===0?`Auto — every non-loopback / non-link-local interface participates.`:`${b.length} pinned`})]}),n(`div`,{className:`flex items-center gap-1`,children:[n(g,{size:`sm`,variant:`secondary`,onClick:()=>p.mutate(void 0),disabled:p.isPending||f.isPending,title:`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`,children:[s(me,{className:`h-3 w-3`}),p.isPending?`Detecting…`:`Best match`]}),n(g,{size:`sm`,variant:`secondary`,onClick:ae,disabled:b.length===0||f.isPending,children:[s(de,{className:`h-3 w-3`}),`Clear`]}),T&&s(g,{size:`sm`,variant:`secondary`,onClick:ie,disabled:f.isPending,children:`Discard`}),n(g,{size:`sm`,variant:`primary`,onClick:E,disabled:!T||f.isPending,children:[s(be,{className:`h-3 w-3`}),f.isPending?`Saving…`:`Save`]})]})]}),s(`div`,{className:`p-4`,children:s(Pe,{mode:`multiple`,interfaces:v,value:b,onChange:S,disabled:f.isPending,emptyMessage:i.isLoading?`Loading interfaces…`:`No interfaces detected.`})})]}),n(x,{children:[n(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between gap-3 flex-wrap`,children:[n(`div`,{children:[s(`div`,{className:`text-sm font-semibold`,children:`Connection endpoints`}),s(`div`,{className:`text-xs text-foreground-subtle`,children:`Ranked URLs this hub advertises. Tick Viewer (many) and Notifications (one).`})]}),n(`div`,{className:`flex items-center gap-1`,children:[!L&&s(g,{size:`sm`,variant:`secondary`,disabled:M.isPending,onClick:()=>M.mutate({baseUrls:[]}),children:`Viewer → auto`}),!R&&s(g,{size:`sm`,variant:`secondary`,disabled:A.isPending,onClick:()=>A.mutate({baseUrl:null}),children:`Notifications → auto`})]})]}),R&&F===null&&s(`p`,{className:`px-4 pt-3 text-[11px] text-amber-600 dark:text-amber-400`,children:`No public address is reachable, so notification media ships as bytes only — a backend that can only take links (WhatsApp, gotify) receives none.`}),s(se,{columns:U,rows:N,rowKey:e=>`${e.priority}-${e.baseUrl}`,minWidthPx:640,bordered:!1,mobileMode:`scroll`,emptyMessage:y.isLoading?`Loading…`:`No endpoints available.`,rowClassName:e=>e.plausible?void 0:`opacity-80`})]})]})}t();var Re={mesh:`bg-violet-500/15 text-violet-700 dark:text-violet-300`,public:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},Z=5e3,ze=3e4,Be={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function Ve(){let e=b({capName:`mesh-network`},{refetchInterval:Z}),t=O(void 0,{refetchInterval:Z}),n=r(()=>J(t.data??[]),[t.data]);return s(q,{title:`Mesh Networks`,subtitle:`Private VPN meshes that connect CamStack to your other devices (Tailscale, Headscale, …). Each provider can also expose this hub publicly via its ingress (Tailscale Funnel).`,pageIcon:N,itemIcon:K,capability:`mesh-network`,installButtonLabel:`Add mesh`,items:r(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:n.get(e.addonId)??e.addonId,isActive:e.isActive})),[e.data,n]),isLoading:e.isLoading,emptyTitle:`No mesh-network providers installed`,emptyDescription:`Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.`,renderStatusBadges:e=>s(He,{addonId:e.addonId}),renderPrimaryAction:e=>s(Ue,{addonId:e.addonId}),renderExpandedPanel:e=>s(We,{addonId:e.addonId})})}function Q(e){let{data:t,isLoading:n}=T({addonId:e},{refetchInterval:Z,retry:!1}),r=t?M.safeParse(t):null;return{status:r?.success?r.data:Be,isLoading:n}}function He({addonId:e}){let{status:t}=Q(e);return n(i,{children:[s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.joined?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:`bg-foreground-subtle/15 text-foreground-subtle`}`,children:t.joined?`Joined`:`Not joined`}),t.joined&&n(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:[t.peerCount,` peer`,t.peerCount===1?``:`s`]})]})}function Ue({addonId:t}){let r=a(),[c,u]=o(!1),[d,f]=o(null),p=l(),{status:m}=Q(t),h=e(()=>{r.invalidateQueries({queryKey:[[`meshNetwork`]]})},[r]),_=A(),v=S({onSuccess:h}),y=ie({onSuccess:h}),b=e(async()=>{u(!0);let e={cancelled:!1};f(e);try{let n=await _.mutateAsync({addonId:t});if(e.cancelled)return;n.loginUrl&&window.open(n.loginUrl,`_blank`,`noopener,noreferrer`);let r=Date.now();for(;!e.cancelled&&(await Ze(2e3),!e.cancelled);){let e=await p.trpcClient.meshNetwork.getStatus.query({addonId:t}).catch(()=>null),n=e?M.safeParse(e):null;if(n?.success&&n.data.joined){h();break}if(Date.now()-r>6e5)break}}finally{u(!1),f(null)}},[t,h,_,p]),x=e(()=>{d&&(d.cancelled=!0),u(!1),f(null)},[d]);return s(i,{children:m.joined?n(i,{children:[n(g,{size:`sm`,variant:`secondary`,disabled:v.isPending,onClick:()=>v.mutate({addonId:t}),children:[v.isPending?s(G,{className:`h-3 w-3 animate-spin`}):s(fe,{className:`h-3 w-3`}),`Disconnect`]}),n(g,{size:`sm`,variant:`ghost`,disabled:y.isPending,onClick:()=>y.mutate({addonId:t}),children:[y.isPending?s(G,{className:`h-3 w-3 animate-spin`}):s(xe,{className:`h-3 w-3`}),`Log out`]})]}):c?n(g,{size:`sm`,variant:`ghost`,onClick:x,children:[s(he,{className:`h-3 w-3 mr-1`}),` Cancel`]}):n(i,{children:[n(g,{size:`sm`,variant:`primary`,onClick:()=>void b(),children:[s(ye,{className:`h-3 w-3`}),`Connect`]}),n(g,{size:`sm`,variant:`ghost`,disabled:y.isPending,onClick:()=>y.mutate({addonId:t}),children:[y.isPending?s(G,{className:`h-3 w-3 animate-spin`}):s(xe,{className:`h-3 w-3`}),`Log out`]})]})})}function We({addonId:e}){let{status:t}=Q(e),r=u({addonId:e},{refetchInterval:ze,retry:!1});return n(`div`,{className:`rounded-lg border border-border bg-surface`,children:[n(`div`,{className:`p-4 space-y-4`,children:[t.error&&s(v,{message:t.error}),s(Ge,{status:t}),t.endpoints.length>0&&n(`div`,{className:`space-y-1.5`,children:[s(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:`Endpoints`}),t.endpoints.map(e=>n(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[n(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${Re[e.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[e.scope===`public`?s(H,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,e.label]}),n(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1`,children:[s(W,{className:`h-3 w-3 shrink-0`}),e.url]})]},e.id))]})]}),s(`div`,{className:`border-t border-border`,children:s(qe,{peers:r.data?.peers??[],loading:r.isLoading})})]})}function Ge({status:e}){return s(`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?Ke(e.keyExpiry):`—`}].map(e=>n(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[s(`span`,{className:`text-foreground-subtle shrink-0`,children:e.label}),s(`span`,{className:`text-foreground truncate ${e.mono?`font-mono`:``}`,children:e.value})]},e.label))})}function Ke(e){let t=e-Date.now();if(t<0)return`Expired ${Xe(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 qe({peers:t,loading:i}){let a=r(()=>t.map(e=>({...e,_id:e.id})),[t]),o=e(e=>{e&&navigator.clipboard?.writeText(e)},[]),c=r(()=>[{key:`hostname`,header:`Hostname`,render:e=>n(`div`,{className:`flex flex-col`,children:[n(`div`,{className:`flex items-center gap-1.5`,children:[s(`span`,{className:`font-medium text-foreground`,children:e.hostname||`(unknown)`}),e.isSelf&&s(p,{variant:`info`,children:`self`}),e.exitNodeOption&&s(p,{variant:`warning`,children:`exit-node`})]}),e.userLogin&&s(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.userLogin})]})},{key:`magicDns`,header:`MagicDNS`,render:e=>e.magicDns?n(`div`,{className:`flex items-center gap-1`,children:[s(`span`,{className:`font-mono text-xs truncate`,children:e.magicDns}),s(`button`,{onClick:()=>o(e.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":`Copy MagicDNS`,children:s(P,{className:`h-3 w-3 text-foreground-subtle`})})]}):s(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:e=>{let t=e.addresses[0]??``;return t?n(`div`,{className:`flex items-center gap-1`,children:[s(`span`,{className:`font-mono text-xs`,children:t}),s(`button`,{onClick:()=>o(t),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":`Copy IP`,children:s(P,{className:`h-3 w-3 text-foreground-subtle`})})]}):s(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:`Connection`,render:e=>n(`div`,{className:`flex items-center gap-1.5`,children:[s(p,{variant:Je(e.connection),children:e.connection}),e.relay&&s(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.relay})]})},{key:`routes`,header:`Routes`,render:e=>e.advertisedRoutes.length>0?s(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):s(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:`TX / RX`,render:e=>n(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,Ye(e.txBytes),` · ↓ `,Ye(e.rxBytes)]})},{key:`lastSeen`,header:`Last seen`,render:e=>s(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?Xe(e.lastSeenMs):`—`})}],[o]);return i&&t.length===0?n(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[s(G,{className:`h-3 w-3 animate-spin inline mr-1`}),` Loading peers…`]}):t.length===0?s(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:`No peers visible — your tailnet may be empty or the host is not joined.`}):s(`div`,{className:`p-4`,children:s(se,{columns:c,rows:a,rowKey:e=>e._id,minWidthPx:820})})}function Je(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function Ye(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 Xe(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 Ze(e){return new Promise(t=>setTimeout(t,e))}t();function $(e){if(e===null||e===``)return`—`;let t=e.replace(/:/g,``);return t.length<=16?e:`${t.slice(0,8)}…${t.slice(-8)}`}function Qe(){let e=a(),t=C(void 0,{refetchInterval:15e3}),r=ne({onSuccess:()=>void e.invalidateQueries({queryKey:[[`localNetwork`]]})}),i=y({onSuccess:()=>void e.invalidateQueries({queryKey:[[`localNetwork`]]})}),c=w({onSuccess:()=>{d(!1),p(``),h(``),v(``),e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),l=t.data,[u,d]=o(!1),[f,p]=o(``),[m,h]=o(``),[_,v]=o(``),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)},S=l?.mode===`uploaded`?`Uploaded`:l?.mode===`generated`?`Generated local CA`:`TLS disabled`;return n(`div`,{className:`flex flex-col gap-4`,children:[s(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.`}),n(x,{className:`p-4 space-y-3`,children:[n(`div`,{className:`flex items-center gap-2`,children:[s(L,{className:`h-4 w-4 text-foreground-subtle`}),s(`h3`,{className:`text-sm font-semibold`,children:`Certificate`})]}),t.isError&&s(`p`,{className:`text-xs text-danger`,children:`Could not read TLS status.`}),l?.reissueError&&s(`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&&s(`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:`Restart the hub to apply the new certificate.`}),n(`dl`,{className:`grid grid-cols-1 gap-2 text-xs sm:grid-cols-2`,children:[n(`div`,{children:[s(`dt`,{className:`text-foreground-subtle`,children:`Mode`}),s(`dd`,{className:`font-medium`,children:S})]}),n(`div`,{children:[s(`dt`,{className:`text-foreground-subtle`,children:`Valid to`}),s(`dd`,{className:`font-mono`,children:l?.validTo?new Date(l.validTo).toLocaleString():`—`})]}),n(`div`,{children:[s(`dt`,{className:`text-foreground-subtle`,children:`Leaf SHA-256`}),s(`dd`,{className:`font-mono`,title:l?.leafFingerprintSha256??void 0,children:$(l?.leafFingerprintSha256??null)})]}),n(`div`,{children:[s(`dt`,{className:`text-foreground-subtle`,children:`CA SHA-256`}),s(`dd`,{className:`font-mono`,title:l?.caFingerprintSha256??void 0,children:$(l?.caFingerprintSha256??null)})]})]}),l&&l.sans.length>0&&s(`div`,{className:`flex flex-wrap gap-1`,children:l.sans.map(e=>s(`span`,{className:`rounded border border-border bg-surface px-1.5 py-0.5 font-mono text-[10px] text-foreground-subtle`,children:e},e))}),n(`div`,{className:`flex flex-wrap gap-2`,children:[s(D,{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`||r.isPending,action:()=>r.mutateAsync({})}),s(g,{size:`sm`,variant:`outline`,onClick:()=>d(e=>!e),children:`Upload`}),l?.caCertPem&&s(g,{size:`sm`,variant:`outline`,onClick:b,children:`Download CA`}),l?.mode===`uploaded`&&s(D,{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&&n(`div`,{className:`space-y-2 border-t border-border pt-3`,children:[n(`label`,{className:`block text-[11px] text-foreground-subtle`,children:[`Certificate PEM`,s(`textarea`,{value:f,onChange:e=>p(e.target.value),rows:6,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`})]}),n(`label`,{className:`block text-[11px] text-foreground-subtle`,children:[`Private key PEM`,s(`textarea`,{value:m,onChange:e=>h(e.target.value),rows:6,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`})]}),n(`label`,{className:`block text-[11px] text-foreground-subtle`,children:[`CA PEM (optional)`,s(`textarea`,{value:_,onChange:e=>v(e.target.value),rows:4,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`})]}),s(g,{size:`sm`,disabled:!f.trim()||!m.trim()||c.isPending,onClick:()=>c.mutate({certPem:f,keyPem:m,..._.trim()?{caPem:_}:{}}),children:`Save certificate`}),c.isError&&s(`p`,{className:`text-xs text-danger`,children:c.error instanceof Error?c.error.message:`Upload failed`})]})]})]})}function $e(){return s(`div`,{className:`flex flex-col p-4`,children:s(_e,{defaultTab:`addresses`,tabs:[{id:`local-access`,label:`Local access`,icon:z,content:s(Qe,{})},{id:`addresses`,label:`Network Addresses`,icon:I,content:s(Le,{})},{id:`remote-access`,label:`Remote Access`,icon:H,content:s(Ce,{})},{id:`mesh`,label:`Mesh Networks`,icon:N,content:s(Ve,{})},{id:`turn`,label:`TURN Servers`,icon:K,content:s(ke,{})}]})})}export{$e as NetworkPage};
|
|
1
|
+
import{I as e,Q as t,S as n,W as r,b as i,o as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{at as l}from"./player-overlays-DVo2KR_t.js";import{$i as u,Bi as d,Fs as f,Ft as p,Gi as m,Hi as h,It as g,Ji as _,Jt as v,Ki as y,Mn as b,Pt as x,Qi as S,Ri as ee,Ui as te,Vi as C,Wi as ne,Xi as w,Yi as re,Zi as T,aa as E,ea as ie,ia as ae,it as D,jn as O,jt as oe,nt as se,oa as k,qi as ce,ta as A,zi as le}from"./src-CLAf92SY.js";import{it as j,lt as M}from"./src-e8CzBBHU.js";import{t as N}from"./boxes-DUWmFsrP.js";import{t as P}from"./copy-Clr1lTje.js";import{t as F}from"./play-Bc0Mbg1N.js";import{t as ue}from"./refresh-cw-Bk9SNV20.js";import{t as de}from"./rotate-ccw-C4cPfNFW.js";import{t as I}from"./server-C4WwnByv.js";import{t as L}from"./shield-BF2zMD3h.js";import{t as R}from"./square-C8DJ0ohY.js";import{t as z}from"./wifi-DKocxMvb.js";import{B,C as V,D as H,J as U,M as W,S as fe,a as pe,c as me,r as he,w as G,y as K}from"./index-DL2yqdrc.js";import{t as ge}from"./AdminPage-CiKtOLQm.js";import{t as _e}from"./AdminTabs-B4GGMxRz.js";import{t as ve}from"./NodeAddonsSettingsPanel-BlZbeN2Z.js";import{t as q}from"./AddonCollectionPage-DwDJOFcL.js";import{t as J}from"./addon-display-names-DvSEQty-.js";var ye=U(`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`}]]),be=U(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),xe=U(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]);t();var Y=5e3,Se={connected:!1,endpoint:null};function Ce(){let e=a(),t=b({capName:`network-access`},{refetchInterval:Y}),n=O(void 0,{refetchInterval:Y}),i=r(()=>J(n.data??[]),[n.data]),c=r(()=>(t.data??[]).map(e=>({addonId:e.addonId,displayName:i.get(e.addonId)??e.addonId,isActive:e.isActive})),[t.data,i]),[l,u]=o(null),[d,f]=o({}),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=E({onSuccess:p,onError:m}),g=k({onSuccess:p,onError:m});return s(q,{title:`Remote Access`,subtitle:`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …). Settings, Logs and Events are docked under every provider.`,pageIcon:H,itemIcon:H,capability:`network-access`,installButtonLabel:`Add tunnel`,items:c,isLoading:t.isLoading,emptyTitle:`No remote-access providers installed`,emptyDescription:`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`,renderStatusBadges:e=>s(Te,{addonId:e.addonId}),itemError:e=>d[e.addonId]??null,renderPrimaryAction:e=>s(Ee,{addonId:e.addonId,busyId:l,onStart:e=>{u(e),h.mutate({addonId:e})},onStop:e=>{u(e),g.mutate({addonId:e})}})})}function we(e){let{data:t}=ae({addonId:e},{refetchInterval:Y,retry:!1}),n=t?M.safeParse(t):null;return n?.success?n.data:Se}function Te({addonId:e}){let t=we(e);return n(i,{children:[s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.connected?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:`bg-foreground-subtle/15 text-foreground-subtle`}`,children:t.connected?`Connected`:`Disconnected`}),t.endpoint&&n(`a`,{href:t.endpoint.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`text-[10px] text-emerald-700 dark:text-emerald-300 hover:underline flex items-center gap-1`,children:[s(W,{className:`h-3 w-3`}),t.endpoint.url]})]})}function Ee({addonId:e,busyId:t,onStart:r,onStop:i}){let a=we(e),o=t===e;return a.connected?n(g,{size:`sm`,variant:`secondary`,disabled:o,onClick:()=>i(e),children:[o?s(G,{className:`h-3 w-3 animate-spin`}):s(R,{className:`h-3 w-3`}),`Stop`]}):n(g,{size:`sm`,variant:`primary`,disabled:o,onClick:()=>r(e),children:[o?s(G,{className:`h-3 w-3 animate-spin`}):s(F,{className:`h-3 w-3`}),`Start`]})}t();var De=3e4;function Oe(e){let t=[];for(let n of e)typeof n.urls==`string`?t.push(n.urls):t.push(...n.urls);return t}function ke(){let e=b({capName:`turn-provider`},{refetchInterval:De}),t=O(void 0,{refetchInterval:De}),i=f(),a=i.data??[],o=r(()=>J(t.data??[]),[t.data]);return s(q,{title:`TURN Servers`,subtitle:`ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.`,pageIcon:K,itemIcon:K,capability:`turn-provider`,installButtonLabel:`Add provider`,items:r(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:o.get(e.addonId)??e.addonId,isActive:e.isActive})),[e.data,o]),isLoading:e.isLoading,emptyTitle:`No TURN providers installed`,emptyDescription:`Install a TURN addon (e.g. @camstack/addon-cloudflare) to enable WebRTC behind restrictive NATs.`,renderExpandedPanel:e=>s(Ae,{addonId:e.addonId,enabled:e.isActive}),trailing:n(x,{children:[n(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between`,children:[n(`div`,{children:[s(`div`,{className:`text-sm font-semibold`,children:`Combined ICE server list`}),s(`div`,{className:`text-xs text-foreground-subtle`,children:`What the WebRTC layer fetches per-session.`})]}),s(g,{size:`sm`,variant:`secondary`,onClick:()=>i.refetch(),disabled:i.isFetching,children:`Refresh`})]}),s(`div`,{className:`p-4`,children:a.length===0?s(`div`,{className:`text-xs text-foreground-subtle`,children:`No servers from enabled providers.`}):s(`div`,{className:`flex flex-col gap-3`,children:a.map((e,t)=>{let r=Array.isArray(e.urls)?e.urls:[e.urls];return n(`div`,{className:`rounded border border-border bg-surface`,children:[(e.username||e.credential)&&n(`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&&n(`span`,{children:[s(`span`,{className:`text-foreground-subtle`,children:`user:`}),` `,s(`span`,{className:`text-foreground`,children:e.username})]}),e.credential&&n(`span`,{children:[s(`span`,{className:`text-foreground-subtle`,children:`credential:`}),` `,s(`span`,{className:`text-foreground`,children:`••••••••`})]})]}),s(`ul`,{className:`divide-y divide-border`,children:r.map(e=>s(`li`,{className:`px-3 py-1.5 font-mono text-xs text-foreground break-all`,children:e},e))})]},t)})})})]})})}function Ae({addonId:e,enabled:t}){let i=f({addonId:e},{enabled:t,retry:!1}),a=r(()=>Oe(i.data??[]),[i.data]);return!t||a.length===0?null:n(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[n(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Discovered ICE servers (`,a.length,`)`]}),s(`div`,{className:`flex flex-wrap gap-1`,children:a.map(e=>s(`span`,{className:`inline-block rounded px-1.5 py-0.5 text-[10px] font-mono bg-foreground-subtle/10 text-foreground`,children:e},e))})]})}t();var je={lan:K,wifi:z,docker:N,vpn:V,loopback:I,other:I},Me={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},Ne=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function Pe(e){let{interfaces:t,disabled:i,hideLoopback:a,ipv4Only:o,emptyMessage:c}=e,l=r(()=>t.filter(e=>!(a&&e.kind===`loopback`||o&&e.family!==`IPv4`)),[t,a,o]),u=r(()=>{let e=new Map;for(let t of l){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return Ne.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(i||t.kind===`loopback`)return;if(e.mode===`single`){e.onChange(e.value===t.address?null:t.address);return}let n=new Set(e.value);n.has(t.address)?n.delete(t.address):n.add(t.address),e.onChange([...n])};return l.length===0?s(`div`,{className:`text-xs text-foreground-subtle italic`,children:c??`No addresses available.`}):s(`div`,{className:`flex flex-col gap-3`,children:u.map(({kind:t,items:r})=>n(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[n(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[s(je[t]??I,{className:`h-3.5 w-3.5 text-foreground-subtle`}),s(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:Me[t]??t}),n(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,r.length]})]}),s(`ul`,{className:`divide-y divide-border`,children:r.map(t=>{let r=d(t.address),a=t.kind===`loopback`,o=!t.plausible&&!a;return n(`li`,{className:`flex items-center gap-3 px-3 py-2 ${a?`opacity-60 cursor-not-allowed`:i?`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:[s(`span`,{className:`flex items-center justify-center h-4 w-4 rounded ${e.mode===`single`?`rounded-full`:`rounded`} border ${r?`border-primary bg-primary text-primary-foreground`:`border-border bg-surface`}`,children:r&&s(B,{className:`h-3 w-3`})}),n(`div`,{className:`flex-1 min-w-0 ${o?`text-foreground-subtle`:``}`,children:[n(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[s(`span`,{className:`font-mono text-xs font-semibold ${o?`text-foreground-subtle`:`text-foreground`}`,children:t.name}),s(`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&&s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:`Auto-preferred`}),a&&s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:`Always included`}),o&&n(`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:[s(pe,{className:`h-2.5 w-2.5`}),`Unlikely usable`]})]}),n(`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))})}t();var Fe={"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`},loopback:{label:`Loopback`,className:`bg-foreground-subtle/15 text-foreground-subtle`}};function X(e){return e.kind!==`loopback`}function Ie(e){return e.kind!==`loopback`}function Le(){let e=a(),t=l(),i=te(void 0,{refetchInterval:3e4}),u=ee(void 0),f=ce({onSuccess:()=>{e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),p=m({onSuccess:t=>{S(t.addresses),e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),v=r(()=>i.data?.interfaces??[],[i.data]),y=le({port:typeof window<`u`?Number(window.location.port)||(window.location.protocol===`https:`?443:80):4e3,scheme:typeof window<`u`&&window.location.protocol===`https:`?`https`:`http`},{refetchInterval:3e4}),[b,S]=o([]),[C,ne]=o(!1);c(()=>{!C&&u.data&&(S(u.data.addresses),ne(!0))},[u.data,C]);let w=u.data?.addresses??[],T=r(()=>{if(b.length!==w.length)return!0;let e=[...b].toSorted(),t=[...w].toSorted();return e.some((e,n)=>e!==t[n])},[b,w]),E=()=>{f.mutate({addresses:[...b]})},ie=()=>{S(w)},ae=()=>{S([])},D=()=>{i.refetch(),y.refetch(),u.refetch(),k.refetch(),j.refetch()},O=async()=>{try{let e=await t.raceConnectionEndpoints({perCandidateTimeoutMs:1500});console.info(`[network-addresses] race result`,e)}catch(e){console.warn(`[network-addresses] race failed`,e)}},k=d(),A=_({onSuccess:()=>void k.refetch()}),j=h(),M=re({onSuccess:()=>void j.refetch()}),N=y.data?.endpoints??[],P=k.data?.baseUrl??null,F=k.data?.resolved??null,I=j.data?.baseUrls??[],L=I.length===0,R=P===null,z=e=>L?e.kind===`lan-ipv4`||e.kind===`public`&&e.interfaceKind===`public`:I.includes(e.baseUrl),B=e=>P===null?F===e.baseUrl:P===e.baseUrl,V=e=>{if(!X(e))return;let t=L?N.filter(e=>X(e)&&z(e)).map(e=>e.baseUrl):[...I],n=t.includes(e.baseUrl)?t.filter(t=>t!==e.baseUrl):[...t,e.baseUrl];M.mutate({baseUrls:n})},H=e=>{if(Ie(e)){if(B(e)){R||A.mutate({baseUrl:null});return}A.mutate({baseUrl:e.baseUrl})}},U=r(()=>[{key:`url`,header:`Endpoint`,render:e=>n(`div`,{className:`min-w-0 py-0.5`,children:[s(`div`,{className:`font-mono text-[12px] break-all ${e.plausible?`text-foreground`:`text-foreground-subtle`}`,children:e.baseUrl}),n(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[s(`span`,{children:e.label}),e.interfaceKind!==`lan`&&e.interfaceKind!==`public`&&s(`span`,{className:`uppercase tracking-wide`,children:e.interfaceKind}),!e.plausible&&e.interfaceKind!==`loopback`&&n(`span`,{className:`inline-flex items-center gap-1 text-amber-700 dark:text-amber-300`,title:e.plausibleReason||void 0,children:[s(pe,{className:`h-2.5 w-2.5`}),`Unlikely usable`]})]})]})},{key:`kind`,header:`Kind`,nowrap:!0,render:e=>{let t=Fe[e.kind]??Fe.loopback;return s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.className}`,children:t.label})}},{key:`viewer`,headerRender:()=>n(`span`,{className:`inline-flex items-center gap-1`,children:[`Viewer`,L?s(`span`,{className:`text-[10px] font-normal normal-case text-foreground-subtle`,children:`auto`}):null]}),align:`center`,nowrap:!0,width:`w-24`,render:e=>{let t=X(e);return s(`label`,{className:`inline-flex justify-center ${t?`cursor-pointer`:`cursor-not-allowed opacity-40`}`,title:e.kind===`loopback`?`Loopback is not a client route.`:`Use this URL in the API / viewer race.`,children:s(oe,{checked:t&&z(e),disabled:!t||M.isPending,onChange:()=>V(e),"aria-label":`Viewer: ${e.baseUrl}`})})}},{key:`notifications`,headerRender:()=>n(`span`,{className:`inline-flex items-center gap-1`,children:[`Notifications`,R?s(`span`,{className:`text-[10px] font-normal normal-case text-foreground-subtle`,children:`auto`}):null]}),align:`center`,nowrap:!0,width:`w-28`,render:e=>{let t=Ie(e);return s(`label`,{className:`inline-flex justify-center ${t?`cursor-pointer`:`cursor-not-allowed opacity-40`}`,title:t?`Notification links and deep links use this address.`:`Loopback is not a client route.`,children:s(oe,{checked:t&&B(e),disabled:!t||A.isPending,onChange:()=>H(e),"aria-label":`Notifications: ${e.baseUrl}`})})}}],[L,R,I,P,F,M.isPending,A.isPending,N]);return n(ge,{children:[n(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[s(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:`Pin which host addresses exist, then tick the destinations each URL should serve. Viewer auto is IPv4 + public; every other row (including IPv6) can be ticked on.`}),n(`div`,{className:`flex items-center gap-2 shrink-0`,children:[n(g,{size:`sm`,variant:`secondary`,onClick:D,disabled:i.isLoading,children:[s(ue,{className:`h-3 w-3 ${i.isLoading?`animate-spin`:``}`}),`Refresh`]}),s(g,{size:`sm`,variant:`secondary`,onClick:O,children:`Probe race`})]})]}),n(x,{children:[n(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between gap-3 flex-wrap`,children:[n(`div`,{children:[s(`div`,{className:`text-sm font-semibold`,children:`Allowed addresses`}),s(`div`,{className:`text-xs text-foreground-subtle`,children:b.length===0?`Auto — every non-loopback / non-link-local interface participates.`:`${b.length} pinned`})]}),n(`div`,{className:`flex items-center gap-1`,children:[n(g,{size:`sm`,variant:`secondary`,onClick:()=>p.mutate(void 0),disabled:p.isPending||f.isPending,title:`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`,children:[s(me,{className:`h-3 w-3`}),p.isPending?`Detecting…`:`Best match`]}),n(g,{size:`sm`,variant:`secondary`,onClick:ae,disabled:b.length===0||f.isPending,children:[s(de,{className:`h-3 w-3`}),`Clear`]}),T&&s(g,{size:`sm`,variant:`secondary`,onClick:ie,disabled:f.isPending,children:`Discard`}),n(g,{size:`sm`,variant:`primary`,onClick:E,disabled:!T||f.isPending,children:[s(be,{className:`h-3 w-3`}),f.isPending?`Saving…`:`Save`]})]})]}),s(`div`,{className:`p-4`,children:s(Pe,{mode:`multiple`,interfaces:v,value:b,onChange:S,disabled:f.isPending,emptyMessage:i.isLoading?`Loading interfaces…`:`No interfaces detected.`})})]}),n(x,{children:[n(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between gap-3 flex-wrap`,children:[n(`div`,{children:[s(`div`,{className:`text-sm font-semibold`,children:`Connection endpoints`}),s(`div`,{className:`text-xs text-foreground-subtle`,children:`Ranked URLs this hub advertises. Tick Viewer (many) and Notifications (one).`})]}),n(`div`,{className:`flex items-center gap-1`,children:[!L&&s(g,{size:`sm`,variant:`secondary`,disabled:M.isPending,onClick:()=>M.mutate({baseUrls:[]}),children:`Viewer → auto`}),!R&&s(g,{size:`sm`,variant:`secondary`,disabled:A.isPending,onClick:()=>A.mutate({baseUrl:null}),children:`Notifications → auto`})]})]}),R&&F===null&&s(`p`,{className:`px-4 pt-3 text-[11px] text-amber-600 dark:text-amber-400`,children:`No public address is reachable, so notification media ships as bytes only — a backend that can only take links (WhatsApp, gotify) receives none.`}),s(se,{columns:U,rows:N,rowKey:e=>`${e.priority}-${e.baseUrl}`,minWidthPx:640,bordered:!1,mobileMode:`scroll`,emptyMessage:y.isLoading?`Loading…`:`No endpoints available.`,rowClassName:e=>e.plausible?void 0:`opacity-80`})]})]})}t();var Re={mesh:`bg-violet-500/15 text-violet-700 dark:text-violet-300`,public:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},Z=5e3,ze=3e4,Be={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function Ve(){let e=b({capName:`mesh-network`},{refetchInterval:Z}),t=O(void 0,{refetchInterval:Z}),n=r(()=>J(t.data??[]),[t.data]);return s(q,{title:`Mesh Networks`,subtitle:`Private VPN meshes that connect CamStack to your other devices (Tailscale, Headscale, …). Each provider can also expose this hub publicly via its ingress (Tailscale Funnel).`,pageIcon:N,itemIcon:K,capability:`mesh-network`,installButtonLabel:`Add mesh`,items:r(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:n.get(e.addonId)??e.addonId,isActive:e.isActive})),[e.data,n]),isLoading:e.isLoading,emptyTitle:`No mesh-network providers installed`,emptyDescription:`Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.`,renderStatusBadges:e=>s(He,{addonId:e.addonId}),renderPrimaryAction:e=>s(Ue,{addonId:e.addonId}),renderExpandedPanel:e=>s(We,{addonId:e.addonId})})}function Q(e){let{data:t,isLoading:n}=T({addonId:e},{refetchInterval:Z,retry:!1}),r=t?j.safeParse(t):null;return{status:r?.success?r.data:Be,isLoading:n}}function He({addonId:e}){let{status:t}=Q(e);return n(i,{children:[s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.joined?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:`bg-foreground-subtle/15 text-foreground-subtle`}`,children:t.joined?`Joined`:`Not joined`}),t.joined&&n(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:[t.peerCount,` peer`,t.peerCount===1?``:`s`]})]})}function Ue({addonId:t}){let r=a(),[c,u]=o(!1),[d,f]=o(null),p=l(),{status:m}=Q(t),h=e(()=>{r.invalidateQueries({queryKey:[[`meshNetwork`]]})},[r]),_=A(),v=S({onSuccess:h}),y=ie({onSuccess:h}),b=e(async()=>{u(!0);let e={cancelled:!1};f(e);try{let n=await _.mutateAsync({addonId:t});if(e.cancelled)return;n.loginUrl&&window.open(n.loginUrl,`_blank`,`noopener,noreferrer`);let r=Date.now();for(;!e.cancelled&&(await Ze(2e3),!e.cancelled);){let e=await p.trpcClient.meshNetwork.getStatus.query({addonId:t}).catch(()=>null),n=e?j.safeParse(e):null;if(n?.success&&n.data.joined){h();break}if(Date.now()-r>6e5)break}}finally{u(!1),f(null)}},[t,h,_,p]),x=e(()=>{d&&(d.cancelled=!0),u(!1),f(null)},[d]);return s(i,{children:m.joined?n(i,{children:[n(g,{size:`sm`,variant:`secondary`,disabled:v.isPending,onClick:()=>v.mutate({addonId:t}),children:[v.isPending?s(G,{className:`h-3 w-3 animate-spin`}):s(fe,{className:`h-3 w-3`}),`Disconnect`]}),n(g,{size:`sm`,variant:`ghost`,disabled:y.isPending,onClick:()=>y.mutate({addonId:t}),children:[y.isPending?s(G,{className:`h-3 w-3 animate-spin`}):s(xe,{className:`h-3 w-3`}),`Log out`]})]}):c?n(g,{size:`sm`,variant:`ghost`,onClick:x,children:[s(he,{className:`h-3 w-3 mr-1`}),` Cancel`]}):n(i,{children:[n(g,{size:`sm`,variant:`primary`,onClick:()=>void b(),children:[s(ye,{className:`h-3 w-3`}),`Connect`]}),n(g,{size:`sm`,variant:`ghost`,disabled:y.isPending,onClick:()=>y.mutate({addonId:t}),children:[y.isPending?s(G,{className:`h-3 w-3 animate-spin`}):s(xe,{className:`h-3 w-3`}),`Log out`]})]})})}function We({addonId:e}){let{status:t}=Q(e),r=u({addonId:e},{refetchInterval:ze,retry:!1});return n(`div`,{className:`rounded-lg border border-border bg-surface`,children:[n(`div`,{className:`p-4 space-y-4`,children:[t.error&&s(v,{message:t.error}),s(Ge,{status:t}),t.endpoints.length>0&&n(`div`,{className:`space-y-1.5`,children:[s(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:`Endpoints`}),t.endpoints.map(e=>n(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[n(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${Re[e.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[e.scope===`public`?s(H,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,e.label]}),n(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1`,children:[s(W,{className:`h-3 w-3 shrink-0`}),e.url]})]},e.id))]})]}),s(`div`,{className:`border-t border-border`,children:s(qe,{peers:r.data?.peers??[],loading:r.isLoading})})]})}function Ge({status:e}){return s(`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?Ke(e.keyExpiry):`—`}].map(e=>n(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[s(`span`,{className:`text-foreground-subtle shrink-0`,children:e.label}),s(`span`,{className:`text-foreground truncate ${e.mono?`font-mono`:``}`,children:e.value})]},e.label))})}function Ke(e){let t=e-Date.now();if(t<0)return`Expired ${Xe(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 qe({peers:t,loading:i}){let a=r(()=>t.map(e=>({...e,_id:e.id})),[t]),o=e(e=>{e&&navigator.clipboard?.writeText(e)},[]),c=r(()=>[{key:`hostname`,header:`Hostname`,render:e=>n(`div`,{className:`flex flex-col`,children:[n(`div`,{className:`flex items-center gap-1.5`,children:[s(`span`,{className:`font-medium text-foreground`,children:e.hostname||`(unknown)`}),e.isSelf&&s(p,{variant:`info`,children:`self`}),e.exitNodeOption&&s(p,{variant:`warning`,children:`exit-node`})]}),e.userLogin&&s(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.userLogin})]})},{key:`magicDns`,header:`MagicDNS`,render:e=>e.magicDns?n(`div`,{className:`flex items-center gap-1`,children:[s(`span`,{className:`font-mono text-xs truncate`,children:e.magicDns}),s(`button`,{onClick:()=>o(e.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":`Copy MagicDNS`,children:s(P,{className:`h-3 w-3 text-foreground-subtle`})})]}):s(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:e=>{let t=e.addresses[0]??``;return t?n(`div`,{className:`flex items-center gap-1`,children:[s(`span`,{className:`font-mono text-xs`,children:t}),s(`button`,{onClick:()=>o(t),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":`Copy IP`,children:s(P,{className:`h-3 w-3 text-foreground-subtle`})})]}):s(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:`Connection`,render:e=>n(`div`,{className:`flex items-center gap-1.5`,children:[s(p,{variant:Je(e.connection),children:e.connection}),e.relay&&s(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.relay})]})},{key:`routes`,header:`Routes`,render:e=>e.advertisedRoutes.length>0?s(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):s(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:`TX / RX`,render:e=>n(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,Ye(e.txBytes),` · ↓ `,Ye(e.rxBytes)]})},{key:`lastSeen`,header:`Last seen`,render:e=>s(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?Xe(e.lastSeenMs):`—`})}],[o]);return i&&t.length===0?n(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[s(G,{className:`h-3 w-3 animate-spin inline mr-1`}),` Loading peers…`]}):t.length===0?s(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:`No peers visible — your tailnet may be empty or the host is not joined.`}):s(`div`,{className:`p-4`,children:s(se,{columns:c,rows:a,rowKey:e=>e._id,minWidthPx:820})})}function Je(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function Ye(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 Xe(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 Ze(e){return new Promise(t=>setTimeout(t,e))}t();function $(e){if(e===null||e===``)return`—`;let t=e.replace(/:/g,``);return t.length<=16?e:`${t.slice(0,8)}…${t.slice(-8)}`}function Qe(){let e=a(),t=C(void 0,{refetchInterval:15e3}),r=ne({onSuccess:()=>void e.invalidateQueries({queryKey:[[`localNetwork`]]})}),i=y({onSuccess:()=>void e.invalidateQueries({queryKey:[[`localNetwork`]]})}),c=w({onSuccess:()=>{d(!1),p(``),h(``),v(``),e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),l=t.data,[u,d]=o(!1),[f,p]=o(``),[m,h]=o(``),[_,v]=o(``),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)},S=l?.mode===`uploaded`?`Uploaded`:l?.mode===`generated`?`Generated local CA`:`TLS disabled`;return n(`div`,{className:`flex flex-col gap-4`,children:[s(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.`}),n(x,{className:`p-4 space-y-3`,children:[n(`div`,{className:`flex items-center gap-2`,children:[s(L,{className:`h-4 w-4 text-foreground-subtle`}),s(`h3`,{className:`text-sm font-semibold`,children:`Certificate`})]}),t.isError&&s(`p`,{className:`text-xs text-danger`,children:`Could not read TLS status.`}),l?.reissueError&&s(`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&&s(`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:`Restart the hub to apply the new certificate.`}),n(`dl`,{className:`grid grid-cols-1 gap-2 text-xs sm:grid-cols-2`,children:[n(`div`,{children:[s(`dt`,{className:`text-foreground-subtle`,children:`Mode`}),s(`dd`,{className:`font-medium`,children:S})]}),n(`div`,{children:[s(`dt`,{className:`text-foreground-subtle`,children:`Valid to`}),s(`dd`,{className:`font-mono`,children:l?.validTo?new Date(l.validTo).toLocaleString():`—`})]}),n(`div`,{children:[s(`dt`,{className:`text-foreground-subtle`,children:`Leaf SHA-256`}),s(`dd`,{className:`font-mono`,title:l?.leafFingerprintSha256??void 0,children:$(l?.leafFingerprintSha256??null)})]}),n(`div`,{children:[s(`dt`,{className:`text-foreground-subtle`,children:`CA SHA-256`}),s(`dd`,{className:`font-mono`,title:l?.caFingerprintSha256??void 0,children:$(l?.caFingerprintSha256??null)})]})]}),l&&l.sans.length>0&&s(`div`,{className:`flex flex-wrap gap-1`,children:l.sans.map(e=>s(`span`,{className:`rounded border border-border bg-surface px-1.5 py-0.5 font-mono text-[10px] text-foreground-subtle`,children:e},e))}),n(`div`,{className:`flex flex-wrap gap-2`,children:[s(D,{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`||r.isPending,action:()=>r.mutateAsync({})}),s(g,{size:`sm`,variant:`outline`,onClick:()=>d(e=>!e),children:`Upload`}),l?.caCertPem&&s(g,{size:`sm`,variant:`outline`,onClick:b,children:`Download CA`}),l?.mode===`uploaded`&&s(D,{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&&n(`div`,{className:`space-y-2 border-t border-border pt-3`,children:[n(`label`,{className:`block text-[11px] text-foreground-subtle`,children:[`Certificate PEM`,s(`textarea`,{value:f,onChange:e=>p(e.target.value),rows:6,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`})]}),n(`label`,{className:`block text-[11px] text-foreground-subtle`,children:[`Private key PEM`,s(`textarea`,{value:m,onChange:e=>h(e.target.value),rows:6,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`})]}),n(`label`,{className:`block text-[11px] text-foreground-subtle`,children:[`CA PEM (optional)`,s(`textarea`,{value:_,onChange:e=>v(e.target.value),rows:4,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`})]}),s(g,{size:`sm`,disabled:!f.trim()||!m.trim()||c.isPending,onClick:()=>c.mutate({certPem:f,keyPem:m,..._.trim()?{caPem:_}:{}}),children:`Save certificate`}),c.isError&&s(`p`,{className:`text-xs text-danger`,children:c.error instanceof Error?c.error.message:`Upload failed`})]})]})]})}function $e(){return s(`div`,{className:`flex flex-col p-4`,children:s(_e,{defaultTab:`addresses`,tabs:[{id:`local-access`,label:`Local access`,icon:z,content:s(Qe,{})},{id:`addresses`,label:`Network Addresses`,icon:I,content:s(Le,{})},{id:`remote-access`,label:`Remote Access`,icon:H,content:s(Ce,{})},{id:`mesh`,label:`Mesh Networks`,icon:N,content:s(Ve,{})},{id:`turn`,label:`TURN Servers`,icon:K,content:s(ke,{})}]})})}export{$e as NetworkPage};
|