@camstack/addon-admin-ui 1.2.650 → 1.2.652
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/CHANGELOG.md +16 -1
- package/dist/assets/Addons-DFygon8k.js +5 -0
- package/dist/assets/{AdminPage-tWFzmkA7.js → AdminPage-2H7qegiH.js} +1 -1
- package/dist/assets/{AdminSectionedPage-D00S68ny.js → AdminSectionedPage-CWRY6TXK.js} +1 -1
- package/dist/assets/AiProfiles-Ct9zcHWG.js +3 -0
- package/dist/assets/{BootstrapSettingsForm-ObiD-4-l.js → BootstrapSettingsForm-DJLxKYKT.js} +1 -1
- package/dist/assets/{Build-MKmgkbmb.js → Build-_MNk-gsH.js} +4 -4
- package/dist/assets/{Calendars-D3mhCBNC.js → Calendars-BrFMMXU3.js} +1 -1
- package/dist/assets/{CameraGrids-C0n7qSaN.js → CameraGrids-7RfsBtg8.js} +1 -1
- package/dist/assets/{Cluster-x_aFWP8q.js → Cluster-qdUn0ZWi.js} +1 -1
- package/dist/assets/{CompositionBlockEditor-xMJURnzF.js → CompositionBlockEditor-tW-fi9fY.js} +2 -2
- package/dist/assets/{CompositionEditorPage-C1X6QW6w.js → CompositionEditorPage-BdKITJdB.js} +1 -1
- package/dist/assets/{Data-DjvjUZ88.js → Data-Dq99cYIc.js} +2 -2
- package/dist/assets/DeviceDetail-DZKwQsDf.js +2 -0
- package/dist/assets/{Devices-CRz_XyZv.js → Devices-B4o5FkKs.js} +1 -1
- package/dist/assets/{EmbedDevicePage-BA8S4eB2.js → EmbedDevicePage-BCz48kwT.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-DwvtigtA.js → EmbedPlayerPage-DROVGJUa.js} +1 -1
- package/dist/assets/{History-Bbh7GyuR.js → History-DjSpw_q0.js} +1 -1
- package/dist/assets/Identity-DRR4EhOw.js +1 -0
- package/dist/assets/InstancesTable-fZ0yNacw.js +1 -0
- package/dist/assets/IntegrationDetail-BWYrpCeb.js +1 -0
- package/dist/assets/IntegrationWizard-DyIJiQjm.js +1 -0
- package/dist/assets/Integrations-BzdMNme3.js +1 -0
- package/dist/assets/{Integrations-2rOn7RrQ.js → Integrations-Dx5lzGGq.js} +2 -2
- package/dist/assets/{Library-Durt7-NC.js → Library-kH7Xd3gC.js} +1 -1
- package/dist/assets/Locations-CPNRVIjp.js +3 -0
- package/dist/assets/{Logs-D72sIrph.js → Logs-BCSHF0Hz.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-BxTTlAfh.js → MaskShapeCanvas-g7yAssct.js} +1 -1
- package/dist/assets/{MotionZonesSettings-ieLDWpte.js → MotionZonesSettings-BvqGObrA.js} +1 -1
- package/dist/assets/MyAccess-Bfdi856H.js +2 -0
- package/dist/assets/{Network-CwqR0gPE.js → Network-CmZhSVsi.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-CgMvgFAN.js → NodeAddonsSettingsPanel-DwqvYEao.js} +1 -1
- package/dist/assets/{Notifications-DmJTTHb2.js → Notifications-DA1lIKUt.js} +1 -1
- package/dist/assets/{Pipeline-K1nNCknb.js → Pipeline-r-8l7hZO.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-BmYR9i5a.js → PrivacyMaskSettings-C43hww2R.js} +1 -1
- package/dist/assets/Recordings-B50SML_Q.js +1 -0
- package/dist/assets/{RemoteGrid-CnvWN_Q7.js → RemoteGrid-Dv8u1cRv.js} +1 -1
- package/dist/assets/{ScanSubnetEditor-COYKrOUZ.js → ScanSubnetEditor-lUmamDRT.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-DeQ9ymYM.js → SceneMonitorEditor-DA76cNih.js} +1 -1
- package/dist/assets/SessionsList-CSmzdfK6.js +2 -0
- package/dist/assets/{Showroom-y8XDooe0.js → Showroom-YNNYBt4x.js} +1 -1
- package/dist/assets/{StorageLocationsTable-CEuzgMli.js → StorageLocationsTable-CIQLMsJC.js} +1 -1
- package/dist/assets/{System-B5rn1ItC.js → System-r539bm4J.js} +1 -1
- package/dist/assets/{Templates-Bk06ZJwK.js → Templates-B6Nl1xgU.js} +1 -1
- package/dist/assets/{Terminal-CrDf4D63.js → Terminal-CdDnVDQl.js} +3 -3
- package/dist/assets/{TrainingProviders-DtxFhEAZ.js → TrainingProviders-DJ09cRpJ.js} +1 -1
- package/dist/assets/{Viewer-Dod1J2kQ.js → Viewer-UkANt4yY.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Ck0PhSCH.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Brm6yYA2.js} +1 -1
- package/dist/assets/{action-draft-CbHoxLjI.js → action-draft-B0YtvIK8.js} +1 -1
- package/dist/assets/{ai-page.helpers-C6ls8wz_.js → ai-page.helpers-D6ZZMriu.js} +1 -1
- package/dist/assets/{assignment-candidates-DWPnaRvD.js → assignment-candidates-D-v7rj2f.js} +1 -1
- package/dist/assets/{authed-media-DSqxjKn1.js → authed-media-CYJ67W1F.js} +1 -1
- package/dist/assets/{board-model-BjCZ9N9K.js → board-model-Bk9dOlXr.js} +1 -1
- package/dist/assets/client-CxoliObn.js +1114 -0
- package/dist/assets/{command-vocab-D-Mb5eIw.js → command-vocab-Xm353Fi-.js} +1 -1
- package/dist/assets/{create-composition-Ds7Ik4DO.js → create-composition-BEPdO8PM.js} +1 -1
- package/dist/assets/device-detail-DUYt5dz3.js +1 -0
- package/dist/assets/{device-integration-icon-CIwY5XXY.js → device-integration-icon-96PtuBb0.js} +1 -1
- package/dist/assets/device-picker-model-CIZB_MPl.js +1 -0
- package/dist/assets/{dist-hKqDc_W9.js → dist-Dur6bHcC.js} +1 -1
- package/dist/assets/dist-_n5SMWsj.js +1114 -0
- package/dist/assets/{format-B7kl8sLY.js → format-BxjElxwq.js} +1 -1
- package/dist/assets/{hostInit-De1tBXdJ.js → hostInit-BopdhKYk.js} +1 -1
- package/dist/assets/i18n-C__Kv-sS.js +1 -0
- package/dist/assets/{icons-B6WiLi5J.js → icons-Djs5qMrO.js} +1 -1
- package/dist/assets/index-hhTXvvOB.js +4 -0
- package/dist/assets/{linked-devices-model-eYoI_73X.js → linked-devices-model-Bb6B3YVg.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-959d6f36.js → mf-entry-bootstrap-0-207caf94.js} +2 -2
- package/dist/assets/mount-CIZB_MPl.js +1 -0
- package/dist/assets/{notification-rule-status-DkXZfwuk.js → notification-rule-status-DEk79oDE.js} +1 -1
- package/dist/assets/{player-overlays-BMit2yun.js → player-overlays-DilQz9uf.js} +1 -1
- package/dist/assets/remoteEntry-PV_ZlxYI.js +1 -0
- package/dist/assets/src-BgJM3bf_.js +252 -0
- package/dist/assets/{step-inspector-model-BmSCuJai.js → step-inspector-model-Ce7VAyE-.js} +1 -1
- package/dist/assets/{use-scenes-feed-DBj0OZCW.js → use-scenes-feed-0Xrve4u9.js} +1 -1
- package/dist/assets/{use-stationary-objects-DtRd8lhr.js → use-stationary-objects-DY7wIMD2.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-d9P0Cpza.js → useAdminDeviceRemoval-CPedVydD.js} +1 -1
- package/dist/assets/useEventInvalidation-CIZB_MPl.js +1 -0
- package/dist/assets/{useNodeUrlSelection-Cut66SbO.js → useNodeUrlSelection-CIiBKiPN.js} +1 -1
- package/dist/assets/{useTemplateSave-CEcw08D0.js → useTemplateSave-Cfew9nvB.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DAlkrz1F.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CMPo2XXm.js} +2 -2
- package/dist/index.html +7 -7
- package/dist/server/addon.js +311 -23
- package/package.json +2 -2
- package/dist/assets/Addons-66AtY5mu.js +0 -5
- package/dist/assets/AiProfiles-DoPAcfxw.js +0 -3
- package/dist/assets/DeviceDetail-DkfzIA36.js +0 -2
- package/dist/assets/Identity-BTU7dHsy.js +0 -1
- package/dist/assets/InstancesTable-D0ePlG0O.js +0 -1
- package/dist/assets/IntegrationDetail-CNpwj5mL.js +0 -1
- package/dist/assets/IntegrationWizard-y3tDHsc8.js +0 -1
- package/dist/assets/Integrations-BghPCCUX.js +0 -1
- package/dist/assets/Locations-DYIW2-f6.js +0 -3
- package/dist/assets/MyAccess-BQTBSq6K.js +0 -2
- package/dist/assets/Recordings-DFhEOydB.js +0 -1
- package/dist/assets/SessionsList-CchnaZDu.js +0 -2
- package/dist/assets/client-DLGNlJDt.js +0 -1114
- package/dist/assets/device-detail-D8-PST69.js +0 -1
- package/dist/assets/device-picker-model-DBhTfKm0.js +0 -1
- package/dist/assets/dist-1yU8tcrp.js +0 -1114
- package/dist/assets/i18n-CcjpDLHK.js +0 -1
- package/dist/assets/index-DgOWypvk.js +0 -4
- package/dist/assets/mount-DBhTfKm0.js +0 -1
- package/dist/assets/remoteEntry-DCzIPVEe.js +0 -1
- package/dist/assets/src-Dg912oqK.js +0 -250
- package/dist/assets/useEventInvalidation-DBhTfKm0.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./browser-BHo8W_uH.js","./rolldown-runtime-Cyuzqnbw.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{t}from"./vite-preload-helper-kNaey6uv.js";import{C as n,J as r,K as i,S as a,V as o,Y as s,a as c,et 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-CEyXHAdg.js";import{Cr as f,En as p,Er as m,Fa as h,Kt as g,Ni as _,Nr as v,Pi as y,Q as b,Yt as x,ct as S,gi as C,gn as w,gt as T,kr as E,ni as D,pa as O,tr as k,ut as A}from"./player-overlays-BMit2yun.js";import{_i as j,vi as M}from"./client-DLGNlJDt.js";import{d as ee,s as N}from"./video-De6y5yax.js";import{t as P}from"./monitor-smartphone-DPI9EQus.js";import{t as te}from"./unlink-D3-IGpS8.js";import{Hr as ne,In as re,Vr as ie,cc as ae,cf as F,ef as I,lt as oe,uc as se,xi as L,zf as R}from"./src-Dg912oqK.js";import{t as ce}from"./i18n-CcjpDLHK.js";import{t as z}from"./useTranslation-BJr-n0es.js";import"./mount-DBhTfKm0.js";import{Gr as B,Hr as le,I as V,Jr as H,Kr as U,Qr as W,Ur as ue,Wr as de,n as G}from"./index-DgOWypvk.js";import{t as fe}from"./AdminSectionedPage-D00S68ny.js";import{t as pe}from"./AdminPage-tWFzmkA7.js";import{D as me,O as he,_ as ge,a as _e,h as ve,r as ye,t as K,w as be}from"./SessionsList-CchnaZDu.js";l();var xe=`${j}/connect`,q={public:0,mesh:1,lan:2,"lan-ipv6":3};function Se(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 M(e)}function Ce(e){return e.startsWith(`https://`)}function we(e){let t=e.flatMap(e=>{let t=Se(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:Ce(r),plausible:e.plausible}]))}function Te(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 Ee(e){let t=new URL(xe);return t.searchParams.set(`hub`,e),t.toString()}var De=176,Y={scheme:`https`};function Oe(){let{t:e}=z(),t=se(Y),r=ae(Y).data?.roles.publicEndpoint.resolved??null;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(w,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`connectPhone.title`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`connectPhone.description`)}),t.isPending?n(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[a(m,{className:`h-3.5 w-3.5 animate-spin`}),e(`connectPhone.loading`)]}):t.isError?n(`div`,{className:`flex items-start gap-2 text-[11px] text-danger`,children:[a(g,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),n(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[a(`div`,{className:`break-words`,children:e(`connectPhone.error`,{message:t.error.message})}),a(I,{size:`sm`,variant:`ghost`,onClick:()=>void t.refetch(),children:e(`connectPhone.retry`)})]})]}):a(ke,{candidates:we(t.data.endpoints),preferredOrigin:r})]})]})}function ke({candidates:e,preferredOrigin:t}){let{t:r}=z(),[o,c]=s(null),l=Te(e,o,t),u=i(()=>l?Ee(l.origin):null,[l]);if(l===null||u===null)return a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.empty`)});let d=e=>r(`connectPhone.tier.${e}`),f=e.map(e=>({value:e.origin,label:`${d(e.tier)} — ${e.origin}`}));return n(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:[a(ie,{value:u,size:De,alt:r(`connectPhone.qrAlt`),className:`self-start`}),n(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[n(`label`,{className:`block space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.addressLabel`)}),a(A,{value:l.origin,options:f,onChange:e=>c(e.target.value)}),n(`span`,{className:`block text-[10px] text-foreground-subtle`,children:[d(l.tier),` · `,l.label]})]}),!l.secure&&a(X,{text:r(`connectPhone.insecure`)}),!l.plausible&&a(X,{text:r(`connectPhone.implausible`)}),n(`div`,{className:`space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.linkLabel`)}),n(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[a(`code`,{className:`flex-1 min-w-0 font-mono text-[11px] text-foreground break-all select-all`,children:u}),a(re,{value:u,srLabel:r(`connectPhone.linkLabel`)})]})]}),a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.signInHint`)})]})]})}function X({text:e}){return n(`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:[a(g,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),a(`span`,{children:e})]})}l();function Ae(e){return new Date(e).toLocaleDateString()}function je(){let{t:e}=z(),t=S(),i=R.useUtils(),c=R.auth.listLinkableProviders.useQuery(),l=R.auth.listOwnExternalIdentities.useQuery(),[u,d]=s(null),[f,p]=s(()=>B(window.location.search)),h=r(null),g=G(`Linking a sign-in account`),v=r(null);o(()=>()=>v.current?.(),[]);let[x,C]=s(null);o(()=>{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 w=R.auth.beginExternalLink.useMutation({onSuccess:({url:e})=>{let t=h.current;if(h.current=null,t===null||t.closed){window.location.assign(e);return}let n=e=>{C(null),p(B(`?${e}`)),i.auth.listOwnExternalIdentities.invalidate()};v.current?.(),v.current=ue(t,{onReturn:e=>{e.target===`profile`&&n(e.query)},onDone:e=>{e.target===`profile`&&n(e.query)},onClosed:()=>{v.current?.(),v.current=null,i.auth.listOwnExternalIdentities.invalidate()}}),t.location.href=b(de(e))},onError:e=>{h.current?.close(),h.current=null,C(null),d(e.message)}}),T=R.auth.unlinkOwnExternalIdentity.useMutation({onSuccess:()=>void i.auth.listOwnExternalIdentities.invalidate(),onError:e=>d(e.message)}),D=c.data??[],O=l.data??[],k=x!==null&&O.some(e=>e.provider===x);if(o(()=>{!k||x===null||(C(null),p({kind:`linked`,provider:x}))},[k,x]),D.length===0&&O.length===0)return null;let A=new Set(O.map(e=>e.provider)),j=e=>D.find(t=>t.provider===e)?.label??e,M=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`})&&(d(null),T.mutate({provider:n.provider,subject:n.subject}))};return n(`div`,{"data-testid":`linked-sign-ins`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[g.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(E,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`users.linkedSignInsSection.linkedSignInAccounts`,`Linked sign-in accounts`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`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`&&n(`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:[a(_,{className:`h-3.5 w-3.5 text-emerald-500 shrink-0`}),e(`users.linkedSignIns.linkedNotice`,{provider:j(f.provider)})]}),(f?.kind===`error`||u)&&n(`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:[a(y,{className:`h-3.5 w-3.5 shrink-0`}),u??(f?.kind===`error`?f.message:``)]}),O.length>0&&a(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:O.map(t=>{let r=t.providerLabel??t.provider;return n(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[n(`div`,{className:`flex-1 min-w-0`,children:[n(`div`,{className:`font-medium text-foreground truncate`,children:[r,!t.available&&a(`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`)})]}),a(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:e(`users.linkedSignIns.linkedOn`,{label:t.label??t.subject,date:Ae(t.linkedAt)})})]}),n(I,{variant:`unstyled`,onClick:()=>void M(t,r),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:[a(te,{className:`h-3 w-3`}),e(`users.linkedSignInsSection.unlink`,`Unlink`)]})]},`${t.provider}|${t.subject}`)})}),a(`div`,{className:`flex flex-wrap gap-2`,children:D.filter(e=>!A.has(e.provider)).map(t=>n(I,{variant:`unstyled`,onClick:()=>{d(null),p(null),g.requestProof().then(e=>{e!==null&&(h.current=le(null),C(h.current===null?null:t.provider),w.mutate({provider:t.provider,reauthToken:e}))})},disabled:w.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:[w.isPending&&w.variables?.provider===t.provider?a(m,{className:`h-3 w-3 animate-spin`}):a(E,{className:`h-3 w-3`}),e(`users.linkedSignIns.link`,{provider:t.label})]},t.provider))})]})]})}l();function Me({value:r,size:i=192}){let{t:c}=z(),[l,u]=s(null),[d,f]=s(null);if(o(()=>{let n=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(n)return;let t=e.create;if(typeof t!=`function`){f(`qrcode.create() unavailable in installed version`);return}try{let e=t(r,{errorCorrectionLevel:`M`});n||u(e)}catch(e){n||f(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{n||f(`qrcode library not installed`)}),()=>{n=!0}},[r]),d)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:c(`users.totpQrCode.qrRenderingUnavailableUseThe`,`QR rendering unavailable — use the secret below.`)});if(!l)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:c(`users.totpQrCode.generating`,`Generating…`)});let p=l.modules.size,m=i/p,h=[];for(let e=0;e<p;e++)for(let t=0;t<p;t++)l.modules.data[e*p+t]&&h.push(a(`rect`,{x:t*m,y:e*m,width:m,height:m,fill:`currentColor`},`${t}-${e}`));return n(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[a(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),h]})}l();function Ne(){let{t:e}=z(),t=T(),[r,i]=s(``),[o,c]=s(``),[l,d]=s(``),[p,h]=s(null),g=u({mutationFn:e=>t.changeOwnPassword(e),onSuccess:()=>{h({kind:`success`,msg:`Password updated.`}),i(``),c(``),d(``)},onError:e=>{h({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),v=o.length>0&&l.length>0&&o!==l,b=o.length>0&&o.length<8,x=r.length>=1&&o.length>=8&&o===l;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(ee,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`systemPage.myAccess.changePassword`,`Change password`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(Z,{label:e(`systemPage.myAccess.currentPassword`,`Current password`),value:r,onChange:i,autoComplete:`current-password`}),a(Z,{label:e(`systemPage.myAccess.newPassword`,`New password`),value:o,onChange:c,autoComplete:`new-password`,hint:e(`systemPage.myAccess.atLeast8Characters`,`At least 8 characters.`)}),a(Z,{label:e(`systemPage.myAccess.confirmNewPassword`,`Confirm new password`),value:l,onChange:d,autoComplete:`new-password`}),(v||b)&&a(`div`,{className:`text-[11px] text-danger`,children:v?e(`systemPage.myAccess.passwordsDoNotMatch`,`Passwords do not match.`):e(`systemPage.myAccess.newPasswordMustBeAt`,`New password must be at least 8 characters.`)}),p&&n(`div`,{className:`text-[11px] flex items-center gap-1 ${p.kind===`success`?`text-success`:`text-danger`}`,children:[p.kind===`success`?a(_,{className:`h-3 w-3`}):a(y,{className:`h-3 w-3`}),p.msg]}),a(`div`,{className:`flex justify-end`,children:n(I,{onClick:()=>{h(null),g.mutate({currentPassword:r,newPassword:o})},disabled:!x||g.isPending,children:[g.isPending?a(m,{className:`h-3 w-3 animate-spin`}):a(f,{className:`h-3 w-3`}),e(`systemPage.myAccess.updatePassword`,`Update password`)]})})]})]})}function Z({label:e,value:t,onChange:r,autoComplete:i,hint:o}){return n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),a(F,{type:`password`,value:t,onChange:e=>r(e.target.value),autoComplete:i,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),o&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:o})]})}function Pe({username:e}){let{t}=z(),r=T(),l=c({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>r.getOwnTotpStatus()}),f=l.data,[p,h]=s(null),[g,v]=s(``),[b,x]=s(null),[S,E]=s(!1),D=u({mutationFn:()=>r.setupOwnTotp(),onSuccess:e=>{h({secret:e.secret,otpauthUrl:e.otpauthUrl}),v(``),x(null)},onError:e=>x(e instanceof Error?e.message:`Setup failed`)}),O=u({mutationFn:e=>r.confirmOwnTotp(e),onSuccess:()=>{h(null),v(``),x(null),l.refetch()},onError:e=>x(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),k=G(`Turning off two-factor authentication`),A=u({mutationFn:async()=>{let e=await k.requestProof();return e===null?null:r.disableOwnTotp({reauthToken:e})},onSuccess:()=>{x(null),l.refetch()},onError:e=>x(e instanceof Error?e.message:`Disable failed`)});o(()=>{if(!S)return;let e=setTimeout(()=>E(!1),1500);return()=>clearTimeout(e)},[S]);let j=i(()=>l.isLoading?`loading`:p?`setup_in_progress`:f?.enabled?`enrolled`:`not_enrolled`,[l.isLoading,f?.enabled,p]);return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[k.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(w,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.twoFactorAuthentication`,`Two-factor authentication`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[j===`loading`&&n(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(m,{className:`h-3.5 w-3.5 animate-spin`}),t(`systemPage.myAccess.checkingStatus`,`Checking status…`)]}),j===`not_enrolled`&&n(d,{children:[a(`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.`)}),a(`div`,{className:`flex justify-end`,children:n(I,{onClick:()=>{x(null),D.mutate()},disabled:D.isPending,children:[D.isPending?a(m,{className:`h-3 w-3 animate-spin`}):a(w,{className:`h-3 w-3`}),t(`systemPage.myAccess.enable2fa`,`Enable 2FA`)]})})]}),j===`setup_in_progress`&&p&&n(d,{children:[a(`div`,{className:`text-[11px] text-foreground-subtle`,children:a(U,{i18nKey:`systemPage.myAccess.scanQr`,values:{username:e},components:{mono:a(`span`,{className:`font-mono`})}})}),n(`div`,{className:`flex flex-col items-center gap-3`,children:[a(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:a(Me,{value:p.otpauthUrl,size:180})}),n(`div`,{className:`w-full`,children:[a(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:t(`systemPage.myAccess.secretManualEntry`,`Secret (manual entry)`)}),n(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[a(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:p.secret}),n(I,{variant:`ghost`,onClick:()=>{p&&navigator.clipboard.writeText(p.secret).then(()=>E(!0))},children:[S?a(_,{className:`h-3 w-3 text-success`}):a(C,{className:`h-3 w-3`}),S?t(`systemPage.myAccess.copied`,`Copied`):t(`common.copy`,`Copy`)]})]})]})]}),n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),a(F,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:g,onChange:e=>v(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary`})]}),b&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(y,{className:`h-3 w-3`}),b]}),n(`div`,{className:`flex justify-end gap-2`,children:[a(I,{variant:`outline`,onClick:()=>{h(null),x(null),v(``)},children:t(`common.cancel`,`Cancel`)}),n(I,{onClick:()=>{x(null),O.mutate({code:g})},disabled:O.isPending||g.length!==6,children:[O.isPending?a(m,{className:`h-3 w-3 animate-spin`}):a(_,{className:`h-3 w-3`}),t(`common.confirm`,`Confirm`)]})]})]}),j===`enrolled`&&f&&n(d,{children:[n(`div`,{className:`rounded-md border border-success/30 bg-success/5 px-3 py-2.5 flex items-start gap-2.5`,children:[a(_,{className:`h-4 w-4 mt-0.5 text-success shrink-0`}),n(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[a(`div`,{className:`font-medium`,children:t(`systemPage.myAccess.2faIsActive`,`2FA is active`)}),a(`div`,{className:`text-foreground-subtle`,children:t(`common.enrolledOn`,{when:f.confirmedAt?new Date(f.confirmedAt).toLocaleString():`—`})})]})]}),b&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(y,{className:`h-3 w-3`}),b]}),a(`div`,{className:`flex justify-end`,children:n(I,{variant:`danger`,onClick:()=>{x(null),A.mutate()},disabled:A.isPending,children:[A.isPending?a(m,{className:`h-3 w-3 animate-spin`}):a(w,{className:`h-3 w-3`}),t(`systemPage.myAccess.disable2fa`,`Disable 2FA`)]})})]})]})]})}function Fe(){return L(`auth-webauthn/passkey-enrollment`)?a(ne,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}l();function Q(e){return e.message.length>0?e.message:ce.t(`auth.authAuditSection.requestFailed`)}function Ie(){let{t:e}=z(),{logout:t}=V(),r=S(),i=R.useUtils(),o=R.auth.listOwnSessions.useQuery(),[c,l]=s(null),u=R.auth.revokeOwnSession.useMutation({onSuccess:()=>void i.auth.listOwnSessions.invalidate(),onError:e=>l(`Sign out failed: ${Q(e)}`)}),d=R.auth.logout.useMutation({onSuccess:()=>t(),onError:e=>l(`Sign out failed: ${Q(e)}`)}),f=async t=>{await r({title:e(`auth.mySessionsSection.signOutThisSession`,`Sign out this session`),message:e(`auth.mySessionsSection.willHaveToSignIn`,`{{label}} will have to sign in again.`,{label:ge(t.client).label}),confirmLabel:e(`auth.mySessionsSection.signOut`,`Sign out`),variant:`danger`})&&(l(null),u.mutate({id:t.id}))},p=async()=>{await r({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`})&&(l(null),d.mutate({everywhere:!0}))};return n(`div`,{"data-testid":`my-sessions`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(P,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`auth.mySessionsSection.activeSessions`,`Active sessions`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`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.`)}),c!==null&&a(`div`,{className:`text-[11px] text-danger`,children:c}),a(K,{sessions:o.data??[],isLoading:o.isLoading,loadError:o.isError?o.error?.message??e(`auth.authAuditSection.requestFailed`):null,emptyText:`No active sessions.`,onRevoke:e=>void f(e),revokingId:u.isPending?u.variables?.id??null:null}),a(`div`,{className:`flex justify-end`,children:n(I,{variant:`unstyled`,onClick:()=>void p(),disabled:d.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:[d.isPending?a(m,{className:`h-3 w-3 animate-spin`}):a(N,{className:`h-3 w-3`}),e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`)]})})]})]})}l();var Le=`You`;function Re(){let{t:e}=z(),t=S(),n=R.useUtils(),r=R.auth.listOwnDeviceCredentials.useQuery(),[o,c]=s(null),l=R.auth.revokeOwnDeviceCredential.useMutation({onSuccess:e=>{e.revoked||c(`That device could not be revoked - it may already be gone.`),n.auth.listOwnDeviceCredentials.invalidate()},onError:e=>c(`Revoke failed: ${e.message}`)}),u=i(()=>(r.data??[]).map(e=>ye(e,Le)),[r.data]),d=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`})&&(c(null),l.mutate({id:n.id}))},f={label:e(`certificates.myDevicesSection.revoke2`,`Revoke`),icon:O,isAvailable:_e,onRun:e=>void d(e),busyId:l.isPending?l.variables?.id??null:null,disabled:l.isPending};return a(me,{id:`my-devices`,title:e(`certificates.myDevicesSection.myDevices`,`My devices`),icon:w,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:he(o),onDismissNotice:()=>c(null),children:a(be,{rows:u,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:f})})}var $={profile:`profile`,signIn:`sign-in`,sessions:`sessions`,tokens:`tokens`},ze=[`linked`,`linkError`],Be={view:{icon:D,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:k,cls:`bg-primary/15 text-primary`},delete:{icon:x,cls:`bg-danger/15 text-danger`}};function Ve(){let{t:e}=z(),{user:t,logout:r}=V(),[i]=W(),o=e(`system.myAccess`,`My access`);if(!t)return a(pe,{icon:p,title:o,children:a(`div`,{className:`text-xs text-foreground-subtle`,children:e(`systemPage.myAccess.notSignedIn`,`Not signed in.`)})});if(i.get(`tab`)===`preferences`)return a(H,{to:`/system/settings`,replace:!0});if(ze.some(e=>i.has(e))&&!i.has(`tab`)){let e=new URLSearchParams(i);return e.set(`tab`,$.signIn),a(H,{to:`?${e.toString()}`,replace:!0})}return a(fe,{icon:p,title:o,subtitle:e(`systemPage.myAccess.subtitle`,`Your account, how you sign in, where you are signed in, and your tokens.`),sectionsLabel:e(`systemPage.myAccess.sectionsLabel`,`My access sections`),defaultSection:$.profile,actions:n(I,{variant:`outline`,onClick:r,children:[a(N,{className:`h-3 w-3`}),e(`systemPage.myAccess.signOut`,`Sign out`)]}),sections:[{id:$.profile,label:e(`systemPage.myAccess.sections.profile`,`Profile`),content:a(He,{user:t})},{id:$.signIn,label:e(`systemPage.myAccess.sections.signIn`,`Sign-in & security`),content:n(`div`,{className:`space-y-4`,children:[a(Ne,{}),a(Pe,{username:t.username}),a(Fe,{}),a(je,{})]})},{id:$.sessions,label:e(`systemPage.myAccess.sections.sessions`,`Sessions & devices`),content:n(`div`,{className:`space-y-4`,children:[a(Ie,{}),a(Re,{}),a(Oe,{})]})},{id:$.tokens,label:e(`systemPage.myAccess.sections.tokens`,`Tokens`),content:a(ve,{ownOnly:!0})}]})}function He({user:e}){let{t}=z(),r=e.isAdmin,i=e.scopes??[];return n(`div`,{className:`space-y-4`,children:[n(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[a(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:e.username.slice(0,1).toUpperCase()}),n(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),n(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r?t(`systemPage.myAccess.administrator`,`Administrator`):t(`systemPage.myAccess.user`,`User`),` `,a(U,{i18nKey:`systemPage.myAccess.sessionId`,values:{id:e.id.slice(0,8)},components:{mono:a(`span`,{className:`font-mono`})}})]})]})]}),r&&n(`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:[a(v,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),n(`div`,{children:[a(`div`,{className:`font-semibold text-foreground`,children:t(`systemPage.myAccess.unrestrictedAccess`,`Unrestricted access`)}),a(`p`,{className:`text-foreground-subtle mt-0.5`,children:t(`systemPage.myAccess.adminSessionsBypassThePer`,`Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below.`)})]})]}),i.length>0&&a(Ue,{scopes:i})]})}function Ue({scopes:e}){let{t}=z(),r=h();return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2 border-b border-border`,children:[a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.grantedScopes`,`Granted scopes`)}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:t(`systemPage.myAccess.bakedIntoYourSessionToken`,`Baked into your session token at login; sign out + back in to refresh after changes.`)})]}),n(`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:[a(`div`,{children:t(`systemPage.myAccess.type`,`Type`)}),a(`div`,{children:t(`systemPage.myAccess.target`,`Target`)}),a(`div`,{children:t(`systemPage.myAccess.access`,`Access`)})]}),a(`ul`,{className:`divide-y divide-border`,children:e.map((e,i)=>n(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[a(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),a(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?oe(e.selector,r):e.target}),a(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(r=>{let i=e.access.includes(r),{icon:o,cls:s}=Be[r];return n(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${i?s:`bg-transparent text-foreground-subtle/40 line-through`}`,title:i?t(`systemPage.myAccess.can`,`Can {{a}}`,{a:r}):t(`systemPage.myAccess.cannot`,`Cannot {{a}}`,{a:r}),children:[a(o,{className:`h-3 w-3`}),r]},r)})})]},i))})]})}export{Ve as MyAccessPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,K as t,R as n,S as r,V as i,Y as a,et 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-CEyXHAdg.js";import{Da as l,Ea as u,Ei as d,Er as f,Kt as p,St as m,Vr as h,Y as g,Yt as _,ci as v,ct as y,ei as b,gt as x,pi as S,qi as C,ut as w,ya as T}from"./player-overlays-BMit2yun.js";import{uc as E}from"./client-DLGNlJDt.js";import{t as D}from"./scissors-Bbq6WhOK.js";import{$u as O,Ci as k,Gc as A,Gn as j,Gr as M,Hi as N,Jr as P,Ju as ee,Ku as F,Lf as I,Lo as L,Nf as R,Ol as te,Pf as ne,Qu as re,Uc as ie,Ur as ae,Wi as z,Wn as B,Wr as oe,Xu as se,Yc as ce,Yr as le,Yu as ue,Zc as de,Zu as fe,_u as pe,ai as V,bu as me,cf as H,ed as he,ef as U,gu as ge,hu as _e,mu as ve,nd as ye,qr as be,qu as xe,rd as Se,td as Ce,vu as we,wl as Te,xu as Ee,yu as De}from"./src-Dg912oqK.js";import{t as W}from"./i18n-CcjpDLHK.js";import{t as G}from"./useTranslation-BJr-n0es.js";import{D as Oe,Kr as ke,x as Ae}from"./index-DgOWypvk.js";import{t as je}from"./AdminSectionedPage-D00S68ny.js";import{n as Me}from"./authed-media-DSqxjKn1.js";import{t as K}from"./format-size-DIxKXxtj.js";import{n as Ne,r as Pe,t as Fe}from"./StorageLocationsTable-CEuzgMli.js";o();var Ie=[{value:`all`,labelKey:`common.all`},{value:`recording`,labelKey:`recordings.activitySection.domainRecordings`},{value:`events`,labelKey:`common.events`}],Le={recording:`bg-primary/10 text-primary`,events:`bg-violet-500/10 text-violet-400`},Re={columnKey:`at`,dir:`desc`};function ze(e){return new Date(e).toLocaleString()}function Be(){let{t:n,i18n:i}=G(),[o,s]=a(`all`),{data:l,isLoading:d,isError:m}=ge({},{refetchOnWindowFocus:!1}),{data:h,isLoading:g,isError:_}=ce({},{refetchOnWindowFocus:!1}),{data:v}=L({isCamera:!0,projection:`slim`}),y=t(()=>{let e=new Map;for(let t of v??[])e.set(t.id,t.name);return e},[v]),b=t(()=>{let e=[...l??[],...h??[]];return(o===`all`?e:e.filter(e=>e.domain===o)).toSorted((e,t)=>t.at-e.at)},[l,h,o]),x=t(()=>{let e=[];return m&&o!==`events`&&e.push(n(`recordings.activitySection.domainRecordings`)),_&&o!==`recording`&&e.push(n(`common.events`)),e},[m,_,o,n]),S=t(()=>new Intl.ListFormat(i.language,{type:`conjunction`}).format(x),[x,i.language]),C=t(()=>[{key:`at`,header:n(`recordings.activitySection.when`,`When`),nowrap:!0,sortValue:e=>e.at,render:e=>r(`span`,{className:`text-foreground-subtle tabular-nums`,children:ze(e.at)})},{key:`domain`,header:n(`recordings.activitySection.domain`,`Domain`),sortValue:e=>e.domain,render:e=>r(`span`,{className:`inline-flex rounded px-1.5 py-0.5 text-[10px] font-medium ${Le[e.domain]}`,children:e.domain})},{key:`op`,header:n(`recordings.activitySection.operation`,`Operation`),sortValue:e=>e.op,render:e=>r(`span`,{className:`text-foreground`,children:e.op})},{key:`reason`,header:n(`recordings.activitySection.reason`,`Reason`),sortValue:e=>e.reason,render:e=>r(`span`,{className:`text-foreground-subtle`,children:e.reason})},{key:`device`,header:n(`recordings.activitySection.camera`,`Camera`),sortValue:e=>e.deviceId===null?`cluster`:y.get(e.deviceId)??`#${String(e.deviceId)}`,render:e=>e.deviceId===null?r(`span`,{className:`text-foreground-subtle`,children:n(`common.cluster`)}):r(`span`,{className:`text-foreground`,children:y.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`items`,header:n(`recordings.activitySection.items`,`Items`),align:`right`,nowrap:!0,sortValue:e=>e.itemsAffected,render:e=>r(`span`,{className:`tabular-nums`,children:e.itemsAffected.toLocaleString()})},{key:`bytes`,header:n(`recordings.activitySection.reclaimed`,`Reclaimed`),align:`right`,nowrap:!0,sortValue:e=>e.bytesReclaimed,render:e=>r(`span`,{className:`tabular-nums`,children:e.bytesReclaimed>0?K(e.bytesReclaimed):`—`})}],[y,n]),w=d||g;return e(`div`,{className:`flex flex-col gap-4`,children:[r(`div`,{className:`flex items-center gap-1`,children:Ie.map(e=>r(U,{variant:`unstyled`,onClick:()=>s(e.value),className:`rounded px-2 py-1 text-xs font-medium ${o===e.value?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-muted`}`,children:n(e.labelKey)},e.value))}),w&&b.length===0?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(f,{className:`h-4 w-4 animate-spin`}),n(`recordings.activitySection.loadingActivity`,`Loading activity…`)]}):b.length===0?x.length>0?r(V,{icon:p,title:n(`recordings.activitySection.activityCouldNotBeRead`,`Activity could not be read`),description:n(`recordings.activitySection.theOpsLogDidNot`,`The {{value1}} ops log did not answer. This is not "nothing happened" — retry, or check the node that owns it.`,{value1:S})}):r(V,{icon:u,title:n(`recordings.activitySection.noActivityYet`,`No activity yet`),description:n(`recordings.activitySection.pruneDeleteAndRescanOperations`,`Prune, delete and rescan operations across recordings and events show up here.`)}):e(c,{children:[x.length>0&&e(`p`,{className:`flex items-center gap-1.5 text-[11px] text-amber-500`,children:[r(p,{className:`h-3 w-3 shrink-0`}),n(`recordings.activitySection.domainsMissing`,{count:x.length,names:S})]}),r(B,{columns:C,rows:b,rowKey:e=>e.id,minWidthPx:720,maxBodyHeight:j,defaultSort:Re})]})]})}o();function Ve(){let{t:n}=G(),i=L({isCamera:!0,projection:`slim`}),o=t(()=>(i.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[i.data]),[s,c]=a(null),l=s??o[0]?.id??null;return!i.isLoading&&o.length===0?r(V,{icon:C,title:n(`recordings.cameraRecordingSettingsSection.noCameras`,`No cameras`),description:n(`recordings.cameraRecordingSettingsSection.addACameraFirst`,`Add a camera first.`)}):e(`div`,{className:`space-y-3`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:n(`recordings.cameraRecordingSettingsSection.perCameraRecordingRetention`,`Per-camera recording & retention`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`recordings.cameraRecordingSettingsSection.recordingModeScheduleBandsAnd`,`Recording mode, schedule bands and the retention policy for one camera — the same controls as the camera's own Recording tab. Retention is one policy over footage and analytics; per-camera event deletion lives on the Events tab.`)})]}),e(`div`,{className:`flex items-center gap-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:n(`recordings.cameraRecordingSettingsSection.camera`,`Camera`)}),r(w,{wrapperClassName:`inline-block w-auto`,value:l??``,onChange:e=>c(Number(e.target.value)),children:o.map(e=>r(`option`,{value:e.id,children:e.name},e.id))})]}),l!==null&&r(k,{deviceId:l,children:r(Oe,{deviceId:l,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},l)]})}function q({types:e}){return r(Fe,{kinds:e})}o();var He=`pipeline-analytics`,Ue=`pipeline-analytics`;function We(e){for(let t of e?.sections??[])for(let e of t.fields??[])if(e.key===`postProcessingNodeId`&&typeof e.value==`string`)return e.value;return`hub`}function Ge(){let{t:n}=G(),i=s(),{nodes:a}=ne(),{data:o,isLoading:c}=N({addonId:He,cap:Ue,scope:`cluster`}),l=We(o),u=z({onSuccess:()=>{i.invalidateQueries({queryKey:[[`addonSettings`,`getScopedSettings`]]})}}),d=t(()=>{let e=a.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,l,...e])].filter(Boolean)},[a,l]);return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`pipeline.clusterEventsTab.postProcessingNode`,`Post-processing node`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterEventsTab.theSingleNodeThatRuns`,`The single node that runs detection post-processing (events, media, audio & motion). Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`)}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[c?r(f,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r(w,{wrapperClassName:`inline-block w-auto`,value:l,onChange:e=>{e.target.value!==l&&u.mutate({addonId:He,cap:Ue,scope:`cluster`,patch:{postProcessingNodeId:e.target.value}})},disabled:u.isPending,children:d.map(e=>r(`option`,{value:e,children:e===`hub`?n(`pipeline.clusterEventsTab.hubDefault`,`hub (default)`):e},e))}),u.isPending&&r(f,{className:`h-4 w-4 animate-spin text-primary`})]})]}),e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:n(`pipeline.clusterEventsTab.eventsFolder`,`Events folder`)}),r(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterEventsTab.whereEventCropsFullFrames`,`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`)}),r(q,{types:[`eventMedia`]})]})]})}o();var Ke=[[`pipelineAnalytics`]],qe=1440*60*1e3;function Je(e,t){return t.get(e)??W.t(`recordings.eventsManagementSection.removedCamera`,{id:String(e)})}var Ye=[{days:1},{days:7},{days:30},{days:90}];function Xe(){let{t:i}=G(),o=s(),c=y(),[l,u]=a(30),[d,p]=a(null),{data:m,isLoading:h}=A({},{refetchOnWindowFocus:!1}),{data:v}=L({isCamera:!0,projection:`slim`}),b=t(()=>{let e=new Map;for(let t of v??[])e.set(t.id,t.name);return e},[v]),x=n(()=>{o.invalidateQueries({queryKey:Ke})},[o]),C=de({onSuccess:x}),T=ie(),E=n(async()=>{await c({title:i(`recordings.eventsManagementSection.pruneTitle`,{count:l}),message:i(`recordings.eventsManagementSection.permanentlyDeletesEveryEventMotion`,`Permanently deletes every event (motion / object / audio) older than the cutoff across all cameras, and their media. This cannot be undone.`),confirmLabel:i(`recordings.eventsManagementSection.pruneEvents`,`Prune events`),variant:`danger`})&&C.mutate({olderThanMs:Date.now()-l*qe,reason:`retention`})},[c,C,l,i]),O=n(async e=>{let t=Je(e.deviceId,b);if(await c({title:i(`recordings.eventsManagementSection.deleteAllEventsFor`,`Delete all events for {{label}}?`,{label:t}),message:i(`recordings.eventsManagementSection.deleteRowsMessage`,{count:e.rows,size:K(e.bytes)}),confirmLabel:i(`recordings.eventsManagementSection.deleteEvents`,`Delete events`),variant:`danger`})){p(null);try{let n=await T.mutateAsync({deviceId:e.deviceId});x();let r=n.motion+n.object+n.audio;if(r===0&&e.bytes>0){p(`0 events deleted for ${t}. Media still listed (${K(e.bytes)}) — those blobs are not event rows; use Management → Count leftovers or Disk reconcile.`);return}p(`Deleted ${String(r)} event${r===1?``:`s`} for ${t}.`)}catch(e){p(e instanceof Error?e.message:String(e))}}},[c,T,b,x,i]),k=t(()=>[{key:`camera`,header:i(`recordings.eventsManagementSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:Je(e.deviceId,b)})},{key:`rows`,header:i(`recordings.eventsManagementSection.events`,`Events`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:e.rows.toLocaleString()})},{key:`bytes`,header:i(`recordings.eventsManagementSection.media`,`Media`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:K(e.bytes)})},{key:`actions`,header:``,align:`right`,render:t=>e(U,{variant:`unstyled`,onClick:()=>{O(t)},disabled:T.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i(`recordings.eventsManagementSection.deleteAllEventsForThis`,`Delete all events for this camera`),children:[r(_,{className:`h-3 w-3`}),i(`common.delete`,`Delete`)]})}],[b,O,T.isPending,i]);return h&&!m?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(f,{className:`h-4 w-4 animate-spin`}),i(`recordings.eventsManagementSection.loadingEventStoreFootprint`,`Loading event-store footprint…`)]}):m?e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[r(g,{label:i(`recordings.eventsManagementSection.totalEvents`,`Total events`),icon:r(S,{className:`h-3 w-3`}),footer:`across ${String(m.devices.length)} camera${m.devices.length===1?``:`s`}`,children:m.totalRows.toLocaleString()}),r(g,{label:i(`recordings.eventsManagementSection.eventMediaOnDisk`,`Event media on disk`),children:K(m.totalBytes)})]}),e(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[r(`span`,{className:`text-foreground-subtle`,children:i(`recordings.eventsManagementSection.pruneEventsOlderThan`,`Prune events older than`)}),r(w,{wrapperClassName:`inline-block w-auto`,value:l,onChange:e=>u(Number(e.target.value)),children:Ye.map(e=>r(`option`,{value:e.days,children:i(`recordings.eventsManagementSection.ageDays`,{count:e.days})},e.days))}),e(U,{variant:`unstyled`,onClick:()=>{E()},disabled:C.isPending,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs font-medium text-foreground-subtle hover:bg-warning/10 hover:text-warning disabled:opacity-50`,children:[C.isPending?r(f,{className:`h-3 w-3 animate-spin`}):r(D,{className:`h-3 w-3`}),i(`recordings.eventsManagementSection.pruneNow`,`Prune now`)]})]}),m.devices.length===0?r(V,{icon:S,title:i(`recordings.eventsManagementSection.noStoredEvents`,`No stored events`),description:i(`recordings.eventsManagementSection.noCameraHasPersistedEvents`,`No camera has persisted events yet.`)}):r(B,{columns:k,rows:[...m.devices],rowKey:e=>e.deviceId,minWidthPx:480}),d===null?null:r(`p`,{className:d.startsWith(`Deleted `)?`text-[11px] text-foreground-subtle`:`text-[11px] text-destructive`,children:d})]}):r(V,{icon:S,title:i(`recordings.eventsManagementSection.noEventData`,`No event data`),description:i(`recordings.eventsManagementSection.pipelineAnalyticsHasNotReported`,`Pipeline analytics has not reported any event-store footprint yet.`)})}function Ze(){let{t}=G();return e(`div`,{className:`flex flex-col gap-8`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.eventsSection.eventStore`,`Event store`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.eventsSection.whatTheDurableEventStore`,`What the durable event store occupies, per camera, with fleet-wide prune-by-age and delete-all-events.`)}),r(`div`,{className:`mt-3`,children:r(Xe,{})})]}),e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.eventsSection.postProcessingNodeFolders`,`Post-processing node & folders`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.eventsSection.theSingleNodeThatWrites`,`The single node that writes event crops, and the storage location they land in.`)}),r(`div`,{className:`mt-3`,children:r(Ge,{})})]})]})}function Qe(e){let t=[];return e.timelapse?t.push(`timelapse ${String(e.timelapse.everyMs/1e3)}s`):(t.push(`${String(e.speed??1)}×`),e.includeAudio&&t.push(`+ audio`)),t.join(` `)}function $e(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function et(e,t){let n=Math.max(0,Math.round((t-e)/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60,o=r>0?`${String(r)}:${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`:`${String(i)}:${String(a).padStart(2,`0`)}`;return`${$e(e)} · ${o}`}function tt(e,t){let n=e-t;if(n<=0)return W.t(`helpers.exportFormat.expired`);let r=Math.floor(n/6e4);if(r<60)return W.t(`helpers.exportFormat.inMinutes`,{n:String(r)});let i=Math.floor(r/60);return i<24?W.t(`helpers.exportFormat.inHours`,{n:String(i)}):W.t(`helpers.exportFormat.inDays`,{n:String(Math.floor(i/24))})}function nt(e,t,n,r){return e.map(e=>{if(e.state===`expired`||e.state===`deleted`)return e;let i=r.get(e.id);if(i)return{...e,state:`failed`,error:i.error,progressPct:null};let a=n.get(e.id);if(a)return{...e,state:`ready`,fileBytes:a.fileBytes,progressPct:100};let o=t.get(e.id);return o&&(e.state===`queued`||e.state===`rendering`)?{...e,state:`rendering`,progressPct:o.progressPct}:e})}o();var rt=[`high`,`mid`,`low`],it=[{value:1,labelKey:`recordings.newExportModal.speedRealTime`},{value:2,labelKey:null},{value:4,labelKey:null},{value:8,labelKey:null},{value:16,labelKey:null}],at=10080*60*1e3;function ot(e){let t=new Date(Date.now()-e*6e4),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function st({onClose:n,onCreated:i}){let{t:o}=G(),s=L({isCamera:!0,projection:`slim`}),c=t(()=>(s.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[s.data]),[u,d]=a(``),[f,p]=a(`high`),[m,h]=a(ot(60)),[g,_]=a(ot(0)),[v,y]=a(1),[x,S]=a(!0),[C,T]=a(``),[E,D]=a(null),O=u===``?c[0]?.id??null:u,k=new Date(m).getTime(),A=new Date(g).getTime(),j=Number.isFinite(k)&&Number.isFinite(A)&&k<A,N=De({onSuccess:()=>{i(),n()},onError:e=>D(e instanceof Error?e.message:String(e))});return r(ae,{open:!0,onOpenChange:e=>!e&&n(),children:e(M,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(P,{children:e(le,{className:`flex items-center gap-1.5`,children:[r(b,{className:`h-3.5 w-3.5`}),o(`recordings.newExportModal.newExport`,`New export`)]})}),e(oe,{className:`space-y-3`,children:[e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.camera`,`Camera`)}),r(w,{value:O??``,onChange:e=>d(Number(e.target.value)),className:`w-full`,children:c.map(e=>r(`option`,{value:e.id,children:e.name},e.id))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.profile`,`Profile`)}),r(w,{value:f,onChange:e=>p(e.target.value),className:`w-full`,children:rt.map(e=>r(`option`,{value:e,children:e},e))})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.from`,`From`)}),r(H,{type:`datetime-local`,value:m,onChange:e=>h(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.to`,`To`)}),r(H,{type:`datetime-local`,value:g,onChange:e=>_(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.speed`,`Speed`)}),r(w,{value:v,onChange:e=>y(Number(e.target.value)),className:`w-full`,children:it.map(e=>r(`option`,{value:e.value,children:e.labelKey===null?`${e.value}×`:o(e.labelKey)},e.value))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.titleOptional`,`Title (optional)`)}),r(H,{type:`text`,value:C,onChange:e=>T(e.target.value),placeholder:o(`recordings.newExportModal.eGCourierAtThe`,`e.g. courier at the gate`),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle`})]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[r(l,{checked:x,disabled:v!==1,onChange:e=>S(e.target.checked),className:`accent-primary`}),o(v===1?`recordings.newExportModal.includeAudio`:`recordings.newExportModal.includeAudioRealtimeOnly`)]}),!j&&r(`p`,{className:`text-[11px] text-danger`,children:o(`recordings.newExportModal.fromMustBeBeforeTo`,`"From" must be before "To".`)}),E&&r(`p`,{className:`text-[11px] text-danger`,children:E})]}),e(be,{children:[r(U,{variant:`outline`,size:`sm`,onClick:n,children:o(`common.cancel`,`Cancel`)}),r(U,{size:`sm`,onClick:()=>{if(O===null||!j)return;D(null);let e=C.trim();N.mutate({deviceId:O,profile:f,fromMs:k,toMs:A,options:{includeAudio:x,maxLifeMs:at,deleteAfterDownload:!1,...v===1?{}:{speed:v},...e.length>0?{title:e}:{}}})},disabled:O===null||!j||N.isPending,children:N.isPending?o(`recordings.newExportModal.queuing`,`Queuing…`):o(`recordings.newExportModal.createExport`,`Create export`)})]})]})})}o();var ct=[[`recordingExport`]],lt={queued:{cls:`bg-muted text-foreground-subtle`,labelKey:`recordings.exportsSection.queued`},rendering:{cls:`bg-primary/10 text-primary`,labelKey:`recordings.exportsSection.rendering`,spin:!0},ready:{cls:`bg-success/10 text-success`,labelKey:`recordings.exportsSection.ready`},failed:{cls:`bg-danger/10 text-danger`,labelKey:`recordings.exportsSection.failed`},expired:{cls:`bg-muted text-foreground-subtle`,labelKey:`recordings.exportsSection.expired`},deleted:{cls:`bg-muted text-foreground-subtle`,labelKey:`recordings.exportsSection.deleted`}};function ut(){let{data:e,isLoading:n}=Ee({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:r}=I(E.RecordingExportProgress,e=>e.exportId),{map:i}=I(E.RecordingExportCompleted,e=>e.exportId),{map:a}=I(E.RecordingExportFailed,e=>e.exportId);return{rows:t(()=>nt(e??[],r,i,a),[e,r,i,a]),isLoading:n}}function dt(e){let[t,n]=a(()=>Date.now());return i(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function ft(){let{t:i}=G(),o=s(),[c,l]=a(!1),u=()=>{o.invalidateQueries({queryKey:[[`recordingExport`,`listExports`]]})},p=y(),m=x().trpcClient,h=dt(6e4),{rows:g,isLoading:S}=ut(),{data:C}=L({isCamera:!0,projection:`slim`}),w=t(()=>{let e=new Map;for(let t of C??[])e.set(t.id,t.name);return e},[C]),T=n(()=>{o.invalidateQueries({queryKey:ct})},[o]),E=we({onSuccess:T}),D=me({onSuccess:T}),[O,k]=a(null),A=n(async e=>{k(e.id);try{let{url:t}=await m.recordingExport.getDownloadUrl.query({exportId:e.id}),n=await Me(t),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.options.title??e.id}.mp4`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r),T()}finally{k(null)}},[m,T]),j=n(async e=>{await p({title:i(`recordings.exportsSection.cancelThisExport`,`Cancel this export?`),message:i(`recordings.exportsSection.stopsTheRenderThePartial`,`Stops the render. The partial file is discarded.`),confirmLabel:i(`recordings.exportsSection.cancelExport`,`Cancel export`),variant:`danger`})&&E.mutate({exportId:e.id})},[p,E,i]),M=n(async e=>{await p({title:i(`recordings.exportsSection.deleteThisExport`,`Delete this export?`),message:i(`recordings.exportsSection.permanentlyRemovesTheRenderedFile`,`Permanently removes the rendered file and its history row.`),confirmLabel:i(`common.delete`,`Delete`),variant:`danger`})&&D.mutate({exportId:e.id})},[p,D,i]),N=t(()=>[{key:`camera`,header:i(`recordings.exportsSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:w.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:i(`recordings.exportsSection.range`,`Range`),nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:et(e.fromMs,e.toMs)})},{key:`variant`,header:i(`recordings.exportsSection.variant`,`Variant`),render:e=>r(`span`,{className:`text-foreground-subtle`,children:Qe(e.options)})},{key:`state`,header:i(`recordings.exportsSection.state`,`State`),render:t=>{let n=lt[t.state];return e(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${n.cls}`,children:[n.spin&&r(f,{className:`h-2.5 w-2.5 animate-spin`}),i(n.labelKey),t.state===`rendering`&&t.progressPct!==null&&e(`span`,{className:`tabular-nums`,children:[t.progressPct,`%`]})]})}},{key:`expiry`,header:i(`recordings.exportsSection.expires`,`Expires`),nowrap:!0,render:e=>e.state===`deleted`?r(`span`,{className:`text-foreground-subtle`,children:`—`}):r(`span`,{className:`text-foreground-subtle tabular-nums`,children:tt(e.expiresAt,h)})},{key:`size`,header:i(`recordings.exportsSection.size`,`Size`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:e.fileBytes===null?`—`:K(e.fileBytes)})},{key:`actions`,header:``,align:`right`,render:t=>{let n=t.state===`ready`,a=t.state===`queued`||t.state===`rendering`,o=t.state!==`deleted`;return e(`div`,{className:`flex items-center justify-end gap-1`,children:[n&&e(U,{variant:`unstyled`,onClick:()=>{A(t)},disabled:O===t.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-primary/10 hover:text-foreground disabled:opacity-50`,title:i(`recordings.exportsSection.downloadMp4`,`Download MP4`),children:[O===t.id?r(f,{className:`h-3 w-3 animate-spin`}):r(v,{className:`h-3 w-3`}),i(`recordings.exportsSection.download`,`Download`)]}),a&&e(U,{variant:`unstyled`,onClick:()=>{j(t)},disabled:E.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:i(`recordings.exportsSection.cancelRender`,`Cancel render`),children:[r(d,{className:`h-3 w-3`}),i(`common.cancel`,`Cancel`)]}),o&&r(U,{variant:`unstyled`,onClick:()=>{M(t)},disabled:D.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i(`recordings.exportsSection.deleteExport`,`Delete export`),children:r(_,{className:`h-3 w-3`})})]})}}],[w,h,O,E.isPending,D.isPending,A,j,M,i]);return S&&g.length===0?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(f,{className:`h-4 w-4 animate-spin`}),i(`recordings.exportsSection.loadingExports`,`Loading exports…`)]}):e(`div`,{className:`space-y-3`,children:[r(`div`,{className:`flex justify-end`,children:e(U,{variant:`unstyled`,onClick:()=>l(!0),className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground`,children:[r(b,{className:`h-3.5 w-3.5`}),i(`recordings.exportsSection.newExport`,`New export`)]})}),g.length===0?r(V,{icon:b,title:i(`recordings.exportsSection.noExportsYet`,`No exports yet`),description:i(`recordings.exportsSection.createOneHereNewExport`,`Create one here (New export) or from a camera's timeline in the viewer. Rendered clips show up here to download or manage.`)}):r(B,{columns:N,rows:g,rowKey:e=>e.id,minWidthPx:720}),c&&r(st,{onClose:()=>l(!1),onCreated:u})]})}var pt=`inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`;o();var mt=`storage-migration`,ht=new Set([`orphans`,`debug-media`,`ghost-ledger`]);function gt(e){return[`${e.orphansReclaimed} orphan rows (${K(e.orphanBytesReclaimed)})`,e.includeDebugMedia?`${e.debugMediaReclaimed} debug files (${K(e.debugMediaBytesReclaimed)})`:null,`${e.ghostsForgotten} ghost rows (${K(e.ghostBytesForgotten)})`].filter(e=>e!==null).join(` · `)}function _t(){let{t:e}=G(),t=R(mt);return t===`pending`?null:t===`unknown`?r(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:e(`recordings.cleanupSection.couldNotCheckWhetherStorage`,`Could not check whether storage cleanup is installed on this hub.`)}):t===`present`?r(vt,{}):null}function vt(){let{t}=G(),n=y(),[i,o]=a(!1),[s,c]=a(null),u=se({},{refetchInterval:2e3}),d=u.data??null,p=d!==null&&ht.has(d.phase),m=ue(),h=ee(),g=async()=>{if(await n({title:t(`recordings.cleanupSection.runStorageCleanup`,`Run storage cleanup?`),message:i?t(`recordings.cleanupSection.reclaimsLeftoverAnalyticsRowsAnd`,`Reclaims leftover analytics rows and files, debug stills/filmstrips, and ghost footage rows on frozen locations. Safe to re-run.`):t(`recordings.cleanupSection.reclaimsLeftoverAnalyticsRowsAnd2`,`Reclaims leftover analytics rows and files, and ghost footage rows on frozen locations. Debug stills are left alone. Safe to re-run.`),confirmLabel:t(`recordings.cleanupSection.runCleanup`,`Run cleanup`),variant:`danger`})){c(null);try{await m.mutateAsync({includeDebugMedia:i}),await u.refetch()}catch(e){c(e instanceof Error?e.message:String(e))}}},v=async()=>{if(d&&await n({title:t(`recordings.cleanupSection.cancelCleanup`,`Cancel cleanup?`),message:t(`recordings.cleanupSection.stopsAfterTheCurrentStep`,`Stops after the current step. Work already done stays done.`),confirmLabel:t(`recordings.cleanupSection.cancelCleanup2`,`Cancel cleanup`),variant:`danger`}))try{await h.mutateAsync({jobId:d.jobId}),await u.refetch()}catch{}};return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.cleanupSection.cleanup`,`Cleanup`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.cleanupSection.onePassOverLeftoverAnalytics`,`One pass over leftover analytics (database + files) and ghost footage rows on frozen locations. Does not time out — progress updates here until it finishes.`)}),e(`label`,{className:`mt-3 flex items-start gap-2 text-[11px] text-foreground`,children:[r(l,{checked:i,disabled:p,onChange:e=>{o(e.target.checked)},className:`mt-0.5 h-3.5 w-3.5 accent-primary`}),r(`span`,{children:t(`recordings.cleanupSection.alsoRemoveDebugMediaMotion`,`Also remove debug media (motion stills and track filmstrips)`)})]}),e(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[e(U,{variant:`unstyled`,type:`button`,disabled:p||m.isPending,onClick:()=>{g()},className:pt,children:[(p||m.isPending)&&r(f,{className:`h-3 w-3 animate-spin`}),r(_,{className:`h-3 w-3`}),t(`recordings.cleanupSection.runCleanup`,`Run cleanup`)]}),p&&r(U,{variant:`unstyled`,type:`button`,onClick:()=>{v()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:t(`common.cancel`,`Cancel`)})]}),s&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:s}),d&&e(`div`,{className:`mt-3 space-y-1 rounded-md border border-border px-2.5 py-2`,children:[e(`p`,{className:`text-xs text-foreground`,children:[t(`recordings.cleanupSection.phase`,`Phase:`),` `,r(`span`,{className:`font-medium`,children:d.phase}),p&&r(f,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),d.detail&&r(`p`,{className:`text-[11px] text-foreground-subtle`,children:d.detail}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:gt(d)}),d.error&&r(`p`,{className:`text-[11px] text-danger`,children:d.error})]})]})}o();var yt=2e3;function bt(){let{t}=G(),n=y(),a=s(),o=te(),c=Te(void 0,{refetchInterval:e=>e.state.data?.state===`running`?yt:!1}),l=c.data,u=l?.state===`running`,d=u||o.isPending;i(()=>{l?.state!==`done`||l.finishedAtMs===null||(a.invalidateQueries({queryKey:[[`recording`]]}),a.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[l?.state,l?.finishedAtMs,a]);let p=async()=>{await n({title:t(`recordings.diskReconcileSection.reconcileStorageFromDisk`,`Reconcile storage from disk?`),message:t(`recordings.diskReconcileSection.makesTheDatabaseMatchThe`,`Makes the database match the filesystem: recordings index, tracks, events and media whose files are gone. Favourited tracks without files are deleted. Snapshot-less motion/audio events are deleted. Enrolled identities stay. This cannot be undone.`),confirmLabel:t(`recordings.diskReconcileSection.reconcile`,`Reconcile`),variant:`warning`})&&(await o.mutateAsync(),await c.refetch())},m=u?l.total>0?`Reconciling ${String(l.completed)}/${String(l.total)}…`:`Reconciling…`:o.isPending?`Reconciling…`:`Reconcile from disk`;return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.diskReconcileSection.diskReconcile`,`Disk reconcile`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.diskReconcileSection.deletesDatabaseRowsWhoseFiles`,`Deletes database rows whose files are gone. Enrolled identities stay.`)}),e(`div`,{className:`mt-3 flex flex-col gap-2`,children:[e(U,{variant:`unstyled`,type:`button`,onClick:()=>void p(),disabled:d,className:`inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[d?r(f,{className:`h-3.5 w-3.5 animate-spin`}):r(h,{className:`h-3.5 w-3.5`}),m]}),l?.state===`done`?e(`p`,{className:`text-[11px] text-foreground-subtle`,children:[t(`recordings.diskReconcileSection.lastRun`,`Last run:`),` `,t(`recordings.diskReconcileSection.summary`,{completed:String(l.completed),tracks:String(l.tracks),events:String(l.events),media:String(l.mediaDropped)}),l.failed.length>0?t(`recordings.diskReconcileSection.failed`,`, {{value1}} failed ({{value2}})`,{value1:String(l.failed.length),value2:l.failed.join(`, `)}):``,`.`]}):null,l?.state===`error`&&l.error!==null?e(`p`,{className:`text-[11px] text-destructive`,children:[t(`recordings.diskReconcileSection.reconcileFailed`,`Reconcile failed:`),` `,l.error]}):null]})]})}var J=1e3,Y=60*J,X=60*Y;function Z(e){return e.toLocaleString(`en-US`)}function xt(e){if(!Number.isFinite(e)||e<0)return`—`;if(e>=X){let t=Math.floor(e/X),n=Math.round(e%X/Y);return`${t.toString()}h ${n.toString()}m`}if(e>=Y){let t=Math.floor(e/Y),n=Math.round(e%Y/J);return`${t.toString()}m ${n.toString()}s`}return`${Math.max(0,Math.round(e/J)).toString()}s`}function St(e){let t=Math.max(0,e.observedAt-e.startedAt),n=e.filesTotal===null?`${Z(e.filesMoved)} files`:`${Z(e.filesMoved)} / ${Z(e.filesTotal)} files`,r=e.filesTotal===null||e.filesTotal===0?null:Math.min(1,e.filesMoved/e.filesTotal),i=t>0&&e.filesMoved>0,a=i?`${K(e.bytesMoved/t*J)}/s`:null,o=e.filesTotal===null?null:e.filesTotal-e.filesMoved,s=!i||o===null||o<=0?null:`~${xt(o*t/e.filesMoved)} left`;return{counted:n,fraction:r,moved:`${K(e.bytesMoved)} moved`,rate:a,eta:s}}function Ct(e){let t=St(e);return[t.counted,t.moved,t.rate,t.eta].filter(e=>e!==null).join(` · `)}o();var wt=`storage-migration`,Q=[{id:`recordings`,labelKey:`recordings.storageMigrationSection.classRecordings`,locationType:`recordings`},{id:`recordingsLow`,labelKey:`recordings.storageMigrationSection.classRecordingsLow`,locationType:`recordingsLow`},{id:`eventMedia`,labelKey:`recordings.storageMigrationSection.classEventMedia`,locationType:`eventMedia`}],Tt=new Set([`planning`,`sealing`,`pausing`,`moving`,`draining`,`verifying`,`repointing`,`refreshing`,`resuming`]);function Et(){let{t}=G(),n=R(wt);return n===`pending`?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(f,{className:`h-4 w-4 animate-spin`}),t(`migration.storageMigrationSection.checkingWhetherStorageMigrationIs`,`Checking whether storage migration is installed…`)]}):n===`unknown`?r(V,{icon:p,title:t(`migration.storageMigrationSection.couldnTCheckWhetherStorage`,`Couldn't check whether storage migration is installed`),description:t(`migration.storageMigrationSection.theCapabilityRegistryDidNot`,`The capability registry did not answer, so this panel has nothing to report either way — it is not a statement that the capability is missing. Reload to ask again.`)}):n===`absent`?r(V,{icon:T,title:t(`migration.storageMigrationSection.storageMigrationNotInstalled`,`Storage migration not installed`),description:t(`migration.storageMigrationSection.theCapabilityRegistryAnsweredNo`,`The capability registry answered: no addon in this cluster provides storage-migration. Once one is deployed, this panel moves recordings, low-res recordings and event media to new storage locations in one coordinated, verified operation.`)}):r(Dt,{})}function Dt(){let{t:n}=G(),i=y(),{data:o}=F({}),[s,c]=a({}),[l,u]=a({}),[d,p]=a(null),[h,g]=a(null),_=t(()=>{let e=new Map;for(let t of o??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[o]),v=t(()=>{let e=new Map;for(let t of o??[]){if(t.enabled===!1)continue;let n=e.get(t.type);n?n.push(t.id):e.set(t.type,[t.id])}let t=new Map;for(let[n,r]of e)r.length===1&&t.set(n,r[0]);return t},[o]),b=Se({},{refetchInterval:2e3}),x=b.data??null,S=x!==null&&Tt.has(x.phase),C=t(()=>{let e={};for(let t of Q){let n=s[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s]),E=t(()=>{let e={};for(let t of Q){if(!s[t.id])continue;let n=l[t.id]??v.get(t.locationType);n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s,l,v]),D=t(()=>({destinations:C??{},...E?{sources:E}:{}}),[C,E]),O=he(D,{enabled:!1,retry:!1}),k=ye(),A=xe(),j=async()=>{if(!C)return;g(null);let e=await O.refetch();if(e.error){g(e.error instanceof Error?e.error.message:String(e.error));return}p(e.data??null)},M=async()=>{if(C&&await i({title:n(`migration.storageMigrationSection.startStorageMigration`,`Start storage migration?`),message:n(`migration.storageMigrationSection.copiesTheSelectedClassesFrom`,`Copies the selected classes from the chosen source to the destination, verifies, then either makes the destination the default (if the source was) or disables the source. Safe to re-run if interrupted.`),confirmLabel:n(`migration.storageMigrationSection.startMigration`,`Start migration`),variant:`danger`})){g(null);try{await k.mutateAsync(D),p(null),await b.refetch()}catch(e){g(e instanceof Error?e.message:String(e))}}},N=async()=>{if(x&&await i({title:n(`migration.storageMigrationSection.cancelMigration`,`Cancel migration?`),message:n(`migration.storageMigrationSection.stopsTheInProgressMigration`,`Stops the in-progress migration. Data already moved and verified stays at the destination; anything already repointed is not reverted.`),confirmLabel:n(`migration.storageMigrationSection.cancelMigration2`,`Cancel migration`),variant:`danger`}))try{await A.mutateAsync({jobId:x.jobId}),await b.refetch()}catch{}};return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[e(`h3`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[r(T,{className:`h-3.5 w-3.5`}),n(`migration.storageMigrationSection.storageMigration`,`Storage migration`)]}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.moveRecordingsLowResRecordings`,`Move recordings, low-res recordings and/or event media from one location to another: copies via the recorder / pipeline-analytics movers, verifies, then either repoints the default (when the source was the default) or disables the source (when it was not). Skip a class with an empty destination.`)}),r(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-3`,children:Q.map(t=>{let i=_.get(t.locationType)??[],a=v.get(t.locationType)??``;return e(`div`,{className:`space-y-2`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:n(t.labelKey)}),e(`div`,{className:`space-y-1`,children:[r(`label`,{htmlFor:`migration-from-${t.id}`,className:`text-[10px] text-foreground-subtle`,children:n(`recordings.storageMigrationSection.classFrom`,{label:n(t.labelKey)})}),r(w,{id:`migration-from-${t.id}`,value:l[t.id]??a,onChange:e=>{let n=e.target.value;u(e=>({...e,[t.id]:n}))},disabled:S,className:`w-full`,children:i.map(t=>e(`option`,{value:t.id,children:[t.displayName,t.enabled===!1?` (${n(`recordings.storageMigrationSection.readOnly`)})`:``]},t.id))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{htmlFor:`migration-dest-${t.id}`,className:`text-[10px] text-foreground-subtle`,children:n(`recordings.storageMigrationSection.classTo`,{label:n(t.labelKey)})}),e(w,{id:`migration-dest-${t.id}`,value:s[t.id]??``,onChange:e=>{let n=e.target.value;c(e=>({...e,[t.id]:n}))},disabled:S,className:`w-full`,children:[r(`option`,{value:``,children:n(`migration.storageMigrationSection.skip`,`— skip —`)}),i.map(e=>r(`option`,{value:e.id,children:e.displayName},e.id))]})]})]},t.id)})}),h&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:h}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[e(U,{variant:`unstyled`,type:`button`,onClick:()=>{j()},disabled:!C||O.isFetching||S,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[O.isFetching&&r(f,{className:`h-3 w-3 animate-spin`}),n(`migration.storageMigrationSection.plan`,`Plan`)]}),e(U,{variant:`unstyled`,type:`button`,onClick:()=>{M()},disabled:!C||k.isPending||S,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:[k.isPending&&r(f,{className:`h-3 w-3 animate-spin`}),n(`migration.storageMigrationSection.startMigration`,`Start migration`)]})]}),d&&r(`div`,{className:`mt-3 divide-y divide-border rounded-md border border-border`,children:d.moves.length===0?r(`p`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.nothingToMoveSelectedDestinations`,`Nothing to move — selected destinations match the current defaults.`)}):d.moves.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground`,children:[t.storageClass,`: `,t.fromLocationId,` → `,t.toLocationId]},`${t.storageClass}-${t.toLocationId}`))}),x&&e(`div`,{className:`mt-4 border-t border-border pt-3`,children:[e(`div`,{className:`flex items-center justify-between`,children:[r(`h4`,{className:`text-xs font-semibold text-foreground`,children:n(`migration.storageMigrationSection.migrationStatus`,`Migration status`)}),S&&e(U,{variant:`unstyled`,type:`button`,onClick:()=>{N()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:[r(m,{className:`h-3 w-3`}),n(`common.cancel`,`Cancel`)]})]}),e(`p`,{className:`mt-1 text-xs text-foreground`,children:[n(`migration.storageMigrationSection.phase`,`Phase:`),` `,r(`span`,{className:`font-medium`,children:x.phase}),S&&r(f,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),x.error&&r(`p`,{className:`mt-1 text-[11px] text-danger`,children:x.error}),x.pausedParticipants.length>0&&e(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[n(`migration.storageMigrationSection.paused`,`Paused:`),` `,x.pausedParticipants.join(`, `)]}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:x.moves.map(e=>r(Ot,{move:e},`${e.storageClass}-${e.fromLocationId}`))})]}),r(kt,{})]}),r(At,{running:S}),r(Mt,{})]})}function Ot({move:t}){let{t:n}=G(),i=t.progress===null?null:St(t.progress);return e(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[e(`div`,{className:`flex items-center justify-between`,children:[e(`span`,{className:`text-foreground`,children:[t.storageClass,`: `,t.fromLocationId,` → `,t.toLocationId]}),e(`span`,{className:`text-foreground-subtle`,children:[t.state??n(`common.pending`),t.error?` (${t.error})`:``]})]}),t.progress!==null&&e(`div`,{className:`mt-1 space-y-1`,children:[i!==null&&i.fraction!==null&&r(`div`,{className:`h-1 w-full overflow-hidden rounded bg-border`,children:r(`div`,{className:`h-full bg-primary`,style:{width:`${(i.fraction*100).toFixed(1)}%`}})}),r(`p`,{className:`text-[10px] text-foreground-subtle`,children:Ct(t.progress)})]})]})}function kt(){let{t}=G(),{data:n}=re({});return!n||n.length===0?null:e(`div`,{className:`mt-4 border-t border-border pt-3`,children:[r(`h4`,{className:`text-xs font-semibold text-foreground`,children:t(`migration.storageMigrationSection.migrationHistory`,`Migration history`)}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:n.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:[r(`span`,{className:`font-medium text-foreground`,children:t.phase}),` · `,Object.entries(t.destinations).filter(e=>typeof e[1]==`string`).map(([e,t])=>`${e} → ${t}`).join(`, `),` · `,new Date(t.startedAt).toLocaleString()]},t.jobId))})]})}function At({running:t}){let{t:n}=G(),i=y(),o=Ce({},{staleTime:1/0,refetchOnWindowFocus:!1}),s=fe(),[c,l]=a(null),u=o.data??[];if(u.length===0)return null;let d=async e=>{if(await i({title:n(`migration.storageMigrationSection.drainRemaining`,`Drain remaining {{storageClass}}?`,{storageClass:e.storageClass}),message:`Moves what is still on ${e.fromLocationId} to ${e.toLocationId}. Nothing is paused and no default is changed — this is the second half of a migration, run on its own. It is resumable: cancelling leaves everything readable from both locations.`,confirmLabel:n(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`),variant:`danger`})){l(null);try{await s.mutateAsync({classes:[e.storageClass]}),await o.refetch()}catch(e){l(e instanceof Error?e.message:String(e))}}};return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[e(`div`,{className:`flex items-start justify-between gap-2`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`migration.storageMigrationSection.leftOnTheOldLocation`,`Left on the old location`)}),e(`div`,{className:`flex shrink-0 items-center gap-2`,children:[r(`span`,{className:`text-[10px] text-foreground-subtle`,children:o.dataUpdatedAt>0?n(`migration.storageMigrationSection.measured`,`Measured {{value1}}`,{value1:new Date(o.dataUpdatedAt).toLocaleTimeString()}):n(`migration.storageMigrationSection.measuredNever`,`Measured — never`)}),r(U,{variant:`unstyled`,type:`button`,onClick:()=>{o.refetch()},disabled:o.isFetching,className:`rounded border border-border px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`,children:o.isFetching?n(`migration.storageMigrationSection.counting`,`Counting…`):n(`common.refresh`,`Refresh`)})]})]}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.aMigrationRepointsFirstAnd`,`A migration repoints first and drains behind. If the drain was cancelled, failed, or was interrupted by a restart, the data below is still on the source — readable, but not where the defaults now point. Draining moves it; it changes no default and pauses nothing.`)}),r(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.thisCountIsTakenOn`,`This count is taken on demand: measuring it walks the whole media collection, so it is not refreshed on a timer. Press Refresh after a drain finishes.`)}),c&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:c}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:u.map(i=>e(`div`,{className:`flex items-center justify-between gap-2 px-2.5 py-1.5 text-[11px]`,children:[e(`span`,{className:`text-foreground`,children:[i.storageClass,`: `,i.fromLocationId,` → `,i.toLocationId,r(`span`,{className:`ml-2 text-foreground-subtle`,children:jt(i)})]}),r(U,{variant:`unstyled`,type:`button`,onClick:()=>{d(i)},disabled:t||s.isPending,className:`shrink-0 rounded border border-border px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`,children:n(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`)})]},`${i.storageClass}-${i.fromLocationId}`))})]})}function jt(e){if(e.items===null)return W.t(`recordings.storageMigrationSection.residueUnknown`);let t=e.items.toLocaleString(`en-US`);return e.bytes===null?W.t(`recordings.storageMigrationSection.residueRows`,{count:e.items,items:t}):W.t(`recordings.storageMigrationSection.residueSegments`,{count:e.items,items:t,size:K(e.bytes)})}function Mt(){let{t}=G(),{data:n}=O({},{refetchInterval:2e3}),i=(n??[]).filter(e=>e.migrationJobId===null&&e.job.state===`running`);return i.length===0?null:e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`migration.storageMigrationSection.moversRunningOutsideAMigration`,`Movers running outside a migration`)}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:i.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[e(`div`,{className:`text-foreground`,children:[t.lane,`: `,t.job.fromLocationId,` → `,t.job.toLocationId]}),r(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:Ct({filesMoved:t.job.filesMoved,filesTotal:t.job.filesTotal,bytesMoved:t.job.bytesMoved,startedAt:t.job.startedAt,observedAt:t.observedAt})})]},t.job.jobId))})]})}function Nt(){let{t}=G();return e(`div`,{className:`flex flex-col gap-4`,children:[r(_t,{}),r(bt,{}),e(`section`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsManagementSection.moveStorage`,`Move storage`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsManagementSection.copyRecordingsLowResRecordings`,`Copy recordings, low-res recordings or event media to a new location, verify, then repoint the default. Applies to every camera.`)}),r(`div`,{className:`mt-3`,children:r(Et,{})})]})]})}o();var Pt=`recorder`,Ft=`recording`;function It(e,t,n){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t&&typeof e.value==`string`)return e.value;return n}function Lt(){let{t:n}=G(),i=s(),{nodes:a}=ne(),{data:o,isLoading:c}=N({addonId:Pt,cap:Ft,scope:`cluster`}),l=It(o,`recordingNodeId`,`hub`),u=z({onSuccess:()=>{i.invalidateQueries({queryKey:[[`addonSettings`,`getScopedSettings`]]})}}),d=t(()=>{let e=a.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,l,...e])].filter(Boolean)},[a,l]);return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`pipeline.clusterRecordingTab.recordingNode`,`Recording node`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterRecordingTab.theSingleNodeThatRecords`,`The single node that records (continuous & events) and serves playback. Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`)}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[c?r(f,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r(w,{wrapperClassName:`inline-block w-auto`,value:l,onChange:e=>{e.target.value!==l&&u.mutate({addonId:Pt,cap:Ft,scope:`cluster`,patch:{recordingNodeId:e.target.value}})},disabled:u.isPending,children:d.map(e=>r(`option`,{value:e,children:e===`hub`?n(`pipeline.clusterRecordingTab.hubDefault`,`hub (default)`):e},e))}),u.isPending&&r(f,{className:`h-4 w-4 animate-spin text-primary`})]}),l!==`hub`&&r(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:r(ke,{i18nKey:`pipeline.clusterRecordingTab.hubOnlyNote`,values:{node:l},components:{b:r(`span`,{className:`font-medium`})}})})]}),e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:n(`pipeline.clusterRecordingTab.recordingsFolders`,`Recordings folders`)}),r(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterRecordingTab.whereRecordingsAreStoredMulti`,`Where recordings are stored. Multi-location collections — segments are split across the locations of a type. Add a location to grow capacity; mark one default per type.`)}),r(q,{types:[`recordings`,`recordingsLow`]})]})]})}function Rt(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function zt(e,t){let n=Rt(e);return n.length===0?W.t(`helpers.cameraDisk.defaultRoot`):n.map(e=>t.get(e)??e).join(` + `)}function Bt(e,t,n){if(e.length===0)return null;let r=e[0];if(e.length===1&&r!==void 0)return{label:zt(r,t),exact:!0};if(n===null)return null;let i=e.find(e=>Rt(e).includes(n));return i===void 0?null:{label:zt(i,t),exact:!1}}o();var Vt=[[`recording`]],Ht=[{value:`retention`,labelKey:`recordings.storageSection.pruneRetention`},{value:`quota`,labelKey:`recordings.storageSection.pruneQuota`},{value:`operator`,labelKey:`recordings.storageSection.pruneOperator`}],Ut={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Wt={ok:`text-foreground-subtle`,warn:`text-amber-500`,critical:`text-danger`};function $(e){return`${String(Math.round(e*100))}%`}function Gt(e){return e==null?`—`:new Date(e).toLocaleString()}function Kt(e,t){let n=e.locationIds??(e.locationId===null?[]:[e.locationId]),r=n.map(e=>t.get(e)).filter(e=>e!==void 0);return r.length>0?r.join(` + `):e.root===void 0?n.length>0?n.join(` + `):W.t(`recordings.storageSection.defaultRoot`):e.root}function qt(){let{t:i}=G(),o=s(),c=y(),[l,u]=a(`retention`),{data:d,isLoading:p}=_e({},{refetchOnWindowFocus:!1}),{data:m}=L({isCamera:!0,projection:`slim`}),{data:v}=F({}),b=t(()=>{let e=new Map;for(let t of m??[])e.set(t.id,t.name);return e},[m]),x=t(()=>{let e=new Map;for(let t of v??[])e.set(t.id,t.displayName);return e},[v]),S=t(()=>{let e=v??[];return e.find(e=>e.type===`recordings`&&e.enabled!==!1)?.id??e.find(e=>e.type===`recordings`)?.id??null},[v]),C=t(()=>d?.locations??[],[d?.locations]),T=t(()=>Bt(C,x,S),[C,x,S]),E=t(()=>Pe(C),[C]),O=n(()=>{o.invalidateQueries({queryKey:Vt})},[o]),k=pe({onSuccess:O}),A=ve({onSuccess:O}),j=n(async e=>{await c({title:i(`recordings.storageSection.prune`,`Prune {{label}}?`,{label:b.get(e.deviceId)??`#${String(e.deviceId)}`}),message:i(`recordings.storageSection.appliesTheRetentionPolicyNow`,`Applies the retention policy now (reason: {{reason}}). Footage beyond the policy is permanently deleted.`,{reason:l}),confirmLabel:i(`recordings.storageSection.pruneNow`,`Prune now`),variant:`danger`})&&k.mutate({deviceId:e.deviceId,reason:l})},[c,k,l,b,i]),M=n(async e=>{await c({title:i(`recordings.storageSection.deleteAllFootageFor`,`Delete all footage for {{label}}?`,{label:b.get(e.deviceId)??`#${String(e.deviceId)}`}),message:i(`recordings.storageSection.permanentlyDeletesOfRecordedFootage`,`Permanently deletes {{value1}} of recorded footage for this camera. This cannot be undone.`,{value1:K(e.usedBytes)}),confirmLabel:i(`recordings.storageSection.delete`,`Delete {{value1}}`,{value1:K(e.usedBytes)}),variant:`danger`})&&A.mutate({deviceId:e.deviceId})},[c,A,b,i]),N=t(()=>[{key:`camera`,header:i(`recordings.storageSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:b.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`disk`,header:i(`recordings.storageSection.disk`,`Disk`),nowrap:!0,render:()=>T===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):e(`span`,{className:T.exact?`text-foreground`:`text-foreground-subtle`,title:T.exact?i(`recordings.storageSection.theOnlyRecordingsVolumeOn`,`The only recordings volume on this node — this camera can only be here.`):i(`recordings.storageSection.theRecordingsDefaultThisNode`,`The recordings DEFAULT. This node has several recordings volumes and the per-camera placement is not reported by recording.getStorageUsage, so this is where footage lands by default rather than a per-camera fact.`),children:[T.label,!T.exact&&r(`span`,{className:`ml-1 text-foreground-subtle`,children:i(`recordings.storageSection.default`,`(default)`)})]})},{key:`used`,header:i(`recordings.storageSection.used`,`Used`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:K(e.usedBytes)})},{key:`oldest`,header:i(`recordings.storageSection.oldestFootage`,`Oldest footage`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums text-foreground-subtle`,title:i(`recordings.storageSection.theOldestSegmentTheArchive`,`The oldest segment the ARCHIVE holds for this camera — the per-camera answer to 'is retention actually holding?'.`),children:Gt(e.oldestMs)})},{key:`actions`,header:``,align:`right`,render:t=>e(`div`,{className:`flex items-center justify-end gap-1`,children:[e(U,{variant:`unstyled`,onClick:()=>{j(t)},disabled:k.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:i(`recordings.storageSection.applyRetentionPolicyNow`,`Apply retention policy now`),children:[r(D,{className:`h-3 w-3`}),i(`recordings.storageSection.prune2`,`Prune`)]}),e(U,{variant:`unstyled`,onClick:()=>{M(t)},disabled:A.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i(`recordings.storageSection.deleteAllFootage`,`Delete all footage`),children:[r(_,{className:`h-3 w-3`}),i(`common.delete`,`Delete`)]})]})}],[b,T,j,M,k.isPending,A.isPending,i]);if(p&&!d)return e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(f,{className:`h-4 w-4 animate-spin`}),i(`recordings.storageSection.loadingStorageUsage`,`Loading storage usage…`)]});if(!d)return r(V,{icon:h,title:i(`recordings.storageSection.noStorageData`,`No storage data`),description:i(`recordings.storageSection.theRecordingNodeHasNot`,`The recording node has not reported any storage usage yet.`)});let P=d.devices.length;return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[r(g,{label:i(`recordings.storageSection.totalUsed`,`Total used`),icon:r(h,{className:`h-3 w-3`}),footer:`${String(P)} camera${P===1?``:`s`} on ${d.nodeId}`,children:K(d.totalUsedBytes)}),E!==null&&E.severity!==null&&r(g,{label:i(`recordings.storageSection.freeOnRecordingsVolumes`,`Free on recordings volumes`),icon:r(h,{className:`h-3 w-3`}),footer:`across ${String(E.knownVolumes)} volume${E.knownVolumes===1?``:`s`} of ${K(E.totalBytes)}`+(E.unknownVolumes>0?` · ${String(E.unknownVolumes)} did not report capacity`:``),children:r(`span`,{className:`tabular-nums ${Wt[E.severity]}`,children:K(E.freeBytes)})}),C.map(t=>{let n=Ne(t),a=t.locationId??t.root??`default`;return r(g,{label:i(`recordings.storageSection.disk2`,`Disk: {{label}}`,{label:Kt(t,x)}),footer:n===null?`${K(t.usedBytes)} of recordings · volume capacity unknown`:`${K(n.freeBytes)} free of ${K(n.totalBytes)} · ${K(t.usedBytes)} recordings (${$(n.recordingsFraction)})`,children:n===null?r(`span`,{className:`tabular-nums`,children:K(t.usedBytes)}):e(`div`,{className:`flex items-center gap-2`,title:i(`recordings.storageSection.volumeFillEverythingOnThe`,`Volume fill — everything on the disk, not only recordings. Warn at 85%, critical at 95%.`),children:[r(`div`,{className:`h-2 flex-1 overflow-hidden rounded bg-muted`,children:r(`div`,{className:`h-full rounded ${Ut[n.severity]}`,style:{width:$(n.fraction)}})}),r(`span`,{className:`tabular-nums text-xs ${Wt[n.severity]}`,children:$(n.fraction)})]})},a)})]}),e(`section`,{className:`flex items-center gap-2 text-xs`,children:[r(`label`,{htmlFor:`prune-reason`,className:`text-foreground-subtle`,children:i(`recordings.storageSection.pruneReason`,`Prune reason`)}),r(w,{wrapperClassName:`inline-block w-auto`,id:`prune-reason`,value:l,onChange:e=>{let t=Ht.find(t=>t.value===e.target.value);t&&u(t.value)},children:Ht.map(e=>r(`option`,{value:e.value,children:i(e.labelKey)},e.value))})]}),P===0?r(V,{icon:h,title:d.devicesRead===`unavailable`?i(`recordings.storageSection.perCameraUsageUnavailable`,`Per-camera usage unavailable`):i(`recordings.storageSection.noRecordedFootage`,`No recorded footage`),description:d.devicesRead===`unavailable`?i(`recordings.storageSection.thisRecordingNodeHasNo`,`This recording node has no footage ledger, so it refused to answer the per-camera table rather than report what it happens to hold in memory. The disk totals above are unaffected.`):i(`recordings.storageSection.noCameraHasRecordedFootage`,`No camera has recorded footage on this node yet.`)}):r(B,{columns:N,rows:[...d.devices],rowKey:e=>e.deviceId,minWidthPx:480})]})}function Jt(){let{t}=G();return e(`div`,{className:`flex flex-col gap-8`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsStorageSection.footageOnDisk`,`Footage on disk`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsStorageSection.whatRecordedFootageOccupiesPer`,`What recorded footage occupies, per camera and per volume, with prune-by-policy and delete-all-footage.`)}),r(`div`,{className:`mt-3`,children:r(qt,{})})]}),e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsStorageSection.recordingNodeFolders`,`Recording node & folders`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsStorageSection.theSingleNodeThatRecords`,`The single node that records and serves playback, and the storage locations footage is written to.`)}),r(`div`,{className:`mt-3`,children:r(Lt,{})})]})]})}function Yt(){let{t:e}=G(),t=Ae(`/recordings`,{t:e,isAdmin:!0})??{icon:b,title:e(`nav.recordings`,`Recordings`)};return r(je,{icon:t.icon,title:t.title,subtitle:e(`recordings.recordedFootageAndTheDurable`,`Recorded footage and the durable event store — what each occupies, where it is written, and the operations that move or reconcile both.`),defaultSection:`storage`,sectionsLabel:`${t.title} sections`,sections:[{id:`storage`,label:e(`recordings.recordings`,`Recordings`),content:r(Jt,{})},{id:`events`,label:e(`recordings.events`,`Events`),content:r(Ze,{})},{id:`cameras`,label:e(`recordings.cameras`,`Cameras`),content:r(Ve,{})},{id:`exports`,label:e(`recordings.export`,`Export`),content:r(ft,{})},{id:`activity`,label:e(`recordings.activity`,`Activity`),content:r(Be,{})},{id:`management`,label:e(`recordings.management`,`Management`),content:r(Nt,{})}]})}export{Yt as RecordingsPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{C as e,K as t,S as n,V as r,Y as i,et as a}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as o,Da as s,Dn as c,En as l,Er as u,Fa as d,Mi as f,St as p,Yt as m,ct as h,ka as g,lt as _,ni as v,ut as y}from"./player-overlays-BMit2yun.js";import{ps as b}from"./client-DLGNlJDt.js";import{a as x,d as S,o as C,s as w}from"./video-De6y5yax.js";import{Fn as T,Gn as E,Gr as D,Hd as O,Hn as k,In as A,Jr as j,K as M,Lo as ee,Nd as N,Pn as P,Q as F,Qr as I,Ur as L,Wd as R,Wn as z,Wr as B,Yr as V,Z as H,Zr as te,_r as U,cf as ne,cr as re,ef as W,ji as ie,lf as ae,lr as oe,lt as G,or as se,q as ce,qr as K,zf as q}from"./src-Dg912oqK.js";import{t as J}from"./i18n-CcjpDLHK.js";import{t as Y}from"./useTranslation-BJr-n0es.js";import{I as le,Kr as ue,n as de}from"./index-DgOWypvk.js";a();function X({id:t,title:r,icon:i,description:a,actions:s,tone:c=`default`,notice:l=null,onDismissNotice:u,children:d}){return n(k,{headingId:`access-${t}`,title:r,icon:i,actions:s,testId:`access-${t}`,children:e(`div`,{className:`${o} space-y-3`,children:[n(`div`,{className:g(`text-[11px] leading-relaxed`,c===`danger`?`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-foreground`:`text-foreground-subtle`),children:a}),l!==null&&n(Z,{notice:l,onDismiss:u}),d]})})}var fe={success:{icon:f,line:`border-success/30 text-foreground`,mark:`text-success`},danger:{icon:x,line:`border-danger/40 text-danger`,mark:`text-danger`}};function Z({notice:t,onDismiss:r}){let{t:i}=Y(),a=fe[t.tone],o=a.icon;return e(`div`,{role:t.tone===`danger`?`alert`:`status`,className:g(`flex items-start gap-2 rounded-md border bg-surface px-3 py-2 text-[11px]`,a.line),children:[n(o,{className:g(`mt-0.5 h-3.5 w-3.5 shrink-0`,a.mark),"aria-hidden":!0}),n(`span`,{className:`min-w-0 flex-1`,children:t.message}),r!==void 0&&n(ae,{type:`button`,variant:`ghost`,size:`sm`,icon:p,"aria-label":i(`access.accessSection.dismiss`,`Dismiss`),onClick:r,className:`-my-1 h-5 w-5`})]})}function pe(){let{data:e}=N();return t(()=>{let t=new Map;for(let n of e??[])t.set(n.id,n.username);return t},[e])}function me(e,t=null){return e===null?t:{tone:`danger`,message:e}}var he={active:`access.credentialColumns.statusActive`,expired:`access.credentialColumns.statusExpired`,revoked:`access.credentialColumns.statusRevoked`,current:`access.credentialColumns.statusCurrent`};function ge(e){return J.t(he[e])}var _e={active:`success`,expired:`warning`,revoked:`default`,current:`info`},ve={current:0,active:1,expired:2,revoked:3};function ye(e,t){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?`—`:n.toLocaleString()}function be({status:e}){return n(R,{variant:_e[e],className:`text-[10px]`,children:ge(e)})}function xe({row:t,action:r}){if(!r.isAvailable(t))return null;let i=r.icon,a=r.busyId===t.id;return e(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r.onRun(t),disabled:r.disabled,"aria-label":J.t(`access.credentialColumns.actionOn`,{action:r.label,name:t.name}),className:r.tone===`neutral`?void 0:`text-danger hover:bg-danger/10`,children:[a?n(u,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):n(i,{className:`h-3 w-3`,"aria-hidden":!0}),r.label]})}function Se(t){return[{key:`name`,header:J.t(`access.credentialColumns.name`,`Name`),sortValue:e=>e.name.toLowerCase(),render:t=>e(`div`,{className:`min-w-0 max-w-[18rem]`,children:[n(`div`,{className:`truncate font-medium text-foreground`,title:t.name,children:t.name}),t.detail!==null&&n(`div`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,title:t.detail,children:t.detail})]})},t.hideOwner?null:{key:`owner`,header:J.t(`access.credentialColumns.owner`,`Owner`),sortValue:e=>e.ownerName.toLowerCase(),render:e=>e.ownerName},{key:`kind`,header:J.t(`access.credentialColumns.kindScope`,`Kind / scope`),sortValue:e=>e.kind.toLowerCase(),nowrap:!1,render:t=>e(`div`,{className:`min-w-[8rem] max-w-[16rem]`,children:[n(`div`,{className:`text-foreground`,children:t.kind}),t.scope!==null&&n(`div`,{className:`line-clamp-2 text-[10px] text-foreground-subtle`,title:t.scope,children:t.scope})]})},{key:`status`,header:J.t(`access.credentialColumns.status`,`Status`),sortValue:e=>ve[e.status],render:e=>n(be,{status:e.status})},{key:`created`,header:J.t(`access.credentialColumns.created`,`Created`),sortValue:e=>e.createdAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:ye(e.createdAt,`—`)})},{key:`lastUsed`,header:J.t(`access.credentialColumns.lastUsed`,`Last used`),sortValue:e=>e.lastUsedAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:ye(e.lastUsedAt,J.t(`access.credentialColumns.never`))})},{key:`expires`,header:J.t(`access.credentialColumns.expires`,`Expires`),sortValue:e=>e.expiresAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:ye(e.expiresAt,t.expiresNone)})},t.action===null?null:{key:`actions`,header:``,align:`right`,notSortableReason:J.t(`access.credentialColumns.actionsHeader`),render:e=>n(`div`,{className:`flex items-center justify-end gap-1`,children:[...t.extraActions??[],t.action].map(t=>t===null?null:n(xe,{row:e,action:t},t.label))})}].filter(e=>e!==null)}a();var Ce=6,we={"current-session":`access.bulk.skipCurrentSession`,"not-active":`access.bulk.skipNotActive`};function Te(e){let t=we[e];return t===void 0?e:J.t(t)}function Ee(e,t){return J.t(t.key,{count:e})}function Q(e,t){return J.t(`access.bulk.countOf`,{count:e,noun:Ee(e,t)})}function De(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return[...t.entries()].map(([e,t])=>J.t(`access.bulk.statusCount`,{count:t,status:ge(e).toLowerCase()})).join(`, `)}function Oe(e,t){let n=e.slice(0,Ce).map(e=>`• ${e.name} — ${e.ownerName}`),r=e.length>Ce?[J.t(`access.bulk.previewMore`,{count:e.length-Ce})]:[];return[J.t(`access.bulk.previewIntro`,{what:Q(e.length,t),breakdown:De(e)}),``,...n,...r].join(`
|
|
2
|
-
`)}async function ke(e,t,n){let r=String(t.length),i=await e({title:J.t(`access.bulk.confirmTitle`,{what:Q(t.length,n)}),message:Oe(t,n),label:J.t(`access.bulk.confirmLabel`,{expected:r}),placeholder:r,confirmLabel:J.t(`access.bulk.confirmButton`,{expected:r}),variant:`danger`,validate:e=>e.trim()===r?null:J.t(`access.bulk.confirmMismatch`,{expected:r,noun:Ee(2,n)})});return i!==null&&i.trim()===r}function Ae(e,t){let n=_(),r=q.auth.revokeCredentials.useMutation(),[a,o]=i(null);return{run:async i=>{if(i.length===0||!await ke(n,i,e))return!1;o(null);try{let t=await r.mutateAsync({ids:i.map(e=>e.id),confirmCount:i.length}),n=t.skipped.map(e=>Te(e.reason));return o({tone:`success`,message:n.length>0?J.t(`access.bulk.revokedSkipped`,{what:Q(t.revoked.length,e),count:n.length,reasons:[...new Set(n)].join(`, `)}):J.t(`access.bulk.revoked`,{what:Q(t.revoked.length,e)})}),!0}catch(e){return o({tone:`danger`,message:J.t(`access.bulk.revokeFailed`,{error:e instanceof Error?e.message:J.t(`access.bulk.requestFailed`)})}),!1}finally{t()}},busy:r.isPending,outcome:a,dismiss:()=>o(null)}}function je(e,t,n){let r=_(),[a,o]=i(!1),[s,c]=i(null);return{run:async i=>{if(i.length===0||!await ke(r,i,e))return!1;c(null),o(!0);let a=[],s=0;for(let e of i)try{await t(e.id),s+=1}catch(t){a.push(`${e.name}: ${t instanceof Error?t.message:J.t(`access.bulk.requestFailed`)}`)}return o(!1),n(),a.length===0?(c({tone:`success`,message:J.t(`access.bulk.revoked`,{what:Q(s,e)})}),!0):(c({tone:`danger`,message:J.t(a.length>3?`access.bulk.eachPartialMore`:`access.bulk.eachPartial`,{what:Q(s,e),count:a.length,details:a.slice(0,3).join(`; `)})}),s>0)},busy:a,outcome:s,dismiss:()=>c(null)}}a();var Me={searchText:e=>[e.name,e.detail??``,e.ownerName,e.kind,e.scope??``],facetGroups:[{id:`status`,value:e=>e.status},{id:`owner`,value:e=>e.ownerName},{id:`kind`,value:e=>e.kind}]},Ne={status:`access.credentialTable.groupStatus`,owner:`access.credentialTable.groupOwner`,kind:`access.credentialTable.groupKind`},Pe=e=>e.status!==`current`,Fe=[`active`,`current`];function Ie({rows:r,label:a,isLoading:o,loadError:s,emptyText:c,hideOwner:l=!1,expiresNone:d,action:f,extraActions:p,bulk:m,defaultStatus:h=Fe}){let{t:g}=Y(),[_]=i(()=>h.length===0?{search:``,facets:[]}:{search:``,facets:[],groups:{status:[...h]}}),v=P(r,Me,_),[y,b]=i(()=>new Set),x=d??g(`access.credentialColumns.never`),S=t(()=>Se({hideOwner:l,expiresNone:x,action:f??null,...p===void 0?{}:{extraActions:p}}),[l,x,f,p,g]),C=t(()=>m===void 0?()=>!1:e=>Pe(e)&&m.isSelectable(e),[m]),w=t(()=>v.rows.filter(e=>y.has(e.id)&&C(e)),[v.rows,y,C]);return o?e(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[n(u,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),g(`access.credentialTable.loading`,{label:a})]}):s===null?e(`div`,{className:`space-y-3`,children:[n(T,{state:v.state,facets:v.facets,groups:v.groups.filter(e=>!(l&&e.id===`owner`)).map(e=>({...e,label:Ne[e.id]===void 0?e.id:g(Ne[e.id]),...e.id===`status`?{facetLabel:e=>ge(e)}:{}})),labels:{searchPlaceholder:g(`access.credentialTable.searchPlaceholder`,{label:a}),searchLabel:g(`access.credentialTable.searchLabel`,{label:a}),facetsLabel:g(`access.credentialTable.facetsLabel`,{label:a}),clearLabel:g(`access.credentialTable.clearFilters`)},onSearch:v.setSearch,onToggleFacet:v.toggleFacet,onToggleGroupFacet:v.toggleGroupFacet,onClear:v.clear}),m!==void 0&&n(Le,{bulk:m,shown:v.rows.filter(C),targets:w,onSelect:b}),n(z,{columns:S,rows:v.rows,rowKey:e=>e.id,minWidthPx:l?760:860,maxBodyHeight:E,defaultSort:{columnKey:`created`,dir:`desc`},pageSize:25,paginationLabels:{navLabel:g(`access.credentialTable.pagesLabel`,{label:a}),previous:g(`access.credentialTable.previousPage`),next:g(`access.credentialTable.nextPage`),range:(e,t,n)=>g(`access.credentialTable.range`,{from:e,to:t,total:n})},emptyMessage:v.active?g(`access.credentialTable.noMatchTheFilters`,`No {{label}} match the filters.`,{label:a}):c,rowClassName:e=>e.status===`revoked`||e.status===`expired`?`opacity-70`:void 0,...m===void 0?{}:{selection:{selected:y,onChange:b,isSelectable:C,rowLabel:e=>g(`access.credentialTable.rowLabel`,{name:e.name,owner:e.ownerName}),pageLabel:g(`access.credentialTable.pageLabel`,{noun:Ee(1,m.noun)})}}})]}):n(O,{title:g(`access.credentialTable.couldNotLoad`,`Could not load {{label}}`,{label:a}),message:s})}function Le({bulk:t,shown:r,targets:i,onSelect:a}){let{t:o}=Y(),{revoke:s,noun:c}=t,l=(t.quickSelect??[]).map(e=>({...e,rows:r.filter(e.match)})).filter(e=>e.rows.length>0),d=async()=>{await s.run(i)&&a(new Set)};return e(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`bulk-bar`,children:[r.length>0&&n(W,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(r.map(e=>e.id))),children:o(`access.credentialTable.selectAllShown`,{count:r.length})}),l.map(t=>e(W,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(t.rows.map(e=>e.id))),children:[t.label,` (`,String(t.rows.length),`)`]},t.label)),i.length>0&&e(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[n(`span`,{className:`text-[11px] tabular-nums text-foreground`,"aria-live":`polite`,children:o(`access.credentialTable.selectedLabel`,{what:Q(i.length,c)})}),e(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>a(new Set),children:[n(p,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.clearSelection`,`Clear selection`)]}),e(W,{type:`button`,variant:`danger`,size:`sm`,disabled:s.busy,onClick:()=>void d(),children:[s.busy?n(u,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):n(m,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.revoke`,{what:Q(i.length,c)})]})]})]})}var Re=(e,t)=>t===null?`—`:e.get(t)??t;function ze(e,t){return e!=null&&e<=t?`expired`:`active`}function Be(e,t,n){return{id:e.id,name:n.client(e.client),detail:e.ip,ownerId:e.userId,ownerName:Re(t,e.userId),kind:n.method(e.method),scope:null,status:e.current?`current`:`active`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Ve(e,t){return{id:e.id,name:e.integrationId,detail:null,ownerId:e.userId,ownerName:e.username,kind:e.integrationId,scope:t,status:e.revokedAt===null?`active`:`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:null}}var He=`All permissions`,Ue=`View link`,We=`Scoped`,Ge={"grid-view":`Grid`,"events-view":`Events`};function Ke(e,t){return e.map(e=>t.get(e)??`#${String(e)}`).join(`, `)}function qe(e){return e!==`*`&&e.type===`share-view`&&`grant`in e}function Je(e,t,n){return e===`*`?He:qe(e)?`${`${Ge[e.grant.kind]} view${e.grant.talk===!0?` + talk`:``}`}: ${Ke(e.grant.deviceIds,t)}`:n(e)}function Ye(e){return e.includes(`*`)?He:e.some(qe)?Ue:We}function Xe(e,t,n,r){return{id:e.id,name:e.label,detail:null,ownerId:e.subjectId,ownerName:Re(t,e.subjectId),kind:Ye(e.scopes),scope:n,status:e.revokedAt===null?ze(e.expiresAt,r):`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Ze(e){return`${e.provider}\u0000${e.subject}`}function Qe(e,t){return{id:Ze(e),name:e.label??e.subject,detail:e.issuer,ownerId:e.userId,ownerName:Re(t,e.userId),kind:e.provider,scope:null,status:`active`,createdAt:e.linkedAt,lastUsedAt:null,expiresAt:null}}var $e=40,et=[{test:/Electron\//,name:`CamStack desktop`},{test:/Edg(e|A|iOS)?\//,name:`Edge`},{test:/OPR\/|Opera/,name:`Opera`},{test:/Firefox\/|FxiOS\//,name:`Firefox`},{test:/Chrome\/|CriOS\//,name:`Chrome`},{test:/Version\/[\d.]+.*Safari\//,name:`Safari`}],tt=[{test:/iPhone/,name:`iPhone`},{test:/iPad/,name:`iPad`},{test:/Android/,name:`Android`},{test:/Mac OS X|Macintosh/,name:`macOS`},{test:/Windows/,name:`Windows`},{test:/CrOS/,name:`ChromeOS`},{test:/Linux/,name:`Linux`}],nt=[{test:/CFNetwork\/.*Darwin\//,name:`CamStack app on iOS`},{test:/^okhttp\//i,name:`CamStack app on Android`},{test:/^(node|undici)\b/i,name:`Script (Node.js)`},{test:/^curl\//i,name:`curl`}];function rt(e,t){return e.find(e=>e.test.test(t))?.name??null}function it(e){return e.length<=$e?e:`${e.slice(0,$e)}…`}function at(e){if(e===null||e.trim().length===0)return{label:J.t(`helpers.sessionClient.unknownDevice`),raw:null};let t=e.trim(),n=rt(nt,t);if(n!==null)return{label:n,raw:t};let r=rt(et,t),i=rt(tt,t);return r!==null&&i!==null?{label:J.t(`helpers.sessionClient.browserOnSystem`,{browser:r,system:i}),raw:t}:r===null?{label:it(t),raw:t}:{label:r,raw:t}}var ot={password:`helpers.sessionClient.method.password`,passkey:`helpers.sessionClient.method.passkey`,sso:`helpers.sessionClient.method.sso`,handoff:`helpers.sessionClient.method.handoff`,"cli-approval":`helpers.sessionClient.method.cliApproval`,exchange:`helpers.sessionClient.method.exchange`};function st(e){let t=ot[e];return t===void 0?e:J.t(t)}function ct(e){if(e==null)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}function lt({token:t,label:r,onClose:i}){let{t:a}=Y();return n(L,{open:!0,onOpenChange:e=>!e&&i(),children:e(D,{width:`md`,scroll:`body`,children:[n(j,{children:n(V,{children:a(`auth.tokenModals.token`,`Token: {{label}}`,{label:r})})}),e(B,{className:`space-y-3`,children:[n(`div`,{className:`rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning`,children:a(`auth.tokenModals.copyThisTokenNowOnce`,`Copy this token now. Once you close this dialog the secret cannot be displayed again.`)}),n(`div`,{className:`select-all break-all rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:t})]}),e(K,{children:[n(A,{value:t,label:a(`common.copy`,`Copy`),srLabel:`token`}),n(W,{type:`button`,variant:`primary`,size:`sm`,onClick:i,children:a(`auth.tokenModals.done`,`Done`)})]})]})})}var ut={token:`newToken`,scoped:`newScoped`,admin:`newAdmin`};a();var dt=80,$=86400,ft=[{value:`1`,seconds:$},{value:`7`,seconds:7*$},{value:`30`,seconds:30*$},{value:`90`,seconds:90*$},{value:`never`,seconds:`never`}],pt=[b.Camera],mt=64,ht={type:`capability`,target:``,access:[`view`,`create`]};function gt({open:a,users:o,onClose:f,onSubmit:p,submitting:m,formError:h,awaitingProof:g}){let{t:_}=Y(),b=d(),{user:x}=le(),C=x?.isAdmin===!0,w=C?null:x?.scopes??[],[T,E]=i(`scopes`),[D,O]=i(x?.id??``),[k,A]=i(``),[j,ee]=i([ht]),[N,P]=i([]),[L,R]=i(`grid-view`),[z,B]=i(!1),[V,H]=i(`30`);r(()=>{a||(E(`scopes`),O(x?.id??``),A(``),ee([ht]),P([]),R(`grid-view`),B(!1),H(`30`))},[a,x?.id]),r(()=>{T!==`view-link`&&V===`never`&&H(`30`)},[T,V]);let ae=t(()=>ft.filter(e=>e.seconds!==`never`||T===`view-link`).map(e=>({value:e.value,label:e.seconds===`never`?_(`access.createTokenModal.never`,`Never (until revoked)`):_(`access.createTokenModal.days`,{count:Number(e.value)})})),[T,_]),G=k.trim(),K=T===`scopes`?ce(j,b):null,q=[...N],J=ft.find(e=>e.value===V)?.seconds??30*$,de=()=>T===`all`?[`*`]:T===`view-link`?[{type:`share-view`,grant:{kind:L,deviceIds:q,...z?{talk:!0}:{}}}]:j,X=G.length>0&&G.length<=dt&&!m&&!g&&(T===`all`?C:T===`view-link`?q.length>0:j.length>0&&K===null),fe=()=>{if(!X)return;let e=C&&T!==`all`&&D!==``&&D!==x?.id;p({scopes:de(),expiresIn:J,label:G,...e?{subjectId:D}:{}})},Z=T===`all`,pe=Z?c:l;return n(F,{open:a,onClose:f,title:_(`access.createTokenModal.createToken`,`Create token`),icon:Z?c:S,error:h,width:`md`,testId:`create-token-dialog`,footer:e(W,{type:`button`,variant:Z?`danger`:`primary`,size:`sm`,onClick:fe,disabled:!X,"data-testid":`create-token-submit`,children:[m||g?n(u,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):n(pe,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),_(`access.createTokenModal.issueToken`,`Issue token`)]}),children:e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[n(U,{children:_(`access.createTokenModal.whatItMayDo`,`What it may do`)}),n(se,{appearance:`pills`,value:T,onValueChange:e=>{(e===`scopes`||e===`view-link`||e===`all`)&&E(e)},children:e(re,{"aria-label":_(`access.createTokenModal.whatItMayDo`,`What it may do`),children:[e(oe,{value:`scopes`,"data-testid":`token-reach-scopes`,children:[n(l,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),_(`access.createTokenModal.reachScopes`,`Scopes`)]}),e(oe,{value:`view-link`,"data-testid":`token-reach-view-link`,children:[n(v,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),_(`access.createTokenModal.reachViewLink`,`View link`)]}),C?e(oe,{value:`all`,"data-testid":`token-reach-all`,children:[n(c,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),_(`access.createTokenModal.reachAll`,`All permissions`)]}):null]})})]}),Z?n(`div`,{className:`space-y-1 rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px] leading-relaxed text-foreground`,"data-testid":`admin-token-warning`,children:n(`p`,{children:n(ue,{i18nKey:`auth.adminTokenNoticeShort`,components:{strong:n(`strong`,{})}})})}):null,C&&T!==`all`&&o.length>1?e(`div`,{className:`space-y-1`,children:[n(U,{htmlFor:`token-user`,children:_(`access.createTokenModal.onBehalfOfUser`,`On behalf of user`)}),n(y,{id:`token-user`,value:D,onChange:e=>O(e.target.value),options:o.map(e=>({value:e.id,label:e.username}))})]}):null,e(`div`,{className:`space-y-1`,children:[n(U,{htmlFor:`token-name`,children:_(`access.createTokenModal.label`,`Label`)}),n(ne,{id:`token-name`,value:k,maxLength:dt,required:!0,onChange:e=>A(e.target.value),placeholder:T===`view-link`?`kitchen-wall`:`nightly-backup`,autoFocus:!0})]}),T===`scopes`?e(`div`,{className:`space-y-1`,children:[n(U,{children:_(`access.createTokenModal.scopes`,`Scopes`)}),n(M,{value:j,onChange:ee,clampToParent:w}),K&&n(`p`,{className:`text-[10px] text-danger`,children:K}),n(`p`,{className:`text-[10px] text-foreground-subtle`,children:_(`access.createTokenModal.eachScopePicksACap`,`Each scope picks a (cap or addon) target + one or more access flavours. The token can access ONLY what's listed.`)})]}):null,T===`view-link`?e(`div`,{className:`space-y-2`,"data-testid":`token-view-link`,children:[e(`div`,{className:`space-y-1`,children:[n(U,{htmlFor:`token-view-cameras`,children:_(`access.createTokenModal.cameras`,`Cameras`)}),n(ie,{id:`token-view-cameras`,multiple:!0,pick:`device`,noun:`camera`,fixedTypes:pt,maxItems:mt,recentKey:`token-view-cameras`,testId:`token-view-cameras`,value:I(N),onChange:e=>P(te(e))})]}),e(`div`,{className:`space-y-1`,children:[n(U,{htmlFor:`token-view-kind`,children:_(`access.createTokenModal.viewKind`,`Shows`)}),n(y,{id:`token-view-kind`,value:L,onChange:e=>R(e.target.value===`events-view`?`events-view`:`grid-view`),options:[{value:`grid-view`,label:_(`access.createTokenModal.viewGrid`,`Live grid`)},{value:`events-view`,label:_(`access.createTokenModal.viewEvents`,`Events`)}]})]}),L===`grid-view`?e(`label`,{className:`flex items-start gap-2 text-sm text-foreground`,children:[n(s,{className:`mt-0.5`,checked:z,onChange:e=>B(e.target.checked),"data-testid":`token-view-talk`}),n(`span`,{children:_(`access.createTokenModal.talk`,`Allow talk-back on these cameras`)})]}):null]}):null,e(`div`,{className:`space-y-1`,children:[n(U,{htmlFor:`token-lifetime`,children:_(`access.createTokenModal.expires`,`Expires after`)}),n(y,{id:`token-lifetime`,value:V,onChange:e=>H(e.target.value),options:ae})]})]})})}a();var _t={key:`access.nouns.token`};function vt(e){return typeof e==`object`&&!!e&&`kind`in e}function yt(e,t){let n=e.access===void 0?``:` [${e.access.join(`, `)}]`;return e.type===`device`?`device:[${vt(e.selector)?G(e.selector,t):`?`}]${n}`:e.type===`addon-routes`?`${t(`access.tokensSection.everyAddonRoutes`,`every addon's routes`)}${n}`:`${e.type}:${e.target??``}${n}`}function bt({headerOwnsCreate:a=!1,createRequested:o=!1,onCreateConsumed:s,ownOnly:c=!1}){let{t:l}=Y(),u=d(),{user:f}=le(),p=h(),g=q.useUtils(),_=pe(),{data:v}=N(),y=t(()=>v??[],[v]),{data:b}=ee({}),x=t(()=>{let e=new Map;for(let t of b??[])e.set(t.id,t.name);return e},[b]),C=q.auth.listTokens.useQuery(void 0),{requestProof:w,dialog:T}=de(`Creating a token with all permissions`),{state:E,openNew:D,close:O}=H({newKey:ut.token}),[k,A]=i(null),[j,M]=i(null),[P,F]=i(!1),[I,L]=i(null),[R,z]=i(null);r(()=>{o&&(D(),s?.())},[o,D,s]);let B=()=>{g.auth.listTokens.invalidate(),g.auth.listAuthAudit.invalidate()},V=q.auth.mintToken.useMutation({onSuccess:({token:e,record:t})=>{B(),O(),M(null),F(!1),L({token:e,label:t.label})},onError:e=>{M(`Create failed: ${e.message}`),F(!1)}}),te=q.auth.revokeToken.useMutation({onSuccess:()=>{z(null),B()},onError:e=>{z(null),A(`Revoke failed: ${e.message}`)}}),U=Ae(_t,B),ne=Date.now(),re=(C.data??[]).filter(e=>!c||e.subjectId===f?.id).map(e=>Xe(e,_,e.scopes.includes(`*`)?null:e.scopes.map(e=>Je(e,x,e=>yt(e,u))).join(`, `),ne)),ie=async e=>{await p({title:l(`access.tokensSection.revoke`,`Revoke "{{name}}"?`,{name:e.name}),message:e.kind===`All permissions`?l(`access.tokensSection.everyScriptUsingItLoses`,`Every script using it loses access immediately. This cannot be undone.`):l(`access.tokensSection.stopsWorking`,`Whoever holds it loses access immediately. This cannot be undone.`),confirmLabel:l(`access.tokensSection.revoke2`,`Revoke`),variant:`danger`})&&(A(null),z(e.id),te.mutate({id:e.id}))},ae=e=>{(async()=>{A(null),M(null);let t;if(e.scopes.includes(`*`)){F(!0);let e=await w();if(F(!1),e===null)return;t=e}V.mutate({scopes:[...e.scopes],expiresIn:e.expiresIn,label:e.label,...e.subjectId===void 0?{}:{subjectId:e.subjectId},...t===void 0?{}:{reauthToken:t}})})()};return e(`div`,{"data-testid":`tokens`,children:[T,n(X,{notice:me(k,U.outcome),onDismissNotice:()=>{A(null),U.dismiss()},id:c?`my-tokens`:`tokens`,title:c?l(`access.tokensSection.myTokens`,`My tokens`):l(`access.tokensSection.tokens`,`Tokens`),icon:S,actions:a?void 0:e(W,{size:`sm`,type:`button`,"data-testid":`tokens-new`,onClick:D,children:[n(S,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),l(`system.access.newToken`,`New token`)]}),description:l(`access.tokensSection.oneFormat`,`Every token is its scopes: a few permissions for a script, all permissions for an admin script, or a view of some cameras for a share link. Revoking one stops it on its next use.`),children:n(Ie,{rows:re,label:l(`common.tokensLabel`),isLoading:C.isLoading,loadError:C.isError?C.error?.message??`Request failed`:null,emptyText:l(`access.tokensSection.noTokens`,`No tokens.`),action:{label:l(`access.tokensSection.revoke2`,`Revoke`),icon:m,isAvailable:e=>e.status===`active`,onRun:e=>void ie(e),busyId:R,disabled:U.busy||R!==null},...f?.isAdmin===!0?{bulk:{revoke:U,noun:_t,isSelectable:e=>e.status===`active`}}:{}})}),n(gt,{open:E.mode===`new`,users:y.map(e=>({id:e.id,username:e.username})),onClose:()=>{O(),M(null),F(!1)},submitting:V.isPending,formError:j,awaitingProof:P,onSubmit:ae}),I&&n(lt,{token:I.token,label:I.label,onClose:()=>L(null)})]})}var xt=864e5,St={qr:`QR (by an admin)`,self:`Self-enrolled`},Ct={ios:`iOS`,android:`Android`,web:`Web`,other:`Other`};function wt(e){return e.status===`revoked`}function Tt(e){return e.status!==`revoked`}function Et(e,t=`—`){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:n.toLocaleString()}function Dt(e,t){return e===null||Number.isNaN(e)?null:Math.floor((e-t)/xt)}function Ot(e,t){let n=Dt(e,t);return n===null?`unknown`:n<0?`expired`:n<30?`soon`:`ok`}function kt(e,t){let n=Dt(e,t);return n===null?J.t(`helpers.certificateModel.unknown`):n===0?J.t(`helpers.certificateModel.today`):n>0?J.t(`helpers.certificateModel.inDays`,{count:n}):J.t(`helpers.certificateModel.daysAgo`,{count:-n})}function At(e){if(e===null)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function jt(e){return e===null||e.length===0?`—`:e.length<=17?e:`${e.slice(0,8)}…${e.slice(-8)}`}function Mt(e){return e.length<=10?e:`${e.slice(0,10)}…`}function Nt(e){if(!e.online)return{allowed:!1,reason:J.t(`helpers.certificateModel.nodeOffline`)};if(e.isHub&&e.https.kind===`served`){if(e.https.status.mode===`uploaded`)return{allowed:!1,reason:J.t(`helpers.certificateModel.uploadedCert`)};if(e.https.status.mode===`disabled`)return{allowed:!1,reason:J.t(`helpers.certificateModel.tlsDisabled`)}}return{allowed:!0,reason:null}}var Pt={prepare:`helpers.certificateModel.stage.prepare`,issue:`helpers.certificateModel.stage.issue`,install:`helpers.certificateModel.stage.install`,reconnect:`helpers.certificateModel.stage.reconnect`,confirm:`helpers.certificateModel.stage.confirm`};function Ft(e){if(e.ok)return{tone:`success`,message:J.t(`helpers.certificateModel.renewed`,{nodeId:e.nodeId,serial:Mt(e.newSerial)})};let t=e.keptPreviousLeaf?J.t(`helpers.certificateModel.keptPrevious`):J.t(`helpers.certificateModel.maybeNoCert`);return{tone:`danger`,message:J.t(`helpers.certificateModel.renewalFailed`,{nodeId:e.nodeId,stage:J.t(Pt[e.stage]),reason:e.reason,kept:t})}}function It(e,t){let n=Math.max(0,e-t),r=Math.ceil(n/1e3),i=Math.floor(r/60),a=r%60;return{expired:n===0,label:`${String(i)}:${String(a).padStart(2,`0`)}`}}var Lt=11;function Rt(e,t){let n=e.slice(0,Lt);return t===null?n:`${n} · ${t}`}function zt(e){return{id:e.id,name:e.deviceName,detail:Rt(e.fingerprint,e.lastUsedFrom),ownerId:e.userId,ownerName:e.username??e.userId,kind:Ct[e.platform],scope:St[e.enrolledVia],status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Bt(e,t){return{id:e.id,name:e.deviceName,detail:null,ownerId:null,ownerName:t,kind:Ct[e.platform],scope:null,status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Vt({sessions:t,isLoading:r,loadError:i,emptyText:a,onRevoke:o,revokingId:s}){let{t:c}=Y();return r?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[n(u,{className:`h-3.5 w-3.5 animate-spin`}),c(`auth.sessionsList.loadingSessions`,`Loading sessions…`)]}):i===null?t.length===0?n(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center`,children:a}):n(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.map(e=>n(Ht,{session:e,revoking:s===e.id,onRevoke:()=>o(e)},e.id))}):e(`div`,{className:`text-[11px] text-danger`,children:[c(`auth.sessionsList.couldNotLoadSessions`,`Could not load sessions:`),` `,i]})}function Ht({session:t,revoking:r,onRevoke:i}){let{t:a}=Y(),o=at(t.client);return e(`li`,{"data-testid":`session-row`,className:`flex items-start gap-3 px-3 py-2 text-xs`,children:[n(C,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-foreground-subtle`}),e(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[n(`span`,{className:`font-medium text-foreground truncate`,title:o.raw??void 0,children:o.label}),t.current&&n(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:a(`auth.sessionsList.thisDevice`,`This device`)})]}),e(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[n(`span`,{children:st(t.method)}),n(`span`,{className:`font-mono`,children:t.ip??a(`auth.sessionsList.ipUnknown`,`IP unknown`)}),n(`span`,{children:a(`auth.sessionsList.lastActive`,{when:ct(t.lastUsedAt)})}),n(`span`,{children:a(`auth.sessionsList.expires`,{when:ct(t.expiresAt)})})]})]}),!t.current&&e(W,{variant:`unstyled`,onClick:i,disabled:r,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[r?n(u,{className:`h-3 w-3 animate-spin`}):n(w,{className:`h-3 w-3`}),a(`auth.sessionsList.signOut`,`Sign out`)]})]})}export{Be as C,X as D,je as E,me as O,Ve as S,Ae as T,at as _,Tt as a,Ze as b,kt as c,Et as d,Nt as f,ut as g,bt as h,wt as i,pe as k,Ft as l,Mt as m,zt as n,It as o,jt as p,Bt as r,At as s,Vt as t,Ot as u,st as v,Ie as w,Qe as x,ct as y};
|