@camstack/addon-admin-ui 1.2.455 → 1.2.456
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-BYNabO6z.js → AddonAssetIcon-DKGFFkU1.js} +1 -1
- package/dist/assets/Addons-f6INIGNk.js +4 -0
- package/dist/assets/{AdminPage-RJcN6Anu.js → AdminPage-DRcphXBk.js} +1 -1
- package/dist/assets/{AdminSectionedPage-DvK84QvU.js → AdminSectionedPage-DSgwWy9V.js} +1 -1
- package/dist/assets/AiProfiles-B6Wxjm7J.js +3 -0
- package/dist/assets/{BrokerForm-Bua9uB8w.js → BrokerForm-DQh-oQXM.js} +1 -1
- package/dist/assets/Build-C1E3G4Li.js +40 -0
- package/dist/assets/{Calendars-ClbErr_S.js → Calendars-BVNS3qJH.js} +1 -1
- package/dist/assets/{Cluster-DmQM6H_p.js → Cluster-Bb3ssLVf.js} +1 -1
- package/dist/assets/ClusterStepModel-BTonEQ8Q.js +1 -0
- package/dist/assets/{CompositionEditor-CpN510VP.js → CompositionEditor-ClnrKef1.js} +1 -1
- package/dist/assets/{CompositionEditorPage-Bicamzo6.js → CompositionEditorPage-UPZOCUTw.js} +1 -1
- package/dist/assets/Data-CMmaSXTq.js +2 -0
- package/dist/assets/{DeviceDetail-4Vysat6s.js → DeviceDetail-r7xGh0V5.js} +2 -2
- package/dist/assets/{DeviceDoActionFields-lfq-_s87.js → DeviceDoActionFields-CK_hotUV.js} +1 -1
- package/dist/assets/{Devices-BCTvzI3Z.js → Devices-D9qIPy3j.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-BzklJ0a5.js → EmbedPlayerPage-CnyoNW1O.js} +1 -1
- package/dist/assets/History-Bu-xlBT6.js +1 -0
- package/dist/assets/Identity-uOmwWcOV.js +1 -0
- package/dist/assets/IntegrationDetail-0gsMfR07.js +1 -0
- package/dist/assets/{IntegrationHub-DHgjRUIy.js → IntegrationHub-PQzIoW-z.js} +1 -1
- package/dist/assets/{Integrations-CQ3JYsSK.js → Integrations-97rH5eud.js} +1 -1
- package/dist/assets/Integrations-CjQ8VMPF.js +1 -0
- package/dist/assets/{Library-02NRO2CR.js → Library-DlZO8qd2.js} +1 -1
- package/dist/assets/Locations-C5D3OkBO.js +3 -0
- package/dist/assets/{Logs-QE5m7m6F.js → Logs-CKiP2BRT.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-C7r7jgVz.js → MaskShapeCanvas-DWXNtDDM.js} +1 -1
- package/dist/assets/{MotionZonesSettings-qCWVDb2U.js → MotionZonesSettings-DJd0Y31u.js} +1 -1
- package/dist/assets/MyAccess-B_R_Psa6.js +2 -0
- package/dist/assets/{Network-CJOuBFOQ.js → Network-T6uv6aRS.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-CTmPFs3s.js → NodeAddonsSettingsPanel-UU1LJcnK.js} +1 -1
- package/dist/assets/{Notifications-WPdPSM1o.js → Notifications-BW3LX1UG.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-CBAaR7ZM.js → PrivacyMaskSettings-DxMOo9HB.js} +1 -1
- package/dist/assets/{Recordings-BeU7j2Jf.js → Recordings-Clc8K8NN.js} +1 -1
- package/dist/assets/{ScanNetworkModal-CiOVqs0H.js → ScanNetworkModal-Cf68s1om.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-BbPp4N2N.js → SceneMonitorEditor-BiawWZG0.js} +1 -1
- package/dist/assets/{SessionsList-DTdwgdgY.js → SessionsList-Dt8jP4yn.js} +2 -2
- package/dist/assets/{Showroom-or-UvZ6_.js → Showroom-qUHeS3m7.js} +1 -1
- package/dist/assets/System-CdmK8YJa.js +1 -0
- package/dist/assets/{Terminal-B3oKTozT.js → Terminal-Cju5rV2v.js} +5 -5
- package/dist/assets/{Viewer-CpC1lsu6.js → Viewer-YynlXnis.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-cERw53qT.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-03dAXb2d.js} +1 -1
- package/dist/assets/{addon-icons-context-BVO6QLZm.js → addon-icons-context-BRjz6lXp.js} +1 -1
- package/dist/assets/{archive-jvBvOOAa.js → archive-C86NKLhj.js} +1 -1
- package/dist/assets/{authed-media-DubLoRPM.js → authed-media-DNvCU5gQ.js} +1 -1
- package/dist/assets/{bell-off-h_oVtaH_.js → bell-off-CLM0BeeE.js} +1 -1
- package/dist/assets/{board-model-lfov_Io5.js → board-model-CGfpWX1e.js} +1 -1
- package/dist/assets/{boxes-CqZzX6pS.js → boxes-D5kVpHYR.js} +1 -1
- package/dist/assets/circle-slash-D3Ys-mWm.js +1 -0
- package/dist/assets/client-Cif6ZNXf.js +358 -0
- package/dist/assets/{cloud-upload-_iPugQ2o.js → cloud-upload-BzujuqId.js} +1 -1
- package/dist/assets/crop-BhaNBRht.js +1 -0
- package/dist/assets/{device-integration-icon-CFPzExgG.js → device-integration-icon-FcBNNpTA.js} +1 -1
- package/dist/assets/device-picker-model-BeeSEnbH.js +1 -0
- package/dist/assets/dist-D34XdNk-.js +358 -0
- package/dist/assets/{dist-BYCY5p_8.js → dist-DfKbyUlI.js} +1 -1
- package/dist/assets/{eraser-RaYHha2L.js → eraser-DbfQdK9E.js} +1 -1
- package/dist/assets/{hard-drive-download-DobqoKaY.js → hard-drive-download-BZLuYqC1.js} +1 -1
- package/dist/assets/{hostInit-Bk_2heUx.js → hostInit-CkedGVrn.js} +1 -1
- package/dist/assets/i18n-D4s8z86g.js +1 -0
- package/dist/assets/{icons-DzYBV1xx.js → icons-CR-DXZNQ.js} +1 -1
- package/dist/assets/index-DLqV2Uxg.css +2 -0
- package/dist/assets/index-DbU7nBkH.js +4 -0
- package/dist/assets/{key-Dtkr3Nze.js → key-Dlm_jdT1.js} +1 -1
- package/dist/assets/{key-round-CNTVmlFS.js → key-round-HqP_LM9P.js} +1 -1
- package/dist/assets/{layers-DGhugmpj.js → layers-73PWVjHZ.js} +1 -1
- package/dist/assets/{linked-devices-model-BpGYuse3.js → linked-devices-model-CtpdAdgc.js} +1 -1
- package/dist/assets/{list-ordered-DR6Fc-kF.js → list-ordered-DuUItJBm.js} +1 -1
- package/dist/assets/{location-owned-usage-CScwnhi4.js → location-owned-usage-ej64Ij_c.js} +1 -1
- package/dist/assets/{log-in-B8yxXP-a.js → log-in-BnTC3lpA.js} +1 -1
- package/dist/assets/{memory-stick-DEd977DV.js → memory-stick-CFvegwjZ.js} +1 -1
- package/dist/assets/{message-square-plus-czVBdg8z.js → message-square-plus-D19WKqRB.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-ffeb770c.js → mf-entry-bootstrap-0-8e777e33.js} +2 -2
- package/dist/assets/{mic-off-CuWOtzwH.js → mic-off-BikPboNB.js} +1 -1
- package/dist/assets/{monitor-off-D1_Vx25v.js → monitor-off-Bg-VBYZ_.js} +1 -1
- package/dist/assets/{monitor-smartphone-EKfsOXbl.js → monitor-smartphone-C--c1kfN.js} +1 -1
- package/dist/assets/mount-BeeSEnbH.js +1 -0
- package/dist/assets/{notification-schedule-field-i8rEjVxQ.js → notification-schedule-field-CqjG-5hF.js} +1 -1
- package/dist/assets/{player-overlays-D98Lvll4.js → player-overlays-CRBEyRbr.js} +1 -1
- package/dist/assets/{recycle-BDYRIJo4.js → recycle-DOHVzhvg.js} +1 -1
- package/dist/assets/remoteEntry--AbYLxqH.js +1 -0
- package/dist/assets/{scan-eye-BF9NJNXB.js → scan-eye-m2aAerVb.js} +1 -1
- package/dist/assets/{scissors-BNz1ybHC.js → scissors-C0kFwmt4.js} +1 -1
- package/dist/assets/{search-x-DOr7Uth6.js → search-x-C1Zu06fo.js} +1 -1
- package/dist/assets/{send-BfMMesXE.js → send-DGFOkxsu.js} +1 -1
- package/dist/assets/{settings-2-CpTdKS6A.js → settings-2-B9EvM-5F.js} +1 -1
- package/dist/assets/{speaker-DiDPOBlm.js → speaker-lMBay1CD.js} +1 -1
- package/dist/assets/src-X6CKvVYm.js +67 -0
- package/dist/assets/{timer-reset-Dw4WCNKZ.js → timer-reset-DQlkGcOB.js} +1 -1
- package/dist/assets/{ungroup-CLr3vekJ.js → ungroup-CiuolLZx.js} +1 -1
- package/dist/assets/{unlink-pUA2UXXM.js → unlink-S1qKy8_1.js} +1 -1
- package/dist/assets/{usb-wx8HtogA.js → usb-BrpBB1_Y.js} +1 -1
- package/dist/assets/{use-scenes-feed-DF4B8gD1.js → use-scenes-feed-91m9645S.js} +1 -1
- package/dist/assets/{use-stationary-objects-CPcayJEy.js → use-stationary-objects-fCdo-oR4.js} +1 -1
- package/dist/assets/useEventInvalidation-BeeSEnbH.js +1 -0
- package/dist/assets/{useNodeUrlSelection-Dm8ObY95.js → useNodeUrlSelection-CDosE56A.js} +1 -1
- package/dist/assets/user-round-DegbdwtA.js +1 -0
- package/dist/assets/{user-x-CzTAjxJ0.js → user-x-DLZWkjil.js} +1 -1
- package/dist/assets/{video-a3E1zR0a.js → video-Bu3o7z_A.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-C-d2SXqo.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DXKYo8xB.js} +2 -2
- package/dist/index.html +30 -11
- package/dist/server/addon.js +63 -4
- package/package.json +1 -1
- package/dist/assets/Addons-B7UpJkGs.js +0 -4
- package/dist/assets/AiProfiles-WyUbwQQi.js +0 -3
- package/dist/assets/Build-w6vEia_c.js +0 -40
- package/dist/assets/ClusterStepModel-hpdBn30Y.js +0 -1
- package/dist/assets/Data-DoXqW90G.js +0 -2
- package/dist/assets/History-BYogPAEo.js +0 -1
- package/dist/assets/Identity-DtlH2M6Y.js +0 -1
- package/dist/assets/IntegrationDetail-B0PsG3wF.js +0 -1
- package/dist/assets/Integrations-DD48mmxj.js +0 -1
- package/dist/assets/Locations-CUmRk0or.js +0 -3
- package/dist/assets/MyAccess-CIhAKN-2.js +0 -2
- package/dist/assets/System-DSx33GfC.js +0 -1
- package/dist/assets/circle-slash-DFnFtATu.js +0 -1
- package/dist/assets/client-Cj9cIFJV.js +0 -358
- package/dist/assets/crop-CesdRTv2.js +0 -1
- package/dist/assets/device-picker-model-CVKD2t0V.js +0 -1
- package/dist/assets/dist-o4U_Imrg.js +0 -358
- package/dist/assets/i18n-BuS8cl72.js +0 -1
- package/dist/assets/index-BuOqDa4D.css +0 -2
- package/dist/assets/index-CM1JjjBW.js +0 -4
- package/dist/assets/mount-CVKD2t0V.js +0 -1
- package/dist/assets/remoteEntry-BtmyK6Gf.js +0 -1
- package/dist/assets/src-MJ2k3G6o.js +0 -67
- package/dist/assets/useEventInvalidation-CVKD2t0V.js +0 -1
- package/dist/assets/user-round-vZzgqRIQ.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,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{$t as f,D as p,Fn as m,Gi as h,It as g,Nt as _,Rr as v,Tt as y,Wr as b,an as x,bn as S,cn as C,dn as w,dt as T,kn as E,lr as D,mi as O,mr as k,or as A,ot as ee,pn as j,rr as M,sa as N,sn as P,xi as F,yi as I}from"./player-overlays-D98Lvll4.js";import{Gi as L,Ki as te,Wi as ne,a as R,c as z,o as re,s as ie}from"./client-Cj9cIFJV.js";import{i as ae,n as oe,r as se,t as ce}from"./key-Dtkr3Nze.js";import{d as B,l as V,s as le}from"./video-a3E1zR0a.js";import{t as ue}from"./key-round-CNTVmlFS.js";import{t as de}from"./monitor-smartphone-EKfsOXbl.js";import{t as fe}from"./unlink-pUA2UXXM.js";import{$n as pe,An as me,Ar as H,Au as he,Ct as ge,Dn as _e,Du as ve,Eu as ye,Nn as be,Ou as xe,Qn as Se,Rr as U,Tu as Ce,Xn as we,Xu as W,Ya as Te,_n as Ee,_u as De,bs as Oe,bu as ke,cn as Ae,ds as je,dt as Me,du as Ne,er as Pe,fr as G,fu as Fe,gn as Ie,gr as Le,gs as Re,gu as ze,hn as K,hr as q,hu as Be,ir as Ve,it as He,jn as Ue,jr as We,kn as Ge,ku as Ke,ln as qe,lt as Je,lu as Ye,mn as Xe,mu as Ze,nr as Qe,oi as $e,pr as et,ps as tt,pu as nt,qn as rt,rr as it,rt as at,si as ot,uu as st,vt as ct,vu as lt,wt as ut,ys as dt,yu as ft}from"./src-MJ2k3G6o.js";import{t as J}from"./i18n-BuS8cl72.js";import{t as Y}from"./useTranslation-D3Is_4B6.js";import{$ as pt,Q as mt,T as ht,V as gt,Z as _t,a as vt,d as yt,et as bt,i as xt,l as St,nt as Ct}from"./index-CM1JjjBW.js";import{t as wt}from"./AdminSectionedPage-DvK84QvU.js";import{t as Tt}from"./AdminPage-RJcN6Anu.js";import{A as Et,C as Dt,D as Ot,E as kt,O as X,S as At,T as jt,a as Mt,b as Nt,c as Pt,d as Ft,f as It,g as Lt,h as Rt,i as zt,k as Bt,l as Vt,m as Ht,n as Ut,o as Wt,p as Gt,s as Kt,t as qt,u as Jt,v as Yt,w as Xt,x as Zt,y as Qt}from"./SessionsList-DTdwgdgY.js";import{i as $t,n as en,r as tn,t as nn}from"./IntegrationHub-DHgjRUIy.js";import{n as rn,t as an}from"./addon-display-names-BkwMrExv.js";e();function on(){let{t:e}=Y(),t=H(),i=W.useUtils(),a=Et(),{data:o,isLoading:s}=Be(),c=n(()=>o??[],[o]),l=W.useQueries(e=>c.map(t=>e.userManagement.listExternalIdentities({userId:t.id}))),u=W.auth.listLoginMethods.useQuery(),[f,p]=r(null),m=ft({onSuccess:()=>void i.userManagement.listExternalIdentities.invalidate(),onError:e=>p(`Remove failed: ${e.message}`)}),h=n(()=>new Map((u.data??[]).flatMap(e=>e.kind===`redirect`?[[e.id,e.label]]:[])),[u.data]),g=c.flatMap((e,t)=>l[t]?.data??[]),_=g.map(e=>({...At(e,a),kind:h.get(e.provider)??e.provider})),v=async n=>{let r=g.find(e=>Zt(e)===n.id);r!==void 0&&await t({title:e(`access.externalIdentitiesSection.removeSignInLink`,`Remove sign-in link`),message:e(`access.externalIdentitiesSection.willNoLongerBeAble`,`"{{ownerName}}" will no longer be able to sign in with this {{kind}} account.`,{ownerName:n.ownerName,kind:n.kind}),confirmLabel:e(`common.remove`,`Remove`),variant:`danger`})&&(p(null),m.mutate({userId:r.userId,provider:r.provider,subject:r.subject}))};return d(X,{notice:Bt(f),onDismissNotice:()=>{p(null)},id:`external-identities`,title:e(`access.externalIdentitiesSection.signInLinks`,`Sign-in links`),icon:B,description:e(`access.externalIdentitiesSection.externalAccountsSingleSignOn`,`External accounts (single sign-on) each user linked to their CamStack account. Only the owner can link one, from their profile; an admin can remove it.`),children:d(jt,{rows:_,label:`sign-in links`,isLoading:s||l.some(e=>e.isLoading),loadError:l.find(e=>e.isError)?.error?.message??null,emptyText:`No user has linked a sign-in account.`,expiresNone:`—`,action:{label:e(`common.remove`,`Remove`),icon:fe,isAvailable:()=>!0,onRun:e=>void v(e),busyId:null,disabled:m.isPending}})})}e();var sn={key:`access.nouns.linkedApp`};function cn(e){if(e.type===`category`){let t=e.target??``;return t===`device`?J.t(`access.linkedAppsSection.allDevices`):J.t(`access.linkedAppsSection.allTarget`,{target:t})}if(e.type===`device`)return`device:[${(e.targets??[]).join(`,`)}]`;let t=e;return`${t.type}:${t.target??``}`}function ln(){let{t:e}=Y(),t=H(),i=c(),a=Ze(),[o,s]=r(null),l=()=>void i.invalidateQueries({queryKey:[[`userManagement`,`listOauthSessions`]]}),u=De({onSuccess:l,onError:e=>s(`Revoke failed: ${e.message}`)}),f=kt(sn,l),p=n(()=>(a.data??[]).map(e=>Dt(e,e.scopes.map(cn).join(`, `))),[a.data]),m=async n=>{await t({title:e(`access.linkedAppsSection.revokeTheLink`,`Revoke the "{{name}}" link?`,{name:n.name}),message:e(`access.linkedAppsSection.losesAccessForOnIts`,`{{name}} loses access for {{ownerName}} on its next call. Linking it again needs the account-link flow from the start.`,{name:n.name,ownerName:n.ownerName}),confirmLabel:e(`access.linkedAppsSection.revoke`,`Revoke`),variant:`danger`})&&(s(null),u.mutate({id:n.id}))},h=u.isPending?u.variables?.id??null:null;return d(X,{notice:Bt(o,f.outcome),onDismissNotice:()=>{s(null),f.dismiss()},id:`linked-apps`,title:e(`access.linkedAppsSection.linkedApps`,`Linked apps`),icon:D,description:e(`access.linkedAppsSection.externalIntegrationsAlexaLinkedTo`,`External integrations (Alexa, …) linked to this hub through OAuth. Revoking one stops that integration on its next call. Already-revoked rows can be selected and removed from the list.`),children:d(jt,{rows:p,label:e(`access.linkedAppsSection.linkedApps2`,`linked apps`),isLoading:a.isLoading,loadError:a.isError?a.error?.message??`Request failed`:null,emptyText:`No linked apps — an integration appears here once it completes the account-link flow.`,expiresNone:`—`,action:{label:e(`access.linkedAppsSection.revoke`,`Revoke`),icon:g,isAvailable:e=>e.status===`active`||e.status===`revoked`,onRun:e=>void m(e),busyId:h,disabled:u.isPending||f.busy},bulk:{revoke:f,noun:sn,isSelectable:e=>e.status===`active`||e.status===`revoked`,quickSelect:[{label:e(`access.linkedAppsSection.selectRevoked`,`Select revoked`),match:e=>e.status===`revoked`}]}})})}e();var un={key:`access.nouns.session`};function dn(){let{t:e}=Y(),t=H(),i=W.useUtils(),a=Et(),o=W.auth.listSessions.useQuery(),[s,c]=r(null),l=()=>void i.auth.listSessions.invalidate(),u=W.auth.revokeSessions.useMutation({onSuccess:l,onError:e=>c(`Sign out failed: ${e.message}`)}),f=kt(un,l),p=n(()=>(o.data??[]).map(e=>Xt(e,a,{client:e=>Yt(e).label,method:Qt})),[o.data,a]),m=async n=>{await t({title:e(`access.loginSessionsSection.signOutThisSession`,`Sign out this session`),message:e(`access.loginSessionsSection.onWillHaveToSign`,`{{ownerName}} on {{name}} will have to sign in again.`,{ownerName:n.ownerName,name:n.name}),confirmLabel:e(`access.loginSessionsSection.signOut`,`Sign out`),variant:`danger`})&&(c(null),u.mutate({id:n.id}))};return d(X,{notice:Bt(s,f.outcome),onDismissNotice:()=>{c(null),f.dismiss()},id:`login-sessions`,title:e(`access.loginSessionsSection.loginSessions`,`Login sessions`),icon:de,description:e(`access.loginSessionsSection.everyBrowserAndAppSigned`,`Every browser and app signed in to this hub, for every user. Signing one out ends it at once; it has to sign in again. Your own current session is marked and never included in a bulk sign-out.`),children:d(jt,{rows:p,label:e(`common.sessionsLabel`),isLoading:o.isLoading,loadError:o.isError?o.error?.message??`Request failed`:null,emptyText:`No active sessions.`,action:{label:e(`access.loginSessionsSection.signOut`,`Sign out`),icon:le,isAvailable:e=>e.status===`active`,onRun:e=>void m(e),busyId:u.isPending&&u.variables!==void 0&&`id`in u.variables?u.variables.id:null,disabled:u.isPending||f.busy},bulk:{revoke:f,noun:un,isSelectable:e=>e.status===`active`}})})}var fn={"by-id":`helpers.authAuditWording.bulkNoun.credential`,"share-link":`helpers.authAuditWording.bulkNoun.shareLink`,"admin-token":`helpers.authAuditWording.bulkNoun.adminToken`,"login-session":`helpers.authAuditWording.bulkNoun.loginSession`};function Z(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function pn(e,t){let n=Z(e,`tokenId`);return Z(e,`name`)??(n===null?void 0:t.get(n))??n??`?`}function Q(e){return e.filter(e=>e!==null)}function mn(e){let t=Z(e,`prefix`);return t===null?null:J.t(`helpers.authAuditWording.prefix`,{prefix:t})}function hn(e,t){let n=e.detail??{};switch(e.action){case`admin-token-created`:{let e=n.expiresAt;return{title:J.t(`helpers.authAuditWording.tokenCreated`,{name:pn(n,t)}),details:Q([mn(n),typeof e==`number`?J.t(`helpers.authAuditWording.expires`,{at:Nt(e)}):null])}}case`admin-token-used`:{let e=Z(n,`path`);return{title:J.t(`helpers.authAuditWording.tokenUsed`,{name:pn(n,t)}),details:Q([mn(n),e===null?null:J.t(`helpers.authAuditWording.call`,{path:e})])}}case`token-minted`:{let e=n.expiresAt;return{title:J.t(`helpers.authAuditWording.tokenMinted`,{name:pn(n,t)}),details:Q([typeof e==`number`?J.t(`helpers.authAuditWording.expires`,{at:Nt(e)}):null])}}case`token-revoked`:return{title:J.t(`helpers.authAuditWording.anyTokenRevoked`,{name:pn(n,t)}),details:[]};case`admin-token-revoked`:return{title:J.t(`helpers.authAuditWording.tokenRevoked`,{name:pn(n,t)}),details:Q([mn(n)])};case`credentials-revoked`:{let e=Z(n,`kind`)??`credential`,t=n.revoked,r=n.skipped,i=fn[e],a=i===void 0?`${e}s`:J.t(i);return{title:J.t(`helpers.authAuditWording.bulkRevoked`,{n:typeof t==`number`?String(t):`?`,noun:a}),details:Q([typeof r==`number`&&r>0?J.t(`helpers.authAuditWording.skipped`,{count:r}):null,Z(n,`ids`)===null?null:J.t(`helpers.authAuditWording.ids`,{ids:Z(n,`ids`)??``})])}}case`second-factor-skipped`:{let e=Z(n,`method`),t=Z(n,`factors`);return{title:J.t(`helpers.authAuditWording.secondFactorSkipped`),details:Q([e===null?null:J.t(`helpers.authAuditWording.signedInWith`,{method:Qt(e)}),t===null?null:J.t(`helpers.authAuditWording.skippedFactors`,{factors:t.split(`,`).join(`, `)})])}}default:return{title:e.action,details:Object.entries(n).map(([e,t])=>`${e}: ${String(t)}`)}}}e();var gn=100;function _n(){let{user:e}=gt();return e?.isAdmin?d(yn,{}):null}function vn(){let{data:e}=Be(),{data:t}=W.auth.listTokens.useQuery(void 0);return n(()=>{let n=new Map;for(let t of e??[])n.set(t.id,t.username);let r=new Map;for(let e of t??[])r.set(e.id,e.label);return{userNameById:n,tokenNameById:r}},[e,t])}function yn(){let{t:e}=Y(),t=W.auth.listAuthAudit.useQuery({limit:gn}),{userNameById:n,tokenNameById:r}=vn(),i=t.data??[];return a(`div`,{"data-testid":`auth-audit`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[a(`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(`auth.authAuditSection.authenticationAudit`,`Authentication audit`)}),d(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:e(`auth.authAuditSection.latest`,{count:gn})})]}),d(`div`,{className:`p-4`,children:t.isLoading?a(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[d(A,{className:`h-3.5 w-3.5 animate-spin`}),e(`auth.authAuditSection.loadingAuditTrail`,`Loading audit trail…`)]}):t.isError?a(`div`,{className:`text-[11px] text-danger`,children:[e(`auth.authAuditSection.couldNotLoadTheAudit`,`Could not load the audit trail:`),` `,t.error?.message??e(`auth.authAuditSection.requestFailed`,`Request failed`)]}):i.length===0?a(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center space-y-1`,children:[d(`div`,{children:e(`auth.authAuditSection.noAuthenticationEventsRecordedYet`,`No authentication events recorded yet.`)}),d(`div`,{className:`text-[11px] text-foreground-subtle/90`,children:e(`auth.authAuditSection.thisTrailRecordsAdminToken`,`This trail records admin-token create/use/revoke, trusted-network 2FA skips, and credential revokes (including single share-link revoke). Browser password logins are not listed here.`)})]}):d(`ul`,{className:`divide-y divide-border rounded-md border border-border max-h-[420px] overflow-y-auto`,children:i.map(e=>d(bn,{record:e,userName:e.userId===void 0?null:n.get(e.userId)??e.userId,tokenNameById:r},e.id))})})]})}function bn({record:e,userName:t,tokenNameById:n}){let r=hn(e,n);return a(`li`,{"data-testid":`auth-audit-row`,className:`px-3 py-2 text-xs space-y-0.5`,children:[a(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[d(`span`,{className:`font-medium text-foreground`,children:r.title}),d(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:Nt(e.at)})]}),a(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[t!==null&&d(`span`,{className:`text-foreground`,children:t}),e.ip!==void 0&&d(`span`,{className:`font-mono`,children:e.ip}),r.details.map(e=>d(`span`,{className:`font-mono`,children:e},e))]})]})}e();var $={loginSessions:`login-sessions`,linkedApps:`linked-apps`,tokens:`tokens`,scopedTokens:`scoped-tokens`,adminTokens:`admin-tokens`,shareLinks:`share-links`,externalIdentities:`external-identities`,audit:`auth-audit`},xn={[$.scopedTokens]:$.tokens,[$.adminTokens]:$.tokens,[$.shareLinks]:$.tokens};function Sn(){return[{id:$.loginSessions,label:J.t(`system.access.loginSessions`,`Login sessions`),icon:de,render:()=>d(dn,{})},{id:$.linkedApps,label:J.t(`system.access.linkedApps`,`Linked apps`),icon:D,render:()=>d(ln,{})},{id:$.tokens,label:J.t(`system.access.tokens`,`Tokens`),icon:ue,render:({createRequested:e,onCreateConsumed:t})=>d(Rt,{headerOwnsCreate:!0,createRequested:e,onCreateConsumed:t})},{id:$.externalIdentities,label:J.t(`system.access.signInLinks`,`Sign-in links`),icon:B,render:()=>d(on,{})},{id:$.audit,label:J.t(`system.access.audit`,`Audit`),icon:j,render:()=>d(_n,{})}]}function Cn({createRequested:e=!1,onCreateConsumed:t}){let{t:r}=Y(),i=n(()=>Sn(),[]),o=$t({ids:n(()=>i.map(e=>e.id),[i]),answered:!0}),s=bt(),[c]=Ct(),l=c.get(`integration`),u=l===null?void 0:xn[l];if(u!==void 0){let e=new URLSearchParams(c);return e.set(`integration`,u),d(pt,{to:`?${e.toString()}`,replace:!0})}let f=i.find(e=>e.id===o.selectedId)??i[0];return a(`div`,{className:`flex flex-col gap-3`,"data-testid":`access-page`,children:[d(_e,{appearance:`pills`,value:f?.id??$.loginSessions,onValueChange:e=>{s(`?${yt(c,e,null,null).toString()}`)},children:d(Ge,{"aria-label":r(`system.access.credentialKinds`,`Credential kinds`),children:i.map(e=>a(me,{value:e.id,"data-testid":`access-kind-${e.id}`,children:[d(e.icon,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),e.label]},e.id))})}),f===void 0?null:d(`div`,{role:`region`,"aria-label":f.label,"data-testid":`access-kind-body`,children:f.render({createRequested:e&&f.id===$.tokens,onCreateConsumed:t??(()=>void 0)})},f.id)]})}function wn(e,t){if(e===$.tokens)return a(q,{size:`sm`,type:`button`,"data-testid":`access-new-token`,onClick:t,children:[d(ue,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),J.t(`system.access.newToken`,`New token`)]})}function Tn(){let[e,t]=r(!1);return{createRequested:e,requestCreate:()=>t(!0),clearCreate:()=>t(!1)}}e();var En=[`oidcConnections`,`listConnections`],Dn=[`oidcConnections`,`connectionFormSchema`],On={displayName:`OpenID Connect`,icon:`shield-check`,issuerUrl:``,clientId:``,clientSecret:``,redirectUri:``,scopes:`openid profile email`,usernameClaim:`preferred_username`},kn=/^[a-z0-9][a-z0-9-]{0,63}$/;function An(e){return e instanceof Error?e.message:String(e)}function jn(e,t){if(t)return typeof e==`string`&&e.length>0?e:void 0;if(L(e))return ne;if(typeof e==`string`&&e.length>0)return e;te(e)}function Mn(e){return typeof e!=`object`||!e?!1:Array.isArray(Reflect.get(e,`sections`))}function Nn({addonId:e}){let{t:f}=Y(),p=ee(),m=c(),h=H(),_=Je({editKey:`oidcEdit`,newKey:`oidcNew`}),[v,y]=r(!1),[b,x]=r(null),[S,C]=r(``),[w,T]=r({...On}),D=l(null),O=o({queryKey:[...En,e],queryFn:async()=>p.trpcClient.oidcConnections.listConnections.query({})}),k=o({queryKey:Dn,queryFn:async()=>p.trpcClient.oidcConnections.connectionFormSchema.query({})}),A=O.data??[],j=Mn(k.data)?k.data:void 0,M=_.state,N=M.mode===`edit`?A.find(e=>e.id===M.id)??null:null;t(()=>{if(_.state.mode===`edit`&&N!==null){let e=`edit:${N.id}`;if(D.current===e)return;D.current=e,x(null),C(N.id),T(N.formValues===void 0?{...On}:{...N.formValues});return}if(_.state.mode===`new`){if(D.current===`new`)return;D.current=`new`,x(null),C(``),T({...On})}},[N,_.state]);let F=i(async()=>{await m.invalidateQueries({queryKey:En})},[m]),I=u({mutationFn:async e=>p.trpcClient.oidcConnections.deleteConnection.mutate({id:e}),onSuccess:async()=>F()}),L=i(async e=>{await h({title:f(`system.oidcSettingsConnections.deleteOidcConnection`,`Delete OIDC connection?`),message:f(`system.oidcSettingsConnections.removeTheLoginButtonAnd`,`Remove “{{displayName}}” ({{id}}). The login button and IdP credentials for this id are dropped.`,{displayName:e.displayName,id:e.id}),confirmLabel:f(`common.delete`,`Delete`),cancelLabel:f(`common.cancel`,`Cancel`),variant:`danger`})&&(await I.mutateAsync(e.id),_.state.mode===`edit`&&_.state.id===e.id&&(_.close(),D.current=null))},[h,I,_,f]),te=i(async()=>{let e=w.displayName,t=typeof e==`string`&&e.trim()!==``?e.trim():``;if(t===``){x(`Display name is required.`);return}let n=_.state.mode===`new`,r=n?S.trim():N?.id??``;if(n&&!kn.test(r)){x(`Instance id must be a lowercase slug (e.g. authentik, google).`);return}if(r===``){x(`That connection is no longer available.`);return}let i=jn(w.clientSecret,n),a=w.icon,o=w.issuerUrl,s=w.clientId,c=w.redirectUri,l=w.scopes,u=w.usernameClaim,d=u===`email`||u===`sub`?u:`preferred_username`;y(!0),x(null);try{n&&await p.trpcClient.oidcConnections.createConnection.mutate({id:r,displayName:t}),await p.trpcClient.oidcConnections.updateConnection.mutate({id:r,displayName:t,icon:typeof a==`string`?a:`shield-check`,issuerUrl:typeof o==`string`?o:``,clientId:typeof s==`string`?s:``,...i===void 0?{}:{clientSecret:i},redirectUri:typeof c==`string`?c:``,scopes:typeof l==`string`?l:`openid profile email`,usernameClaim:d}),await F(),_.close(),D.current=null}catch(e){x(An(e))}finally{y(!1)}},[S,N?.id,_,w,F,p]),ne=n(()=>[{key:`id`,header:f(`system.oidcSettingsConnections.id`,`Id`),sortValue:e=>e.id,render:e=>d(`span`,{className:`font-mono text-xs text-foreground`,children:e.id})},{key:`name`,header:f(`system.oidcSettingsConnections.name`,`Name`),sortValue:e=>e.displayName,render:e=>d(`span`,{className:`truncate font-medium text-foreground`,children:e.displayName})},{key:`issuer`,header:f(`system.oidcSettingsConnections.issuer`,`Issuer`),sortValue:e=>e.issuerUrl,render:e=>d(`span`,{className:`truncate text-xs text-foreground-muted`,children:e.issuerUrl===``?`—`:e.issuerUrl})},{key:`status`,header:f(`system.oidcSettingsConnections.status`,`Status`),notSortableReason:`Badge`,render:e=>d(U,{variant:e.configured?`success`:`warning`,children:e.configured?f(`system.oidcSettingsConnections.configured`,`Configured`):f(`system.oidcSettingsConnections.notConfigured`,`Not configured`)})},{key:`actions`,header:``,align:`right`,notSortableReason:`Row actions`,nowrap:!0,render:e=>a(`div`,{className:`flex justify-end gap-1`,children:[d(q,{type:`button`,size:`sm`,variant:`secondary`,onClick:t=>{t.stopPropagation(),_.openEdit(e.id)},children:f(`common.edit`,`Edit`)}),d(q,{type:`button`,size:`sm`,variant:`ghost`,"aria-label":f(`system.oidcSettingsConnections.delete`,`Delete {{displayName}}`,{displayName:e.displayName}),title:f(`common.delete`,`Delete`),onClick:t=>{t.stopPropagation(),L(e)},children:d(g,{className:`h-3.5 w-3.5 text-danger`})})]})}],[_,L,f]),R=_.state.mode===`new`,z=R||N!==null,re=R?`new`:N===null?`closed`:`edit:${N.id}:${N.configured?`cfg`:`empty`}`;return a(`div`,{className:`flex min-h-0 flex-col gap-3`,"data-testid":`oidc-settings-connections`,children:[a(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[a(`p`,{className:`text-sm text-foreground-muted`,children:[f(`system.oidcSettingsConnections.eachRowIsOneIdp`,`Each row is one IdP. Redirect URI:`),` `,d(`span`,{className:`font-mono text-xs`,children:`/addon/${e}/<id>/callback`})]}),a(q,{type:`button`,size:`sm`,"data-testid":`oidc-connections-add`,onClick:()=>_.openNew(),children:[d(E,{className:`h-3.5 w-3.5`}),f(`system.oidcSettingsConnections.addConnection`,`Add connection`)]})]}),O.isError?d(`p`,{className:`text-sm text-danger`,children:f(`system.oidcSettingsConnections.couldNotLoadConnections`,`Could not load connections.`)}):null,O.isPending?d(Le,{className:`h-32 w-full`}):d(Ie,{columns:ne,rows:A,rowKey:e=>e.id,pageSize:25,emptyMessage:f(`system.oidcSettingsConnections.noOidcConnectionsYetAdd`,`No OIDC connections yet. Add one to register an IdP.`),onRowClick:e=>_.openEdit(e.id),defaultSort:{columnKey:`name`,dir:`asc`}}),d(Me,{open:z,onClose:()=>{_.close(),x(null),D.current=null},title:R?f(`system.oidcSettingsConnections.addOidcConnection`,`Add OIDC connection`):f(`system.oidcSettingsConnections.edit`,`Edit {{value1}}`,{value1:N?.displayName??`connection`}),icon:P,width:`xl`,testId:`oidc-connection-editor`,error:b,footer:d(q,{type:`button`,size:`sm`,disabled:v||R&&S.trim()===``,onClick:()=>void te(),children:v?f(`system.oidcSettingsConnections.saving`,`Saving…`):f(`common.save`,`Save`)}),children:z?a(s,{children:[R?a(`div`,{children:[d(be,{htmlFor:`oidc-connection-id`,children:f(`system.oidcSettingsConnections.instanceId`,`Instance id`)}),d(he,{id:`oidc-connection-id`,value:S,onChange:e=>C(e.target.value),placeholder:`authentik`,autoComplete:`off`}),d(`p`,{className:`mt-1 text-xs text-foreground-muted`,children:f(`system.oidcSettingsConnections.urlSlugAppearsInAddon`,`URL slug — appears in /addon/{{addonId}}/<id>/callback. Stable; renaming is not supported after save.`,{addonId:e})})]}):a(`p`,{className:`text-sm text-foreground-muted`,children:[f(`system.oidcSettingsConnections.instanceId2`,`Instance id:`),` `,d(`span`,{className:`font-mono`,children:N?.id})]}),j===void 0?d(`p`,{className:`text-sm text-foreground-muted`,children:f(`system.oidcSettingsConnections.loadingForm`,`Loading form…`)}):d(rt,{schema:j,values:w,onChange:T,bare:!0},re)]}):null})]})}e();var Pn=3e4,Fn=[{capName:`auth-provider`,stageBadge:null},{capName:`user-passkeys`,stageBadge:`Second factor`}],In={titleKey:`system.authentication.sectionTitle`,subtitleKey:`system.authentication.sectionSubtitle`,emptyTitleKey:`system.authentication.sectionEmptyTitle`,emptyDescriptionKey:`system.authentication.sectionEmptyDescription`,installLabelKey:`system.authentication.sectionInstall`};function Ln(e){return e===`local-auth`?{headline:`Username + password (local).`,icon:oe,bullets:[`Users live in the hub’s SQLite database — no IdP roundtrip.`,`TOTP / 2FA is self-enrolled: each user enables it from their own profile page (My access → Two-factor authentication).`,`Scoped tokens, admin tokens and sessions are managed from Identity → Tokens & sessions.`],setupSteps:[`A fresh hub has one account, admin / changeme — the first sign-in asks for a new password. Add users from Users → New user.`,`Hand out either passwords or scoped tokens — both validate through this provider.`]}:e.startsWith(`auth-oidc`)?{headline:`OpenID Connect (Google, Microsoft, Okta, Keycloak, …).`,icon:V,bullets:[`Three-leg redirect flow with PKCE S256 + nonce.`,`id_token is signature-verified against the IdP’s JWKS — no implicit trust.`,`Explicit linking only: an IdP account signs in only the CamStack user who linked it from their profile (My access → Linked sign-in accounts). No auto-created users, no email matching.`,`The linked user’s role, scopes and two-factor authentication apply.`],setupSteps:[`Register a web app at your IdP and copy the client_id + client_secret.`,"Choose a stable instance id (slug). Set the IdP redirect URI to `https://<this-hub>/addon/auth-oidc/<id>/callback`.",`In Settings below, Add connection — enter the id, issuer, and credentials; Save.`,`Each user then links their IdP account from My access → Linked sign-in accounts.`]}:e.startsWith(`auth-saml`)?{headline:`SAML 2.0 — enterprise SSO (Azure AD, Okta, OneLogin).`,icon:V,bullets:[`Heavier handshake than OIDC — exchange metadata XML with your IdP.`,`Group → role mapping via SAML assertions.`]}:e.startsWith(`auth-webauthn`)||e.startsWith(`auth-passkey`)?{headline:`Passkeys / WebAuthn — passwordless second factor.`,icon:f,bullets:[`Enroll a YubiKey, Touch ID, or platform passkey per user.`,`Resistant to phishing — the browser binds the credential to your hub origin.`]}:e.startsWith(`auth-totp`)?{headline:`TOTP — second factor.`,icon:f,bullets:[`Time-based codes from an authenticator app (RFC 6238).`,`Compatible with Google Authenticator, Aegis, 1Password, Bitwarden, etc.`]}:{headline:`Authentication provider.`,icon:P,bullets:[`Generic authentication provider. No additional hints registered.`]}}function Rn(){let{t:e}=Y(),t=ot({capName:Fn[0].capName},{refetchInterval:Pn}),r=ot({capName:Fn[1].capName},{refetchInterval:Pn}),i=$e(void 0,{refetchInterval:Pn}),a=n(()=>an(i.data??[]),[i.data]),o=n(()=>{let e=[],n=[t.data??[],r.data??[]];for(let[t,r]of Fn.entries())for(let i of n[t]??[])e.push({addonId:i.addonId,displayName:a.get(i.addonId)??i.addonId,isActive:i.isActive,capName:r.capName,stageBadge:r.stageBadge});return e},[t.data,r.data,a]),s=[{id:`authentication`,label:e(`system.authentication.authenticationProviders`,`Authentication providers`),install:{capability:Fn[0].capName,label:e(In.installLabelKey)},entries:o.map(t=>({id:t.addonId,name:t.displayName,fallbackIcon:P,...rn(t.isActive),render:()=>d(en,{addonId:t.addonId,displayName:t.displayName,capName:t.capName,isActive:t.isActive,badges:t.stageBadge===null?null:d(U,{variant:`info`,className:tn,children:t.stageBadge}),settingsContent:t.addonId.startsWith(`auth-oidc`)?d(Nn,{addonId:t.addonId}):void 0,panels:[{id:`about`,title:e(`system.authentication.about`,`About`),icon:Ln(t.addonId).icon,content:d(zn,{addonId:t.addonId})}]})}))}];return d(nn,{embedded:!0,icon:P,title:e(In.titleKey),subtitle:e(In.subtitleKey),groups:s,isLoading:t.isLoading||r.isLoading,emptyTitle:e(In.emptyTitleKey),emptyDescription:e(In.emptyDescriptionKey)})}function zn({addonId:e}){let{t}=Y(),n=Ln(e),r=n.icon;return a(`div`,{className:`space-y-3 rounded-lg border border-border bg-surface p-2 sm:p-4`,children:[a(`div`,{className:`flex items-start gap-2.5`,children:[d(r,{className:`h-4 w-4 mt-0.5 text-primary shrink-0`}),d(`div`,{className:`text-xs text-foreground font-medium`,children:n.headline})]}),d(`ul`,{className:`text-xs text-foreground-subtle space-y-1.5 pl-6 list-disc`,children:n.bullets.map((e,t)=>d(`li`,{children:e},t))}),n.setupSteps&&n.setupSteps.length>0&&a(`div`,{className:`rounded-md border border-border bg-surface-hover/40 px-3 py-2.5 space-y-1.5`,children:[a(`div`,{className:`flex items-center gap-1.5 text-[10px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:[d(ae,{className:`h-3 w-3`}),t(`system.authentication.setupSteps`,`Setup steps`)]}),d(`ol`,{className:`text-xs text-foreground space-y-0.5 pl-4 list-decimal`,children:n.setupSteps.map((e,t)=>d(`li`,{children:e},t))})]}),e===`local-auth`&&a(`div`,{className:`rounded-md border border-info/30 bg-info/5 px-3 py-2 flex items-start gap-2 text-[11px] text-foreground`,children:[d(k,{className:`h-3.5 w-3.5 mt-0.5 text-info shrink-0`}),d(`span`,{children:d(_t,{i18nKey:`system.authentication.totpNote`,components:{access:d(mt,{to:`/system/my-access`,className:`underline text-primary`}),users:d(mt,{to:`/system/identity?tab=users`,className:`underline text-primary`})}})})]})]})}function Bn({isPending:e,error:t,what:n,onRetry:r,children:i}){let{t:o}=Y();return e?a(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,role:`status`,"data-testid":`query-pending`,children:[d(A,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),o(`certificates.queryBody.reading`,{what:n})]}):t===null?i:d(G,{title:o(`certificates.queryBody.couldNotRead`,`Could not read {{what}}`,{what:n}),message:t.message.length>0?t.message:o(`certificates.queryBody.requestFailed`,`Request failed`),onRetry:r})}function Vn(){let{t:e}=Y(),t=W.deviceCredentials.getDeviceCaStatus.useQuery({}),n=t.data;return d(X,{id:`device-ca`,title:e(`certificates.deviceCaCard.deviceCertificateAuthority`,`Device certificate authority`),icon:P,description:e(`certificates.deviceCaCard.signsTheCertificateEachPaired`,`Signs the certificate each paired device holds. It is created the first time a device is paired.`),children:d(Bn,{isPending:t.isPending,error:t.error,what:`the device CA`,onRetry:()=>void t.refetch(),children:n!==void 0&&a(`div`,{className:`space-y-1`,"data-testid":`device-ca-status`,children:[a(K,{label:e(`certificates.deviceCaCard.state`,`State`),children:[n.state===`ready`&&d(U,{variant:`success`,children:e(`certificates.deviceCaCard.ready`,`Ready`)}),n.state===`absent`&&d(U,{variant:`default`,children:e(`certificates.deviceCaCard.notCreatedYet`,`Not created yet`)}),n.state===`unavailable`&&d(U,{variant:`danger`,children:e(`certificates.deviceCaCard.unavailable`,`Unavailable`)})]}),n.state===`ready`&&a(s,{children:[d(K,{label:e(`certificates.deviceCaCard.subject`,`Subject`),valueClassName:`font-mono`,children:n.subject}),d(K,{label:e(`certificates.deviceCaCard.fingerprintSha256`,`Fingerprint (SHA-256)`),valueClassName:`font-mono`,children:n.fingerprintSha256}),d(K,{label:e(`certificates.deviceCaCard.validUntil`,`Valid until`),children:n.validTo})]}),n.state===`unavailable`&&d(K,{label:e(`certificates.deviceCaCard.reason`,`Reason`),children:d(`span`,{className:`text-danger`,children:n.reason})})]})})})}e();function Hn(){let{t:e}=Y(),t=W.useUtils(),n=W.deviceCredentials.getDeviceCertificateSettings.useQuery({}),[i,o]=r(null),s=W.deviceCredentials.setDeviceCertificateSettings.useMutation({onSuccess:()=>{o(null),t.deviceCredentials.getDeviceCertificateSettings.invalidate()},onError:e=>o(`Could not save: ${e.message}`)});return d(Bn,{isPending:n.isPending,error:n.error,what:`the enrollment setting`,onRetry:()=>void n.refetch(),children:n.data!==void 0&&a(K,{label:e(`certificates.deviceSettingsRow.usersCanEnrollTheirOwn`,`Users can enroll their own devices`),actions:d(Ue,{checked:n.data.selfEnrollment===`allowed`,disabled:s.isPending,"aria-label":e(`certificates.deviceSettingsRow.usersCanEnrollTheirOwn`,`Users can enroll their own devices`),onCheckedChange:e=>s.mutate({selfEnrollment:e?`allowed`:`disabled`})}),children:[d(`span`,{className:`text-[11px] text-foreground-subtle`,children:n.data.selfEnrollment===`allowed`?e(`certificates.deviceSettingsRow.allowedAUserSignedIn`,`Allowed - a user signed in on a phone can keep it signed in. Pairing by QR works either way.`):e(`certificates.deviceSettingsRow.disabledOnlyAnAdminCan`,`Disabled - only an admin can pair a device, with a QR code.`)}),i!==null&&d(`span`,{className:`block text-[11px] text-danger`,children:i})]})})}e();function Un(e){let[n,i]=r(()=>Date.now());return t(()=>{let t=setInterval(()=>i(Date.now()),e);return()=>clearInterval(t)},[e]),n}e();var Wn=80,Gn=208;function Kn({open:e,users:t,onClose:n,onPaired:i}){let{t:o}=Y(),s=W.deviceCredentials.startEnrollment.useMutation({onSuccess:i}),[c,l]=r(``),[u,p]=r(``),m=c===``?t[0]?.id??``:c,h=s.data,g=()=>{s.reset(),p(``),n()};return d(Me,{open:e,onClose:g,title:o(`certificates.pairDeviceDialog.pairADevice`,`Pair a device`),icon:f,width:`md`,testId:`pair-device-dialog`,error:s.isError?s.error.message:null,footer:h===void 0?a(q,{type:`button`,onClick:()=>{let e=u.trim();m===``||e===``||s.mutate({userId:m,deviceName:e})},disabled:s.isPending||m===``||u.trim()===``,children:[s.isPending&&d(A,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),o(`certificates.pairDeviceDialog.createPairingCode`,`Create pairing code`)]}):d(q,{type:`button`,variant:`outline`,onClick:g,children:o(`certificates.pairDeviceDialog.done`,`Done`)}),children:h===void 0?a(`div`,{className:`space-y-3`,children:[d(`p`,{className:`text-[11px] text-foreground-subtle`,children:o(`certificates.pairDeviceDialog.createsAOneTimeCode`,`Creates a one-time code for a phone you hold. Scan it with the CamStack app on that phone; the phone then stays signed in as the chosen user until you revoke it.`)}),d(ct,{label:o(`certificates.pairDeviceDialog.user`,`User`),required:!0,children:d(Ce,{value:m,onChange:e=>l(e.target.value),options:t.map(e=>({value:e.id,label:e.username}))})}),d(ct,{label:o(`certificates.pairDeviceDialog.deviceName`,`Device name`),required:!0,description:o(`certificates.pairDeviceDialog.howThisPhoneIsListed`,`How this phone is listed, e.g. Anna's iPhone.`),children:d(he,{value:u,maxLength:Wn,onChange:e=>p(e.target.value),placeholder:o(`certificates.pairDeviceDialog.annaSIphone`,`Anna's iPhone`),autoFocus:!0})})]}):d(qn,{enrollUrl:h.enrollUrl,expiresAt:h.expiresAt,hubKnown:h.hubOrigin!==null,onRestart:()=>s.reset()})})}function qn({enrollUrl:e,expiresAt:t,hubKnown:n,onRestart:r}){let{t:i}=Y(),o=Wt(t,Un(1e3));return d(`div`,{className:`space-y-3`,"data-testid":`pair-issued`,children:a(`div`,{className:`flex flex-col items-center gap-3 sm:flex-row sm:items-start`,children:[d(`div`,{className:o.expired?`opacity-30`:void 0,children:d(we,{value:e,size:Gn,alt:i(`certificates.pairDeviceDialog.enrollmentQrCode`,`Enrollment QR code`)})}),a(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[d(`p`,{className:`text-[11px] text-foreground-subtle`,children:i(`certificates.pairDeviceDialog.openTheCamstackAppOn`,`Open the CamStack app on the phone and scan this code. It works once.`)}),d(`div`,{className:`text-sm font-semibold tabular-nums text-foreground`,role:`timer`,"data-testid":`pair-countdown`,children:o.expired?i(`certificates.pairDeviceDialog.expiredCreateANewCode`,`Expired - create a new code`):i(`certificates.pairDeviceDialog.expiresIn`,`Expires in {{label}}`,{label:o.label})}),a(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[d(`code`,{className:`min-w-0 flex-1 select-all break-all font-mono text-[11px] text-foreground`,children:e}),d(Ae,{value:e,srLabel:`Enrollment link`})]}),!n&&a(`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(_,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`,"aria-hidden":!0}),d(`span`,{children:i(`certificates.pairDeviceDialog.theHubCouldNotName`,`The hub could not name an address for this link, so the app must already know it.`)})]}),o.expired&&d(q,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:i(`certificates.pairDeviceDialog.newCode`,`New code`)})]})]})})}e();var Jn={key:`access.nouns.device`};function Yn({pairOpen:e,onPairClose:t}){let{t:i}=Y(),o=H(),s=We(),c=W.useUtils(),l=W.deviceCredentials.listDeviceCredentials.useQuery({includeRevoked:!0}),u=Be(),[p,_]=r(null),[v,y]=r(null),b=()=>void c.deviceCredentials.listDeviceCredentials.invalidate(),x=e=>t=>{y(null),_(`${e} failed: ${t.message}`)},S=()=>{y(null),b()},C=W.deviceCredentials.revokeDeviceCredential.useMutation({onSuccess:S,onError:x(`Revoke`)}),w=W.deviceCredentials.deleteDeviceCredential.useMutation({onSuccess:e=>{e.result!==`deleted`&&_(e.result===`live`?`Only a revoked device can be deleted: revoke it first.`:`That device no longer exists.`),S()},onError:x(`Delete`)}),T=W.deviceCredentials.renameDeviceCredential.useMutation({onSuccess:S,onError:x(`Rename`)}),E=Ot(Jn,e=>C.mutateAsync({id:e}),b),D=E.busy||v!==null,O=n(()=>(l.data??[]).map(Ut),[l.data]),k=async e=>{await o({title:i(`certificates.devicesCard.revoke`,`Revoke "{{name}}"?`,{name:e.name}),message:i(`certificates.devicesCard.sDeviceStopsSigningIn`,`{{ownerName}}'s device stops signing in at once and its open sessions end. To use it again it has to be paired anew. This cannot be undone.`,{ownerName:e.ownerName}),confirmLabel:i(`certificates.devicesCard.revoke2`,`Revoke`),variant:`danger`})&&(_(null),y(e.id),C.mutate({id:e.id}))},A=async e=>{await o({title:i(`certificates.devicesCard.delete`,`Delete "{{name}}"?`,{name:e.name}),message:i(`certificates.devicesCard.isRemovedFromTheList`,`{{name}} is removed from the list. The audit trail keeps the revocation.`,{name:e.name}),confirmLabel:i(`common.delete`,`Delete`),variant:`danger`})&&(_(null),y(e.id),w.mutate({id:e.id}))},ee=async e=>{let t=(await s({title:i(`certificates.devicesCard.renameDevice`,`Rename device`),label:i(`certificates.devicesCard.deviceName`,`Device name`),defaultValue:e.name,confirmLabel:i(`certificates.devicesCard.rename`,`Rename`)}))?.trim()??``;t===``||t===e.name||(_(null),y(e.id),T.mutate({id:e.id,deviceName:t}))},j={label:i(`certificates.devicesCard.revoke2`,`Revoke`),icon:h,isAvailable:Mt,onRun:e=>void k(e),busyId:C.isPending?v:null,disabled:D},M=[{label:i(`certificates.devicesCard.rename`,`Rename`),icon:m,tone:`neutral`,isAvailable:()=>!0,onRun:e=>void ee(e),busyId:T.isPending?v:null,disabled:D},{label:i(`common.delete`,`Delete`),icon:g,isAvailable:zt,onRun:e=>void A(e),busyId:w.isPending?v:null,disabled:D}];return a(X,{id:`devices`,title:i(`certificates.devicesCard.devices`,`Devices`),icon:f,description:i(`certificates.devicesCard.phonesThatStaySignedIn`,`Phones that stay signed in with a certificate instead of a login. Revoking one signs it out at once; it has to be paired again.`),notice:Bt(p,E.outcome),onDismissNotice:()=>{_(null),E.dismiss()},children:[d(Hn,{}),d(jt,{rows:O,label:i(`certificates.devicesCard.label`),isLoading:l.isPending,loadError:l.error===null?null:l.error.message||`Request failed`,emptyText:`No devices paired yet.`,expiresNone:`—`,action:j,extraActions:M,bulk:{revoke:E,noun:Jn,isSelectable:Mt}}),d(Kn,{open:e,users:u.data??[],onClose:t,onPaired:b})]})}var Xn=/-----BEGIN CERTIFICATE-----[\s\S]+?-----END CERTIFICATE-----/,Zn=/-----BEGIN ((?:RSA |EC |ENCRYPTED )?PRIVATE KEY)-----[\s\S]+?-----END \1-----/,Qn={certificate:`.pem,.crt,.cer`,privateKey:`.pem,.key`,ca:`.pem,.crt,.cer`};function $n(e,t){if(t.trim()===``)return null;if(e===`privateKey`){let e=Zn.exec(t);return e===null?Xn.test(t)?J.t(`helpers.pemFile.isCert`):J.t(`helpers.pemFile.notKey`):e[1]===`ENCRYPTED PRIVATE KEY`?J.t(`helpers.pemFile.encrypted`):null}return Xn.test(t)?e===`certificate`&&Zn.test(t)?J.t(`helpers.pemFile.certHasKey`):null:Zn.test(t)?J.t(`helpers.pemFile.isKey`):J.t(`helpers.pemFile.notCert`)}function er(e){return e.text()}e();function tr({kind:e,label:t,value:n,onChange:i,rows:o=6}){let{t:s}=Y(),c=l(null),[u,f]=r(null),[p,m]=r(null),h=p??$n(e,n),g=`pem-${e}`,_=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t!==void 0){f(t.name);try{let e=await er(t);m(null),i(e)}catch(e){m(`Could not read ${t.name}: ${e instanceof Error?e.message:String(e)}`)}}};return a(`div`,{className:`space-y-1`,children:[a(`div`,{className:`flex items-center justify-between gap-2`,children:[d(`label`,{htmlFor:g,className:`text-[11px] text-foreground-subtle`,children:t}),a(`div`,{className:`flex min-w-0 items-center gap-2`,children:[u!==null&&d(`span`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,"data-testid":`${g}-file-name`,children:u}),d(`input`,{ref:c,type:`file`,accept:Qn[e],onChange:e=>void _(e),className:`hidden`,"data-testid":`${g}-file`}),a(q,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>c.current?.click(),children:[d(se,{className:`mr-1 h-3 w-3`}),s(`system.pemField.chooseFile`,`Choose file`)]})]})]}),d(`textarea`,{id:g,value:n,onChange:e=>{f(null),m(null),i(e.target.value)},rows:o,"aria-invalid":h!==null,className:`w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`}),h!==null&&d(`p`,{className:`text-[11px] text-danger`,role:`alert`,children:h})]})}e();var nr=30;function rr(e){let t=Date.parse(e);return!Number.isNaN(t)&&Date.now()-t<nr*864e5}function ir(e){if(e===null||e===``)return`—`;let t=e.replace(/:/g,``);return t.length<=16?e:`${t.slice(0,8)}…${t.slice(-8)}`}function ar(){let{t:e}=Y(),t=c(),n=je(void 0,{refetchInterval:15e3}),i=tt({onSuccess:()=>void t.invalidateQueries({queryKey:[[`localNetwork`]]})}),o=Re({onSuccess:()=>void t.invalidateQueries({queryKey:[[`localNetwork`]]})}),s=Oe({onSuccess:()=>void t.invalidateQueries({queryKey:[[`localNetwork`]]})}),l=dt({onSuccess:()=>{m(!1),g(``),v(``),b(``),t.invalidateQueries({queryKey:[[`localNetwork`]]})}}),u=n.data,[f,m]=r(!1),[h,g]=r(``),[_,v]=r(``),[y,b]=r(``),S=()=>{if(!u?.caCertPem)return;let e=new Blob([u.caCertPem],{type:`application/x-pem-file`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`camstack-ca.crt`,n.click(),URL.revokeObjectURL(t)},C=u?.mode===`uploaded`?`Uploaded`:u?.mode===`generated`?`Generated local CA`:`TLS disabled`;return d(Xe,{headingId:`local-access-certificate`,title:e(`system.localAccess.certificate`,`Certificate`),icon:x,children:a(`div`,{className:`${p} space-y-3`,children:[n.isError&&d(`p`,{className:`text-xs text-danger`,children:e(`system.localAccess.couldNotReadTlsStatus`,`Could not read TLS status.`)}),u?.reissueError&&d(G,{variant:`warning`,title:e(`system.localAccess.certificateReissue`,`Certificate reissue`),message:u.reissueError}),u?.restartRequired&&d(G,{variant:`warning`,title:e(`system.localAccess.restartRequired`,`Restart required`),message:e(`system.localAccess.theHttpsListenerStillServes`,`The HTTPS listener still serves the previous certificate. Restart the hub to apply it.`)}),u?.caMissing===!0&&d(G,{variant:`warning`,title:e(`system.localAccess.caMissingTitle`,`CA missing - devices cannot trust this hub`),message:e(`system.localAccess.caMissingBody`,"The uploaded certificate was not issued by a public CA and no CA was stored with it, so Download CA has nothing to hand out. Upload the certificate again together with its CA (for mkcert, the rootCA.pem in the folder `mkcert -CAROOT` prints).")}),u?.caReplacedAt!=null&&rr(u.caReplacedAt)&&d(G,{variant:`warning`,title:e(`system.localAccess.caReplacedTitle`,`The local CA was replaced - re-install it on your devices`),message:e(`system.localAccess.caReplacedBody`,`The previous local CA had no name constraints: if its key ever leaked it could vouch for any website. The hub now uses a CA limited to private addresses and local names. Download it again and trust it on every phone and computer that used the old one (replaced {{when}}).`,{when:new Date(u.caReplacedAt).toLocaleString()})}),a(`dl`,{className:`grid grid-cols-1 gap-2 text-xs sm:grid-cols-2`,children:[a(`div`,{children:[d(`dt`,{className:`text-foreground-subtle`,children:e(`system.localAccess.mode`,`Mode`)}),d(`dd`,{className:`font-medium`,children:C})]}),a(`div`,{children:[d(`dt`,{className:`text-foreground-subtle`,children:e(`system.localAccess.validTo`,`Valid to`)}),d(`dd`,{className:`font-mono`,children:u?.validTo?new Date(u.validTo).toLocaleString():`—`})]}),a(`div`,{children:[d(`dt`,{className:`text-foreground-subtle`,children:e(`system.localAccess.leafSha256`,`Leaf SHA-256`)}),d(`dd`,{className:`font-mono`,title:u?.leafFingerprintSha256??void 0,children:ir(u?.leafFingerprintSha256??null)})]}),u?.storedUpload!=null&&a(`div`,{children:[d(`dt`,{className:`text-foreground-subtle`,children:e(`system.localAccess.storedUpload`,`Stored upload`)}),d(`dd`,{className:`font-medium`,children:e(`system.localAccess.storedUploadValue`,`valid to {{validTo}}, {{ca}}`,{validTo:new Date(u.storedUpload.validTo).toLocaleDateString(),ca:u.storedUpload.hasCa?e(`system.localAccess.storedUploadWithCa`,`with its CA`):e(`system.localAccess.storedUploadNoCa`,`no CA`)})})]}),a(`div`,{children:[d(`dt`,{className:`text-foreground-subtle`,children:e(`system.localAccess.caSha256`,`CA SHA-256`)}),d(`dd`,{className:`font-mono`,title:u?.caFingerprintSha256??void 0,children:u?.mode===`uploaded`&&u.caFingerprintSha256===null?d(`span`,{className:`font-sans text-foreground-subtle`,children:e(`system.localAccess.issuerNotIncludedInThe`,`Issuer not included in the upload (not the local CA)`)}):ir(u?.caFingerprintSha256??null)})]})]}),u&&u.sans.length>0&&d(`div`,{className:`flex flex-wrap gap-1`,children:u.sans.map(e=>d(`span`,{className:`rounded border border-border bg-surface px-1.5 py-0.5 font-mono text-[10px] text-foreground-subtle`,children:e},e))}),a(`div`,{className:`flex flex-wrap gap-2`,children:[d(qe,{label:e(`system.localAccess.regenerate`,`Regenerate`),title:e(`system.localAccess.issueANewLeaf`,`Issue a new leaf?`),description:e(`system.localAccess.issuesANewLeafUnder`,`Issues a new leaf under the current local CA. Clients that trust the CA keep working. The HTTPS listener reloads.`),confirmLabel:e(`system.localAccess.regenerate`,`Regenerate`),disabled:u?.mode===`uploaded`||i.isPending,action:()=>i.mutateAsync({})}),d(q,{size:`sm`,variant:`outline`,onClick:()=>m(e=>!e),children:e(`system.localAccess.upload`,`Upload`)}),u?.caCertPem&&d(q,{size:`sm`,variant:`outline`,onClick:S,children:e(`system.localAccess.downloadCa`,`Download CA`)}),u?.mode===`uploaded`&&d(qe,{label:e(`system.localAccess.revertToGenerated`,`Revert to generated`),title:e(`system.localAccess.revertTitle`,`Switch back to the generated certificate?`),description:e(`system.localAccess.keepsTheUploadedPair`,`Returns to the generated local CA. The uploaded certificate and its CA stay stored here; you can select them again.`),confirmLabel:e(`system.localAccess.revert`,`Revert`),disabled:o.isPending,action:()=>o.mutateAsync({})}),u?.mode===`generated`&&u.storedUpload!=null&&d(qe,{label:e(`system.localAccess.useUploaded`,`Use uploaded certificate`),title:e(`system.localAccess.useUploadedTitle`,`Serve the stored upload again?`),description:e(`system.localAccess.useUploadedDescription`,`The stored uploaded certificate replaces the generated one on the HTTPS listener. The generated certificate stays stored.`),confirmLabel:e(`system.localAccess.useUploaded`,`Use uploaded certificate`),disabled:s.isPending,action:()=>s.mutateAsync(void 0)})]}),f&&a(`div`,{className:`space-y-2 border-t border-border pt-3`,children:[d(tr,{kind:`certificate`,label:e(`system.localAccess.certificateOrFullChainPem`,`Certificate or full chain (PEM)`),value:h,onChange:g}),d(tr,{kind:`privateKey`,label:e(`system.localAccess.privateKeyPem`,`Private key (PEM)`),value:_,onChange:v}),d(tr,{kind:`ca`,label:e(`system.localAccess.caPemRequired`,`CA (PEM) - required unless the certificate comes from a public CA`),value:y,onChange:b,rows:4}),d(q,{size:`sm`,disabled:!h.trim()||!_.trim()||$n(`certificate`,h)!==null||$n(`privateKey`,_)!==null||$n(`ca`,y)!==null||l.isPending,onClick:()=>l.mutate({certPem:h,keyPem:_,...y.trim()?{caPem:y}:{}}),children:e(`system.localAccess.saveCertificate`,`Save certificate`)}),l.isError&&d(`p`,{className:`text-xs text-danger`,children:l.error instanceof Error?l.error.message:e(`system.localAccess.uploadFailed`,`Upload failed`)})]})]})})}var or={ok:`text-foreground-subtle`,soon:`text-warning`,expired:`text-danger`,unknown:`text-foreground-subtle`};function sr(e){let t=e.find(e=>e.isHub);return t?.https.kind===`served`?t.https.status.caFingerprintSha256:null}function cr({https:e,mesh:t,now:n}){let{t:r}=Y(),i=je().data?.caCertPem??``,o=()=>{if(i===``)return;let e=URL.createObjectURL(new Blob([i],{type:`application/x-pem-file`})),t=document.createElement(`a`);t.href=e,t.download=`camstack-ca.crt`,t.click(),URL.revokeObjectURL(e)},s=t?.ca,c=s?.state===`ready`?Date.parse(s.validTo):null,l=t?.listener;return a(`div`,{className:`space-y-1`,"data-testid":`ca-strip`,children:[d(K,{label:r(`certificates.caStrip.localHttpsCaSha256`,`Local HTTPS CA (SHA-256)`),valueClassName:`font-mono`,children:a(`span`,{className:`flex flex-wrap items-center gap-2`,children:[sr(e)??`—`,i!==``&&a(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:o,children:[d(b,{className:`h-3 w-3`,"aria-hidden":!0}),r(`certificates.caStrip.downloadCa`,`Download CA`)]})]})}),d(K,{label:r(`certificates.caStrip.clusterCaSha256`,`Cluster CA (SHA-256)`),valueClassName:`font-mono`,children:s===void 0?`—`:s.state===`ready`?s.fingerprintSha256:d(`span`,{className:`text-danger`,children:r(`certificates.caStrip.unavailable`,{reason:s.reason})})}),s?.state===`ready`&&a(K,{label:r(`certificates.caStrip.clusterCaValidUntil`,`Cluster CA valid until`),children:[s.validTo,c!==null&&!Number.isNaN(c)&&a(`span`,{className:`ml-2 text-[10px] ${or[Jt(c,n)]}`,children:[`(`,Pt(c,n),`)`]})]}),l!==void 0&&a(K,{label:r(`certificates.caStrip.nodeListener`,`Node listener`),children:[l.state===`open`&&d(U,{variant:`success`,children:r(`certificates.caStrip.open`,`Open`)}),l.state===`not-started`&&d(U,{variant:`default`,children:r(`certificates.caStrip.notStarted`,`Not started`)}),l.state===`closed`&&a(`span`,{className:`text-danger`,children:[r(`certificates.caStrip.closedSince`,{when:Ft(l.since)}),` `,l.reason]})]}),t!==void 0&&!t.registryAvailable&&a(`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(_,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`,"aria-hidden":!0}),d(`span`,{children:r(`certificates.caStrip.theCertificateRegistryIsNot`,`The certificate registry is not up, so the node list below is incomplete.`)})]})]})}function lr(e,t){let n=new Set;for(let t of e)n.add(t.nodeId);for(let e of t?.nodes??[])n.add(e.nodeId);return[...n].map(n=>{let r=e.find(e=>e.nodeId===n)??null,i=t?.nodes.find(e=>e.nodeId===n)??null;return{nodeId:n,isHub:r?.isHub??n===`hub`,online:r?.online??i?.online??!1,https:r,mesh:i}}).toSorted((e,t)=>Number(t.isHub)-Number(e.isHub)||e.nodeId.localeCompare(t.nodeId))}function ur(e){return e.isHub?J.t(`helpers.nodesModel.hubReissued`):e.mesh===null?J.t(`helpers.nodesModel.noCertRecorded`):e.online?null:J.t(`helpers.certificateModel.nodeOffline`)}function dr(e){return e.isHub||e.mesh===null?ur(e):null}var fr={ok:`text-foreground-subtle`,soon:`text-warning`,expired:`text-danger`,unknown:`text-foreground-subtle`},pr={enroll:`Issued at enrollment`,renewal:`Issued by a renewal`,boot:`Issued at boot`,pairing:`Issued at pairing`,observed:`Observed on its connection`},mr={uploaded:`Uploaded`,generated:`Generated`,disabled:`Disabled`};function hr(e){let t=e.https?.https;return t?.kind===`served`?Kt(t.status.validTo):null}function gr({ms:e,now:t}){return e===null?d(`span`,{className:`text-foreground-subtle`,children:`—`}):a(`div`,{children:[d(`div`,{children:Ft(e)}),d(`div`,{className:`text-[10px] ${fr[Jt(e,t)]}`,children:Pt(e,t)})]})}function _r({row:e}){let{t}=Y(),n=e.https?.https;return n===void 0?d(`span`,{className:`text-foreground-subtle`,children:`—`}):n.kind===`served`?a(`div`,{title:n.status.leafFingerprintSha256??``,children:[d(U,{variant:`success`,className:`text-[10px]`,children:t(`certificates.nodesColumns.served`,`Served`)}),d(`span`,{className:`ml-1.5 text-[10px] text-foreground-subtle`,children:mr[n.status.mode]}),d(`div`,{className:`mt-1 font-mono text-[10px] text-foreground-subtle`,children:Gt(n.status.leafFingerprintSha256)}),n.status.sans.length>0&&d(`div`,{className:`mt-0.5 max-w-[14rem] truncate font-mono text-[10px] text-foreground-subtle`,title:n.status.sans.join(`, `),children:n.status.sans.join(`, `)})]}):a(`div`,{className:`max-w-[16rem]`,children:[d(U,{variant:n.kind===`unreadable`?`danger`:`warning`,className:`text-[10px]`,children:n.kind===`unreadable`?t(`certificates.nodesColumns.unreadable`,`Unreadable`):t(`certificates.nodesColumns.notServed`,`Not served`)}),d(`div`,{className:`mt-1 whitespace-normal text-[10px] text-foreground-subtle`,children:n.reason})]})}function vr({row:e}){let{t}=Y(),n=e.mesh?.current??null;if(n===null)return d(`span`,{className:`text-foreground-subtle`,children:t(`certificates.nodesColumns.noneRecorded`,`None recorded`)});let r=e.mesh?.history.length??0;return a(`div`,{children:[d(`div`,{className:`font-mono text-[11px]`,title:n.serial,children:Ht(n.serial)}),d(`div`,{className:`font-mono text-[10px] text-foreground-subtle`,title:n.fingerprintSha256,children:Gt(n.fingerprintSha256)}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:[pr[n.issuedVia],r>0?` · ${t(`certificates.nodesColumns.earlier`,{count:r})}`:``]})]})}function yr({row:e}){let{t}=Y(),n=e.mesh?.presentingCurrent??null;return n===null?d(`span`,{className:`text-foreground-subtle`,children:e.online?`—`:t(`certificates.nodesColumns.offline`,`Offline`)}):n?d(U,{variant:`success`,className:`text-[10px]`,children:t(`common.yes`,`Yes`)}):d(U,{variant:`warning`,className:`text-[10px]`,children:t(`certificates.nodesColumns.noPresentsAnother`,`No - presents another`)})}function br(e){let t=e.icon;return a(q,{type:`button`,variant:`ghost`,size:`sm`,className:e.danger?`text-danger hover:bg-danger/10`:void 0,disabled:e.reason!==null||e.busy,title:e.reason??void 0,"aria-label":e.ariaLabel,onClick:e.onClick,children:[e.spinning?d(A,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):d(t,{className:`h-3 w-3`,"aria-hidden":!0}),e.label]})}function xr({reasons:e}){let{t}=Y();return a(ve,{className:`inline-block`,children:[d(Ke,{children:d(`span`,{className:`cursor-help text-[11px] text-foreground-subtle`,"data-testid":`hub-managed-note`,children:t(`certificates.nodesColumns.managedByTheHub`,`Managed by the hub`)})}),d(xe,{children:d(`ul`,{className:`max-w-xs space-y-1 whitespace-normal text-left text-[11px]`,children:e.map(e=>d(`li`,{children:e},e))})})]})}function Sr({row:e,o:t}){let{t:n}=Y(),r=e.https===null?`No HTTPS inventory for this node.`:It(e.https).reason,i=ur(e),o=dr(e),s=n=>t.running?.nodeId===e.nodeId&&t.running.action===n,c=t=>!e.isHub||t===null,l=[r,i,o].filter((e,t,n)=>e!==null&&n.indexOf(e)===t);return a(`div`,{className:`flex w-44 flex-col items-end gap-1`,children:[a(`div`,{className:`flex flex-col items-end gap-0.5`,children:[c(r)&&d(br,{label:n(`certificates.nodesColumns.renewHttps`,`Renew HTTPS`),ariaLabel:n(`certificates.nodesColumns.renewTheCertificateOn`,`Renew the certificate on {{nodeId}}`,{nodeId:e.nodeId}),icon:S,reason:r,busy:t.busy,spinning:s(`renew-https`),danger:!1,onClick:()=>t.onRenewHttps(e)}),c(i)&&d(br,{label:s(`renew-identity`)?n(`certificates.nodesColumns.renewing`,`Renewing…`):n(`certificates.nodesColumns.renewIdentity`,`Renew identity`),ariaLabel:n(`certificates.nodesColumns.renewTheClusterCertificateOf`,`Renew the cluster certificate of {{nodeId}}`,{nodeId:e.nodeId}),icon:S,reason:i,busy:t.busy,spinning:s(`renew-identity`),danger:!1,onClick:()=>t.onRenewIdentity(e)}),c(o)&&d(br,{label:n(`certificates.nodesColumns.revokeIdentity`,`Revoke identity`),ariaLabel:n(`certificates.nodesColumns.revokeTheClusterCertificateOf`,`Revoke the cluster certificate of {{nodeId}}`,{nodeId:e.nodeId}),icon:h,reason:o,busy:t.busy,spinning:s(`revoke-identity`),danger:!0,onClick:()=>t.onRevokeIdentity(e)})]}),e.isHub&&l.length>0&&d(xr,{reasons:l}),!e.isHub&&r!==null&&e.https!==null&&d(`div`,{className:`w-full whitespace-normal text-right text-[10px] text-foreground-subtle`,"data-testid":`renew-reason-${e.nodeId}`,children:r}),!e.isHub&&i!==null&&d(`div`,{className:`w-full whitespace-normal text-right text-[10px] text-foreground-subtle`,"data-testid":`mesh-reason-${e.nodeId}`,children:i})]})}function Cr(e){return[{key:`node`,header:J.t(`certificates.nodesColumns.node`,`Node`),sortValue:e=>e.isHub?``:e.nodeId.toLowerCase(),render:e=>a(`div`,{className:`flex items-center gap-1.5`,children:[d(`span`,{className:`font-medium text-foreground`,children:e.nodeId}),e.nodeId===`hub`&&d(U,{variant:`info`,className:`text-[10px]`,children:J.t(`common.hubWord`)}),!e.online&&d(U,{variant:`default`,className:`text-[10px]`,children:J.t(`common.offline`)})]})},{key:`https-state`,header:`HTTPS`,notSortableReason:`A state with a reason has no single order.`,render:e=>d(_r,{row:e})},{key:`https-expires`,header:J.t(`certificates.nodesColumns.httpsExpires`,`HTTPS expires`),sortValue:e=>hr(e),render:t=>d(gr,{ms:hr(t),now:e.now})},{key:`identity`,header:J.t(`certificates.nodesColumns.identity`,`Identity`),sortValue:e=>e.mesh?.current?.serial??null,render:e=>d(vr,{row:e})},{key:`identity-expires`,header:J.t(`certificates.nodesColumns.identityExpires`,`Identity expires`),sortValue:e=>e.mesh?.current?.notAfter??null,render:t=>d(gr,{ms:t.mesh?.current?.notAfter??null,now:e.now})},{key:`presenting`,header:J.t(`certificates.nodesColumns.inUse`,`In use`),notSortableReason:`Offline nodes have no answer to order by.`,render:e=>d(yr,{row:e})},{key:`actions`,header:J.t(`certificates.nodesColumns.actions`,`Actions`),align:`right`,notSortableReason:`Actions have no order.`,render:t=>d(Sr,{row:t,o:e})}]}e();function wr(){let{t:e}=Y(),t=H(),i=W.useUtils(),o=Un(6e4),s=W.certificates.listHttpsCertificates.useQuery(),c=W.certificates.getMeshCertificates.useQuery(),[l,u]=r(null),[f,p]=r(null),[m,h]=r(null),g=()=>{h(null),i.certificates.listHttpsCertificates.invalidate(),i.certificates.getMeshCertificates.invalidate()},_=e=>(t,n)=>{h(null),u(`${n.nodeId}: ${e} - ${t.message}`)},v=W.certificates.renewHttpsOnNode.useMutation({onSuccess:(t,n)=>{p({tone:`success`,message:t.restartRequired?e(`certificates.nodesCard.newCertificateIssuedRestartThe`,`{{nodeId}}: new certificate issued. Restart the node to serve it.`,{nodeId:n.nodeId}):e(`certificates.nodesCard.newCertificateIssuedAndServed`,`{{nodeId}}: new certificate issued and served.`,{nodeId:n.nodeId})}),g()},onError:_(`renewal failed`)}),y=W.certificates.renewMeshOnNode.useMutation({onSuccess:e=>{p(Vt(e)),g()},onError:_(`renewal could not start`)}),b=W.certificates.revokeMeshOnNode.useMutation({onSuccess:e=>{p({tone:`success`,message:`${e.nodeId}: ${e.next}`}),g()},onError:_(`revoke failed`)}),x=v.isPending||y.isPending||b.isPending,S=(e,t)=>{u(null),p(null),h({nodeId:e,action:t})},C=async n=>{await t({title:e(`certificates.nodesCard.renewHttpsOn`,`Renew HTTPS on "{{nodeId}}"?`,{nodeId:n.nodeId}),message:n.isHub?e(`certificates.nodesCard.aNewCertificateIsIssued`,`A new certificate is issued from the local CA. Clients that trust the CA keep working.`):e(`certificates.nodesCard.theNodeMakesANew`,`The node makes a new key, the hub signs it and the node switches over without a restart. It keeps serving what it had if anything fails.`),confirmLabel:e(`certificates.nodesCard.renew`,`Renew`)})&&(S(n.nodeId,`renew-https`),v.mutate({nodeId:n.nodeId}))},T=e=>{S(e.nodeId,`renew-identity`),y.mutate({nodeId:e.nodeId})},E=async n=>{await t({title:e(`certificates.nodesCard.revokeTheIdentityOf`,`Revoke the identity of "{{nodeId}}"?`,{nodeId:n.nodeId}),message:e(`certificates.nodesCard.isDisconnectedAtOnceAnd`,`{{nodeId}} is disconnected at once and can no longer connect. To bring it back it must be paired again from System → Cluster → Agents. It stays in the node list until you forget it on the Cluster page. This cannot be undone.`,{nodeId:n.nodeId}),confirmLabel:e(`certificates.nodesCard.revokeAndDisconnect`,`Revoke and disconnect`),variant:`danger`})&&(S(n.nodeId,`revoke-identity`),b.mutate({nodeId:n.nodeId}))},D=Cr({now:o,busy:x,running:m,onRenewHttps:e=>void C(e),onRenewIdentity:T,onRevokeIdentity:e=>void E(e)}),O=n(()=>lr(s.data??[],c.data),[s.data,c.data]),k=c.data?.registryAvailable??!0;return d(X,{id:`nodes`,title:e(`certificates.nodesCard.nodes`,`Nodes`),icon:w,description:e(`certificates.nodesCard.eachNodeHoldsTwoCertificates`,`Each node holds two certificates: one it serves over HTTPS, one that proves its identity to the hub. Renewing replaces a certificate without a gap; revoking an identity cuts the node off until it re-joins.`),notice:Bt(l,f),onDismissNotice:()=>{u(null),p(null)},children:d(Bn,{isPending:s.isPending||c.isPending,error:s.error??c.error,what:`node certificates`,onRetry:()=>{s.refetch(),c.refetch()},children:a(`div`,{className:`space-y-3`,children:[d(cr,{https:s.data??[],mesh:c.data,now:o}),d(Ie,{columns:D,rows:O,rowKey:e=>e.nodeId,minWidthPx:960,maxBodyHeight:Ee,defaultSort:{columnKey:`node`,dir:`asc`},emptyMessage:k?e(`certificates.nodesCard.noNodesReported`,`No nodes reported.`):e(`certificates.nodesCard.theCertificateRegistryIsNot`,`The certificate registry is not available yet, so nodes cannot be listed.`)})]})})})}function Tr({pairOpen:e,onPairClose:t}){return a(`div`,{className:`space-y-4`,"data-testid":`certificates-page`,children:[d(Yn,{pairOpen:e,onPairClose:t}),d(Vn,{}),d(ar,{}),d(wr,{})]})}function Er({userId:e,username:t,onClose:n}){let{t:r}=Y(),i=H(),o=W.useUtils(),s=nt({userId:e}),c=W.auth.listLoginMethods.useQuery(),l=ft({onSuccess:()=>void o.userManagement.listExternalIdentities.invalidate()}),u=new Map((c.data??[]).flatMap(e=>e.kind===`redirect`?[[e.id,e.label]]:[])),f=s.data??[],p=async(n,a)=>{await i({title:r(`users.externalIdentitiesModal.removeSignInLink`,`Remove sign-in link`),message:r(`users.externalIdentitiesModal.willNoLongerBeAble`,`"{{username}}" will no longer be able to sign in with this {{label}} account.`,{username:t,label:a}),confirmLabel:r(`common.remove`,`Remove`),variant:`danger`})&&l.mutate({userId:e,provider:n.provider,subject:n.subject})};return d(Se,{open:!0,onOpenChange:e=>!e&&n(),children:a(Pe,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,"data-testid":`external-identities-modal`,children:[d(it,{children:a(Ve,{className:`flex items-center gap-2`,children:[d(D,{className:`h-4 w-4 text-primary`}),a(`span`,{children:[r(`users.externalIdentitiesModal.linkedSignInAccounts`,`Linked sign-in accounts`),a(`span`,{className:`mt-0.5 block text-[11px] font-normal text-foreground-subtle`,children:[r(`users.externalIdentitiesModal.user`,`User:`),` `,d(`span`,{className:`font-mono`,children:t})]})]})]})}),d(pe,{className:`space-y-3`,children:s.isLoading?a(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[d(A,{className:`h-3.5 w-3.5 animate-spin`}),r(`common.loading`,`Loading…`)]}):f.length===0?d(`p`,{className:`text-xs text-foreground-subtle`,children:r(`users.externalIdentitiesModal.noLinkedAccountsOnlyThe`,`No linked accounts. Only the user can link one, from their own profile page.`)}):d(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:f.map(e=>{let t=u.get(e.provider),n=t??e.provider;return a(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[a(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`font-medium text-foreground truncate`,children:[n,t===void 0&&d(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:r(`users.externalIdentitiesModal.providerUnavailable`,`provider unavailable`)})]}),a(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:[e.label??e.subject,` ·`,` `,new Date(e.linkedAt).toLocaleDateString()]})]}),a(`button`,{onClick:()=>void p(e,n),disabled:l.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(fe,{className:`h-3 w-3`}),r(`common.remove`,`Remove`)]})]},`${e.provider}|${e.subject}`)})})}),d(Qe,{children:d(q,{onClick:n,variant:`secondary`,children:r(`common.close`,`Close`)})})]})})}function Dr({userId:e,username:t,onClose:n}){let{t:r}=Y(),i=c(),o=H(),l=Fe({userId:e}),u=l.data,p=()=>i.invalidateQueries({queryKey:[[`userManagement`,`getTotpStatus`]]}),m=Ne({onSuccess:()=>{p(),n()}}),h=l.isLoading?`loading`:u?.enabled?`enrolled`:`not_enrolled`;return d(Se,{open:!0,onOpenChange:e=>!e&&n(),children:a(Pe,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[d(it,{children:a(Ve,{className:`flex items-center gap-2`,children:[d(f,{className:`h-4 w-4 text-primary`}),a(`span`,{children:[r(`users.totpModal.twoFactorAuthentication`,`Two-factor authentication`),a(`span`,{className:`mt-0.5 block text-[11px] font-normal text-foreground-subtle`,children:[r(`users.totpModal.user`,`User:`),` `,d(`span`,{className:`font-mono`,children:t})]})]})]})}),a(pe,{className:`space-y-4`,children:[h===`loading`&&a(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[d(A,{className:`h-3.5 w-3.5 animate-spin`}),r(`users.totpModal.checkingStatus`,`Checking status…`)]}),h===`not_enrolled`&&a(`div`,{className:`rounded-md border border-border bg-surface-hover/30 px-3 py-2.5 flex items-start gap-2.5 text-xs text-foreground-subtle`,children:[d(k,{className:`h-4 w-4 mt-0.5 shrink-0`}),a(`div`,{children:[d(`div`,{className:`font-medium text-foreground`,children:r(`users.totpModal.2faNotEnrolled`,`2FA not enrolled`)}),d(`p`,{className:`mt-0.5`,children:r(`users.totpModal.onlyTheUserThemselvesCan`,`Only the user themselves can enable 2FA, from their own profile page.`)})]})]}),h===`enrolled`&&u&&a(s,{children:[a(`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(O,{className:`h-4 w-4 mt-0.5 text-emerald-500 shrink-0`}),a(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[d(`div`,{className:`font-medium`,children:r(`users.totpModal.2faIsActive`,`2FA is active`)}),d(`div`,{className:`text-foreground-subtle`,children:r(`common.enrolledOn`,{when:u.confirmedAt?new Date(u.confirmedAt).toLocaleString():`—`})})]})]}),d(`div`,{className:`text-[11px] text-foreground-subtle`,children:r(`users.totpModal.removingHereClearsTheServer`,`Removing here clears the server-side secret. Use this only when the user has lost access — they'll have to re-enroll from their profile page afterwards.`)}),a(`div`,{className:`flex justify-end gap-2`,children:[d(q,{onClick:n,variant:`secondary`,children:r(`common.close`,`Close`)}),a(`button`,{onClick:async()=>{await o({title:r(`users.totpModal.remove2fa`,`Remove 2FA`),message:r(`users.totpModal.removeTwoFactorAuthenticationFor`,`Remove two-factor authentication for "{{username}}"? They'll be able to log in with just their password until they re-enroll from their own profile page.`,{username:t}),confirmLabel:r(`common.remove`,`Remove`),variant:`danger`})&&m.mutate({userId:e})},disabled:m.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:[m.isPending?d(A,{className:`h-3 w-3 animate-spin`}):d(T,{className:`h-3 w-3`}),r(`users.totpModal.remove2fa`,`Remove 2FA`)]})]})]})]})]})})}e();function Or({userId:e,username:t,onClose:n}){let{t:i}=Y(),{user:o,logout:s}=gt(),c=o?.id===e,l=H(),u=W.useUtils(),f=W.auth.listSessions.useQuery({userId:e}),[p,m]=r(null),h=W.auth.revokeSessions.useMutation({onSuccess:(e,t)=>{if(c&&`userId`in t){s();return}u.auth.listSessions.invalidate()},onError:e=>m(`Sign out failed: ${e.message}`)}),g=async e=>{await l({title:i(`users.userSessionsModal.signOutThisSession`,`Sign out this session`),message:i(`users.userSessionsModal.onWillHaveToSign`,`"{{username}}" on {{label}} will have to sign in again.`,{username:t,label:Yt(e.client).label}),confirmLabel:i(`users.userSessionsModal.signOut`,`Sign out`),variant:`danger`})&&(m(null),h.mutate({id:e.id}))},_=async()=>{await l({title:i(`users.userSessionsModal.signOutEverywhere`,`Sign out everywhere`),message:c?i(`users.userSessionsModal.everySessionOfYourOwn`,`Every session of your own account ends, this browser included: you will be signed out here too.`):i(`users.userSessionsModal.everySessionOfEndsAt`,`Every session of "{{username}}" ends at once; each device has to sign in again.`,{username:t}),confirmLabel:i(`users.userSessionsModal.signOutEverywhere`,`Sign out everywhere`),variant:`danger`})&&(m(null),h.mutate({userId:e}))},v=h.isPending&&h.variables!==void 0&&`id`in h.variables?h.variables.id:null;return d(Se,{open:!0,onOpenChange:e=>!e&&n(),children:a(Pe,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,"data-testid":`user-sessions-modal`,children:[d(it,{children:a(Ve,{className:`flex items-center gap-2`,children:[d(de,{className:`h-4 w-4 text-primary`}),a(`span`,{children:[i(`users.userSessionsModal.activeSessions`,`Active sessions`),a(`span`,{className:`mt-0.5 block text-[11px] font-normal text-foreground-subtle`,children:[i(`users.userSessionsModal.user`,`User:`),` `,d(`span`,{className:`font-mono`,children:t})]})]})]})}),a(pe,{className:`space-y-3`,children:[p!==null&&d(`div`,{className:`text-[11px] text-danger`,children:p}),d(qt,{sessions:f.data??[],isLoading:f.isLoading,loadError:f.isError?f.error?.message??`Request failed`:null,emptyText:`No active sessions.`,onRevoke:e=>void g(e),revokingId:v})]}),a(Qe,{className:`justify-between`,children:[a(`button`,{onClick:()=>void _(),disabled:h.isPending||(f.data??[]).length===0,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:[h.isPending&&v===null?d(A,{className:`h-3 w-3 animate-spin`}):d(le,{className:`h-3 w-3`}),i(`users.userSessionsModal.signOutEverywhere`,`Sign out everywhere`)]}),d(q,{onClick:n,variant:`secondary`,children:i(`common.close`,`Close`)})]})]})})}function kr({icon:e,label:t,count:n,all:r,total:i}){let{t:o}=Y();return a(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[d(e,{className:`h-3 w-3 shrink-0 text-foreground-subtle`}),d(`span`,{className:`min-w-0 flex-1 text-foreground-subtle`,children:t}),d(`span`,{className:n===0?`text-foreground-subtle`:`font-medium text-foreground`,children:n===0?o(`common.none`):r?o(`users.scopePreview.all`,`all {{total}}`,{total:i}):o(`users.scopePreview.of`,`{{count}} of {{total}}`,{count:n,total:i})})]})}function Ar({scopes:e,isAdmin:t,invalidReason:n}){let{t:r}=Y(),i=ee(),c=o({queryKey:[`auth`,`previewScope`,e,t],enabled:n===null,queryFn:()=>i.trpcClient.auth.previewScope.query({scopes:[...e],isAdmin:t})}),{data:l}=Te({projection:`slim`}),u=l?.length??0;if(n!==null)return d(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:a(`p`,{className:`flex items-center gap-1.5 text-[11px] text-warning`,children:[d(C,{className:`h-3 w-3 shrink-0`}),n]})});if(c.isLoading)return a(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface p-3 text-[11px] text-foreground-subtle`,children:[d(A,{className:`h-3 w-3 animate-spin`}),r(`users.scopePreview.resolving`,`Resolving…`)]});if(c.isError||!c.data)return d(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:d(`p`,{className:`text-[11px] text-danger`,children:r(`users.scopePreview.couldNotResolveThisGrant`,`Could not resolve this grant set. Saving is still allowed — the server enforces the same rules either way.`)})});let f=c.data;return d(`div`,{className:`space-y-2 rounded-lg border border-border bg-surface p-3`,children:f.isAdmin?a(`p`,{className:`text-[11px] text-foreground`,children:[d(`span`,{className:`font-medium`,children:r(`users.scopePreview.administrator`,`Administrator`)}),` `,r(`users.scopePreview.unrestricted`)]}):a(s,{children:[d(kr,{icon:v,label:r(`users.scopePreview.devicesTheyCanSee`,`Devices they can see`),count:f.device.view.deviceCount,all:f.device.view.all,total:u}),d(kr,{icon:m,label:r(`users.scopePreview.devicesTheyCanOperate`,`Devices they can operate`),count:f.device.create.deviceCount,all:f.device.create.all,total:u}),d(kr,{icon:g,label:r(`users.scopePreview.devicesTheyCanDelete`,`Devices they can delete`),count:f.device.delete.deviceCount,all:f.device.delete.all,total:u}),a(`div`,{className:`border-t border-border pt-2 text-[10px] text-foreground-subtle`,children:[r(`users.scopePreview.systemAccess`,`System access:`),` `,f.system.length===0?r(`common.none`):f.system.join(`, `),f.capabilities.length>0&&a(s,{children:[` `,r(`users.scopePreview.extraCapabilities`,`· Extra capabilities:`),` `,f.capabilities.map(e=>e.name).join(`, `)]}),f.addons.length>0&&a(s,{children:[` `,r(`users.scopePreview.addons`,`· Addons:`),` `,f.addons.map(e=>e.name).join(`, `)]})]}),f.device.view.deviceCount===0&&d(`p`,{className:`text-[10px] text-warning`,children:r(`users.scopePreview.thisUserWillNotBe`,`This user will not be able to see any device.`)})]})})}e();function jr(e){let t=ie(e);return t===null?{mode:e.length===0?`role`:`advanced`,roleId:null,selector:{kind:`all`},includeLinked:!0,advancedScopes:e}:{mode:`role`,roleId:t.roleId,selector:t.selector,includeLinked:t.includeLinked,advancedScopes:e}}function Mr(e){return e.mode===`advanced`?e.advancedScopes:e.roleId===null?[]:re({roleId:e.roleId,selector:e.selector,includeLinked:e.includeLinked})}function Nr({user:e,onClose:t,onSubmit:i,submitting:o,callerScopes:c}){let{t:l}=Y(),u=N(),f=n(()=>jr(e.scopes??[]),[e.scopes]),[p,m]=r(f),[h,g]=r(f.mode===`advanced`),_=n(()=>Mr(p),[p]),v=!e.isAdmin&&p.mode===`role`&&p.roleId===null,y=n(()=>e.isAdmin?null:p.mode===`role`&&p.roleId===null?l(`users.userAccessModal.pickAccess`):He(_,u),[e.isAdmin,p.mode,p.roleId,_]),b=e=>m({...p,...e});return d(Se,{open:!0,onOpenChange:e=>!e&&t(),children:a(Pe,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-2xl`,children:[a(it,{children:[d(Ve,{children:l(`users.userAccessModal.title`,{name:e.username})}),d(`p`,{className:`text-[10px] text-foreground-subtle`,children:e.isAdmin?l(`users.userAccessModal.thisUserIsAnAdministrator`,`This user is an administrator — they can do everything, and the settings below are ignored.`):l(`users.userAccessModal.chooseWhatTheyCanDo`,`Choose what they can do, then which devices it applies to.`)})]}),a(pe,{className:`space-y-4`,children:[v&&a(`div`,{className:`flex items-start gap-2 rounded-lg border border-warning/40 bg-warning/10 p-3`,children:[d(C,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`}),a(`p`,{className:`text-[11px] text-foreground`,children:[d(`span`,{className:`font-medium`,children:l(`users.userAccessModal.noAccess`,`No access.`)}),` `,d(`span`,{className:`text-foreground-subtle`,children:l(`users.userAccessModal.cannotSeeAnything`,{name:e.username})})]})]}),a(`section`,{className:`space-y-2`,children:[d(`h3`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:l(`users.userAccessModal.1WhatCanTheyDo`,`1 · What can they do`)}),d(`div`,{className:`space-y-1.5`,children:R.map(e=>{let t=p.mode===`role`&&p.roleId===e.id;return a(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-lg border p-2.5 transition-colors ${t?`border-primary bg-primary/5`:`border-border hover:bg-foreground-subtle/5`}`,children:[d(`input`,{type:`radio`,name:`access-role`,checked:t,onChange:()=>b({mode:`role`,roleId:e.id}),className:`mt-0.5 border-border focus:ring-primary`}),a(`span`,{className:`min-w-0`,children:[d(`span`,{className:`block text-[12px] font-medium text-foreground`,children:e.label}),d(`span`,{className:`mt-0.5 block text-[10px] text-foreground-subtle`,children:e.description})]})]},e.id)})}),a(`button`,{type:`button`,onClick:()=>{if(!h){m({...p,mode:`advanced`,advancedScopes:_}),g(!0);return}g(!1),m(jr(p.advancedScopes))},className:`inline-flex items-center gap-1 rounded px-1.5 py-1 text-[10px] text-foreground-subtle transition-colors hover:bg-foreground-subtle/10 hover:text-foreground`,children:[d(h?F:I,{className:`h-3 w-3`}),l(`users.userAccessModal.advancedEditRawGrants`,`Advanced — edit raw grants`)]}),h&&a(`div`,{className:`rounded-lg border border-border p-2`,children:[d(`p`,{className:`mb-2 text-[10px] text-foreground-subtle`,children:l(`users.userAccessModal.oneRowPerGrantAnything`,`One row per grant. Anything expressible here overrides the three roles above; close this section to go back to them.`)}),d(at,{value:p.advancedScopes,onChange:e=>b({mode:`advanced`,advancedScopes:e}),clampToParent:c,emptyHint:d(s,{children:d(_t,{i18nKey:`users.userAccessModal.noGrants`,values:{name:e.username},components:{b:d(`span`,{className:`font-medium text-foreground`})}})})})]})]}),p.mode===`role`&&a(`section`,{className:`space-y-2`,children:[d(`h3`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:l(`users.userAccessModal.2OnWhichDevices`,`2 · On which devices`)}),d(ge,{value:p.selector,onChange:e=>b({selector:e}),includeLinked:p.includeLinked,onIncludeLinkedChange:e=>b({includeLinked:e}),clampToDeviceIds:null})]}),a(`section`,{className:`space-y-2`,children:[d(`h3`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:p.mode===`role`?l(`users.userAccessModal.3Result`,`3 · Result`):l(`users.userAccessModal.2Result`,`2 · Result`)}),d(Ar,{scopes:_,isAdmin:e.isAdmin,invalidReason:y})]})]}),a(Qe,{children:[d(q,{variant:`outline`,size:`sm`,onClick:t,children:l(`common.cancel`,`Cancel`)}),d(q,{size:`sm`,onClick:()=>i([..._]),disabled:o||y!==null,children:o?d(A,{className:`h-3 w-3 animate-spin`}):l(`users.userAccessModal.saveAccess`,`Save access`)})]})]})})}e();var Pr=8;function Fr(){return{username:``,password:``,isAdmin:!1}}function Ir(e){return{id:e.id,username:e.username,password:``,isAdmin:e.isAdmin}}function Lr(e){return e instanceof Error?e.message:J.t(`admin.system.users.genericError`)}function Rr(){let{t:e}=Y(),n=c(),{user:i}=gt(),{state:o,openNew:l,openEdit:u,close:p}=Je(),[h,_]=r(null),[v,b]=r(null),[x,S]=r(!1),{data:C,isLoading:w,isError:T,error:O,refetch:k}=Be(),ee=H(),j=We(),M=()=>n.invalidateQueries({queryKey:[[`userManagement`,`listUsers`]]}),N=Ye(),F=st({onSuccess:M}),I=ke({onSuccess:M}),L=ze({onSuccess:M}),te=lt({onSuccess:()=>{M(),R(null)}}),[ne,R]=r(null),[z,re]=r(null),[ie,ae]=r(null),[oe,se]=r(null),B=C??[],V=o.mode===`edit`?B.find(e=>e.id===o.id)??null:null,le=()=>{_(null),b(null),S(!1),N.reset(),I.reset(),p()};t(()=>{if(o.mode===`closed`){_(null),b(null),S(!1);return}if(o.mode===`new`){_(e=>e!==null&&e.id===void 0?e:Fr());return}if(V===null){w||p();return}_(e=>e?.id===V.id?e:Ir(V))},[o,V,w,p]);let ue=o.mode===`new`&&h!==null&&h.id===void 0||o.mode===`edit`&&h!==null&&V!==null;async function fe(t){await ee({title:e(`admin.system.users.deleteUser`,`Delete user`),message:e(`admin.system.users.permanentlyDeleteUserThisCannot`,`Permanently delete user "{{username}}"? This cannot be undone — any active sessions will be revoked on next request.`,{username:t.username}),confirmLabel:e(`common.delete`,`Delete`),variant:`danger`})&&(F.mutate({id:t.id}),o.mode===`edit`&&o.id===t.id&&le())}async function pe(t){let n=await j({title:e(`admin.system.users.resetPassword`,`Reset password`),message:e(`admin.system.users.setANewPasswordFor`,`Set a new password for "{{username}}".`,{username:t.username}),label:e(`admin.system.users.newPassword`,`New password`),inputType:`password`,placeholder:e(`admin.system.users.atLeast8Characters`,`At least 8 characters`),confirmLabel:e(`admin.system.users.continue`,`Continue`),validate:e=>e.length<Pr?J.t(`admin.system.users.passwordTooShort`,{min:Pr}):null});n===null||n.length===0||await ee({title:e(`admin.system.users.resetPassword`,`Reset password`),message:e(`admin.system.users.resetThePasswordForThey`,`Reset the password for "{{username}}"? They will need to use the new password on their next login.`,{username:t.username}),confirmLabel:e(`common.reset`,`Reset`)})&&L.mutate({id:t.id,newPassword:n})}function me(e,t){t!==e.isAdmin&&I.mutate({id:e.id,isAdmin:t})}async function ge(){if(h!==null){b(null);try{if(h.id===void 0){let e=h.username.trim();if(e===``||h.password.length<Pr)return;await N.mutateAsync({username:e,password:h.password,isAdmin:h.isAdmin})}else await I.mutateAsync({id:h.id,isAdmin:h.isAdmin});M(),le()}catch(e){b(Lr(e))}}}function _e(e){return e?new Date(typeof e==`number`?e:String(e)).toLocaleDateString(`en-GB`,{day:`2-digit`,month:`short`,year:`numeric`}):`—`}let ve=N.isPending||I.isPending,be=h!==null&&h.id===void 0&&h.username.trim()!==``&&h.password.length>=Pr,xe=h!==null&&h.id!==void 0,Se=ve||(h?.id===void 0?!be:!xe),U=e=>F.isPending&&F.variables?.id===e.id||I.isPending&&I.variables?.id===e.id||L.isPending&&L.variables?.id===e.id,Ce=[{key:`username`,header:e(`admin.system.users.username`,`Username`),sortValue:e=>e.username,render:e=>d(`span`,{className:`font-medium text-foreground`,"data-testid":`user-open-${e.id}`,children:e.username})},{key:`isAdmin`,header:e(`admin.system.users.admin`,`Admin`),nowrap:!0,sortValue:e=>+!!e.isAdmin,render:t=>d(`span`,{onClick:e=>e.stopPropagation(),children:a(`label`,{className:`inline-flex items-center gap-1.5 text-xs cursor-pointer`,children:[d(`input`,{type:`checkbox`,checked:t.isAdmin,onChange:e=>me(t,e.target.checked),disabled:U(t),className:`rounded border-border focus:ring-primary disabled:opacity-50`}),d(`span`,{className:t.isAdmin?`text-primary font-medium`:`text-foreground-subtle`,children:t.isAdmin?e(`admin.system.users.admin`,`Admin`):e(`admin.system.users.regular`,`Regular`)})]})})},{key:`scopes`,header:e(`admin.system.users.access`,`Access`),render:t=>t.isAdmin?d(`span`,{className:`text-[10px] italic text-foreground-subtle`,children:e(`admin.system.users.everythingAdmin`,`everything (admin)`)}):d(`span`,{onClick:e=>e.stopPropagation(),children:a(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>R(t),title:e(`admin.system.users.configureAccess`,`Configure access`),children:[d(P,{className:`h-3 w-3 shrink-0 text-foreground-subtle`}),d(zr,{scopes:t.scopes??[]})]})})},{key:`createdAt`,header:e(`admin.system.users.created`,`Created`),nowrap:!0,sortValue:e=>e.createdAt,render:e=>d(`span`,{className:`text-foreground-subtle`,children:_e(e.createdAt)})},{key:`actions`,header:e(`admin.system.users.actions`,`Actions`),align:`right`,nowrap:!0,notSortableReason:`Row actions`,render:t=>{let n=U(t),r=t.id!==i?.id&&t.totpEnabled;return a(`div`,{className:`flex items-center justify-end gap-1`,onClick:e=>e.stopPropagation(),children:[a(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>u(t.id),disabled:n,title:e(`admin.system.users.editUser`,`Edit user`),children:[d(m,{className:`h-3 w-3`}),e(`common.edit`,`Edit`)]}),r&&a(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>re(t),disabled:n,title:e(`admin.system.users.removeTwoFactorAuthentication`,`Remove two-factor authentication`),children:[d(f,{className:`h-3 w-3`}),e(`admin.system.users.remove2fa`,`Remove 2FA`)]}),a(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>ae(t),disabled:n,title:e(`admin.system.users.linkedSignInAccounts`,`Linked sign-in accounts`),children:[d(D,{className:`h-3 w-3`}),e(`admin.system.users.signInLinks`,`Sign-in links`)]}),a(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>se(t),disabled:n,title:e(`admin.system.users.activeSessions`,`Active sessions`),children:[d(de,{className:`h-3 w-3`}),e(`admin.system.users.sessions`,`Sessions`)]}),a(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>void pe(t),disabled:n,title:e(`admin.system.users.resetPassword`,`Reset password`),children:[d(ce,{className:`h-3 w-3`}),e(`admin.system.users.resetPassword`,`Reset password`)]}),a(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>void fe(t),disabled:n,title:e(`admin.system.users.deleteUser`,`Delete user`),className:`text-danger hover:bg-danger/10`,children:[n?d(A,{className:`h-3 w-3 animate-spin`}):d(g,{className:`h-3 w-3`}),e(`common.delete`,`Delete`)]})]})}}];return a(Tt,{embedded:!0,icon:y,title:e(`admin.system.users.users`,`Users`),subtitle:e(`admin.system.users.hubAccountsAdminFlagAccess`,`Hub accounts, admin flag, access scopes, sessions and sign-in links.`),actions:a(q,{size:`sm`,type:`button`,onClick:()=>{b(null),l()},children:[d(E,{className:`h-3.5 w-3.5`}),e(`admin.system.users.createUser`,`Create User`)]}),children:[T&&d(G,{title:e(`admin.system.users.couldNotLoadUsers`,`Could not load users`),message:Lr(O),onRetry:()=>void k()}),w&&a(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[d(A,{className:`h-3.5 w-3.5 animate-spin`}),e(`common.loading`,`Loading…`)]}),!w&&!T&&B.length===0&&d(et,{icon:y,title:e(`admin.system.users.noUsersYet`,`No users yet`),description:e(`admin.system.users.createAUserToGrant`,`Create a user to grant hub access.`)}),!w&&!T&&B.length>0&&d(Ie,{columns:Ce,rows:B,rowKey:e=>e.id,minWidthPx:560,maxBodyHeight:`max-h-[60vh]`,onRowClick:e=>u(e.id)}),d(Me,{open:ue,onClose:le,title:h?.id===void 0?e(`admin.system.users.createUser`,`Create User`):e(`admin.system.users.edit`,`Edit {{value1}}`,{value1:h.username||`user`}),icon:y,error:v,testId:`user-form-dialog`,footer:d(q,{size:`sm`,type:`button`,disabled:Se,onClick:()=>void ge(),children:ve?a(s,{children:[d(A,{className:`h-3.5 w-3.5 animate-spin`}),e(`admin.system.users.saving`,`Saving…`)]}):h?.id===void 0?e(`admin.system.users.create`,`Create`):e(`common.save`,`Save`)}),children:h!==null&&a(`div`,{className:`space-y-3`,children:[d(ct,{label:e(`admin.system.users.username`,`Username`),required:h.id===void 0,children:d(he,{value:h.username,onChange:e=>_({...h,username:e.target.value}),placeholder:`john`,autoFocus:h.id===void 0,disabled:h.id!==void 0,"data-testid":`user-form-username`})}),h.id===void 0&&d(ct,{label:e(`admin.system.users.password`,`Password`),required:!0,description:e(`admin.system.users.atLeastCharacters`,`At least {{value1}} characters.`,{value1:String(Pr)}),children:d(ye,{value:h.password,onValueChange:e=>_({...h,password:e}),shown:x,onToggleShown:()=>S(e=>!e),placeholder:`••••••••`,"data-testid":`user-form-password`})}),d(ct,{label:e(`admin.system.users.admin`,`Admin`),description:e(`admin.system.users.unrestrictedAccessToEveryCapability`,`Unrestricted access to every capability and device.`),children:a(`label`,{className:`inline-flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[d(`input`,{type:`checkbox`,checked:h.isAdmin,onChange:e=>_({...h,isAdmin:e.target.checked}),className:`rounded border-border focus:ring-primary`,"data-testid":`user-form-admin`}),d(`span`,{children:e(`admin.system.users.admin`,`Admin`)})]})}),h.id!==void 0&&d(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`admin.system.users.toChangeThePasswordUse`,`To change the password, use Reset password on the user's row. Access scopes are configured from the Access column.`)})]})}),z&&d(Dr,{userId:z.id,username:z.username,onClose:()=>re(null)}),ie&&d(Er,{userId:ie.id,username:ie.username,onClose:()=>ae(null)}),oe&&d(Or,{userId:oe.id,username:oe.username,onClose:()=>se(null)}),ne&&d(Br,{user:ne,onClose:()=>R(null),onSubmit:e=>te.mutate({userId:ne.id,scopes:e}),submitting:te.isPending})]})}function zr({scopes:e}){let{t}=Y(),n=N();if(e.length===0)return d(`span`,{className:`font-medium text-warning`,children:t(`admin.system.users.noAccess`,`No access`)});let r=ie(e);return r===null?d(`span`,{className:`text-foreground-subtle`,children:t(`users.customGrants`,{count:e.length})}):a(`span`,{className:`text-foreground-subtle`,children:[d(`span`,{className:`font-medium text-foreground`,children:z(r.roleId).label}),` ·`,` `,ut(r.selector,n)]})}function Br(e){let{user:t}=gt(),n=t?.isAdmin===!0;return d(Nr,{...e,callerScopes:n?null:t?.scopes??[]})}e();var Vr={"api-keys":$.tokens,"linked-sessions":$.linkedApps},Hr=`certificates`;function Ur(e){return a(q,{size:`sm`,type:`button`,"data-testid":`certificates-pair-device`,onClick:e,children:[d(f,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),J.t(`systemPage.identity.pairADevice`,`Pair a device`)]})}function Wr(){let{t:e}=Y(),[t]=Ct(),n=Tn(),[i,a]=r(!1),o=Vr[t.get(`tab`)??``];if(o!==void 0)return d(pt,{to:St(`access`,{integration:o}),replace:!0});let s=ht(`/system/identity`,{t:e,isAdmin:!0})??{icon:M,title:e(`system.identity`,`Identity & Access`)},c=t.get(`tab`)??`users`,l=t.get(`integration`),u=c===vt.access.tab?wn(l,n.requestCreate):c===`certificates`?Ur(()=>a(!0)):void 0;return d(wt,{icon:s.icon,title:s.title,defaultSection:`users`,sectionsLabel:`${s.title} sections`,actions:u,sections:[{id:`users`,label:e(`systemPage.identity.users`,`Users`),content:d(Rr,{})},{id:vt.access.tab,label:e(`systemPage.identity.tokensSessions`,`Tokens & sessions`),content:d(Cn,{createRequested:n.createRequested,onCreateConsumed:n.clearCreate}),ownedParams:xt.concat([Lt.token,Lt.scoped,Lt.admin])},{id:Hr,label:e(`systemPage.identity.certificates`,`Certificates`),content:d(Tr,{pairOpen:i,onPairClose:()=>a(!1)})},{id:vt.authentication.tab,label:e(`systemPage.identity.authentication`,`Authentication`),content:d(Rn,{}),ownedParams:xt}]})}export{Wr as IdentityPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,B as t,G as n,J as r,L as i,S as a,o,q 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,It as u,Nt as d,Rr as f,Si as p,Xi as m,bn as h,dt as g,ht as _,kn as v,or as y,ot as b,pi as x,pn as S,sa as C,si as w,un as ee,vn as T,xi as te,yi as E,zr as D}from"./player-overlays-D98Lvll4.js";import{di as O}from"./client-Cj9cIFJV.js";import{t as k}from"./search-x-DOr7Uth6.js";import{$n as A,Aa as j,At as ne,Ba as M,Bo as N,Da as P,Dt as re,Fa as F,Ho as I,Ia as L,Jr as R,Kn as z,Ko as B,Na as V,Oa as H,Ot as ie,Qn as U,Uo as ae,Va as W,Vo as oe,Vu as se,Wa as G,Wo as K,Wu as ce,Ya as le,Yr as ue,Zt as de,er as fe,fi as pe,io as me,ir as he,ja as ge,jn as _e,ka as ve,ln as q,no as J,rr as ye,xo as be,yn as xe,zo as Se}from"./src-MJ2k3G6o.js";import{t as Y}from"./useTranslation-D3Is_4B6.js";import{n as Ce}from"./addon-icons-context-BVO6QLZm.js";import{Z as we,et as Te,nt as Ee,tt as De,z as Oe}from"./index-CM1JjjBW.js";import{t as ke}from"./NodeAddonsSettingsPanel-CTmPFs3s.js";import{t as Ae}from"./device-integration-icon-CFPzExgG.js";import{n as je,r as X,t as Me}from"./ScanNetworkModal-CiOVqs0H.js";e();function Z(e){let t=[];for(let n of e)n.type===`probe`&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...Z(n.fields));return t}function Ne(e,t,a){let[o,s]=r(`idle`),[c,l]=r({}),u=n(()=>{let t=[];for(let n of e.sections)t.push(...Z(n.fields));return t},[e]),d=u.length>0&&a!==void 0,f=i(e=>{l(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},[]);return{testAllStatus:o,hasProbeFields:d,probeResults:c,handleTestAll:i(async()=>{if(!a)return;let e=u.filter(e=>{let n=t[e];return n!=null&&String(n).trim()!==``});if(e.length===0)return;s(`testing`);let n={};for(let t of e)n[t]={status:`probing`};l(n);let r=await Promise.allSettled(e.map(async e=>{try{return{key:e,result:await a(e,t[e])}}catch(t){return{key:e,result:{status:`error`,error:t instanceof Error?t.message:String(t)}}}})),i={};for(let e of r)if(e.status===`fulfilled`){let{key:t,result:n}=e.value;i[t]={status:n.status===`ok`?`ok`:`error`,result:n}}l(i),s(`idle`)},[a,u,t]),clearProbeResult:f}}e();function Pe(e){let t=[];for(let n of e)`required`in n&&n.required===!0&&`key`in n&&n.key&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...Pe(n.fields));return t}function Fe(e){return e==null?!0:typeof e==`string`?e.trim()===``:!1}function Ie(e,t={}){for(let n of e){if(n.type===`group`&&`fields`in n){Ie(n.fields,t);continue}`key`in n&&n.key&&`default`in n&&n.default!==void 0&&(t[n.key]=n.default)}return t}function Le(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Re({open:e,integrationId:s,addonId:l,onClose:u}){let{t:f}=Y(),p=o(),[m,h]=r({}),[v,b]=r(!1),[x,C]=r(null),[w,ee]=r(Le),T=J({addonId:l},{enabled:e}),E=T.data?.deviceType??null,D=G({addonId:l,type:E??O.Camera},{enabled:e&&T.isSuccess&&E!==null}),k=D.data??null;t(()=>{e&&(h(k?Ie(k.sections.flatMap(e=>e.fields)):{}),ee(Le()),b(!1),C(null))},[e,s,k]);let A=n(()=>({...m,_probeRequestId:w}),[m,w]),j=F({onSuccess:()=>{p.invalidateQueries({queryKey:[[`deviceManager`]]})}}),ne=be(),M=i(async(e,t)=>{b(!0);let n=await ne.mutateAsync({addonId:l,type:E??O.Camera,key:e,value:t,formValues:A});return n.status===`ok`&&n.suggestedValues&&h(e=>{let t=!1,r={...e};for(let[i,a]of Object.entries(n.suggestedValues??{}))Fe(e[i])&&!Fe(a)&&(r[i]=a,t=!0);return t?r:e}),n},[ne,l,A,E]),{testAllStatus:N,hasProbeFields:P,probeResults:re,handleTestAll:I,clearProbeResult:L}=Ne(k??{sections:[]},m,M);async function R(e){C(null);try{await j.mutateAsync({addonId:l,type:E??O.Camera,config:m,integrationId:s}),e?h(k?Ie(k.sections.flatMap(e=>e.fields)):{}):u()}catch(e){C(e instanceof Error?e.message:String(e))}}if(!e)return null;let z=Pe((k?.sections??[]).flatMap(e=>e.fields)).filter(e=>Fe(m[e])),B=z.length===0,V=T.isLoading||E!==null&&D.isLoading,H=T.isError||T.isSuccess&&E===null||D.isError||D.isSuccess&&k===null;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:u}),a(`div`,{className:`relative z-10 flex w-full max-w-2xl flex-col max-h-[calc(90dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl`,children:[a(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:f(`integrations.addDevice`)}),c(`button`,{onClick:u,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:c(g,{className:`h-4 w-4`})})]}),c(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-3`,children:V?c(`div`,{className:`flex items-center justify-center py-8`,children:c(y,{className:`h-5 w-5 animate-spin text-primary`})}):H?a(`div`,{className:`flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3`,children:[c(d,{className:`h-4 w-4 text-destructive mt-0.5 shrink-0`}),a(`div`,{className:`space-y-1`,children:[c(`p`,{className:`text-xs font-medium text-destructive`,children:f(`integrations.addDeviceDialog.providerUnavailable`,`Provider unavailable`)}),c(`p`,{className:`text-xs text-foreground-subtle`,children:c(we,{i18nKey:`integrations.addDeviceDialog.notReady`,values:{addonId:l},components:{mono:c(`span`,{className:`font-mono`})}})})]})]}):c(Oe,{schema:k,values:m,onChange:h,onTestField:M,probeResults:re,onClearProbe:L})}),!H&&!V&&a(`div`,{className:`border-t border-border bg-surface/50 shrink-0`,children:[a(`button`,{type:`button`,onClick:()=>b(e=>!e),className:`flex w-full items-center justify-between px-5 py-2 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[a(`span`,{className:`flex items-center gap-2`,children:[c(S,{className:`h-3.5 w-3.5`}),f(`integrations.addDeviceDialog.testLogs`,`Test logs`),c(`span`,{className:`font-mono text-[9px] opacity-60`,children:w.slice(0,14)})]}),c(te,{className:`h-3.5 w-3.5 transition-transform ${v?`rotate-180`:``}`})]}),v&&c(`div`,{className:`border-t border-border max-h-64 overflow-hidden`,children:c(de,{addonId:l,requestId:w,limit:50,maxHeight:`max-h-64`,showFilters:!1,showScope:!1,className:`border-0 rounded-none`})})]}),!H&&!V&&(x||z.length>0)&&c(`div`,{className:`border-t border-destructive/30 bg-destructive/5 px-5 py-2 shrink-0`,children:a(`div`,{className:`flex items-start gap-2`,children:[c(d,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),c(`p`,{className:`text-[11px] text-destructive`,children:x||f(`integrations.addDeviceDialog.required`,`Required: {{value1}}`,{value1:z.join(`, `)})})]})}),a(`div`,{className:`flex items-center justify-between border-t border-border px-5 py-3 shrink-0`,children:[a(`div`,{className:`flex items-center gap-2`,children:[c(`button`,{onClick:u,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:f(`integrations.cancel`)}),!H&&P&&a(`button`,{type:`button`,onClick:I,disabled:N===`testing`,className:`inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[N===`testing`?c(y,{className:`h-3.5 w-3.5 animate-spin`}):c(_,{className:`h-3.5 w-3.5`}),f(`integrations.addDeviceDialog.testAll`,`Test All`)]})]}),a(`div`,{className:`flex items-center gap-2`,children:[c(`button`,{onClick:()=>R(!0),disabled:H||!B||j.isPending,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:f(`integrations.saveAndNew`)}),c(`button`,{onClick:()=>R(!1),disabled:H||!B||j.isPending,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:j.isPending?f(`integrations.saving`):f(`integrations.save`)})]})]})]})]})}var Q=1500;function ze({addonId:e,integrationId:t,jobId:n,onFinished:r}){let{t:i}=Y(),o=P(),s=(j({addonId:e,integrationId:t},{refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`running`)?Q:!1}).data??[]).find(e=>e.jobId===n);if(!s)return null;let l=s.state===`running`,u=s.processed,f=s.total>0?Math.round(u/s.total*100):0;!l&&s.finishedAt!==null&&r();let p=[`${u}/${s.total} ${i(`integrations.adoptJobProcessed`,{defaultValue:`processed`})}`];s.adopted>0&&p.push(`${s.adopted} ${i(`integrations.adoptJobAdded`,{defaultValue:`added`})}`),s.alreadyAdopted>0&&p.push(`${s.alreadyAdopted} ${i(`integrations.adoptJobSkipped`,{defaultValue:`already there`})}`),s.failed>0&&p.push(`${s.failed} ${i(`integrations.adoptJobFailed`,{defaultValue:`failed`})}`);let m=p.join(` · `);return a(`div`,{className:`border-t border-border px-5 py-3 shrink-0 space-y-2`,children:[a(`div`,{className:`flex items-center gap-2`,children:[l?c(y,{className:`h-3.5 w-3.5 animate-spin text-primary shrink-0`}):s.failed>0?c(d,{className:`h-3.5 w-3.5 text-destructive shrink-0`}):s.state===`cancelled`?c(w,{className:`h-3.5 w-3.5 text-foreground-subtle shrink-0`}):c(x,{className:`h-3.5 w-3.5 text-primary shrink-0`}),c(`p`,{className:`text-[11px] text-foreground`,children:m}),l&&c(`button`,{onClick:()=>o.mutate({jobId:n}),className:`ml-auto rounded-lg border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:i(`integrations.adoptJobCancel`,{defaultValue:`Stop`})})]}),c(`div`,{className:`h-1 w-full rounded-full bg-border overflow-hidden`,children:c(`div`,{className:`h-full bg-primary transition-all`,style:{width:`${f}%`},role:`progressbar`,"aria-valuenow":f,"aria-valuemin":0,"aria-valuemax":100})}),s.results.filter(e=>e.outcome===`failed`).slice(0,5).map(e=>a(`p`,{className:`text-[11px] text-destructive`,children:[e.childNativeId,`: `,e.error]},e.childNativeId))]})}function Be(e){let t=e.metadata;return[e.name,e.childNativeId,t.model,t.manufacturer,t.integration,t.externalLocation].filter(e=>typeof e==`string`&&e.length>0).join(` `)}e();var $=`devices`;function Ve(e){return{id:$,label:e(`integrations.adoptDevicesModal.defaultFilter`),isDefault:!0}}var He=2e4,Ue=100;function We({addonId:e,integrationId:n,onClose:l}){let u=C(),{t:f}=Y(),m=o(),[h,_]=r(new Set),[v,b]=r(new Set),[x,S]=r(new Map),[w,ee]=r(null),{data:te}=oe(),E=(te??[]).find(t=>t.addonId===e)?.supportsLocationImport??!1,[D,O]=r(!0),k=H({addonId:e,integrationId:n}).data?.filters,A=k&&k.length>0?k:[Ve(f)],[j,ne]=r(A.find(e=>e.isDefault)?.id??(A.some(e=>e.id===$)?$:A[0].id)),M=j!==$,N=ge(),P=ve({addonId:e,integrationId:n,page:1,pageSize:He,filter:j}),F=P.refetch,I=N.mutate,L=i(()=>{I({addonId:e,integrationId:n},{onSettled:()=>{F()}})},[I,e,n,F]),R=s(null);t(()=>{let t=`${e}::${n}`;R.current===t||P.isLoading||(R.current=t,(P.data?.candidates.length??0)===0&&L())},[e,n,P.isLoading,P.data,L]);let z=N.isPending,B=N.isError?N.error instanceof Error?N.error.message:String(N.error):null,ie=typeof N.data?.lastError==`string`&&N.data.lastError.length>0?N.data.lastError:null,U=P.data?.candidates??[],ae=P.isError?P.error instanceof Error?P.error.message:String(P.error):null,W=V(),[G,K]=r(null),le=i(e=>{e.alreadyAdopted||_(t=>{let n=new Set(t);return n.has(e.childNativeId)?n.delete(e.childNativeId):n.add(e.childNativeId),n})},[]),ue=i(e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),de=i((e,t)=>{S(n=>{let r=new Map(n),i=r.get(e)?.hiddenChildIds??new Set,a=new Set(i);return a.has(t)?a.delete(t):a.add(t),a.size===0?r.delete(e):r.set(e,{hiddenChildIds:a}),r})},[]),fe=i(e=>{let t={};for(let n of e){let e=x.get(n);e&&e.hiddenChildIds.size>0&&(t[n]={hiddenChildIds:[...e.hiddenChildIds]})}return Object.keys(t).length>0?t:void 0},[x]),pe=i(async()=>{ee(null);let t=[...h];if(t.length!==0)try{let r=fe(t),{jobId:i}=await W.mutateAsync({addonId:e,integrationId:n,filter:j,childNativeIds:t,...r?{perCandidate:r}:{},...E?{importLocations:D}:{}});K(i),_(new Set),S(new Map)}catch(e){ee(e instanceof Error?e.message:String(e))}},[h,fe,W,e,n,j,E,D]),me=s(null),he=i(()=>{G===null||me.current===G||(me.current=G,F(),m.invalidateQueries({queryKey:[[`integrations`]]}),m.invalidateQueries({queryKey:[[`deviceManager`]]}))},[G,F,m]),_e=i(e=>{ne(e),_(new Set),b(new Set),S(new Map),ee(null)},[]),q=h.size,J=G!==null&&q===0&&!W.isPending;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:l}),a(`div`,{className:`relative z-10 flex w-full max-w-3xl flex-col h-[85vh] rounded-xl border border-border bg-background shadow-2xl`,children:[a(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[a(`div`,{className:`min-w-0`,children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:f(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}),c(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:f(`integrations.adoptDevicesHint`,{defaultValue:`Preview the candidate devices and add the ones you want.`})})]}),a(`div`,{className:`flex items-center gap-3 shrink-0`,children:[E&&a(`label`,{className:`flex items-center gap-1.5 cursor-pointer text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:[c(`input`,{type:`checkbox`,checked:D,onChange:e=>O(e.target.checked),className:`accent-primary`}),f(`integrations.importLocations`,{defaultValue:`Import locations from the integration`})]}),c(`button`,{onClick:l,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":f(`common.close`,`Close`),children:c(g,{className:`h-4 w-4`})})]})]}),a(`div`,{className:`flex-1 min-h-0 px-5 py-3 flex flex-col gap-2 overflow-hidden`,children:[(B??ae??ie)&&U.length===0&&c(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-3 shrink-0`,children:a(`div`,{className:`flex items-start gap-2`,children:[c(d,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),a(`div`,{className:`min-w-0`,children:[c(`p`,{className:`text-xs font-medium text-destructive`,children:f(`integrations.adoptRefreshFailed`,{defaultValue:`Could not discover devices.`})}),c(`p`,{className:`text-[11px] text-destructive/90 mt-0.5`,children:B??ae??ie})]})]})}),A.length>1&&c(Ge,{filters:A,activeFilter:j,onSelect:_e}),c(`div`,{className:`flex-1 min-h-0`,children:c(re,{mode:`generic`,items:U,pageSize:Ue,getKey:e=>e.childNativeId,getSearchText:Be,getFilterType:e=>e.type,filterOptions:se(u),filterLabel:f(`integrations.adoptColType`,{defaultValue:`Type`}),isLoading:P.isLoading||z&&U.length===0,searchPlaceholder:f(`integrations.adoptSearch`,{defaultValue:`Search candidates…`}),emptyLabel:(B??ae??ie)&&U.length===0?``:f(`integrations.adoptNoCandidates`,{defaultValue:`No candidate devices found.`}),toolbar:a(`button`,{type:`button`,onClick:L,disabled:z,title:f(`integrations.adoptRefreshTitle`,{defaultValue:`Re-scan Home Assistant for devices`}),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-60 shrink-0`,children:[c(T,{className:`h-3.5 w-3.5 ${z?`animate-spin`:``}`}),f(`integrations.adoptRefresh`,{defaultValue:`Refresh`})]}),columns:[{key:`name`,header:f(`integrations.adoptColName`,{defaultValue:`Name`}),headerClassName:`w-[55%]`,cell:e=>c(Ke,{candidate:e,expandable:!M,expanded:v.has(e.childNativeId),onToggleExpand:()=>ue(e.childNativeId),adoptedLabel:f(`integrations.adoptAlready`,{defaultValue:`Adopted`})})},{key:`type`,header:f(`integrations.adoptColType`,{defaultValue:`Type`}),headerClassName:`w-[30%] hidden sm:table-cell`,cellClassName:`hidden sm:table-cell`,cell:e=>{let t=ce(e.type,u),n=t.icon;return a(`span`,{className:`inline-flex items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[c(n,{className:`h-3.5 w-3.5 shrink-0`}),t.label]})}},{key:`select`,header:``,headerClassName:`w-[15%] text-right`,cellClassName:`text-right`,cell:e=>c(`div`,{className:`flex items-center justify-end`,children:c(`button`,{onClick:()=>le(e),disabled:e.alreadyAdopted,"aria-label":h.has(e.childNativeId)?f(`integrations.adoptDevicesModal.deselect`,`Deselect`):f(`integrations.adoptDevicesModal.select`,`Select`),className:`inline-flex h-5 w-5 items-center justify-center rounded border ${h.has(e.childNativeId)?`border-primary bg-primary`:`border-border`} ${e.alreadyAdopted?`cursor-not-allowed opacity-50`:``}`,children:h.has(e.childNativeId)&&c(p,{className:`h-3 w-3 text-primary-foreground`})})})}],isExpanded:e=>!M&&v.has(e.childNativeId),renderExpanded:M?void 0:e=>c(qe,{candidate:e,hiddenChildIds:x.get(e.childNativeId)?.hiddenChildIds??new Set,onToggleChildHidden:t=>de(e.childNativeId,t)}),rowClassName:e=>e.alreadyAdopted?`opacity-60`:h.has(e.childNativeId)?`bg-primary/5`:``})})]}),w&&c(`div`,{className:`border-t border-destructive/30 bg-destructive/5 px-5 py-2 shrink-0`,children:a(`div`,{className:`flex items-start gap-2`,children:[c(d,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),c(`p`,{className:`text-[11px] text-destructive`,children:w})]})}),G!==null&&c(ze,{addonId:e,integrationId:n,jobId:G,onFinished:he}),a(`div`,{className:`flex items-center justify-between border-t border-border px-5 py-3 shrink-0`,children:[c(`div`,{}),a(`div`,{className:`flex items-center gap-2`,children:[c(`button`,{onClick:l,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:f(`integrations.cancel`,{defaultValue:`Cancel`})}),a(`button`,{onClick:J?l:pe,disabled:!J&&(q===0||W.isPending),className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50 disabled:cursor-not-allowed`,children:[W.isPending&&c(y,{className:`h-3.5 w-3.5 animate-spin`}),J?f(`integrations.close`,{defaultValue:`Close`}):f(`integrations.addSelected`,{defaultValue:`Add selected`}),!J&&q>0?` (${q})`:``]})]})]})]})]})}function Ge({filters:e,activeFilter:t,onSelect:n}){let{t:r}=Y();return c(`div`,{role:`tablist`,"aria-label":r(`integrations.adoptDevicesModal.discoveryGranularity`,`Discovery granularity`),className:`inline-flex shrink-0 self-start rounded-lg border border-border bg-surface p-0.5`,children:e.map(e=>{let r=e.id===t;return c(`button`,{type:`button`,role:`tab`,"aria-selected":r,onClick:()=>n(e.id),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${r?`bg-primary text-primary-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:e.label},e.id)})})}function Ke({candidate:e,expandable:t,expanded:n,onToggleExpand:r,adoptedLabel:i}){let{t:o}=Y(),s=(e.children??[]).length;return a(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[t&&s>0?a(`button`,{type:`button`,onClick:r,"aria-label":n?o(`integrations.adoptDevicesModal.collapse`,`Collapse`):o(`integrations.adoptDevicesModal.expand`,`Expand`),"aria-expanded":n,className:`flex h-5 flex-shrink-0 items-center justify-center gap-0.5 rounded px-0.5 text-[10px] text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:[c(n?te:E,{className:`h-3.5 w-3.5`}),s]}):c(`span`,{className:`flex h-5 w-5 flex-shrink-0 items-center justify-center text-foreground-subtle/40`,children:`—`}),c(`span`,{className:`truncate text-xs font-medium text-foreground`,children:e.name}),e.alreadyAdopted&&c(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-[9px] font-medium text-success shrink-0`,children:i})]})}function qe({candidate:e,hiddenChildIds:t,onToggleChildHidden:n}){let{t:r}=Y(),i=e.children??[];return i.length===0?null:c(`div`,{className:`space-y-1 py-1`,children:i.map(e=>{let i=t.has(e.childNativeId),o=e.capabilities??[];return a(`div`,{className:`flex items-center gap-2 rounded px-2 py-1 ${i?`opacity-50`:``}`,children:[c(`span`,{className:`text-[11px] text-foreground truncate flex-1 min-w-0`,children:e.name}),o.length>0&&c(`span`,{className:`text-[9px] text-foreground-subtle truncate`,children:o.join(`, `)}),c(`button`,{onClick:()=>n(e.childNativeId),"aria-label":i?r(`integrations.adoptDevicesModal.showChild`,`Show child`):r(`integrations.adoptDevicesModal.hideChild`,`Hide child`),title:i?r(`integrations.adoptDevicesModal.showAfterAdopt`,`Show after adopt`):r(`integrations.adoptDevicesModal.hideAfterAdopt`,`Hide after adopt`),className:`flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors flex-shrink-0`,children:c(i?D:f,{className:`h-3 w-3`})})]},e.childNativeId)})})}e();function Je(e){let t=[];for(let n of e){if(n.type===`group`){t.push(...Je(n.fields));continue}`key`in n&&typeof n.key==`string`&&t.push(n.key)}return t}function Ye(e,t){if(!e)return{};let n=new Set(e.sections.flatMap(e=>Je(e.fields))),r={};for(let e of n)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e]);return r}function Xe(e){return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{if(`value`in e){let{value:t,...n}=e;return n}return e})}))}}function Ze({integrationId:e,addonId:t,name:r,kind:i,mode:s,brokerKind:l,canTest:u=!1,trpc:d,onClose:f}){let{t:p}=Y(),m=o(),{data:h,isLoading:g}=I({id:e},{enabled:s===`account`||s===`broker`}),_=n(()=>{let e=h?.brokerId;return typeof e==`string`?e:null},[h]),{data:v,isLoading:b}=R({addonId:t,nodeId:`hub`},{enabled:s===`account`}),x=n(()=>v?Xe(v):null,[v]),S=K(),C=(t,n)=>{S.mutate({id:e,settings:t,...n?{secretKeys:[...n]}:{}},{onSuccess:()=>{m.invalidateQueries(),f()}})};return c(U,{open:!0,onOpenChange:e=>!e&&f(),children:a(fe,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[c(ye,{children:a(he,{children:[p(`integrations.editConfig`,{defaultValue:`Edit configuration`}),` — `,r]})}),c(A,{children:s===`broker`?l?a(`div`,{className:`space-y-3`,children:[c(`p`,{className:`text-[11px] text-foreground-subtle`,children:p(`integrations.relinkBrokerHelp`,{defaultValue:`Choose the broker this integration connects through. Picking a different broker re-points it and restarts the addon.`})}),_&&a(`p`,{className:`text-[11px] text-foreground`,children:[p(`integrations.currentBroker`,{defaultValue:`Current broker`}),`:`,` `,c(`span`,{className:`font-mono text-foreground-subtle`,children:_})]}),S.isPending?a(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[c(y,{className:`h-3 w-3 animate-spin`}),p(`integrations.saving`,{defaultValue:`Saving…`})]}):c(X,{kind:l,onResolved:e=>{C({brokerId:e})},onBack:f}),S.isError&&c(`p`,{className:`text-[11px] text-danger`,children:p(`integrations.relinkFailed`,{defaultValue:`Failed to update broker link.`})})]}):c(`p`,{className:`text-[11px] text-danger`,children:p(`integrations.noBrokerKind`,{defaultValue:`This integration declares device-adoption but its addon manifest has no brokerKind.`})}):s===`account`?g||b?a(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[c(y,{className:`h-3 w-3 animate-spin`}),p(`integrations.loading`,{defaultValue:`Loading…`})]}):c(je,{addonId:t,configSchema:x,canTest:u,initialName:r,initialConfig:Ye(x,h??{}),submitLabel:p(`integrations.save`,{defaultValue:`Save`}),hideName:!0,onSave:({config:e,secretKeys:t})=>C(e,t),onBack:f}):c(z,{trpc:d,addonId:t,nodeId:`hub`,title:r})})]})})}function Qe(e){return e==null?!1:e.sections.some(e=>e.fields.length>0)}e();function $e(){let{t:e}=Y(),{integrationId:s}=De(),d=o(),f=Te(),[p,g]=Ee(),_=b(),[x,C]=r(!1),[w,T]=r(!1),[te,E]=r(!1),[D,O]=r(!1),{data:j,isLoading:P}=N({id:s??``},{enabled:!!s}),{data:F}=R({addonId:j?.addonId??``,nodeId:`hub`},{enabled:!!j?.addonId}),{data:I,isSuccess:z}=oe(),V=n(()=>{let e=j?.addonId;return!e||!z?null:(I??[]).find(t=>t.addonId===e)?.kind===`device-adoption`?`device-adoption`:`device-provider`},[I,j?.addonId,z]),{data:H}=M({}),se=n(()=>(H?.providers??[]).some(e=>e.addonId===j?.addonId),[H,j?.addonId]),G=V!==null,K=j?.info?.fixed===!0,ce=G?V===`device-adoption`?e(`integrations.adoptDevices`,{defaultValue:`Adopt devices`}):e(`integrations.addDevice`):e(`integrations.addDeviceLoading`,{defaultValue:`Loading…`}),ge=n(()=>{let e=j?.addonId;return!e||!z?null:(I??[]).find(t=>t.addonId===e)?.brokerKind??null},[I,j?.addonId,z]),ve=n(()=>{let e=j?.addonId;return!e||!z?!1:(I??[]).find(t=>t.addonId===e)?.canTest===!0},[I,j?.addonId,z]),J=n(()=>{let e=j?.addonId;return!e||!z?null:(I??[]).find(t=>t.addonId===e)?.mode??null},[I,j?.addonId,z]);t(()=>{p.get(`add`)===`1`&&G&&(C(!0),g(e=>{let t=new URLSearchParams(e);return t.delete(`add`),t},{replace:!0}))},[p,G,g]);let be=F!=null&&Array.isArray(F.sections)&&F.sections.some(e=>e.fields.length>0),{data:Ce}=ue({addonId:j?.addonId??``,nodeId:`hub`},{enabled:!!j?.addonId&&J!==`account`}),we=J!==null&&J!==`account`&&Qe(Ce),Oe=n(()=>j?.addonId?[j.addonId]:[],[j?.addonId]),{data:je}=le({projection:`slim`},{refetchInterval:3e4}),X=[[`integrations`,`get`],{input:{id:s??``},type:`query`}],Z=B({onMutate:async e=>{await d.cancelQueries({queryKey:X});let t=d.getQueryData(X);return t!=null&&d.setQueryData(X,{...t,enabled:e.enabled}),{previous:t}},onError:(e,t,n)=>{let r=n;r?.previous!=null&&d.setQueryData(X,r.previous)},onSettled:()=>{d.invalidateQueries({queryKey:[[`integrations`]]}),d.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ne=Se({onSuccess:()=>{d.invalidateQueries({queryKey:[[`integrations`]]}),d.invalidateQueries({queryKey:[[`deviceManager`]]}),f(`/integrations`)}}),Pe=pe({onSuccess:()=>{d.invalidateQueries({queryKey:[[`integrations`]]}),d.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Fe=me({onSuccess:()=>{d.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ie=L({onSuccess:()=>{d.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Le=W({onSuccess:()=>{d.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Q=n(()=>je??[],[je]),ze=n(()=>{let e=new Map;for(let t of Q)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[Q]),Be=i(e=>ze.get(e)??null,[ze]),{data:$}=ae(void 0),Ve=n(()=>ie($),[$]),He=i(e=>f(`/devices/${String(e)}`),[f]),Ue=n(()=>{let e=j?.id;return e?Q.filter(t=>{let n=Ve(t);return n.kind===`resolved`&&n.integration.id===e}):[]},[Q,j?.id,Ve]),Ge=n(()=>$===void 0?null:ne(Ue).length,[$,Ue])??`…`;return P?a(`div`,{className:`p-4`,children:[c(`div`,{className:`h-16 rounded-lg bg-surface animate-pulse mb-4`}),c(`div`,{className:`h-40 rounded-lg bg-surface animate-pulse`})]}):j?a(`div`,{className:`p-4 space-y-4 overflow-x-hidden`,children:[c(xe,{items:[{label:e(`integrationDetail.integrations`,`Integrations`),onClick:()=>f(`/integrations`)},{label:j.name}]}),a(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[a(`div`,{className:`flex items-center gap-3 min-w-0`,children:[c(et,{addonId:j.addonId}),a(`div`,{className:`min-w-0`,children:[c(`h1`,{className:`text-lg font-semibold text-foreground truncate`,children:j.name}),a(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5 truncate`,children:[j.addonId,` · `,Ge,` `,e(`integrations.devices`)]})]})]}),a(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[se&&a(`button`,{onClick:()=>T(!0),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(`integrationDetail.scanTheNetworkForDevices`,`Scan the network for devices (incl. a different subnet)`),children:[c(l,{className:`h-3.5 w-3.5`}),e(`integrationDetail.scanNetwork`,`Scan network`)]}),!K&&a(`button`,{onClick:()=>C(!0),disabled:!G,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50 disabled:cursor-not-allowed`,title:ce,children:[c(v,{className:`h-3.5 w-3.5`}),ce]}),a(`div`,{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 transition-colors ${Z.isPending?`opacity-60`:``} ${j.enabled?`border-success/30 bg-success/5`:`border-border bg-surface`}`,title:e(`integrations.toggleHint`,{defaultValue:`Click to toggle`}),children:[c(_e,{checked:j.enabled,onCheckedChange:e=>Z.mutate({id:s,enabled:e}),disabled:Z.isPending,"aria-label":j.enabled?e(`integrationDetail.disableIntegration`,`Disable integration`):e(`integrationDetail.enableIntegration`,`Enable integration`)}),c(`span`,{className:`text-[11px] font-medium ${j.enabled?`text-success`:`text-foreground-subtle`}`,children:j.enabled?e(`integrationDetail.enabled`,`Enabled`):e(`integrationDetail.disabled`,`Disabled`)}),Z.isPending&&c(y,{className:`h-3 w-3 animate-spin text-foreground-subtle`})]}),J!==`standalone`&&(be||V===`device-adoption`)&&a(`button`,{onClick:()=>E(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[c(ee,{className:`h-3 w-3`}),e(`integrations.config`)]}),a(`button`,{onClick:()=>O(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:e(`integrations.logs`,{defaultValue:`View logs`}),children:[c(S,{className:`h-3 w-3`}),e(`integrations.logs`,{defaultValue:`Logs`})]}),c(q,{label:e(`integrationDetail.restart`,`Restart`),icon:h,title:e(`integrationDetail.restart2`,`Restart "{{name}}"?`,{name:j.name}),description:e(`integrationDetail.restartingTheAddonWillBriefly`,`Restarting the addon will briefly disconnect every device backed by it ({{topLevelCountLabel}} active). Streams will reconnect automatically.`,{topLevelCountLabel:Ge}),confirmLabel:e(`integrationDetail.restart`,`Restart`),triggerVariant:`outline`,confirmVariant:`danger`,disabled:Pe.isPending,action:()=>Pe.mutateAsync({addonId:j.addonId})}),!K&&s&&c(q,{label:e(`integrations.delete`,{defaultValue:`Delete`}),icon:u,title:e(`integrations.deleteTitle`,{defaultValue:`Delete integration?`}),description:e(`integrations.deleteWarning`,{defaultValue:`This removes the integration "{{name}}" and its {{count}} device(s). The addon will restart. This cannot be undone.`,name:j.name,count:Ge}),confirmLabel:e(`integrations.confirmDelete`,{defaultValue:`Delete integration`}),triggerVariant:`outline`,confirmVariant:`danger`,className:`border-danger bg-danger/10 text-danger hover:bg-danger hover:text-background`,disabled:Ne.isPending,action:()=>Ne.mutateAsync({id:s})})]})]}),we&&c(ke,{nodeId:null,addonIds:Oe,level:`global`,surface:`integration`,title:e(`integrations.settings`,{defaultValue:`Settings`})}),c(re,{context:`integration-detail`,devices:Q,trpc:_.trpcClient,integrationOf:Ve,forceIntegrationId:j.id,urlScope:`root`,lsKey:`integration-detail:${j.addonId}`,resolveIntegrationIcon:Ae,resolveParent:Be,onNavigate:He,batchActions:{remove:Fe.mutate,disable:Ie.mutate,enable:Le.mutate},...K?{}:{onDeleteDevice:e=>Fe.mutate({deviceId:e.id})}}),x&&s&&V===`device-adoption`&&c(We,{addonId:j.addonId,integrationId:s,onClose:()=>C(!1)}),x&&s&&V===`device-provider`&&c(Re,{open:x,integrationId:s,addonId:j.addonId,onClose:()=>C(!1)}),w&&j&&c(Me,{open:w,scope:{addonId:j.addonId,label:j.name},onClose:()=>T(!1)}),te&&s&&V!==null&&J!==null&&c(Ze,{integrationId:s,addonId:j.addonId,name:j.name,kind:V,mode:J,brokerKind:ge,canTest:ve,trpc:_.trpcClient,onClose:()=>E(!1)}),D&&c(U,{open:!0,onOpenChange:e=>!e&&O(!1),children:a(fe,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-5xl md:h-[80vh]`,children:[c(ye,{className:`mb-0`,children:a(he,{className:`flex items-center gap-2 min-w-0`,children:[c(S,{className:`h-4 w-4 text-primary shrink-0`}),c(`span`,{className:`truncate`,children:j.name}),a(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate font-normal`,children:[j.addonId,s?` · ${s}`:``]})]})}),c(A,{className:`min-h-0 overflow-hidden p-0`,children:c(de,{addonId:j.addonId,limit:200,maxHeight:`max-h-full`,showScope:!1,className:`h-full border-0 rounded-none`})})]})})]}):a(`div`,{className:`flex flex-col items-center justify-center py-20 px-6 text-center gap-4`,children:[c(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-foreground-subtle/10`,children:c(k,{className:`h-6 w-6 text-foreground-subtle`})}),a(`div`,{className:`space-y-1 max-w-sm`,children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`integrations.integrationNotFound`,{defaultValue:`Integration not found`})}),c(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`integrations.integrationNotFoundHint`,{defaultValue:`The integration "{{id}}" does not exist. It may have been deleted, or the URL may be wrong.`,id:s??``})})]}),a(`button`,{onClick:()=>f(`/integrations`),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:[c(m,{className:`h-3 w-3`}),e(`integrations.backToList`,{defaultValue:`Back to integrations`})]})]})}function et({addonId:e}){let t=Ce(e),[n,i]=r(!1);return!t||n?null:c(`img`,{src:t,alt:``,className:`h-8 w-8 rounded-lg shrink-0`,onError:()=>i(!0)})}export{$e as IntegrationDetailPage};
|
|
@@ -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,Di 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-D98Lvll4.js";import{At as S,Au as C,Dt as w,Ea as T,Jr as ee,Ot as E,Ra as D,Ro as te,Ru as O,Uo as k,Vo as A,Ya as j,nt as M,r as N}from"./src-MJ2k3G6o.js";import{t as P}from"./i18n-BuS8cl72.js";import{t as F}from"./useTranslation-D3Is_4B6.js";import{Y as I,et as L,nt as R}from"./index-CM1JjjBW.js";import{t as z}from"./AdminPage-RJcN6Anu.js";import"./useEventInvalidation-CVKD2t0V.js";import{t as ne}from"./device-integration-icon-CFPzExgG.js";import{n as re,r as B,t as ie}from"./ScanNetworkModal-CiOVqs0H.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}=F(),[s,l]=r(new Set),d=D(),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}=F(),s=L(),[l,u]=r(``),{data:d,isLoading:f}=A(),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(C,{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}=F(),u=L(),d=s(),[f,p]=r(`picker`),[h,g]=r(null),[v,y]=r(null),[b,x]=r(`manual`),[S,C]=r(null),[w,E]=r(``),[O,k]=r(null),[A,j]=r(null),[M,N]=r(!1),{data:P}=ee({addonId:h??``,nodeId:`hub`},{enabled:h!=null}),I=n(()=>P?oe(P):null,[P]),R=te({onSuccess:()=>d.invalidateQueries({queryKey:[[`integrations`]]})}),z=D(),ne=z.data;t(()=>{f!==`discovery`||!v||!h||z.isPending||z.data||z.mutate({addonId:h})},[f,v,h,z]);let ie=T({onSuccess:()=>d.invalidateQueries({queryKey:[[`deviceManager`]]})});function se(e,t,n,r,i,a,o,s){if(!R.isPending){if(g(e),N(s),x(n),E(r),j(null),o===`broker`){if(!a){j(`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 R.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 R.mutateAsync({addonId:h,name:e.name,settings:e.config,secretKeys:[...e.secretKeys]});y(t.id),k(t.id),b===`auto`||b===`both`?p(`discovery`):q(t.id,{openAdd:!0})}catch{}}async function le(e){if(h)try{let t=await R.mutateAsync({addonId:h,name:w,settings:{brokerId:e}});k(t.id),y(t.id),q(t.id)}catch{}}async function K(e){if(h){for(let t of e){let e=ne?.find(e=>e.stableId===t);e&&await ie.mutateAsync({addonId:h,candidate:e,...O===null?{}:{integrationId:O}})}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),E(``),k(null),j(null),N(!1)}function Y(){i(),J()}V(e);let X=R.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,$=R.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:[A&&c(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:A}),c(U,{onSelect:se,onClose:Y,pendingAddonId:Q})]}),f===`config`&&h&&c(re,{addonId:h,configSchema:I??null,canTest:M,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}=F();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(I,{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:P.t(`integrations.integrationColumns.integration`,`Integration`),headerClassName:`w-[55%]`,cell:e=>c(G,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:P.t(`integrations.integrationColumns.devices`,`Devices`),headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>P.t(`integrations.integrationColumns.deviceCount`,{count:e.deviceCount})},{key:`status`,header:P.t(`integrations.integrationColumns.status`,`Status`),headerClassName:`w-[15%]`,cell:e=>c(M,{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}=F(),t=L(),s=v(),[u]=R(),[f,m]=r(!1),h=i(()=>m(!0),[]),_=i(()=>m(!1),[]),[y,b]=r(!1),x=i(()=>b(!0),[]),C=i(()=>b(!1),[]);N([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),N([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:T,isLoading:ee,refetch:D}=k(void 0),{data:te,isLoading:A,refetch:M}=j({projection:`slim`}),P=n(()=>te??[],[te]),I=n(()=>T??[],[T]),re=n(()=>{let e=new Map;for(let t of P)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[P]),B=n(()=>E(T),[T]),V=n(()=>{let e=new Map;for(let t of S(P)){let n=B(t);if(n.kind!==`resolved`)continue;let r=n.integration.id;e.set(r,(e.get(r)??0)+1)}return e},[P,B]),ae=n(()=>I.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:le(e),deviceCount:V.get(e.id)??0})),[I,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=>re.get(e)??null,[re]),G=i(e=>t(`/devices/${String(e)}`),[t]),q=i(e=>c(w,{context:`integration-detail`,devices:P,trpc:s.trpcClient,integrationOf:B,forceIntegrationId:e.id,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:ne,resolveParent:W,onNavigate:G}),[P,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(()=>{D(),M()},[D,M]),Q=ee||A,$=I.length>0;return a(z,{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:O(`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(w,{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:C})]})}export{q 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,Di as l,Fn as u,Gi as d,Hr as f,Ht as p,It as m,Lr as h,Mi as g,O as _,Pi as v,Pr as y,Ri as b,Rt as x,Ur as S,V 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,k as M,kn as N,lr as P,pn as F,pt as I,rn as L,rr as R,ta 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-D98Lvll4.js";import{Sr as ae,fn as oe,wr as se}from"./client-Cj9cIFJV.js";import{t as ce}from"./boxes-CqZzX6pS.js";import{n as le,r as ue,t as de}from"./speaker-DiDPOBlm.js";import{t as H}from"./user-round-vZzgqRIQ.js";import{$a as fe,$n as pe,Ar as me,Au as U,Ca as W,F as G,Mn as he,Mu as K,Nn as ge,Pr as _e,Qa as ve,Qn as ye,Rr as be,Sa as xe,Ta as Se,Tu as Ce,Ya as we,Za as Te,ao as Ee,co as De,do as Oe,eo as ke,er as Ae,fo as je,gn as q,gt as Me,hr as J,ir as Ne,ju as Pe,mo as Fe,nr as Ie,on as Le,oo as Re,po as ze,rr as Be,sn as Ve,so as He,wa as Ue,yo as We}from"./src-MJ2k3G6o.js";import{t as Y}from"./i18n-BuS8cl72.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-CM1JjjBW.js";import{t as Je}from"./AdminSectionedPage-DvK84QvU.js";import{a as Ye,n as Xe,r as Ze}from"./linked-devices-model-BpGYuse3.js";e();var Qe={camera:l,hub:le,container:ce,light:z,siren:L,switch:ie,sensor:ee,thermostat:p,climate:D,button:A,"event-emitter":ne,update:ue,notifier:b,script:F,automation:I,lock:R,cover:v,valve:S,humidifier:f,"water-heater":y,fan:h,"media-player":de,"alarm-panel":T,control:k,presence:H,weather:O,vacuum:g,"lawn-mower":x,image:j,smoke:c};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(ye,{open:e,onOpenChange:e=>e?void 0:p(),children:i(Ae,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,"aria-label":n,children:[s(Be,{children:s(Ne,{children:n})}),i(pe,{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(G,{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(Ie,{children:[s(J,{variant:`ghost`,onClick:p,children:m(`locations.addDialog.cancel`)}),s(J,{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=Ue(),g=m.kind===`present`?m:null,v=xe({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:`${M} 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(J,{variant:`ghost`,size:`sm`,onClick:()=>c(qe(e.id)),children:[s(P,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),n(`locations.links.edit`)]}),s(J,{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(q,{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(ge,{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(ge,{htmlFor:`location-zone-${e}`,children:o(`locations.locationZoneField.zone`,`Zone`)}),s(Ce,{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(K,{value:t,onPick:r,fallbackGlyph:te,clearGlyph:d,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:se(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:p,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=Le(t,n(()=>({searchText:e=>[e.name,...yt(o,e.id).map(e=>e.name)],facetValue:e=>e.type}),[o])),[j,N]=r(()=>new Set),P=e=>N(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:m,danger:!0,separatorBefore:!0,disabled:c,onClick:()=>void p()}];return i(`section`,{className:`min-w-0 ${_}`,children:[i(`header`,{className:`${M} 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(U,{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(J,{type:`button`,size:`sm`,onClick:()=>void R(),children:C(`common.save`,`Save`)}),s(Pe,{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(J,{type:`button`,variant:`outline`,size:`sm`,disabled:c,onClick:g,"aria-label":C(`locations.room.addTo`,{room:e}),children:C(`locations.room.add`)}),s(Me,{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(Ve,{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(q,{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(J,{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(q,{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(U,{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(J,{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(J,{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(m,{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(U,{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(J,{size:`sm`,type:`submit`,disabled:c.trim().length===0||e,children:[s(N,{className:`h-3.5 w-3.5`}),n(`common.add`,`Add`)]}),s(J,{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(J,{size:`sm`,type:`button`,onClick:()=>o(!0),"data-testid":`new-location-button`,children:[s(N,{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(U,{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(J,{size:`sm`,type:`submit`,disabled:c.trim().length===0||e,children:[s(N,{className:`h-3.5 w-3.5`}),n(`common.add`,`Add`)]}),s(J,{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(J,{size:`sm`,type:`button`,onClick:()=>o(!0),"data-testid":`new-zone-button`,children:[s(N,{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(_e,{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=Le(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),S=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(he,{checked:y,onChange:w,"aria-label":y?u(`locations.unassignedTable.clearSelection`,`Clear selection`):u(`locations.unassignedTable.selectAllUnassignedDevices`,`Select all unassigned devices`)}),render:e=>s(he,{checked:v.includes(e.id),onChange:()=>S(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(be,{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(Ce,{"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:C,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(Ve,{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(Ce,{"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(J,{type:`button`,size:`sm`,onClick:T,disabled:o||p.length===0,children:u(`locations.unassignedTable.assign`,`Assign`)}),s(J,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>f([]),children:u(`locations.unassignedTable.clear`,`Clear`)})]}),s(q,{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:oe({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=me(),{data:c,isLoading:l}=fe(),{data:u}=ve(),{data:d}=Te(),{data:f}=ke(),{data:p,isLoading:m}=we({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=Se({onSuccess:h}),_=Ee({onSuccess:h}),v=Oe({onSuccess:h}),y=He({onSuccess:h}),b=ze({onSuccess:h}),x=je({onSuccess:h}),S=We({onSuccess:h}),C=Re({onSuccess:h}),w=De({onSuccess:h}),T=Fe({onSuccess:h}),E=Ue(),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})},oe=async(e,t)=>{let n=t.trim();n.length===0||n===e||await y.mutateAsync({from:e,to:n})},se=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??[],pe=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),he=n(()=>D.filter(e=>e.parentDeviceId===null).map(e=>({id:e.id,name:e.name,type:e.type,location:e.location})),[D]),K=s(At,{rooms:ne,...N===`locations`?{unassignedCount:F.length}:{},value:N===`locations`?ee:z??``,unassignedValue:Lt,onChange:re}),ge=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…`)}),K,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,ae(R.name)),onPickIcon:e=>ue(R.name,e),description:at(d,ae(R.name)),onSaveDescription:e=>de(R.name,e),zones:H,zoneKey:ct(H,ae(R.name)),onChangeZone:e=>pe(R.name,e),onRename:e=>oe(R.name,e),onDelete:()=>ce(R.name,dt(D,R.name).length),onRebuildLinks:()=>se(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:he,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)})]}),_e=i(`div`,{className:`flex flex-col gap-3`,"data-testid":`camera-links-tab`,children:[K,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:ge},{id:`camera-links`,label:e(`locations.cameraLinks`,`Camera links`),content:_e},{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,Gi as m,It as h,Nt as g,Q as _,Rr as v,Zr as y,hi as b,lr as x,mi as S,mr as C,or as w,ot as T,rr as E,sa as D}from"./player-overlays-D98Lvll4.js";import{_r as O,gr as k}from"./client-Cj9cIFJV.js";import{s as A}from"./video-a3E1zR0a.js";import{t as j}from"./key-round-CNTVmlFS.js";import{t as ee}from"./monitor-smartphone-EKfsOXbl.js";import{t as M}from"./unlink-pUA2UXXM.js";import{Ar as N,Cr as te,Tu as P,Xn as F,Xu as I,Zn as ne,cn as re,cs as ie,hr as ae,us as oe,wt as se}from"./src-MJ2k3G6o.js";import{t as ce}from"./i18n-BuS8cl72.js";import{t as L}from"./useTranslation-D3Is_4B6.js";import"./mount-CVKD2t0V.js";import{C as R,S as z,V as B,Z as V,b as H,x as U}from"./index-CM1JjjBW.js";import{t as W}from"./AdminPage-RJcN6Anu.js";import{O as G,T as le,_ as K,a as ue,h as de,k as fe,r as pe,t as me,v as he}from"./SessionsList-DTdwgdgY.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=oe(Y),n=ie(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(w,{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(g,{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(ae,{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(F,{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(P,{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(re,{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(g,{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=N(),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`),g=l(null);r(()=>()=>g.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()};g.current?.(),g.current=U(t,{onReturn:e=>{e.target===`profile`&&r(e.query)},onDone:e=>{e.target===`profile`&&r(e.query)},onClosed:()=>{g.current?.(),g.current=null,n.auth.listOwnExternalIdentities.invalidate()}}),t.location.href=_(z(e))},onError:e=>{m.current?.close(),m.current=null,y(null),u(e.message)}}),T=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),T.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:T.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(M,{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(w,{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=N(),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(w,{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=N(),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:m,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:fe(o),onDismissNotice:()=>s(null),children:d(le,{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:v,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:p,cls:`bg-primary/15 text-primary`},delete:{icon:h,cls:`bg-danger/15 text-danger`}};function je(){let{t:e}=L(),t=D(),{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,{ownOnly:!0}),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`?se(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=T(),[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(w,{className:`h-3 w-3 animate-spin`}):d(E,{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=T(),l=s({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>n.getOwnTotpStatus()}),p=l.data,[m,h]=a(null),[g,_]=a(``),[v,x]=a(null),[C,E]=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(()=>E(!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(w,{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(w,{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(()=>E(!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(w,{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(w,{className:`h-3 w-3 animate-spin`}):d(f,{className:`h-3 w-3`}),t(`systemPage.myAccess.disable2fa`,`Disable 2FA`)]})})]})]})]})}function Pe(){return te(`auth-webauthn/passkey-enrollment`)?d(ne,{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,a as o,b as s,o as c,t as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{D as d,It as f,Nt as p,Rr as m,Tn as h,bi as g,bn as _,dn as v,en as y,hi as b,mi as x,mr as S,or as C,ot as w,rr as ee,sn as te,tr as T,un as E,xi as ne,yi as re}from"./player-overlays-D98Lvll4.js";import{Mr as ie}from"./client-Cj9cIFJV.js";import{i as ae}from"./video-a3E1zR0a.js";import{t as D}from"./key-round-CNTVmlFS.js";import{$n as oe,$o as se,An as O,Ar as ce,Au as k,Bl as le,Cu as A,Dn as ue,Gu as de,Kl as fe,On as j,Qn as pe,Qo as me,Rr as M,Ru as N,Ul as he,Xo as ge,Zo as _e,_n as P,as as F,cn as I,er as ve,es as ye,fr as be,gn as L,hr as R,ir as xe,is as Se,jr as Ce,kn as we,kr as z,mn as Te,nr as Ee,ns as De,os as Oe,rr as ke,rs as Ae,sr as je,tr as Me,ts as Ne}from"./src-MJ2k3G6o.js";import{t as B}from"./i18n-BuS8cl72.js";import{t as V}from"./useTranslation-D3Is_4B6.js";import{T as Pe,Z as Fe,k as Ie,nt as Le}from"./index-CM1JjjBW.js";import{t as Re}from"./AdminSectionedPage-DvK84QvU.js";import{t as H}from"./AdminPage-RJcN6Anu.js";import{t as ze}from"./NodeAddonsSettingsPanel-CTmPFs3s.js";import{t as Be}from"./AddonAssetIcon-BYNabO6z.js";e();var Ve={detection:`border-green-500`,detector:`border-green-500`,streaming:`border-blue-500`,decode:`border-blue-500`,decoder:`border-blue-500`,recording:`border-orange-500`,recorder:`border-orange-500`,transcoding:`border-purple-500`,transcoder:`border-purple-500`,restream:`border-cyan-500`,restreamer:`border-cyan-500`,storage:`border-yellow-500`,notification:`border-pink-500`,notifier:`border-pink-500`,faces:`border-indigo-500`},He={detection:`bg-green-500/5`,detector:`bg-green-500/5`,streaming:`bg-blue-500/5`,decode:`bg-blue-500/5`,decoder:`bg-blue-500/5`,recording:`bg-orange-500/5`,recorder:`bg-orange-500/5`,transcoding:`bg-purple-500/5`,transcoder:`bg-purple-500/5`,restream:`bg-cyan-500/5`,restreamer:`bg-cyan-500/5`,storage:`bg-yellow-500/5`,notification:`bg-pink-500/5`,notifier:`bg-pink-500/5`,faces:`bg-indigo-500/5`};function Ue({entry:e,actions:t}){let n=e.name.toLowerCase(),r=Ve[n]??`border-primary`,i=He[n]??`bg-primary/5`,o=e.providers.find(e=>e.active),s=t?.pendingCapability===e.name;return a(`div`,{className:`rounded-lg border-t-2 border border-border ${r} ${i} p-3 space-y-2`,children:[a(`div`,{className:`flex items-center justify-between gap-2`,children:[a(`span`,{className:`text-xs font-semibold text-foreground capitalize flex items-center gap-1.5`,children:[e.name,s&&u(C,{className:`h-3 w-3 animate-spin text-primary`})]}),u(`span`,{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ${e.mode===`singleton`?`bg-primary/10 text-primary`:`bg-info/10 text-info`}`,children:e.mode})]}),e.mode===`singleton`?u(We,{entry:e,actions:t,activeProvider:o,isPending:s}):u(Ge,{entry:e,actions:t,isPending:s})]})}function We({entry:e,actions:t,activeProvider:n,isPending:r}){let{t:i}=V();if(!t)return u(`div`,{children:n?a(`div`,{className:`flex items-center gap-1.5 text-[10px] text-foreground`,children:[u(x,{className:`h-3 w-3 text-green-400 shrink-0`}),u(`span`,{className:`font-medium`,children:n.addonName}),u(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto`,children:`ACTIVE`})]}):u(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:i(`addons.capabilityMap.noActiveProvider`,`No active provider`)})});if(e.providers.length===0)return u(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:i(`addons.capabilityMap.noProviders`,`No providers`)});let o=`__inherit__`;return a(`div`,{className:`space-y-2`,children:[u(`div`,{className:`space-y-1`,children:e.providers.map(n=>{let i=n.active;return a(`button`,{type:`button`,disabled:r||i,onClick:()=>t.onSelectSingleton(e.name,n.addonId),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${i?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[u(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${i?`border-green-400 bg-green-400`:`border-border`}`}),u(`span`,{className:`font-medium truncate`,children:n.addonName}),i&&u(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},n.addonId)})}),e.perNode&&e.perNode.length>0&&u(`div`,{className:`space-y-2 pt-1 border-t border-border/40`,children:e.perNode.map(n=>{let s=n.hasOverride&&n.resolvedActive?n.resolvedActive:o,c=[{value:o,label:n.resolvedActive?i(`addons.capabilityMap.inheritGlobalWith`,{provider:n.resolvedActive}):i(`addons.capabilityMap.inheritGlobal`)},...n.providers.map(e=>({value:e,label:e}))],l=r=>{r===o?t.onClearNodeSingleton(e.name,n.nodeId):t.onSelectNodeSingleton(e.name,n.nodeId,r)},d=r;return a(`div`,{className:`space-y-0.5`,children:[a(`div`,{className:`text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60 px-1.5`,children:[n.nodeId,n.hasOverride&&u(`span`,{className:`ml-1.5 rounded-full bg-primary/10 text-primary px-1 py-0.5 normal-case tracking-normal font-medium`,children:i(`common.override`)})]}),c.map(e=>{let t=s===e.value;return a(`button`,{type:`button`,disabled:d||t,onClick:()=>l(e.value),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${t?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[u(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${t?`border-green-400 bg-green-400`:`border-border`}`}),u(`span`,{className:`font-medium truncate`,children:e.label}),t&&e.value!==o&&u(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},e.value)})]},n.nodeId)})})]})}function Ge({entry:e,actions:t,isPending:n}){let{t:r}=V();if(e.providers.length===0)return u(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:r(`addons.capabilityMap.noProviders`,`No providers`)});if(!t)return u(`div`,{className:`space-y-1`,children:e.providers.map(e=>a(`div`,{className:`flex items-center justify-between gap-2 text-[10px]`,children:[u(`span`,{className:`text-foreground-subtle`,children:e.addonName}),e.active&&u(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium`,children:`ACTIVE`})]},e.addonId))});let i=e.providers.filter(e=>e.active).map(e=>e.addonId),o=(n,r)=>{let a=r?[...new Set([...i,n])]:i.filter(e=>e!==n);t.onToggleCollection(e.name,a)};return u(`div`,{className:`space-y-1`,children:e.providers.map(e=>a(`label`,{className:`flex items-center justify-between gap-2 text-[10px] rounded px-1.5 py-1 transition-colors ${n?`opacity-50`:`hover:bg-surface-hover cursor-pointer`}`,children:[a(`span`,{className:`flex items-center gap-1.5 min-w-0`,children:[u(`input`,{type:`checkbox`,checked:e.active,disabled:n,onChange:t=>o(e.addonId,t.target.checked),className:`h-3 w-3 accent-green-500 shrink-0`}),u(`span`,{className:`text-foreground truncate`,children:e.addonName})]}),e.active&&u(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium shrink-0`,children:`ACTIVE`})]},e.addonId))})}function U({capabilities:e,actions:t}){let{t:n}=V();return e.length===0?u(`div`,{className:`text-xs text-foreground-subtle text-center py-8`,children:n(`addons.capabilityMap.noCapabilitiesRegistered`,`No capabilities registered`)}):u(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3`,children:e.map(e=>u(Ue,{entry:e,actions:t},e.name))})}var W=[`capabilities`,`listCapabilities`];function Ke(e){return e===`singleton`||e===`collection`}function qe(e){let t=e.indexOf(`@`);return t===-1?B.t(`system.capabilities.providerHub`,{addonId:e}):`${e.slice(0,t)} (${e.slice(t+1)})`}function Je(e,t){return{name:e.name,mode:t,providers:e.providers.map(n=>({addonId:n,addonName:qe(n),active:t===`singleton`?e.activeProvider===n:!e.disabledProviders.includes(n)})),...t===`singleton`&&e.perNode?{perNode:e.perNode}:{}}}function Ye(){let{t:e}=V(),t=w(),[i,s]=r(null),[c,d]=r(null),f=o({queryKey:W,queryFn:()=>t.trpcClient.capabilities.listCapabilities.query()}),p=n(()=>{let e=(f.data??[]).flatMap(e=>Ke(e.mode)?[Je(e,e.mode)]:[]),t=e.filter(e=>e.mode===`singleton`).toSorted((e,t)=>e.name.localeCompare(t.name)),n=e.filter(e=>e.mode===`collection`).toSorted((e,t)=>e.name.localeCompare(t.name));return[...t,...n]},[f.data]),m=n(()=>p.filter(e=>e.mode===`singleton`),[p]),h=n(()=>p.filter(e=>e.mode===`collection`),[p]),g=l({mutationFn:e=>t.trpcClient.capabilities.setActiveSingleton.mutate({capability:e.capName,addonId:e.addonId}),onMutate:e=>{s(e.capName),d(null)},onSuccess:async(t,n)=>{d({kind:`success`,message:e(`system.capabilities.isNowActive`,`{{capName}} → {{addonId}} is now active.`,{capName:n.capName,addonId:n.addonId})}),await f.refetch()},onError:(t,n)=>{d({kind:`error`,message:e(`system.capabilities.failedToSet`,{cap:n.capName,error:t instanceof Error?t.message:e(`common.unknownError`)})})},onSettled:()=>s(null)}),_=l({mutationFn:e=>t.trpcClient.capabilities.setActiveSingleton.mutate({capability:e.capName,addonId:e.addonId,nodeId:e.nodeId}),onMutate:e=>{s(e.capName),d(null)},onSuccess:async(e,t)=>{d({kind:`success`,message:`${t.capName} @ ${t.nodeId} → ${t.addonId}.`}),await f.refetch()},onError:(t,n)=>{d({kind:`error`,message:e(`system.capabilities.failedToSetOnNode`,{cap:n.capName,node:n.nodeId,error:t instanceof Error?t.message:e(`common.unknownError`)})})},onSettled:()=>s(null)}),v=l({mutationFn:e=>t.trpcClient.capabilities.clearSingletonNodeOverride.mutate({capability:e.capName,nodeId:e.nodeId}),onMutate:e=>{s(e.capName),d(null)},onSuccess:async(t,n)=>{d({kind:`success`,message:e(`system.capabilities.nowInheritsTheGlobalDefault`,`{{capName}} @ {{nodeId}} now inherits the global default.`,{capName:n.capName,nodeId:n.nodeId})}),await f.refetch()},onError:(t,n)=>{d({kind:`error`,message:e(`system.capabilities.failedToClearOnNode`,{cap:n.capName,node:n.nodeId,error:t instanceof Error?t.message:e(`common.unknownError`)})})},onSettled:()=>s(null)}),S=l({mutationFn:e=>t.trpcClient.capabilities.setCollectionEnabledProviders.mutate({capability:e.capName,enabledAddonIds:[...e.enabledAddonIds]}),onMutate:e=>{s(e.capName),d(null)},onSuccess:async(t,n)=>{d({kind:`success`,message:e(`system.capabilities.providerSEnabled`,`{{capName}}: {{length}} provider(s) enabled.`,{capName:n.capName,length:n.enabledAddonIds.length})}),await f.refetch()},onError:(t,n)=>{d({kind:`error`,message:e(`system.capabilities.failedToUpdate`,{cap:n.capName,error:t instanceof Error?t.message:e(`common.unknownError`)})})},onSettled:()=>s(null)}),C={onSelectSingleton:(e,t)=>g.mutate({capName:e,addonId:t}),onSelectNodeSingleton:(e,t,n)=>_.mutate({capName:e,nodeId:t,addonId:n}),onClearNodeSingleton:(e,t)=>v.mutate({capName:e,nodeId:t}),onToggleCollection:(e,t)=>S.mutate({capName:e,enabledAddonIds:t}),pendingCapability:i};return a(H,{embedded:!0,icon:y,title:e(`system.capabilities.capabilities`,`Capabilities`),subtitle:e(`system.capabilities.chooseWhichProviderIsActive`,`Choose which provider is active for each system capability. Singleton caps pick exactly one provider; collection caps enable a set.`),children:[c&&a(`div`,{className:`flex items-center gap-2 rounded-md border px-3 py-2 text-xs ${c.kind===`success`?`border-success/30 bg-success/10 text-success`:`border-danger/40 bg-danger/10 text-danger`}`,children:[c.kind===`success`?u(x,{className:`h-3.5 w-3.5 shrink-0`}):u(b,{className:`h-3.5 w-3.5 shrink-0`}),u(`span`,{children:c.message})]}),f.isLoading&&u(`div`,{className:`flex items-center justify-center py-16`,children:u(`div`,{className:`animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full`})}),f.isError&&!f.isLoading&&u(be,{title:e(`system.capabilities.failedToLoadCapabilities`,`Failed to load capabilities`),message:f.error instanceof Error?f.error.message:e(`system.capabilities.unknownError`,`Unknown error`),onRetry:()=>void f.refetch()}),!f.isLoading&&!f.isError&&p.length===0&&u(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:e(`system.capabilities.noCapabilitiesRegistered`,`No capabilities registered.`)}),!f.isLoading&&!f.isError&&p.length>0&&a(`div`,{className:`space-y-6`,children:[m.length>0&&a(`section`,{className:`space-y-2`,children:[u(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:e(`system.capabilities.singletonPickOneProvider`,`Singleton — pick one provider`)}),u(U,{capabilities:m,actions:C})]}),h.length>0&&a(`section`,{className:`space-y-2`,children:[u(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:e(`system.capabilities.collectionEnableASet`,`Collection — enable a set`)}),u(U,{capabilities:h,actions:C})]})]})]})}var G=[`locked`,`reset`,`shares-backup`,`recovery-key`,`rotation-pending`,`orphans`],Xe={"key-missing":`helpers.keychainNotices.lockedKeyMissing`,"wrong-key":`helpers.keychainNotices.lockedWrongKey`,"key-file-unreadable":`helpers.keychainNotices.lockedKeyFileUnreadable`,"store-unavailable":`helpers.keychainNotices.lockedStoreUnavailable`,"not-initialized":`helpers.keychainNotices.lockedNotInitialized`,"decrypt-failed":`helpers.keychainNotices.lockedDecryptFailed`};function Ze(e){let t=Xe[e];return t===void 0?e:B.t(t)}function Qe({status:e,reset:t,pendingReentry:n,orphans:r}){let i=e.keychain.state===`locked`,a=e.keySource??e.configuredSource,o=[];return e.keychain.state===`locked`&&o.push({id:`locked`,tone:`danger`,title:B.t(`helpers.keychainNotices.locked`,{reason:Ze(e.keychain.reason)})}),t!==null&&t.acknowledgedAt===null&&o.push({id:`reset`,tone:`danger`,title:n>0?B.t(`helpers.keychainNotices.resetPending`,{count:n}):B.t(`helpers.keychainNotices.resetDone`)}),a.sharesBackupWithDatabase&&o.push({id:`shares-backup`,tone:`warning`,title:B.t(`helpers.keychainNotices.sharesBackup`)}),!i&&e.recoveryKeyDownloadedAt===null&&o.push({id:`recovery-key`,tone:`warning`,title:B.t(`helpers.keychainNotices.recoveryKey`)}),!i&&e.rotationPending&&o.push({id:`rotation-pending`,tone:`info`,title:B.t(`helpers.keychainNotices.rotationPending`)}),!i&&r>0&&o.push({id:`orphans`,tone:`info`,title:B.t(`helpers.keychainNotices.orphans`,{count:r})}),[...o].sort((e,t)=>G.indexOf(e.id)-G.indexOf(t.id))}var $e={dateStyle:`short`,timeStyle:`short`};function K(e){return e===null?`—`:new Date(e).toLocaleString(void 0,$e)}function q({value:e,copyValue:t,srLabel:n,maxWidthClass:r,className:i}){let o=t??e;return a(`span`,{className:N(`flex min-w-0 items-center gap-0.5`,r),children:[u(`span`,{className:N(`min-w-0 truncate font-mono`,i),title:o,children:e}),u(I,{value:o,srLabel:n,className:`h-6 shrink-0 px-1.5`})]})}e();var et=new Set([`reveal`,`download-recovery-key`,`rotate-master-key`,`reset`]);function tt(e){return[{key:`at`,header:e(`system.keychainAuditTable.colWhen`),render:e=>K(e.at)},{key:`action`,header:e(`system.keychainAuditTable.colAction`),render:e=>u(M,{variant:et.has(e.action)?`warning`:`default`,children:e.action})},{key:`actor`,header:e(`system.keychainAuditTable.colActor`),render:e=>u(`span`,{className:`font-mono`,children:e.actor})},{key:`ref`,header:e(`system.keychainAuditTable.colRef`),render:e=>e.ref===null?u(`span`,{className:`text-foreground-subtle`,children:`—`}):u(q,{value:e.ref,srLabel:`secret ref`,maxWidthClass:`max-w-[22rem]`})},{key:`detail`,header:e(`system.keychainAuditTable.colDetail`),render:e=>u(`span`,{className:`text-foreground-muted`,children:e.detail??``})}]}function nt({entries:e}){let{t}=V(),[i,o]=r(0),s=n(()=>tt(t),[t]);if(e===void 0)return u(`p`,{className:`text-xs text-foreground-subtle`,children:t(`common.loading`,`Loading…`)});let c=Math.max(1,Math.ceil(e.length/25)),l=Math.min(i,c-1),d=l*25,f=e.slice(d,d+25);return a(`div`,{className:`space-y-2`,children:[u(L,{columns:s,rows:f,rowKey:e=>e.id,minWidthPx:760,emptyMessage:t(`secrets.keychainAuditTable.nothingHasBeenAuditedYet`,`Nothing has been audited yet.`)}),e.length>25&&a(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-[11px] text-foreground-subtle`,children:[u(`span`,{children:t(e.length>=500?`system.keychainAuditTable.rangeRecent`:`system.keychainAuditTable.range`,{from:d+1,to:d+f.length,total:e.length})}),a(`span`,{className:`inline-flex items-center gap-1`,children:[u(R,{size:`sm`,variant:`outline`,"aria-label":t(`secrets.keychainAuditTable.previousPage`,`Previous page`),disabled:l===0,onClick:()=>o(l-1),children:u(g,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),a(`span`,{className:`tabular-nums`,children:[l+1,` / `,c]}),u(R,{size:`sm`,variant:`outline`,"aria-label":t(`secrets.keychainAuditTable.nextPage`,`Next page`),disabled:l>=c-1,onClick:()=>o(l+1),children:u(re,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]})]})]})}function rt(e,t){switch(e){case`locked`:return u(R,{size:`sm`,variant:`danger`,disabled:t.busy,onClick:t.onReset,children:B.t(`secrets.keychainNoticeContent.resetKeychain`,`Reset keychain`)});case`reset`:return u(R,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onAcknowledgeReset,children:B.t(`secrets.keychainNoticeContent.dismiss`,`Dismiss`)});case`recovery-key`:return u(R,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onDownload,children:B.t(`secrets.keychainNoticeContent.download`,`Download`)});case`rotation-pending`:return u(R,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onRotate,children:B.t(`secrets.keychainNoticeContent.rotate`,`Rotate`)});case`orphans`:return u(R,{size:`sm`,variant:`outline`,onClick:t.onShowOrphans,children:B.t(`secrets.keychainNoticeContent.review`,`Review`)});case`shares-backup`:return null}}function it(e,t){switch(e){case`locked`:return u(`p`,{children:B.t(`secrets.keychainNoticeContent.noValueCanBeRead`,`No value can be read or stored. If the master key is lost for good, Reset archives every stored value and starts a new keychain; every secret field then reads “not set”.`)});case`reset`:return t.reset===null?null:u(at,{reset:t.reset,pending:t.pendingReentry});case`shares-backup`:return u(`p`,{children:u(Fe,{i18nKey:`secrets.keychainNoticeContent.backupKeyFile`,components:{code:u(`code`,{className:`font-mono`})}})});case`recovery-key`:return u(`p`,{children:B.t(`secrets.keychainNoticeContent.withoutACopyOfThe`,`Without a copy of the master key, the stored values cannot be recovered.`)});case`rotation-pending`:return u(`p`,{children:B.t(`secrets.keychainNoticeContent.theKeychainUnlockedWithA`,`The keychain unlocked with a previous key. Rotate to move onto the configured one.`)});case`orphans`:return null}}function at({reset:e,pending:t}){let{t:n}=V(),r=e.actor===`trigger-file`?n(`secrets.keychainNoticeContent.resetByTrigger`):n(`secrets.keychainNoticeContent.resetByAdmin`,{actor:e.actor});return a(`div`,{className:`space-y-1.5`,children:[u(`p`,{children:n(`secrets.keychainNoticeContent.resetDetail`,{when:K(e.at),by:r,archived:e.archived})}),t.length>0&&u(`ul`,{className:`max-h-40 space-y-0.5 overflow-y-auto rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:t.map(e=>a(`li`,{className:`break-all`,children:[e.owner,` · `,e.scope,` · `,e.fieldPath]},e.ref))})]})}e();var ot=2,J={danger:{icon:ae,text:`text-danger`,border:`border-danger/40`},warning:{icon:p,text:`text-warning`,border:`border-warning/40`},info:{icon:S,text:`text-info`,border:`border-border`}};function st({notices:e,renderAction:t,renderDetail:n}){let{t:i}=V(),[o,s]=r(!1),c=e[0];if(c===void 0)return null;let l=e.length>ot,d=l&&!o?e.slice(0,1):e,f=e.length-d.length;return a(`section`,{"aria-label":i(`secrets.keychainNotices.keychainNotices`,`Keychain notices`),className:N(`rounded-lg border bg-surface`,J[c.tone].border),children:[u(`ul`,{className:`divide-y divide-border`,children:d.map(e=>u(ct,{notice:e,action:t(e.id),detail:n(e.id)},e.id))}),l&&u(`div`,{className:`border-t border-border px-3 py-1`,children:a(R,{size:`sm`,variant:`ghost`,"aria-expanded":o,onClick:()=>s(e=>!e),children:[u(ne,{className:N(`h-3.5 w-3.5 transition-transform`,o&&`rotate-180`),"aria-hidden":!0}),o?i(`secrets.keychainNotices.showLess`,`Show less`):i(`secrets.keychainNotices.more`,`{{hidden}} more`,{hidden:f})]})})]})}function ct({notice:e,action:t,detail:n}){let{t:i}=V(),[o,s]=r(!1),c=J[e.tone],l=c.icon,d=n!=null,f=`keychain-notice-${e.id}`;return a(`li`,{className:`px-3 py-2`,children:[a(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[a(`p`,{className:`flex min-w-0 flex-1 items-start gap-2 text-xs text-foreground`,children:[u(l,{className:N(`mt-0.5 h-3.5 w-3.5 shrink-0`,c.text),"aria-hidden":!0}),u(`span`,{className:`min-w-0 break-words`,children:e.title})]}),a(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5 pl-5 sm:pl-0`,children:[d&&u(R,{size:`sm`,variant:`ghost`,"aria-expanded":o,"aria-controls":f,onClick:()=>s(e=>!e),children:i(`secrets.keychainNotices.details`,`Details`)}),t]})]}),d&&o&&u(`div`,{id:f,className:`mt-2 pl-5 text-xs text-foreground-muted`,children:n})]})}var lt={"config-file":`Key file (config.yaml)`,"previous-config-file":`Previous key file`,platform:`OS keychain`,"default-file":`Default key file (data volume)`},ut=8;function dt({status:e,busy:t,onDownload:n,onRotate:r,onPurge:i}){let{t:o}=V(),s=e.keychain.state===`locked`,c=e.keySource??e.configuredSource;return u(Te,{headingId:`keychain-status`,title:o(`secrets.keychainStatusCard.keychain`,`Keychain`),icon:D,actions:a(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[e.retiredWraps>0&&u(R,{size:`sm`,variant:`ghost`,disabled:t||s,onClick:i,children:o(`secrets.keychainStatusCard.purge`,{count:e.retiredWraps})}),u(R,{size:`sm`,variant:`outline`,disabled:t||s,onClick:r,children:o(`secrets.keychainStatusCard.rotateKey`,`Rotate key`)}),u(R,{size:`sm`,variant:`outline`,disabled:t||s,onClick:n,children:o(`secrets.keychainStatusCard.downloadRecoveryKey`,`Download recovery key`)})]}),children:a(`dl`,{className:`${d} grid grid-cols-1 gap-x-6 gap-y-3 sm:grid-cols-2 xl:grid-cols-4`,children:[a(Y,{label:o(`secrets.keychainStatusCard.state`,`State`),children:[s?a(M,{variant:`danger`,className:`gap-1`,children:[u(ee,{className:`h-3 w-3`,"aria-hidden":!0}),o(`secrets.keychainStatusCard.locked`,`Locked`)]}):a(M,{variant:`success`,className:`gap-1`,children:[u(te,{className:`h-3 w-3`,"aria-hidden":!0}),o(`secrets.keychainStatusCard.unlocked`,`Unlocked`)]}),u(`span`,{className:`ml-2 text-foreground-subtle`,children:o(`common.stored`,{count:e.secretCount})})]}),a(Y,{label:o(`secrets.keychainStatusCard.keySource`,`Key source`),children:[u(`span`,{className:`block`,children:lt[c.kind]}),c.path!==void 0&&u(q,{value:c.path,srLabel:`key path`})]}),u(Y,{label:o(`secrets.keychainStatusCard.fingerprint`,`Fingerprint`),children:e.fingerprint===null?u(`span`,{className:`text-foreground-subtle`,children:`—`}):a(`span`,{className:`inline-flex items-center gap-0.5`,children:[u(`span`,{className:`font-mono`,title:e.fingerprint,children:e.fingerprint.slice(0,ut)}),u(I,{value:e.fingerprint,srLabel:`fingerprint`})]})}),u(Y,{label:o(`secrets.keychainStatusCard.recoveryKey`,`Recovery key`),children:e.recoveryKeyDownloadedAt===null?u(M,{variant:`warning`,children:o(`secrets.keychainStatusCard.notTaken`,`Not taken`)}):u(`span`,{children:o(`secrets.keychainStatusCard.taken`,{when:K(e.recoveryKeyDownloadedAt)})})})]})})}function Y({label:e,children:t}){return a(`div`,{className:`min-w-0 text-xs`,children:[u(`dt`,{className:`text-foreground-subtle`,children:e}),u(`dd`,{className:`mt-0.5 min-w-0 text-foreground`,children:t})]})}e();var ft=1e3;function pt({revealed:e,onClose:n}){let{t:i}=V(),[o,c]=r(A);t(()=>{if(e===null)return;let t=Date.now();c(A);let r=setTimeout(n,A),i=setInterval(()=>c(Math.max(0,A-(Date.now()-t))),ft);return()=>{clearTimeout(r),clearInterval(i)}},[e,n]);let l=Math.ceil(o/1e3);return u(pe,{open:e!==null,onOpenChange:e=>!e&&n(),children:u(ve,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:e!==null&&a(s,{children:[a(ke,{children:[u(xe,{className:`break-all`,children:e.entry.fieldPath}),a(Me,{className:`break-all`,children:[e.entry.owner,` · `,e.entry.scope]})]}),u(oe,{children:u(`pre`,{"data-testid":`revealed-value`,className:`whitespace-pre-wrap break-all rounded-md border border-border bg-background p-3 font-mono text-xs text-foreground`,children:e.value})}),a(Ee,{className:`flex-col items-stretch gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[u(`p`,{className:`text-[11px] text-foreground-subtle`,children:i(`secrets.revealDialog.recorded`,{seconds:l})}),a(`div`,{className:`flex justify-end gap-2`,children:[u(I,{value:e.value,label:i(`common.copy`,`Copy`),srLabel:`revealed value`}),u(R,{size:`sm`,variant:`outline`,onClick:n,children:i(`secrets.revealDialog.hide`,`Hide`)})]})]})]})})})}var X={orphan:{labelKey:`secrets.secretsTableState.usageOrphan`,variant:`warning`,hintKey:`secrets.secretsTableState.usageOrphanHint`,rank:0},unknown:{labelKey:`secrets.secretsTableState.usageUnknown`,variant:`default`,hintKey:`secrets.secretsTableState.usageUnknownHint`,rank:1},"in-use":{labelKey:`secrets.secretsTableState.usageInUse`,variant:`success`,hintKey:`secrets.secretsTableState.usageInUseHint`,rank:2}},mt=[{id:`all`,labelKey:`common.all`},{id:`in-use`,labelKey:`secrets.secretsTableState.usageInUse`},{id:`orphan`,labelKey:`secrets.secretsTableState.filterOrphans`},{id:`unknown`,labelKey:`secrets.secretsTableState.usageUnknown`}],Z=`system`;function ht(e){let{t}=V(),{secrets:n,filter:r,onFilterChange:i,onDeleteOrphans:o,deleting:s,locked:c}=e;if(n===void 0)return u(`p`,{className:`text-xs text-foreground-subtle`,children:t(`common.loading`,`Loading…`)});let l=e=>e===`all`?n.length:n.filter(t=>t.usage===e).length,d=n.filter(e=>e.usage===`orphan`).map(e=>e.ref),p=r===`all`?n:n.filter(e=>e.usage===r);return a(`div`,{className:`space-y-2`,children:[a(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[u(`div`,{className:`flex flex-wrap gap-1`,role:`group`,"aria-label":t(`secrets.secretsTable.filterByUsage`,`Filter by usage`),children:mt.map(e=>a(R,{size:`sm`,variant:r===e.id?`secondary`:`ghost`,"aria-pressed":r===e.id,className:r===e.id?`ring-1 ring-border`:void 0,onClick:()=>i(e.id),children:[t(e.labelKey),u(`span`,{className:`text-foreground-subtle tabular-nums`,children:l(e.id)})]},e.id))}),d.length>0&&a(R,{size:`sm`,variant:`outline`,className:`ml-auto`,disabled:s||c,onClick:()=>o(d),children:[u(f,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),t(`secrets.secretsTableState.deleteOrphans`,{count:d.length})]})]}),u(L,{columns:_t(e),rows:p,rowKey:e=>e.ref,minWidthPx:860,maxBodyHeight:P,defaultSort:{columnKey:`owner`,dir:`asc`},emptyMessage:n.length===0?t(`secrets.secretsTable.noValueIsStoredIn`,`No value is stored in the keychain yet.`):t(`secrets.secretsTable.noStoredValueMatchesThis`,`No stored value matches this filter.`)})]})}function gt({owner:e}){let{t}=V();return a(`span`,{className:`flex items-center gap-2`,children:[u(Be,{addonId:e,fallback:e===Z?v:h,tileClassName:`bg-surface-hover text-foreground-subtle`,size:`sm`}),u(`span`,{className:`font-medium`,children:e===Z?t(`secrets.secretsTable.hubSystem`,`Hub (system)`):e})]})}function _t({locked:e,onReveal:t,revealing:n}){return[{key:`owner`,header:B.t(`secrets.secretsTable.owner`,`Owner`),render:e=>u(gt,{owner:e.owner}),sortValue:e=>e.owner},{key:`scope`,header:B.t(`secrets.secretsTable.scope`,`Scope`),render:e=>u(`span`,{className:`block max-w-[11rem] truncate font-mono`,title:e.scope,children:e.scope}),sortValue:e=>e.scope},{key:`field`,header:B.t(`secrets.secretsTable.field`,`Field`),render:e=>u(q,{value:e.fieldPath,copyValue:e.ref,srLabel:`secret ref`,maxWidthClass:`max-w-[16rem]`}),sortValue:e=>e.fieldPath},{key:`updated`,header:B.t(`secrets.secretsTable.updated`,`Updated`),render:e=>K(e.updatedAt),sortValue:e=>e.updatedAt},{key:`last-read`,header:B.t(`secrets.secretsTable.lastRead`,`Last read`),render:e=>K(e.lastReadAt),sortValue:e=>e.lastReadAt},{key:`status`,header:B.t(`secrets.secretsTable.status`,`Status`),render:e=>u(M,{variant:X[e.usage].variant,title:B.t(X[e.usage].hintKey),children:B.t(X[e.usage].labelKey)}),sortValue:e=>X[e.usage].rank},{key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:r=>a(R,{size:`sm`,variant:`ghost`,disabled:e||n,"aria-label":B.t(`secrets.secretsTable.reveal`,`Reveal {{fieldPath}}`,{fieldPath:r.fieldPath}),title:e?B.t(`secrets.secretsTable.theKeychainIsLocked`,`The keychain is locked`):B.t(`secrets.secretsTable.revealAudited`,`Reveal (audited)`),onClick:()=>t(r),children:[u(m,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),B.t(`secrets.secretsTable.reveal2`,`Reveal`)]})}]}function vt(e){return e instanceof Error?e.message:String(e)}function yt(e){let{t}=V(),n=ce(),r=z(),i=Ce(),a=me(),o=F(),s=Ne(),c=De(),l=ge(),u=_e(),d=async(t,n)=>{try{await n()}catch(e){await r({title:t,message:vt(e),variant:`danger`})}e()};return{busy:a.isPending||o.isPending||s.isPending||c.isPending,deleting:u.isPending,download:async()=>{await n({title:t(`secrets.useKeychainActions.downloadTitle`),message:t(`secrets.useKeychainActions.downloadMessage`),confirmLabel:t(`secrets.useKeychainActions.downloadConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.downloadRefused`),async()=>{let e=await a.mutateAsync({});await i({title:t(`secrets.useKeychainActions.recoveryTitle`,{fingerprint:e.fingerprint}),message:t(`secrets.useKeychainActions.recoveryMessage`),defaultValue:e.key,readOnly:!0,confirmLabel:t(`secrets.useKeychainActions.recoveryDone`)})})},rotate:async()=>{await n({title:t(`secrets.useKeychainActions.rotateTitle`),message:t(`secrets.useKeychainActions.rotateMessage`),confirmLabel:t(`secrets.useKeychainActions.rotateConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.rotateRefused`),async()=>{let e=await o.mutateAsync({});await r({title:t(`secrets.useKeychainActions.rotatedTitle`),message:t(`secrets.useKeychainActions.rotatedMessage`,{fingerprint:e.fingerprint})})})},purge:async()=>{await n({title:t(`secrets.useKeychainActions.purgeTitle`),message:t(`secrets.useKeychainActions.purgeMessage`),confirmLabel:t(`secrets.useKeychainActions.purgeConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.purgeRefused`),async()=>{await s.mutateAsync({})})},reset:async()=>{await i({title:t(`secrets.useKeychainActions.resetTitle`),message:t(`secrets.useKeychainActions.resetMessage`,{confirmation:`RESET KEYCHAIN`}),confirmLabel:t(`secrets.useKeychainActions.resetConfirm`),validate:e=>e===`RESET KEYCHAIN`?null:t(`secrets.useKeychainActions.resetMismatch`)})===`RESET KEYCHAIN`&&await d(t(`secrets.useKeychainActions.resetRefused`),async()=>{await c.mutateAsync({confirm:ie})})},acknowledgeReset:async()=>{await d(t(`secrets.useKeychainActions.dismissFailed`),async()=>{await l.mutateAsync({})})},deleteOrphans:async e=>{await n({title:t(`secrets.useKeychainActions.orphansTitle`,{count:e.length}),message:t(`secrets.useKeychainActions.orphansMessage`),confirmLabel:t(`secrets.useKeychainActions.orphansConfirm`),variant:`danger`})&&await d(t(`secrets.useKeychainActions.orphansRefused`),async()=>{let n=await u.mutateAsync({refs:[...e]});n.kept.length>0&&await r({title:t(`secrets.useKeychainActions.keptTitle`),message:t(`secrets.useKeychainActions.keptMessage`,{deleted:n.deleted.length,kept:n.kept.length})})})}}}e();var Q=`view`;function bt(){let[e,t]=Le();return[e.get(Q)===`audit`?`audit`:`values`,n=>{let r=new URLSearchParams(e);n===`values`?r.delete(Q):r.set(Q,n),t(r,{replace:!0})}]}function xt(){let{t:e}=V(),t=Oe({}),o=ye({}),s=se({limit:500}),c=Ae({}),l=Se(),d=z(),[f,p]=bt(),[m,h]=r(`all`),[g,_]=r(null),v=yt(()=>{t.refetch(),o.refetch(),s.refetch(),c.refetch()}),y=t.data?.keychain.state===`locked`,b=n(()=>(o.data??[]).filter(e=>e.usage===`orphan`).length,[o.data]),x=n(()=>t.data===void 0?[]:Qe({status:t.data,reset:c.data?.reset??null,pendingReentry:c.data?.pendingReentry.length??0,orphans:b}),[t.data,c.data,b]),S={reset:c.data?.reset??null,pendingReentry:c.data?.pendingReentry??[],busy:v.busy,onReset:()=>void v.reset(),onAcknowledgeReset:()=>void v.acknowledgeReset(),onDownload:()=>void v.download(),onRotate:()=>void v.rotate(),onShowOrphans:()=>{h(`orphan`),p(`values`)}},C=async t=>{try{_({entry:t,value:(await l.mutateAsync({ref:t.ref})).value}),o.refetch()}catch(t){await d({title:e(`admin.system.secrets.revealRefused`,`Reveal refused`),message:Ie(t),variant:`danger`})}},w=i(()=>_(null),[]);return a(H,{embedded:!0,icon:D,title:e(`admin.system.secrets.secrets`,`Secrets`),subtitle:e(`admin.system.secrets.passwordsTokensAndKeysEncrypted`,`Passwords, tokens and keys, encrypted in the hub keychain. Values leave the hub only through an audited reveal.`),children:[u(st,{notices:x,renderAction:e=>rt(e,S),renderDetail:e=>it(e,S)}),t.data!==void 0&&u(dt,{status:t.data,busy:v.busy,onDownload:S.onDownload,onRotate:S.onRotate,onPurge:()=>void v.purge()}),a(ue,{value:f,onValueChange:e=>p(e===`audit`?`audit`:`values`),children:[a(we,{children:[u(O,{value:`values`,children:e(`admin.system.secrets.storedValues`,`Stored values`)}),u(O,{value:`audit`,children:e(`admin.system.secrets.audit`,`Audit`)})]}),u(j,{value:`values`,children:u(ht,{secrets:o.data,locked:y,filter:m,onFilterChange:h,onReveal:e=>void C(e),revealing:l.isPending,onDeleteOrphans:e=>void v.deleteOrphans(e),deleting:v.deleting})}),u(j,{value:`audit`,children:u(nt,{entries:s.data})})]}),u(pt,{revealed:g,onClose:w})]})}e();var St=[[`system`]];function $(e){return e.toFixed(6).replace(/0+$/,``).replace(/\.$/,``)}function Ct(){let{t:e}=V(),n=c(),i=he(),o=fe(),s=le(),[l,d]=r(``),[f,p]=r(``),[m,h]=r(null),g=i.data?.location??null;t(()=>{d(g===null?``:$(g.latitude)),p(g===null?``:$(g.longitude))},[g]);let v=async()=>{await n.invalidateQueries({queryKey:St})},y=async e=>{e.preventDefault();let t=Number(l),n=Number(f);if(l.trim()===``||f.trim()===``){h(`Enter both a latitude and a longitude, or press Clear.`);return}if(!Number.isFinite(t)||t<-90||t>90){h(`Latitude must be between -90 and 90 decimal degrees.`);return}if(!Number.isFinite(n)||n<-180||n>180){h(`Longitude must be between -180 and 180 decimal degrees.`);return}h(null),await o.mutateAsync({latitude:t,longitude:n}),await v()},b=async()=>{h(null),await o.mutateAsync(null),await v()},x=async()=>{h(null),await s.mutateAsync(),await v()},S=o.isPending||s.isPending||i.isLoading;return a(je,{className:`space-y-3`,children:[a(`div`,{className:`flex items-start justify-between gap-3`,children:[a(`div`,{className:`flex items-start gap-2`,children:[u(T,{className:`h-4 w-4 mt-0.5 text-muted-foreground shrink-0`}),u(`div`,{children:u(`h3`,{className:`text-sm font-medium`,children:e(`settings.siteLocationCard.siteLocation`,`Site location`)})})]}),g===null?u(M,{variant:`warning`,children:e(`settings.siteLocationCard.notConfigured`,`Not configured`)}):u(M,{variant:g.source===`operator-set`?`success`:`info`,children:g.source===`operator-set`?e(`settings.siteLocationCard.setByYou`,`Set by you`):e(`settings.siteLocationCard.derivedFromIp`,`Derived from IP`)})]}),g?.label!==void 0&&g.label!==``?u(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings.siteLocationCard.detectedNear`,{place:g.label})}):null,g===null&&i.data?.derivationAttemptedAt!==null?a(`p`,{className:`text-xs text-warning`,children:[e(`settings.siteLocationCard.automaticDetectionFromThePublic`,`Automatic detection from the public IP did not succeed`),i.data?.derivationError!==null&&i.data?.derivationError!==void 0?`: ${i.data.derivationError}`:`.`,` `,e(`settings.siteLocationCard.itIsNotRetriedOn`,`It is not retried on its own — enter the coordinates, or press Detect.`)]}):null,a(`form`,{className:`flex flex-wrap items-end gap-3`,onSubmit:y,children:[a(`label`,{className:`flex flex-col gap-1 text-xs`,children:[u(`span`,{className:`text-muted-foreground`,children:e(`settings.siteLocationCard.latitude`,`Latitude`)}),u(k,{className:`w-40`,value:l,inputMode:`decimal`,placeholder:`40.851800`,onChange:e=>d(e.target.value),"aria-label":e(`settings.siteLocationCard.latitude`,`Latitude`)})]}),a(`label`,{className:`flex flex-col gap-1 text-xs`,children:[u(`span`,{className:`text-muted-foreground`,children:e(`settings.siteLocationCard.longitude`,`Longitude`)}),u(k,{className:`w-40`,value:f,inputMode:`decimal`,placeholder:`14.268100`,onChange:e=>p(e.target.value),"aria-label":e(`settings.siteLocationCard.longitude`,`Longitude`)})]}),u(R,{type:`submit`,disabled:S,children:e(`common.save`,`Save`)}),a(R,{type:`button`,variant:`ghost`,disabled:S,onClick:x,children:[u(_,{className:`h-3.5 w-3.5 mr-1`}),e(`settings.siteLocationCard.detectFromIp`,`Detect from IP`)]}),g===null?null:u(R,{type:`button`,variant:`ghost`,disabled:S,onClick:b,children:e(`settings.siteLocationCard.clear`,`Clear`)})]}),m===null?null:u(`p`,{className:`text-xs text-danger`,children:m}),u(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings.siteLocationCard.wgs84DecimalDegreesDetectAsks`,`WGS84 decimal degrees. Detect asks a public geo-IP service once and will not overwrite a value you typed — clear it first.`)})]})}function wt(){let{t:e}=V(),{nodes:t,isLoading:n}=de(),r=t.find(e=>e.isHub&&e.isOnline),i=r?.addons.map(e=>e.addonId)??[];return a(H,{embedded:!0,children:[u(Ct,{}),n?u(`div`,{className:`text-muted-foreground text-sm py-12 text-center`,children:e(`admin.system.settings.loadingHubTopology`,`Loading hub topology…`)}):r?i.length===0?u(`div`,{className:`text-muted-foreground text-sm py-12 text-center`,children:e(`admin.system.settings.noAddonsInstalledOnThe`,`No addons installed on the hub yet.`)}):u(ze,{nodeId:r.id,addonIds:i,level:`global`}):a(`div`,{className:`flex flex-col items-center justify-center text-muted-foreground text-sm gap-2 py-12`,children:[u(E,{className:`h-8 w-8 opacity-30`}),u(`p`,{children:e(`admin.system.settings.noOnlineHubNodeFound`,`No online hub node found.`)}),u(`p`,{className:`text-xs`,children:e(`admin.system.settings.settingsWillAppearOnceThe`,`Settings will appear once the hub is reachable.`)})]})]})}function Tt(){let{t:e}=V(),t=Pe(`/system/settings`,{t:e,isAdmin:!0})??{icon:E,title:e(`system.systemNav`,`System`)};return u(Re,{icon:t.icon,title:t.title,defaultSection:`settings`,sectionsLabel:`${t.title} sections`,sections:[{id:`settings`,label:e(`system.system.settings`,`Settings`),content:u(wt,{})},{id:`secrets`,label:e(`system.system.secrets`,`Secrets`),content:u(xt,{}),ownedParams:[`view`]},{id:`capabilities`,label:e(`system.system.capabilities`,`Capabilities`),content:u(Ye,{})}]})}export{Tt as SystemPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{na as e}from"./player-overlays-D98Lvll4.js";var t=e(`circle-slash`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]);export{t};
|