@camstack/addon-admin-ui 1.2.81 → 1.2.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AddLocationWizard-WDALxpq-.js → AddLocationWizard-De7ns5QL.js} +1 -1
- package/dist/assets/{AddonCollectionPage-D86qUT-8.js → AddonCollectionPage-DXsxDYkh.js} +1 -1
- package/dist/assets/{Addons-C7jR5jKB.js → Addons-iB8Jj8Wa.js} +1 -1
- package/dist/assets/{AdminTabs-D6yDsobg.js → AdminTabs-Ea5QF5Xy.js} +1 -1
- package/dist/assets/AiProfiles-Cf11u16h.js +3 -0
- package/dist/assets/{BrokerForm-DnKqFWQy.js → BrokerForm-B-sL3dqC.js} +1 -1
- package/dist/assets/{Build-Ipz6h2Qx.js → Build-_kPogt2B.js} +5 -5
- package/dist/assets/{Capabilities-wOV3gO99.js → Capabilities-D-_vyuUw.js} +1 -1
- package/dist/assets/{CapabilityBadges-CByvC3eB.js → CapabilityBadges-DVcflr6z.js} +1 -1
- package/dist/assets/{Cluster-DDXbnzQA.js → Cluster-CP-cfGdm.js} +1 -1
- package/dist/assets/{Data-Btzeyfj7.js → Data-D3-pzcKz.js} +1 -1
- package/dist/assets/{DetectionIntelligence-Dt4la9Ns.js → DetectionIntelligence-B914KqGk.js} +1 -1
- package/dist/assets/{DeviceAggregateSection-iY2G54zN.js → DeviceAggregateSection-CZPFsC_N.js} +1 -1
- package/dist/assets/DeviceDetail-Cz70xnHl.js +2 -0
- package/dist/assets/Devices-CQEzT4CH.js +1 -0
- package/dist/assets/EmbedPlayerPage-BQ1dgL2t.js +1 -0
- package/dist/assets/Events-B9-2qvUg.js +1 -0
- package/dist/assets/{FormBuilder-B-sNHhCg.js → FormBuilder-ERsdhqXU.js} +1 -1
- package/dist/assets/Identity-BNMnBiNq.js +1 -0
- package/dist/assets/IntegrationDetail-CY-7m0wv.js +1 -0
- package/dist/assets/Integrations-Bs6_6m2A.js +1 -0
- package/dist/assets/Integrations-CbfIXyMv.js +1 -0
- package/dist/assets/{Logs-Rdo_SjmO.js → Logs-CJEauzfn.js} +1 -1
- package/dist/assets/{MotionZonesSettings-Bhfztqso.js → MotionZonesSettings-CrtWFnAG.js} +1 -1
- package/dist/assets/{MyAccess-Cuk_gmTY.js → MyAccess-MG2HC7n3.js} +1 -1
- package/dist/assets/Network-DaZHubTl.js +1 -0
- package/dist/assets/{NodeAddonsSettingsPanel-mIPiVij_.js → NodeAddonsSettingsPanel-Cm3hCWxL.js} +1 -1
- package/dist/assets/{NodeInferenceDevices-9bqVJEiE.js → NodeInferenceDevices-2-PPLG4L.js} +1 -1
- package/dist/assets/Notifications-DMPhSkZ8.js +1 -0
- package/dist/assets/Pipeline-D4RLE8zf.js +1 -0
- package/dist/assets/{Plates-DyGd_pUG.js → Plates-CdlwAHjB.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-CTbYEYkc.js → PrivacyMaskSettings-1sJg0nCf.js} +1 -1
- package/dist/assets/{ProviderIcon-D8aWAoj0.js → ProviderIcon-CIB9wAOh.js} +1 -1
- package/dist/assets/Recordings-D4KRWthc.js +1 -0
- package/dist/assets/{ScanNetworkModal-C8Bakspm.js → ScanNetworkModal-QJjU9tvg.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-Cx7eASci.js → SceneMonitorEditor-B_qhxMl3.js} +1 -1
- package/dist/assets/{Scenes-DnqImYTT.js → Scenes-S26M2qHR.js} +1 -1
- package/dist/assets/{Settings-COAxk1-6.js → Settings-BgvNkBP1.js} +1 -1
- package/dist/assets/{Showroom-DmEvzSMg.js → Showroom-GHOpXZqD.js} +1 -1
- package/dist/assets/{Terminal-DasTfEQo.js → Terminal-B0ibWMEy.js} +2 -2
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-tsLPdvDU.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BxzyL6ky.js} +1 -1
- package/dist/assets/{bell-ring-B6JDETmm.js → bell-ring-C1CDDXf4.js} +1 -1
- package/dist/assets/{boxes-DVDxegRH.js → boxes-D1jLdgix.js} +1 -1
- package/dist/assets/{build-cluster-graph-B8Cdzik4.js → build-cluster-graph-C4jX8n1A.js} +2 -2
- package/dist/assets/circle-check-big-Be_uVG-B.js +1 -0
- package/dist/assets/{circle-x-a0OLhq9b.js → circle-x-CJJu15h-.js} +1 -1
- package/dist/assets/clock-9WRXwSMf.js +1 -0
- package/dist/assets/{copy-EKhXmX92.js → copy-CCWWm0Zr.js} +1 -1
- package/dist/assets/{debounced-invalidate-BQ8ML6Ah.js → debounced-invalidate-Bo_vaBxo.js} +1 -1
- package/dist/assets/{dist-Df5TpDx0.js → dist-B7jD-S4H.js} +1 -1
- package/dist/assets/{download-BChaquac.js → download-BkhXjXOx.js} +1 -1
- package/dist/assets/{face-bbox-DKVz3zEq.js → face-bbox-BOyxoUe0.js} +1 -1
- package/dist/assets/{hard-drive-Dg_uzT-t.js → hard-drive-fVjmkYpz.js} +1 -1
- package/dist/assets/{hostInit-CbA0YcFo.js → hostInit-CFYQGKqd.js} +1 -1
- package/dist/assets/index-DM4pp8Vx.js +4 -0
- package/dist/assets/{key-round-DpXzoCIV.js → key-round-BWUCyF0a.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-631dbdb7.js → mf-entry-bootstrap-0-8a7c339b.js} +2 -2
- package/dist/assets/{pencil-dvZNet31.js → pencil-BOy-rDbD.js} +1 -1
- package/dist/assets/play-tYEpmInf.js +1 -0
- package/dist/assets/{player-overlays-DXNKqmwI.js → player-overlays-UTlrOH4s.js} +1 -1
- package/dist/assets/plus-uTnAmy5n.js +1 -0
- package/dist/assets/power-DLJJxxZ5.js +1 -0
- package/dist/assets/{radio-CUBDyXa0.js → radio-DKuDbOsT.js} +1 -1
- package/dist/assets/{refresh-cw-CikJV4hg.js → refresh-cw-BRs_7wGu.js} +1 -1
- package/dist/assets/remoteEntry-B-TTgn5K.js +1 -0
- package/dist/assets/rotate-ccw-CZY9UuXq.js +1 -0
- package/dist/assets/rotate-cw-rDbUnEsj.js +1 -0
- package/dist/assets/search-BGsNM6IN.js +1 -0
- package/dist/assets/{send-jra0X2FY.js → send-DSafmQi_.js} +1 -1
- package/dist/assets/{server-CLphEdE1.js → server-wq15CL48.js} +1 -1
- package/dist/assets/square-BFMdi_Qm.js +1 -0
- package/dist/assets/{square-check-big-B4oQsHOX.js → square-check-big-DO81u3O2.js} +1 -1
- package/dist/assets/{src-DAigq6PX.js → src-C9CFJqET.js} +2 -2
- package/dist/assets/{src-C0QlPpXb.js → src-DVZrqMsD.js} +14 -14
- package/dist/assets/{star-Ch9uuiCl.js → star-Docf4EYZ.js} +1 -1
- package/dist/assets/{undo-2-DLrLmKUr.js → undo-2-LIqqVOPk.js} +1 -1
- package/dist/assets/{upload-DVgOLthM.js → upload-D4XiPM-V.js} +1 -1
- package/dist/assets/{use-scenes-feed-DdlE4MDL.js → use-scenes-feed-BdUI8ZzS.js} +1 -1
- package/dist/assets/useEventInvalidation-DLMOtAJP.js +1 -0
- package/dist/assets/{video-DuMIkvBP.js → video-DdJ2lmUL.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DdAFU5xY.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-cD-zqb5y.js} +2 -2
- package/dist/assets/{wifi-DNsDHc6u.js → wifi-Dx0-akbW.js} +1 -1
- package/dist/assets/{zap-RHfxlZhI.js → zap-BLI50LGc.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/server/addon.js +1 -1
- package/package.json +1 -1
- package/dist/assets/AiProfiles-DECvat8h.js +0 -3
- package/dist/assets/DeviceDetail-CVuY2t9Q.js +0 -2
- package/dist/assets/Devices-DornCZOc.js +0 -1
- package/dist/assets/EmbedPlayerPage-DLdvRzTy.js +0 -1
- package/dist/assets/Events-CEUNSnDV.js +0 -1
- package/dist/assets/Identity-CLAq5pc-.js +0 -1
- package/dist/assets/IntegrationDetail-7LmaONwQ.js +0 -1
- package/dist/assets/Integrations-CDPziDzI.js +0 -1
- package/dist/assets/Integrations-o_BOKz_C.js +0 -1
- package/dist/assets/Network-BAt6cJW9.js +0 -1
- package/dist/assets/Notifications-CwcH2yYC.js +0 -1
- package/dist/assets/Pipeline-C3oEXt8M.js +0 -1
- package/dist/assets/Recordings-CcL3TTxW.js +0 -1
- package/dist/assets/circle-check-big-BZnwR-f7.js +0 -1
- package/dist/assets/clock-fhk_ag9V.js +0 -1
- package/dist/assets/index-DhYfPTfU.js +0 -4
- package/dist/assets/play-D6bynunz.js +0 -1
- package/dist/assets/plus-CDo9Tbkz.js +0 -1
- package/dist/assets/power-BF-VFkkW.js +0 -1
- package/dist/assets/remoteEntry-DbX8dE3W.js +0 -1
- package/dist/assets/rotate-ccw-P5OXZofT.js +0 -1
- package/dist/assets/rotate-cw-DDRA2uuI.js +0 -1
- package/dist/assets/search-DhirDmpC.js +0 -1
- package/dist/assets/square-UC6vONGu.js +0 -1
- package/dist/assets/useEventInvalidation-DqKGeTpc.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
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{Z as l}from"./player-overlays-DXNKqmwI.js";import{Dr as u,E as d,Rr as f,T as p,fi as m,gr as h,hi as g,mn as ee,tn as _,vi as v}from"./src-C0QlPpXb.js";import{t as y}from"./ProviderIcon-D8aWAoj0.js";import{t as b}from"./plus-CDo9Tbkz.js";import{i as te,n as ne,r as re,t as ie}from"./ScanNetworkModal-C8Bakspm.js";import{t as x}from"./refresh-cw-CikJV4hg.js";import{C as S,I as C,J as w,R as T,V as E,X as D,i as O,p as k,t as A,v as ae,z as j}from"./index-DhYfPTfU.js";import{t as oe}from"./AdminPage-CCD07UMs.js";import{t as M}from"./useEventInvalidation-DqKGeTpc.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),d=u(),f=d.data,p=d.isPending||!d.data&&!d.isError;c(()=>{e&&(d.isPending||d.data||d.mutate({addonId:e}))},[e,d]);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=f??[];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,i=a.has(t);return n(`button`,{onClick:()=>m(t),className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${i?`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 ${i?`border-primary bg-primary`:`border-border`}`,children:i&&s(j,{className:`h-3 w-3 text-primary-foreground`})}),s(E,{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})]},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=w(),{data:o,isLoading:c}=g();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(S,{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(C,{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=w(),f=a(),[p,g]=o(`picker`),[_,v]=o(null),[y,b]=o(null),[te,ie]=o(`manual`),[x,C]=o(null),[T,E]=o(``),[D,k]=o(null),[ae,j]=o(null),[oe,M]=o(!1),{data:N}=ee({addonId:_??``,nodeId:`hub`},{enabled:_!=null}),ce=r(()=>N?se(N):null,[N]),z=m({onSuccess:()=>f.invalidateQueries({queryKey:[[`integrations`]]})}),B=u(),le=B.data;c(()=>{p!==`discovery`||!y||!_||B.isPending||B.data||B.mutate({addonId:_})},[p,y,_,B]);let V=h({onSuccess:()=>f.invalidateQueries({queryKey:[[`deviceManager`]]})});function H(e,t,n,r,i,a,o,s){if(!z.isPending){if(v(e),M(s),ie(n),E(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),te===`auto`||te===`both`?g(`discovery`):K(t.id)}catch{}}async function G(e){if(_)try{let t=await z.mutateAsync({addonId:_,name:T,settings:{brokerId:e}});k(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,...D===null?{}:{integrationId:D}})}K()}}function K(e){let n=e??y??_;t(),q(),n&&d(`/integrations/${n}`)}function q(){g(`picker`),v(null),b(null),ie(`manual`),C(null),E(``),k(null),j(null),M(!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[p]}),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(O,{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($)}),p===`picker`&&n(i,{children:[ae&&s(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:ae}),s(L,{onSelect:H,onClose:J,pendingAddonId:Q})]}),p===`config`&&_&&s(ne,{addonId:_,configSchema:ce??null,canTest:oe,onSave:W,onBack:()=>g(`picker`)}),p===`broker`&&x&&s(re,{kind:x,onResolved:e=>{G(e)},onBack:()=>g(`picker`)}),p===`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(S,{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?T:C,{className:`h-3.5 w-3.5`})}),s(y,{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=w(),c=l(),[u]=D(),[m,h]=o(!1),g=e(()=>h(!0),[]),ee=e(()=>h(!1),[]),[ne,re]=o(!1),S=e(()=>re(!0),[]),C=e(()=>re(!1),[]);M([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),M([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:T,isLoading:E,refetch:O}=v(void 0),{data:k,isLoading:j,refetch:N}=f({}),P=r(()=>k??[],[k]),F=r(()=>T??[],[T]),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 d(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(y,{type:e,size:`sm`}),[]),G=e(e=>a(`/devices/${String(e)}`),[a]),ue=e(e=>s(p,{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(()=>{O(),N()},[O,N]),Z=E||j,Q=F.length>0;return n(oe,{icon:ae,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(x,{className:_(`h-3.5 w-3.5`,Z&&`animate-spin`)})}),n(`button`,{onClick:S,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:g,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(b,{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(p,{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:m,onClose:ee}),s(ie,{open:ne,onClose:C})]})}export{H as IntegrationsPage};
|
|
@@ -1 +0,0 @@
|
|
|
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{Z as s}from"./player-overlays-DXNKqmwI.js";import{ar as c,cr as l,hr as u,lr as d,nr as f,or as p,rr as m,sr as h,un as g,ur as _,w as v,wn as y}from"./src-C0QlPpXb.js";import{J as b,Q as x,k as S}from"./src-DAigq6PX.js";import{t as C}from"./pencil-dvZNet31.js";import{t as w}from"./plus-CDo9Tbkz.js";import{t as T}from"./radio-CUBDyXa0.js";import{t as E}from"./wifi-DNsDHc6u.js";import{C as D,J as O,K as k,i as ee,s as A,v as j}from"./index-DhYfPTfU.js";import{t as M}from"./AdminPage-CCD07UMs.js";import{t as N}from"./AdminTabs-D6yDsobg.js";import{t as P}from"./BrokerForm-DnKqFWQy.js";import{t as F}from"./useBodyScrollLock-BDocajQE.js";import{t as I}from"./AddonCollectionPage-D86qUT-8.js";var L=k(`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`}]]),R=k(`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 z={"home-assistant":`Home Assistant`,mqtt:`MQTT`};function B(e){return z[e]??e}function V(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}var H={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 U({status:e}){return o(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${H[e]}`,children:e})}function W(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function G({title:e,subtitle:n,onClose:r,children:i}){return F(),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(ee,{className:`h-4 w-4`})})]}),o(`div`,{className:`p-4 max-h-[70vh] overflow-y-auto overscroll-contain`,children:i})]})})}function K({kinds:e,onClose:n,onDone:s}){let c=i(),l=e=>`${e.addonId??``}::${e.kind}`,[u,d]=a(e[0]?l(e[0]):``),[p,m]=a(``),[h,g]=a(!1),[_,v]=a(``),y=e.find(e=>l(e)===u)??e[0],b=y?.kind??``,x=y?.addonId,S=f({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(G,{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:u,onChange:e=>d(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:l(e),children:e.label},l(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(P,{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 q({broker:e,onClose:r,onDone:a}){let s=i(),c=m({id:e.id,addonId:e.addonId}),l=d({onSuccess:()=>{s.invalidateQueries({queryKey:[[`broker`,`list`]]}),s.invalidateQueries({queryKey:[[`broker`,`getSettings`],{input:{id:e.id,addonId:e.addonId}}]}),a()}}),u=n(()=>{let e=c.data;return e&&typeof e==`object`?{...e}:{}},[c.data]);return o(G,{title:`Edit ${e.name}`,subtitle:`${B(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(D,{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(P,{kind:e.kind,addonId:e.addonId,initialValues:u,onSubmit:t=>{l.mutate({id:e.id,settings:t,addonId:e.addonId})},onCancel:r,submitLabel:l.isPending?`Saving…`:`Save`,disabled:l.isPending})]})})}function J({broker:e,onEdit:n}){let r=i(),s=g(),[c,u]=a(null),d=_({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=l({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:B(e.kind)}),t(`td`,{className:`px-3 py-2`,children:[o(U,{status:e.status}),c&&o(`span`,{className:`ml-2 text-[10px] ${c.ok?`text-success`:`text-danger`}`,children:c.ok?`OK`:c.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(D,{className:`h-3 w-3 animate-spin`}):o(E,{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(C,{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(D,{className:`h-3 w-3 animate-spin`}):o(A,{className:`h-3 w-3`}),`Delete`]})]})})]})}function Y(){let e=p({}),r=h(),i=n(()=>W(e.data),[e.data]),[s,c]=a(!1),[l,u]=a(null),d=n(()=>{let e=new Map;for(let t of V(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:B(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:d.length===0,title:d.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(w,{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(D,{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(J,{broker:e,onEdit:u},e.id))]})]})}),s&&o(K,{kinds:d,onClose:()=>c(!1),onDone:()=>c(!1)}),l&&o(q,{broker:l,onClose:()=>u(null),onDone:()=>u(null)})]})}var X=[{kind:`device-export`,tabId:`device-export`,title:`Device export`,subtitle:`Outbound exporters that publish CamStack devices to other ecosystems (HomeAssistant, HomeKit, Alexa, …).`,icon:R,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:L,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:T,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 Z(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 Q(e){let t=e,n=t?.manifest;if(!n?.id)return null;let r=[];for(let e of n.capabilities??[]){let t=Z(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 te(e,t){let n=new Set(t);return e.filter(e=>e.capNames.some(e=>n.has(e)))}function ne(e){for(let[t,n]of Object.entries(S))if(n===e)return t;return null}function re(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 ie({addonId:e}){let{data:t,isLoading:n}=c({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 ae({addonId:e}){let{data:t,isLoading:n}=u({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 oe({kind:e,addonId:t}){return e===`broker`?o(ie,{addonId:t}):e===`device-export`?o(ae,{addonId:t}):null}function se({descriptor:e,rows:n,isLoading:i}){let a=ne(e.kind),c=e.kind===`device-export`,l=s(),u=O();return o(I,{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=re(n.processState);return t(r,{children:[o($,{label:i.label,className:i.className}),o(oe,{kind:e.kind,addonId:n.addonId})]})},renderExpandedPanel:c?e=>o(v,{addonId:e.addonId,trpc:l.trpcClient,onOpenDevice:e=>u(`/devices/${e}`)}):void 0,showChrome:!0})}function ce(){let e=y(void 0,{refetchInterval:1e4}),t=(e.data??[]).map(Q).filter(e=>e!==null);return o(M,{icon:j,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(N,{tabs:X.map(n=>{let r=Object.entries(S).filter(([,e])=>e===n.kind).map(([e])=>e),i=n.kind===`broker`?o(Y,{}):o(se,{descriptor:n,rows:te(t,r),isLoading:e.isLoading});return{id:n.tabId,label:n.title,icon:n.icon,content:i}})})})}export{ce as IntegrationsPage};
|
|
@@ -1 +0,0 @@
|
|
|
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{Z as l}from"./player-overlays-DXNKqmwI.js";import{Ai as u,Bi as d,Di as f,Ei as p,Fi as m,Ii as h,It as g,Lt as _,Mi as v,Ni as y,Oi as b,Pi as x,Rt as S,Ti as C,Tn as w,Vi as T,Xt as E,ji as ee,ki as te,ls as D,tt as O,wn as k,zi as A}from"./src-C0QlPpXb.js";import{K as j,V as M}from"./src-DAigq6PX.js";import{t as N}from"./boxes-DVDxegRH.js";import{t as P}from"./copy-EKhXmX92.js";import{t as F}from"./play-D6bynunz.js";import{t as ne}from"./refresh-cw-CikJV4hg.js";import{t as re}from"./rotate-ccw-P5OXZofT.js";import{t as I}from"./server-CLphEdE1.js";import{t as L}from"./square-UC6vONGu.js";import{t as ie}from"./wifi-DNsDHc6u.js";import{C as R,E as z,K as B,S as ae,U as oe,i as se,j as V,l as ce,o as H,x as le,y as U,z as ue}from"./index-DhYfPTfU.js";import{t as de}from"./AdminPage-CCD07UMs.js";import{t as fe}from"./AdminTabs-D6yDsobg.js";import{t as W}from"./AddonCollectionPage-D86qUT-8.js";import{t as G}from"./addon-display-names-DvSEQty-.js";var pe=B(`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`}]]),me=B(`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`}]]),K=B(`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 q=5e3,he={connected:!1,endpoint:null};function ge(){let e=a(),t=w({capName:`network-access`},{refetchInterval:q}),n=k(void 0,{refetchInterval:q}),i=r(()=>G(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),[f,p]=o({}),m=(t,n)=>{let r=n?.addonId;e.invalidateQueries({queryKey:[[`networkAccess`,`getStatus`],{input:{addonId:r},type:`query`}]}),u(null),p(e=>{if(r===void 0||!(r in e))return e;let t={...e};return delete t[r],t})},h=(e,t)=>{u(null);let n=t?.addonId;if(n===void 0)return;let r=e instanceof Error?e.message:String(e);p(e=>({...e,[n]:r}))},g=d({onSuccess:m,onError:h}),_=T({onSuccess:m,onError:h});return s(W,{title:`Remote Access`,subtitle:`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …). Settings, Logs and Events are docked under every provider.`,pageIcon:z,itemIcon:z,capability:`network-access`,installButtonLabel:`Add tunnel`,items: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(_e,{addonId:e.addonId}),itemError:e=>f[e.addonId]??null,renderPrimaryAction:e=>s(ve,{addonId:e.addonId,busyId:l,onStart:e=>{u(e),g.mutate({addonId:e})},onStop:e=>{u(e),_.mutate({addonId:e})}})})}function J(e){let{data:t}=A({addonId:e},{refetchInterval:q,retry:!1}),n=t?j.safeParse(t):null;return n?.success?n.data:he}function _e({addonId:e}){let t=J(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(V,{className:`h-3 w-3`}),t.endpoint.url]})]})}function ve({addonId:e,busyId:t,onStart:r,onStop:i}){let a=J(e),o=t===e;return a.connected?n(S,{size:`sm`,variant:`secondary`,disabled:o,onClick:()=>i(e),children:[o?s(R,{className:`h-3 w-3 animate-spin`}):s(L,{className:`h-3 w-3`}),`Stop`]}):n(S,{size:`sm`,variant:`primary`,disabled:o,onClick:()=>r(e),children:[o?s(R,{className:`h-3 w-3 animate-spin`}):s(F,{className:`h-3 w-3`}),`Start`]})}t();var Y=3e4;function ye(e){let t=[];for(let n of e)typeof n.urls==`string`?t.push(n.urls):t.push(...n.urls);return t}function be(){let e=w({capName:`turn-provider`},{refetchInterval:Y}),t=k(void 0,{refetchInterval:Y}),i=D(),a=i.data??[],o=r(()=>G(t.data??[]),[t.data]);return s(W,{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:U,itemIcon:U,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(xe,{addonId:e.addonId,enabled:e.isActive}),trailing:n(g,{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(S,{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 xe({addonId:e,enabled:t}){let i=D({addonId:e},{enabled:t,retry:!1}),a=r(()=>ye(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 Se={lan:U,wifi:ie,docker:N,vpn:ae,loopback:I,other:I},Ce={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},we=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function Te(e){let{interfaces:t,disabled: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 we.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(Se[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:Ce[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(ue,{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(H,{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 X={"lan-ipv4":`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`,"lan-ipv6":`bg-violet-500/15 text-violet-700 dark:text-violet-300`,public:`bg-blue-500/15 text-blue-700 dark:text-blue-300`,loopback:`bg-foreground-subtle/15 text-foreground-subtle`};function Ee(){let e=a(),t=l(),i=b(void 0,{refetchInterval:3e4}),d=C(void 0),m=u({onSuccess:()=>{e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),h=te({onSuccess:t=>{x(t.addresses),e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),_=r(()=>i.data?.interfaces??[],[i.data]),v=p({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}),[y,x]=o([]),[w,T]=o(!1);c(()=>{!w&&d.data&&(x(d.data.addresses),T(!0))},[d.data,w]);let E=d.data?.addresses??[],D=r(()=>{if(y.length!==E.length)return!0;let e=[...y].toSorted(),t=[...E].toSorted();return e.some((e,n)=>e!==t[n])},[y,E]),O=()=>{m.mutate({addresses:[...y]})},k=()=>{x(E)},A=()=>{x([])},j=()=>{i.refetch(),v.refetch(),d.refetch()},M=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)}},N=f(),P=ee({onSuccess:()=>void N.refetch()}),F=v.data?.endpoints??[],I=N.data?.baseUrl??null,L=N.data?.resolved??null;return n(de,{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:`Pick the local addresses SDK clients should race for the fastest path to this hub. Empty selection (auto) lets every non-loopback / non-link-local interface participate.`}),n(`div`,{className:`flex items-center gap-2 shrink-0`,children:[n(S,{size:`sm`,variant:`secondary`,onClick:j,disabled:i.isLoading,children:[s(ne,{className:`h-3 w-3 ${i.isLoading?`animate-spin`:``}`}),`Refresh`]}),s(S,{size:`sm`,variant:`secondary`,onClick:M,children:`Probe race`})]})]}),n(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[n(g,{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:`Allowed addresses`}),s(`div`,{className:`text-xs text-foreground-subtle`,children:y.length===0?`Auto — every non-loopback / non-link-local interface participates.`:`${y.length} pinned`})]}),n(`div`,{className:`flex items-center gap-1`,children:[n(S,{size:`sm`,variant:`secondary`,onClick:()=>h.mutate(void 0),disabled:h.isPending||m.isPending,title:`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`,children:[s(ce,{className:`h-3 w-3`}),h.isPending?`Detecting…`:`Best match`]}),n(S,{size:`sm`,variant:`secondary`,onClick:A,disabled:y.length===0||m.isPending,children:[s(re,{className:`h-3 w-3`}),`Clear`]}),D&&s(S,{size:`sm`,variant:`secondary`,onClick:k,disabled:m.isPending,children:`Discard`}),n(S,{size:`sm`,variant:`primary`,onClick:O,disabled:!D||m.isPending,children:[s(me,{className:`h-3 w-3`}),m.isPending?`Saving…`:`Save`]})]})]}),s(`div`,{className:`p-4`,children:s(Te,{mode:`multiple`,interfaces:_,value:y,onChange:x,disabled:m.isPending,emptyMessage:i.isLoading?`Loading interfaces…`:`No interfaces detected.`})})]}),n(g,{children:[n(`div`,{className:`px-4 py-3 border-b border-border`,children:[s(`div`,{className:`text-sm font-semibold`,children:`Connection endpoints — priority order`}),s(`div`,{className:`text-xs text-foreground-subtle`,children:`Live preview of the ranked candidate list the SDK would race against. Updates with each Save.`}),n(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-2 text-xs`,children:[s(`span`,{className:`text-foreground-subtle`,children:`Notification links use:`}),s(`span`,{className:`font-mono text-foreground`,children:I??`${L??`nothing reachable`} (auto)`}),I!==null&&s(`button`,{type:`button`,disabled:P.isPending,onClick:()=>P.mutate({baseUrl:null}),className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:`reset to auto`})]}),I===null&&L===null&&s(`p`,{className:`mt-1 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(`div`,{className:`p-4`,children:F.length===0?s(`div`,{className:`text-xs text-foreground-subtle italic`,children:v.isLoading?`Loading…`:`No endpoints available.`}):s(`ul`,{className:`space-y-1 text-xs`,children:F.map(e=>n(`li`,{className:`flex items-center gap-2 flex-wrap ${e.plausible?``:`opacity-80`}`,children:[s(`span`,{className:`font-mono text-[10px] w-10 text-foreground-subtle`,children:String(e.priority).padStart(4,`0`)}),s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${X[e.kind]??X.loopback}`,children:e.kind}),e.interfaceKind!==`lan`&&e.interfaceKind!==`public`&&s(`span`,{className:`text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-medium uppercase`,children:e.interfaceKind}),!e.plausible&&e.interfaceKind!==`loopback`&&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:e.plausibleReason||void 0,children:[s(H,{className:`h-2.5 w-2.5`}),`Unlikely usable`]}),s(`span`,{className:`font-mono break-all ${e.plausible?`text-foreground`:`text-foreground-subtle`}`,children:e.baseUrl}),n(`span`,{className:`text-foreground-subtle`,children:[`— `,e.label]}),e.kind===`loopback`?null:I===e.baseUrl?n(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-primary/15 px-2 py-0.5 text-[10px] font-medium text-primary`,children:[s(oe,{className:`h-2.5 w-2.5`}),` notifications`]}):s(`button`,{type:`button`,disabled:P.isPending,onClick:()=>P.mutate({baseUrl:e.baseUrl}),className:`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:`use for notifications`})]},`${e.priority}-${e.baseUrl}`))})})]})]})]})}t();var De={mesh:`bg-violet-500/15 text-violet-700 dark:text-violet-300`,public:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},Z=5e3,Oe=3e4,ke={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function Ae(){let e=w({capName:`mesh-network`},{refetchInterval:Z}),t=k(void 0,{refetchInterval:Z}),n=r(()=>G(t.data??[]),[t.data]);return s(W,{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:U,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(je,{addonId:e.addonId}),renderPrimaryAction:e=>s(Me,{addonId:e.addonId}),renderExpandedPanel:e=>s(Ne,{addonId:e.addonId})})}function Q(e){let{data:t,isLoading:n}=v({addonId:e},{refetchInterval:Z,retry:!1}),r=t?M.safeParse(t):null;return{status:r?.success?r.data:ke,isLoading:n}}function je({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 Me({addonId:t}){let r=a(),[c,u]=o(!1),[d,f]=o(null),p=l(),{status:g}=Q(t),_=e(()=>{r.invalidateQueries({queryKey:[[`meshNetwork`]]})},[r]),v=h(),b=y({onSuccess:_}),x=m({onSuccess:_}),C=e(async()=>{u(!0);let e={cancelled:!1};f(e);try{let n=await v.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){_();break}if(Date.now()-r>6e5)break}}finally{u(!1),f(null)}},[t,_,v,p]),w=e(()=>{d&&(d.cancelled=!0),u(!1),f(null)},[d]);return s(i,{children:g.joined?n(i,{children:[n(S,{size:`sm`,variant:`secondary`,disabled:b.isPending,onClick:()=>b.mutate({addonId:t}),children:[b.isPending?s(R,{className:`h-3 w-3 animate-spin`}):s(le,{className:`h-3 w-3`}),`Disconnect`]}),n(S,{size:`sm`,variant:`ghost`,disabled:x.isPending,onClick:()=>x.mutate({addonId:t}),children:[x.isPending?s(R,{className:`h-3 w-3 animate-spin`}):s(K,{className:`h-3 w-3`}),`Log out`]})]}):c?n(S,{size:`sm`,variant:`ghost`,onClick:w,children:[s(se,{className:`h-3 w-3 mr-1`}),` Cancel`]}):n(i,{children:[n(S,{size:`sm`,variant:`primary`,onClick:()=>void C(),children:[s(pe,{className:`h-3 w-3`}),`Connect`]}),n(S,{size:`sm`,variant:`ghost`,disabled:x.isPending,onClick:()=>x.mutate({addonId:t}),children:[x.isPending?s(R,{className:`h-3 w-3 animate-spin`}):s(K,{className:`h-3 w-3`}),`Log out`]})]})})}function Ne({addonId:e}){let{status:t}=Q(e),r=x({addonId:e},{refetchInterval:Oe,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(E,{message:t.error}),s(Pe,{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 ${De[e.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[e.scope===`public`?s(z,{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(V,{className:`h-3 w-3 shrink-0`}),e.url]})]},e.id))]})]}),s(`div`,{className:`border-t border-border`,children:s(Ie,{peers:r.data?.peers??[],loading:r.isLoading})})]})}function Pe({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?Fe(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 Fe(e){let t=e-Date.now();if(t<0)return`Expired ${$(e)}`;let n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return`in ${n} days`;let r=Math.floor(t/36e5);return r>1?`in ${r}h`:`in ${Math.max(1,Math.floor(t/6e4))} min`}function Ie({peers: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(_,{variant:`info`,children:`self`}),e.exitNodeOption&&s(_,{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(_,{variant:Le(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:[`↑ `,Re(e.txBytes),` · ↓ `,Re(e.rxBytes)]})},{key:`lastSeen`,header:`Last seen`,render:e=>s(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?$(e.lastSeenMs):`—`})}],[o]);return i&&t.length===0?n(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[s(R,{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(O,{columns:c,rows:a,rowKey:e=>e._id,minWidthPx:820})})}function Le(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function Re(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)}MB`:`${(e/1024/1024/1024).toFixed(2)}GB`}function $(e){let t=Date.now()-e;return t<6e4?`just now`:t<36e5?`${Math.round(t/6e4)}m ago`:t<864e5?`${Math.round(t/36e5)}h ago`:`${Math.round(t/864e5)}d ago`}function ze(e){return new Promise(t=>setTimeout(t,e))}function Be(){return s(`div`,{className:`flex flex-col p-4`,children:s(fe,{tabs:[{id:`addresses`,label:`Network Addresses`,icon:I,content:s(Ee,{})},{id:`remote-access`,label:`Remote Access`,icon:z,content:s(ge,{})},{id:`mesh`,label:`Mesh Networks`,icon:N,content:s(Ae,{})},{id:`turn`,label:`TURN Servers`,icon:U,content:s(be,{})}]})})}export{Be as NetworkPage};
|