@camstack/addon-admin-ui 1.2.441 → 1.2.443
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/{AddonAssetIcon-CCzVCA49.js → AddonAssetIcon-BZ3nAoxI.js} +1 -1
- package/dist/assets/Addons-BGWXApJO.js +4 -0
- package/dist/assets/{AdminPage--m3xHpjx.js → AdminPage-BrNVYSyo.js} +1 -1
- package/dist/assets/{AdminSectionedPage-D5J86Kfp.js → AdminSectionedPage-Dh0h99mU.js} +1 -1
- package/dist/assets/AiProfiles-LVK8z9CZ.js +3 -0
- package/dist/assets/{BrokerForm-Cd5z8Mk0.js → BrokerForm-Ccq1Ih2O.js} +1 -1
- package/dist/assets/Build-C_Zu-Je3.js +40 -0
- package/dist/assets/{Calendars-CVnE0N6y.js → Calendars-1uP96v-V.js} +1 -1
- package/dist/assets/Cluster-BnmZh2Nn.js +1 -0
- package/dist/assets/ClusterStepModel-B6c_UMsA.js +1 -0
- package/dist/assets/CompositionEditor-joJfcrqc.js +1 -0
- package/dist/assets/{CompositionEditorPage-D3LiFLq4.js → CompositionEditorPage-y89GyEA5.js} +1 -1
- package/dist/assets/Data-DX8kzB-3.js +2 -0
- package/dist/assets/{DeviceDetail-Ry7b522t.js → DeviceDetail-B8U3Yepm.js} +2 -2
- package/dist/assets/{DeviceDoActionFields-n2-NdVST.js → DeviceDoActionFields-q6xVAIAa.js} +1 -1
- package/dist/assets/{Devices-BacO9x6N.js → Devices-AoATGKWU.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-DgFNOUrt.js → EmbedPlayerPage-Du1J1yTM.js} +1 -1
- package/dist/assets/Identity-BOfwyXgX.js +1 -0
- package/dist/assets/IntegrationDetail-DCQjP8LU.js +1 -0
- package/dist/assets/IntegrationHub-B-RxXA9_.js +1 -0
- package/dist/assets/Integrations-CzTceJFE.js +1 -0
- package/dist/assets/Integrations-WPdqnrXU.js +1 -0
- package/dist/assets/{Library-yKp-qGfV.js → Library-B67zZRsd.js} +1 -1
- package/dist/assets/Locations-HaHa_Fsr.js +3 -0
- package/dist/assets/{Logs-DWz6dVJo.js → Logs-D5P4nUT8.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-wkrQJhyN.js → MaskShapeCanvas-DImE8rL3.js} +1 -1
- package/dist/assets/{MotionZonesSettings-BZneggiu.js → MotionZonesSettings-0CuyxGPc.js} +1 -1
- package/dist/assets/MyAccess-CvUaUk6O.js +2 -0
- package/dist/assets/Network-Cn22Onk0.js +1 -0
- package/dist/assets/{NodeAddonsSettingsPanel-BxeQZ-hu.js → NodeAddonsSettingsPanel-D2a6eJdl.js} +1 -1
- package/dist/assets/Notifications-DDmcZBvb.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-CN2hF3qR.js → PrivacyMaskSettings-iuZ15_7K.js} +1 -1
- package/dist/assets/Recordings-DDufOAKc.js +1 -0
- package/dist/assets/{ScanNetworkModal-CfHHLP_k.js → ScanNetworkModal-DMI4Puj8.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-CU-Yj4Sw.js → SceneMonitorEditor-BeQX-lOK.js} +1 -1
- package/dist/assets/SessionsList-DJQsiJpZ.js +2 -0
- package/dist/assets/{Showroom-ChGRG_dB.js → Showroom-yw0GMHMG.js} +1 -1
- package/dist/assets/{System-GfppoElu.js → System-CiRePLgR.js} +1 -1
- package/dist/assets/{Terminal-C7azorOj.js → Terminal-BISFdyS_.js} +3 -3
- package/dist/assets/{Viewer-DWdf6_8H.js → Viewer-C9JIf56u.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CGI8Rmb1.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-PnsnCmkC.js} +1 -1
- package/dist/assets/{addon-icons-context-D3LZwxs2.js → addon-icons-context-Ci899mcp.js} +1 -1
- package/dist/assets/{archive-BOODG6Jz.js → archive-LCkF1dZb.js} +1 -1
- package/dist/assets/{authed-media-F_SweyTm.js → authed-media-D_mDMacH.js} +1 -1
- package/dist/assets/{bell-off-acWBqVHX.js → bell-off-GaaNTQY2.js} +1 -1
- package/dist/assets/{board-model-Bdetmchn.js → board-model-D4eidiUD.js} +1 -1
- package/dist/assets/{boxes-U2BARjlG.js → boxes-C5tX31nL.js} +1 -1
- package/dist/assets/circle-slash-DB409D2V.js +1 -0
- package/dist/assets/client-C7PU3uqv.js +358 -0
- package/dist/assets/{cloud-upload-C12rtBFh.js → cloud-upload-VkAtqPMg.js} +1 -1
- package/dist/assets/crop-CpbGKQ8Q.js +1 -0
- package/dist/assets/{device-integration-icon-BeeizbXV.js → device-integration-icon-DQ-h2aqY.js} +1 -1
- package/dist/assets/device-picker-model-BtWCNPPD.js +1 -0
- package/dist/assets/dist-D10PjgBb.js +358 -0
- package/dist/assets/{dist-CQud2KJs.js → dist-D8lgrNhR.js} +1 -1
- package/dist/assets/{eraser-BmJjK2wc.js → eraser-fzzWtRJk.js} +1 -1
- package/dist/assets/{hard-drive-download-DfnBSa39.js → hard-drive-download-BoCYHTOr.js} +1 -1
- package/dist/assets/{history-CNfarVY1.js → history-CRzL5JIS.js} +1 -1
- package/dist/assets/{hostInit-Df4MAORd.js → hostInit-Cez0g2jV.js} +1 -1
- package/dist/assets/i18n-DPnbeqSW.js +1 -0
- package/dist/assets/{icons-BLn-D-gO.js → icons-C1hjXP2s.js} +1 -1
- package/dist/assets/{index-CcAR8Rlk.js → index-P4Ykaww9.js} +3 -3
- package/dist/assets/{key-BF4fZLz_.js → key-B8BAPcXc.js} +1 -1
- package/dist/assets/{key-round-CjE9GF4T.js → key-round-BJ8BVDGZ.js} +1 -1
- package/dist/assets/{layers-b-H6nVdd.js → layers-CD_tu1Pc.js} +1 -1
- package/dist/assets/{linked-devices-model-BMUapBfD.js → linked-devices-model-BpLdQSS2.js} +1 -1
- package/dist/assets/{list-ordered-CxtL1h3H.js → list-ordered-CV8Mey9J.js} +1 -1
- package/dist/assets/{location-owned-usage-DVh3ypCw.js → location-owned-usage-BWKIfwEv.js} +1 -1
- package/dist/assets/{log-in-D4y0eEu8.js → log-in-CssruFII.js} +1 -1
- package/dist/assets/{memory-stick-jw7STOQc.js → memory-stick-CGxsa350.js} +1 -1
- package/dist/assets/{message-square-plus-EaPlmlsM.js → message-square-plus-CBy6WJpr.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-8a2679ae.js → mf-entry-bootstrap-0-c381d6e5.js} +2 -2
- package/dist/assets/{mic-off-DiEVWn3e.js → mic-off-DZ1gYAW7.js} +1 -1
- package/dist/assets/{monitor-off-bCAhCbCp.js → monitor-off-CLe0AluZ.js} +1 -1
- package/dist/assets/{monitor-smartphone-ASdELIYw.js → monitor-smartphone-ClAfVDzo.js} +1 -1
- package/dist/assets/mount-BtWCNPPD.js +1 -0
- package/dist/assets/notification-schedule-field-DZeBBmOz.js +1 -0
- package/dist/assets/{player-overlays-Fx6RE6kI.js → player-overlays-HaJLnfsi.js} +1 -1
- package/dist/assets/{recycle-twm2_92b.js → recycle-zmChefCS.js} +1 -1
- package/dist/assets/remoteEntry-m6BFtz9i.js +1 -0
- package/dist/assets/{scan-eye-DuyDP-FQ.js → scan-eye-CMTwtxZj.js} +1 -1
- package/dist/assets/{scissors-BJ2tjgEs.js → scissors-BlRdwWP1.js} +1 -1
- package/dist/assets/{search-x-C9z-zNBZ.js → search-x-CbwcvDCN.js} +1 -1
- package/dist/assets/{send-C_-A97md.js → send-6r6Ib9OA.js} +1 -1
- package/dist/assets/{settings-2-A0nya3CH.js → settings-2-BcvvKclK.js} +1 -1
- package/dist/assets/{speaker-C8juqhRE.js → speaker-CMJy4ydK.js} +1 -1
- package/dist/assets/src-DVZ_yCN-.js +67 -0
- package/dist/assets/{timer-reset-DHBRudwU.js → timer-reset-BdRlRB62.js} +1 -1
- package/dist/assets/{ungroup-BLEMoVnk.js → ungroup-BpleWEEi.js} +1 -1
- package/dist/assets/{unlink-YiKNaJO_.js → unlink-DKyXFXyJ.js} +1 -1
- package/dist/assets/{usb-DzR5JdOt.js → usb-6pnA3ol4.js} +1 -1
- package/dist/assets/{use-scenes-feed-wz6RYR34.js → use-scenes-feed-DaSpiEjT.js} +1 -1
- package/dist/assets/{use-stationary-objects-ByxBafUy.js → use-stationary-objects-CMuPPZiU.js} +1 -1
- package/dist/assets/useEventInvalidation-BtWCNPPD.js +1 -0
- package/dist/assets/{useNodeUrlSelection-v_RZ_Gxk.js → useNodeUrlSelection-DKMh9oxh.js} +1 -1
- package/dist/assets/user-round-DvLwlL_U.js +1 -0
- package/dist/assets/{user-x-CY41cwk1.js → user-x-BRy73Tug.js} +1 -1
- package/dist/assets/{video-BRgeujOO.js → video-C_Glztyb.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BrkS3kK7.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Bwge-Brs.js} +2 -2
- package/dist/index.html +10 -10
- package/dist/server/addon.js +420 -125
- package/package.json +1 -1
- package/dist/assets/Addons-CUPFTOFz.js +0 -4
- package/dist/assets/AiProfiles-CEZqx-Sw.js +0 -3
- package/dist/assets/Build-RW9SjiCM.js +0 -40
- package/dist/assets/Cluster-DdgLAQcF.js +0 -1
- package/dist/assets/ClusterStepModel-BbVbEWqh.js +0 -1
- package/dist/assets/CompositionEditor-BDEQF7e9.js +0 -1
- package/dist/assets/Data-TI1fXQ8e.js +0 -2
- package/dist/assets/Identity-BPWd0o-B.js +0 -1
- package/dist/assets/IntegrationDetail-CFsboI2-.js +0 -1
- package/dist/assets/IntegrationHub-BRMnV56J.js +0 -1
- package/dist/assets/Integrations-Bf2SzcCT.js +0 -1
- package/dist/assets/Integrations-CBqnh8t8.js +0 -1
- package/dist/assets/Locations-BCY7diBp.js +0 -3
- package/dist/assets/MyAccess-DmuNu2nC.js +0 -2
- package/dist/assets/Network-CMlIm20D.js +0 -1
- package/dist/assets/Notifications-B0nD4977.js +0 -1
- package/dist/assets/Recordings-CkHyBhqh.js +0 -1
- package/dist/assets/SessionsList-DrSkZMrj.js +0 -2
- package/dist/assets/circle-slash-90QkMLx4.js +0 -1
- package/dist/assets/client-yfOXPkcm.js +0 -358
- package/dist/assets/crop-BjSJZpbg.js +0 -1
- package/dist/assets/device-picker-model-CRpYde_B.js +0 -1
- package/dist/assets/dist-BfR6seq4.js +0 -358
- package/dist/assets/i18n-B1bxeya5.js +0 -1
- package/dist/assets/mount-CRpYde_B.js +0 -1
- package/dist/assets/notification-schedule-field-BKROBLSv.js +0 -1
- package/dist/assets/remoteEntry-D-hdlf-C.js +0 -1
- package/dist/assets/src-AhVPNkCn.js +0 -67
- package/dist/assets/useEventInvalidation-CRpYde_B.js +0 -1
- package/dist/assets/user-round-CjXCVqIf.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,B as t,G as n,J as r,L as i,S as a,b as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{Cn as l,Ei as u,On as d,Si as f,bn as p,dt as m,fn as h,kn as g,or as _,ot as v,un as y,xi as b,yi as x}from"./player-overlays-Fx6RE6kI.js";import{Ji as ee,M as S,_a as C,at as te,do as w,gr as ne,lo as T,nt as E,nu as D,oa as O,oo as k,r as A,rt as re,uu as j}from"./src-AhVPNkCn.js";import{t as M}from"./i18n-B1bxeya5.js";import{t as N}from"./useTranslation-D3Is_4B6.js";import{Y as P,et as F,nt as I}from"./index-CcAR8Rlk.js";import{t as L}from"./AdminPage--m3xHpjx.js";import"./useEventInvalidation-CRpYde_B.js";import{t as R}from"./device-integration-icon-BeeizbXV.js";import{n as z,r as B,t as ie}from"./ScanNetworkModal-CfHHLP_k.js";e();function V(e=!0){t(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e])}e();function ae(e,n){let[i,a]=r(!1);return t(()=>{if(!e){a(!1);return}a(!1);let t=setTimeout(()=>a(!0),n);return()=>clearTimeout(t)},[e,n]),i}e();function H({providerId:e,onImport:n,onSkip:i}){let{t:o}=N(),[s,l]=r(new Set),d=O(),p=d.data,m=d.isPending||!d.data&&!d.isError;t(()=>{e&&(d.isPending||d.data||d.mutate({addonId:e}))},[e,d]);function h(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(m)return a(`div`,{className:`flex flex-col items-center py-12`,children:[c(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),c(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:o(`integrations.searchingDevices`)})]});let g=p??[];return a(`div`,{className:`space-y-4`,children:[c(`p`,{className:`text-xs text-foreground-subtle`,children:g.length>0?o(`integrations.foundDevices`,{count:g.length}):o(`integrations.noDevicesFound`)}),g.length>0&&c(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:g.map(e=>{let t=e.stableId,n=e.suggestedName??t,r=s.has(t),i=e.alreadyOnboarded===!0;return a(`button`,{onClick:()=>{i||h(t)},disabled:i,title:i?o(`integrations.alreadyAddedHint`,{defaultValue:`Already added as "{{name}}" — re-adding would overwrite its settings.`,name:e.onboardedName??n}):void 0,className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${i?`border-border bg-surface opacity-60 cursor-not-allowed`:r?`border-primary/40 bg-primary/5`:`border-border bg-surface hover:border-foreground-subtle/30`}`,children:[c(`div`,{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${r&&!i?`border-primary bg-primary`:`border-border`}`,children:r&&!i&&c(f,{className:`h-3 w-3 text-primary-foreground`})}),c(u,{className:`h-3.5 w-3.5 text-foreground-subtle flex-shrink-0`}),c(`span`,{className:`text-xs font-medium text-foreground truncate`,children:n}),i&&c(`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:o(`integrations.alreadyAdded`,{defaultValue:`Already added`})})]},t)})}),a(`div`,{className:`flex items-center justify-between pt-2`,children:[c(`button`,{onClick:i,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:o(`integrations.skip`)}),g.length>0&&a(`button`,{onClick:()=>n(Array.from(s)),disabled:s.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:[o(`integrations.importSelected`),` (`,s.size,`)`]})]})]})}e();function U({onSelect:e,onClose:t,pendingAddonId:i=null}){let{t:o}=N(),s=F(),[l,u]=r(``),{data:d,isLoading:f}=T(),p=n(()=>{let e=d??[],t=l.trim().toLowerCase();return t.length===0?e:e.filter(e=>`${e.name} ${e.description??``} ${e.addonId}`.toLowerCase().includes(t))},[d,l]);if(f)return c(`div`,{className:`grid grid-cols-2 gap-2 p-2`,children:[1,2,3,4].map(e=>c(`div`,{className:`h-24 rounded-lg bg-surface animate-pulse`},e))});let m=i!==null;return a(`div`,{className:`space-y-3`,"data-testid":`provider-picker`,children:[a(`div`,{className:`relative`,children:[c(h,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),c(D,{type:`search`,value:l,onChange:e=>u(e.target.value),placeholder:o(`integrations.searchProviders`,`Search integrations…`),className:`pl-8`,"data-testid":`provider-picker-search`,"aria-label":o(`integrations.searchProviders`,`Search integrations…`)})]}),c(`div`,{className:`grid grid-cols-2 gap-2`,children:p.map(n=>{let r=n.instanceMode===`unique`&&n.existingInstances.length>0,l=i===n.addonId,u=m;return a(`button`,{type:`button`,disabled:u,"data-testid":`provider-pick-${n.addonId}`,onClick:()=>{if(!u)if(r){let e=n.existingInstances[0].id;t(),s(`/integrations/${e}`)}else e(n.addonId,n.instanceMode,n.discoveryMode,n.name,n.kind,n.brokerKind,n.mode,n.canTest)},className:`flex flex-col items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-3 text-center text-xs hover:border-primary/50 hover:bg-surface-hover transition-colors disabled:opacity-60 disabled:cursor-not-allowed disabled:hover:border-border`,children:[n.iconUrl?c(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${n.color}15`},children:c(`img`,{src:n.iconUrl,alt:``,className:`h-5 w-5`})}):c(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${n.color}15`},children:c(`span`,{className:`text-sm`,style:{color:n.color},children:`◉`})}),c(`p`,{className:`w-full truncate text-xs font-semibold text-foreground`,children:n.name}),n.description?c(`p`,{className:`w-full line-clamp-2 text-[10px] text-foreground-subtle`,children:n.description}):null,l?c(_,{className:`h-4 w-4 animate-spin text-primary`}):r?a(`span`,{className:`flex items-center gap-1 text-[10px] font-medium text-foreground-subtle`,children:[c(y,{className:`h-3 w-3`}),o(`integrations.manage`)]}):null]},n.addonId)})}),p.length===0&&c(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:(d??[]).length===0?o(`integrations.noProviders`):o(`integrations.noProvidersMatch`,`No integrations match your search.`)})]})}e();function oe(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 W=2e4;function se({open:e,onClose:i}){let{t:l}=N(),u=F(),d=s(),[f,p]=r(`picker`),[h,g]=r(null),[v,y]=r(null),[b,x]=r(`manual`),[S,C]=r(null),[te,w]=r(``),[T,E]=r(null),[D,A]=r(null),[re,j]=r(!1),{data:M}=ne({addonId:h??``,nodeId:`hub`},{enabled:h!=null}),P=n(()=>M?oe(M):null,[M]),I=k({onSuccess:()=>d.invalidateQueries({queryKey:[[`integrations`]]})}),L=O(),R=L.data;t(()=>{f!==`discovery`||!v||!h||L.isPending||L.data||L.mutate({addonId:h})},[f,v,h,L]);let ie=ee({onSuccess:()=>d.invalidateQueries({queryKey:[[`deviceManager`]]})});function se(e,t,n,r,i,a,o,s){if(!I.isPending){if(g(e),j(s),x(n),w(r),A(null),o===`broker`){if(!a){A(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}C(a),p(`broker`);return}if(o===`account`){p(`config`);return}G(e,r)}}async function G(e,t){try{let n=await I.mutateAsync({addonId:e,name:t,settings:{}});i(),J(),u(`/integrations/${n.id}?add=1`)}catch{}}async function ce(e){if(h)try{let t=await I.mutateAsync({addonId:h,name:e.name,settings:e.config,secretKeys:[...e.secretKeys]});y(t.id),E(t.id),b===`auto`||b===`both`?p(`discovery`):q(t.id,{openAdd:!0})}catch{}}async function le(e){if(h)try{let t=await I.mutateAsync({addonId:h,name:te,settings:{brokerId:e}});E(t.id),y(t.id),q(t.id)}catch{}}async function K(e){if(h){for(let t of e){let e=R?.find(e=>e.stableId===t);e&&await ie.mutateAsync({addonId:h,candidate:e,...T===null?{}:{integrationId:T}})}q()}}function q(e,t){let n=e??v??h;i(),J(),n&&u(t?.openAdd===!0?`/integrations/${n}?add=1`:`/integrations/${n}`)}function J(){p(`picker`),g(null),y(null),x(`manual`),C(null),w(``),E(null),A(null),j(!1)}function Y(){i(),J()}V(e);let X=I.isPending,Z=ae(X,W);if(!e)return null;let ue={picker:l(`integrations.newIntegration`),config:l(`integrations.configureIntegration`),discovery:l(`integrations.importDevices`),broker:l(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},Q=X?h:null,$=I.error,de=X&&!Z;return a(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[c(`div`,{className:`absolute inset-0 bg-black/60`,onClick:de?void 0:Y}),a(`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:[a(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 flex-shrink-0`,children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:ue[f]}),c(`button`,{onClick:Y,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:c(m,{className:`h-4 w-4`})})]}),a(`div`,{className:`px-5 py-4 flex-1 overflow-y-auto overscroll-contain`,children:[$&&!X&&c(`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($)}),f===`picker`&&a(o,{children:[D&&c(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:D}),c(U,{onSelect:se,onClose:Y,pendingAddonId:Q})]}),f===`config`&&h&&c(z,{addonId:h,configSchema:P??null,canTest:re,onSave:ce,onBack:()=>p(`picker`)}),f===`broker`&&S&&c(B,{kind:S,onResolved:e=>{le(e)},onBack:()=>p(`picker`)}),f===`discovery`&&v&&c(H,{providerId:v,onImport:K,onSkip:q})]}),X&&a(`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:[c(_,{className:`h-6 w-6 animate-spin text-primary`}),c(`p`,{className:`text-xs font-medium text-foreground`,children:l(`integrations.creating`,{defaultValue:`Creating integration…`})}),!Z&&c(`p`,{className:`text-[10px] text-foreground-subtle`,children:l(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),Z&&a(o,{children:[c(`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.`})}),c(`button`,{onClick:Y,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 G({integration:e,expanded:t,onToggleExpand:n}){let{t:r}=N();return a(`div`,{className:`flex items-center gap-2.5`,children:[c(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),n(e.addonId)},"aria-label":t?r(`integrations.integrationColumns.collapse`,`Collapse`):r(`integrations.integrationColumns.expand`,`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:c(t?b:x,{className:`h-3.5 w-3.5`})}),c(P,{type:e.addonId,size:`sm`}),a(`div`,{className:`flex min-w-0 flex-col`,children:[c(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:e.name}),c(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:e.addonId})]})]})}function ce(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:M.t(`integrations.integrationColumns.integration`,`Integration`),headerClassName:`w-[55%]`,cell:e=>c(G,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:M.t(`integrations.integrationColumns.devices`,`Devices`),headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>M.t(`integrations.integrationColumns.deviceCount`,{count:e.deviceCount})},{key:`status`,header:M.t(`integrations.integrationColumns.status`,`Status`),headerClassName:`w-[15%]`,cell:e=>c(S,{status:e.status})}]}e();function le(e){if(!e.enabled)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var K=`expand`;function q(){let{t:e}=N(),t=F(),s=v(),[u]=I(),[f,m]=r(!1),h=i(()=>m(!0),[]),_=i(()=>m(!1),[]),[y,b]=r(!1),x=i(()=>b(!0),[]),ee=i(()=>b(!1),[]);A([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),A([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:S,isLoading:ne,refetch:T}=w(void 0),{data:D,isLoading:O,refetch:k}=C({projection:`slim`}),M=n(()=>D??[],[D]),P=n(()=>S??[],[S]),z=n(()=>{let e=new Map;for(let t of M)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[M]),B=n(()=>re(S),[S]),V=n(()=>{let e=new Map;for(let t of te(M)){let n=B(t);if(n.kind!==`resolved`)continue;let r=n.integration.id;e.set(r,(e.get(r)??0)+1)}return e},[M,B]),ae=n(()=>P.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:le(e),deviceCount:V.get(e.id)??0})),[P,V]),H=u.get(K),U=i(e=>{let t=new URLSearchParams(window.location.search);t.get(K)===e?t.delete(K):t.set(K,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`))},[]),oe=i(e=>t(`/integrations/${e.id}`),[t]),W=i(e=>z.get(e)??null,[z]),G=i(e=>t(`/devices/${String(e)}`),[t]),q=i(e=>c(E,{context:`integration-detail`,devices:M,trpc:s.trpcClient,integrationOf:B,forceIntegrationId:e.id,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:R,resolveParent:W,onNavigate:G}),[M,s.trpcClient,B,W,G]),J=i(e=>H===e.addonId,[H]),Y=n(()=>ce({isExpanded:J,onToggleExpand:U}),[J,U]),X=i(e=>`${e.name} ${e.addonId}`,[]),Z=i(e=>e.addonId,[]),ue=i(()=>{T(),k()},[T,k]),Q=ne||O,$=P.length>0;return a(L,{icon:d,title:e(`nav.integrations`,`Integrations`),actions:a(o,{children:[c(`button`,{onClick:ue,disabled:Q,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:e(`common.refresh`,`Refresh`),children:c(p,{className:j(`h-3.5 w-3.5`,Q&&`animate-spin`)})}),a(`button`,{onClick:x,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:e(`integrations.scanTheLocalNetworkFor`,`Scan the local network for devices`),children:[c(l,{className:`h-3.5 w-3.5`}),e(`integrations.scanNetwork`,`Scan network`)]}),a(`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:[c(g,{className:`h-3.5 w-3.5`}),e(`integrations.newIntegration`,`New Integration`)]})]}),children:[Q&&c(`div`,{className:`space-y-2`,children:[1,2,3].map(e=>c(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!Q&&!$&&a(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[c(`p`,{className:`text-sm`,children:e(`integrations.noIntegrationsConfigured`,`No integrations configured.`)}),c(`p`,{className:`text-xs mt-1`,children:e(`integrations.clickNewIntegrationToConnect`,`Click "New Integration" to connect cameras and devices.`)})]}),!Q&&$&&c(E,{mode:`generic`,items:ae,getKey:Z,getSearchText:X,columns:Y,onRowClick:oe,isExpanded:J,renderExpanded:q,searchPlaceholder:e(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:e(`integrations.empty`,{defaultValue:`No integrations found.`})}),c(se,{open:f,onClose:_}),c(ie,{open:y,onClose:ee})]})}export{q as IntegrationsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,B as t,G as n,J as r,L as i,S as a,a as o,b as s,o as c,q as l,t as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{Fn as f,It as p,On as m,ht as h,kn as g,ln as _,nr as v,or as y,ot as b,xn as x}from"./player-overlays-Fx6RE6kI.js";import{Ar as S,Pt as ee,cr as C}from"./client-yfOXPkcm.js";import{h as w,s as T}from"./video-BRgeujOO.js";import{t as E}from"./log-in-D4y0eEu8.js";import{t as D}from"./monitor-smartphone-ASdELIYw.js";import{t as te}from"./recycle-twm2_92b.js";import{$n as ne,Ac as O,An as k,Dn as A,Gt as re,Hn as j,I as M,Mn as N,Nn as ie,On as ae,Or as P,Sn as oe,Ui as F,V as se,Vn as ce,_i as I,bi as L,et as R,gi as le,kn as z,mi as B,pi as ue,sr as V,tt as H,vi as U,xi as W,yi as de,z as fe,zn as G}from"./src-AhVPNkCn.js";import{t as K}from"./i18n-B1bxeya5.js";import{t as q}from"./useTranslation-D3Is_4B6.js";import{T as J,et as pe,i as me,nt as he,y as Y,z as ge}from"./index-CcAR8Rlk.js";import{t as _e}from"./AdminSectionedPage-D5J86Kfp.js";import{t as ve}from"./NodeAddonsSettingsPanel-BxeQZ-hu.js";import{t as ye}from"./BrokerForm-Cd5z8Mk0.js";import{n as be,r as X,t as xe}from"./IntegrationHub-BRMnV56J.js";e();var Z=`kind`,Q=`name`,Se=`restore`,Ce=`restoreId`;function we(e){return{sections:[{id:`broker-identity`,title:K.t(`helpers.brokerIdentitySchema.title`),columns:1,fields:[{type:`select`,key:Z,label:K.t(`helpers.brokerIdentitySchema.kind`),options:e.map(e=>({value:e.key,label:e.label})),disabled:e.length<=1},{type:`text`,key:Q,label:K.t(`helpers.brokerIdentitySchema.name`),placeholder:K.t(`helpers.brokerIdentitySchema.namePlaceholder`),required:!0},{type:`boolean`,key:Se,label:K.t(`helpers.brokerIdentitySchema.restore`),description:K.t(`helpers.brokerIdentitySchema.restoreHint`)},{type:`text`,key:Ce,label:K.t(`helpers.brokerIdentitySchema.originalId`),placeholder:`ha_004`,required:!0,showWhen:{field:Se,equals:!0}}]}]}}function Te(e){let t=t=>{let n=e[t];return typeof n==`string`?n.trim():``},n=t(Z);if(n===``)return{ok:!1,problem:`Pick a kind.`};let r=t(Q);if(r===``)return{ok:!1,problem:`Enter a name before saving.`};if(e.restore!==!0)return{ok:!0,identity:{kindKey:n,name:r,restoreId:null}};let i=t(Ce);return i===``?{ok:!1,problem:`Enter the original id, or turn restore off to create a new broker.`}:{ok:!0,identity:{kindKey:n,name:r,restoreId:i}}}var Ee={"home-assistant":`Home Assistant`,mqtt:`MQTT`};function De(e){return Ee[e]??e}function Oe(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}var ke={connected:`success`,connecting:`warning`,disconnected:`default`,"auth-failed":`danger`,unreachable:`danger`,error:`danger`};function Ae({status:e}){return d(V,{variant:ke[e],className:`text-[10px]`,children:e})}function je(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function Me({title:e,subtitle:t,onClose:n,children:r}){return d(A,{open:!0,onOpenChange:e=>!e&&n(),children:a(z,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(N,{children:[d(ie,{children:e}),t&&d(k,{children:t})]}),d(ae,{className:`space-y-3 pr-1`,children:r})]})})}function Ne({kinds:e,onClose:t,onDone:i}){let{t:o}=q(),s=c(),l=n(()=>we(e.map(e=>({key:$(e),label:e.label}))),[e]),[u,f]=r(()=>({[Z]:$(e[0]),[Q]:``,[Se]:!1,[Ce]:``})),[p,m]=r(null),h=e.find(e=>$(e)===u.kind)??e[0],g=h?.kind??``,_=h?.addonId,v=h?.interactiveConnectPath,y=ue({onSuccess:e=>{s.invalidateQueries({queryKey:[[`broker`,`list`]]});let t=typeof e==`object`&&e&&typeof e.id==`string`?e.id:null;t!==null&&v!==void 0&&v.length>0&&Y(v,t,()=>{s.invalidateQueries({queryKey:[[`broker`,`list`]]})}),i()}}),b=e=>{let t=Te(u);if(!t.ok){m(t.problem);return}m(null);let{name:n,restoreId:r}=t.identity;y.mutate({kind:g,name:n,settings:e,...r===null?{}:{id:r},..._===void 0?{}:{addonId:_}})};return a(Me,{title:o(`brokers.brokerManager.addBroker`,`Add broker`),subtitle:o(`brokers.brokerManager.registerAMessageBrokerFor`,`Register a message broker for exporters and automations.`),onClose:y.isPending?()=>{}:t,children:[d(ge,{schema:l,values:u,onChange:f}),p!==null&&d(G,{message:p}),y.isError&&d(G,{message:y.error instanceof Error?y.error.message:String(y.error)}),g&&d(ye,{kind:g,..._===void 0?{}:{addonId:_},onSubmit:b,onCancel:t,submitLabel:y.isPending?o(`brokers.brokerManager.adding`,`Adding…`):o(`brokers.brokerManager.addBroker`,`Add broker`),disabled:y.isPending},$(h))]})}function $(e){return e===void 0?``:`${e.addonId??``}::${e.kind}`}function Pe({broker:e,onClose:t,onDone:r}){let{t:i}=q(),o=c(),s=B({id:e.id,addonId:e.addonId}),l=L({onSuccess:()=>{o.invalidateQueries({queryKey:[[`broker`,`list`]]}),o.invalidateQueries({queryKey:[[`broker`,`getSettings`],{input:{id:e.id,addonId:e.addonId}}]}),r()}}),u=n(()=>{let e=s.data;return e&&typeof e==`object`?{...e}:{}},[s.data]);return d(Me,{title:i(`brokers.brokerManager.edit`,`Edit {{name}}`,{name:e.name}),subtitle:`${De(e.kind)} · ${e.id}`,onClose:l.isPending?()=>{}:t,children:s.isLoading?a(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[d(y,{className:`h-3.5 w-3.5 animate-spin`}),` `,i(`brokers.brokerManager.loadingSettings`)]}):s.isError?a(`div`,{className:`space-y-3`,children:[d(G,{message:i(`brokers.brokerManager.loadSettingsFailed`,{message:s.error instanceof Error?s.error.message:i(`common.unknownError`)})}),d(`div`,{className:`flex justify-end`,children:d(j,{variant:`outline`,size:`sm`,onClick:t,children:i(`common.close`,`Close`)})})]}):a(`div`,{className:`space-y-3`,children:[l.isError&&d(G,{message:l.error instanceof Error?l.error.message:String(l.error)}),d(ye,{kind:e.kind,addonId:e.addonId,brokerId:e.id,initialValues:u,onSubmit:t=>{l.mutate({id:e.id,settings:t,addonId:e.addonId})},onCancel:t,submitLabel:l.isPending?i(`brokers.brokerManager.saving`,`Saving…`):i(`common.save`,`Save`),disabled:l.isPending})]})})}function Fe({broker:e,interactiveConnectPath:t,interactiveDisconnectPath:n,onEdit:i}){let{t:o}=q(),s=c(),l=ne(),[u,m]=r(null),g=W({onSuccess:e=>m(e.ok?{ok:!0}:{ok:!1,error:e.error}),onError:e=>m({ok:!1,error:e instanceof Error?e.message:String(e)})}),_=de({onSuccess:()=>{s.invalidateQueries({queryKey:[[`broker`,`list`]]})}}),v=async()=>{await l({title:o(`brokers.brokerManager.deleteBroker`,`Delete broker`),message:o(`brokers.brokerManager.deleteBrokerIntegrationsThatDepend`,`Delete broker "{{name}}"? Integrations that depend on it will stop working.`,{name:e.name}),confirmLabel:o(`common.delete`,`Delete`),variant:`danger`})&&_.mutate({id:e.id,addonId:e.addonId})},b=t!==void 0&&t.length>0&&e.status!==`connected`,x=n!==void 0&&n.length>0&&e.status===`connected`;return a(`tr`,{className:`border-b border-border last:border-0`,children:[d(`td`,{className:`px-3 py-2 text-xs text-foreground font-medium`,children:e.name}),d(`td`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:De(e.kind)}),a(`td`,{className:`px-3 py-2`,children:[d(Ae,{status:e.status}),u&&d(`span`,{className:`ml-2 text-[10px] ${u.ok?`text-success`:`text-danger`}`,children:u.ok?`OK`:u.error??o(`common.failedWord`)})]}),d(`td`,{className:`px-3 py-2`,children:a(`div`,{className:`flex items-center justify-end gap-1.5`,children:[b&&a(j,{variant:`primary`,size:`sm`,onClick:()=>{Y(t,e.id,()=>{s.invalidateQueries({queryKey:[[`broker`,`list`]]})})},title:o(`brokers.brokerManager.signInOpensAPopup`,`Sign in — opens a popup that closes when done`),children:[d(E,{className:`h-3 w-3`}),` `,o(`brokers.brokerManager.signIn`)]}),x&&a(j,{variant:`outline`,size:`sm`,onClick:()=>{Y(n,e.id,()=>{s.invalidateQueries({queryKey:[[`broker`,`list`]]})})},title:o(`brokers.brokerManager.signOutClearsTheLinked`,`Sign out — clears the linked Google account on this broker`),children:[d(T,{className:`h-3 w-3`}),` `,o(`brokers.brokerManager.signOut`)]}),a(j,{variant:`outline`,size:`sm`,onClick:()=>g.mutate({id:e.id,addonId:e.addonId}),disabled:g.isPending,title:o(`brokers.brokerManager.testConnection`,`Test connection`),children:[g.isPending?d(y,{className:`h-3 w-3 animate-spin`}):d(h,{className:`h-3 w-3`}),o(`brokers.brokerManager.test`,`Test`)]}),a(j,{variant:`outline`,size:`sm`,onClick:()=>i(e),title:o(`common.edit`,`Edit`),children:[d(f,{className:`h-3 w-3`}),` `,o(`common.edit`)]}),a(j,{variant:`outline`,size:`sm`,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>{v()},disabled:_.isPending,title:o(`common.delete`,`Delete`),children:[_.isPending?d(y,{className:`h-3 w-3 animate-spin`}):d(p,{className:`h-3 w-3`}),o(`common.delete`,`Delete`)]})]})})]})}function Ie({addonId:e}={}){let{t}=q(),i=I({}),o=U(),s=n(()=>je(i.data).filter(t=>e===void 0||t.addonId===e),[i.data,e]),[c,l]=r(!1),[u,f]=r(null),p=n(()=>{let t=new Map;for(let n of Oe(o.data))if(!(e!==void 0&&n.addonId!==e))for(let e of n.kinds){let r=typeof e.interactiveConnectPath==`string`&&e.interactiveConnectPath.length>0?e.interactiveConnectPath:void 0,i=typeof e.interactiveDisconnectPath==`string`&&e.interactiveDisconnectPath.length>0?e.interactiveDisconnectPath:void 0;t.set(`${n.addonId}::${e.kind}`,{addonId:n.addonId,kind:e.kind,label:e.label,...r===void 0?{}:{interactiveConnectPath:r},...i===void 0?{}:{interactiveDisconnectPath:i}})}for(let e of s)[...t.values()].some(t=>t.kind===e.kind)||t.set(`::${e.kind}`,{kind:e.kind,label:De(e.kind)});return[...t.values()]},[s,o.data,e]),m=n(()=>{let e=new Map;for(let t of p)e.has(t.kind)||e.set(t.kind,{...t.interactiveConnectPath===void 0?{}:{connect:t.interactiveConnectPath},...t.interactiveDisconnectPath===void 0?{}:{disconnect:t.interactiveDisconnectPath}});return e},[p]);return a(`div`,{className:`space-y-3`,children:[d(`div`,{className:`flex items-center justify-end`,children:a(j,{variant:`primary`,size:`sm`,onClick:()=>l(!0),disabled:p.length===0,title:p.length===0?t(`brokers.brokerManager.noBrokerProvidersAvailable`,`No broker providers available`):void 0,children:[d(g,{className:`h-3.5 w-3.5`}),` `,t(`brokers.brokerManager.addBroker`)]})}),d(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:a(`table`,{className:`w-full min-w-[36rem] border-collapse`,children:[d(`thead`,{children:a(`tr`,{className:`border-b border-border bg-background/50`,children:[d(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:t(`brokers.brokerManager.name`,`Name`)}),d(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:t(`brokers.brokerManager.kind`,`Kind`)}),d(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:t(`brokers.brokerManager.status`,`Status`)}),d(`th`,{className:`px-3 py-2 text-right text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:t(`brokers.brokerManager.actions`,`Actions`)})]})}),a(`tbody`,{children:[i.isLoading&&d(`tr`,{children:a(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:[d(y,{className:`inline h-4 w-4 animate-spin`}),` `,t(`brokers.brokerManager.loadingBrokers`)]})}),i.isError&&d(`tr`,{children:a(`td`,{colSpan:4,className:`px-3 py-4 text-center text-xs text-danger`,children:[t(`brokers.brokerManager.failedToLoadBrokers`,`Failed to load brokers:`),` `,i.error instanceof Error?i.error.message:t(`brokers.brokerManager.unknownError`,`Unknown error`)]})}),!i.isLoading&&!i.isError&&s.length===0&&d(`tr`,{children:d(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:t(`brokers.brokerManager.noBrokersRegisteredYetAdd`,`No brokers registered yet. Add one to publish device events for downstream automations.`)})}),s.map(e=>{let t=m.get(e.kind);return d(Fe,{broker:e,...t?.connect===void 0?{}:{interactiveConnectPath:t.connect},...t?.disconnect===void 0?{}:{interactiveDisconnectPath:t.disconnect},onEdit:f},e.id)})]})]})}),c&&d(Ne,{kinds:p,onClose:()=>l(!1),onDone:()=>l(!1)}),u&&d(Pe,{broker:u,onClose:()=>f(null),onDone:()=>f(null)})]})}e();function Le({addonId:e,fallback:t}){let n=O({});if(n.isPending)return d(`div`,{className:`flex justify-center py-8`,children:d(y,{className:`size-6 animate-spin text-muted-foreground`})});if(n.isError)return d(G,{message:`Could not load entry kinds`});let r=n.data.kinds.find(t=>t.owner===e&&t.kind===`brokers`);return r===void 0?t:d(Re,{addonId:e,kind:r})}function Re({addonId:e,kind:t}){let{t:r}=q(),i=c(),o=I({}),l=U(),u=n(()=>{let t=new Map;for(let n of je(o.data))n.addonId===e&&t.set(n.id,n);return t},[o.data,e]),f=n(()=>{let e=new Map;for(let t of Oe(l.data))for(let n of t.kinds){let r=n.interactiveConnectPath,i=n.interactiveDisconnectPath;e.set(`${t.addonId}::${n.kind}`,{...typeof r==`string`&&r.length>0?{connect:r}:{},...typeof i==`string`&&i.length>0?{disconnect:i}:{}})}return e},[l.data]),p=()=>{i.invalidateQueries({queryKey:[[`broker`]]}),i.invalidateQueries({queryKey:[[`recordEntries`]]})};return d(M,{kind:t,extraColumns:n(()=>[{key:`status`,header:r(`brokers.brokerManager.status`,`Status`),nowrap:!0,width:`w-px`,render:e=>{let t=u.get(e.id);return t===void 0?null:d(Ae,{status:t.status})}}],[u,r]),rowActions:e=>{let t=u.get(e.id);if(t===void 0)return null;let n=f.get(`${t.addonId}::${t.kind}`);if(n===void 0)return null;let i=t.status===`connected`;return a(s,{children:[n.connect!==void 0&&!i&&a(j,{variant:`primary`,size:`sm`,"aria-label":r(`brokers.brokerManager.signIn`),onClick:()=>Y(n.connect??``,t.id,p),title:r(`brokers.brokerManager.signInOpensAPopup`,`Sign in — opens a popup that closes when done`),children:[d(E,{className:`h-3 w-3`}),d(`span`,{className:`hidden sm:inline`,children:r(`brokers.brokerManager.signIn`)})]}),n.disconnect!==void 0&&i&&a(j,{variant:`outline`,size:`sm`,"aria-label":r(`brokers.brokerManager.signOut`),onClick:()=>Y(n.disconnect??``,t.id,p),title:r(`brokers.brokerManager.signOutClearsTheLinked`,`Sign out — clears the linked Google account on this broker`),children:[d(T,{className:`h-3 w-3`}),d(`span`,{className:`hidden sm:inline`,children:r(`brokers.brokerManager.signOut`)})]})]})},showUpdated:!1,minWidthPx:340})}function ze(e){if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e.name;if(typeof t==`string`)return t}return null}function Be(e){let t=e,n=t?.manifest;if(n?.id===void 0)return null;let r=(n.capabilities??[]).map(ze).filter(e=>e!==null);return{addonId:n.id,displayName:n.packageDisplayName??n.name??n.id,capNames:r,processState:t?.process?.state??null}}function Ve(e,t){return Object.entries(e).filter(([,e])=>e===t).map(([e])=>e)}function He(e,t){return t.find(t=>e.capNames.includes(t))??null}function Ue(e){switch(e){case`running`:return{state:`ok`,label:K.t(`helpers.connectivityModel.running`)};case`crashed`:case`failed`:return{state:`error`,label:e};case`stopped`:case`disabled`:return{state:`off`,label:K.t(`helpers.connectivityModel.stopped`)};default:return{state:`unknown`,label:e??K.t(`common.unknownWord`)}}}e();var We=[`wasteCollections`,`listSources`],Ge=[`wasteCollections`,`listCountries`];function Ke(e){return e instanceof Error?e.message:String(e)}function qe(e){return typeof e!=`object`||!e?!1:Array.isArray(Reflect.get(e,`sections`))}function Je(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e=Reflect.get(n,`id`),r=Reflect.get(n,`label`),i=Reflect.get(n,`module`);if(typeof e!=`string`||typeof r!=`string`||typeof i!=`string`)continue;let a=Reflect.get(n,`enabled`),o=Reflect.get(n,`formValues`),s=Reflect.get(n,`serviceId`),c=Reflect.get(n,`countryId`);t.push({id:e,label:r,module:i,enabled:typeof a==`boolean`?a:!0,formValues:typeof o==`object`&&o&&!Array.isArray(o)?o:void 0,serviceId:typeof s==`string`?s:void 0,countryId:typeof c==`string`?c:void 0})}return t}function Ye(e){return Array.isArray(e)?e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=Reflect.get(e,`id`),n=Reflect.get(e,`label`);return typeof t!=`string`||typeof n!=`string`?[]:[{id:t,label:n}]}):[]}function Xe(e){return Array.isArray(e)?e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=Reflect.get(e,`id`),n=Reflect.get(e,`label`),r=Reflect.get(e,`module`);if(typeof t!=`string`||typeof n!=`string`||typeof r!=`string`)return[];let i=Reflect.get(e,`title`);return[{id:t,label:n,title:typeof i==`string`&&i.length>0?i:n,module:r}]}):[]}function Ze(e,t,n){return{sections:[{id:`picker`,title:K.t(`system.wasteSettingsSources.countryService`,`Country & service`),columns:2,fields:[{type:`select`,key:`countryId`,label:K.t(`system.wasteSettingsSources.country`,`Country`),options:[{value:``,label:K.t(`system.wasteSettingsSources.selectCountry`,`Select country…`)},...e.map(e=>({value:e.id,label:e.label}))]},{type:`select`,key:`serviceId`,label:K.t(`system.wasteSettingsSources.service`,`Service`),options:[{value:``,label:n===``?K.t(`system.wasteSettingsSources.pickACountryFirst`,`Pick a country first`):K.t(`system.wasteSettingsSources.selectService`,`Select service…`)},...t.map(e=>({value:e.id,label:e.label}))]}]}]}}function Qe({addonId:e,capName:f}){let{t:m}=q(),h=b(),_=c(),v=ne(),y=fe({editKey:`wasteEdit`,newKey:`wasteNew`}),[x,S]=r(!1),[ee,C]=r(null),[w,T]=r({countryId:``,serviceId:``}),[E,D]=r({label:m(`system.wasteSettingsSources.newSource`,`New source`),enabled:!0}),O=l(null),k=typeof w.countryId==`string`?w.countryId:``,A=typeof w.serviceId==`string`?w.serviceId:``,M=i((t,n)=>h.trpcClient.addons.custom.mutate({addonId:e,action:t,input:n}),[e,h]),N=o({queryKey:[...We,e],queryFn:async()=>Je(await M(`listSources`,{}))}),ie=o({queryKey:[...Ge,e],queryFn:async()=>Ye(await M(`listCountries`,{}))}),ae=o({queryKey:[`wasteCollections`,`listServices`,e,k],enabled:k!==``,queryFn:async()=>Xe(await M(`listServices`,{countryId:k}))}),P=o({queryKey:[`wasteCollections`,`serviceFormSchema`,e,A],enabled:A!==``,queryFn:async()=>M(`serviceFormSchema`,{serviceId:A})}),F=N.data??[],I=ie.data??[],L=ae.data??[],R=qe(P.data)?P.data:void 0,le=n(()=>Ze(I,k===``?[]:L,k),[I,L,k]),z=y.state,B=z.mode===`edit`?F.find(e=>e.id===z.id)??null:null;t(()=>{if(y.state.mode===`edit`&&B!==null){let e=`edit:${B.id}`;if(O.current===e)return;O.current=e,C(null),T({countryId:B.countryId??``,serviceId:B.serviceId??``}),D(B.formValues===void 0?{label:B.label,enabled:B.enabled}:{...B.formValues});return}if(y.state.mode===`new`){if(O.current===`new`)return;O.current=`new`,C(null),T({countryId:``,serviceId:``}),D({label:m(`system.wasteSettingsSources.newSource`,`New source`),enabled:!0})}},[B,y.state]),t(()=>{if(y.state.mode!==`new`||A===``)return;let e=L.find(e=>e.id===A);e&&D(t=>{let n=t.label;return typeof n==`string`&&n!==``&&n!==`New source`?t:{...t,label:e.title}})},[y.state.mode,A,L]);let ue=i(e=>{T(t=>{let n=typeof e.countryId==`string`?e.countryId:``;return n===(typeof t.countryId==`string`?t.countryId:``)?e:{countryId:n,serviceId:``}})},[]),H=i(async()=>{await _.invalidateQueries({queryKey:We})},[_]),U=u({mutationFn:async e=>M(`deleteSource`,{id:e}),onSuccess:async()=>H()}),W=i(async e=>{await v({title:m(`system.wasteSettingsSources.deleteWasteSource`,`Delete waste source?`),message:m(`system.wasteSettingsSources.removeItsCalendarUnderSystem`,`Remove “{{label}}” ({{id}}). Its calendar under System → Calendars is dropped.`,{label:e.label,id:e.id}),confirmLabel:m(`common.delete`,`Delete`),cancelLabel:m(`common.cancel`,`Cancel`),variant:`danger`})&&(await U.mutateAsync(e.id),y.state.mode===`edit`&&y.state.id===e.id&&(y.close(),O.current=null))},[v,U,y,m]),de=i(async()=>{let e=E.label,t=typeof e==`string`&&e.trim()!==``?e.trim():``;if(t===``){C(`Label is required.`);return}if(A===``){C(`Pick a country and a service.`);return}let n=y.state.mode===`new`,r=B?.id;if(!n&&(r===void 0||r===``)){C(`That source is no longer available.`);return}let i=E.enabled,a={...E};delete a.label,delete a.enabled,S(!0),C(null);try{n?await M(`createSource`,{label:t,serviceId:A,args:a,enabled:typeof i==`boolean`?i:!0}):r!==void 0&&await M(`updateSource`,{id:r,label:t,serviceId:A,args:a,enabled:typeof i==`boolean`?i:!0}),await H(),y.close(),O.current=null}catch(e){C(Ke(e))}finally{S(!1)}},[M,B,y,E,H,A]),G=n(()=>[{key:`label`,header:m(`system.wasteSettingsSources.label`,`Label`),sortValue:e=>e.label,render:e=>d(`span`,{className:`text-sm text-foreground`,children:e.label})},{key:`module`,header:m(`system.wasteSettingsSources.module`,`Module`),sortValue:e=>e.module,render:e=>d(`span`,{className:`font-mono text-xs text-foreground-muted`,children:e.module})},{key:`enabled`,header:m(`system.wasteSettingsSources.enabled`,`Enabled`),sortValue:e=>+!!e.enabled,render:e=>d(V,{variant:e.enabled?`success`:`default`,children:e.enabled?m(`system.wasteSettingsSources.on`,`On`):m(`system.wasteSettingsSources.off`,`Off`)})},{key:`actions`,header:``,notSortableReason:`actions`,render:e=>d(j,{type:`button`,size:`sm`,variant:`ghost`,"aria-label":m(`system.wasteSettingsSources.delete`,`Delete {{label}}`,{label:e.label}),"data-testid":`waste-source-delete-${e.id}`,onClick:t=>{t.stopPropagation(),W(e)},children:d(p,{className:`h-3.5 w-3.5 text-danger`})})}],[W,m]),K=y.state.mode===`new`,J=K||B!==null,pe=`${A}:${K?`new`:B?.id??`closed`}`;return a(`div`,{className:`flex min-h-0 flex-col gap-4`,"data-testid":`waste-settings-sources`,children:[a(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[d(`p`,{className:`text-sm text-foreground-muted`,children:m(`system.wasteSettingsSources.pickACountryAndA`,`Pick a country and a service — configuration fields come from that HACS source.`)}),a(j,{type:`button`,size:`sm`,"data-testid":`waste-sources-add`,onClick:()=>y.openNew(),children:[d(g,{className:`h-3.5 w-3.5`}),m(`system.wasteSettingsSources.addSource`,`Add source`)]})]}),N.isError?d(`p`,{className:`text-sm text-danger`,children:m(`system.wasteSettingsSources.couldNotLoadSources`,`Could not load sources.`)}):null,N.isPending?d(ce,{className:`h-32 w-full`}):d(re,{columns:G,rows:F,rowKey:e=>e.id,pageSize:25,emptyMessage:m(`system.wasteSettingsSources.noWasteSourcesYetAdd`,`No waste sources yet. Add one to register a municipal service.`),onRowClick:e=>y.openEdit(e.id),defaultSort:{columnKey:`label`,dir:`asc`}}),d(se,{open:J,onClose:()=>{y.close(),C(null),O.current=null},title:K?m(`system.wasteSettingsSources.addWasteSource`,`Add waste source`):m(`system.wasteSettingsSources.edit`,`Edit {{value1}}`,{value1:B?.label??`source`}),icon:te,width:`xl`,testId:`waste-source-editor`,error:ee,footer:d(j,{type:`button`,size:`sm`,disabled:x||A===``,onClick:()=>void de(),children:x?m(`system.wasteSettingsSources.saving`,`Saving…`):m(`common.save`,`Save`)}),children:J?a(s,{children:[d(`div`,{"data-testid":`waste-country-service`,children:d(oe,{schema:le,values:w,onChange:ue},`picker:${k}:${L.length}`)}),A!==``&&R!==void 0?d(oe,{schema:R,values:E,onChange:D,bare:!0},pe):A!==``&&P.isPending?d(`p`,{className:`text-sm text-foreground-muted`,children:m(`system.wasteSettingsSources.loadingFields`,`Loading fields…`)}):d(`p`,{className:`text-sm text-foreground-muted`,children:m(`system.wasteSettingsSources.chooseACountryAndService`,`Choose a country and service to see the required fields.`)})]}):null}),d(ve,{nodeId:`hub`,addonIds:[e],level:`global`,capability:f,hideSectionChrome:!0})]})}e();var $e=1e4,et={"device-export":`exporters`,exporters:`exporters`,email:`email`,broker:`brokers`,brokers:`brokers`,"message-brokers":`brokers`,calendar:`calendars`,calendars:`calendars`,"calendar-source":`calendars`},tt=[{sectionId:`exporters`,kind:`device-export`,labelKey:`system.connectivity.exporters`,icon:_,installLabelKey:`system.connectivity.exportersInstall`,emptyTitleKey:`system.connectivity.exportersEmptyTitle`,emptyDescriptionKey:`system.connectivity.exportersEmptyDescription`},{sectionId:`email`,kind:`email`,labelKey:`system.connectivity.email`,icon:v,installLabelKey:`system.connectivity.emailInstall`,emptyTitleKey:`system.connectivity.emailEmptyTitle`,emptyDescriptionKey:`system.connectivity.emailEmptyDescription`},{sectionId:`brokers`,kind:`broker`,labelKey:`system.connectivity.brokers`,icon:x,installLabelKey:`system.connectivity.brokersInstall`,emptyTitleKey:`system.connectivity.brokersEmptyTitle`,emptyDescriptionKey:`system.connectivity.brokersEmptyDescription`},{sectionId:`calendars`,kind:`calendar`,labelKey:`system.connectivity.calendars`,icon:w,installLabelKey:`system.connectivity.calendarsInstall`,emptyTitleKey:`system.connectivity.calendarsEmptyTitle`,emptyDescriptionKey:`system.connectivity.calendarsEmptyDescription`}];function nt(e,t,n,r){let i=Ve(ee,e.kind),o=t.flatMap(t=>{let r=He(t,i);if(r===null)return[];let o=Ue(t.processState);return[{id:t.addonId,name:t.displayName,fallbackIcon:e.icon,state:o.state,stateLabel:o.label,render:()=>d(be,{addonId:t.addonId,displayName:t.displayName,capName:r,isActive:t.processState===`running`,badges:a(s,{children:[d(ot,{processState:t.processState}),d(st,{kind:e.kind,addonId:t.addonId})]}),lead:e.kind===`device-export`?d(H,{addonId:t.addonId}):void 0,panels:at(e.kind,t.addonId,e=>n(`/devices/${e}`)),settingsContent:t.addonId===`waste-collections`?d(Qe,{addonId:t.addonId,capName:r}):void 0})}]});return{id:e.sectionId,label:r(e.labelKey),entries:o,install:{capability:i[0]??e.kind,label:r(e.installLabelKey)}}}function rt({descriptor:e,rows:t,isLoading:r}){let{t:i}=q(),a=pe(),o=n(()=>nt(e,t,a,i),[e,t,a,i]);return d(xe,{embedded:!0,icon:e.icon,title:i(e.labelKey),subtitle:null,groups:[o],isLoading:r,emptyTitle:i(e.emptyTitleKey),emptyDescription:i(e.emptyDescriptionKey)})}function it(){let{t:e}=q(),r=P(void 0,{refetchInterval:$e}),[i,a]=he(),o=J(`/system/integrations`,{t:e,isAdmin:!0})??{icon:m,title:e(`admin.system.integrations.connectivity`,`Connectivity`)};t(()=>{let e=i.get(`tab`);if(e===null)return;let t=et[e];t===void 0||t===e||a(e=>{let n=new URLSearchParams(e);return n.set(`tab`,t),n},{replace:!0})},[i,a]);let s=n(()=>(r.data??[]).map(Be).filter(e=>e!==null),[r.data]),c=n(()=>tt.map(t=>({id:t.sectionId,label:e(t.labelKey),ownedParams:me,content:d(rt,{descriptor:t,rows:s,isLoading:r.isLoading})})),[r.isLoading,s,e]);return d(_e,{icon:o.icon,title:o.title,subtitle:e(`admin.system.integrations.externalSystemsThisHubTalks`,`External systems this hub talks to — exporters, email, brokers and calendar sources.`),defaultSection:`exporters`,sectionsLabel:`Connectivity sections`,sections:c})}function at(e,t,n){return e===`device-export`?[{id:`devices`,title:K.t(`admin.system.integrations.devices`,`Devices`),icon:D,placement:`end`,content:d(R,{addonId:t,onOpenDevice:n,showSetup:!1})}]:e===`broker`?[{id:`connections`,title:K.t(`admin.system.integrations.connections`,`Connections`),icon:x,content:d(Le,{addonId:t,fallback:d(Ie,{addonId:t})})}]:[]}function ot({processState:e}){let{state:t,label:n}=Ue(e);return d(V,{variant:t===`ok`?`success`:t===`error`?`danger`:`default`,className:`${X} capitalize`,children:n})}function st({kind:e,addonId:t}){return e===`broker`?d(ct,{addonId:t}):e===`device-export`?d(lt,{addonId:t}):null}function ct({addonId:e}){let{t}=q(),{data:n}=le({addonId:e},{refetchInterval:$e,retry:!1}),r=S.safeParse(n);if(!r.success)return null;let{brokerCount:i,connectedCount:a}=r.data;return d(V,{variant:`info`,className:X,children:a>0?t(`system.connectivity.connectionsConnected`,{count:i,connected:a}):t(`system.connectivity.connections`,{count:i})})}function lt({addonId:e}){let{t}=q(),{data:n}=F({addonId:e},{refetchInterval:$e,retry:!1}),r=C.safeParse(n);if(!r.success)return null;let{linkState:i,exposedDeviceCount:a}=r.data;return d(V,{variant:i===`linked`?`success`:i===`error`?`danger`:`default`,className:X,children:t(`admin.system.integrations.exposed`,`{{linkState}} · {{exposedDeviceCount}} exposed`,{linkState:i,exposedDeviceCount:a})})}export{it as IntegrationsPage};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{$ as e,B as t,G as n,J as r,S as i,b as a,o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{$i as c,Ei as l,Fn as u,Hr as d,Ht as f,It as p,Li as m,Lr as h,Ni as g,O as _,Pr as v,Qi as y,Rt as b,Ur as x,V as S,Wi as C,bn as w,cn as T,dt as E,ea as D,ei as O,en as k,fi as A,gr as j,ji as M,k as N,kn as P,lr as F,pn as I,pt as L,rn as R,rr as ee,tr as te,ur as z,ut as ne,xi as re,yi as B,z as V,zt as ie}from"./player-overlays-Fx6RE6kI.js";import{Zt as ae,rr as oe,tr as se}from"./client-yfOXPkcm.js";import{t as ce}from"./boxes-U2BARjlG.js";import{n as le,r as ue,t as de}from"./speaker-C8juqhRE.js";import{t as H}from"./user-round-CjXCVqIf.js";import{$n as fe,Aa as pe,Da as me,Dn as he,Fa as ge,Ft as U,Gi as W,Gt as G,Hn as K,Ia as _e,It as q,K as ve,Ki as ye,Mn as be,Na as xe,Nn as Se,Oa as Ce,On as we,Pa as Te,Sa as Ee,Va as De,Wi as Oe,Zl as ke,_a as Ae,ba as je,cn as Me,d as Ne,iu as Pe,jn as Fe,ka as Ie,kn as Le,nu as J,qi as Re,rr as ze,ru as Be,sn as Ve,sr as He,xa as Ue,ya as We}from"./src-AhVPNkCn.js";import{t as Y}from"./i18n-B1bxeya5.js";import{t as X}from"./useTranslation-D3Is_4B6.js";import{Q as Z,et as Ge,nt as Ke,v as qe}from"./index-CcAR8Rlk.js";import{t as Je}from"./AdminSectionedPage-D5J86Kfp.js";import{a as Ye,n as Xe,r as Ze}from"./linked-devices-model-BMUapBfD.js";e();var Qe={camera:l,hub:le,container:ce,light:z,siren:R,switch:ie,sensor:D,thermostat:f,climate:c,button:A,"event-emitter":ne,update:ue,notifier:m,script:I,automation:L,lock:ee,cover:g,valve:x,humidifier:d,"water-heater":v,fan:h,"media-player":de,"alarm-panel":T,control:k,presence:H,weather:O,vacuum:M,"lawn-mower":b,image:j,smoke:y};function Q({type:e,className:t}){return s(Qe[e]??A,{"aria-hidden":`true`,className:t??`h-3.5 w-3.5 shrink-0 text-foreground-subtle`})}function $e({online:e,deviceName:t}){return s(`span`,{className:e?`inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-success`:`inline-block h-1.5 w-1.5 shrink-0 rounded-full border border-foreground-subtle`,role:`img`,"aria-label":Y.t(`locations.deviceGlyphs.aria`,{name:t,state:e?Y.t(`common.online`):Y.t(`common.offline`)}),title:e?Y.t(`common.online`):Y.t(`common.offline`)})}function et({open:e,title:n,items:a,listState:o,lockedIds:c,lockedNote:l,suggestions:u=null,busy:d=!1,onConfirm:f,onClose:p}){let{t:m}=X(),[h,g]=r([]);t(()=>{e||g([])},[e]);let _=new Map(a.map(e=>[e.id,e.name])),v=(u?.ids??[]).filter(e=>_.has(e)&&!c.includes(e)),y=e=>g(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return s(he,{open:e,onOpenChange:e=>e?void 0:p(),children:i(Le,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,"aria-label":n,children:[s(be,{children:s(Se,{children:n})}),i(we,{className:`flex flex-col gap-3 p-2 sm:p-4`,children:[e&&u!==null&&v.length>0&&i(`section`,{"aria-label":u.heading,className:`flex flex-col gap-1`,children:[s(`h3`,{className:`text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:u.heading}),s(`div`,{className:`flex flex-wrap gap-1`,children:v.map(e=>s(`button`,{type:`button`,"aria-pressed":h.includes(e),className:`inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors ${h.includes(e)?`border-primary/50 bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle hover:bg-surface-hover`}`,onClick:()=>y(e),children:_.get(e)},e))})]}),e&&s(Ne,{devices:a,listState:o,value:h,onChange:e=>g(e),noun:`device`,emptyLabel:m(`locations.addDialog.nonePicked`),showAll:!0,lockedIds:c,lockedNote:l,testId:`quick-add-picker`})]}),i(Fe,{children:[s(K,{variant:`ghost`,onClick:p,children:m(`locations.addDialog.cancel`)}),s(K,{disabled:h.length===0||d,onClick:()=>f(h),children:m(`locations.addDialog.confirm`,{count:h.length})})]})]})})}e();function tt({room:e,cameras:t,fleet:r}){let{t:i}=X(),a=n(()=>new Map(r.map(e=>[e.id,e])),[r]);return e===null?s(`p`,{className:`text-xs text-foreground-subtle`,children:i(`locations.links.noRoom`)}):s(`div`,{className:`flex flex-col gap-3`,"data-testid":`camera-links-section`,children:t.length===0?s(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`camera-links-empty`,children:i(`locations.links.noCameras`,{room:e})}):t.map(e=>s(rt,{camera:e,byId:a},e.id))})}function nt(e){return{id:e.deviceId,name:e.parentName===null?e.name:`${e.parentName} · ${e.name}`,type:e.type,location:e.location}}function rt({camera:e,byId:t}){let{t:n}=X(),a=o(),c=Ge(),[l,u]=r(!1),[d,f]=r(null),p=W({deviceId:e.id}),m=Ze({status:p.status,data:p.data,error:p.error===null||p.error===void 0?null:p.error}),h=ye(),g=m.kind===`present`?m:null,v=Oe({deviceId:e.id,slotRef:g?.slot.slotRef??``},{enabled:l&&g!==null}),y=g===null?[]:Xe(g.slot,g.value),b=y.map(e=>e.deviceId),x=(v.data?.candidates??[]).map(nt),S=new Set(x.map(e=>e.id)),C=b.filter(e=>!S.has(e)).map(e=>{let n=t.get(e);return{id:e,name:n?.name??`#${String(e)}`,...n===void 0?{}:{type:n.type,location:n.location}}}),w=[...x,...C],T=(v.data?.candidates??[]).filter(e=>e.suggested).map(e=>e.deviceId),E=async t=>{if(g!==null){f(null);try{await h.mutateAsync({deviceId:e.id,slotRef:g.slot.slotRef,value:Ye(g.value,t)}),await p.refetch(),await a.invalidateQueries({queryKey:[[`deviceManager`]]}),u(!1)}catch(e){f(e instanceof Error?e.message:String(e))}}},D=[{key:`device`,header:n(`locations.columns.device`),notSortableReason:n(`locations.columns.noSort`),render:e=>{let r=t.get(e.deviceId),a=e.name??r?.name??`#${String(e.deviceId)}`;return i(`span`,{className:`flex items-center gap-1.5`,children:[r!==void 0&&s(Q,{type:r.type}),s(Z,{to:`/devices/${String(e.deviceId)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:a}),e.implied&&s(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`locations.links.implied`)})]})}},{key:`type`,header:n(`locations.columns.type`),notSortableReason:n(`locations.columns.noSort`),render:e=>s(`span`,{className:`text-xs text-foreground-muted`,children:t.get(e.deviceId)?.type??`—`})},{key:`status`,header:n(`locations.columns.status`),notSortableReason:n(`locations.columns.noSort`),render:e=>{let r=t.get(e.deviceId);return r===void 0?s(`span`,{className:`text-xs text-foreground-subtle`,children:`—`}):i(`span`,{className:`flex items-center gap-1.5`,children:[s($e,{online:r.online,deviceName:r.name}),s(`span`,{className:`text-xs text-foreground-muted`,children:r.online?n(`common.online`):n(`common.offline`)})]})}}];return i(`section`,{className:`min-w-0 ${_}`,"data-testid":`camera-links-${String(e.id)}`,children:[i(`header`,{className:`${N} flex min-h-9 items-center gap-1.5`,children:[s(Q,{type:e.type}),s(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:e.name}),i(K,{variant:`ghost`,size:`sm`,onClick:()=>c(qe(e.id)),children:[s(F,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),n(`locations.links.edit`)]}),s(K,{variant:`outline`,size:`sm`,disabled:g===null,onClick:()=>u(!0),"aria-label":n(`locations.links.addNamed`,{camera:e.name}),children:n(`locations.room.add`)})]}),m.kind===`pending`&&s(`p`,{role:`status`,className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:n(`locations.links.loading`)}),m.kind===`unknown`&&s(`p`,{role:`alert`,className:`px-3 py-3 text-xs text-warning sm:px-4`,children:n(`locations.links.unreadable`,{reason:m.reason})}),m.kind===`absent`&&s(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:n(`locations.links.unsupported`)}),d!==null&&s(`p`,{role:`alert`,className:`px-3 pt-2 text-xs text-danger break-words sm:px-4`,children:d}),g!==null&&(y.length===0?s(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:n(`locations.links.none`)}):s(G,{columns:D,rows:y,rowKey:e=>String(e.deviceId),bordered:!1,minWidthPx:360})),s(et,{open:l,title:n(`locations.links.pickTitle`,{camera:e.name}),items:w,listState:v.status===`error`?`failed`:v.data===void 0?`pending`:`answered`,lockedIds:b,lockedNote:n(`locations.links.alreadyLinked`),suggestions:e.location===null?null:{heading:n(`locations.links.suggested`,{room:e.location}),ids:T},busy:h.isPending,onConfirm:e=>void E(e),onClose:()=>u(!1)})]})}e();function it({name:e,description:n,busy:a,onSave:o}){let{t:c}=X(),[l,u]=r(n??``);return t(()=>{u(n??``)},[n]),i(`div`,{className:`border-t border-border px-3 py-2 sm:px-4`,children:[s(Me,{htmlFor:`location-description-${e}`,className:`block`,children:c(`locations.locationDescriptionField.whatIsThere`,`What is there`)}),s(`textarea`,{id:`location-description-${e}`,value:l,onChange:e=>u(e.target.value),onBlur:()=>{let e=l.trim();e!==(n??``)&&o(e.length===0?null:e)},disabled:a,rows:2,maxLength:400,placeholder:c(`locations.locationDescriptionField.surfacesBoundariesWhatIsNormally`,`Surfaces, boundaries, what is normally parked or stored here.`),className:`mt-1 w-full resize-y rounded-md border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-inset focus:ring-primary disabled:cursor-not-allowed disabled:opacity-50`}),s(`p`,{className:`mt-1 ${V}`,children:c(`locations.locationDescriptionField.givenToTheAiWith`,`Given to the AI with the pictures, so it knows what it is looking at. Describe the PLACE, not what happens in it — events change, the ground does not.`)})]})}function at(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0||n.description.length===0?null:n.description}var ot=` none`;function st({name:e,zones:t,zoneKey:n,busy:r,onChange:a}){let{t:o}=X();if(t.length===0)return null;let c=[{value:ot,label:o(`locations.locationZoneField.none`,`— none —`)},...t.map(e=>({value:e.zoneKey,label:e.label}))];return i(`div`,{className:`flex items-center gap-2 border-t border-border px-3 py-1.5 sm:px-4 sm:py-2`,children:[s(Me,{htmlFor:`location-zone-${e}`,children:o(`locations.locationZoneField.zone`,`Zone`)}),s(ke,{id:`location-zone-${e}`,value:n??ot,disabled:r,onChange:e=>{let n=e.target.value;if(n===ot){a(null);return}let r=t.find(e=>e.zoneKey===n);r!==void 0&&a(r.label)},options:c})]})}function ct(e,t){return e.find(e=>e.locationKeys.includes(t))?.zoneKey??null}function lt({name:e,icon:t,busy:n,onPick:r}){return s(Pe,{value:t,onPick:r,fallbackGlyph:te,clearGlyph:C,labels:{trigger:`Change the icon of ${e}`,panel:`Icon for ${e}`,searchPlaceholder:`Search icons`,clear:`No icon`,noMatches:`No icon matches that`},disabled:n})}function ut(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0?null:oe(n.icon)??`map-pin`}function $(e){if(e==null)return null;let t=e.trim();return t.length===0?null:t.toLowerCase()}function dt(e,t){let n=$(t);return n===null?[]:e.filter(e=>$(e.location)===n)}function ft(e,t){let n=dt(e,t),r=new Set(n.map(e=>e.id));return n.filter(e=>e.parentDeviceId===null||!r.has(e.parentDeviceId))}function pt(e,t){let n=$(e.location);return n===null||new Set(t.map(e=>$(e))).has(n)?null:e.location?.trim()??null}function mt(e,t){let n=$(e.location);return n!==null&&t.has(n)}function ht(e,t){let n=new Set(t.map(e=>$(e))),r=new Set(e.filter(e=>mt(e,n)).map(e=>e.id));return e.filter(e=>!(mt(e,n)||e.parentDeviceId!==null&&r.has(e.parentDeviceId)))}function gt(e,t){return ht(e,t).filter(e=>e.parentDeviceId===null)}function _t(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 vt(e,t){return _t(e,t).length}function yt(e,t){return e.filter(e=>!e.isCamera&&e.parentDeviceId===t)}function bt(e,t){return t.map(t=>({name:t,members:ft(e,t)}))}function xt(e){return`${e.kind}:${String(e.device.id)}`}function St(e,t,n){return e.flatMap(e=>{let r=yt(t,e.id),i=n.has(e.id),a={kind:`member`,device:e,accessories:r,open:i};return!i||r.length===0?[a]:[a,...r.map(t=>({kind:`accessory`,device:t,parent:e}))]})}e();function Ct({name:e,members:t,devices:o,busy:c,icon:l,description:d,onRename:f,onDelete:m,onRebuildLinks:h,onAddDevices:g,onPickIcon:v,onSaveDescription:y,zones:b,zoneKey:x,onChangeZone:S}){let{t:C}=X(),[T,D]=r(!1),[O,k]=r(e),A=U(t,n(()=>({searchText:e=>[e.name,...yt(o,e.id).map(e=>e.name)],facetValue:e=>e.type}),[o])),[j,M]=r(()=>new Set),P=e=>M(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),F=n(()=>St(A.rows,o,j),[A.rows,o,j]),I=[{key:`name`,header:C(`locations.columns.device`),notSortableReason:C(`locations.columns.noSort`),render:e=>e.kind===`member`?s(wt,{row:e,onToggle:()=>P(e.device.id)}):s(Tt,{row:e})},{key:`type`,header:C(`locations.columns.type`),notSortableReason:C(`locations.columns.noSort`),render:e=>s(`span`,{className:`text-xs text-foreground-muted`,children:e.device.type})},{key:`status`,header:C(`locations.columns.status`),notSortableReason:C(`locations.columns.noSort`),render:e=>i(`span`,{className:`flex items-center gap-1.5`,children:[s($e,{online:e.device.online,deviceName:e.device.name}),s(`span`,{className:`text-xs text-foreground-muted`,children:e.device.online?C(`common.online`):C(`common.offline`)})]})}],L=()=>{k(e),D(!1)},R=async()=>{let t=O.trim();if(t.length===0||t===e){L();return}await f(t),D(!1)},ee=[{id:`rename`,label:C(`locations.locationCard.rename`,`Rename`),icon:u,disabled:c,onClick:()=>{k(e),D(!0)}},{id:`rebuild-links`,label:C(`locations.locationCard.rebuildLinkedDevices`,`Rebuild linked devices`),icon:w,separatorBefore:!0,disabled:c,onClick:()=>void h()},{id:`delete`,label:C(`common.delete`,`Delete`),icon:p,danger:!0,separatorBefore:!0,disabled:c,onClick:()=>void m()}];return i(`section`,{className:`min-w-0 ${_}`,children:[i(`header`,{className:`${N} flex min-h-9 items-center gap-1.5`,children:[s(lt,{name:e,icon:l,busy:c,onPick:v}),T?i(a,{children:[s(J,{value:O,onChange:e=>k(e.target.value),onKeyDown:e=>{e.key===`Enter`&&R(),e.key===`Escape`&&L()},"aria-label":C(`locations.locationCard.rename2`,`Rename {{name}}`,{name:e}),className:`min-w-0 flex-1`,autoFocus:!0}),s(K,{type:`button`,size:`sm`,onClick:()=>void R(),children:C(`common.save`,`Save`)}),s(Be,{type:`button`,variant:`ghost`,icon:E,onClick:L,"aria-label":C(`locations.locationCard.cancelRename`,`Cancel rename`)})]}):i(a,{children:[s(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:e}),s(K,{type:`button`,variant:`outline`,size:`sm`,disabled:c,onClick:g,"aria-label":C(`locations.room.addTo`,{room:e}),children:C(`locations.room.add`)}),s(ve,{items:ee,title:C(`locations.locationCard.actionsFor`,`Actions for {{name}}`,{name:e}),triggerClassName:`p-1`})]})]}),s(st,{name:e,zones:b,zoneKey:x,busy:c,onChange:S}),s(it,{name:e,description:d,busy:c,onSave:y}),t.length>0&&s(`div`,{className:`border-b border-border px-3 py-1.5 sm:px-4 sm:py-2`,children:s(q,{state:A.state,facets:A.facets,labels:{searchPlaceholder:C(`locations.filter.searchPlaceholder`),searchLabel:C(`locations.room.searchLabel`,{room:e}),facetsLabel:C(`locations.filter.typesLabel`),clearLabel:C(`locations.filter.clear`)},onSearch:A.setSearch,onToggleFacet:A.toggleFacet,onClear:A.clear})}),t.length===0?s(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:C(`locations.locationCard.nothingHereYetAssignA`,`Nothing here yet — assign a device from the table below.`)}):s(G,{columns:I,rows:F,rowKey:xt,bordered:!1,minWidthPx:360,emptyMessage:C(`locations.filter.noMatch`)})]})}function wt({row:e,onToggle:t}){let{t:n}=X(),{device:r,accessories:a,open:o}=e,c=o?re:B;return i(`span`,{className:`flex items-center gap-1.5`,children:[a.length>0?i(K,{type:`button`,variant:`ghost`,onClick:t,"aria-expanded":o,"aria-label":n(o?`locations.locationCard.collapseAccessories`:`locations.locationCard.expandAccessories`,{count:a.length,name:r.name}),className:`h-auto shrink-0 gap-0.5 p-0.5 text-foreground-subtle hover:text-foreground`,children:[s(c,{className:`h-3 w-3`}),s(`span`,{className:`text-[10px] tabular-nums`,children:a.length})]}):s(`span`,{"aria-hidden":`true`,className:`w-[1.35rem] shrink-0`}),s(Q,{type:r.type}),s(Z,{to:`/devices/${String(r.id)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:r.name})]})}function Tt({row:e}){let{device:t}=e;return i(`span`,{className:`flex items-center gap-1.5 pl-6`,children:[s(`span`,{"aria-hidden":`true`,className:`text-[10px] text-foreground-subtle`,children:`└`}),s(Q,{type:t.type,className:`h-3 w-3 shrink-0 text-foreground-subtle`}),s(Z,{to:`/devices/${String(t.id)}`,className:`min-w-0 truncate text-xs text-foreground-muted hover:underline`,children:t.name})]})}e();function Et({zones:e,busy:t,onRename:n,onDelete:i,onPickIcon:a}){let{t:o}=X(),[c,l]=r(null),[u,d]=r(``),f=async e=>{let t=u.trim();l(null),!(t.length===0||t===e)&&await n(e,t)};return s(G,{columns:[{key:`icon`,header:o(`locations.siteZonesPanel.icon`,`Icon`),width:`w-12`,notSortableReason:`An icon has no order`,render:e=>s(lt,{name:e.label,icon:e.icon,busy:t,onPick:t=>a(e.label,t)})},{key:`name`,header:o(`locations.siteZonesPanel.zone`,`Zone`),sortValue:e=>e.label.toLowerCase(),render:e=>c===e.label?s(J,{value:u,onChange:e=>d(e.target.value),onKeyDown:t=>{t.key===`Enter`&&f(e.label),t.key===`Escape`&&l(null)},onBlur:()=>void f(e.label),"aria-label":o(`locations.siteZonesPanel.rename`,`Rename {{label}}`,{label:e.label}),autoFocus:!0}):s(K,{type:`button`,variant:`ghost`,size:`sm`,className:`px-0`,onClick:()=>{d(e.label),l(e.label)},disabled:t,title:o(`locations.siteZonesPanel.renameTheZone`,`Rename the zone`),children:e.label})},{key:`rooms`,header:o(`locations.siteZonesPanel.rooms`,`Rooms`),align:`right`,sortValue:e=>e.locationKeys.length,render:e=>s(`span`,{className:`tabular-nums text-foreground-subtle`,children:e.locationKeys.length===0?o(`common.empty`):o(`common.rooms`,{count:e.locationKeys.length})})},{key:`actions`,header:o(`locations.siteZonesPanel.actions`,`Actions`),align:`right`,notSortableReason:`Actions have no order`,render:e=>s(K,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void i(e.label),disabled:t,"aria-label":o(`locations.siteZonesPanel.delete`,`Delete {{label}}`,{label:e.label}),title:o(`locations.siteZonesPanel.deleteTheZoneTheRooms`,`Delete the zone — the rooms in it are kept`),children:s(p,{className:`h-3.5 w-3.5`})})}],rows:e,rowKey:e=>e.zoneKey,emptyMessage:o(`locations.siteZonesPanel.noZonesYetAZone`,`No zones yet. A zone groups rooms — “Zona notte” for the bedrooms — and shows up before them in the app’s camera filter.`)})}e();function Dt({busy:e,onCreate:t}){let{t:n}=X(),[a,o]=r(!1),[c,l]=r(``),u=()=>{l(``),o(!1)},d=async()=>{let e=c.trim();e.length!==0&&(await t(e),u())};return a?i(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[s(J,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&u()},placeholder:n(`locations.newLocationButton.ingressoSaloneCucina`,`Ingresso, Salone, Cucina…`),"aria-label":n(`locations.newLocationButton.newLocationName`,`New location name`),className:`min-w-[12rem] flex-1`,autoFocus:!0}),i(K,{size:`sm`,type:`submit`,disabled:c.trim().length===0||e,children:[s(P,{className:`h-3.5 w-3.5`}),n(`common.add`,`Add`)]}),s(K,{size:`sm`,variant:`ghost`,type:`button`,onClick:u,"aria-label":n(`locations.newLocationButton.cancelNewLocation`,`Cancel new location`),children:s(E,{className:`h-3.5 w-3.5`})})]}):i(K,{size:`sm`,type:`button`,onClick:()=>o(!0),"data-testid":`new-location-button`,children:[s(P,{className:`h-3.5 w-3.5`}),n(`locations.newLocationButton.newLocation`,`New location`)]})}e();function Ot({busy:e,onCreate:t}){let{t:n}=X(),[a,o]=r(!1),[c,l]=r(``),u=()=>{l(``),o(!1)},d=async()=>{let e=c.trim();e.length!==0&&(await t(e),u())};return a?i(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[s(J,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&u()},placeholder:n(`locations.newZoneButton.zonaGiornoZonaNotte`,`Zona giorno, Zona notte…`),"aria-label":n(`locations.newZoneButton.newZoneName`,`New zone name`),className:`min-w-[12rem] flex-1`,autoFocus:!0}),i(K,{size:`sm`,type:`submit`,disabled:c.trim().length===0||e,children:[s(P,{className:`h-3.5 w-3.5`}),n(`common.add`,`Add`)]}),s(K,{size:`sm`,variant:`ghost`,type:`button`,onClick:u,"aria-label":n(`locations.newZoneButton.cancelNewZone`,`Cancel new zone`),children:s(E,{className:`h-3.5 w-3.5`})})]}):i(K,{size:`sm`,type:`button`,onClick:()=>o(!0),"data-testid":`new-zone-button`,children:[s(P,{className:`h-3.5 w-3.5`}),n(`locations.newZoneButton.newZone`,`New zone`)]})}e();function kt(e,t,n,r){let i=e.map(e=>({value:e.name,label:`${e.name} · ${String(e.count)}`}));return t===void 0?i:[...i,{value:n,label:`${r} · ${String(t)}`}]}function At({rooms:e,unassignedCount:t,value:r,unassignedValue:i,onChange:a}){let{t:o}=X(),c=n(()=>kt(e,t,i,o(`locations.roomPicker.unassigned`)),[e,t,i,o]);return s(`div`,{className:`max-w-sm`,"data-testid":`room-select`,children:s(ze,{mode:`single`,singleDisplay:`field`,label:o(`locations.roomPicker.label`),placeholder:o(`locations.roomPicker.placeholder`),options:c,value:r,onChange:a,searchable:!0,testId:`room-select-control`,optionTestIdPrefix:`room-option`})})}e();var jt={searchText:e=>[e.name],facetValue:e=>e.type};function Mt({rows:e,fleet:t,locations:a,busy:o,emptyMessage:c,onAssign:l}){let{t:u}=X(),[d,f]=r([]),[p,m]=r(``),h=U(e,jt),g=h.rows,_=n(()=>g.map(e=>e.id),[g]),v=n(()=>d.filter(e=>_.includes(e)),[d,_]),y=g.length>0&&v.length===g.length,b=n(()=>{let n=new Map;for(let r of e)n.set(r.id,vt(t,r.id));return n},[e,t]),x=v.reduce((e,t)=>e+(b.get(t)??0),0),C=e=>f(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),w=()=>f(y?[]:_),T=()=>{p.length===0||v.length===0||(l(v,p),f([]),m(``))},E=a.map(e=>({value:e,label:e})),D=[{key:`select`,width:`w-8`,headerRender:()=>s(Ve,{checked:y,onChange:w,"aria-label":y?u(`locations.unassignedTable.clearSelection`,`Clear selection`):u(`locations.unassignedTable.selectAllUnassignedDevices`,`Select all unassigned devices`)}),render:e=>s(Ve,{checked:v.includes(e.id),onChange:()=>C(e.id),"aria-label":u(`locations.unassignedTable.select`,`Select {{name}}`,{name:e.name})})},{key:`name`,header:u(`locations.unassignedTable.device`,`Device`),sortValue:e=>e.name.toLowerCase(),render:e=>{let t=pt(e,a);return i(`span`,{className:`flex items-center gap-1.5`,children:[s(Q,{type:e.type}),s(Z,{to:`/devices/${String(e.id)}`,className:`truncate text-xs text-foreground hover:underline`,children:e.name}),t!==null&&s(He,{variant:`warning`,children:u(`locations.unassignedTable.unknownRoom`,{room:t})})]})}},{key:`type`,header:u(`locations.unassignedTable.type`,`Type`),sortValue:e=>e.type,render:e=>s(`span`,{className:`text-xs text-foreground-muted`,children:e.type})},{key:`status`,header:u(`locations.unassignedTable.status`,`Status`),sortValue:e=>+!!e.online,render:e=>i(`span`,{className:`flex items-center gap-1.5`,children:[s($e,{online:e.online,deviceName:e.name}),s(`span`,{className:`text-xs text-foreground-muted`,children:e.online?u(`common.online`):u(`common.offline`)})]})},{key:`followers`,header:u(`locations.unassignedTable.accessoriesInTowCount`,`Accessories in tow`),align:`right`,sortValue:e=>b.get(e.id)??0,render:e=>s(`span`,{className:`tabular-nums text-xs text-foreground-muted`,children:b.get(e.id)??0})},{key:`assign`,header:u(`locations.unassignedTable.assignTo`,`Assign to`),align:`right`,notSortableReason:`This column is a control, not a value.`,render:e=>s(ke,{"aria-label":u(`locations.unassignedTable.locationFor`,`Location for {{name}}`,{name:e.name}),value:``,disabled:o||a.length===0,onChange:t=>{let n=t.target.value;n.length!==0&&l([e.id],n)},className:`max-w-[11rem]`,options:[{value:``,label:`—`},...E]})}];return i(`section`,{className:`space-y-2`,children:[i(`header`,{className:`flex flex-wrap items-baseline gap-2`,children:[s(`h2`,{className:S,children:u(`locations.unassignedTable.notInARoom`,`Not in a room`)}),s(`p`,{className:V,children:u(`locations.unassignedTable.topLevelDevicesOnlyAccessories`,`Top-level devices only — accessories move with their parent.`)})]}),e.length>0&&s(q,{state:h.state,facets:h.facets,labels:{searchPlaceholder:u(`locations.filter.searchPlaceholder`),searchLabel:u(`locations.unassigned.searchLabel`),facetsLabel:u(`locations.filter.typesLabel`),clearLabel:u(`locations.filter.clear`)},onSearch:h.setSearch,onToggleFacet:h.toggleFacet,onClear:h.clear}),v.length>0&&i(`div`,{role:`group`,"aria-label":u(`locations.unassignedTable.bulkAssignment`,`Bulk assignment`),className:`flex flex-wrap items-center gap-2 rounded border border-primary/40 bg-primary/5 px-2 py-1.5`,children:[i(`span`,{className:`text-xs text-foreground`,children:[u(`locations.unassignedTable.selected`,{count:v.length}),x>0&&` · ${u(`locations.unassignedTable.accessoriesInTowCount`,{count:x})}`]}),s(ke,{"aria-label":u(`locations.unassignedTable.assignSelectedDevicesTo`,`Assign selected devices to`),value:p,onChange:e=>m(e.target.value),className:`w-auto min-w-[10rem]`,options:[{value:``,label:u(`locations.unassignedTable.assignTo2`,`Assign to…`)},...E]}),s(K,{type:`button`,size:`sm`,onClick:T,disabled:o||p.length===0,children:u(`locations.unassignedTable.assign`,`Assign`)}),s(K,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>f([]),children:u(`locations.unassignedTable.clear`,`Clear`)})]}),s(G,{columns:D,rows:g,rowKey:e=>e.id,minWidthPx:720,emptyMessage:h.active?u(`locations.filter.noMatch`):c})]})}function Nt(e){return{id:e.id,parentDeviceId:e.parentDeviceId,location:e.location,type:e.type,stableId:e.stableId??``,...e.primaryChildEntityId===void 0?{}:{primaryChildEntityId:e.primaryChildEntityId},...e.role!==void 0&&e.role!==null?{role:e.role}:{},name:e.name}}function Pt(e,t){let n=t.map(Nt),r=[];for(let i of t)i.isCamera&&i.location===e&&r.push({deviceId:i.id,name:i.name,ids:ae({selfId:i.id,selfLocation:i.location,candidates:n})});return{entries:r}}var Ft=`device-manager:linked-devices`;function It(e){return{deviceId:e.deviceId,slotRef:Ft,value:{slot:`linked-devices`,deviceIds:[...e.ids]}}}e();var Lt=`__unassigned__`;function Rt(){let{t:e}=X(),t=o(),a=fe(),{data:c,isLoading:l}=Ue(),{data:u}=je(),{data:d}=We(),{data:f}=Ee(),{data:p,isLoading:m}=Ae({projection:`slim`}),h=()=>{t.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]}),t.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),t.invalidateQueries({queryKey:[[`deviceManager`,`listLocationIcons`]]}),t.invalidateQueries({queryKey:[[`deviceManager`,`listLocationDescriptions`]]}),t.invalidateQueries({queryKey:[[`deviceManager`,`listSiteZones`]]})},g=Re({onSuccess:h}),_=me({onSuccess:h}),v=xe({onSuccess:h}),y=Ie({onSuccess:h}),b=ge({onSuccess:h}),x=Te({onSuccess:h}),S=De({onSuccess:h}),C=Ce({onSuccess:h}),w=pe({onSuccess:h}),T=_e({onSuccess:h}),E=ye(),D=n(()=>(p??[]).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,stableId:e.stableId,primaryChildEntityId:e.primaryChildEntityId??null})),[p]),O=c??[],k=n(()=>bt(D,O),[D,O]),[A,j]=Ke(),M=A.get(`tab`),N=M===`zones`||M===`camera-links`?M:`locations`,P=A.get(`room`),F=n(()=>gt(D,O),[D,O]),I=P===Lt,L=I?null:P!==null&&k.some(e=>e.name===P)?P:k[0]?.name??null,R=L===null?null:k.find(e=>e.name===L)??null,ee=I?Lt:L??`__unassigned__`,z=L??k[0]?.name??null,ne=n(()=>k.map(e=>({name:e.name,count:e.members.length})),[k]),re=e=>{j(t=>{let n=new URLSearchParams(t);return n.set(`room`,e),n},{replace:!0})},B=l||m,V=v.isPending||_.isPending||g.isPending||b.isPending,ie=async e=>{await g.mutateAsync({name:e})},ae=async(e,t)=>{let n=t.trim();n.length===0||n===e||await y.mutateAsync({from:e,to:n})},oe=async t=>{let n=Pt(t,D);if(n.entries.length===0){await a({title:e(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:e(`locations.noCameraIsAssignedTo`,`No camera is assigned to “{{room}}”.`,{room:t}),confirmLabel:`OK`});return}let r=n.entries.map(t=>e(`locations.rebuildEntry`,{name:t.name,count:t.ids.length})).join(`
|
|
2
|
-
`);if(!await a({title:e(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:e(`locations.replaceTheLinkedDeviceList`,`Replace the linked-device list of every camera in “{{room}}” with what the room contains? {{lines}} Anything linked by hand that is not in this room is lost.`,{room:t,lines:r}),confirmLabel:e(`locations.rebuild`,`Rebuild`),variant:`danger`}))return;let i=[];for(let e of n.entries)try{await E.mutateAsync(It(e))}catch(t){i.push(`• ${e.name}: ${t instanceof Error?t.message:String(t)}`)}h(),i.length>0&&await a({title:e(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:e(`locations.notRebuilt`,`Not rebuilt: {{value1}}`,{value1:i.join(`
|
|
3
|
-
`)}),confirmLabel:`OK`})},ce=async(t,n)=>{let r=n>0?` ${String(n)} device(s) will become unassigned.`:``;await a({title:e(`locations.deleteLocation`,`Delete location`),message:e(`locations.deleteTheLocation`,`Delete the location “{{name}}”?{{extra}}`,{name:t,extra:r}),confirmLabel:e(`common.delete`,`Delete`),variant:`danger`})&&await _.mutateAsync({name:t,cascade:!0})},le=async t=>{await a({title:e(`locations.deleteZone`,`Delete zone`),message:e(`locations.deleteTheZoneTheRooms`,`Delete the zone “{{name}}”? The rooms in it are kept.`,{name:t}),confirmLabel:e(`common.delete`,`Delete`),variant:`danger`})&&await C.mutateAsync({name:t})},ue=async(e,t)=>{await b.mutateAsync({location:e,icon:t})},de=async(e,t)=>{await x.mutateAsync({location:e,description:t})},H=f??[],he=async(e,t)=>{await T.mutateAsync({location:e,zone:t})},U=(e,t)=>{for(let n of e)v.mutate({deviceId:n,location:t})},[W,G]=r(null),K=n(()=>D.filter(e=>e.parentDeviceId===null).map(e=>({id:e.id,name:e.name,type:e.type,location:e.location})),[D]),q=s(At,{rooms:ne,...N===`locations`?{unassignedCount:F.length}:{},value:N===`locations`?ee:z??``,unassignedValue:Lt,onChange:re}),ve=i(`div`,{className:`flex flex-col gap-3`,"data-testid":`locations-section`,children:[B&&s(`p`,{className:`text-xs text-foreground-subtle`,children:e(`locations.loadingLocationsAndDevices`,`Loading locations and devices…`)}),q,I||R===null?s(Mt,{rows:F,fleet:D,locations:O,busy:V,emptyMessage:B?e(`common.loading`,`Loading…`):e(`locations.everyTopLevelDeviceHas`,`Every top-level device has a room.`),onAssign:U}):s(Ct,{name:R.name,members:R.members,devices:D,busy:V,icon:ut(u,se(R.name)),onPickIcon:e=>ue(R.name,e),description:at(d,se(R.name)),onSaveDescription:e=>de(R.name,e),zones:H,zoneKey:ct(H,se(R.name)),onChangeZone:e=>he(R.name,e),onRename:e=>ae(R.name,e),onDelete:()=>ce(R.name,dt(D,R.name).length),onRebuildLinks:()=>oe(R.name),onAddDevices:()=>G(R.name)},R.name),O.length===0&&!B&&s(`p`,{className:`text-xs text-foreground-subtle`,children:e(`locations.noLocationsYetAddIngresso`,`No locations yet. Add Ingresso, Salone, Cucina…`)}),s(et,{open:W!==null,title:e(`locations.room.addDialogTitle`,{room:W??``}),items:K,listState:m?`pending`:`answered`,lockedIds:W===null?[]:(k.find(e=>e.name===W)?.members??[]).map(e=>e.id),lockedNote:e(`locations.room.alreadyHere`),suggestions:{heading:e(`locations.room.suggestedUnassigned`),ids:F.map(e=>e.id)},busy:v.isPending,onConfirm:e=>{W!==null&&U(e,W),G(null)},onClose:()=>G(null)})]}),be=i(`div`,{className:`flex flex-col gap-3`,"data-testid":`camera-links-tab`,children:[q,s(tt,{room:z,cameras:z===null?[]:dt(D,z).filter(e=>e.isCamera),fleet:D})]});return s(Je,{icon:te,title:e(`locations.locations`,`Locations`),subtitle:e(`locations.roomsAndAreasOfThe`,`Rooms and areas of the site. Assign any device here — storage disks are under Data → Storage.`),defaultSection:`locations`,sectionsLabel:`Locations sections`,actions:N===`zones`?s(Ot,{busy:S.isPending,onCreate:e=>S.mutateAsync({name:e})}):s(Dt,{busy:g.isPending,onCreate:ie}),sections:[{id:`locations`,label:e(`locations.locations`,`Locations`),content:ve},{id:`camera-links`,label:e(`locations.cameraLinks`,`Camera links`),content:be},{id:`zones`,label:e(`locations.zones`,`Zones`),content:s(Et,{zones:H,busy:V,onRename:(e,t)=>w.mutateAsync({from:e,to:t}),onDelete:le,onPickIcon:(e,t)=>S.mutateAsync({name:e,icon:t})})}]})}export{Rt as LocationsPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./browser-BHo8W_uH.js","./rolldown-runtime-Cyuzqnbw.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{t}from"./vite-preload-helper-kNaey6uv.js";import{$ as n,B as r,G as i,J as a,S as o,a as s,b as c,q as l,t as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{$t as f,Fn as p,It as m,Nt as h,Q as g,Rr as _,Wi as v,Zr as y,hi as b,lr as x,mi as S,mr as C,oa as w,or as T,ot as E,rr as D}from"./player-overlays-Fx6RE6kI.js";import{Xn as O,Yn as k}from"./client-yfOXPkcm.js";import{s as A}from"./video-BRgeujOO.js";import{t as j}from"./key-round-CjE9GF4T.js";import{t as ee}from"./monitor-smartphone-ASdELIYw.js";import{t as te}from"./unlink-YiKNaJO_.js";import{$ as ne,$n as M,Ao as N,En as P,Hn as F,Kn as re,Lt as ie,Mo as ae,Su as I,Tn as oe,Zl as se}from"./src-AhVPNkCn.js";import{t as ce}from"./i18n-B1bxeya5.js";import{t as L}from"./useTranslation-D3Is_4B6.js";import"./mount-CRpYde_B.js";import{C as R,S as z,V as B,Z as V,b as H,x as U}from"./index-CcAR8Rlk.js";import{t as W}from"./AdminPage--m3xHpjx.js";import{N as G,P as le,_ as K,a as ue,g as de,k as fe,r as pe,t as me,v as he}from"./SessionsList-DrSkZMrj.js";n();function ge({value:n,size:i=192}){let{t:s}=L(),[c,l]=a(null),[u,f]=a(null);if(r(()=>{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`){f(`qrcode.create() unavailable in installed version`);return}try{let e=t(n,{errorCorrectionLevel:`M`});r||l(e)}catch(e){r||f(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{r||f(`qrcode library not installed`)}),()=>{r=!0}},[n]),u)return d(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:s(`users.totpQrCode.qrRenderingUnavailableUseThe`,`QR rendering unavailable — use the secret below.`)});if(!c)return d(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:s(`users.totpQrCode.generating`,`Generating…`)});let p=c.modules.size,m=i/p,h=[];for(let e=0;e<p;e++)for(let t=0;t<p;t++)c.modules.data[e*p+t]&&h.push(d(`rect`,{x:t*m,y:e*m,width:m,height:m,fill:`currentColor`},`${t}-${e}`));return o(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[d(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),h]})}var _e=`${k}/connect`,q={public:0,mesh:1,lan:2,"lan-ipv6":3};function ve(e){switch(e.kind){case`public`:return e.interfaceKind===`vpn`?`mesh`:`public`;case`lan-ipv4`:return`lan`;case`lan-ipv6`:return`lan-ipv6`;case`custom`:return`public`;case`loopback`:case`app-link`:return null}}function J(e){return O(e)}function ye(e){return e.startsWith(`https://`)}function be(e){let t=e.flatMap(e=>{let t=ve(e),n=J(e.baseUrl);return t===null||n===null?[]:[{endpoint:e,tier:t,origin:n}]}).toSorted((e,t)=>q[e.tier]-q[t.tier]||Number(t.endpoint.plausible)-Number(e.endpoint.plausible)||e.endpoint.priority-t.endpoint.priority),n=new Set;return t.flatMap(({endpoint:e,tier:t,origin:r})=>n.has(r)?[]:(n.add(r),[{origin:r,label:e.label,tier:t,secure:ye(r),plausible:e.plausible}]))}function xe(e,t,n=null){for(let r of[t,n]){if(r===null)continue;let t=J(r),n=e.find(e=>e.origin===t);if(n!==void 0)return n}return e[0]??null}function Se(e){let t=new URL(_e);return t.searchParams.set(`hub`,e),t.toString()}n();var Ce=176,Y={scheme:`https`};function we(){let{t:e}=L(),t=ae(Y),n=N(Y).data?.roles.publicEndpoint.resolved??null;return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(f,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`connectPhone.title`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[d(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`connectPhone.description`)}),t.isPending?o(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[d(T,{className:`h-3.5 w-3.5 animate-spin`}),e(`connectPhone.loading`)]}):t.isError?o(`div`,{className:`flex items-start gap-2 text-[11px] text-danger`,children:[d(h,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),o(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[d(`div`,{className:`break-words`,children:e(`connectPhone.error`,{message:t.error.message})}),d(F,{size:`sm`,variant:`ghost`,onClick:()=>void t.refetch(),children:e(`connectPhone.retry`)})]})]}):d(Te,{candidates:be(t.data.endpoints),preferredOrigin:n})]})]})}function Te({candidates:e,preferredOrigin:t}){let{t:n}=L(),[r,s]=a(null),c=xe(e,r,t),l=i(()=>c?Se(c.origin):null,[c]);if(c===null||l===null)return d(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`connectPhone.empty`)});let u=e=>n(`connectPhone.tier.${e}`),f=e.map(e=>({value:e.origin,label:`${u(e.tier)} — ${e.origin}`}));return o(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:[d(oe,{value:l,size:Ce,alt:n(`connectPhone.qrAlt`),className:`self-start`}),o(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[o(`label`,{className:`block space-y-1`,children:[d(`span`,{className:`text-[11px] font-medium text-foreground`,children:n(`connectPhone.addressLabel`)}),d(se,{value:c.origin,options:f,onChange:e=>s(e.target.value)}),o(`span`,{className:`block text-[10px] text-foreground-subtle`,children:[u(c.tier),` · `,c.label]})]}),!c.secure&&d(X,{text:n(`connectPhone.insecure`)}),!c.plausible&&d(X,{text:n(`connectPhone.implausible`)}),o(`div`,{className:`space-y-1`,children:[d(`span`,{className:`text-[11px] font-medium text-foreground`,children:n(`connectPhone.linkLabel`)}),o(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[d(`code`,{className:`flex-1 min-w-0 font-mono text-[11px] text-foreground break-all select-all`,children:l}),d(ie,{value:l,srLabel:n(`connectPhone.linkLabel`)})]})]}),d(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`connectPhone.signInHint`)})]})]})}function X({text:e}){return o(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-1.5 text-[11px] text-foreground`,children:[d(h,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),d(`span`,{children:e})]})}n();function Ee(e){return new Date(e).toLocaleDateString()}function De(){let{t:e}=L(),t=M(),n=I.useUtils(),i=I.auth.listLinkableProviders.useQuery(),s=I.auth.listOwnExternalIdentities.useQuery(),[c,u]=a(null),[f,p]=a(()=>R(window.location.search)),m=l(null),h=K(`Linking a sign-in account`),_=l(null);r(()=>()=>_.current?.(),[]);let[v,y]=a(null);r(()=>{if(f===null)return;let e=new URL(window.location.href);e.searchParams.delete(`linked`),e.searchParams.delete(`linkError`),window.history.replaceState({},``,e.pathname+e.search+e.hash)},[f]);let C=I.auth.beginExternalLink.useMutation({onSuccess:({url:e})=>{let t=m.current;if(m.current=null,t===null||t.closed){window.location.assign(e);return}let r=e=>{y(null),p(R(`?${e}`)),n.auth.listOwnExternalIdentities.invalidate()};_.current?.(),_.current=U(t,{onReturn:e=>{e.target===`profile`&&r(e.query)},onDone:e=>{e.target===`profile`&&r(e.query)},onClosed:()=>{_.current?.(),_.current=null,n.auth.listOwnExternalIdentities.invalidate()}}),t.location.href=g(z(e))},onError:e=>{m.current?.close(),m.current=null,y(null),u(e.message)}}),w=I.auth.unlinkOwnExternalIdentity.useMutation({onSuccess:()=>void n.auth.listOwnExternalIdentities.invalidate(),onError:e=>u(e.message)}),E=i.data??[],D=s.data??[],O=v!==null&&D.some(e=>e.provider===v);if(r(()=>{!O||v===null||(y(null),p({kind:`linked`,provider:v}))},[O,v]),E.length===0&&D.length===0)return null;let k=new Set(D.map(e=>e.provider)),A=e=>E.find(t=>t.provider===e)?.label??e,j=async(n,r)=>{await t({title:e(`users.linkedSignInsSection.unlinkSignInAccount`,`Unlink sign-in account`),message:e(`users.linkedSignInsSection.stopSigningInWithThis`,`Stop signing in with this {{label}} account?`,{label:r}),confirmLabel:e(`users.linkedSignInsSection.unlink`,`Unlink`),variant:`danger`})&&(u(null),w.mutate({provider:n.provider,subject:n.subject}))};return o(`div`,{"data-testid":`linked-sign-ins`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[h.dialog,o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(x,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`users.linkedSignInsSection.linkedSignInAccounts`,`Linked sign-in accounts`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[d(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`users.linkedSignInsSection.signInWithAnExternal`,`Sign in with an external account instead of your password. Only accounts you link here can sign you in; your two-factor authentication still applies.`)}),f?.kind===`linked`&&o(`div`,{className:`flex items-center gap-2 rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2 text-xs text-foreground`,children:[d(S,{className:`h-3.5 w-3.5 text-emerald-500 shrink-0`}),e(`users.linkedSignIns.linkedNotice`,{provider:A(f.provider)})]}),(f?.kind===`error`||c)&&o(`div`,{className:`flex items-center gap-2 rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[d(b,{className:`h-3.5 w-3.5 shrink-0`}),c??(f?.kind===`error`?f.message:``)]}),D.length>0&&d(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:D.map(t=>{let n=t.providerLabel??t.provider;return o(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[o(`div`,{className:`flex-1 min-w-0`,children:[o(`div`,{className:`font-medium text-foreground truncate`,children:[n,!t.available&&d(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:e(`users.linkedSignInsSection.providerUnavailable`,`provider unavailable`)})]}),d(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:e(`users.linkedSignIns.linkedOn`,{label:t.label??t.subject,date:Ee(t.linkedAt)})})]}),o(`button`,{onClick:()=>void j(t,n),disabled:w.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[d(te,{className:`h-3 w-3`}),e(`users.linkedSignInsSection.unlink`,`Unlink`)]})]},`${t.provider}|${t.subject}`)})}),d(`div`,{className:`flex flex-wrap gap-2`,children:E.filter(e=>!k.has(e.provider)).map(t=>o(`button`,{onClick:()=>{u(null),p(null),h.requestProof().then(e=>{e!==null&&(m.current=H(null),y(m.current===null?null:t.provider),C.mutate({provider:t.provider,reauthToken:e}))})},disabled:C.isPending,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[C.isPending&&C.variables?.provider===t.provider?d(T,{className:`h-3 w-3 animate-spin`}):d(x,{className:`h-3 w-3`}),e(`users.linkedSignIns.link`,{provider:t.label})]},t.provider))})]})]})}n();function Z(e){return e.message.length>0?e.message:ce.t(`auth.authAuditSection.requestFailed`)}function Oe(){let{t:e}=L(),{logout:t}=B(),n=M(),r=I.useUtils(),i=I.auth.listOwnSessions.useQuery(),[s,c]=a(null),l=I.auth.revokeOwnSession.useMutation({onSuccess:()=>void r.auth.listOwnSessions.invalidate(),onError:e=>c(`Sign out failed: ${Z(e)}`)}),u=I.auth.logout.useMutation({onSuccess:()=>t(),onError:e=>c(`Sign out failed: ${Z(e)}`)}),f=async t=>{await n({title:e(`auth.mySessionsSection.signOutThisSession`,`Sign out this session`),message:e(`auth.mySessionsSection.willHaveToSignIn`,`{{label}} will have to sign in again.`,{label:he(t.client).label}),confirmLabel:e(`auth.mySessionsSection.signOut`,`Sign out`),variant:`danger`})&&(c(null),l.mutate({id:t.id}))},p=async()=>{await n({title:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),message:e(`auth.mySessionsSection.everySessionOfYourAccount`,`Every session of your account ends, this browser included: you will be signed out here too and every device has to sign in again.`),confirmLabel:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),variant:`danger`})&&(c(null),u.mutate({everywhere:!0}))};return o(`div`,{"data-testid":`my-sessions`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(ee,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`auth.mySessionsSection.activeSessions`,`Active sessions`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[d(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`auth.mySessionsSection.theBrowsersAndAppsSigned`,`The browsers and apps signed in to your account. Signing one out ends it at once.`)}),s!==null&&d(`div`,{className:`text-[11px] text-danger`,children:s}),d(me,{sessions:i.data??[],isLoading:i.isLoading,loadError:i.isError?i.error?.message??e(`auth.authAuditSection.requestFailed`):null,emptyText:`No active sessions.`,onRevoke:e=>void f(e),revokingId:l.isPending?l.variables?.id??null:null}),d(`div`,{className:`flex justify-end`,children:o(`button`,{onClick:()=>void p(),disabled:u.isPending,className:`inline-flex items-center gap-1.5 rounded border border-danger/40 px-2.5 py-1 text-[11px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,children:[u.isPending?d(T,{className:`h-3 w-3 animate-spin`}):d(A,{className:`h-3 w-3`}),e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`)]})})]})]})}n();var Q=`You`;function ke(){let{t:e}=L(),t=M(),n=I.useUtils(),r=I.auth.listOwnDeviceCredentials.useQuery(),[o,s]=a(null),c=I.auth.revokeOwnDeviceCredential.useMutation({onSuccess:e=>{e.revoked||s(`That device could not be revoked - it may already be gone.`),n.auth.listOwnDeviceCredentials.invalidate()},onError:e=>s(`Revoke failed: ${e.message}`)}),l=i(()=>(r.data??[]).map(e=>pe(e,Q)),[r.data]),u=async n=>{await t({title:e(`certificates.myDevicesSection.revoke`,`Revoke "{{name}}"?`,{name:n.name}),message:e(`certificates.myDevicesSection.theDeviceStopsSigningIn`,`The device stops signing in at once and its open sessions end. To use it again you have to pair it anew. This cannot be undone.`),confirmLabel:e(`certificates.myDevicesSection.revoke2`,`Revoke`),variant:`danger`})&&(s(null),c.mutate({id:n.id}))},p={label:e(`certificates.myDevicesSection.revoke2`,`Revoke`),icon:v,isAvailable:ue,onRun:e=>void u(e),busyId:c.isPending?c.variables?.id??null:null,disabled:c.isPending};return d(G,{id:`my-devices`,title:e(`certificates.myDevicesSection.myDevices`,`My devices`),icon:f,description:e(`certificates.myDevicesSection.phonesThatStaySignedIn`,`Phones that stay signed in to your account with a certificate. If one is lost, revoke it here and it is signed out at once.`),notice:le(o),onDismissNotice:()=>s(null),children:d(fe,{rows:l,label:e(`certificates.devicesCard.label`),isLoading:r.isPending,loadError:r.error===null?null:r.error.message||`Request failed`,emptyText:`No devices are signed in with a certificate.`,hideOwner:!0,expiresNone:`—`,action:p})})}n();var Ae={view:{icon:_,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:p,cls:`bg-primary/15 text-primary`},delete:{icon:m,cls:`bg-danger/15 text-danger`}};function je(){let{t:e}=L(),t=w(),{user:n,logout:r}=B();if(!n)return d(W,{children:d(`div`,{className:`text-xs text-foreground-subtle`,children:e(`systemPage.myAccess.notSignedIn`,`Not signed in.`)})});let i=n.isAdmin,a=n.scopes??[];return o(W,{children:[o(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[d(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:n.username.slice(0,1).toUpperCase()}),o(`div`,{className:`flex-1 min-w-0`,children:[d(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:n.username}),o(`div`,{className:`text-[11px] text-foreground-subtle`,children:[i?e(`systemPage.myAccess.administrator`,`Administrator`):e(`systemPage.myAccess.user`,`User`),` `,d(V,{i18nKey:`systemPage.myAccess.sessionId`,values:{id:n.id.slice(0,8)},components:{mono:d(`span`,{className:`font-mono`})}})]})]})]}),i&&o(`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:[d(C,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),o(`div`,{children:[d(`div`,{className:`font-semibold text-foreground`,children:e(`systemPage.myAccess.unrestrictedAccess`,`Unrestricted access`)}),d(`p`,{className:`text-foreground-subtle mt-0.5`,children:e(`systemPage.myAccess.adminSessionsBypassThePer`,`Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below.`)})]})]}),d(Me,{}),d(Ne,{username:n.username}),d(Pe,{}),d(De,{}),d(de,{}),d(Oe,{}),d(ke,{}),d(we,{}),a.length>0&&o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`px-4 py-2 border-b border-border`,children:[d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`systemPage.myAccess.grantedScopes`,`Granted scopes`)}),d(`div`,{className:`text-[10px] text-foreground-subtle`,children:e(`systemPage.myAccess.bakedIntoYourSessionToken`,`Baked into your session token at login; sign out + back in to refresh after changes.`)})]}),o(`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:[d(`div`,{children:e(`systemPage.myAccess.type`,`Type`)}),d(`div`,{children:e(`systemPage.myAccess.target`,`Target`)}),d(`div`,{children:e(`systemPage.myAccess.access`,`Access`)})]}),d(`ul`,{className:`divide-y divide-border`,children:a.map((n,r)=>o(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[d(`span`,{className:`font-mono text-foreground-subtle`,children:n.type}),d(`span`,{className:`font-mono text-foreground`,children:n.type===`device`?ne(n.selector,t):n.target}),d(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(t=>{let r=n.access.includes(t),{icon:i,cls:a}=Ae[t];return o(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${r?a:`bg-transparent text-foreground-subtle/40 line-through`}`,title:r?e(`systemPage.myAccess.can`,`Can {{a}}`,{a:t}):e(`systemPage.myAccess.cannot`,`Cannot {{a}}`,{a:t}),children:[d(i,{className:`h-3 w-3`}),t]},t)})})]},r))})]}),d(`div`,{className:`flex justify-end`,children:o(`button`,{onClick:r,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:[d(A,{className:`h-3 w-3`}),e(`systemPage.myAccess.signOut`,`Sign out`)]})})]})}function Me(){let{t:e}=L(),t=E(),[n,r]=a(``),[i,s]=a(``),[c,l]=a(``),[f,p]=a(null),m=u({mutationFn:e=>t.changeOwnPassword(e),onSuccess:()=>{p({kind:`success`,msg:`Password updated.`}),r(``),s(``),l(``)},onError:e=>{p({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),h=i.length>0&&c.length>0&&i!==c,g=i.length>0&&i.length<8,_=n.length>=1&&i.length>=8&&i===c;return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(j,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`systemPage.myAccess.changePassword`,`Change password`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[d($,{label:e(`systemPage.myAccess.currentPassword`,`Current password`),value:n,onChange:r,autoComplete:`current-password`}),d($,{label:e(`systemPage.myAccess.newPassword`,`New password`),value:i,onChange:s,autoComplete:`new-password`,hint:e(`systemPage.myAccess.atLeast8Characters`,`At least 8 characters.`)}),d($,{label:e(`systemPage.myAccess.confirmNewPassword`,`Confirm new password`),value:c,onChange:l,autoComplete:`new-password`}),(h||g)&&d(`div`,{className:`text-[11px] text-danger`,children:h?e(`systemPage.myAccess.passwordsDoNotMatch`,`Passwords do not match.`):e(`systemPage.myAccess.newPasswordMustBeAt`,`New password must be at least 8 characters.`)}),f&&o(`div`,{className:`text-[11px] flex items-center gap-1 ${f.kind===`success`?`text-emerald-500`:`text-danger`}`,children:[f.kind===`success`?d(S,{className:`h-3 w-3`}):d(b,{className:`h-3 w-3`}),f.msg]}),d(`div`,{className:`flex justify-end`,children:o(`button`,{onClick:()=>{p(null),m.mutate({currentPassword:n,newPassword:i})},disabled:!_||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?d(T,{className:`h-3 w-3 animate-spin`}):d(D,{className:`h-3 w-3`}),e(`systemPage.myAccess.updatePassword`,`Update password`)]})})]})]})}function $({label:e,value:t,onChange:n,autoComplete:r,hint:i}){return o(`div`,{className:`space-y-1`,children:[d(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),d(`input`,{type:`password`,value:t,onChange:e=>n(e.target.value),autoComplete:r,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),i&&d(`div`,{className:`text-[10px] text-foreground-subtle`,children:i})]})}function Ne({username:e}){let{t}=L(),n=E(),l=s({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>n.getOwnTotpStatus()}),p=l.data,[m,h]=a(null),[g,_]=a(``),[v,x]=a(null),[C,w]=a(!1),D=u({mutationFn:()=>n.setupOwnTotp(),onSuccess:e=>{h({secret:e.secret,otpauthUrl:e.otpauthUrl}),_(``),x(null)},onError:e=>x(e instanceof Error?e.message:`Setup failed`)}),O=u({mutationFn:e=>n.confirmOwnTotp(e),onSuccess:()=>{h(null),_(``),x(null),l.refetch()},onError:e=>x(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),k=K(`Turning off two-factor authentication`),A=u({mutationFn:async()=>{let e=await k.requestProof();return e===null?null:n.disableOwnTotp({reauthToken:e})},onSuccess:()=>{x(null),l.refetch()},onError:e=>x(e instanceof Error?e.message:`Disable failed`)});r(()=>{if(!C)return;let e=setTimeout(()=>w(!1),1500);return()=>clearTimeout(e)},[C]);let j=i(()=>l.isLoading?`loading`:m?`setup_in_progress`:p?.enabled?`enrolled`:`not_enrolled`,[l.isLoading,p?.enabled,m]);return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[k.dialog,o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(f,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.twoFactorAuthentication`,`Two-factor authentication`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[j===`loading`&&o(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[d(T,{className:`h-3.5 w-3.5 animate-spin`}),t(`systemPage.myAccess.checkingStatus`,`Checking status…`)]}),j===`not_enrolled`&&o(c,{children:[d(`div`,{className:`text-xs text-foreground-subtle`,children:t(`systemPage.myAccess.2faIsnTActiveOn`,`2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login.`)}),d(`div`,{className:`flex justify-end`,children:o(`button`,{onClick:()=>{x(null),D.mutate()},disabled:D.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:[D.isPending?d(T,{className:`h-3 w-3 animate-spin`}):d(f,{className:`h-3 w-3`}),t(`systemPage.myAccess.enable2fa`,`Enable 2FA`)]})})]}),j===`setup_in_progress`&&m&&o(c,{children:[d(`div`,{className:`text-[11px] text-foreground-subtle`,children:d(V,{i18nKey:`systemPage.myAccess.scanQr`,values:{username:e},components:{mono:d(`span`,{className:`font-mono`})}})}),o(`div`,{className:`flex flex-col items-center gap-3`,children:[d(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:d(ge,{value:m.otpauthUrl,size:180})}),o(`div`,{className:`w-full`,children:[d(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:t(`systemPage.myAccess.secretManualEntry`,`Secret (manual entry)`)}),o(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[d(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:m.secret}),o(`button`,{onClick:()=>{m&&navigator.clipboard.writeText(m.secret).then(()=>w(!0))},className:`inline-flex items-center gap-1 text-[10px] text-foreground-subtle hover:text-foreground`,children:[C?d(S,{className:`h-3 w-3 text-emerald-500`}):d(y,{className:`h-3 w-3`}),C?t(`systemPage.myAccess.copied`,`Copied`):t(`common.copy`,`Copy`)]})]})]})]}),o(`div`,{className:`space-y-1`,children:[d(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),d(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:g,onChange:e=>_(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary`})]}),v&&o(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[d(b,{className:`h-3 w-3`}),v]}),o(`div`,{className:`flex justify-end gap-2`,children:[d(`button`,{onClick:()=>{h(null),x(null),_(``)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:t(`common.cancel`,`Cancel`)}),o(`button`,{onClick:()=>{x(null),O.mutate({code:g})},disabled:O.isPending||g.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:[O.isPending?d(T,{className:`h-3 w-3 animate-spin`}):d(S,{className:`h-3 w-3`}),t(`common.confirm`,`Confirm`)]})]})]}),j===`enrolled`&&p&&o(c,{children:[o(`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:[d(S,{className:`h-4 w-4 mt-0.5 text-emerald-500 shrink-0`}),o(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[d(`div`,{className:`font-medium`,children:t(`systemPage.myAccess.2faIsActive`,`2FA is active`)}),d(`div`,{className:`text-foreground-subtle`,children:t(`common.enrolledOn`,{when:p.confirmedAt?new Date(p.confirmedAt).toLocaleString():`—`})})]})]}),v&&o(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[d(b,{className:`h-3 w-3`}),v]}),d(`div`,{className:`flex justify-end`,children:o(`button`,{onClick:()=>{x(null),A.mutate()},disabled:A.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:[A.isPending?d(T,{className:`h-3 w-3 animate-spin`}):d(f,{className:`h-3 w-3`}),t(`systemPage.myAccess.disable2fa`,`Disable 2FA`)]})})]})]})]})}function Pe(){return re(`auth-webauthn/passkey-enrollment`)?d(P,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}export{je as MyAccessPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,B as t,G as n,J as r,L as i,S as a,b as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{An as l,Br as u,D as d,It as f,L as p,Nt as m,Si as h,Yt as g,Z as _,Zr as v,Zt as y,bn as b,dn as x,dt as S,hn as ee,ht as C,kn as w,on as T,or as E,ot as D,rr as O,yn as te,zn as k}from"./player-overlays-Fx6RE6kI.js";import{Jn as ne,Wn as re,qn as ie,vn as A}from"./client-yfOXPkcm.js";import{t as j}from"./boxes-U2BARjlG.js";import{l as M,s as ae}from"./video-BRgeujOO.js";import{t as oe}from"./log-in-D4y0eEu8.js";import{Al as se,Ao as ce,Bo as le,Bt as ue,Go as de,Gt as fe,Hn as N,Ht as pe,In as me,Io as he,Ko as ge,Lo as _e,Or as P,Po as ve,Qo as ye,Uo as be,Ut as xe,Wo as Se,Xo as Ce,Zl as we,Zo as Te,_a as Ee,jo as De,ko as Oe,kr as F,nu as ke,qo as Ae,sn as je,sr as I,zn as Me,zo as Ne}from"./src-AhVPNkCn.js";import{t as L}from"./i18n-B1bxeya5.js";import{t as R}from"./useTranslation-D3Is_4B6.js";import"./mount-CRpYde_B.js";import{$ as Pe,Q as Fe,T as Ie,a as z,i as B,nt as Le}from"./index-CcAR8Rlk.js";import{t as Re}from"./AdminSectionedPage-D5J86Kfp.js";import{t as V}from"./AdminPage--m3xHpjx.js";import{t as ze}from"./NodeAddonsSettingsPanel-BxeQZ-hu.js";import{n as H,r as Be,t as U}from"./IntegrationHub-BRMnV56J.js";import{n as W,t as G}from"./addon-display-names-BkwMrExv.js";e();var K=5e3,q=`network-access`,Ve={connected:!1,endpoint:null};function He(){let{t:e}=R(),t=s(),i=F({capName:`network-access`},{refetchInterval:K}),a=P(void 0,{refetchInterval:K}),o=n(()=>G(a.data??[]),[a.data]),l=n(()=>(i.data??[]).map(e=>({addonId:e.addonId,displayName:o.get(e.addonId)??e.addonId,isActive:e.isActive})),[i.data,o]),[u,d]=r(null),[f,p]=r({}),m=(e,n)=>{let r=n?.addonId;t.invalidateQueries({queryKey:[[`networkAccess`,`getStatus`],{input:{addonId:r},type:`query`}]}),d(null),p(e=>{if(r===void 0||!(r in e))return e;let t={...e};return delete t[r],t})},h=(e,t)=>{d(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=Te({onSuccess:m,onError:h}),_=ye({onSuccess:m,onError:h}),v=[{id:q,label:e(`system.remoteAccess.remoteAccess`,`Remote access`),install:{capability:q,label:e(`system.remoteAccess.addTunnel`,`Add tunnel`)},entries:l.map(e=>({id:e.addonId,name:e.displayName,fallbackIcon:M,...W(e.isActive),render:()=>c(H,{addonId:e.addonId,displayName:e.displayName,capName:q,isActive:e.isActive,badges:c(We,{addonId:e.addonId}),error:f[e.addonId]??null,primaryAction:c(Ge,{addonId:e.addonId,busyId:u,onStart:e=>{d(e),g.mutate({addonId:e})},onStop:e=>{d(e),_.mutate({addonId:e})}})})}))}];return c(U,{embedded:!0,icon:M,title:e(`system.remoteAccess.remoteAccess2`,`Remote Access`),subtitle:e(`system.remoteAccess.publicFacingTunnelsThatExpose`,`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …).`),groups:v,isLoading:i.isLoading,emptyTitle:e(`system.remoteAccess.noRemoteAccessProvidersInstalled`,`No remote-access providers installed`),emptyDescription:e(`system.remoteAccess.installATunnelAddonE`,`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`)})}function Ue(e){let{data:t}=Ce({addonId:e},{refetchInterval:K,retry:!1}),n=t?re.safeParse(t):null;return n?.success?n.data:Ve}function We({addonId:e}){let{t}=R(),n=Ue(e);return a(o,{children:[c(I,{variant:n.connected?`success`:`default`,className:Be,children:n.connected?t(`system.remoteAccess.connected`,`Connected`):t(`system.remoteAccess.disconnected`,`Disconnected`)}),n.endpoint&&a(`a`,{href:n.endpoint.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-w-0 items-center gap-1 break-all text-[11px] text-success hover:underline`,children:[c(u,{className:`h-3 w-3`}),n.endpoint.url]})]})}function Ge({addonId:e,busyId:t,onStart:n,onStop:r}){let{t:i}=R(),o=Ue(e),s=t===e;return o.connected?a(N,{size:`sm`,variant:`secondary`,disabled:s,onClick:()=>r(e),children:[s?c(E,{className:`h-3 w-3 animate-spin`}):c(g,{className:`h-3 w-3`}),i(`system.remoteAccess.stop`,`Stop`)]}):a(N,{size:`sm`,variant:`primary`,disabled:s,onClick:()=>n(e),children:[s?c(E,{className:`h-3 w-3 animate-spin`}):c(l,{className:`h-3 w-3`}),i(`system.remoteAccess.start`,`Start`)]})}e();var Ke=3e4,J=`turn-provider`;function qe(e){let t=[];for(let n of e)typeof n.urls==`string`?t.push(n.urls):t.push(...n.urls);return t}function Je(){let{t:e}=R(),t=F({capName:`turn-provider`},{refetchInterval:Ke}),r=P(void 0,{refetchInterval:Ke}),i=se(),o=i.data??[],s=n(()=>G(r.data??[]),[r.data]),l=n(()=>(t.data??[]).map(e=>({addonId:e.addonId,displayName:s.get(e.addonId)??e.addonId,isActive:e.isActive})),[t.data,s]),u=[{id:J,label:e(`system.turnServers.turnProviders`,`TURN providers`),install:{capability:J,label:e(`system.turnServers.addProvider`,`Add provider`)},entries:l.map(t=>({id:t.addonId,name:t.displayName,fallbackIcon:k,...W(t.isActive),render:()=>c(H,{addonId:t.addonId,displayName:t.displayName,capName:J,isActive:t.isActive,panels:[{id:`ice-servers`,title:e(`system.turnServers.discoveredIceServers`,`Discovered ICE servers`),icon:k,content:c(Ye,{addonId:t.addonId,enabled:t.isActive})}]})}))}];return c(U,{embedded:!0,icon:k,title:e(`system.turnServers.turnServers`,`TURN Servers`),subtitle:e(`system.turnServers.iceServersUsedForWebrtc`,`ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.`),groups:u,isLoading:t.isLoading,emptyTitle:e(`system.turnServers.noTurnProvidersInstalled`,`No TURN providers installed`),emptyDescription:e(`system.turnServers.installATurnAddonE`,`Install a TURN addon (e.g. @camstack/addon-cloudflare) to enable WebRTC behind restrictive NATs.`),trailing:c(xe,{headingId:`turn-combined-ice`,title:e(`system.turnServers.combinedIceServerListAll`,`Combined ICE server list — all enabled providers`),icon:k,actions:c(N,{size:`sm`,variant:`secondary`,onClick:()=>i.refetch(),disabled:i.isFetching,children:e(`common.refresh`,`Refresh`)}),children:c(`div`,{className:d,children:o.length===0?c(`div`,{className:`text-xs text-foreground-subtle`,children:e(`system.turnServers.noServersFromEnabledProviders`,`No servers from enabled providers.`)}):c(`div`,{className:`flex flex-col gap-3`,children:o.map((e,t)=>{let n=Array.isArray(e.urls)?e.urls:[e.urls];return a(`div`,{className:`rounded border border-border bg-surface`,children:[(e.username||e.credential)&&a(`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&&a(`span`,{children:[c(`span`,{className:`text-foreground-subtle`,children:`user:`}),` `,c(`span`,{className:`text-foreground`,children:e.username})]}),e.credential&&a(`span`,{children:[c(`span`,{className:`text-foreground-subtle`,children:`credential:`}),` `,c(`span`,{className:`text-foreground`,children:`••••••••`})]})]}),c(`ul`,{className:`divide-y divide-border`,children:n.map(e=>c(`li`,{className:`px-3 py-1.5 font-mono text-xs text-foreground break-all`,children:e},e))})]},t)})})})})})}function Ye({addonId:e,enabled:t}){let r=se({addonId:e},{enabled:t,retry:!1}),i=n(()=>qe(r.data??[]),[r.data]),a=t?r.isLoading?`Loading…`:i.length===0?`This provider returned no servers.`:null:`Disabled — enable the provider to fetch its servers.`;return c(`div`,{className:`rounded-lg border border-border bg-surface p-2 sm:p-3`,children:a===null?c(`div`,{className:`flex flex-wrap gap-1`,children:i.map(e=>c(`span`,{className:`inline-block break-all rounded bg-foreground-subtle/10 px-1.5 py-0.5 font-mono text-[10px] text-foreground`,children:e},e))}):c(`div`,{className:`text-xs text-foreground-subtle`,children:a})})}e();var Xe={lan:k,wifi:C,docker:j,vpn:O,loopback:x,other:x},Ze={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},Qe=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function $e(e){let{t}=R(),{interfaces:r,disabled:i,hideLoopback:o,ipv4Only:s,emptyMessage:l}=e,u=n(()=>r.filter(e=>!(o&&e.kind===`loopback`||s&&e.family!==`IPv4`)),[r,o,s]),d=n(()=>{let e=new Map;for(let t of u){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return Qe.filter(t=>e.has(t)).map(t=>({kind:t,items:e.get(t)}))},[u]),f=t=>e.mode===`single`?e.value===t:e.value.includes(t),p=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 u.length===0?c(`div`,{className:`text-xs text-foreground-subtle italic`,children:l??t(`shared.addressSelector.noAddressesAvailable`,`No addresses available.`)}):c(`div`,{className:`flex flex-col gap-3`,children:d.map(({kind:n,items:r})=>a(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[a(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[c(Xe[n]??x,{className:`h-3.5 w-3.5 text-foreground-subtle`}),c(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:Ze[n]??n}),a(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,r.length]})]}),c(`ul`,{className:`divide-y divide-border`,children:r.map(n=>{let r=f(n.address),o=n.kind===`loopback`,s=!n.plausible&&!o;return a(`li`,{className:`flex items-center gap-3 px-3 py-2 ${o?`opacity-60 cursor-not-allowed`:i?`opacity-60`:s?`cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]`:`cursor-pointer hover:bg-surface-hover/30`}`,onClick:()=>p(n),children:[c(`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&&c(h,{className:`h-3 w-3`})}),a(`div`,{className:`flex-1 min-w-0 ${s?`text-foreground-subtle`:``}`,children:[a(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[c(`span`,{className:`font-mono text-xs font-semibold ${s?`text-foreground-subtle`:`text-foreground`}`,children:n.name}),c(`span`,{className:`text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-mono`,children:n.family}),n.preferred&&c(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:t(`shared.addressSelector.autoPreferred`,`Auto-preferred`)}),o&&c(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:t(`shared.addressSelector.alwaysIncluded`,`Always included`)}),s&&a(`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:n.plausibleReason||void 0,children:[c(m,{className:`h-2.5 w-2.5`}),t(`shared.addressSelector.unlikelyUsable`,`Unlikely usable`)]})]}),a(`div`,{className:`text-xs text-foreground-subtle mt-0.5 font-mono break-all`,children:[n.address,n.cidr&&n.cidr!==n.address?` (${n.cidr})`:``]})]})]},`${n.name}-${n.family}-${n.address}`)})})]},n))})}var Y=[{role:`appConnections`,get title(){return L.t(`helpers.addressTableModel.appConnectionsTitle`)},single:!1,get help(){return L.t(`helpers.addressTableModel.appConnectionsHelp`)}},{role:`notificationTaps`,get title(){return L.t(`helpers.addressTableModel.notificationTapsTitle`)},single:!0,get help(){return L.t(`helpers.addressTableModel.notificationTapsHelp`)}},{role:`publicEndpoint`,get title(){return L.t(`helpers.addressTableModel.publicEndpointTitle`)},single:!0,get help(){return L.t(`helpers.addressTableModel.publicEndpointHelp`)}},{role:`internal`,get title(){return L.t(`helpers.addressTableModel.internalTitle`)},single:!0,get help(){return L.t(`helpers.addressTableModel.internalHelp`)}}],et=`A role with nothing ticked is automatic. Add a custom address when the hub is reached at an address it cannot see itself (NAT, reverse proxy, VPN, Docker bridge).`;function X(e,t){return e.inUse.includes(t)}function tt(e,t){if(!e.eligible.includes(t))return{kind:`none`};if(e.kind===`app-link`)return X(e,t)?{kind:`none`}:{kind:`set`,input:{role:t,baseUrl:null,enabled:!0}};if(e.flags.includes(t)||t===`appConnections`&&X(e,t))return{kind:`set`,input:{role:t,baseUrl:e.baseUrl,enabled:!1}};let n={role:t,baseUrl:e.baseUrl,enabled:!0};return t===`publicEndpoint`&&e.baseUrl.startsWith(`http:`)?{kind:`confirm-http`,input:n,reason:ie}:{kind:`set`,input:n}}function nt(e){return Y.map(({role:t,title:n})=>{if(t===`appConnections`){let r=e.roles.appConnections;return{role:t,title:n,inUse:r.resolved.length===0?`nothing reachable`:r.resolved.join(`, `),automatic:r.source!==`flagged`}}let r=e.roles[t];return{role:t,title:n,inUse:r.resolved===null?`nothing reachable`:t===`notificationTaps`&&r.source===`auto`?`CamStack app link`:r.resolved,automatic:r.source!==`flagged`}})}e();var rt={"lan-ipv4":{labelKey:`system.addressesCard.kindIpv4`,className:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`},"lan-ipv6":{labelKey:`system.addressesCard.kindIpv6`,className:`bg-violet-500/15 text-violet-700 dark:text-violet-300`},public:{labelKey:`system.addressesCard.kindPublic`,className:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},"app-link":{labelKey:`system.addressesCard.kindAppLink`,className:`bg-amber-500/15 text-amber-700 dark:text-amber-300`},custom:{labelKey:`system.addressesCard.kindCustom`,className:`bg-sky-500/15 text-sky-700 dark:text-sky-300`},loopback:{labelKey:`system.addressesCard.kindLoopback`,className:`bg-foreground-subtle/15 text-foreground-subtle`}};function it({book:e,loading:t,saving:n,error:i,onSetRole:o,onAdd:s,onRemove:l}){let{t:u}=R(),[d,p]=r(``),[h,g]=r(``),[_,v]=r(null),[y,b]=r(null),x=()=>{let e=ne(d);if(!e.ok){v(e.reason);return}v(null),p(``),g(``),s(e.baseUrl,h.trim())},S=(e,t)=>{let n=tt(e,t.role);if(n.kind!==`none`){if(n.kind===`confirm-http`){b({input:n.input,reason:n.reason});return}b(null),o(n.input)}},ee=[{key:`url`,header:u(`system.addressesCard.address`,`Address`),render:t=>a(`div`,{className:`min-w-0 py-0.5`,children:[c(`div`,{className:`font-mono text-[12px] break-all ${t.plausible?`text-foreground`:`text-foreground-subtle`}`,children:t.baseUrl}),a(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[c(`span`,{children:t.label}),t.kind===`app-link`&&a(`span`,{className:`font-mono`,children:[`hub=`,` `,e?.appLinkHub??u(`system.addressesCard.noneNoTunnelOrTailscale`,`none (no tunnel or Tailscale)`)]}),t.custom&&t.detected&&c(`span`,{children:u(`system.addressesCard.alsoAddedAsACustom`,`also added as a custom address`)}),t.kind!==`custom`&&t.interfaceKind!==`lan`&&t.interfaceKind!==`public`&&t.interfaceKind!==`other`&&c(`span`,{className:`uppercase tracking-wide`,children:t.interfaceKind}),!t.plausible&&t.interfaceKind!==`loopback`&&a(`span`,{className:`inline-flex items-center gap-1 text-amber-700 dark:text-amber-300`,title:t.plausibleReason||void 0,children:[c(m,{className:`h-2.5 w-2.5`}),u(`system.addressesCard.unlikelyUsable`,`Unlikely usable`)]})]})]})},{key:`kind`,header:u(`system.addressesCard.kind`,`Kind`),nowrap:!0,render:e=>{let t=rt[e.kind]??rt.loopback;return c(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.className}`,children:u(t.labelKey)})}},...Y.map(e=>({key:e.role,headerRender:()=>c(`span`,{title:e.help,children:e.title}),align:`center`,nowrap:!0,width:`w-24`,render:t=>{let r=t.eligible.includes(e.role),i=t.flags.includes(e.role),o=X(t,e.role);return a(`label`,{className:`inline-flex items-center justify-center gap-1 ${r?`cursor-pointer`:`cursor-not-allowed opacity-40`}`,title:r?o&&!i?u(`system.addressesCard.inUseAutomatically`,`{{title}}: in use automatically. {{help}}`,{title:e.title,help:e.help}):e.help:u(`system.addressesCard.thisAddressCannotBeUsed`,`This address cannot be used for this.`),children:[c(je,{checked:r&&o,disabled:!r||n,onChange:()=>S(t,e),"aria-label":`${e.title}: ${t.baseUrl}`}),o&&!i&&r&&c(`span`,{className:`text-[9px] text-foreground-subtle`,children:u(`common.auto`)})]})}})),{key:`actions`,header:``,align:`right`,nowrap:!0,render:e=>e.custom?c(N,{size:`sm`,variant:`ghost`,disabled:n,onClick:()=>l(e.baseUrl),"aria-label":u(`system.addressesCard.remove`,`Remove {{baseUrl}}`,{baseUrl:e.baseUrl}),title:u(`system.addressesCard.removeThisCustomAddressIts`,`Remove this custom address (its roles turn automatic)`),children:c(f,{className:`h-3 w-3`})}):null}],C=e===void 0?[]:nt(e);return a(me,{children:[a(`div`,{className:`px-4 py-3 border-b border-border flex flex-col gap-2`,children:[a(`div`,{children:[c(`div`,{className:`text-sm font-semibold`,children:u(`system.addressesCard.addresses`,`Addresses`)}),c(`div`,{className:`text-xs text-foreground-subtle max-w-3xl`,children:u(`system.addressesCard.everyAddressThisHubIs`,`Every address this hub is reached at, detected or added by you. Tick what each one is used for.`)}),a(`details`,{className:`mt-1.5 text-xs max-w-3xl`,"data-testid":`address-roles-help`,children:[c(`summary`,{className:`cursor-pointer select-none text-foreground-subtle hover:text-foreground`,children:u(`system.addressesCard.whatAreRoles`,`What are roles?`)}),c(`dl`,{className:`mt-1.5 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1`,children:Y.map(e=>a(`div`,{className:`contents`,children:[c(`dt`,{className:`font-medium`,children:e.title}),c(`dd`,{className:`text-foreground-subtle`,children:e.help})]},e.role))}),c(`p`,{className:`mt-1.5 text-foreground-subtle`,children:et})]})]}),C.length>0&&c(`div`,{className:`grid grid-cols-[auto_1fr_auto] gap-x-3 gap-y-1 items-baseline text-xs`,"data-testid":`address-roles-summary`,children:C.map(e=>a(`div`,{className:`contents`,children:[c(`span`,{className:`text-foreground-subtle`,children:e.title}),a(`span`,{className:`font-mono break-all`,"data-testid":`address-role-${e.role}`,children:[e.inUse,c(`span`,{className:`ml-1.5 font-sans text-foreground-subtle`,children:e.automatic?u(`system.addressesCard.automatic`,`(automatic)`):u(`system.addressesCard.setByYou`,`(set by you)`)})]}),e.automatic?c(`span`,{}):c(N,{size:`sm`,variant:`secondary`,disabled:n,onClick:()=>o({role:e.role,baseUrl:null,enabled:!1}),children:u(`system.addressesCard.useAutomatic`,`Use automatic`)})]},e.role))}),y!==null&&a(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs flex flex-wrap items-center gap-2`,children:[c(m,{className:`h-3.5 w-3.5 text-amber-600`}),c(`span`,{className:`flex-1 min-w-[220px]`,children:y.reason}),c(N,{size:`sm`,variant:`secondary`,onClick:()=>{o({...y.input,acceptInsecureHttp:!0}),b(null)},children:u(`system.addressesCard.useHttpAnyway`,`Use http anyway`)}),c(N,{size:`sm`,variant:`ghost`,onClick:()=>b(null),children:u(`common.cancel`,`Cancel`)})]}),i!==null&&c(`div`,{className:`text-[11px] text-red-600 dark:text-red-400`,role:`alert`,children:i})]}),c(fe,{columns:ee,rows:e?.rows??[],rowKey:e=>`${e.kind}-${e.baseUrl}`,minWidthPx:760,bordered:!1,emptyMessage:t?u(`common.loading`,`Loading…`):u(`system.addressesCard.noAddressesAvailable`,`No addresses available.`),rowClassName:e=>e.plausible?void 0:`opacity-80`}),a(`div`,{className:`px-4 py-3 border-t border-border flex flex-wrap items-start gap-2`,children:[a(`div`,{className:`flex-1 min-w-[220px]`,children:[c(ke,{value:d,onChange:e=>{p(e.target.value),v(null)},placeholder:`https://cams.example.com or https://192.168.1.50:4443`,"aria-label":u(`system.addressesCard.customAddress`,`Custom address`),disabled:n}),_!==null&&c(`div`,{className:`mt-1 text-[11px] text-red-600 dark:text-red-400`,children:_})]}),c(`div`,{className:`w-48`,children:c(ke,{value:h,onChange:e=>g(e.target.value),placeholder:u(`system.addressesCard.labelOptional`,`Label (optional)`),"aria-label":u(`system.addressesCard.customAddressLabel`,`Custom address label`),maxLength:80,disabled:n})}),a(N,{size:`sm`,variant:`secondary`,disabled:n||d.trim()===``,onClick:x,children:[c(w,{className:`h-3 w-3`}),u(`system.addressesCard.addCustomAddress`,`Add custom address`)]})]})]})}e();function at(){let{t:e}=R(),i=s(),o=()=>{i.invalidateQueries({queryKey:[[`localNetwork`]]})},l=ve(void 0,{refetchInterval:3e4}),u=De(void 0),f=le({onSuccess:o}),p=_e({onSuccess:e=>{w(e.addresses),o()}}),m=n(()=>l.data?.interfaces??[],[l.data]),h=ce({scheme:typeof window<`u`&&window.location.protocol===`https:`?`https`:`http`},{refetchInterval:3e4}),g=Ne({onSuccess:o}),_=Oe({onSuccess:o}),v=he({onSuccess:o}),x=g.error?.message??_.error?.message??v.error?.message??null,S=g.isPending||_.isPending||v.isPending,[C,w]=r([]),[T,E]=r(!1);t(()=>{!T&&u.data&&(w(u.data.addresses),E(!0))},[u.data,T]);let D=u.data?.addresses??[],O=n(()=>{if(C.length!==D.length)return!0;let e=[...C].toSorted(),t=[...D].toSorted();return e.some((e,n)=>e!==t[n])},[C,D]);return a(V,{embedded:!0,children:[a(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[c(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:e(`system.networkAddresses.pinWhichHostInterfacesExist`,`Pin which host interfaces exist, then tick what each address is used for. Add a custom address when this hub is reached at one it cannot detect.`)}),c(`div`,{className:`flex items-center gap-2 shrink-0`,children:a(N,{size:`sm`,variant:`secondary`,onClick:()=>{l.refetch(),u.refetch(),h.refetch()},disabled:l.isLoading,children:[c(b,{className:`h-3 w-3 ${l.isLoading?`animate-spin`:``}`}),e(`common.refresh`,`Refresh`)]})})]}),c(xe,{headingId:`network-allowed-addresses`,title:e(`system.networkAddresses.allowedAddresses`,`Allowed addresses`),actions:a(`div`,{className:`flex flex-wrap items-center gap-1`,children:[a(N,{size:`sm`,variant:`secondary`,onClick:()=>p.mutate(void 0),disabled:p.isPending||f.isPending,title:e(`system.networkAddresses.reRunTheAutoDetection`,`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`),children:[c(y,{className:`h-3 w-3`}),p.isPending?e(`system.networkAddresses.detecting`,`Detecting…`):e(`system.networkAddresses.bestMatch`,`Best match`)]}),a(N,{size:`sm`,variant:`secondary`,onClick:()=>{w([])},disabled:C.length===0||f.isPending,children:[c(te,{className:`h-3 w-3`}),e(`system.networkAddresses.clear`,`Clear`)]}),O&&c(N,{size:`sm`,variant:`secondary`,onClick:()=>{w(D)},disabled:f.isPending,children:e(`system.networkAddresses.discard`,`Discard`)}),a(N,{size:`sm`,variant:`primary`,onClick:()=>{f.mutate({addresses:[...C]})},disabled:!O||f.isPending,children:[c(ee,{className:`h-3 w-3`}),f.isPending?e(`system.networkAddresses.saving`,`Saving…`):e(`common.save`,`Save`)]})]}),children:a(`div`,{className:d,children:[c(`p`,{className:`mb-3 text-xs text-foreground-subtle`,children:C.length===0?e(`system.networkAddresses.autoEveryNonLoopbackNon`,`Auto — every non-loopback / non-link-local interface participates.`):e(`system.networkAddresses.pinned`,`{{value1}} pinned`,{value1:String(C.length)})}),c($e,{mode:`multiple`,interfaces:m,value:C,onChange:w,disabled:f.isPending,emptyMessage:l.isLoading?e(`system.networkAddresses.loadingInterfaces`,`Loading interfaces…`):e(`system.networkAddresses.noInterfacesDetected`,`No interfaces detected.`)})]})}),c(it,{book:h.data,loading:h.isLoading,saving:S,error:x,onSetRole:e=>g.mutate({...e}),onAdd:(e,t)=>_.mutate({baseUrl:e,label:t}),onRemove:e=>v.mutate({baseUrl:e})})]})}e();var ot={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,Q=`mesh-network`,st=3e4,ct={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function lt(){let{t:e}=R(),t=F({capName:`mesh-network`},{refetchInterval:Z}),r=P(void 0,{refetchInterval:Z}),i=n(()=>G(r.data??[]),[r.data]),a=n(()=>(t.data??[]).map(e=>({addonId:e.addonId,displayName:i.get(e.addonId)??e.addonId,isActive:e.isActive})),[t.data,i]),o=[{id:Q,label:e(`system.meshNetworks.meshNetworks`,`Mesh networks`),install:{capability:Q,label:e(`system.meshNetworks.addMesh`,`Add mesh`)},entries:a.map(t=>({id:t.addonId,name:t.displayName,fallbackIcon:k,...W(t.isActive),render:()=>c(H,{addonId:t.addonId,displayName:t.displayName,capName:Q,isActive:t.isActive,badges:c(ut,{addonId:t.addonId}),primaryAction:c(dt,{addonId:t.addonId}),panels:[{id:`status`,title:e(`system.meshNetworks.status`,`Status`),icon:j,content:c(ft,{addonId:t.addonId})}]})}))}];return c(U,{embedded:!0,icon:j,title:e(`system.meshNetworks.meshNetworks2`,`Mesh Networks`),subtitle:e(`system.meshNetworks.privateVpnMeshesThatConnect`,`Private VPN meshes that connect CamStack to your other devices (Tailscale, Headscale, …). Each provider can also expose this hub publicly via its ingress (Tailscale Funnel).`),groups:o,isLoading:t.isLoading,emptyTitle:e(`system.meshNetworks.noMeshNetworkProvidersInstalled`,`No mesh-network providers installed`),emptyDescription:e(`system.meshNetworks.installAMeshAddonE`,`Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.`)})}function $(e){let{data:t,isLoading:n}=be({addonId:e},{refetchInterval:Z,retry:!1}),r=t?A.safeParse(t):null;return{status:r?.success?r.data:ct,isLoading:n}}function ut({addonId:e}){let{t}=R(),{status:n}=$(e);return a(o,{children:[c(I,{variant:n.joined?`success`:`default`,className:Be,children:n.joined?t(`system.meshNetworks.joined`,`Joined`):t(`system.meshNetworks.notJoined`,`Not joined`)}),n.joined&&c(I,{className:`text-[10px]`,children:t(`common.peers`,{count:n.peerCount})})]})}function dt({addonId:e}){let{t}=R(),n=s(),[l,u]=r(!1),[d,f]=r(null),p=D(),{status:m}=$(e),h=i(()=>{n.invalidateQueries({queryKey:[[`meshNetwork`]]})},[n]),g=Ae(),_=Se({onSuccess:h}),v=ge({onSuccess:h}),y=i(async()=>{u(!0);let t={cancelled:!1};f(t);try{let n=await g.mutateAsync({addonId:e});if(t.cancelled)return;n.loginUrl&&window.open(n.loginUrl,`_blank`,`noopener,noreferrer`);let r=Date.now();for(;!t.cancelled&&(await yt(2e3),!t.cancelled);){let t=await p.trpcClient.meshNetwork.getStatus.query({addonId:e}).catch(()=>null),n=t?A.safeParse(t):null;if(n?.success&&n.data.joined){h();break}if(Date.now()-r>6e5)break}}finally{u(!1),f(null)}},[e,h,g,p]),b=i(()=>{d&&(d.cancelled=!0),u(!1),f(null)},[d]);return c(o,{children:m.joined?a(o,{children:[a(N,{size:`sm`,variant:`secondary`,disabled:_.isPending,onClick:()=>_.mutate({addonId:e}),children:[_.isPending?c(E,{className:`h-3 w-3 animate-spin`}):c(ae,{className:`h-3 w-3`}),t(`system.meshNetworks.disconnect`,`Disconnect`)]}),a(N,{size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>v.mutate({addonId:e}),children:[v.isPending?c(E,{className:`h-3 w-3 animate-spin`}):c(T,{className:`h-3 w-3`}),t(`system.meshNetworks.logOut`,`Log out`)]})]}):l?a(N,{size:`sm`,variant:`ghost`,onClick:b,children:[c(S,{className:`h-3 w-3 mr-1`}),` `,t(`common.cancel`)]}):a(o,{children:[a(N,{size:`sm`,variant:`primary`,onClick:()=>void y(),children:[c(oe,{className:`h-3 w-3`}),t(`system.meshNetworks.connect`,`Connect`)]}),a(N,{size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>v.mutate({addonId:e}),children:[v.isPending?c(E,{className:`h-3 w-3 animate-spin`}):c(T,{className:`h-3 w-3`}),t(`system.meshNetworks.logOut`,`Log out`)]})]})})}function ft({addonId:e}){let{t}=R(),{status:n}=$(e),r=de({addonId:e},{refetchInterval:st,retry:!1});return a(`div`,{className:`rounded-lg border border-border bg-surface`,children:[a(`div`,{className:`space-y-4 p-2 sm:p-4`,children:[n.error&&c(Me,{message:n.error}),c(pt,{status:n}),n.endpoints.length>0&&a(`div`,{className:`space-y-1.5`,children:[c(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:t(`system.meshNetworks.endpoints`,`Endpoints`)}),n.endpoints.map(e=>a(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[a(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${ot[e.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[e.scope===`public`?c(M,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,e.label]}),a(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1`,children:[c(u,{className:`h-3 w-3 shrink-0`}),e.url]})]},e.id))]})]}),c(`div`,{className:`border-t border-border`,children:c(ht,{peers:r.data?.peers??[],loading:r.isLoading})})]})}function pt({status:e}){let{t}=R();return c(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5`,children:[{label:t(`system.meshNetworks.tenant`,`Tenant`),value:e.tenantName||`—`},{label:t(`system.meshNetworks.user`,`User`),value:e.userLogin??`—`},{label:t(`system.meshNetworks.controlPlane`,`Control plane`),value:e.controlPlaneUrl||`—`},{label:t(`system.meshNetworks.meshIp`,`Mesh IP`),value:e.meshIp||`—`,mono:!0},{label:t(`system.meshNetworks.magicdns`,`MagicDNS`),value:e.magicDnsHostname||`—`,mono:!0},{label:t(`system.meshNetworks.dnsSuffix`,`DNS suffix`),value:e.magicDnsSuffix||`—`,mono:!0},{label:t(`system.meshNetworks.peers`,`Peers`),value:String(e.peerCount)},{label:t(`system.meshNetworks.keyExpiry`,`Key expiry`),value:e.keyExpiry?mt(e.keyExpiry):`—`}].map(e=>a(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[c(`span`,{className:`text-foreground-subtle shrink-0`,children:e.label}),c(`span`,{className:`text-foreground truncate ${e.mono?`font-mono`:``}`,children:e.value})]},e.label))})}function mt(e){let t=e-Date.now();if(t<0)return L.t(`system.meshNetworks.expiredAgo`,{when:vt(e)});let n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return L.t(`system.meshNetworks.expiryDays`,{count:n});let r=Math.floor(t/36e5);return r>1?L.t(`system.meshNetworks.expiryHours`,{count:r}):L.t(`system.meshNetworks.expiryMin`,{count:Math.max(1,Math.floor(t/6e4))})}function ht({peers:e,loading:t}){let{t:r}=R(),o=n(()=>e.map(e=>({...e,_id:e.id})),[e]),s=i(e=>{e&&navigator.clipboard?.writeText(e)},[]),l=n(()=>[{key:`hostname`,header:r(`system.meshNetworks.hostname`,`Hostname`),render:e=>a(`div`,{className:`flex flex-col`,children:[a(`div`,{className:`flex items-center gap-1.5`,children:[c(`span`,{className:`font-medium text-foreground`,children:e.hostname||r(`system.meshNetworks.unknown`,`(unknown)`)}),e.isSelf&&c(I,{variant:`info`,children:r(`common.self`)}),e.exitNodeOption&&c(I,{variant:`warning`,children:`exit-node`})]}),e.userLogin&&c(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.userLogin})]})},{key:`magicDns`,header:r(`system.meshNetworks.magicdns`,`MagicDNS`),render:e=>e.magicDns?a(`div`,{className:`flex items-center gap-1`,children:[c(`span`,{className:`font-mono text-xs truncate`,children:e.magicDns}),c(`button`,{onClick:()=>s(e.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":r(`system.meshNetworks.copyMagicdns`,`Copy MagicDNS`),children:c(v,{className:`h-3 w-3 text-foreground-subtle`})})]}):c(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:e=>{let t=e.addresses[0]??``;return t?a(`div`,{className:`flex items-center gap-1`,children:[c(`span`,{className:`font-mono text-xs`,children:t}),c(`button`,{onClick:()=>s(t),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":r(`system.meshNetworks.copyIp`,`Copy IP`),children:c(v,{className:`h-3 w-3 text-foreground-subtle`})})]}):c(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:r(`system.meshNetworks.connection`,`Connection`),render:e=>a(`div`,{className:`flex items-center gap-1.5`,children:[c(I,{variant:gt(e.connection),children:e.connection}),e.relay&&c(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.relay})]})},{key:`routes`,header:r(`system.meshNetworks.routes`,`Routes`),render:e=>e.advertisedRoutes.length>0?c(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):c(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:r(`system.meshNetworks.txRx`,`TX / RX`),render:e=>a(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,_t(e.txBytes),` · ↓ `,_t(e.rxBytes)]})},{key:`lastSeen`,header:r(`system.meshNetworks.lastSeen`,`Last seen`),render:e=>c(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?vt(e.lastSeenMs):`—`})}],[s,r]);return t&&e.length===0?a(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[c(E,{className:`h-3 w-3 animate-spin inline mr-1`}),` `,r(`systemPage.meshNetworks.loadingPeers`)]}):e.length===0?c(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:r(`system.meshNetworks.noPeersVisibleYourTailnet`,`No peers visible — your tailnet may be empty or the host is not joined.`)}):c(`div`,{className:`p-4`,children:c(fe,{columns:l,rows:o,rowKey:e=>e._id,minWidthPx:820})})}function gt(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function _t(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 vt(e){let t=Date.now()-e;return t<6e4?L.t(`system.meshNetworks.justNow`):t<36e5?L.t(`system.meshNetworks.agoMin`,{count:Math.round(t/6e4)}):t<864e5?L.t(`system.meshNetworks.agoHour`,{count:Math.round(t/36e5)}):L.t(`system.meshNetworks.agoDay`,{count:Math.round(t/864e5)})}function yt(e){return new Promise(t=>setTimeout(t,e))}var bt=`/system/identity?tab=certificates`;function xt(){let{t:e}=R();return c(V,{embedded:!0,children:a(`div`,{className:p,children:[c(ze,{nodeId:`hub`,addonIds:[`local-network`],level:`global`,title:e(`system.localAccess.lanHttp`,`LAN HTTP`),description:e(`system.localAccess.nativeAppsOnThisWi`,`Native apps on this Wi-Fi use http:// and skip the private certificate. The tunnel and this admin UI stay on HTTPS.`)}),a(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`https-certificate-hint`,children:[e(`system.localAccess.certificateMoved`,`The HTTPS certificate and the local CA are managed under`),` `,c(Fe,{className:`underline`,to:bt,children:e(`system.localAccess.certificateMovedLink`,`Identity → Certificates`)}),`.`]})]})})}e();function St({value:e,onChange:t}){let{t:r}=R(),{data:i}=Ee({isCamera:!0,projection:`slim`}),o=n(()=>i===void 0?[{value:``,label:r(`system.networkDiagnostics.loadingCameras`,`Loading cameras…`)}]:i.length===0?[{value:``,label:r(`system.networkDiagnostics.noCameras`,`No cameras`)}]:[{value:``,label:r(`system.networkDiagnostics.pickACamera`,`Pick a camera`)},...i.toSorted((e,t)=>e.name.localeCompare(t.name)).map(e=>({value:String(e.id),label:`${e.name} (#${String(e.id)})`}))],[i,r]);return a(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[c(`span`,{className:`text-[11px] text-foreground-subtle`,children:r(`system.networkDiagnostics.camera`,`Camera`)}),c(we,{value:e===null?``:String(e),disabled:i===void 0||i.length===0,onChange:e=>t(e.target.value===``?null:Number(e.target.value)),options:o})]})}function Ct(){let e=D(),[t,n]=r(null);return c(V,{embedded:!0,children:a(`div`,{className:p,"data-testid":`network-diagnostics`,children:[c(pe,{loadServers:i(async()=>e.trpcClient.turnProvider.getTurnServers.query(),[e])}),c(ue,{trpc:e.trpcClient,serverUrl:_(),deviceId:t,cameraField:c(St,{value:t,onChange:n})})]})})}var wt=[`certificate`,`certificates`,`https`];function Tt(){let{t:e}=R(),[t]=Le();if(wt.includes(t.get(`tab`)??``))return c(Pe,{to:bt,replace:!0});let n=Ie(`/system/network`,{t:e,isAdmin:!0})??{icon:M,title:e(`system.network`,`Network`)};return c(Re,{icon:n.icon,title:n.title,defaultSection:`addresses`,sectionsLabel:`${n.title} sections`,sections:[{id:`local-access`,label:e(`systemPage.network.localAccess`,`Local access`),content:c(xt,{})},{id:`addresses`,label:e(`systemPage.network.networkAddresses`,`Network Addresses`),content:c(at,{})},{id:z.remoteAccess.tab,label:e(`systemPage.network.remoteAccess`,`Remote Access`),content:c(He,{}),ownedParams:B},{id:z.mesh.tab,label:e(`systemPage.network.meshNetworks`,`Mesh Networks`),content:c(lt,{}),ownedParams:B},{id:z.turn.tab,label:e(`systemPage.network.turnServers`,`TURN Servers`),content:c(Je,{}),ownedParams:B},{id:`diagnostics`,label:e(`systemPage.network.diagnostics`,`Diagnostics`),content:c(Ct,{})}]})}export{Tt as NetworkPage};
|