@camstack/addon-admin-ui 1.2.437 → 1.2.438
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AddonAssetIcon-C3Ltt0yX.js → AddonAssetIcon-n8Qr5_Kp.js} +1 -1
- package/dist/assets/{Addons-CkBmnKjV.js → Addons-Dtpom4zF.js} +1 -1
- package/dist/assets/{AdminPage-B7Z1OWO3.js → AdminPage-D2JwPYR7.js} +1 -1
- package/dist/assets/{AdminSectionedPage-USP4OV_Y.js → AdminSectionedPage-5tMwz6Be.js} +1 -1
- package/dist/assets/{AiProfiles-QWD8PlMr.js → AiProfiles-CrkwNINl.js} +1 -1
- package/dist/assets/{BrokerForm-BxmxiIRw.js → BrokerForm-Dbt1v9HX.js} +1 -1
- package/dist/assets/{Build-CXn4HT3p.js → Build-Bv-SRt3z.js} +1 -1
- package/dist/assets/{Calendars-DN9ln21d.js → Calendars-CPdNc3AH.js} +1 -1
- package/dist/assets/{Cluster-tgWdVHND.js → Cluster-iOH_2qVx.js} +1 -1
- package/dist/assets/{ClusterStepModel-BizBdfIU.js → ClusterStepModel-vvtitbie.js} +1 -1
- package/dist/assets/{CompositionEditor-GiDCG4Aj.js → CompositionEditor-BP-AGI3Y.js} +1 -1
- package/dist/assets/{CompositionEditorPage-wfYMLlvy.js → CompositionEditorPage-BRatBKGt.js} +1 -1
- package/dist/assets/{Data-CmT5GPx9.js → Data-Bk8YwGJK.js} +1 -1
- package/dist/assets/{DeviceDetail-moNYFDGE.js → DeviceDetail-BtiSYWZr.js} +1 -1
- package/dist/assets/{DeviceDoActionFields-C1LG9nW0.js → DeviceDoActionFields-CBs8E-hd.js} +1 -1
- package/dist/assets/{Devices-837Dt931.js → Devices-Bgd8Iyo4.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-Crrh_6YT.js → EmbedPlayerPage-OppPi2oS.js} +1 -1
- package/dist/assets/{Identity-CNNb8wrU.js → Identity-BlDv0gjH.js} +1 -1
- package/dist/assets/{IntegrationDetail-BER_0Zaz.js → IntegrationDetail-CLiGGiDO.js} +1 -1
- package/dist/assets/{IntegrationHub-BEu0isNR.js → IntegrationHub-elusTiRh.js} +1 -1
- package/dist/assets/{Integrations-Sjh868gF.js → Integrations-BX33zgRF.js} +1 -1
- package/dist/assets/{Integrations-CuZucOyR.js → Integrations-DlLfaKrk.js} +1 -1
- package/dist/assets/{Library-B4Nw3n28.js → Library-CGx2d-jp.js} +1 -1
- package/dist/assets/{Locations-B7dC2DyF.js → Locations-CFU7VvDI.js} +1 -1
- package/dist/assets/{Logs-4XWMmfpD.js → Logs-BppneNXQ.js} +1 -1
- package/dist/assets/{MyAccess-TAG05L5N.js → MyAccess-7TTQLj-6.js} +1 -1
- package/dist/assets/{Network-ReY1qUoQ.js → Network-D4qKoubf.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-DIKEaj5p.js → NodeAddonsSettingsPanel-DOLEqwOJ.js} +1 -1
- package/dist/assets/{Notifications-CqTEfaZ_.js → Notifications--kvb7ubW.js} +1 -1
- package/dist/assets/{Recordings-EMQC9iqz.js → Recordings-C3Ikd7pB.js} +1 -1
- package/dist/assets/{ScanNetworkModal-DK98Sjd4.js → ScanNetworkModal-O2KH9u3g.js} +1 -1
- package/dist/assets/{SessionsList-B1Ni2lo_.js → SessionsList-DCXslvk3.js} +1 -1
- package/dist/assets/{Showroom-BKLoHB4Z.js → Showroom-BXD3terh.js} +1 -1
- package/dist/assets/{System-DEOHPmr3.js → System-CHwXBdVd.js} +1 -1
- package/dist/assets/{Terminal-dVu7TTAE.js → Terminal-D2WVII9y.js} +1 -1
- package/dist/assets/{Viewer-B9mEIKqz.js → Viewer-BdY4QQPs.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BX43JXOX.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-D8hkm2kB.js} +1 -1
- package/dist/assets/{addon-icons-context-BjcmJD_J.js → addon-icons-context-Drfj1y7k.js} +1 -1
- package/dist/assets/{authed-media-Cf82_ejX.js → authed-media-CFsHrcXx.js} +1 -1
- package/dist/assets/{device-integration-icon-3UfBj_i6.js → device-integration-icon-Bd49r785.js} +1 -1
- package/dist/assets/device-picker-model-BQdOI8yn.js +1 -0
- package/dist/assets/{hostInit-BCqJwB4Y.js → hostInit-C_3liyhx.js} +1 -1
- package/dist/assets/{index-CeO2wVZi.js → index-DrWxDgY9.js} +3 -3
- package/dist/assets/{linked-devices-model-DbkbB7KM.js → linked-devices-model-B7EZaQcp.js} +1 -1
- package/dist/assets/{location-owned-usage-C21QUrwl.js → location-owned-usage-CEUpeKPu.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-5e54ea5d.js → mf-entry-bootstrap-0-aa799d5d.js} +2 -2
- package/dist/assets/mount-BQdOI8yn.js +1 -0
- package/dist/assets/{notification-schedule-field-DiZ-TJBp.js → notification-schedule-field-3QjzRWF0.js} +1 -1
- package/dist/assets/remoteEntry-CavKhY-Z.js +1 -0
- package/dist/assets/{src-CL0G8g2V.js → src-BpDNu6in.js} +1 -1
- package/dist/assets/{use-scenes-feed-DCExYbbk.js → use-scenes-feed-CAUwbJgh.js} +1 -1
- package/dist/assets/{use-stationary-objects-DPwgtmOw.js → use-stationary-objects-CwdwiqSu.js} +1 -1
- package/dist/assets/useEventInvalidation-BQdOI8yn.js +1 -0
- package/dist/assets/{useNodeUrlSelection-ibxCoFYh.js → useNodeUrlSelection-2GpIyOt_.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DVRZb8h3.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CVZRr77d.js} +2 -2
- package/dist/index.html +6 -6
- package/dist/server/addon.js +1 -1
- package/package.json +1 -1
- package/dist/assets/device-picker-model-DJj6igTj.js +0 -1
- package/dist/assets/mount-DJj6igTj.js +0 -1
- package/dist/assets/remoteEntry-DSZ__m0a.js +0 -1
- package/dist/assets/useEventInvalidation-DJj6igTj.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,B as t,G as n,J as r,L as i,S as a,b as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{Ei as l,Fr as u,It as d,Jr as f,Nt as p,Wr as m,Y as h,dt as g,ea as _,or as v,ot as y,si as b,xr as x}from"./player-overlays-Db_o1Zm2.js";import{Oi as S}from"./client-CUuI767h.js";import{n as C,t as w}from"./scissors-DjP6Unuk.js";import{$c as T,An as E,Fc as D,Gs as O,Ic as k,Kc as A,Kt as j,Lc as M,Mc as N,Mn as P,Nc as ee,Nn as F,On as te,Pc as ne,Pn as re,Qc as ie,Rc as ae,Un as oe,Vn as I,Wc as se,Wn as L,Xc as ce,Yc as le,Yn as ue,Ys as de,Zc as fe,_r as pe,al as me,br as he,bs as ge,el as _e,er as R,fs as ve,il as ye,kn as be,ms as xe,nl as Se,ol as Ce,qc as z,qt as we,rl as Te,tl as Ee,va as B,vs as De,vu as Oe,xu as V,zc as ke}from"./src-CL0G8g2V.js";import{t as H}from"./i18n-RHwbGLC0.js";import{t as U}from"./useTranslation-D3Is_4B6.js";import{A as Ae,X as je,w as Me}from"./index-CeO2wVZi.js";import{t as Ne}from"./AdminSectionedPage-USP4OV_Y.js";import{n as Pe}from"./authed-media-Cf82_ejX.js";import{t as W}from"./format-size-DIxKXxtj.js";import{c as Fe,i as Ie,l as Le,n as Re,o as ze,r as Be,s as Ve,t as He,u as Ue}from"./location-owned-usage-C21QUrwl.js";e();var We=[{value:`all`,labelKey:`common.all`},{value:`recording`,labelKey:`recordings.activitySection.domainRecordings`},{value:`events`,labelKey:`common.events`}],Ge={recording:`bg-primary/10 text-primary`,events:`bg-violet-500/10 text-violet-400`},Ke={columnKey:`at`,dir:`desc`};function qe(e){return new Date(e).toLocaleString()}function Je(){let{t:e,i18n:t}=U(),[i,s]=r(`all`),{data:l,isLoading:u,isError:d}=ne({},{refetchOnWindowFocus:!1}),{data:f,isLoading:m,isError:h}=De({},{refetchOnWindowFocus:!1}),{data:g}=B({isCamera:!0,projection:`slim`}),y=n(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.name);return e},[g]),b=n(()=>{let e=[...l??[],...f??[]];return(i===`all`?e:e.filter(e=>e.domain===i)).toSorted((e,t)=>t.at-e.at)},[l,f,i]),x=n(()=>{let t=[];return d&&i!==`events`&&t.push(e(`recordings.activitySection.domainRecordings`)),h&&i!==`recording`&&t.push(e(`common.events`)),t},[d,h,i,e]),S=n(()=>new Intl.ListFormat(t.language,{type:`conjunction`}).format(x),[x,t.language]),C=n(()=>[{key:`at`,header:e(`recordings.activitySection.when`,`When`),nowrap:!0,sortValue:e=>e.at,render:e=>c(`span`,{className:`text-foreground-subtle tabular-nums`,children:qe(e.at)})},{key:`domain`,header:e(`recordings.activitySection.domain`,`Domain`),sortValue:e=>e.domain,render:e=>c(`span`,{className:`inline-flex rounded px-1.5 py-0.5 text-[10px] font-medium ${Ge[e.domain]}`,children:e.domain})},{key:`op`,header:e(`recordings.activitySection.operation`,`Operation`),sortValue:e=>e.op,render:e=>c(`span`,{className:`text-foreground`,children:e.op})},{key:`reason`,header:e(`recordings.activitySection.reason`,`Reason`),sortValue:e=>e.reason,render:e=>c(`span`,{className:`text-foreground-subtle`,children:e.reason})},{key:`device`,header:e(`recordings.activitySection.camera`,`Camera`),sortValue:e=>e.deviceId===null?`cluster`:y.get(e.deviceId)??`#${String(e.deviceId)}`,render:t=>t.deviceId===null?c(`span`,{className:`text-foreground-subtle`,children:e(`common.cluster`)}):c(`span`,{className:`text-foreground`,children:y.get(t.deviceId)??`#${String(t.deviceId)}`})},{key:`items`,header:e(`recordings.activitySection.items`,`Items`),align:`right`,nowrap:!0,sortValue:e=>e.itemsAffected,render:e=>c(`span`,{className:`tabular-nums`,children:e.itemsAffected.toLocaleString()})},{key:`bytes`,header:e(`recordings.activitySection.reclaimed`,`Reclaimed`),align:`right`,nowrap:!0,sortValue:e=>e.bytesReclaimed,render:e=>c(`span`,{className:`tabular-nums`,children:e.bytesReclaimed>0?W(e.bytesReclaimed):`—`})}],[y,e]),w=u||m;return a(`div`,{className:`flex flex-col gap-4`,children:[c(`div`,{className:`flex items-center gap-1`,children:We.map(t=>c(`button`,{onClick:()=>s(t.value),className:`rounded px-2 py-1 text-xs font-medium ${i===t.value?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-muted`}`,children:e(t.labelKey)},t.value))}),w&&b.length===0?a(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[c(v,{className:`h-4 w-4 animate-spin`}),e(`recordings.activitySection.loadingActivity`,`Loading activity…`)]}):b.length===0?x.length>0?c(I,{icon:p,title:e(`recordings.activitySection.activityCouldNotBeRead`,`Activity could not be read`),description:e(`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})}):c(I,{icon:_,title:e(`recordings.activitySection.noActivityYet`,`No activity yet`),description:e(`recordings.activitySection.pruneDeleteAndRescanOperations`,`Prune, delete and rescan operations across recordings and events show up here.`)}):a(o,{children:[x.length>0&&a(`p`,{className:`flex items-center gap-1.5 text-[11px] text-amber-500`,children:[c(p,{className:`h-3 w-3 shrink-0`}),e(`recordings.activitySection.domainsMissing`,{count:x.length,names:S})]}),c(j,{columns:C,rows:b,rowKey:e=>e.id,minWidthPx:720,maxBodyHeight:we,defaultSort:Ke})]})]})}e();function Ye(){let{t:e}=U(),t=B({isCamera:!0,projection:`slim`}),i=n(()=>(t.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[t.data]),[o,s]=r(null),u=o??i[0]?.id??null;return!t.isLoading&&i.length===0?c(I,{icon:l,title:e(`recordings.cameraRecordingSettingsSection.noCameras`,`No cameras`),description:e(`recordings.cameraRecordingSettingsSection.addACameraFirst`,`Add a camera first.`)}):a(`div`,{className:`space-y-3`,children:[a(`div`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.cameraRecordingSettingsSection.perCameraRecordingRetention`,`Per-camera recording & retention`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`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.`)})]}),a(`div`,{className:`flex items-center gap-2`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e(`recordings.cameraRecordingSettingsSection.camera`,`Camera`)}),c(`select`,{value:u??``,onChange:e=>s(Number(e.target.value)),className:`rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:i.map(e=>c(`option`,{value:e.id,children:e.name},e.id))})]}),u!==null&&c(ue,{deviceId:u,children:c(Ae,{deviceId:u,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},u)]})}e();function Xe({types:e}){let{t}=U(),i=s(),o=R(),{data:l}=z({}),u=A(),d=n(()=>u.data??[],[u.data]),{data:f}=ee({},{refetchOnWindowFocus:!1}),p=n(()=>He(l??[],f?.locations),[l,f?.locations]),[m,h]=r(null),[g,_]=r(null),v=()=>{i.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})},y=Ce({onSuccess:v}),b=se({onSuccess:v}),x=n(()=>{let e=new Map;for(let t of l??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[l]),S=async(e,n)=>{Le(n)&&!await o({title:t(`pipeline.storageLocationsPanel.disable`,`Disable "{{displayName}}"?`,{displayName:e.displayName}),message:t(`pipeline.storageLocationsPanel.nothingIsDeletedSetThe`,`{{consequence}} Nothing is deleted — set the location back to Read-only or Active to bring its footage back.`,{consequence:Fe(n).consequence}),confirmLabel:t(`common.disable`,`Disable`),variant:`danger`})||y.mutate(Ve(e,{mode:n}))},C=async e=>{if(await o({title:t(`pipeline.storageLocationsPanel.deleteLocation`,`Delete location "{{displayName}}"?`,{displayName:e.displayName}),message:t(`pipeline.storageLocationsPanel.removesTheRecordFilesOn`,`Removes the record; files on disk are untouched.`),confirmLabel:t(`common.delete`,`Delete`),variant:`danger`}))try{await b.mutateAsync({id:e.id})}catch(n){await o({title:t(`pipeline.storageLocationsPanel.deleteAnyway`,`Delete anyway?`),message:t(`pipeline.storageLocationsPanel.forcingNote`,{error:n instanceof Error?n.message:String(n)}),confirmLabel:t(`pipeline.storageLocationsPanel.forceDelete`,`Force delete`),variant:`danger`})&&b.mutate({id:e.id,force:!0})}},w=e.map(e=>d.find(t=>t.id===e)).filter(e=>e!==void 0);return a(`div`,{className:`space-y-3`,children:[w.length===0?c(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:t(`pipeline.storageLocationsPanel.noStorageLocationsDeclaredFor`,`No storage locations declared for this purpose.`)}):w.map(e=>c(Re,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:x.get(e.id)??[],onAdd:e=>h(e),onEdit:e=>_(e),onDelete:e=>{C(e)},ownedBytesById:p,onSetMode:(e,t)=>{S(e,t)}},e.id)),m!==null&&c(Ue,{initialType:m,onClose:()=>h(null),onCreated:()=>{v(),h(null)}}),g!==null&&c(ze,{location:g,onClose:()=>_(null),onSaved:()=>{v(),_(null)}})]})}e();var Ze=`pipeline-analytics`;function Qe(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 $e(){let{t:e}=U(),t=s(),{nodes:r}=Oe(),{data:i,isLoading:o}=pe({addonId:Ze}),l=Qe(i),u=he({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),d=n(()=>{let e=r.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,l,...e])].filter(Boolean)},[r,l]);return a(`div`,{className:`flex flex-col gap-6`,children:[a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h3`,{className:`text-sm font-semibold text-foreground`,children:e(`pipeline.clusterEventsTab.postProcessingNode`,`Post-processing node`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`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.`)}),a(`div`,{className:`mt-3 flex items-center gap-2`,children:[o?c(v,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):c(`select`,{value:l,onChange:e=>{e.target.value!==l&&u.mutate({addonId:Ze,patch:{postProcessingNodeId:e.target.value}})},disabled:u.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:d.map(t=>c(`option`,{value:t,children:t===`hub`?e(`pipeline.clusterEventsTab.hubDefault`,`hub (default)`):t},t))}),u.isPending&&c(v,{className:`h-4 w-4 animate-spin text-primary`})]})]}),a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:e(`pipeline.clusterEventsTab.eventsFolder`,`Events folder`)}),c(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:e(`pipeline.clusterEventsTab.whereEventCropsFullFrames`,`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`)}),c(Xe,{types:[`eventMedia`]})]})]})}e();var et=[[`pipelineAnalytics`]],tt=1440*60*1e3;function G(e,t){return t.get(e)??H.t(`recordings.eventsManagementSection.removedCamera`,{id:String(e)})}var nt=[{days:1},{days:7},{days:30},{days:90}];function rt(){let{t:e}=U(),t=s(),o=R(),[l,u]=r(30),[p,m]=r(null),{data:g,isLoading:_}=xe({},{refetchOnWindowFocus:!1}),{data:y}=B({isCamera:!0,projection:`slim`}),b=n(()=>{let e=new Map;for(let t of y??[])e.set(t.id,t.name);return e},[y]),x=i(()=>{t.invalidateQueries({queryKey:et})},[t]),S=ge({onSuccess:x}),C=ve(),T=i(async()=>{await o({title:e(`recordings.eventsManagementSection.pruneTitle`,{count:l}),message:e(`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:e(`recordings.eventsManagementSection.pruneEvents`,`Prune events`),variant:`danger`})&&S.mutate({olderThanMs:Date.now()-l*tt,reason:`retention`})},[o,S,l,e]),E=i(async t=>{let n=G(t.deviceId,b);if(await o({title:e(`recordings.eventsManagementSection.deleteAllEventsFor`,`Delete all events for {{label}}?`,{label:n}),message:e(`recordings.eventsManagementSection.deleteRowsMessage`,{count:t.rows,size:W(t.bytes)}),confirmLabel:e(`recordings.eventsManagementSection.deleteEvents`,`Delete events`),variant:`danger`})){m(null);try{let e=await C.mutateAsync({deviceId:t.deviceId});x();let r=e.motion+e.object+e.audio;if(r===0&&t.bytes>0){m(`0 events deleted for ${n}. Media still listed (${W(t.bytes)}) — those blobs are not event rows; use Management → Count leftovers or Disk reconcile.`);return}m(`Deleted ${String(r)} event${r===1?``:`s`} for ${n}.`)}catch(e){m(e instanceof Error?e.message:String(e))}}},[o,C,b,x,e]),D=n(()=>[{key:`camera`,header:e(`recordings.eventsManagementSection.camera`,`Camera`),render:e=>c(`span`,{className:`text-foreground`,children:G(e.deviceId,b)})},{key:`rows`,header:e(`recordings.eventsManagementSection.events`,`Events`),align:`right`,nowrap:!0,render:e=>c(`span`,{className:`tabular-nums`,children:e.rows.toLocaleString()})},{key:`bytes`,header:e(`recordings.eventsManagementSection.media`,`Media`),align:`right`,nowrap:!0,render:e=>c(`span`,{className:`tabular-nums`,children:W(e.bytes)})},{key:`actions`,header:``,align:`right`,render:t=>a(`button`,{onClick:()=>{E(t)},disabled:C.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:e(`recordings.eventsManagementSection.deleteAllEventsForThis`,`Delete all events for this camera`),children:[c(d,{className:`h-3 w-3`}),e(`common.delete`,`Delete`)]})}],[b,E,C.isPending,e]);return _&&!g?a(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[c(v,{className:`h-4 w-4 animate-spin`}),e(`recordings.eventsManagementSection.loadingEventStoreFootprint`,`Loading event-store footprint…`)]}):g?a(`div`,{className:`flex flex-col gap-6`,children:[a(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[c(h,{label:e(`recordings.eventsManagementSection.totalEvents`,`Total events`),icon:c(f,{className:`h-3 w-3`}),footer:`across ${String(g.devices.length)} camera${g.devices.length===1?``:`s`}`,children:g.totalRows.toLocaleString()}),c(h,{label:e(`recordings.eventsManagementSection.eventMediaOnDisk`,`Event media on disk`),children:W(g.totalBytes)})]}),a(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[c(`span`,{className:`text-foreground-subtle`,children:e(`recordings.eventsManagementSection.pruneEventsOlderThan`,`Prune events older than`)}),c(`select`,{value:l,onChange:e=>u(Number(e.target.value)),className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:nt.map(t=>c(`option`,{value:t.days,children:e(`recordings.eventsManagementSection.ageDays`,{count:t.days})},t.days))}),a(`button`,{onClick:()=>{T()},disabled:S.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:[S.isPending?c(v,{className:`h-3 w-3 animate-spin`}):c(w,{className:`h-3 w-3`}),e(`recordings.eventsManagementSection.pruneNow`,`Prune now`)]})]}),g.devices.length===0?c(I,{icon:f,title:e(`recordings.eventsManagementSection.noStoredEvents`,`No stored events`),description:e(`recordings.eventsManagementSection.noCameraHasPersistedEvents`,`No camera has persisted events yet.`)}):c(j,{columns:D,rows:[...g.devices],rowKey:e=>e.deviceId,minWidthPx:480}),p===null?null:c(`p`,{className:p.startsWith(`Deleted `)?`text-[11px] text-foreground-subtle`:`text-[11px] text-destructive`,children:p})]}):c(I,{icon:f,title:e(`recordings.eventsManagementSection.noEventData`,`No event data`),description:e(`recordings.eventsManagementSection.pipelineAnalyticsHasNotReported`,`Pipeline analytics has not reported any event-store footprint yet.`)})}function it(){let{t:e}=U();return a(`div`,{className:`flex flex-col gap-8`,children:[a(`div`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.eventsSection.eventStore`,`Event store`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`recordings.eventsSection.whatTheDurableEventStore`,`What the durable event store occupies, per camera, with fleet-wide prune-by-age and delete-all-events.`)}),c(`div`,{className:`mt-3`,children:c(rt,{})})]}),a(`div`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.eventsSection.postProcessingNodeFolders`,`Post-processing node & folders`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`recordings.eventsSection.theSingleNodeThatWrites`,`The single node that writes event crops, and the storage location they land in.`)}),c(`div`,{className:`mt-3`,children:c($e,{})})]})]})}function at(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 ot(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function st(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`${ot(e)} · ${o}`}function ct(e,t){let n=e-t;if(n<=0)return H.t(`helpers.exportFormat.expired`);let r=Math.floor(n/6e4);if(r<60)return H.t(`helpers.exportFormat.inMinutes`,{n:String(r)});let i=Math.floor(r/60);return i<24?H.t(`helpers.exportFormat.inHours`,{n:String(i)}):H.t(`helpers.exportFormat.inDays`,{n:String(Math.floor(i/24))})}function lt(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})}e();var ut=[`high`,`mid`,`low`],dt=[{value:1,labelKey:`recordings.newExportModal.speedRealTime`},{value:2,labelKey:null},{value:4,labelKey:null},{value:8,labelKey:null},{value:16,labelKey:null}],ft=10080*60*1e3;function K(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 pt({onClose:e,onCreated:t}){let{t:i}=U(),o=B({isCamera:!0,projection:`slim`}),s=n(()=>(o.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[o.data]),[l,d]=r(``),[f,p]=r(`high`),[m,h]=r(K(60)),[g,_]=r(K(0)),[v,y]=r(1),[b,x]=r(!0),[S,C]=r(``),[w,T]=r(null),D=l===``?s[0]?.id??null:l,O=new Date(m).getTime(),k=new Date(g).getTime(),A=Number.isFinite(O)&&Number.isFinite(k)&&O<k,j=M({onSuccess:()=>{t(),e()},onError:e=>T(e instanceof Error?e.message:String(e))});return c(te,{open:!0,onOpenChange:t=>!t&&e(),children:a(E,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[c(F,{children:a(re,{className:`flex items-center gap-1.5`,children:[c(u,{className:`h-3.5 w-3.5`}),i(`recordings.newExportModal.newExport`,`New export`)]})}),a(be,{className:`space-y-3`,children:[a(`div`,{className:`grid grid-cols-2 gap-3`,children:[a(`div`,{className:`space-y-1`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:i(`recordings.newExportModal.camera`,`Camera`)}),c(`select`,{value:D??``,onChange:e=>d(Number(e.target.value)),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:s.map(e=>c(`option`,{value:e.id,children:e.name},e.id))})]}),a(`div`,{className:`space-y-1`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:i(`recordings.newExportModal.profile`,`Profile`)}),c(`select`,{value:f,onChange:e=>p(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:ut.map(e=>c(`option`,{value:e,children:e},e))})]})]}),a(`div`,{className:`grid grid-cols-2 gap-3`,children:[a(`div`,{className:`space-y-1`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:i(`recordings.newExportModal.from`,`From`)}),c(`input`,{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`})]}),a(`div`,{className:`space-y-1`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:i(`recordings.newExportModal.to`,`To`)}),c(`input`,{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`})]})]}),a(`div`,{className:`grid grid-cols-2 gap-3`,children:[a(`div`,{className:`space-y-1`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:i(`recordings.newExportModal.speed`,`Speed`)}),c(`select`,{value:v,onChange:e=>y(Number(e.target.value)),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:dt.map(e=>c(`option`,{value:e.value,children:e.labelKey===null?`${e.value}×`:i(e.labelKey)},e.value))})]}),a(`div`,{className:`space-y-1`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:i(`recordings.newExportModal.titleOptional`,`Title (optional)`)}),c(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:i(`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`})]})]}),a(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[c(`input`,{type:`checkbox`,checked:b,disabled:v!==1,onChange:e=>x(e.target.checked),className:`accent-primary`}),i(v===1?`recordings.newExportModal.includeAudio`:`recordings.newExportModal.includeAudioRealtimeOnly`)]}),!A&&c(`p`,{className:`text-[11px] text-danger`,children:i(`recordings.newExportModal.fromMustBeBeforeTo`,`"From" must be before "To".`)}),w&&c(`p`,{className:`text-[11px] text-danger`,children:w})]}),a(P,{children:[c(oe,{variant:`outline`,size:`sm`,onClick:e,children:i(`common.cancel`,`Cancel`)}),c(oe,{size:`sm`,onClick:()=>{if(D===null||!A)return;T(null);let e=S.trim();j.mutate({deviceId:D,profile:f,fromMs:O,toMs:k,options:{includeAudio:b,maxLifeMs:ft,deleteAfterDownload:!1,...v===1?{}:{speed:v},...e.length>0?{title:e}:{}}})},disabled:D===null||!A||j.isPending,children:j.isPending?i(`recordings.newExportModal.queuing`,`Queuing…`):i(`recordings.newExportModal.createExport`,`Create export`)})]})]})})}e();var mt=[[`recordingExport`]],ht={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 gt(){let{data:e,isLoading:t}=ke({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:r}=V(S.RecordingExportProgress,e=>e.exportId),{map:i}=V(S.RecordingExportCompleted,e=>e.exportId),{map:a}=V(S.RecordingExportFailed,e=>e.exportId);return{rows:n(()=>lt(e??[],r,i,a),[e,r,i,a]),isLoading:t}}function _t(e){let[n,i]=r(()=>Date.now());return t(()=>{let t=setInterval(()=>i(Date.now()),e);return()=>clearInterval(t)},[e]),n}function vt(){let{t:e}=U(),t=s(),[o,l]=r(!1),f=()=>{t.invalidateQueries({queryKey:[[`recordingExport`,`listExports`]]})},p=R(),h=y().trpcClient,g=_t(6e4),{rows:_,isLoading:x}=gt(),{data:S}=B({isCamera:!0,projection:`slim`}),C=n(()=>{let e=new Map;for(let t of S??[])e.set(t.id,t.name);return e},[S]),w=i(()=>{t.invalidateQueries({queryKey:mt})},[t]),T=k({onSuccess:w}),E=ae({onSuccess:w}),[D,O]=r(null),A=i(async e=>{O(e.id);try{let{url:t}=await h.recordingExport.getDownloadUrl.query({exportId:e.id}),n=await Pe(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),w()}finally{O(null)}},[h,w]),M=i(async t=>{await p({title:e(`recordings.exportsSection.cancelThisExport`,`Cancel this export?`),message:e(`recordings.exportsSection.stopsTheRenderThePartial`,`Stops the render. The partial file is discarded.`),confirmLabel:e(`recordings.exportsSection.cancelExport`,`Cancel export`),variant:`danger`})&&T.mutate({exportId:t.id})},[p,T,e]),N=i(async t=>{await p({title:e(`recordings.exportsSection.deleteThisExport`,`Delete this export?`),message:e(`recordings.exportsSection.permanentlyRemovesTheRenderedFile`,`Permanently removes the rendered file and its history row.`),confirmLabel:e(`common.delete`,`Delete`),variant:`danger`})&&E.mutate({exportId:t.id})},[p,E,e]),P=n(()=>[{key:`camera`,header:e(`recordings.exportsSection.camera`,`Camera`),render:e=>c(`span`,{className:`text-foreground`,children:C.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:e(`recordings.exportsSection.range`,`Range`),nowrap:!0,render:e=>c(`span`,{className:`tabular-nums`,children:st(e.fromMs,e.toMs)})},{key:`variant`,header:e(`recordings.exportsSection.variant`,`Variant`),render:e=>c(`span`,{className:`text-foreground-subtle`,children:at(e.options)})},{key:`state`,header:e(`recordings.exportsSection.state`,`State`),render:t=>{let n=ht[t.state];return a(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${n.cls}`,children:[n.spin&&c(v,{className:`h-2.5 w-2.5 animate-spin`}),e(n.labelKey),t.state===`rendering`&&t.progressPct!==null&&a(`span`,{className:`tabular-nums`,children:[t.progressPct,`%`]})]})}},{key:`expiry`,header:e(`recordings.exportsSection.expires`,`Expires`),nowrap:!0,render:e=>e.state===`deleted`?c(`span`,{className:`text-foreground-subtle`,children:`—`}):c(`span`,{className:`text-foreground-subtle tabular-nums`,children:ct(e.expiresAt,g)})},{key:`size`,header:e(`recordings.exportsSection.size`,`Size`),align:`right`,nowrap:!0,render:e=>c(`span`,{className:`tabular-nums`,children:e.fileBytes===null?`—`:W(e.fileBytes)})},{key:`actions`,header:``,align:`right`,render:t=>{let n=t.state===`ready`,r=t.state===`queued`||t.state===`rendering`,i=t.state!==`deleted`;return a(`div`,{className:`flex items-center justify-end gap-1`,children:[n&&a(`button`,{onClick:()=>{A(t)},disabled:D===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:e(`recordings.exportsSection.downloadMp4`,`Download MP4`),children:[D===t.id?c(v,{className:`h-3 w-3 animate-spin`}):c(m,{className:`h-3 w-3`}),e(`recordings.exportsSection.download`,`Download`)]}),r&&a(`button`,{onClick:()=>{M(t)},disabled:T.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:e(`recordings.exportsSection.cancelRender`,`Cancel render`),children:[c(b,{className:`h-3 w-3`}),e(`common.cancel`,`Cancel`)]}),i&&c(`button`,{onClick:()=>{N(t)},disabled:E.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:e(`recordings.exportsSection.deleteExport`,`Delete export`),children:c(d,{className:`h-3 w-3`})})]})}}],[C,g,D,T.isPending,E.isPending,A,M,N,e]);return x&&_.length===0?a(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[c(v,{className:`h-4 w-4 animate-spin`}),e(`recordings.exportsSection.loadingExports`,`Loading exports…`)]}):a(`div`,{className:`space-y-3`,children:[c(`div`,{className:`flex justify-end`,children:a(`button`,{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:[c(u,{className:`h-3.5 w-3.5`}),e(`recordings.exportsSection.newExport`,`New export`)]})}),_.length===0?c(I,{icon:u,title:e(`recordings.exportsSection.noExportsYet`,`No exports yet`),description:e(`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.`)}):c(j,{columns:P,rows:_,rowKey:e=>e.id,minWidthPx:720}),o&&c(pt,{onClose:()=>l(!1),onCreated:f})]})}var yt=`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`;e();var bt=`storage-migration`,xt=new Set([`orphans`,`debug-media`,`ghost-ledger`]);function St(e){return[`${e.orphansReclaimed} orphan rows (${W(e.orphanBytesReclaimed)})`,e.includeDebugMedia?`${e.debugMediaReclaimed} debug files (${W(e.debugMediaBytesReclaimed)})`:null,`${e.ghostsForgotten} ghost rows (${W(e.ghostBytesForgotten)})`].filter(e=>e!==null).join(` · `)}function Ct(){let{t:e}=U(),t=L(bt);return t===`pending`?null:t===`unknown`?c(`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`?c(wt,{}):null}function wt(){let{t:e}=U(),t=R(),[n,i]=r(!1),[o,s]=r(null),l=ie({},{refetchInterval:2e3}),u=l.data??null,f=u!==null&&xt.has(u.phase),p=fe(),m=ce(),h=async()=>{if(await t({title:e(`recordings.cleanupSection.runStorageCleanup`,`Run storage cleanup?`),message:n?e(`recordings.cleanupSection.reclaimsLeftoverAnalyticsRowsAnd`,`Reclaims leftover analytics rows and files, debug stills/filmstrips, and ghost footage rows on frozen locations. Safe to re-run.`):e(`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:e(`recordings.cleanupSection.runCleanup`,`Run cleanup`),variant:`danger`})){s(null);try{await p.mutateAsync({includeDebugMedia:n}),await l.refetch()}catch(e){s(e instanceof Error?e.message:String(e))}}},g=async()=>{if(u&&await t({title:e(`recordings.cleanupSection.cancelCleanup`,`Cancel cleanup?`),message:e(`recordings.cleanupSection.stopsAfterTheCurrentStep`,`Stops after the current step. Work already done stays done.`),confirmLabel:e(`recordings.cleanupSection.cancelCleanup2`,`Cancel cleanup`),variant:`danger`}))try{await m.mutateAsync({jobId:u.jobId}),await l.refetch()}catch{}};return a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.cleanupSection.cleanup`,`Cleanup`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`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.`)}),a(`label`,{className:`mt-3 flex items-start gap-2 text-[11px] text-foreground`,children:[c(`input`,{type:`checkbox`,checked:n,disabled:f,onChange:e=>{i(e.target.checked)},className:`mt-0.5 h-3.5 w-3.5 accent-primary`}),c(`span`,{children:e(`recordings.cleanupSection.alsoRemoveDebugMediaMotion`,`Also remove debug media (motion stills and track filmstrips)`)})]}),a(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[a(`button`,{type:`button`,disabled:f||p.isPending,onClick:()=>{h()},className:yt,children:[(f||p.isPending)&&c(v,{className:`h-3 w-3 animate-spin`}),c(d,{className:`h-3 w-3`}),e(`recordings.cleanupSection.runCleanup`,`Run cleanup`)]}),f&&c(`button`,{type:`button`,onClick:()=>{g()},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:e(`common.cancel`,`Cancel`)})]}),o&&c(`p`,{className:`mt-2 text-[11px] text-danger`,children:o}),u&&a(`div`,{className:`mt-3 space-y-1 rounded-md border border-border px-2.5 py-2`,children:[a(`p`,{className:`text-xs text-foreground`,children:[e(`recordings.cleanupSection.phase`,`Phase:`),` `,c(`span`,{className:`font-medium`,children:u.phase}),f&&c(v,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),u.detail&&c(`p`,{className:`text-[11px] text-foreground-subtle`,children:u.detail}),c(`p`,{className:`text-[11px] text-foreground-subtle`,children:St(u)}),u.error&&c(`p`,{className:`text-[11px] text-danger`,children:u.error})]})]})}e();var Tt=2e3;function Et(){let{t:e}=U(),n=R(),r=s(),i=de(),o=O(void 0,{refetchInterval:e=>e.state.data?.state===`running`?Tt:!1}),l=o.data,u=l?.state===`running`,d=u||i.isPending;t(()=>{l?.state!==`done`||l.finishedAtMs===null||(r.invalidateQueries({queryKey:[[`recording`]]}),r.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[l?.state,l?.finishedAtMs,r]);let f=async()=>{await n({title:e(`recordings.diskReconcileSection.reconcileStorageFromDisk`,`Reconcile storage from disk?`),message:e(`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:e(`recordings.diskReconcileSection.reconcile`,`Reconcile`),variant:`warning`})&&(await i.mutateAsync(),await o.refetch())},p=u?l.total>0?`Reconciling ${String(l.completed)}/${String(l.total)}…`:`Reconciling…`:i.isPending?`Reconciling…`:`Reconcile from disk`;return a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h3`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.diskReconcileSection.diskReconcile`,`Disk reconcile`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`recordings.diskReconcileSection.deletesDatabaseRowsWhoseFiles`,`Deletes database rows whose files are gone. Enrolled identities stay.`)}),a(`div`,{className:`mt-3 flex flex-col gap-2`,children:[a(`button`,{type:`button`,onClick:()=>void f(),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?c(v,{className:`h-3.5 w-3.5 animate-spin`}):c(x,{className:`h-3.5 w-3.5`}),p]}),l?.state===`done`?a(`p`,{className:`text-[11px] text-foreground-subtle`,children:[e(`recordings.diskReconcileSection.lastRun`,`Last run:`),` `,e(`recordings.diskReconcileSection.summary`,{completed:String(l.completed),tracks:String(l.tracks),events:String(l.events),media:String(l.mediaDropped)}),l.failed.length>0?e(`recordings.diskReconcileSection.failed`,`, {{value1}} failed ({{value2}})`,{value1:String(l.failed.length),value2:l.failed.join(`, `)}):``,`.`]}):null,l?.state===`error`&&l.error!==null?a(`p`,{className:`text-[11px] text-destructive`,children:[e(`recordings.diskReconcileSection.reconcileFailed`,`Reconcile failed:`),` `,l.error]}):null]})]})}var q=1e3,J=60*q,Y=60*J;function X(e){return e.toLocaleString(`en-US`)}function Dt(e){if(!Number.isFinite(e)||e<0)return`—`;if(e>=Y){let t=Math.floor(e/Y),n=Math.round(e%Y/J);return`${t.toString()}h ${n.toString()}m`}if(e>=J){let t=Math.floor(e/J),n=Math.round(e%J/q);return`${t.toString()}m ${n.toString()}s`}return`${Math.max(0,Math.round(e/q)).toString()}s`}function Ot(e){let t=Math.max(0,e.observedAt-e.startedAt),n=e.filesTotal===null?`${X(e.filesMoved)} files`:`${X(e.filesMoved)} / ${X(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?`${W(e.bytesMoved/t*q)}/s`:null,o=e.filesTotal===null?null:e.filesTotal-e.filesMoved,s=!i||o===null||o<=0?null:`~${Dt(o*t/e.filesMoved)} left`;return{counted:n,fraction:r,moved:`${W(e.bytesMoved)} moved`,rate:a,eta:s}}function kt(e){let t=Ot(e);return[t.counted,t.moved,t.rate,t.eta].filter(e=>e!==null).join(` · `)}e();var At=`storage-migration`,Z=[{id:`recordings`,labelKey:`recordings.storageMigrationSection.classRecordings`,locationType:`recordings`},{id:`recordingsLow`,labelKey:`recordings.storageMigrationSection.classRecordingsLow`,locationType:`recordingsLow`},{id:`eventMedia`,labelKey:`recordings.storageMigrationSection.classEventMedia`,locationType:`eventMedia`}],jt=new Set([`planning`,`sealing`,`pausing`,`moving`,`draining`,`verifying`,`repointing`,`refreshing`,`resuming`]);function Mt(){let{t:e}=U(),t=L(At);return t===`pending`?a(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[c(v,{className:`h-4 w-4 animate-spin`}),e(`migration.storageMigrationSection.checkingWhetherStorageMigrationIs`,`Checking whether storage migration is installed…`)]}):t===`unknown`?c(I,{icon:p,title:e(`migration.storageMigrationSection.couldnTCheckWhetherStorage`,`Couldn't check whether storage migration is installed`),description:e(`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.`)}):t===`absent`?c(I,{icon:C,title:e(`migration.storageMigrationSection.storageMigrationNotInstalled`,`Storage migration not installed`),description:e(`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.`)}):c(Nt,{})}function Nt(){let{t:e}=U(),t=R(),{data:i}=z({}),[o,s]=r({}),[l,u]=r({}),[d,f]=r(null),[p,m]=r(null),h=n(()=>{let e=new Map;for(let t of i??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[i]),_=n(()=>{let e=new Map;for(let t of i??[]){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},[i]),y=me({},{refetchInterval:2e3}),b=y.data??null,x=b!==null&&jt.has(b.phase),S=n(()=>{let e={};for(let t of Z){let n=o[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[o]),w=n(()=>{let e={};for(let t of Z){if(!o[t.id])continue;let n=l[t.id]??_.get(t.locationType);n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[o,l,_]),T=n(()=>({destinations:S??{},...w?{sources:w}:{}}),[S,w]),E=Se(T,{enabled:!1,retry:!1}),D=ye(),O=le(),k=async()=>{if(!S)return;m(null);let e=await E.refetch();if(e.error){m(e.error instanceof Error?e.error.message:String(e.error));return}f(e.data??null)},A=async()=>{if(S&&await t({title:e(`migration.storageMigrationSection.startStorageMigration`,`Start storage migration?`),message:e(`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:e(`migration.storageMigrationSection.startMigration`,`Start migration`),variant:`danger`})){m(null);try{await D.mutateAsync(T),f(null),await y.refetch()}catch(e){m(e instanceof Error?e.message:String(e))}}},j=async()=>{if(b&&await t({title:e(`migration.storageMigrationSection.cancelMigration`,`Cancel migration?`),message:e(`migration.storageMigrationSection.stopsTheInProgressMigration`,`Stops the in-progress migration. Data already moved and verified stays at the destination; anything already repointed is not reverted.`),confirmLabel:e(`migration.storageMigrationSection.cancelMigration2`,`Cancel migration`),variant:`danger`}))try{await O.mutateAsync({jobId:b.jobId}),await y.refetch()}catch{}};return a(`div`,{className:`flex flex-col gap-6`,children:[a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[a(`h3`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[c(C,{className:`h-3.5 w-3.5`}),e(`migration.storageMigrationSection.storageMigration`,`Storage migration`)]}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`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.`)}),c(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-3`,children:Z.map(t=>{let n=h.get(t.locationType)??[],r=_.get(t.locationType)??``;return a(`div`,{className:`space-y-2`,children:[c(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e(t.labelKey)}),a(`div`,{className:`space-y-1`,children:[c(`label`,{htmlFor:`migration-from-${t.id}`,className:`text-[10px] text-foreground-subtle`,children:e(`recordings.storageMigrationSection.classFrom`,{label:e(t.labelKey)})}),c(`select`,{id:`migration-from-${t.id}`,value:l[t.id]??r,onChange:e=>{let n=e.target.value;u(e=>({...e,[t.id]:n}))},disabled:x,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground disabled:opacity-50`,children:n.map(t=>a(`option`,{value:t.id,children:[t.displayName,t.enabled===!1?` (${e(`recordings.storageMigrationSection.readOnly`)})`:``]},t.id))})]}),a(`div`,{className:`space-y-1`,children:[c(`label`,{htmlFor:`migration-dest-${t.id}`,className:`text-[10px] text-foreground-subtle`,children:e(`recordings.storageMigrationSection.classTo`,{label:e(t.labelKey)})}),a(`select`,{id:`migration-dest-${t.id}`,value:o[t.id]??``,onChange:e=>{let n=e.target.value;s(e=>({...e,[t.id]:n}))},disabled:x,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground disabled:opacity-50`,children:[c(`option`,{value:``,children:e(`migration.storageMigrationSection.skip`,`— skip —`)}),n.map(e=>c(`option`,{value:e.id,children:e.displayName},e.id))]})]})]},t.id)})}),p&&c(`p`,{className:`mt-2 text-[11px] text-danger`,children:p}),a(`div`,{className:`mt-3 flex items-center gap-2`,children:[a(`button`,{type:`button`,onClick:()=>{k()},disabled:!S||E.isFetching||x,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:[E.isFetching&&c(v,{className:`h-3 w-3 animate-spin`}),e(`migration.storageMigrationSection.plan`,`Plan`)]}),a(`button`,{type:`button`,onClick:()=>{A()},disabled:!S||D.isPending||x,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:[D.isPending&&c(v,{className:`h-3 w-3 animate-spin`}),e(`migration.storageMigrationSection.startMigration`,`Start migration`)]})]}),d&&c(`div`,{className:`mt-3 divide-y divide-border rounded-md border border-border`,children:d.moves.length===0?c(`p`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:e(`migration.storageMigrationSection.nothingToMoveSelectedDestinations`,`Nothing to move — selected destinations match the current defaults.`)}):d.moves.map(e=>a(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground`,children:[e.storageClass,`: `,e.fromLocationId,` → `,e.toLocationId]},`${e.storageClass}-${e.toLocationId}`))}),b&&a(`div`,{className:`mt-4 border-t border-border pt-3`,children:[a(`div`,{className:`flex items-center justify-between`,children:[c(`h4`,{className:`text-xs font-semibold text-foreground`,children:e(`migration.storageMigrationSection.migrationStatus`,`Migration status`)}),x&&a(`button`,{type:`button`,onClick:()=>{j()},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:[c(g,{className:`h-3 w-3`}),e(`common.cancel`,`Cancel`)]})]}),a(`p`,{className:`mt-1 text-xs text-foreground`,children:[e(`migration.storageMigrationSection.phase`,`Phase:`),` `,c(`span`,{className:`font-medium`,children:b.phase}),x&&c(v,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),b.error&&c(`p`,{className:`mt-1 text-[11px] text-danger`,children:b.error}),b.pausedParticipants.length>0&&a(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[e(`migration.storageMigrationSection.paused`,`Paused:`),` `,b.pausedParticipants.join(`, `)]}),c(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:b.moves.map(e=>c(Pt,{move:e},`${e.storageClass}-${e.fromLocationId}`))})]}),c(Ft,{})]}),c(It,{running:x}),c(Rt,{})]})}function Pt({move:e}){let{t}=U(),n=e.progress===null?null:Ot(e.progress);return a(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[a(`div`,{className:`flex items-center justify-between`,children:[a(`span`,{className:`text-foreground`,children:[e.storageClass,`: `,e.fromLocationId,` → `,e.toLocationId]}),a(`span`,{className:`text-foreground-subtle`,children:[e.state??t(`common.pending`),e.error?` (${e.error})`:``]})]}),e.progress!==null&&a(`div`,{className:`mt-1 space-y-1`,children:[n!==null&&n.fraction!==null&&c(`div`,{className:`h-1 w-full overflow-hidden rounded bg-border`,children:c(`div`,{className:`h-full bg-primary`,style:{width:`${(n.fraction*100).toFixed(1)}%`}})}),c(`p`,{className:`text-[10px] text-foreground-subtle`,children:kt(e.progress)})]})]})}function Ft(){let{t:e}=U(),{data:t}=_e({});return!t||t.length===0?null:a(`div`,{className:`mt-4 border-t border-border pt-3`,children:[c(`h4`,{className:`text-xs font-semibold text-foreground`,children:e(`migration.storageMigrationSection.migrationHistory`,`Migration history`)}),c(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:t.map(e=>a(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:[c(`span`,{className:`font-medium text-foreground`,children:e.phase}),` · `,Object.entries(e.destinations).filter(e=>typeof e[1]==`string`).map(([e,t])=>`${e} → ${t}`).join(`, `),` · `,new Date(e.startedAt).toLocaleString()]},e.jobId))})]})}function It({running:e}){let{t}=U(),n=R(),i=Te({},{staleTime:1/0,refetchOnWindowFocus:!1}),o=T(),[s,l]=r(null),u=i.data??[];if(u.length===0)return null;let d=async e=>{if(await n({title:t(`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:t(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`),variant:`danger`})){l(null);try{await o.mutateAsync({classes:[e.storageClass]}),await i.refetch()}catch(e){l(e instanceof Error?e.message:String(e))}}};return a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[a(`div`,{className:`flex items-start justify-between gap-2`,children:[c(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`migration.storageMigrationSection.leftOnTheOldLocation`,`Left on the old location`)}),a(`div`,{className:`flex shrink-0 items-center gap-2`,children:[c(`span`,{className:`text-[10px] text-foreground-subtle`,children:i.dataUpdatedAt>0?t(`migration.storageMigrationSection.measured`,`Measured {{value1}}`,{value1:new Date(i.dataUpdatedAt).toLocaleTimeString()}):t(`migration.storageMigrationSection.measuredNever`,`Measured — never`)}),c(`button`,{type:`button`,onClick:()=>{i.refetch()},disabled:i.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:i.isFetching?t(`migration.storageMigrationSection.counting`,`Counting…`):t(`common.refresh`,`Refresh`)})]})]}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`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.`)}),c(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:t(`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.`)}),s&&c(`p`,{className:`mt-2 text-[11px] text-danger`,children:s}),c(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:u.map(n=>a(`div`,{className:`flex items-center justify-between gap-2 px-2.5 py-1.5 text-[11px]`,children:[a(`span`,{className:`text-foreground`,children:[n.storageClass,`: `,n.fromLocationId,` → `,n.toLocationId,c(`span`,{className:`ml-2 text-foreground-subtle`,children:Lt(n)})]}),c(`button`,{type:`button`,onClick:()=>{d(n)},disabled:e||o.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:t(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`)})]},`${n.storageClass}-${n.fromLocationId}`))})]})}function Lt(e){if(e.items===null)return H.t(`recordings.storageMigrationSection.residueUnknown`);let t=e.items.toLocaleString(`en-US`);return e.bytes===null?H.t(`recordings.storageMigrationSection.residueRows`,{count:e.items,items:t}):H.t(`recordings.storageMigrationSection.residueSegments`,{count:e.items,items:t,size:W(e.bytes)})}function Rt(){let{t:e}=U(),{data:t}=Ee({},{refetchInterval:2e3}),n=(t??[]).filter(e=>e.migrationJobId===null&&e.job.state===`running`);return n.length===0?null:a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h3`,{className:`text-sm font-semibold text-foreground`,children:e(`migration.storageMigrationSection.moversRunningOutsideAMigration`,`Movers running outside a migration`)}),c(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:n.map(e=>a(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[a(`div`,{className:`text-foreground`,children:[e.lane,`: `,e.job.fromLocationId,` → `,e.job.toLocationId]}),c(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:kt({filesMoved:e.job.filesMoved,filesTotal:e.job.filesTotal,bytesMoved:e.job.bytesMoved,startedAt:e.job.startedAt,observedAt:e.observedAt})})]},e.job.jobId))})]})}function zt(){let{t:e}=U();return a(`div`,{className:`flex flex-col gap-4`,children:[c(Ct,{}),c(Et,{}),a(`section`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.recordingsManagementSection.moveStorage`,`Move storage`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`recordings.recordingsManagementSection.copyRecordingsLowResRecordings`,`Copy recordings, low-res recordings or event media to a new location, verify, then repoint the default. Applies to every camera.`)}),c(`div`,{className:`mt-3`,children:c(Mt,{})})]})]})}e();var Bt=`recorder`;function Vt(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 Ht(){let{t:e}=U(),t=s(),{nodes:r}=Oe(),{data:i,isLoading:o}=pe({addonId:Bt}),l=Vt(i,`recordingNodeId`,`hub`),u=he({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),d=n(()=>{let e=r.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,l,...e])].filter(Boolean)},[r,l]);return a(`div`,{className:`flex flex-col gap-6`,children:[a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h3`,{className:`text-sm font-semibold text-foreground`,children:e(`pipeline.clusterRecordingTab.recordingNode`,`Recording node`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`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.`)}),a(`div`,{className:`mt-3 flex items-center gap-2`,children:[o?c(v,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):c(`select`,{value:l,onChange:e=>{e.target.value!==l&&u.mutate({addonId:Bt,patch:{recordingNodeId:e.target.value}})},disabled:u.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:d.map(t=>c(`option`,{value:t,children:t===`hub`?e(`pipeline.clusterRecordingTab.hubDefault`,`hub (default)`):t},t))}),u.isPending&&c(v,{className:`h-4 w-4 animate-spin text-primary`})]}),l!==`hub`&&c(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:c(je,{i18nKey:`pipeline.clusterRecordingTab.hubOnlyNote`,values:{node:l},components:{b:c(`span`,{className:`font-medium`})}})})]}),a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:e(`pipeline.clusterRecordingTab.recordingsFolders`,`Recordings folders`)}),c(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:e(`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.`)}),c(Xe,{types:[`recordings`,`recordingsLow`]})]})]})}function Ut(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function Q(e,t){let n=Ut(e);return n.length===0?H.t(`helpers.cameraDisk.defaultRoot`):n.map(e=>t.get(e)??e).join(` + `)}function Wt(e,t,n){if(e.length===0)return null;let r=e[0];if(e.length===1&&r!==void 0)return{label:Q(r,t),exact:!0};if(n===null)return null;let i=e.find(e=>Ut(e).includes(n));return i===void 0?null:{label:Q(i,t),exact:!1}}e();var Gt=[[`recording`]],Kt=[{value:`retention`,labelKey:`recordings.storageSection.pruneRetention`},{value:`quota`,labelKey:`recordings.storageSection.pruneQuota`},{value:`operator`,labelKey:`recordings.storageSection.pruneOperator`}],qt={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Jt={ok:`text-foreground-subtle`,warn:`text-amber-500`,critical:`text-danger`};function $(e){return`${String(Math.round(e*100))}%`}function Yt(e){return e==null?`—`:new Date(e).toLocaleString()}function Xt(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(` + `):H.t(`recordings.storageSection.defaultRoot`):e.root}function Zt(){let{t:e}=U(),t=s(),o=R(),[l,u]=r(`retention`),{data:f,isLoading:p}=ee({},{refetchOnWindowFocus:!1}),{data:m}=B({isCamera:!0,projection:`slim`}),{data:g}=z({}),_=n(()=>{let e=new Map;for(let t of m??[])e.set(t.id,t.name);return e},[m]),y=n(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.displayName);return e},[g]),b=n(()=>{let e=g??[];return e.find(e=>e.type===`recordings`&&e.enabled!==!1)?.id??e.find(e=>e.type===`recordings`)?.id??null},[g]),S=n(()=>f?.locations??[],[f?.locations]),C=n(()=>Wt(S,y,b),[S,y,b]),T=n(()=>Ie(S),[S]),E=i(()=>{t.invalidateQueries({queryKey:Gt})},[t]),O=D({onSuccess:E}),k=N({onSuccess:E}),A=i(async t=>{await o({title:e(`recordings.storageSection.prune`,`Prune {{label}}?`,{label:_.get(t.deviceId)??`#${String(t.deviceId)}`}),message:e(`recordings.storageSection.appliesTheRetentionPolicyNow`,`Applies the retention policy now (reason: {{reason}}). Footage beyond the policy is permanently deleted.`,{reason:l}),confirmLabel:e(`recordings.storageSection.pruneNow`,`Prune now`),variant:`danger`})&&O.mutate({deviceId:t.deviceId,reason:l})},[o,O,l,_,e]),M=i(async t=>{await o({title:e(`recordings.storageSection.deleteAllFootageFor`,`Delete all footage for {{label}}?`,{label:_.get(t.deviceId)??`#${String(t.deviceId)}`}),message:e(`recordings.storageSection.permanentlyDeletesOfRecordedFootage`,`Permanently deletes {{value1}} of recorded footage for this camera. This cannot be undone.`,{value1:W(t.usedBytes)}),confirmLabel:e(`recordings.storageSection.delete`,`Delete {{value1}}`,{value1:W(t.usedBytes)}),variant:`danger`})&&k.mutate({deviceId:t.deviceId})},[o,k,_,e]),P=n(()=>[{key:`camera`,header:e(`recordings.storageSection.camera`,`Camera`),render:e=>c(`span`,{className:`text-foreground`,children:_.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`disk`,header:e(`recordings.storageSection.disk`,`Disk`),nowrap:!0,render:()=>C===null?c(`span`,{className:`text-foreground-subtle`,children:`—`}):a(`span`,{className:C.exact?`text-foreground`:`text-foreground-subtle`,title:C.exact?e(`recordings.storageSection.theOnlyRecordingsVolumeOn`,`The only recordings volume on this node — this camera can only be here.`):e(`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:[C.label,!C.exact&&c(`span`,{className:`ml-1 text-foreground-subtle`,children:e(`recordings.storageSection.default`,`(default)`)})]})},{key:`used`,header:e(`recordings.storageSection.used`,`Used`),align:`right`,nowrap:!0,render:e=>c(`span`,{className:`tabular-nums`,children:W(e.usedBytes)})},{key:`oldest`,header:e(`recordings.storageSection.oldestFootage`,`Oldest footage`),align:`right`,nowrap:!0,render:t=>c(`span`,{className:`tabular-nums text-foreground-subtle`,title:e(`recordings.storageSection.theOldestSegmentTheArchive`,`The oldest segment the ARCHIVE holds for this camera — the per-camera answer to 'is retention actually holding?'.`),children:Yt(t.oldestMs)})},{key:`actions`,header:``,align:`right`,render:t=>a(`div`,{className:`flex items-center justify-end gap-1`,children:[a(`button`,{onClick:()=>{A(t)},disabled:O.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:e(`recordings.storageSection.applyRetentionPolicyNow`,`Apply retention policy now`),children:[c(w,{className:`h-3 w-3`}),e(`recordings.storageSection.prune2`,`Prune`)]}),a(`button`,{onClick:()=>{M(t)},disabled:k.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:e(`recordings.storageSection.deleteAllFootage`,`Delete all footage`),children:[c(d,{className:`h-3 w-3`}),e(`common.delete`,`Delete`)]})]})}],[_,C,A,M,O.isPending,k.isPending,e]);if(p&&!f)return a(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[c(v,{className:`h-4 w-4 animate-spin`}),e(`recordings.storageSection.loadingStorageUsage`,`Loading storage usage…`)]});if(!f)return c(I,{icon:x,title:e(`recordings.storageSection.noStorageData`,`No storage data`),description:e(`recordings.storageSection.theRecordingNodeHasNot`,`The recording node has not reported any storage usage yet.`)});let F=f.devices.length;return a(`div`,{className:`flex flex-col gap-6`,children:[a(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[c(h,{label:e(`recordings.storageSection.totalUsed`,`Total used`),icon:c(x,{className:`h-3 w-3`}),footer:`${String(F)} camera${F===1?``:`s`} on ${f.nodeId}`,children:W(f.totalUsedBytes)}),T!==null&&T.severity!==null&&c(h,{label:e(`recordings.storageSection.freeOnRecordingsVolumes`,`Free on recordings volumes`),icon:c(x,{className:`h-3 w-3`}),footer:`across ${String(T.knownVolumes)} volume${T.knownVolumes===1?``:`s`} of ${W(T.totalBytes)}`+(T.unknownVolumes>0?` · ${String(T.unknownVolumes)} did not report capacity`:``),children:c(`span`,{className:`tabular-nums ${Jt[T.severity]}`,children:W(T.freeBytes)})}),S.map(t=>{let n=Be(t),r=t.locationId??t.root??`default`;return c(h,{label:e(`recordings.storageSection.disk2`,`Disk: {{label}}`,{label:Xt(t,y)}),footer:n===null?`${W(t.usedBytes)} of recordings · volume capacity unknown`:`${W(n.freeBytes)} free of ${W(n.totalBytes)} · ${W(t.usedBytes)} recordings (${$(n.recordingsFraction)})`,children:n===null?c(`span`,{className:`tabular-nums`,children:W(t.usedBytes)}):a(`div`,{className:`flex items-center gap-2`,title:e(`recordings.storageSection.volumeFillEverythingOnThe`,`Volume fill — everything on the disk, not only recordings. Warn at 85%, critical at 95%.`),children:[c(`div`,{className:`h-2 flex-1 overflow-hidden rounded bg-muted`,children:c(`div`,{className:`h-full rounded ${qt[n.severity]}`,style:{width:$(n.fraction)}})}),c(`span`,{className:`tabular-nums text-xs ${Jt[n.severity]}`,children:$(n.fraction)})]})},r)})]}),a(`section`,{className:`flex items-center gap-2 text-xs`,children:[c(`label`,{htmlFor:`prune-reason`,className:`text-foreground-subtle`,children:e(`recordings.storageSection.pruneReason`,`Prune reason`)}),c(`select`,{id:`prune-reason`,value:l,onChange:e=>{let t=Kt.find(t=>t.value===e.target.value);t&&u(t.value)},className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:Kt.map(t=>c(`option`,{value:t.value,children:e(t.labelKey)},t.value))})]}),F===0?c(I,{icon:x,title:f.devicesRead===`unavailable`?e(`recordings.storageSection.perCameraUsageUnavailable`,`Per-camera usage unavailable`):e(`recordings.storageSection.noRecordedFootage`,`No recorded footage`),description:f.devicesRead===`unavailable`?e(`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.`):e(`recordings.storageSection.noCameraHasRecordedFootage`,`No camera has recorded footage on this node yet.`)}):c(j,{columns:P,rows:[...f.devices],rowKey:e=>e.deviceId,minWidthPx:480})]})}function Qt(){let{t:e}=U();return a(`div`,{className:`flex flex-col gap-8`,children:[a(`div`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.recordingsStorageSection.footageOnDisk`,`Footage on disk`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`recordings.recordingsStorageSection.whatRecordedFootageOccupiesPer`,`What recorded footage occupies, per camera and per volume, with prune-by-policy and delete-all-footage.`)}),c(`div`,{className:`mt-3`,children:c(Zt,{})})]}),a(`div`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.recordingsStorageSection.recordingNodeFolders`,`Recording node & folders`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`recordings.recordingsStorageSection.theSingleNodeThatRecords`,`The single node that records and serves playback, and the storage locations footage is written to.`)}),c(`div`,{className:`mt-3`,children:c(Ht,{})})]})]})}function $t(){let{t:e}=U(),t=Me(`/recordings`,{t:e,isAdmin:!0})??{icon:u,title:e(`nav.recordings`,`Recordings`)};return c(Ne,{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:c(Qt,{})},{id:`events`,label:e(`recordings.events`,`Events`),content:c(it,{})},{id:`cameras`,label:e(`recordings.cameras`,`Cameras`),content:c(Ye,{})},{id:`exports`,label:e(`recordings.export`,`Export`),content:c(vt,{})},{id:`activity`,label:e(`recordings.activity`,`Activity`),content:c(Je,{})},{id:`management`,label:e(`recordings.management`,`Management`),content:c(zt,{})}]})}export{$t as RecordingsPage};
|
|
1
|
+
import{$ as e,B as t,G as n,J as r,L as i,S as a,b as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{Ei as l,Fr as u,It as d,Jr as f,Nt as p,Wr as m,Y as h,dt as g,ea as _,or as v,ot as y,si as b,xr as x}from"./player-overlays-Db_o1Zm2.js";import{Oi as S}from"./client-CUuI767h.js";import{n as C,t as w}from"./scissors-DjP6Unuk.js";import{$c as T,An as E,Fc as D,Gs as O,Ic as k,Kc as A,Kt as j,Lc as M,Mc as N,Mn as P,Nc as ee,Nn as F,On as te,Pc as ne,Pn as re,Qc as ie,Rc as ae,Un as oe,Vn as I,Wc as se,Wn as L,Xc as ce,Yc as le,Yn as ue,Ys as de,Zc as fe,_r as pe,al as me,br as he,bs as ge,el as _e,er as R,fs as ve,il as ye,kn as be,ms as xe,nl as Se,ol as Ce,qc as z,qt as we,rl as Te,tl as Ee,va as B,vs as De,vu as Oe,xu as V,zc as ke}from"./src-BpDNu6in.js";import{t as H}from"./i18n-RHwbGLC0.js";import{t as U}from"./useTranslation-D3Is_4B6.js";import{A as Ae,X as je,w as Me}from"./index-DrWxDgY9.js";import{t as Ne}from"./AdminSectionedPage-5tMwz6Be.js";import{n as Pe}from"./authed-media-CFsHrcXx.js";import{t as W}from"./format-size-DIxKXxtj.js";import{c as Fe,i as Ie,l as Le,n as Re,o as ze,r as Be,s as Ve,t as He,u as Ue}from"./location-owned-usage-CEUpeKPu.js";e();var We=[{value:`all`,labelKey:`common.all`},{value:`recording`,labelKey:`recordings.activitySection.domainRecordings`},{value:`events`,labelKey:`common.events`}],Ge={recording:`bg-primary/10 text-primary`,events:`bg-violet-500/10 text-violet-400`},Ke={columnKey:`at`,dir:`desc`};function qe(e){return new Date(e).toLocaleString()}function Je(){let{t:e,i18n:t}=U(),[i,s]=r(`all`),{data:l,isLoading:u,isError:d}=ne({},{refetchOnWindowFocus:!1}),{data:f,isLoading:m,isError:h}=De({},{refetchOnWindowFocus:!1}),{data:g}=B({isCamera:!0,projection:`slim`}),y=n(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.name);return e},[g]),b=n(()=>{let e=[...l??[],...f??[]];return(i===`all`?e:e.filter(e=>e.domain===i)).toSorted((e,t)=>t.at-e.at)},[l,f,i]),x=n(()=>{let t=[];return d&&i!==`events`&&t.push(e(`recordings.activitySection.domainRecordings`)),h&&i!==`recording`&&t.push(e(`common.events`)),t},[d,h,i,e]),S=n(()=>new Intl.ListFormat(t.language,{type:`conjunction`}).format(x),[x,t.language]),C=n(()=>[{key:`at`,header:e(`recordings.activitySection.when`,`When`),nowrap:!0,sortValue:e=>e.at,render:e=>c(`span`,{className:`text-foreground-subtle tabular-nums`,children:qe(e.at)})},{key:`domain`,header:e(`recordings.activitySection.domain`,`Domain`),sortValue:e=>e.domain,render:e=>c(`span`,{className:`inline-flex rounded px-1.5 py-0.5 text-[10px] font-medium ${Ge[e.domain]}`,children:e.domain})},{key:`op`,header:e(`recordings.activitySection.operation`,`Operation`),sortValue:e=>e.op,render:e=>c(`span`,{className:`text-foreground`,children:e.op})},{key:`reason`,header:e(`recordings.activitySection.reason`,`Reason`),sortValue:e=>e.reason,render:e=>c(`span`,{className:`text-foreground-subtle`,children:e.reason})},{key:`device`,header:e(`recordings.activitySection.camera`,`Camera`),sortValue:e=>e.deviceId===null?`cluster`:y.get(e.deviceId)??`#${String(e.deviceId)}`,render:t=>t.deviceId===null?c(`span`,{className:`text-foreground-subtle`,children:e(`common.cluster`)}):c(`span`,{className:`text-foreground`,children:y.get(t.deviceId)??`#${String(t.deviceId)}`})},{key:`items`,header:e(`recordings.activitySection.items`,`Items`),align:`right`,nowrap:!0,sortValue:e=>e.itemsAffected,render:e=>c(`span`,{className:`tabular-nums`,children:e.itemsAffected.toLocaleString()})},{key:`bytes`,header:e(`recordings.activitySection.reclaimed`,`Reclaimed`),align:`right`,nowrap:!0,sortValue:e=>e.bytesReclaimed,render:e=>c(`span`,{className:`tabular-nums`,children:e.bytesReclaimed>0?W(e.bytesReclaimed):`—`})}],[y,e]),w=u||m;return a(`div`,{className:`flex flex-col gap-4`,children:[c(`div`,{className:`flex items-center gap-1`,children:We.map(t=>c(`button`,{onClick:()=>s(t.value),className:`rounded px-2 py-1 text-xs font-medium ${i===t.value?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-muted`}`,children:e(t.labelKey)},t.value))}),w&&b.length===0?a(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[c(v,{className:`h-4 w-4 animate-spin`}),e(`recordings.activitySection.loadingActivity`,`Loading activity…`)]}):b.length===0?x.length>0?c(I,{icon:p,title:e(`recordings.activitySection.activityCouldNotBeRead`,`Activity could not be read`),description:e(`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})}):c(I,{icon:_,title:e(`recordings.activitySection.noActivityYet`,`No activity yet`),description:e(`recordings.activitySection.pruneDeleteAndRescanOperations`,`Prune, delete and rescan operations across recordings and events show up here.`)}):a(o,{children:[x.length>0&&a(`p`,{className:`flex items-center gap-1.5 text-[11px] text-amber-500`,children:[c(p,{className:`h-3 w-3 shrink-0`}),e(`recordings.activitySection.domainsMissing`,{count:x.length,names:S})]}),c(j,{columns:C,rows:b,rowKey:e=>e.id,minWidthPx:720,maxBodyHeight:we,defaultSort:Ke})]})]})}e();function Ye(){let{t:e}=U(),t=B({isCamera:!0,projection:`slim`}),i=n(()=>(t.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[t.data]),[o,s]=r(null),u=o??i[0]?.id??null;return!t.isLoading&&i.length===0?c(I,{icon:l,title:e(`recordings.cameraRecordingSettingsSection.noCameras`,`No cameras`),description:e(`recordings.cameraRecordingSettingsSection.addACameraFirst`,`Add a camera first.`)}):a(`div`,{className:`space-y-3`,children:[a(`div`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.cameraRecordingSettingsSection.perCameraRecordingRetention`,`Per-camera recording & retention`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`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.`)})]}),a(`div`,{className:`flex items-center gap-2`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e(`recordings.cameraRecordingSettingsSection.camera`,`Camera`)}),c(`select`,{value:u??``,onChange:e=>s(Number(e.target.value)),className:`rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:i.map(e=>c(`option`,{value:e.id,children:e.name},e.id))})]}),u!==null&&c(ue,{deviceId:u,children:c(Ae,{deviceId:u,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},u)]})}e();function Xe({types:e}){let{t}=U(),i=s(),o=R(),{data:l}=z({}),u=A(),d=n(()=>u.data??[],[u.data]),{data:f}=ee({},{refetchOnWindowFocus:!1}),p=n(()=>He(l??[],f?.locations),[l,f?.locations]),[m,h]=r(null),[g,_]=r(null),v=()=>{i.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})},y=Ce({onSuccess:v}),b=se({onSuccess:v}),x=n(()=>{let e=new Map;for(let t of l??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[l]),S=async(e,n)=>{Le(n)&&!await o({title:t(`pipeline.storageLocationsPanel.disable`,`Disable "{{displayName}}"?`,{displayName:e.displayName}),message:t(`pipeline.storageLocationsPanel.nothingIsDeletedSetThe`,`{{consequence}} Nothing is deleted — set the location back to Read-only or Active to bring its footage back.`,{consequence:Fe(n).consequence}),confirmLabel:t(`common.disable`,`Disable`),variant:`danger`})||y.mutate(Ve(e,{mode:n}))},C=async e=>{if(await o({title:t(`pipeline.storageLocationsPanel.deleteLocation`,`Delete location "{{displayName}}"?`,{displayName:e.displayName}),message:t(`pipeline.storageLocationsPanel.removesTheRecordFilesOn`,`Removes the record; files on disk are untouched.`),confirmLabel:t(`common.delete`,`Delete`),variant:`danger`}))try{await b.mutateAsync({id:e.id})}catch(n){await o({title:t(`pipeline.storageLocationsPanel.deleteAnyway`,`Delete anyway?`),message:t(`pipeline.storageLocationsPanel.forcingNote`,{error:n instanceof Error?n.message:String(n)}),confirmLabel:t(`pipeline.storageLocationsPanel.forceDelete`,`Force delete`),variant:`danger`})&&b.mutate({id:e.id,force:!0})}},w=e.map(e=>d.find(t=>t.id===e)).filter(e=>e!==void 0);return a(`div`,{className:`space-y-3`,children:[w.length===0?c(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:t(`pipeline.storageLocationsPanel.noStorageLocationsDeclaredFor`,`No storage locations declared for this purpose.`)}):w.map(e=>c(Re,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:x.get(e.id)??[],onAdd:e=>h(e),onEdit:e=>_(e),onDelete:e=>{C(e)},ownedBytesById:p,onSetMode:(e,t)=>{S(e,t)}},e.id)),m!==null&&c(Ue,{initialType:m,onClose:()=>h(null),onCreated:()=>{v(),h(null)}}),g!==null&&c(ze,{location:g,onClose:()=>_(null),onSaved:()=>{v(),_(null)}})]})}e();var Ze=`pipeline-analytics`;function Qe(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 $e(){let{t:e}=U(),t=s(),{nodes:r}=Oe(),{data:i,isLoading:o}=pe({addonId:Ze}),l=Qe(i),u=he({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),d=n(()=>{let e=r.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,l,...e])].filter(Boolean)},[r,l]);return a(`div`,{className:`flex flex-col gap-6`,children:[a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h3`,{className:`text-sm font-semibold text-foreground`,children:e(`pipeline.clusterEventsTab.postProcessingNode`,`Post-processing node`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`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.`)}),a(`div`,{className:`mt-3 flex items-center gap-2`,children:[o?c(v,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):c(`select`,{value:l,onChange:e=>{e.target.value!==l&&u.mutate({addonId:Ze,patch:{postProcessingNodeId:e.target.value}})},disabled:u.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:d.map(t=>c(`option`,{value:t,children:t===`hub`?e(`pipeline.clusterEventsTab.hubDefault`,`hub (default)`):t},t))}),u.isPending&&c(v,{className:`h-4 w-4 animate-spin text-primary`})]})]}),a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:e(`pipeline.clusterEventsTab.eventsFolder`,`Events folder`)}),c(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:e(`pipeline.clusterEventsTab.whereEventCropsFullFrames`,`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`)}),c(Xe,{types:[`eventMedia`]})]})]})}e();var et=[[`pipelineAnalytics`]],tt=1440*60*1e3;function G(e,t){return t.get(e)??H.t(`recordings.eventsManagementSection.removedCamera`,{id:String(e)})}var nt=[{days:1},{days:7},{days:30},{days:90}];function rt(){let{t:e}=U(),t=s(),o=R(),[l,u]=r(30),[p,m]=r(null),{data:g,isLoading:_}=xe({},{refetchOnWindowFocus:!1}),{data:y}=B({isCamera:!0,projection:`slim`}),b=n(()=>{let e=new Map;for(let t of y??[])e.set(t.id,t.name);return e},[y]),x=i(()=>{t.invalidateQueries({queryKey:et})},[t]),S=ge({onSuccess:x}),C=ve(),T=i(async()=>{await o({title:e(`recordings.eventsManagementSection.pruneTitle`,{count:l}),message:e(`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:e(`recordings.eventsManagementSection.pruneEvents`,`Prune events`),variant:`danger`})&&S.mutate({olderThanMs:Date.now()-l*tt,reason:`retention`})},[o,S,l,e]),E=i(async t=>{let n=G(t.deviceId,b);if(await o({title:e(`recordings.eventsManagementSection.deleteAllEventsFor`,`Delete all events for {{label}}?`,{label:n}),message:e(`recordings.eventsManagementSection.deleteRowsMessage`,{count:t.rows,size:W(t.bytes)}),confirmLabel:e(`recordings.eventsManagementSection.deleteEvents`,`Delete events`),variant:`danger`})){m(null);try{let e=await C.mutateAsync({deviceId:t.deviceId});x();let r=e.motion+e.object+e.audio;if(r===0&&t.bytes>0){m(`0 events deleted for ${n}. Media still listed (${W(t.bytes)}) — those blobs are not event rows; use Management → Count leftovers or Disk reconcile.`);return}m(`Deleted ${String(r)} event${r===1?``:`s`} for ${n}.`)}catch(e){m(e instanceof Error?e.message:String(e))}}},[o,C,b,x,e]),D=n(()=>[{key:`camera`,header:e(`recordings.eventsManagementSection.camera`,`Camera`),render:e=>c(`span`,{className:`text-foreground`,children:G(e.deviceId,b)})},{key:`rows`,header:e(`recordings.eventsManagementSection.events`,`Events`),align:`right`,nowrap:!0,render:e=>c(`span`,{className:`tabular-nums`,children:e.rows.toLocaleString()})},{key:`bytes`,header:e(`recordings.eventsManagementSection.media`,`Media`),align:`right`,nowrap:!0,render:e=>c(`span`,{className:`tabular-nums`,children:W(e.bytes)})},{key:`actions`,header:``,align:`right`,render:t=>a(`button`,{onClick:()=>{E(t)},disabled:C.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:e(`recordings.eventsManagementSection.deleteAllEventsForThis`,`Delete all events for this camera`),children:[c(d,{className:`h-3 w-3`}),e(`common.delete`,`Delete`)]})}],[b,E,C.isPending,e]);return _&&!g?a(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[c(v,{className:`h-4 w-4 animate-spin`}),e(`recordings.eventsManagementSection.loadingEventStoreFootprint`,`Loading event-store footprint…`)]}):g?a(`div`,{className:`flex flex-col gap-6`,children:[a(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[c(h,{label:e(`recordings.eventsManagementSection.totalEvents`,`Total events`),icon:c(f,{className:`h-3 w-3`}),footer:`across ${String(g.devices.length)} camera${g.devices.length===1?``:`s`}`,children:g.totalRows.toLocaleString()}),c(h,{label:e(`recordings.eventsManagementSection.eventMediaOnDisk`,`Event media on disk`),children:W(g.totalBytes)})]}),a(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[c(`span`,{className:`text-foreground-subtle`,children:e(`recordings.eventsManagementSection.pruneEventsOlderThan`,`Prune events older than`)}),c(`select`,{value:l,onChange:e=>u(Number(e.target.value)),className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:nt.map(t=>c(`option`,{value:t.days,children:e(`recordings.eventsManagementSection.ageDays`,{count:t.days})},t.days))}),a(`button`,{onClick:()=>{T()},disabled:S.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:[S.isPending?c(v,{className:`h-3 w-3 animate-spin`}):c(w,{className:`h-3 w-3`}),e(`recordings.eventsManagementSection.pruneNow`,`Prune now`)]})]}),g.devices.length===0?c(I,{icon:f,title:e(`recordings.eventsManagementSection.noStoredEvents`,`No stored events`),description:e(`recordings.eventsManagementSection.noCameraHasPersistedEvents`,`No camera has persisted events yet.`)}):c(j,{columns:D,rows:[...g.devices],rowKey:e=>e.deviceId,minWidthPx:480}),p===null?null:c(`p`,{className:p.startsWith(`Deleted `)?`text-[11px] text-foreground-subtle`:`text-[11px] text-destructive`,children:p})]}):c(I,{icon:f,title:e(`recordings.eventsManagementSection.noEventData`,`No event data`),description:e(`recordings.eventsManagementSection.pipelineAnalyticsHasNotReported`,`Pipeline analytics has not reported any event-store footprint yet.`)})}function it(){let{t:e}=U();return a(`div`,{className:`flex flex-col gap-8`,children:[a(`div`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.eventsSection.eventStore`,`Event store`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`recordings.eventsSection.whatTheDurableEventStore`,`What the durable event store occupies, per camera, with fleet-wide prune-by-age and delete-all-events.`)}),c(`div`,{className:`mt-3`,children:c(rt,{})})]}),a(`div`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.eventsSection.postProcessingNodeFolders`,`Post-processing node & folders`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`recordings.eventsSection.theSingleNodeThatWrites`,`The single node that writes event crops, and the storage location they land in.`)}),c(`div`,{className:`mt-3`,children:c($e,{})})]})]})}function at(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 ot(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function st(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`${ot(e)} · ${o}`}function ct(e,t){let n=e-t;if(n<=0)return H.t(`helpers.exportFormat.expired`);let r=Math.floor(n/6e4);if(r<60)return H.t(`helpers.exportFormat.inMinutes`,{n:String(r)});let i=Math.floor(r/60);return i<24?H.t(`helpers.exportFormat.inHours`,{n:String(i)}):H.t(`helpers.exportFormat.inDays`,{n:String(Math.floor(i/24))})}function lt(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})}e();var ut=[`high`,`mid`,`low`],dt=[{value:1,labelKey:`recordings.newExportModal.speedRealTime`},{value:2,labelKey:null},{value:4,labelKey:null},{value:8,labelKey:null},{value:16,labelKey:null}],ft=10080*60*1e3;function K(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 pt({onClose:e,onCreated:t}){let{t:i}=U(),o=B({isCamera:!0,projection:`slim`}),s=n(()=>(o.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[o.data]),[l,d]=r(``),[f,p]=r(`high`),[m,h]=r(K(60)),[g,_]=r(K(0)),[v,y]=r(1),[b,x]=r(!0),[S,C]=r(``),[w,T]=r(null),D=l===``?s[0]?.id??null:l,O=new Date(m).getTime(),k=new Date(g).getTime(),A=Number.isFinite(O)&&Number.isFinite(k)&&O<k,j=M({onSuccess:()=>{t(),e()},onError:e=>T(e instanceof Error?e.message:String(e))});return c(te,{open:!0,onOpenChange:t=>!t&&e(),children:a(E,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[c(F,{children:a(re,{className:`flex items-center gap-1.5`,children:[c(u,{className:`h-3.5 w-3.5`}),i(`recordings.newExportModal.newExport`,`New export`)]})}),a(be,{className:`space-y-3`,children:[a(`div`,{className:`grid grid-cols-2 gap-3`,children:[a(`div`,{className:`space-y-1`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:i(`recordings.newExportModal.camera`,`Camera`)}),c(`select`,{value:D??``,onChange:e=>d(Number(e.target.value)),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:s.map(e=>c(`option`,{value:e.id,children:e.name},e.id))})]}),a(`div`,{className:`space-y-1`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:i(`recordings.newExportModal.profile`,`Profile`)}),c(`select`,{value:f,onChange:e=>p(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:ut.map(e=>c(`option`,{value:e,children:e},e))})]})]}),a(`div`,{className:`grid grid-cols-2 gap-3`,children:[a(`div`,{className:`space-y-1`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:i(`recordings.newExportModal.from`,`From`)}),c(`input`,{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`})]}),a(`div`,{className:`space-y-1`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:i(`recordings.newExportModal.to`,`To`)}),c(`input`,{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`})]})]}),a(`div`,{className:`grid grid-cols-2 gap-3`,children:[a(`div`,{className:`space-y-1`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:i(`recordings.newExportModal.speed`,`Speed`)}),c(`select`,{value:v,onChange:e=>y(Number(e.target.value)),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:dt.map(e=>c(`option`,{value:e.value,children:e.labelKey===null?`${e.value}×`:i(e.labelKey)},e.value))})]}),a(`div`,{className:`space-y-1`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:i(`recordings.newExportModal.titleOptional`,`Title (optional)`)}),c(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:i(`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`})]})]}),a(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[c(`input`,{type:`checkbox`,checked:b,disabled:v!==1,onChange:e=>x(e.target.checked),className:`accent-primary`}),i(v===1?`recordings.newExportModal.includeAudio`:`recordings.newExportModal.includeAudioRealtimeOnly`)]}),!A&&c(`p`,{className:`text-[11px] text-danger`,children:i(`recordings.newExportModal.fromMustBeBeforeTo`,`"From" must be before "To".`)}),w&&c(`p`,{className:`text-[11px] text-danger`,children:w})]}),a(P,{children:[c(oe,{variant:`outline`,size:`sm`,onClick:e,children:i(`common.cancel`,`Cancel`)}),c(oe,{size:`sm`,onClick:()=>{if(D===null||!A)return;T(null);let e=S.trim();j.mutate({deviceId:D,profile:f,fromMs:O,toMs:k,options:{includeAudio:b,maxLifeMs:ft,deleteAfterDownload:!1,...v===1?{}:{speed:v},...e.length>0?{title:e}:{}}})},disabled:D===null||!A||j.isPending,children:j.isPending?i(`recordings.newExportModal.queuing`,`Queuing…`):i(`recordings.newExportModal.createExport`,`Create export`)})]})]})})}e();var mt=[[`recordingExport`]],ht={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 gt(){let{data:e,isLoading:t}=ke({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:r}=V(S.RecordingExportProgress,e=>e.exportId),{map:i}=V(S.RecordingExportCompleted,e=>e.exportId),{map:a}=V(S.RecordingExportFailed,e=>e.exportId);return{rows:n(()=>lt(e??[],r,i,a),[e,r,i,a]),isLoading:t}}function _t(e){let[n,i]=r(()=>Date.now());return t(()=>{let t=setInterval(()=>i(Date.now()),e);return()=>clearInterval(t)},[e]),n}function vt(){let{t:e}=U(),t=s(),[o,l]=r(!1),f=()=>{t.invalidateQueries({queryKey:[[`recordingExport`,`listExports`]]})},p=R(),h=y().trpcClient,g=_t(6e4),{rows:_,isLoading:x}=gt(),{data:S}=B({isCamera:!0,projection:`slim`}),C=n(()=>{let e=new Map;for(let t of S??[])e.set(t.id,t.name);return e},[S]),w=i(()=>{t.invalidateQueries({queryKey:mt})},[t]),T=k({onSuccess:w}),E=ae({onSuccess:w}),[D,O]=r(null),A=i(async e=>{O(e.id);try{let{url:t}=await h.recordingExport.getDownloadUrl.query({exportId:e.id}),n=await Pe(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),w()}finally{O(null)}},[h,w]),M=i(async t=>{await p({title:e(`recordings.exportsSection.cancelThisExport`,`Cancel this export?`),message:e(`recordings.exportsSection.stopsTheRenderThePartial`,`Stops the render. The partial file is discarded.`),confirmLabel:e(`recordings.exportsSection.cancelExport`,`Cancel export`),variant:`danger`})&&T.mutate({exportId:t.id})},[p,T,e]),N=i(async t=>{await p({title:e(`recordings.exportsSection.deleteThisExport`,`Delete this export?`),message:e(`recordings.exportsSection.permanentlyRemovesTheRenderedFile`,`Permanently removes the rendered file and its history row.`),confirmLabel:e(`common.delete`,`Delete`),variant:`danger`})&&E.mutate({exportId:t.id})},[p,E,e]),P=n(()=>[{key:`camera`,header:e(`recordings.exportsSection.camera`,`Camera`),render:e=>c(`span`,{className:`text-foreground`,children:C.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:e(`recordings.exportsSection.range`,`Range`),nowrap:!0,render:e=>c(`span`,{className:`tabular-nums`,children:st(e.fromMs,e.toMs)})},{key:`variant`,header:e(`recordings.exportsSection.variant`,`Variant`),render:e=>c(`span`,{className:`text-foreground-subtle`,children:at(e.options)})},{key:`state`,header:e(`recordings.exportsSection.state`,`State`),render:t=>{let n=ht[t.state];return a(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${n.cls}`,children:[n.spin&&c(v,{className:`h-2.5 w-2.5 animate-spin`}),e(n.labelKey),t.state===`rendering`&&t.progressPct!==null&&a(`span`,{className:`tabular-nums`,children:[t.progressPct,`%`]})]})}},{key:`expiry`,header:e(`recordings.exportsSection.expires`,`Expires`),nowrap:!0,render:e=>e.state===`deleted`?c(`span`,{className:`text-foreground-subtle`,children:`—`}):c(`span`,{className:`text-foreground-subtle tabular-nums`,children:ct(e.expiresAt,g)})},{key:`size`,header:e(`recordings.exportsSection.size`,`Size`),align:`right`,nowrap:!0,render:e=>c(`span`,{className:`tabular-nums`,children:e.fileBytes===null?`—`:W(e.fileBytes)})},{key:`actions`,header:``,align:`right`,render:t=>{let n=t.state===`ready`,r=t.state===`queued`||t.state===`rendering`,i=t.state!==`deleted`;return a(`div`,{className:`flex items-center justify-end gap-1`,children:[n&&a(`button`,{onClick:()=>{A(t)},disabled:D===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:e(`recordings.exportsSection.downloadMp4`,`Download MP4`),children:[D===t.id?c(v,{className:`h-3 w-3 animate-spin`}):c(m,{className:`h-3 w-3`}),e(`recordings.exportsSection.download`,`Download`)]}),r&&a(`button`,{onClick:()=>{M(t)},disabled:T.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:e(`recordings.exportsSection.cancelRender`,`Cancel render`),children:[c(b,{className:`h-3 w-3`}),e(`common.cancel`,`Cancel`)]}),i&&c(`button`,{onClick:()=>{N(t)},disabled:E.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:e(`recordings.exportsSection.deleteExport`,`Delete export`),children:c(d,{className:`h-3 w-3`})})]})}}],[C,g,D,T.isPending,E.isPending,A,M,N,e]);return x&&_.length===0?a(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[c(v,{className:`h-4 w-4 animate-spin`}),e(`recordings.exportsSection.loadingExports`,`Loading exports…`)]}):a(`div`,{className:`space-y-3`,children:[c(`div`,{className:`flex justify-end`,children:a(`button`,{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:[c(u,{className:`h-3.5 w-3.5`}),e(`recordings.exportsSection.newExport`,`New export`)]})}),_.length===0?c(I,{icon:u,title:e(`recordings.exportsSection.noExportsYet`,`No exports yet`),description:e(`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.`)}):c(j,{columns:P,rows:_,rowKey:e=>e.id,minWidthPx:720}),o&&c(pt,{onClose:()=>l(!1),onCreated:f})]})}var yt=`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`;e();var bt=`storage-migration`,xt=new Set([`orphans`,`debug-media`,`ghost-ledger`]);function St(e){return[`${e.orphansReclaimed} orphan rows (${W(e.orphanBytesReclaimed)})`,e.includeDebugMedia?`${e.debugMediaReclaimed} debug files (${W(e.debugMediaBytesReclaimed)})`:null,`${e.ghostsForgotten} ghost rows (${W(e.ghostBytesForgotten)})`].filter(e=>e!==null).join(` · `)}function Ct(){let{t:e}=U(),t=L(bt);return t===`pending`?null:t===`unknown`?c(`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`?c(wt,{}):null}function wt(){let{t:e}=U(),t=R(),[n,i]=r(!1),[o,s]=r(null),l=ie({},{refetchInterval:2e3}),u=l.data??null,f=u!==null&&xt.has(u.phase),p=fe(),m=ce(),h=async()=>{if(await t({title:e(`recordings.cleanupSection.runStorageCleanup`,`Run storage cleanup?`),message:n?e(`recordings.cleanupSection.reclaimsLeftoverAnalyticsRowsAnd`,`Reclaims leftover analytics rows and files, debug stills/filmstrips, and ghost footage rows on frozen locations. Safe to re-run.`):e(`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:e(`recordings.cleanupSection.runCleanup`,`Run cleanup`),variant:`danger`})){s(null);try{await p.mutateAsync({includeDebugMedia:n}),await l.refetch()}catch(e){s(e instanceof Error?e.message:String(e))}}},g=async()=>{if(u&&await t({title:e(`recordings.cleanupSection.cancelCleanup`,`Cancel cleanup?`),message:e(`recordings.cleanupSection.stopsAfterTheCurrentStep`,`Stops after the current step. Work already done stays done.`),confirmLabel:e(`recordings.cleanupSection.cancelCleanup2`,`Cancel cleanup`),variant:`danger`}))try{await m.mutateAsync({jobId:u.jobId}),await l.refetch()}catch{}};return a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.cleanupSection.cleanup`,`Cleanup`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`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.`)}),a(`label`,{className:`mt-3 flex items-start gap-2 text-[11px] text-foreground`,children:[c(`input`,{type:`checkbox`,checked:n,disabled:f,onChange:e=>{i(e.target.checked)},className:`mt-0.5 h-3.5 w-3.5 accent-primary`}),c(`span`,{children:e(`recordings.cleanupSection.alsoRemoveDebugMediaMotion`,`Also remove debug media (motion stills and track filmstrips)`)})]}),a(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[a(`button`,{type:`button`,disabled:f||p.isPending,onClick:()=>{h()},className:yt,children:[(f||p.isPending)&&c(v,{className:`h-3 w-3 animate-spin`}),c(d,{className:`h-3 w-3`}),e(`recordings.cleanupSection.runCleanup`,`Run cleanup`)]}),f&&c(`button`,{type:`button`,onClick:()=>{g()},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:e(`common.cancel`,`Cancel`)})]}),o&&c(`p`,{className:`mt-2 text-[11px] text-danger`,children:o}),u&&a(`div`,{className:`mt-3 space-y-1 rounded-md border border-border px-2.5 py-2`,children:[a(`p`,{className:`text-xs text-foreground`,children:[e(`recordings.cleanupSection.phase`,`Phase:`),` `,c(`span`,{className:`font-medium`,children:u.phase}),f&&c(v,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),u.detail&&c(`p`,{className:`text-[11px] text-foreground-subtle`,children:u.detail}),c(`p`,{className:`text-[11px] text-foreground-subtle`,children:St(u)}),u.error&&c(`p`,{className:`text-[11px] text-danger`,children:u.error})]})]})}e();var Tt=2e3;function Et(){let{t:e}=U(),n=R(),r=s(),i=de(),o=O(void 0,{refetchInterval:e=>e.state.data?.state===`running`?Tt:!1}),l=o.data,u=l?.state===`running`,d=u||i.isPending;t(()=>{l?.state!==`done`||l.finishedAtMs===null||(r.invalidateQueries({queryKey:[[`recording`]]}),r.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[l?.state,l?.finishedAtMs,r]);let f=async()=>{await n({title:e(`recordings.diskReconcileSection.reconcileStorageFromDisk`,`Reconcile storage from disk?`),message:e(`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:e(`recordings.diskReconcileSection.reconcile`,`Reconcile`),variant:`warning`})&&(await i.mutateAsync(),await o.refetch())},p=u?l.total>0?`Reconciling ${String(l.completed)}/${String(l.total)}…`:`Reconciling…`:i.isPending?`Reconciling…`:`Reconcile from disk`;return a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h3`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.diskReconcileSection.diskReconcile`,`Disk reconcile`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`recordings.diskReconcileSection.deletesDatabaseRowsWhoseFiles`,`Deletes database rows whose files are gone. Enrolled identities stay.`)}),a(`div`,{className:`mt-3 flex flex-col gap-2`,children:[a(`button`,{type:`button`,onClick:()=>void f(),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?c(v,{className:`h-3.5 w-3.5 animate-spin`}):c(x,{className:`h-3.5 w-3.5`}),p]}),l?.state===`done`?a(`p`,{className:`text-[11px] text-foreground-subtle`,children:[e(`recordings.diskReconcileSection.lastRun`,`Last run:`),` `,e(`recordings.diskReconcileSection.summary`,{completed:String(l.completed),tracks:String(l.tracks),events:String(l.events),media:String(l.mediaDropped)}),l.failed.length>0?e(`recordings.diskReconcileSection.failed`,`, {{value1}} failed ({{value2}})`,{value1:String(l.failed.length),value2:l.failed.join(`, `)}):``,`.`]}):null,l?.state===`error`&&l.error!==null?a(`p`,{className:`text-[11px] text-destructive`,children:[e(`recordings.diskReconcileSection.reconcileFailed`,`Reconcile failed:`),` `,l.error]}):null]})]})}var q=1e3,J=60*q,Y=60*J;function X(e){return e.toLocaleString(`en-US`)}function Dt(e){if(!Number.isFinite(e)||e<0)return`—`;if(e>=Y){let t=Math.floor(e/Y),n=Math.round(e%Y/J);return`${t.toString()}h ${n.toString()}m`}if(e>=J){let t=Math.floor(e/J),n=Math.round(e%J/q);return`${t.toString()}m ${n.toString()}s`}return`${Math.max(0,Math.round(e/q)).toString()}s`}function Ot(e){let t=Math.max(0,e.observedAt-e.startedAt),n=e.filesTotal===null?`${X(e.filesMoved)} files`:`${X(e.filesMoved)} / ${X(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?`${W(e.bytesMoved/t*q)}/s`:null,o=e.filesTotal===null?null:e.filesTotal-e.filesMoved,s=!i||o===null||o<=0?null:`~${Dt(o*t/e.filesMoved)} left`;return{counted:n,fraction:r,moved:`${W(e.bytesMoved)} moved`,rate:a,eta:s}}function kt(e){let t=Ot(e);return[t.counted,t.moved,t.rate,t.eta].filter(e=>e!==null).join(` · `)}e();var At=`storage-migration`,Z=[{id:`recordings`,labelKey:`recordings.storageMigrationSection.classRecordings`,locationType:`recordings`},{id:`recordingsLow`,labelKey:`recordings.storageMigrationSection.classRecordingsLow`,locationType:`recordingsLow`},{id:`eventMedia`,labelKey:`recordings.storageMigrationSection.classEventMedia`,locationType:`eventMedia`}],jt=new Set([`planning`,`sealing`,`pausing`,`moving`,`draining`,`verifying`,`repointing`,`refreshing`,`resuming`]);function Mt(){let{t:e}=U(),t=L(At);return t===`pending`?a(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[c(v,{className:`h-4 w-4 animate-spin`}),e(`migration.storageMigrationSection.checkingWhetherStorageMigrationIs`,`Checking whether storage migration is installed…`)]}):t===`unknown`?c(I,{icon:p,title:e(`migration.storageMigrationSection.couldnTCheckWhetherStorage`,`Couldn't check whether storage migration is installed`),description:e(`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.`)}):t===`absent`?c(I,{icon:C,title:e(`migration.storageMigrationSection.storageMigrationNotInstalled`,`Storage migration not installed`),description:e(`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.`)}):c(Nt,{})}function Nt(){let{t:e}=U(),t=R(),{data:i}=z({}),[o,s]=r({}),[l,u]=r({}),[d,f]=r(null),[p,m]=r(null),h=n(()=>{let e=new Map;for(let t of i??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[i]),_=n(()=>{let e=new Map;for(let t of i??[]){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},[i]),y=me({},{refetchInterval:2e3}),b=y.data??null,x=b!==null&&jt.has(b.phase),S=n(()=>{let e={};for(let t of Z){let n=o[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[o]),w=n(()=>{let e={};for(let t of Z){if(!o[t.id])continue;let n=l[t.id]??_.get(t.locationType);n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[o,l,_]),T=n(()=>({destinations:S??{},...w?{sources:w}:{}}),[S,w]),E=Se(T,{enabled:!1,retry:!1}),D=ye(),O=le(),k=async()=>{if(!S)return;m(null);let e=await E.refetch();if(e.error){m(e.error instanceof Error?e.error.message:String(e.error));return}f(e.data??null)},A=async()=>{if(S&&await t({title:e(`migration.storageMigrationSection.startStorageMigration`,`Start storage migration?`),message:e(`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:e(`migration.storageMigrationSection.startMigration`,`Start migration`),variant:`danger`})){m(null);try{await D.mutateAsync(T),f(null),await y.refetch()}catch(e){m(e instanceof Error?e.message:String(e))}}},j=async()=>{if(b&&await t({title:e(`migration.storageMigrationSection.cancelMigration`,`Cancel migration?`),message:e(`migration.storageMigrationSection.stopsTheInProgressMigration`,`Stops the in-progress migration. Data already moved and verified stays at the destination; anything already repointed is not reverted.`),confirmLabel:e(`migration.storageMigrationSection.cancelMigration2`,`Cancel migration`),variant:`danger`}))try{await O.mutateAsync({jobId:b.jobId}),await y.refetch()}catch{}};return a(`div`,{className:`flex flex-col gap-6`,children:[a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[a(`h3`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[c(C,{className:`h-3.5 w-3.5`}),e(`migration.storageMigrationSection.storageMigration`,`Storage migration`)]}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`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.`)}),c(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-3`,children:Z.map(t=>{let n=h.get(t.locationType)??[],r=_.get(t.locationType)??``;return a(`div`,{className:`space-y-2`,children:[c(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e(t.labelKey)}),a(`div`,{className:`space-y-1`,children:[c(`label`,{htmlFor:`migration-from-${t.id}`,className:`text-[10px] text-foreground-subtle`,children:e(`recordings.storageMigrationSection.classFrom`,{label:e(t.labelKey)})}),c(`select`,{id:`migration-from-${t.id}`,value:l[t.id]??r,onChange:e=>{let n=e.target.value;u(e=>({...e,[t.id]:n}))},disabled:x,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground disabled:opacity-50`,children:n.map(t=>a(`option`,{value:t.id,children:[t.displayName,t.enabled===!1?` (${e(`recordings.storageMigrationSection.readOnly`)})`:``]},t.id))})]}),a(`div`,{className:`space-y-1`,children:[c(`label`,{htmlFor:`migration-dest-${t.id}`,className:`text-[10px] text-foreground-subtle`,children:e(`recordings.storageMigrationSection.classTo`,{label:e(t.labelKey)})}),a(`select`,{id:`migration-dest-${t.id}`,value:o[t.id]??``,onChange:e=>{let n=e.target.value;s(e=>({...e,[t.id]:n}))},disabled:x,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground disabled:opacity-50`,children:[c(`option`,{value:``,children:e(`migration.storageMigrationSection.skip`,`— skip —`)}),n.map(e=>c(`option`,{value:e.id,children:e.displayName},e.id))]})]})]},t.id)})}),p&&c(`p`,{className:`mt-2 text-[11px] text-danger`,children:p}),a(`div`,{className:`mt-3 flex items-center gap-2`,children:[a(`button`,{type:`button`,onClick:()=>{k()},disabled:!S||E.isFetching||x,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:[E.isFetching&&c(v,{className:`h-3 w-3 animate-spin`}),e(`migration.storageMigrationSection.plan`,`Plan`)]}),a(`button`,{type:`button`,onClick:()=>{A()},disabled:!S||D.isPending||x,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:[D.isPending&&c(v,{className:`h-3 w-3 animate-spin`}),e(`migration.storageMigrationSection.startMigration`,`Start migration`)]})]}),d&&c(`div`,{className:`mt-3 divide-y divide-border rounded-md border border-border`,children:d.moves.length===0?c(`p`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:e(`migration.storageMigrationSection.nothingToMoveSelectedDestinations`,`Nothing to move — selected destinations match the current defaults.`)}):d.moves.map(e=>a(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground`,children:[e.storageClass,`: `,e.fromLocationId,` → `,e.toLocationId]},`${e.storageClass}-${e.toLocationId}`))}),b&&a(`div`,{className:`mt-4 border-t border-border pt-3`,children:[a(`div`,{className:`flex items-center justify-between`,children:[c(`h4`,{className:`text-xs font-semibold text-foreground`,children:e(`migration.storageMigrationSection.migrationStatus`,`Migration status`)}),x&&a(`button`,{type:`button`,onClick:()=>{j()},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:[c(g,{className:`h-3 w-3`}),e(`common.cancel`,`Cancel`)]})]}),a(`p`,{className:`mt-1 text-xs text-foreground`,children:[e(`migration.storageMigrationSection.phase`,`Phase:`),` `,c(`span`,{className:`font-medium`,children:b.phase}),x&&c(v,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),b.error&&c(`p`,{className:`mt-1 text-[11px] text-danger`,children:b.error}),b.pausedParticipants.length>0&&a(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[e(`migration.storageMigrationSection.paused`,`Paused:`),` `,b.pausedParticipants.join(`, `)]}),c(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:b.moves.map(e=>c(Pt,{move:e},`${e.storageClass}-${e.fromLocationId}`))})]}),c(Ft,{})]}),c(It,{running:x}),c(Rt,{})]})}function Pt({move:e}){let{t}=U(),n=e.progress===null?null:Ot(e.progress);return a(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[a(`div`,{className:`flex items-center justify-between`,children:[a(`span`,{className:`text-foreground`,children:[e.storageClass,`: `,e.fromLocationId,` → `,e.toLocationId]}),a(`span`,{className:`text-foreground-subtle`,children:[e.state??t(`common.pending`),e.error?` (${e.error})`:``]})]}),e.progress!==null&&a(`div`,{className:`mt-1 space-y-1`,children:[n!==null&&n.fraction!==null&&c(`div`,{className:`h-1 w-full overflow-hidden rounded bg-border`,children:c(`div`,{className:`h-full bg-primary`,style:{width:`${(n.fraction*100).toFixed(1)}%`}})}),c(`p`,{className:`text-[10px] text-foreground-subtle`,children:kt(e.progress)})]})]})}function Ft(){let{t:e}=U(),{data:t}=_e({});return!t||t.length===0?null:a(`div`,{className:`mt-4 border-t border-border pt-3`,children:[c(`h4`,{className:`text-xs font-semibold text-foreground`,children:e(`migration.storageMigrationSection.migrationHistory`,`Migration history`)}),c(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:t.map(e=>a(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:[c(`span`,{className:`font-medium text-foreground`,children:e.phase}),` · `,Object.entries(e.destinations).filter(e=>typeof e[1]==`string`).map(([e,t])=>`${e} → ${t}`).join(`, `),` · `,new Date(e.startedAt).toLocaleString()]},e.jobId))})]})}function It({running:e}){let{t}=U(),n=R(),i=Te({},{staleTime:1/0,refetchOnWindowFocus:!1}),o=T(),[s,l]=r(null),u=i.data??[];if(u.length===0)return null;let d=async e=>{if(await n({title:t(`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:t(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`),variant:`danger`})){l(null);try{await o.mutateAsync({classes:[e.storageClass]}),await i.refetch()}catch(e){l(e instanceof Error?e.message:String(e))}}};return a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[a(`div`,{className:`flex items-start justify-between gap-2`,children:[c(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`migration.storageMigrationSection.leftOnTheOldLocation`,`Left on the old location`)}),a(`div`,{className:`flex shrink-0 items-center gap-2`,children:[c(`span`,{className:`text-[10px] text-foreground-subtle`,children:i.dataUpdatedAt>0?t(`migration.storageMigrationSection.measured`,`Measured {{value1}}`,{value1:new Date(i.dataUpdatedAt).toLocaleTimeString()}):t(`migration.storageMigrationSection.measuredNever`,`Measured — never`)}),c(`button`,{type:`button`,onClick:()=>{i.refetch()},disabled:i.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:i.isFetching?t(`migration.storageMigrationSection.counting`,`Counting…`):t(`common.refresh`,`Refresh`)})]})]}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`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.`)}),c(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:t(`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.`)}),s&&c(`p`,{className:`mt-2 text-[11px] text-danger`,children:s}),c(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:u.map(n=>a(`div`,{className:`flex items-center justify-between gap-2 px-2.5 py-1.5 text-[11px]`,children:[a(`span`,{className:`text-foreground`,children:[n.storageClass,`: `,n.fromLocationId,` → `,n.toLocationId,c(`span`,{className:`ml-2 text-foreground-subtle`,children:Lt(n)})]}),c(`button`,{type:`button`,onClick:()=>{d(n)},disabled:e||o.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:t(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`)})]},`${n.storageClass}-${n.fromLocationId}`))})]})}function Lt(e){if(e.items===null)return H.t(`recordings.storageMigrationSection.residueUnknown`);let t=e.items.toLocaleString(`en-US`);return e.bytes===null?H.t(`recordings.storageMigrationSection.residueRows`,{count:e.items,items:t}):H.t(`recordings.storageMigrationSection.residueSegments`,{count:e.items,items:t,size:W(e.bytes)})}function Rt(){let{t:e}=U(),{data:t}=Ee({},{refetchInterval:2e3}),n=(t??[]).filter(e=>e.migrationJobId===null&&e.job.state===`running`);return n.length===0?null:a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h3`,{className:`text-sm font-semibold text-foreground`,children:e(`migration.storageMigrationSection.moversRunningOutsideAMigration`,`Movers running outside a migration`)}),c(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:n.map(e=>a(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[a(`div`,{className:`text-foreground`,children:[e.lane,`: `,e.job.fromLocationId,` → `,e.job.toLocationId]}),c(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:kt({filesMoved:e.job.filesMoved,filesTotal:e.job.filesTotal,bytesMoved:e.job.bytesMoved,startedAt:e.job.startedAt,observedAt:e.observedAt})})]},e.job.jobId))})]})}function zt(){let{t:e}=U();return a(`div`,{className:`flex flex-col gap-4`,children:[c(Ct,{}),c(Et,{}),a(`section`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.recordingsManagementSection.moveStorage`,`Move storage`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`recordings.recordingsManagementSection.copyRecordingsLowResRecordings`,`Copy recordings, low-res recordings or event media to a new location, verify, then repoint the default. Applies to every camera.`)}),c(`div`,{className:`mt-3`,children:c(Mt,{})})]})]})}e();var Bt=`recorder`;function Vt(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 Ht(){let{t:e}=U(),t=s(),{nodes:r}=Oe(),{data:i,isLoading:o}=pe({addonId:Bt}),l=Vt(i,`recordingNodeId`,`hub`),u=he({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),d=n(()=>{let e=r.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,l,...e])].filter(Boolean)},[r,l]);return a(`div`,{className:`flex flex-col gap-6`,children:[a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h3`,{className:`text-sm font-semibold text-foreground`,children:e(`pipeline.clusterRecordingTab.recordingNode`,`Recording node`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`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.`)}),a(`div`,{className:`mt-3 flex items-center gap-2`,children:[o?c(v,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):c(`select`,{value:l,onChange:e=>{e.target.value!==l&&u.mutate({addonId:Bt,patch:{recordingNodeId:e.target.value}})},disabled:u.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:d.map(t=>c(`option`,{value:t,children:t===`hub`?e(`pipeline.clusterRecordingTab.hubDefault`,`hub (default)`):t},t))}),u.isPending&&c(v,{className:`h-4 w-4 animate-spin text-primary`})]}),l!==`hub`&&c(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:c(je,{i18nKey:`pipeline.clusterRecordingTab.hubOnlyNote`,values:{node:l},components:{b:c(`span`,{className:`font-medium`})}})})]}),a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:e(`pipeline.clusterRecordingTab.recordingsFolders`,`Recordings folders`)}),c(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:e(`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.`)}),c(Xe,{types:[`recordings`,`recordingsLow`]})]})]})}function Ut(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function Q(e,t){let n=Ut(e);return n.length===0?H.t(`helpers.cameraDisk.defaultRoot`):n.map(e=>t.get(e)??e).join(` + `)}function Wt(e,t,n){if(e.length===0)return null;let r=e[0];if(e.length===1&&r!==void 0)return{label:Q(r,t),exact:!0};if(n===null)return null;let i=e.find(e=>Ut(e).includes(n));return i===void 0?null:{label:Q(i,t),exact:!1}}e();var Gt=[[`recording`]],Kt=[{value:`retention`,labelKey:`recordings.storageSection.pruneRetention`},{value:`quota`,labelKey:`recordings.storageSection.pruneQuota`},{value:`operator`,labelKey:`recordings.storageSection.pruneOperator`}],qt={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Jt={ok:`text-foreground-subtle`,warn:`text-amber-500`,critical:`text-danger`};function $(e){return`${String(Math.round(e*100))}%`}function Yt(e){return e==null?`—`:new Date(e).toLocaleString()}function Xt(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(` + `):H.t(`recordings.storageSection.defaultRoot`):e.root}function Zt(){let{t:e}=U(),t=s(),o=R(),[l,u]=r(`retention`),{data:f,isLoading:p}=ee({},{refetchOnWindowFocus:!1}),{data:m}=B({isCamera:!0,projection:`slim`}),{data:g}=z({}),_=n(()=>{let e=new Map;for(let t of m??[])e.set(t.id,t.name);return e},[m]),y=n(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.displayName);return e},[g]),b=n(()=>{let e=g??[];return e.find(e=>e.type===`recordings`&&e.enabled!==!1)?.id??e.find(e=>e.type===`recordings`)?.id??null},[g]),S=n(()=>f?.locations??[],[f?.locations]),C=n(()=>Wt(S,y,b),[S,y,b]),T=n(()=>Ie(S),[S]),E=i(()=>{t.invalidateQueries({queryKey:Gt})},[t]),O=D({onSuccess:E}),k=N({onSuccess:E}),A=i(async t=>{await o({title:e(`recordings.storageSection.prune`,`Prune {{label}}?`,{label:_.get(t.deviceId)??`#${String(t.deviceId)}`}),message:e(`recordings.storageSection.appliesTheRetentionPolicyNow`,`Applies the retention policy now (reason: {{reason}}). Footage beyond the policy is permanently deleted.`,{reason:l}),confirmLabel:e(`recordings.storageSection.pruneNow`,`Prune now`),variant:`danger`})&&O.mutate({deviceId:t.deviceId,reason:l})},[o,O,l,_,e]),M=i(async t=>{await o({title:e(`recordings.storageSection.deleteAllFootageFor`,`Delete all footage for {{label}}?`,{label:_.get(t.deviceId)??`#${String(t.deviceId)}`}),message:e(`recordings.storageSection.permanentlyDeletesOfRecordedFootage`,`Permanently deletes {{value1}} of recorded footage for this camera. This cannot be undone.`,{value1:W(t.usedBytes)}),confirmLabel:e(`recordings.storageSection.delete`,`Delete {{value1}}`,{value1:W(t.usedBytes)}),variant:`danger`})&&k.mutate({deviceId:t.deviceId})},[o,k,_,e]),P=n(()=>[{key:`camera`,header:e(`recordings.storageSection.camera`,`Camera`),render:e=>c(`span`,{className:`text-foreground`,children:_.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`disk`,header:e(`recordings.storageSection.disk`,`Disk`),nowrap:!0,render:()=>C===null?c(`span`,{className:`text-foreground-subtle`,children:`—`}):a(`span`,{className:C.exact?`text-foreground`:`text-foreground-subtle`,title:C.exact?e(`recordings.storageSection.theOnlyRecordingsVolumeOn`,`The only recordings volume on this node — this camera can only be here.`):e(`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:[C.label,!C.exact&&c(`span`,{className:`ml-1 text-foreground-subtle`,children:e(`recordings.storageSection.default`,`(default)`)})]})},{key:`used`,header:e(`recordings.storageSection.used`,`Used`),align:`right`,nowrap:!0,render:e=>c(`span`,{className:`tabular-nums`,children:W(e.usedBytes)})},{key:`oldest`,header:e(`recordings.storageSection.oldestFootage`,`Oldest footage`),align:`right`,nowrap:!0,render:t=>c(`span`,{className:`tabular-nums text-foreground-subtle`,title:e(`recordings.storageSection.theOldestSegmentTheArchive`,`The oldest segment the ARCHIVE holds for this camera — the per-camera answer to 'is retention actually holding?'.`),children:Yt(t.oldestMs)})},{key:`actions`,header:``,align:`right`,render:t=>a(`div`,{className:`flex items-center justify-end gap-1`,children:[a(`button`,{onClick:()=>{A(t)},disabled:O.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:e(`recordings.storageSection.applyRetentionPolicyNow`,`Apply retention policy now`),children:[c(w,{className:`h-3 w-3`}),e(`recordings.storageSection.prune2`,`Prune`)]}),a(`button`,{onClick:()=>{M(t)},disabled:k.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:e(`recordings.storageSection.deleteAllFootage`,`Delete all footage`),children:[c(d,{className:`h-3 w-3`}),e(`common.delete`,`Delete`)]})]})}],[_,C,A,M,O.isPending,k.isPending,e]);if(p&&!f)return a(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[c(v,{className:`h-4 w-4 animate-spin`}),e(`recordings.storageSection.loadingStorageUsage`,`Loading storage usage…`)]});if(!f)return c(I,{icon:x,title:e(`recordings.storageSection.noStorageData`,`No storage data`),description:e(`recordings.storageSection.theRecordingNodeHasNot`,`The recording node has not reported any storage usage yet.`)});let F=f.devices.length;return a(`div`,{className:`flex flex-col gap-6`,children:[a(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[c(h,{label:e(`recordings.storageSection.totalUsed`,`Total used`),icon:c(x,{className:`h-3 w-3`}),footer:`${String(F)} camera${F===1?``:`s`} on ${f.nodeId}`,children:W(f.totalUsedBytes)}),T!==null&&T.severity!==null&&c(h,{label:e(`recordings.storageSection.freeOnRecordingsVolumes`,`Free on recordings volumes`),icon:c(x,{className:`h-3 w-3`}),footer:`across ${String(T.knownVolumes)} volume${T.knownVolumes===1?``:`s`} of ${W(T.totalBytes)}`+(T.unknownVolumes>0?` · ${String(T.unknownVolumes)} did not report capacity`:``),children:c(`span`,{className:`tabular-nums ${Jt[T.severity]}`,children:W(T.freeBytes)})}),S.map(t=>{let n=Be(t),r=t.locationId??t.root??`default`;return c(h,{label:e(`recordings.storageSection.disk2`,`Disk: {{label}}`,{label:Xt(t,y)}),footer:n===null?`${W(t.usedBytes)} of recordings · volume capacity unknown`:`${W(n.freeBytes)} free of ${W(n.totalBytes)} · ${W(t.usedBytes)} recordings (${$(n.recordingsFraction)})`,children:n===null?c(`span`,{className:`tabular-nums`,children:W(t.usedBytes)}):a(`div`,{className:`flex items-center gap-2`,title:e(`recordings.storageSection.volumeFillEverythingOnThe`,`Volume fill — everything on the disk, not only recordings. Warn at 85%, critical at 95%.`),children:[c(`div`,{className:`h-2 flex-1 overflow-hidden rounded bg-muted`,children:c(`div`,{className:`h-full rounded ${qt[n.severity]}`,style:{width:$(n.fraction)}})}),c(`span`,{className:`tabular-nums text-xs ${Jt[n.severity]}`,children:$(n.fraction)})]})},r)})]}),a(`section`,{className:`flex items-center gap-2 text-xs`,children:[c(`label`,{htmlFor:`prune-reason`,className:`text-foreground-subtle`,children:e(`recordings.storageSection.pruneReason`,`Prune reason`)}),c(`select`,{id:`prune-reason`,value:l,onChange:e=>{let t=Kt.find(t=>t.value===e.target.value);t&&u(t.value)},className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:Kt.map(t=>c(`option`,{value:t.value,children:e(t.labelKey)},t.value))})]}),F===0?c(I,{icon:x,title:f.devicesRead===`unavailable`?e(`recordings.storageSection.perCameraUsageUnavailable`,`Per-camera usage unavailable`):e(`recordings.storageSection.noRecordedFootage`,`No recorded footage`),description:f.devicesRead===`unavailable`?e(`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.`):e(`recordings.storageSection.noCameraHasRecordedFootage`,`No camera has recorded footage on this node yet.`)}):c(j,{columns:P,rows:[...f.devices],rowKey:e=>e.deviceId,minWidthPx:480})]})}function Qt(){let{t:e}=U();return a(`div`,{className:`flex flex-col gap-8`,children:[a(`div`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.recordingsStorageSection.footageOnDisk`,`Footage on disk`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`recordings.recordingsStorageSection.whatRecordedFootageOccupiesPer`,`What recorded footage occupies, per camera and per volume, with prune-by-policy and delete-all-footage.`)}),c(`div`,{className:`mt-3`,children:c(Zt,{})})]}),a(`div`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.recordingsStorageSection.recordingNodeFolders`,`Recording node & folders`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`recordings.recordingsStorageSection.theSingleNodeThatRecords`,`The single node that records and serves playback, and the storage locations footage is written to.`)}),c(`div`,{className:`mt-3`,children:c(Ht,{})})]})]})}function $t(){let{t:e}=U(),t=Me(`/recordings`,{t:e,isAdmin:!0})??{icon:u,title:e(`nav.recordings`,`Recordings`)};return c(Ne,{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:c(Qt,{})},{id:`events`,label:e(`recordings.events`,`Events`),content:c(it,{})},{id:`cameras`,label:e(`recordings.cameras`,`Cameras`),content:c(Ye,{})},{id:`exports`,label:e(`recordings.export`,`Export`),content:c(vt,{})},{id:`activity`,label:e(`recordings.activity`,`Activity`),content:c(Je,{})},{id:`management`,label:e(`recordings.management`,`Management`),content:c(zt,{})}]})}export{$t as RecordingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,B as t,G as n,J as r,L as i,S as a,b as o,q as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{Br as l,Cn as u,Nt as d,Q as f,Si as p,Wr as m,bi as h,bn as g,dt as _,or as v}from"./player-overlays-Db_o1Zm2.js";import{Di as y,Ti as b}from"./client-CUuI767h.js";import{Ea as x,Sr as S,Yi as C,ca as w,mi as T,mo as E,oa as D,va as O,vi as k,yi as A}from"./src-CL0G8g2V.js";import{t as j}from"./useTranslation-D3Is_4B6.js";import"./mount-DJj6igTj.js";import{R as M,X as N}from"./index-CeO2wVZi.js";import{t as P}from"./BrokerForm-BxmxiIRw.js";e();var F=[`amazon.com`,`amazon.it`,`amazon.de`,`amazon.co.uk`,`amazon.fr`,`amazon.es`,`amazon.ca`,`amazon.com.au`,`amazon.co.jp`,`amazon.in`,`amazon.com.br`,`amazon.com.mx`],I=f(`/addon/import-alexa`),L=2e3;function R(e){return typeof e==`object`&&!!e&&typeof e.sessionId==`string`&&typeof e.loginUrl==`string`}function z(e){return typeof e==`object`&&!!e&&typeof e.phase==`string`&&typeof e.sessionId==`string`}function B(e){return typeof e==`object`&&!!e&&typeof e.brokerId==`string`}function V(e){return{"Content-Type":`application/json`,Authorization:`Bearer ${localStorage.getItem(`camstack_admin_token`)??``}`,...e}}async function H(e,t,n){let r=await fetch(`${I}${e}`,{method:`POST`,headers:V(),body:JSON.stringify(t)}),i=await r.json();if(!r.ok){let e=typeof i==`object`&&i?i.error??`Unknown error`:`Unknown error`;throw Error(String(e))}if(!n(i))throw Error(`Unexpected response from server`);return i}async function U(e){let t=new URLSearchParams({sessionId:e}),n=localStorage.getItem(`camstack_admin_token`)??``,r=await fetch(`${I}/login/status?${t.toString()}`,{headers:{Authorization:`Bearer ${n}`}}),i=await r.json();if(!r.ok){let e=typeof i==`object`&&i?i.error??`Unknown error`:`Unknown error`;throw Error(String(e))}if(!z(i))throw Error(`Unexpected status response from server`);return i}async function W(e){try{await fetch(`${I}/login/cancel`,{method:`POST`,headers:V(),body:JSON.stringify({sessionId:e})})}catch{}}function G({brokerId:e,onResolved:n,onCancel:o}){let{t:u}=j(),[f,p]=r(`amazon.it`),[m,h]=r(`Alexa account`),[_,y]=r({kind:`idle`}),b=s(!0);t(()=>(b.current=!0,()=>{b.current=!1}),[]);let x=s(null),S=s(null),C=i(()=>{S.current!==null&&(clearInterval(S.current),S.current=null)},[]),w=i(async t=>{C(),b.current&&y({kind:`committing`,sessionId:t});try{let r=await H(`/login/commit`,{sessionId:t,name:m.trim().length>0?m.trim():`Alexa account`,...e===void 0?{}:{brokerId:e}},B);x.current=null,n(r.brokerId)}catch(e){let n=e instanceof Error?e.message:String(e);b.current&&y({kind:`error`,message:n,sessionId:t})}},[e,m,n,C]),T=i((e,t)=>{C();let n=async()=>{try{let n=await U(e);if(n.phase===`captured`){C(),w(e);return}if(n.phase===`error`){C(),b.current&&y({kind:`error`,message:n.error??u(`integrations.alexaLoginStep.loginProxyReturnedAnError`,`Login proxy returned an error`),sessionId:e});return}if(n.phase===`cancelled`){C(),b.current&&y({kind:`idle`});return}b.current&&y({kind:`polling`,sessionId:e,loginUrl:n.loginUrl||t,phase:n.phase})}catch(e){let t=e instanceof Error?e.message:String(e);b.current&&y(e=>e.kind===`polling`?{...e}:{kind:`error`,message:t,sessionId:null})}};S.current=setInterval(()=>{n()},L)},[C,w,u]);t(()=>()=>{C(),x.current!==null&&W(x.current)},[C]);let E=async()=>{C(),x.current!==null&&(W(x.current),x.current=null),y({kind:`starting`});try{let e=await H(`/login/start`,{amazonDomain:f},R);x.current=e.sessionId,y({kind:`polling`,sessionId:e.sessionId,loginUrl:e.loginUrl,phase:`starting`}),T(e.sessionId,e.loginUrl)}catch(e){y({kind:`error`,message:e instanceof Error?e.message:String(e),sessionId:null})}},D=()=>{C(),x.current!==null&&(W(x.current),x.current=null),y({kind:`idle`})},O=()=>{D()},k=_.kind===`idle`,A=_.kind===`starting`,M=_.kind===`polling`,P=_.kind===`committing`,I=_.kind===`error`,z=A||M||P,V=_.kind===`polling`?_.phase:null,G=_.kind===`polling`?_.loginUrl:null,K=M&&V===`awaiting-login`,q=M&&(V===`starting`||V===null);return a(`div`,{className:`space-y-4`,children:[(k||I)&&a(`div`,{className:`space-y-3`,children:[e===void 0&&a(`div`,{className:`space-y-1`,children:[c(`label`,{htmlFor:`alexa-account-name`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:u(`integrations.alexaLoginStep.accountName`,`Account name`)}),c(`input`,{id:`alexa-account-name`,type:`text`,value:m,onChange:e=>h(e.target.value),placeholder:u(`integrations.alexaLoginStep.alexaAccount`,`Alexa account`),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),a(`div`,{className:`space-y-1`,children:[c(`label`,{htmlFor:`alexa-amazon-region`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:u(`integrations.alexaLoginStep.amazonRegion`,`Amazon region`)}),c(`select`,{id:`alexa-amazon-region`,value:f,onChange:e=>p(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:F.map(e=>c(`option`,{value:e,children:e},e))})]})]}),I&&a(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px] flex items-start gap-2`,children:[c(d,{className:`h-3.5 w-3.5 mt-0.5 flex-shrink-0`}),c(`span`,{children:_.message})]}),A&&a(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[c(v,{className:`h-4 w-4 animate-spin flex-shrink-0`}),u(`integrations.alexaLoginStep.startingLoginProxy`,`Starting login proxy…`)]}),q&&a(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[c(v,{className:`h-4 w-4 animate-spin flex-shrink-0`}),u(`integrations.alexaLoginStep.waitingForProxyToBe`,`Waiting for proxy to be ready…`)]}),P&&a(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[c(v,{className:`h-4 w-4 animate-spin flex-shrink-0`}),u(`integrations.alexaLoginStep.savingCredentials`,`Saving credentials…`)]}),K&&G!==null&&a(`div`,{className:`space-y-3`,children:[a(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-2`,children:[c(`p`,{className:`text-xs font-semibold text-foreground`,children:u(`integrations.alexaLoginStep.openTheLinkBelowTo`,`Open the link below to log in to your Amazon account`)}),c(`p`,{className:`text-[10px] text-foreground-subtle`,children:u(`integrations.alexaLoginStep.afterCompletingTheLoginAnd`,`After completing the login and any 2FA steps, this wizard will continue automatically.`)}),a(`a`,{href:G,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:[c(l,{className:`h-3.5 w-3.5`}),u(`integrations.alexaLoginStep.loginToAmazon`,`Login to Amazon`)]})]}),c(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-[10px] text-warning`,children:c(N,{i18nKey:`integrations.alexaLoginStep.proxyNote`,components:{b:c(`strong`,{}),code:c(`code`,{className:`font-mono`})}})}),a(`div`,{className:`flex items-center gap-2 text-[10px] text-foreground-subtle`,children:[c(v,{className:`h-3 w-3 animate-spin`}),u(`integrations.alexaLoginStep.waitingForAmazonLoginTo`,`Waiting for Amazon login to complete…`)]})]}),a(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[c(`button`,{type:`button`,onClick:z?D:o,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:z?u(`integrations.alexaLoginStep.cancelLogin`,`Cancel login`):u(`common.back`,`Back`)}),a(`div`,{className:`flex items-center gap-2`,children:[I&&a(`button`,{type:`button`,onClick:O,className:`inline-flex items-center gap-1.5 rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10`,children:[c(g,{className:`h-3.5 w-3.5`}),u(`common.retry`,`Retry`)]}),k&&c(`button`,{type:`button`,onClick:()=>{E()},disabled:e===void 0&&m.trim().length===0,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:u(`integrations.alexaLoginStep.startLogin`,`Start login`)})]})]})]})}e();var K=`alexa`;function q(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function J(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}var Y={connected:`bg-success/15 text-success`,connecting:`bg-warning/15 text-warning`,disconnected:`bg-foreground-subtle/15 text-foreground-subtle`,"auth-failed":`bg-danger/15 text-danger`,unreachable:`bg-danger/15 text-danger`,error:`bg-danger/15 text-danger`};function X({kind:e,onResolved:t,onBack:i}){let{t:o}=j(),[s,l]=r(e===K?`alexa-login`:`existing`),u=k({kind:e}),d=n(()=>q(u.data).filter(t=>t.kind===e),[u.data,e]),f=A(),p=n(()=>{for(let t of J(f.data))if(t.kinds.some(t=>t.kind===e))return t.addonId},[f.data,e]),[m,g]=r(null),[_,y]=r(``),b=T({}),x=()=>{m&&t(m)},S=async n=>{_.trim().length!==0&&t((await b.mutateAsync({kind:e,name:_.trim(),settings:n,...p===void 0?{}:{addonId:p}})).id)},C=e=>{e===`new`?g(null):b.reset(),l(e)};return a(`div`,{className:`space-y-4`,children:[a(`button`,{type:`button`,onClick:i,className:`inline-flex items-center gap-1 text-[11px] text-foreground-subtle hover:text-foreground`,children:[c(h,{className:`h-3.5 w-3.5`}),` `,o(`common.back`)]}),a(`div`,{className:`inline-flex rounded-lg border border-border p-0.5 flex-wrap gap-0.5`,children:[e===K&&c(`button`,{type:`button`,onClick:()=>C(`alexa-login`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${s===`alexa-login`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:o(`integrations.brokerStep.loginInteractively`,`Login interactively`)}),c(`button`,{type:`button`,onClick:()=>C(`existing`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${s===`existing`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:o(`integrations.brokerStep.useExisting`,`Use existing`)}),c(`button`,{type:`button`,onClick:()=>C(`new`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${s===`new`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:e===K?o(`integrations.brokerStep.pasteCookie`,`Paste cookie`):o(`integrations.brokerStep.createNew`,`Create new`)})]}),s===`alexa-login`&&c(G,{onResolved:t,onCancel:i}),s===`existing`&&a(`div`,{className:`space-y-3`,children:[u.isLoading&&a(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[c(v,{className:`h-3.5 w-3.5 animate-spin`}),` `,o(`integrations.brokerStep.loadingBrokers`)]}),u.isError&&a(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:[o(`integrations.brokerStep.failedToLoadBrokers`,`Failed to load brokers:`),` `,u.error instanceof Error?u.error.message:o(`integrations.brokerStep.unknownError`,`Unknown error`)]}),!u.isLoading&&!u.isError&&d.length===0&&c(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-6 text-center text-xs text-foreground-subtle`,children:c(N,{i18nKey:`integrations.brokerStep.noBrokers`,values:{mode:e===K?o(`integrations.brokerStep.loginInteractively`,`Login interactively`):o(`integrations.brokerStep.createNew`,`Create new`)},components:{b:c(`span`,{className:`font-medium text-foreground`})}})}),c(`div`,{className:`space-y-2`,children:d.map(e=>a(`button`,{type:`button`,onClick:()=>g(e.id),className:`flex w-full items-center justify-between gap-3 rounded-lg border bg-surface p-3 text-left transition-colors ${m===e.id?`border-primary ring-1 ring-primary`:`border-border hover:border-foreground-subtle/30`}`,children:[c(`span`,{className:`text-xs font-semibold text-foreground`,children:e.name}),c(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${Y[e.status]}`,children:e.status})]},e.id))}),d.length>0&&c(`div`,{className:`flex justify-end pt-1`,children:c(`button`,{type:`button`,onClick:x,disabled:!m,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:o(`integrations.brokerStep.useThisBroker`,`Use this broker`)})})]}),s===`new`&&a(`div`,{className:`space-y-3`,children:[a(`div`,{className:`space-y-1`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`integrations.brokerStep.name`,`Name`)}),c(`input`,{type:`text`,value:_,onChange:e=>y(e.target.value),placeholder:o(`integrations.brokerStep.myHomeAssistant`,`My Home Assistant`),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),b.isError&&c(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:b.error instanceof Error?b.error.message:String(b.error)}),c(P,{kind:e,...p===void 0?{}:{addonId:p},onSubmit:e=>{S(e).catch(()=>{})},onCancel:i,submitLabel:b.isPending?o(`integrations.brokerStep.creating`,`Creating…`):o(`integrations.brokerStep.createBroker`,`Create broker`),disabled:b.isPending||_.trim().length===0}),_.trim().length===0&&c(`p`,{className:`text-[10px] text-foreground-subtle`,children:o(`integrations.brokerStep.enterANameBeforeCreating`,`Enter a name before creating.`)})]})]})}e();function Z(e){return{status:e.status===`validated`||e.status===`rejected`||e.status===`inconclusive`||e.status===`unsupported`?e.status:e.success?`validated`:`rejected`,...e.error===void 0?{}:{error:e.error},...e.detail===void 0?{}:{detail:e.detail}}}var Q={validated:`border-success/30 bg-success/5 text-success`,rejected:`border-danger/30 bg-danger/5 text-danger`,inconclusive:`border-warning/30 bg-warning/5 text-warning`,unsupported:`border-border bg-surface text-foreground-subtle`};function ee({addonId:e,configSchema:t,canTest:n=!0,initialName:i,initialConfig:o,submitLabel:s,hideName:l=!1,onSave:u,onBack:d}){let{t:f}=j(),[p,m]=r(i??``),[h,g]=r(o??{}),[_,v]=r(null),x=E({onSuccess:e=>v(Z(e)),onError:e=>v({status:`inconclusive`,error:String(e)})}),C=S(),w=!n||_?.status===`validated`,T=(l||p.trim().length>0)&&w;return a(`div`,{className:`space-y-4`,children:[!l&&a(`div`,{children:[c(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:f(`integrations.integrationName`)}),c(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:f(`integrations.integrationNamePlaceholder`),className:`w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:border-primary/50`})]}),t&&c(M,{schema:t,values:h,onChange:e=>{g(e),v(null)},onAction:async(r,i,a)=>{let o=await C.mutateAsync({addonId:e,action:r,input:a??{}});if(n&&typeof o==`object`&&o){let n=o;if(!(typeof n.token==`string`||typeof n.sslCertificate==`string`||typeof n.host==`string`))return o;let r={...h};for(let[e,t]of Object.entries(n))typeof t==`string`&&e!==`summary`&&(r[e]=t);let i=y(t,r);g(i),v(null),x.mutate({addonId:e,settings:i})}return o}}),_&&c(`div`,{className:`rounded-lg border px-3 py-2 text-xs ${Q[_.status]}`,children:(e=>{switch(e.status){case`validated`:return e.detail?`${f(`integrations.connectionSuccess`)} — ${e.detail}`:f(`integrations.connectionSuccess`);case`rejected`:return`${f(`integrations.errorPrefix`)} ${e.error??``}`;case`inconclusive`:return`${f(`integrations.connectionInconclusive`,{defaultValue:`Could not be checked:`})} ${e.error??``}`;case`unsupported`:return e.error??f(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`})}})(_)}),a(`div`,{className:`flex items-center justify-between pt-2`,children:[c(`button`,{onClick:d,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:f(`integrations.back`)}),a(`div`,{className:`flex items-center gap-2`,children:[c(`button`,{onClick:()=>x.mutate({addonId:e,settings:y(t,h)}),disabled:x.isPending||!n,title:n?void 0:f(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`}),className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:x.isPending?f(`integrations.testing`):f(`integrations.testConnection`)}),c(`button`,{onClick:()=>u({name:p,config:y(t,h),secretKeys:[...b(t)]}),disabled:!T,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:s??f(`integrations.forward`)})]})]})]})}e();function te({open:e,onClose:t,scope:o}){let{t:s}=j(),l=C(),[d,f]=r(new Set),[h,g]=r(new Set),{data:y}=O({projection:`slim`}),b=n(()=>new Set((y??[]).map(e=>e.stableId)),[y]),x=i(async(e,t)=>{g(e=>new Set(e).add(t.stableId));try{await l.mutateAsync({addonId:e,candidate:t}),f(e=>new Set(e).add(t.stableId))}catch{}finally{g(e=>{let n=new Set(e);return n.delete(t.stableId),n})}},[l]),S=i((e,t)=>{let n=typeof t.prefilledConfig.host==`string`?t.prefilledConfig.host:null,r=b.has(t.stableId),i=d.has(t.stableId)||r,o=h.has(t.stableId);return a(`div`,{className:`flex items-center justify-between rounded-lg border border-border bg-surface px-3 py-2`,children:[a(`div`,{className:`min-w-0`,children:[c(`p`,{className:`truncate text-xs font-medium text-foreground`,children:t.suggestedName}),n&&c(`p`,{className:`truncate text-[10px] font-mono text-foreground-subtle`,children:n})]}),i?a(`span`,{className:`flex items-center gap-1 text-[11px] text-foreground-subtle`,children:[c(p,{className:`h-3.5 w-3.5`}),` `,r?s(`integrations.scanNetworkModal.alreadyAdded`,`Already added`):s(`integrations.scanNetworkModal.added`,`Added`)]}):a(`button`,{type:`button`,onClick:()=>void x(e,t),disabled:o,className:`flex items-center gap-1 rounded-md bg-primary px-2.5 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-50`,children:[o?c(v,{className:`h-3.5 w-3.5 animate-spin`}):c(m,{className:`h-3.5 w-3.5`}),s(`common.add`,`Add`)]})]},t.stableId)},[d,h,b,x,s]);if(!e)return null;let w=o?`Scan network — ${o.label}`:`Scan network for devices`;return a(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[c(`div`,{className:`absolute inset-0 bg-black/60`,onClick:t}),a(`div`,{className:`relative z-10 flex w-full max-w-2xl flex-col max-h-[calc(90dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl`,children:[a(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[a(`div`,{className:`flex items-center gap-2`,children:[c(u,{className:`h-4 w-4 text-primary`}),c(`h2`,{className:`text-sm font-semibold text-foreground`,children:w})]}),c(`button`,{onClick:t,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:c(_,{className:`h-4 w-4`})})]}),o?c(re,{scope:o,onAdopt:S,onReset:()=>f(new Set)}):c(ne,{onAdopt:S,onReset:()=>f(new Set)})]})]})}function ne({onAdopt:e,onReset:r}){let{t:s}=j(),l=D(),u=i(()=>{r(),l.mutate({})},[l,r]);t(()=>{!l.isPending&&!l.data&&u()},[]);let d=n(()=>(l.data?.groups??[]).filter(e=>e.candidates.length>0),[l.data]),f=n(()=>d.reduce((e,t)=>e+t.candidates.length,0),[d]);return a(o,{children:[c(`div`,{className:`flex items-center justify-end gap-2 border-b border-border px-5 py-2 shrink-0`,children:a(`button`,{onClick:u,disabled:l.isPending,className:`flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[c(g,{className:`h-3.5 w-3.5 ${l.isPending?`animate-spin`:``}`}),s(`integrations.scanNetworkModal.reScan`,`Re-scan`)]})}),a(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[l.isPending&&c(ie,{label:s(`integrations.scanNetworkModal.scanningTheLocalNetwork`,`Scanning the local network…`)}),!l.isPending&&l.isError&&c($,{}),!l.isPending&&l.data&&d.length===0&&c(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:s(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)}),!l.isPending&&d.length>0&&c(`p`,{className:`text-xs text-foreground-subtle`,children:s(`integrations.scanNetworkModal.found`,{count:f})}),!l.isPending&&d.map(t=>a(`div`,{className:`space-y-1.5`,children:[a(`div`,{className:`flex items-center gap-2`,children:[c(`span`,{className:`text-[11px] font-semibold text-foreground`,children:t.label}),a(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`(`,t.candidates.length,`)`]})]}),t.candidates.map(n=>e(t.addonId,n))]},t.addonId))]})]})}function re({scope:e,onAdopt:t,onReset:n}){let{t:s}=j(),l=x({addonId:e.addonId}).data??null,[d,f]=r({}),p=w(),m=i(()=>{n(),p.mutate({addonId:e.addonId,params:d})},[p,e.addonId,d,n]),h=p.data?.candidates??[];return c(o,{children:a(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[l&&c(M,{schema:l,values:d,onChange:f}),a(`button`,{onClick:m,disabled:p.isPending,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:[p.isPending?c(v,{className:`h-3.5 w-3.5 animate-spin`}):c(u,{className:`h-3.5 w-3.5`}),p.isPending?s(`integrations.scanNetworkModal.scanning`,`Scanning…`):s(`integrations.scanNetworkModal.scan`,`Scan`)]}),p.isError&&c($,{}),!p.isPending&&p.data&&h.length===0&&c(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:s(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)}),!p.isPending&&h.length>0&&a(`div`,{className:`space-y-1.5`,children:[c(`p`,{className:`text-xs text-foreground-subtle`,children:s(`integrations.scanNetworkModal.foundShort`,{count:h.length})}),h.map(n=>t(e.addonId,n))]})]})})}function ie({label:e}){return a(`div`,{className:`flex flex-col items-center py-12`,children:[c(v,{className:`h-6 w-6 animate-spin text-primary`}),c(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:e})]})}function $(){let{t:e}=j();return a(`div`,{className:`flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3`,children:[c(d,{className:`h-4 w-4 text-destructive mt-0.5 shrink-0`}),c(`p`,{className:`text-xs text-destructive`,children:e(`integrations.scanNetworkModal.theScanFailedTryAgain`,`The scan failed. Try again.`)})]})}export{ee as n,X as r,te as t};
|
|
1
|
+
import{$ as e,B as t,G as n,J as r,L as i,S as a,b as o,q as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{Br as l,Cn as u,Nt as d,Q as f,Si as p,Wr as m,bi as h,bn as g,dt as _,or as v}from"./player-overlays-Db_o1Zm2.js";import{Di as y,Ti as b}from"./client-CUuI767h.js";import{Ea as x,Sr as S,Yi as C,ca as w,mi as T,mo as E,oa as D,va as O,vi as k,yi as A}from"./src-BpDNu6in.js";import{t as j}from"./useTranslation-D3Is_4B6.js";import"./mount-BQdOI8yn.js";import{R as M,X as N}from"./index-DrWxDgY9.js";import{t as P}from"./BrokerForm-Dbt1v9HX.js";e();var F=[`amazon.com`,`amazon.it`,`amazon.de`,`amazon.co.uk`,`amazon.fr`,`amazon.es`,`amazon.ca`,`amazon.com.au`,`amazon.co.jp`,`amazon.in`,`amazon.com.br`,`amazon.com.mx`],I=f(`/addon/import-alexa`),L=2e3;function R(e){return typeof e==`object`&&!!e&&typeof e.sessionId==`string`&&typeof e.loginUrl==`string`}function z(e){return typeof e==`object`&&!!e&&typeof e.phase==`string`&&typeof e.sessionId==`string`}function B(e){return typeof e==`object`&&!!e&&typeof e.brokerId==`string`}function V(e){return{"Content-Type":`application/json`,Authorization:`Bearer ${localStorage.getItem(`camstack_admin_token`)??``}`,...e}}async function H(e,t,n){let r=await fetch(`${I}${e}`,{method:`POST`,headers:V(),body:JSON.stringify(t)}),i=await r.json();if(!r.ok){let e=typeof i==`object`&&i?i.error??`Unknown error`:`Unknown error`;throw Error(String(e))}if(!n(i))throw Error(`Unexpected response from server`);return i}async function U(e){let t=new URLSearchParams({sessionId:e}),n=localStorage.getItem(`camstack_admin_token`)??``,r=await fetch(`${I}/login/status?${t.toString()}`,{headers:{Authorization:`Bearer ${n}`}}),i=await r.json();if(!r.ok){let e=typeof i==`object`&&i?i.error??`Unknown error`:`Unknown error`;throw Error(String(e))}if(!z(i))throw Error(`Unexpected status response from server`);return i}async function W(e){try{await fetch(`${I}/login/cancel`,{method:`POST`,headers:V(),body:JSON.stringify({sessionId:e})})}catch{}}function G({brokerId:e,onResolved:n,onCancel:o}){let{t:u}=j(),[f,p]=r(`amazon.it`),[m,h]=r(`Alexa account`),[_,y]=r({kind:`idle`}),b=s(!0);t(()=>(b.current=!0,()=>{b.current=!1}),[]);let x=s(null),S=s(null),C=i(()=>{S.current!==null&&(clearInterval(S.current),S.current=null)},[]),w=i(async t=>{C(),b.current&&y({kind:`committing`,sessionId:t});try{let r=await H(`/login/commit`,{sessionId:t,name:m.trim().length>0?m.trim():`Alexa account`,...e===void 0?{}:{brokerId:e}},B);x.current=null,n(r.brokerId)}catch(e){let n=e instanceof Error?e.message:String(e);b.current&&y({kind:`error`,message:n,sessionId:t})}},[e,m,n,C]),T=i((e,t)=>{C();let n=async()=>{try{let n=await U(e);if(n.phase===`captured`){C(),w(e);return}if(n.phase===`error`){C(),b.current&&y({kind:`error`,message:n.error??u(`integrations.alexaLoginStep.loginProxyReturnedAnError`,`Login proxy returned an error`),sessionId:e});return}if(n.phase===`cancelled`){C(),b.current&&y({kind:`idle`});return}b.current&&y({kind:`polling`,sessionId:e,loginUrl:n.loginUrl||t,phase:n.phase})}catch(e){let t=e instanceof Error?e.message:String(e);b.current&&y(e=>e.kind===`polling`?{...e}:{kind:`error`,message:t,sessionId:null})}};S.current=setInterval(()=>{n()},L)},[C,w,u]);t(()=>()=>{C(),x.current!==null&&W(x.current)},[C]);let E=async()=>{C(),x.current!==null&&(W(x.current),x.current=null),y({kind:`starting`});try{let e=await H(`/login/start`,{amazonDomain:f},R);x.current=e.sessionId,y({kind:`polling`,sessionId:e.sessionId,loginUrl:e.loginUrl,phase:`starting`}),T(e.sessionId,e.loginUrl)}catch(e){y({kind:`error`,message:e instanceof Error?e.message:String(e),sessionId:null})}},D=()=>{C(),x.current!==null&&(W(x.current),x.current=null),y({kind:`idle`})},O=()=>{D()},k=_.kind===`idle`,A=_.kind===`starting`,M=_.kind===`polling`,P=_.kind===`committing`,I=_.kind===`error`,z=A||M||P,V=_.kind===`polling`?_.phase:null,G=_.kind===`polling`?_.loginUrl:null,K=M&&V===`awaiting-login`,q=M&&(V===`starting`||V===null);return a(`div`,{className:`space-y-4`,children:[(k||I)&&a(`div`,{className:`space-y-3`,children:[e===void 0&&a(`div`,{className:`space-y-1`,children:[c(`label`,{htmlFor:`alexa-account-name`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:u(`integrations.alexaLoginStep.accountName`,`Account name`)}),c(`input`,{id:`alexa-account-name`,type:`text`,value:m,onChange:e=>h(e.target.value),placeholder:u(`integrations.alexaLoginStep.alexaAccount`,`Alexa account`),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),a(`div`,{className:`space-y-1`,children:[c(`label`,{htmlFor:`alexa-amazon-region`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:u(`integrations.alexaLoginStep.amazonRegion`,`Amazon region`)}),c(`select`,{id:`alexa-amazon-region`,value:f,onChange:e=>p(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:F.map(e=>c(`option`,{value:e,children:e},e))})]})]}),I&&a(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px] flex items-start gap-2`,children:[c(d,{className:`h-3.5 w-3.5 mt-0.5 flex-shrink-0`}),c(`span`,{children:_.message})]}),A&&a(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[c(v,{className:`h-4 w-4 animate-spin flex-shrink-0`}),u(`integrations.alexaLoginStep.startingLoginProxy`,`Starting login proxy…`)]}),q&&a(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[c(v,{className:`h-4 w-4 animate-spin flex-shrink-0`}),u(`integrations.alexaLoginStep.waitingForProxyToBe`,`Waiting for proxy to be ready…`)]}),P&&a(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[c(v,{className:`h-4 w-4 animate-spin flex-shrink-0`}),u(`integrations.alexaLoginStep.savingCredentials`,`Saving credentials…`)]}),K&&G!==null&&a(`div`,{className:`space-y-3`,children:[a(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-2`,children:[c(`p`,{className:`text-xs font-semibold text-foreground`,children:u(`integrations.alexaLoginStep.openTheLinkBelowTo`,`Open the link below to log in to your Amazon account`)}),c(`p`,{className:`text-[10px] text-foreground-subtle`,children:u(`integrations.alexaLoginStep.afterCompletingTheLoginAnd`,`After completing the login and any 2FA steps, this wizard will continue automatically.`)}),a(`a`,{href:G,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:[c(l,{className:`h-3.5 w-3.5`}),u(`integrations.alexaLoginStep.loginToAmazon`,`Login to Amazon`)]})]}),c(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-[10px] text-warning`,children:c(N,{i18nKey:`integrations.alexaLoginStep.proxyNote`,components:{b:c(`strong`,{}),code:c(`code`,{className:`font-mono`})}})}),a(`div`,{className:`flex items-center gap-2 text-[10px] text-foreground-subtle`,children:[c(v,{className:`h-3 w-3 animate-spin`}),u(`integrations.alexaLoginStep.waitingForAmazonLoginTo`,`Waiting for Amazon login to complete…`)]})]}),a(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[c(`button`,{type:`button`,onClick:z?D:o,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:z?u(`integrations.alexaLoginStep.cancelLogin`,`Cancel login`):u(`common.back`,`Back`)}),a(`div`,{className:`flex items-center gap-2`,children:[I&&a(`button`,{type:`button`,onClick:O,className:`inline-flex items-center gap-1.5 rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10`,children:[c(g,{className:`h-3.5 w-3.5`}),u(`common.retry`,`Retry`)]}),k&&c(`button`,{type:`button`,onClick:()=>{E()},disabled:e===void 0&&m.trim().length===0,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:u(`integrations.alexaLoginStep.startLogin`,`Start login`)})]})]})]})}e();var K=`alexa`;function q(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function J(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}var Y={connected:`bg-success/15 text-success`,connecting:`bg-warning/15 text-warning`,disconnected:`bg-foreground-subtle/15 text-foreground-subtle`,"auth-failed":`bg-danger/15 text-danger`,unreachable:`bg-danger/15 text-danger`,error:`bg-danger/15 text-danger`};function X({kind:e,onResolved:t,onBack:i}){let{t:o}=j(),[s,l]=r(e===K?`alexa-login`:`existing`),u=k({kind:e}),d=n(()=>q(u.data).filter(t=>t.kind===e),[u.data,e]),f=A(),p=n(()=>{for(let t of J(f.data))if(t.kinds.some(t=>t.kind===e))return t.addonId},[f.data,e]),[m,g]=r(null),[_,y]=r(``),b=T({}),x=()=>{m&&t(m)},S=async n=>{_.trim().length!==0&&t((await b.mutateAsync({kind:e,name:_.trim(),settings:n,...p===void 0?{}:{addonId:p}})).id)},C=e=>{e===`new`?g(null):b.reset(),l(e)};return a(`div`,{className:`space-y-4`,children:[a(`button`,{type:`button`,onClick:i,className:`inline-flex items-center gap-1 text-[11px] text-foreground-subtle hover:text-foreground`,children:[c(h,{className:`h-3.5 w-3.5`}),` `,o(`common.back`)]}),a(`div`,{className:`inline-flex rounded-lg border border-border p-0.5 flex-wrap gap-0.5`,children:[e===K&&c(`button`,{type:`button`,onClick:()=>C(`alexa-login`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${s===`alexa-login`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:o(`integrations.brokerStep.loginInteractively`,`Login interactively`)}),c(`button`,{type:`button`,onClick:()=>C(`existing`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${s===`existing`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:o(`integrations.brokerStep.useExisting`,`Use existing`)}),c(`button`,{type:`button`,onClick:()=>C(`new`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${s===`new`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:e===K?o(`integrations.brokerStep.pasteCookie`,`Paste cookie`):o(`integrations.brokerStep.createNew`,`Create new`)})]}),s===`alexa-login`&&c(G,{onResolved:t,onCancel:i}),s===`existing`&&a(`div`,{className:`space-y-3`,children:[u.isLoading&&a(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[c(v,{className:`h-3.5 w-3.5 animate-spin`}),` `,o(`integrations.brokerStep.loadingBrokers`)]}),u.isError&&a(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:[o(`integrations.brokerStep.failedToLoadBrokers`,`Failed to load brokers:`),` `,u.error instanceof Error?u.error.message:o(`integrations.brokerStep.unknownError`,`Unknown error`)]}),!u.isLoading&&!u.isError&&d.length===0&&c(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-6 text-center text-xs text-foreground-subtle`,children:c(N,{i18nKey:`integrations.brokerStep.noBrokers`,values:{mode:e===K?o(`integrations.brokerStep.loginInteractively`,`Login interactively`):o(`integrations.brokerStep.createNew`,`Create new`)},components:{b:c(`span`,{className:`font-medium text-foreground`})}})}),c(`div`,{className:`space-y-2`,children:d.map(e=>a(`button`,{type:`button`,onClick:()=>g(e.id),className:`flex w-full items-center justify-between gap-3 rounded-lg border bg-surface p-3 text-left transition-colors ${m===e.id?`border-primary ring-1 ring-primary`:`border-border hover:border-foreground-subtle/30`}`,children:[c(`span`,{className:`text-xs font-semibold text-foreground`,children:e.name}),c(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${Y[e.status]}`,children:e.status})]},e.id))}),d.length>0&&c(`div`,{className:`flex justify-end pt-1`,children:c(`button`,{type:`button`,onClick:x,disabled:!m,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:o(`integrations.brokerStep.useThisBroker`,`Use this broker`)})})]}),s===`new`&&a(`div`,{className:`space-y-3`,children:[a(`div`,{className:`space-y-1`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`integrations.brokerStep.name`,`Name`)}),c(`input`,{type:`text`,value:_,onChange:e=>y(e.target.value),placeholder:o(`integrations.brokerStep.myHomeAssistant`,`My Home Assistant`),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),b.isError&&c(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:b.error instanceof Error?b.error.message:String(b.error)}),c(P,{kind:e,...p===void 0?{}:{addonId:p},onSubmit:e=>{S(e).catch(()=>{})},onCancel:i,submitLabel:b.isPending?o(`integrations.brokerStep.creating`,`Creating…`):o(`integrations.brokerStep.createBroker`,`Create broker`),disabled:b.isPending||_.trim().length===0}),_.trim().length===0&&c(`p`,{className:`text-[10px] text-foreground-subtle`,children:o(`integrations.brokerStep.enterANameBeforeCreating`,`Enter a name before creating.`)})]})]})}e();function Z(e){return{status:e.status===`validated`||e.status===`rejected`||e.status===`inconclusive`||e.status===`unsupported`?e.status:e.success?`validated`:`rejected`,...e.error===void 0?{}:{error:e.error},...e.detail===void 0?{}:{detail:e.detail}}}var Q={validated:`border-success/30 bg-success/5 text-success`,rejected:`border-danger/30 bg-danger/5 text-danger`,inconclusive:`border-warning/30 bg-warning/5 text-warning`,unsupported:`border-border bg-surface text-foreground-subtle`};function ee({addonId:e,configSchema:t,canTest:n=!0,initialName:i,initialConfig:o,submitLabel:s,hideName:l=!1,onSave:u,onBack:d}){let{t:f}=j(),[p,m]=r(i??``),[h,g]=r(o??{}),[_,v]=r(null),x=E({onSuccess:e=>v(Z(e)),onError:e=>v({status:`inconclusive`,error:String(e)})}),C=S(),w=!n||_?.status===`validated`,T=(l||p.trim().length>0)&&w;return a(`div`,{className:`space-y-4`,children:[!l&&a(`div`,{children:[c(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:f(`integrations.integrationName`)}),c(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:f(`integrations.integrationNamePlaceholder`),className:`w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:border-primary/50`})]}),t&&c(M,{schema:t,values:h,onChange:e=>{g(e),v(null)},onAction:async(r,i,a)=>{let o=await C.mutateAsync({addonId:e,action:r,input:a??{}});if(n&&typeof o==`object`&&o){let n=o;if(!(typeof n.token==`string`||typeof n.sslCertificate==`string`||typeof n.host==`string`))return o;let r={...h};for(let[e,t]of Object.entries(n))typeof t==`string`&&e!==`summary`&&(r[e]=t);let i=y(t,r);g(i),v(null),x.mutate({addonId:e,settings:i})}return o}}),_&&c(`div`,{className:`rounded-lg border px-3 py-2 text-xs ${Q[_.status]}`,children:(e=>{switch(e.status){case`validated`:return e.detail?`${f(`integrations.connectionSuccess`)} — ${e.detail}`:f(`integrations.connectionSuccess`);case`rejected`:return`${f(`integrations.errorPrefix`)} ${e.error??``}`;case`inconclusive`:return`${f(`integrations.connectionInconclusive`,{defaultValue:`Could not be checked:`})} ${e.error??``}`;case`unsupported`:return e.error??f(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`})}})(_)}),a(`div`,{className:`flex items-center justify-between pt-2`,children:[c(`button`,{onClick:d,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:f(`integrations.back`)}),a(`div`,{className:`flex items-center gap-2`,children:[c(`button`,{onClick:()=>x.mutate({addonId:e,settings:y(t,h)}),disabled:x.isPending||!n,title:n?void 0:f(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`}),className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:x.isPending?f(`integrations.testing`):f(`integrations.testConnection`)}),c(`button`,{onClick:()=>u({name:p,config:y(t,h),secretKeys:[...b(t)]}),disabled:!T,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:s??f(`integrations.forward`)})]})]})]})}e();function te({open:e,onClose:t,scope:o}){let{t:s}=j(),l=C(),[d,f]=r(new Set),[h,g]=r(new Set),{data:y}=O({projection:`slim`}),b=n(()=>new Set((y??[]).map(e=>e.stableId)),[y]),x=i(async(e,t)=>{g(e=>new Set(e).add(t.stableId));try{await l.mutateAsync({addonId:e,candidate:t}),f(e=>new Set(e).add(t.stableId))}catch{}finally{g(e=>{let n=new Set(e);return n.delete(t.stableId),n})}},[l]),S=i((e,t)=>{let n=typeof t.prefilledConfig.host==`string`?t.prefilledConfig.host:null,r=b.has(t.stableId),i=d.has(t.stableId)||r,o=h.has(t.stableId);return a(`div`,{className:`flex items-center justify-between rounded-lg border border-border bg-surface px-3 py-2`,children:[a(`div`,{className:`min-w-0`,children:[c(`p`,{className:`truncate text-xs font-medium text-foreground`,children:t.suggestedName}),n&&c(`p`,{className:`truncate text-[10px] font-mono text-foreground-subtle`,children:n})]}),i?a(`span`,{className:`flex items-center gap-1 text-[11px] text-foreground-subtle`,children:[c(p,{className:`h-3.5 w-3.5`}),` `,r?s(`integrations.scanNetworkModal.alreadyAdded`,`Already added`):s(`integrations.scanNetworkModal.added`,`Added`)]}):a(`button`,{type:`button`,onClick:()=>void x(e,t),disabled:o,className:`flex items-center gap-1 rounded-md bg-primary px-2.5 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-50`,children:[o?c(v,{className:`h-3.5 w-3.5 animate-spin`}):c(m,{className:`h-3.5 w-3.5`}),s(`common.add`,`Add`)]})]},t.stableId)},[d,h,b,x,s]);if(!e)return null;let w=o?`Scan network — ${o.label}`:`Scan network for devices`;return a(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[c(`div`,{className:`absolute inset-0 bg-black/60`,onClick:t}),a(`div`,{className:`relative z-10 flex w-full max-w-2xl flex-col max-h-[calc(90dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl`,children:[a(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[a(`div`,{className:`flex items-center gap-2`,children:[c(u,{className:`h-4 w-4 text-primary`}),c(`h2`,{className:`text-sm font-semibold text-foreground`,children:w})]}),c(`button`,{onClick:t,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:c(_,{className:`h-4 w-4`})})]}),o?c(re,{scope:o,onAdopt:S,onReset:()=>f(new Set)}):c(ne,{onAdopt:S,onReset:()=>f(new Set)})]})]})}function ne({onAdopt:e,onReset:r}){let{t:s}=j(),l=D(),u=i(()=>{r(),l.mutate({})},[l,r]);t(()=>{!l.isPending&&!l.data&&u()},[]);let d=n(()=>(l.data?.groups??[]).filter(e=>e.candidates.length>0),[l.data]),f=n(()=>d.reduce((e,t)=>e+t.candidates.length,0),[d]);return a(o,{children:[c(`div`,{className:`flex items-center justify-end gap-2 border-b border-border px-5 py-2 shrink-0`,children:a(`button`,{onClick:u,disabled:l.isPending,className:`flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[c(g,{className:`h-3.5 w-3.5 ${l.isPending?`animate-spin`:``}`}),s(`integrations.scanNetworkModal.reScan`,`Re-scan`)]})}),a(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[l.isPending&&c(ie,{label:s(`integrations.scanNetworkModal.scanningTheLocalNetwork`,`Scanning the local network…`)}),!l.isPending&&l.isError&&c($,{}),!l.isPending&&l.data&&d.length===0&&c(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:s(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)}),!l.isPending&&d.length>0&&c(`p`,{className:`text-xs text-foreground-subtle`,children:s(`integrations.scanNetworkModal.found`,{count:f})}),!l.isPending&&d.map(t=>a(`div`,{className:`space-y-1.5`,children:[a(`div`,{className:`flex items-center gap-2`,children:[c(`span`,{className:`text-[11px] font-semibold text-foreground`,children:t.label}),a(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`(`,t.candidates.length,`)`]})]}),t.candidates.map(n=>e(t.addonId,n))]},t.addonId))]})]})}function re({scope:e,onAdopt:t,onReset:n}){let{t:s}=j(),l=x({addonId:e.addonId}).data??null,[d,f]=r({}),p=w(),m=i(()=>{n(),p.mutate({addonId:e.addonId,params:d})},[p,e.addonId,d,n]),h=p.data?.candidates??[];return c(o,{children:a(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[l&&c(M,{schema:l,values:d,onChange:f}),a(`button`,{onClick:m,disabled:p.isPending,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:[p.isPending?c(v,{className:`h-3.5 w-3.5 animate-spin`}):c(u,{className:`h-3.5 w-3.5`}),p.isPending?s(`integrations.scanNetworkModal.scanning`,`Scanning…`):s(`integrations.scanNetworkModal.scan`,`Scan`)]}),p.isError&&c($,{}),!p.isPending&&p.data&&h.length===0&&c(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:s(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)}),!p.isPending&&h.length>0&&a(`div`,{className:`space-y-1.5`,children:[c(`p`,{className:`text-xs text-foreground-subtle`,children:s(`integrations.scanNetworkModal.foundShort`,{count:h.length})}),h.map(n=>t(e.addonId,n))]})]})})}function ie({label:e}){return a(`div`,{className:`flex flex-col items-center py-12`,children:[c(v,{className:`h-6 w-6 animate-spin text-primary`}),c(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:e})]})}function $(){let{t:e}=j();return a(`div`,{className:`flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3`,children:[c(d,{className:`h-4 w-4 text-destructive mt-0.5 shrink-0`}),c(`p`,{className:`text-xs text-destructive`,children:e(`integrations.scanNetworkModal.theScanFailedTryAgain`,`The scan failed. Try again.`)})]})}export{ee as n,X as r,te as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{$ as e,G as t,J as n,L as r,S as i,q as a,x as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{D as s,It as c,dt as l,ln as u,or as d,ot as f,pi as p}from"./player-overlays-Db_o1Zm2.js";import{a as m,i as h,s as g}from"./video-Dzs93Xor.js";import{t as _}from"./key-round-CasJ848Z.js";import{An as v,Bl as y,Bn as b,Cu as x,It as S,Kt as ee,Lt as C,Mn as w,Nn as T,On as E,Pn as D,Un as O,Wt as te,cr as ne,du as k,er as re,iu as ie,jn as ae,qt as oe,ru as se,tr as A,va as ce}from"./src-
|
|
1
|
+
import{$ as e,G as t,J as n,L as r,S as i,q as a,x as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{D as s,It as c,dt as l,ln as u,or as d,ot as f,pi as p}from"./player-overlays-Db_o1Zm2.js";import{a as m,i as h,s as g}from"./video-Dzs93Xor.js";import{t as _}from"./key-round-CasJ848Z.js";import{An as v,Bl as y,Bn as b,Cu as x,It as S,Kt as ee,Lt as C,Mn as w,Nn as T,On as E,Pn as D,Un as O,Wt as te,cr as ne,du as k,er as re,iu as ie,jn as ae,qt as oe,ru as se,tr as A,va as ce}from"./src-BpDNu6in.js";import{t as j}from"./i18n-RHwbGLC0.js";import{t as M}from"./useTranslation-D3Is_4B6.js";import{B as le,a as ue,o as de}from"./index-DrWxDgY9.js";e();function N({id:e,title:t,icon:n,description:r,actions:a,tone:c=`default`,notice:l=null,onDismissNotice:u,children:d}){return o(te,{headingId:`access-${e}`,title:t,icon:n,actions:a,testId:`access-${e}`,children:i(`div`,{className:`${s} space-y-3`,children:[o(`div`,{className:k(`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:r}),l!==null&&o(pe,{notice:l,onDismiss:u}),d]})})}var fe={success:{icon:p,line:`border-success/30 text-foreground`,mark:`text-success`},danger:{icon:h,line:`border-danger/40 text-danger`,mark:`text-danger`}};function pe({notice:e,onDismiss:t}){let{t:n}=M(),r=fe[e.tone],a=r.icon;return i(`div`,{role:e.tone===`danger`?`alert`:`status`,className:k(`flex items-start gap-2 rounded-md border bg-surface px-3 py-2 text-[11px]`,r.line),children:[o(a,{className:k(`mt-0.5 h-3.5 w-3.5 shrink-0`,r.mark),"aria-hidden":!0}),o(`span`,{className:`min-w-0 flex-1`,children:e.message}),t!==void 0&&o(ie,{type:`button`,variant:`ghost`,size:`sm`,icon:l,"aria-label":n(`access.accessSection.dismiss`,`Dismiss`),onClick:t,className:`-my-1 h-5 w-5`})]})}function me(){let{data:e}=y();return t(()=>{let t=new Map;for(let n of e??[])t.set(n.id,n.username);return t},[e])}function P(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 F(e){return j.t(he[e])}var ge={active:`success`,expired:`warning`,revoked:`default`,current:`info`},_e={current:0,active:1,expired:2,revoked:3};function I(e,t){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?`—`:n.toLocaleString()}function ve({status:e}){return o(ne,{variant:ge[e],className:`text-[10px]`,children:F(e)})}function ye({row:e,action:t}){if(!t.isAvailable(e))return null;let n=t.icon,r=t.busyId===e.id;return i(O,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>t.onRun(e),disabled:t.disabled,"aria-label":j.t(`access.credentialColumns.actionOn`,{action:t.label,name:e.name}),className:t.tone===`neutral`?void 0:`text-danger hover:bg-danger/10`,children:[r?o(d,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):o(n,{className:`h-3 w-3`,"aria-hidden":!0}),t.label]})}function be(e){return[{key:`name`,header:j.t(`access.credentialColumns.name`,`Name`),sortValue:e=>e.name.toLowerCase(),render:e=>i(`div`,{className:`min-w-0 max-w-[18rem]`,children:[o(`div`,{className:`truncate font-medium text-foreground`,title:e.name,children:e.name}),e.detail!==null&&o(`div`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,title:e.detail,children:e.detail})]})},e.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:e=>i(`div`,{className:`min-w-[8rem] max-w-[16rem]`,children:[o(`div`,{className:`text-foreground`,children:e.kind}),e.scope!==null&&o(`div`,{className:`line-clamp-2 text-[10px] text-foreground-subtle`,title:e.scope,children:e.scope})]})},{key:`status`,header:j.t(`access.credentialColumns.status`,`Status`),sortValue:e=>_e[e.status],render:e=>o(ve,{status:e.status})},{key:`created`,header:j.t(`access.credentialColumns.created`,`Created`),sortValue:e=>e.createdAt,render:e=>o(`span`,{className:`text-foreground-subtle`,children:I(e.createdAt,`—`)})},{key:`lastUsed`,header:j.t(`access.credentialColumns.lastUsed`,`Last used`),sortValue:e=>e.lastUsedAt,render:e=>o(`span`,{className:`text-foreground-subtle`,children:I(e.lastUsedAt,j.t(`access.credentialColumns.never`))})},{key:`expires`,header:j.t(`access.credentialColumns.expires`,`Expires`),sortValue:e=>e.expiresAt,render:t=>o(`span`,{className:`text-foreground-subtle`,children:I(t.expiresAt,e.expiresNone)})},e.action===null?null:{key:`actions`,header:``,align:`right`,notSortableReason:j.t(`access.credentialColumns.actionsHeader`),render:t=>o(`div`,{className:`flex items-center justify-end gap-1`,children:[...e.extraActions??[],e.action].map(e=>e===null?null:o(ye,{row:t,action:e},e.label))})}].filter(e=>e!==null)}e();var L=6,xe={"current-session":`access.bulk.skipCurrentSession`,"not-active":`access.bulk.skipNotActive`};function R(e){let t=xe[e];return t===void 0?e:j.t(t)}function z(e,t){return j.t(t.key,{count:e})}function B(e,t){return j.t(`access.bulk.countOf`,{count:e,noun:z(e,t)})}function Se(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:F(e).toLowerCase()})).join(`, `)}function Ce(e,t){let n=e.slice(0,L).map(e=>`• ${e.name} — ${e.ownerName}`),r=e.length>L?[j.t(`access.bulk.previewMore`,{count:e.length-L})]:[];return[j.t(`access.bulk.previewIntro`,{what:B(e.length,t),breakdown:Se(e)}),``,...n,...r].join(`
|
|
2
2
|
`)}async function V(e,t,n){let r=String(t.length),i=await e({title:j.t(`access.bulk.confirmTitle`,{what:B(t.length,n)}),message:Ce(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:z(2,n)})});return i!==null&&i.trim()===r}function H(e,t,r){let i=A(),a=x.auth.revokeCredentials.useMutation(),[o,s]=n(null);return{run:async n=>{if(n.length===0||!await V(i,n,t))return!1;s(null);try{let r=await a.mutateAsync({kind:e,ids:n.map(e=>e.id),confirmCount:n.length}),i=r.skipped.map(e=>R(e.reason));return s({tone:`success`,message:i.length>0?j.t(`access.bulk.revokedSkipped`,{what:B(r.revoked.length,t),count:i.length,reasons:[...new Set(i)].join(`, `)}):j.t(`access.bulk.revoked`,{what:B(r.revoked.length,t)})}),!0}catch(e){return s({tone:`danger`,message:j.t(`access.bulk.revokeFailed`,{error:e instanceof Error?e.message:j.t(`access.bulk.requestFailed`)})}),!1}finally{r()}},busy:a.isPending,outcome:o,dismiss:()=>s(null)}}function we(e,t){let r=A(),i=x.auth.revokeCredentials.useMutation(),[a,o]=n(null);return{run:async n=>{if(n.length===0||!await V(r,n,e))return!1;o(null);let a=n.filter(e=>e.kind===`Scoped`).map(e=>e.id),s=n.filter(e=>e.kind===`Admin`).map(e=>e.id);try{let t=[],n=[];if(a.length>0){let e=await i.mutateAsync({kind:`scoped-token`,ids:a,confirmCount:a.length});t.push(...e.revoked),n.push(...e.skipped)}if(s.length>0){let e=await i.mutateAsync({kind:`admin-token`,ids:s,confirmCount:s.length});t.push(...e.revoked),n.push(...e.skipped)}let r=n.map(e=>R(e.reason));return o({tone:`success`,message:r.length>0?j.t(`access.bulk.revokedSkipped`,{what:B(t.length,e),count:r.length,reasons:[...new Set(r)].join(`, `)}):j.t(`access.bulk.revoked`,{what:B(t.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:i.isPending,outcome:a,dismiss:()=>o(null)}}function Te(e,t,r){let i=A(),[a,o]=n(!1),[s,c]=n(null);return{run:async n=>{if(n.length===0||!await V(i,n,e))return!1;c(null),o(!0);let a=[],s=0;for(let e of n)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),r(),a.length===0?(c({tone:`success`,message:j.t(`access.bulk.revoked`,{what:B(s,e)})}),!0):(c({tone:`danger`,message:j.t(a.length>3?`access.bulk.eachPartialMore`:`access.bulk.eachPartial`,{what:B(s,e),count:a.length,details:a.slice(0,3).join(`; `)})}),s>0)},busy:a,outcome:s,dismiss:()=>c(null)}}e();var Ee={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}]},U={status:`access.credentialTable.groupStatus`,owner:`access.credentialTable.groupOwner`,kind:`access.credentialTable.groupKind`},De=e=>e.status!==`current`,Oe=[`active`,`current`];function W({rows:e,label:r,isLoading:a,loadError:s,emptyText:c,hideOwner:l=!1,expiresNone:u,action:f,extraActions:p,bulk:m,defaultStatus:h=Oe}){let{t:g}=M(),[_]=n(()=>h.length===0?{search:``,facets:[]}:{search:``,facets:[],groups:{status:[...h]}}),v=S(e,Ee,_),[y,x]=n(()=>new Set),w=u??g(`access.credentialColumns.never`),T=t(()=>be({hideOwner:l,expiresNone:w,action:f??null,...p===void 0?{}:{extraActions:p}}),[l,w,f,p,g]),E=t(()=>m===void 0?()=>!1:e=>De(e)&&m.isSelectable(e),[m]),D=t(()=>v.rows.filter(e=>y.has(e.id)&&E(e)),[v.rows,y,E]);return a?i(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[o(d,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),g(`access.credentialTable.loading`,{label:r})]}):s===null?i(`div`,{className:`space-y-3`,children:[o(C,{state:v.state,facets:v.facets,groups:v.groups.filter(e=>!(l&&e.id===`owner`)).map(e=>({...e,label:U[e.id]===void 0?e.id:g(U[e.id]),...e.id===`status`?{facetLabel:e=>F(e)}:{}})),labels:{searchPlaceholder:g(`access.credentialTable.searchPlaceholder`,{label:r}),searchLabel:g(`access.credentialTable.searchLabel`,{label:r}),facetsLabel:g(`access.credentialTable.facetsLabel`,{label:r}),clearLabel:g(`access.credentialTable.clearFilters`)},onSearch:v.setSearch,onToggleFacet:v.toggleFacet,onToggleGroupFacet:v.toggleGroupFacet,onClear:v.clear}),m!==void 0&&o(ke,{bulk:m,shown:v.rows.filter(E),targets:D,onSelect:x}),o(ee,{columns:T,rows:v.rows,rowKey:e=>e.id,minWidthPx:l?760:860,maxBodyHeight:oe,defaultSort:{columnKey:`created`,dir:`desc`},pageSize:25,paginationLabels:{navLabel:g(`access.credentialTable.pagesLabel`,{label:r}),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:r}):c,rowClassName:e=>e.status===`revoked`||e.status===`expired`?`opacity-70`:void 0,...m===void 0?{}:{selection:{selected:y,onChange:x,isSelectable:E,rowLabel:e=>g(`access.credentialTable.rowLabel`,{name:e.name,owner:e.ownerName}),pageLabel:g(`access.credentialTable.pageLabel`,{noun:z(1,m.noun)})}}})]}):o(b,{title:g(`access.credentialTable.couldNotLoad`,`Could not load {{label}}`,{label:r}),message:s})}function ke({bulk:e,shown:t,targets:n,onSelect:r}){let{t:a}=M(),{revoke:s,noun:u}=e,f=(e.quickSelect??[]).map(e=>({...e,rows:t.filter(e.match)})).filter(e=>e.rows.length>0),p=async()=>{await s.run(n)&&r(new Set)};return i(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`bulk-bar`,children:[t.length>0&&o(O,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(new Set(t.map(e=>e.id))),children:a(`access.credentialTable.selectAllShown`,{count:t.length})}),f.map(e=>i(O,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(new Set(e.rows.map(e=>e.id))),children:[e.label,` (`,String(e.rows.length),`)`]},e.label)),n.length>0&&i(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[o(`span`,{className:`text-[11px] tabular-nums text-foreground`,"aria-live":`polite`,children:a(`access.credentialTable.selectedLabel`,{what:B(n.length,u)})}),i(O,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r(new Set),children:[o(l,{className:`h-3 w-3`,"aria-hidden":!0}),a(`access.credentialTable.clearSelection`,`Clear selection`)]}),i(O,{type:`button`,variant:`danger`,size:`sm`,disabled:s.busy,onClick:()=>void p(),children:[s.busy?o(d,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):o(c,{className:`h-3 w-3`,"aria-hidden":!0}),a(`access.credentialTable.revoke`,{what:B(n.length,u)})]})]})]})}var G=(e,t)=>t===null?`—`:e.get(t)??t;function K(e,t){return e!=null&&e<=t?`expired`:`active`}function Ae(e,t,n){return{id:e.id,name:n.client(e.client),detail:e.ip,ownerId:e.userId,ownerName:G(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 je(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 Me=`Scoped`,q=`Admin`;function Ne(e,t,n,r,i){return{id:e.id,name:e.name,detail:`${e.tokenPrefix}…`,ownerId:t,ownerName:G(n,t),kind:Me,scope:r,status:K(e.expiresAt,i),createdAt:e.createdAt,lastUsedAt:e.lastUsedAt??null,expiresAt:e.expiresAt??null}}function Pe(e,t,n){return{id:e.id,name:e.name,detail:`${e.tokenPrefix}…`,ownerId:e.createdBy,ownerName:G(t,e.createdBy),kind:q,scope:`Full administrator`,status:e.revokedAt===null?K(e.expiresAt,n):`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}var Fe={"grid-view":`Grid`,"events-view":`Events`};function Ie(e,t){return e.map(e=>t.get(e)??`#${String(e)}`).join(`, `)}function Le(e,t,n,r){let i=Fe[e.scope.kind];return{id:e.id,name:`${i} · ${String(e.scope.deviceIds.length)} camera${e.scope.deviceIds.length===1?``:`s`}`,detail:`${e.tokenPrefix}…`,ownerId:e.userId,ownerName:G(t,e.userId),kind:e.scope.talk===!0?`${i} + talk`:i,scope:Ie(e.scope.deviceIds,n),status:K(e.expiresAt,r),createdAt:e.createdAt,lastUsedAt:e.lastUsedAt??null,expiresAt:e.expiresAt}}function J(e){return`${e.provider}\u0000${e.subject}`}function Re(e,t){return{id:J(e),name:e.label??e.subject,detail:e.issuer,ownerId:e.userId,ownerName:G(t,e.userId),kind:e.provider,scope:null,status:`active`,createdAt:e.linkedAt,lastUsedAt:null,expiresAt:null}}function ze(e,t){let n=e.allowedProviders;return{id:e.id,name:e.label,detail:`${e.tokenPrefix}…`,ownerId:e.userId??null,ownerName:G(t,e.userId??null),kind:e.isAdmin===!0?`Admin`:`Regular`,scope:n===void 0||n===`*`?`All providers`:n.join(`, `)||`All providers`,status:`active`,createdAt:e.createdAt??null,lastUsedAt:e.lastUsedAt??null,expiresAt:null}}var Y=40,Be=[{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`}],Ve=[{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`}],He=[{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 X(e,t){return e.find(e=>e.test.test(t))?.name??null}function Ue(e){return e.length<=Y?e:`${e.slice(0,Y)}…`}function Z(e){if(e===null||e.trim().length===0)return{label:j.t(`helpers.sessionClient.unknownDevice`),raw:null};let t=e.trim(),n=X(He,t);if(n!==null)return{label:n,raw:t};let r=X(Be,t),i=X(Ve,t);return r!==null&&i!==null?{label:j.t(`helpers.sessionClient.browserOnSystem`,{browser:r,system:i}),raw:t}:r===null?{label:Ue(t),raw:t}:{label:r,raw:t}}var We={password:`helpers.sessionClient.method.password`,passkey:`helpers.sessionClient.method.passkey`,sso:`helpers.sessionClient.method.sso`,handoff:`helpers.sessionClient.method.handoff`,exchange:`helpers.sessionClient.method.exchange`};function Q(e){let t=We[e];return t===void 0?e:j.t(t)}function $(e){if(e==null)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}e();function Ge(e,t){return e instanceof Error&&e.message.length>0?e.message:t}function Ke(e){let{t}=M(),s=f(),[c,l]=n(!1),[u,p]=n(``),[m,h]=n(null),[g,y]=n(null),b=a(null),x=r(e=>{b.current?.(e),b.current=null,l(!1),p(``),h(null),y(null)},[]),S=r(()=>new Promise(e=>{b.current?.(null),b.current=e,y(null),l(!0)}),[]),ee=async()=>{h(`password`),y(null);try{let{reauthToken:e}=await s.reauthenticate({password:u});x(e)}catch(e){y(Ge(e,`Password is incorrect`)),h(null)}},C=async()=>{h(`passkey`),y(null);try{let{optionsJSON:e}=await s.reauthBeginPasskey();if(!ue(e))throw Error(`passkey authentication options missing challenge`);let t=await de({optionsJSON:e}),{reauthToken:n}=await s.reauthenticate({passkeyResponse:Object.fromEntries(Object.entries(t))});x(n)}catch(e){y(Ge(e,`Passkey verification failed`)),h(null)}};return{requestProof:S,dialog:o(E,{open:c,onOpenChange:e=>!e&&x(null),children:i(v,{children:[i(T,{children:[o(D,{children:t(`auth.reauthDialog.confirmItSYou`,`Confirm it’s you`)}),o(ae,{children:t(`auth.reauthDialog.needsPassword`,{action:e})})]}),i(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),u.length>0&&m===null&&ee()},children:[o(se,{type:`password`,autoComplete:`current-password`,placeholder:t(`auth.reauthDialog.currentPassword`,`Current password`),value:u,onChange:e=>p(e.target.value),"aria-label":t(`auth.reauthDialog.currentPassword`,`Current password`)}),g!==null&&o(`p`,{role:`alert`,className:`text-xs text-danger`,children:g}),i(w,{className:`flex flex-wrap gap-2`,children:[i(O,{type:`button`,variant:`outline`,disabled:m!==null,onClick:()=>void C(),children:[m===`passkey`?o(d,{className:`h-4 w-4 animate-spin`}):o(_,{className:`h-4 w-4`}),t(`auth.reauthDialog.useAPasskey`,`Use a passkey`)]}),i(O,{type:`submit`,disabled:u.length===0||m!==null,children:[m===`password`&&o(d,{className:`h-4 w-4 animate-spin`}),t(`common.confirm`,`Confirm`)]})]})]})]})})}}e();var qe={key:`access.nouns.shareLink`};function Je(e){let{t:r}=M(),i=re(),a=x.useUtils(),o=x.auth.listShareTokens.useQuery({owner:e}),s=me(),{data:l}=ce({isCamera:!0,projection:`slim`}),[u,d]=n(null),f=()=>void a.auth.listShareTokens.invalidate(),p=x.auth.revokeShareToken.useMutation({onSuccess:f,onError:e=>d(`Revoke failed: ${e.message}`)}),m=t(()=>{let e=new Map;for(let t of l??[])e.set(t.id,t.name);return e},[l]),h=Date.now(),g=(o.data??[]).map(e=>Le(e,s,m,h)),_=async e=>{await i({title:r(`users.shareLinksSection.revokeShareLink`,`Revoke share link`),message:r(`users.shareLinksSection.anyoneHoldingThisLinkTo`,`Anyone holding this link to {{value1}} loses access immediately. This cannot be undone.`,{value1:e.scope??e.name}),confirmLabel:r(`users.shareLinksSection.revoke`,`Revoke`),variant:`danger`})&&(d(null),p.mutate({id:e.id}))};return{rows:g,refresh:f,error:u,clearError:()=>d(null),isLoading:o.isLoading,loadError:o.isError?o.error?.message??`Request failed`:null,action:{label:r(`users.shareLinksSection.revoke`,`Revoke`),icon:c,isAvailable:()=>!0,onRun:e=>void _(e),busyId:p.isPending?p.variables?.id??null:null,disabled:p.isPending}}}function Ye(){let{t:e}=M(),t=Je(`self`);return o(N,{notice:P(t.error),onDismissNotice:t.clearError,id:`my-share-links`,title:e(`users.shareLinksSection.shareLinks`,`Share links`),icon:u,description:e(`users.shareLinksSection.viewOnlyLinksYouCreated`,`View-only links you created in the viewer app to share a grid or the events of some cameras. Revoking a link stops it working everywhere it was sent.`),children:o(W,{rows:t.rows,label:e(`users.shareLinksSection.shareLinks2`,`share links`),isLoading:t.isLoading,loadError:t.loadError,emptyText:`You have no share links.`,hideOwner:!0,action:t.action})})}function Xe(){let{user:e}=le();return e?.isAdmin?o(Ze,{}):null}function Ze(){let{t:e}=M(),t=Je(`all`),n=H(`share-link`,qe,t.refresh);return o(N,{notice:P(t.error,n.outcome),onDismissNotice:()=>{t.clearError(),n.dismiss()},id:`share-links`,title:e(`users.shareLinksSection.shareLinks`,`Share links`),icon:u,description:e(`users.shareLinksSection.everyUserSViewOnly`,`Every user's view-only share links. Revoking one stops it working for whoever it was sent to — a revoked link is deleted and cannot be restored.`),children:o(W,{rows:t.rows,label:e(`users.shareLinksSection.shareLinks2`,`share links`),isLoading:t.isLoading,loadError:t.loadError,emptyText:`No user has any share links.`,action:{...t.action,disabled:t.action.disabled||n.busy},bulk:{revoke:n,noun:qe,isSelectable:()=>!0,quickSelect:[{label:e(`users.shareLinksSection.selectExpired`,`Select expired`),match:e=>e.status===`expired`}]}})})}var Qe=864e5,$e={qr:`QR (by an admin)`,self:`Self-enrolled`},et={ios:`iOS`,android:`Android`,web:`Web`,other:`Other`};function tt(e){return e.status===`revoked`}function nt(e){return e.status!==`revoked`}function rt(e,t=`—`){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:n.toLocaleString()}function it(e,t){return e===null||Number.isNaN(e)?null:Math.floor((e-t)/Qe)}function at(e,t){let n=it(e,t);return n===null?`unknown`:n<0?`expired`:n<30?`soon`:`ok`}function ot(e,t){let n=it(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 st(e){if(e===null)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function ct(e){return e===null||e.length===0?`—`:e.length<=17?e:`${e.slice(0,8)}…${e.slice(-8)}`}function lt(e){return e.length<=10?e:`${e.slice(0,10)}…`}function ut(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 dt={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:lt(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(dt[e.stage]),reason:e.reason,kept:t})}}function pt(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 mt=11;function ht(e,t){let n=e.slice(0,mt);return t===null?n:`${n} · ${t}`}function gt(e){return{id:e.id,name:e.deviceName,detail:ht(e.fingerprint,e.lastUsedFrom),ownerId:e.userId,ownerName:e.username??e.userId,kind:et[e.platform],scope:$e[e.enrolledVia],status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function _t(e,t){return{id:e.id,name:e.deviceName,detail:null,ownerId:null,ownerName:t,kind:et[e.platform],scope:null,status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function vt({sessions:e,isLoading:t,loadError:n,emptyText:r,onRevoke:a,revokingId:s}){let{t:c}=M();return t?i(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[o(d,{className:`h-3.5 w-3.5 animate-spin`}),c(`auth.sessionsList.loadingSessions`,`Loading sessions…`)]}):n===null?e.length===0?o(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center`,children:r}):o(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:e.map(e=>o(yt,{session:e,revoking:s===e.id,onRevoke:()=>a(e)},e.id))}):i(`div`,{className:`text-[11px] text-danger`,children:[c(`auth.sessionsList.couldNotLoadSessions`,`Could not load sessions:`),` `,n]})}function yt({session:e,revoking:t,onRevoke:n}){let{t:r}=M(),a=Z(e.client);return i(`li`,{"data-testid":`session-row`,className:`flex items-start gap-3 px-3 py-2 text-xs`,children:[o(m,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-foreground-subtle`}),i(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[i(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[o(`span`,{className:`font-medium text-foreground truncate`,title:a.raw??void 0,children:a.label}),e.current&&o(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:r(`auth.sessionsList.thisDevice`,`This device`)})]}),i(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[o(`span`,{children:Q(e.method)}),o(`span`,{className:`font-mono`,children:e.ip??r(`auth.sessionsList.ipUnknown`,`IP unknown`)}),o(`span`,{children:r(`auth.sessionsList.lastActive`,{when:$(e.lastUsedAt)})}),o(`span`,{children:r(`auth.sessionsList.expires`,{when:$(e.expiresAt)})})]})]}),!e.current&&i(`button`,{onClick:n,disabled:t,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[t?o(d,{className:`h-3 w-3 animate-spin`}):o(g,{className:`h-3 w-3`}),r(`auth.sessionsList.signOut`,`Sign out`)]})]})}export{H as A,ze as C,Ae as D,je as E,me as F,we as M,N,Ne as O,P,Pe as S,Re as T,Ke as _,nt as a,$ as b,ot as c,rt as d,ut as f,Ye as g,Xe as h,tt as i,Te as j,W as k,ft as l,lt as m,gt as n,pt as o,ct as p,_t as r,st as s,vt as t,at as u,Z as v,J as w,q as x,Q as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,J as t,S as n,x as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{M as i}from"./src-CL0G8g2V.js";import{J as a,R as o,Y as s}from"./index-CeO2wVZi.js";e();function c({title:e,children:t}){return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`border-b border-border px-4 py-2.5`,children:r(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:e})}),r(`div`,{className:`p-4`,children:t})]})}function l({name:e,cssVar:t,hex:i}){return n(`div`,{className:`flex flex-col items-center gap-1.5`,children:[r(`div`,{className:`h-10 w-10 rounded-lg border border-border shadow-inner`,style:{backgroundColor:t?`var(${t})`:i}}),r(`span`,{className:`text-[10px] text-foreground-subtle text-center leading-tight`,children:e})]})}var u={sections:[{id:`demo`,title:`Demo Fields`,columns:2,fields:[{key:`name`,type:`text`,label:`Name`,placeholder:`Enter name`},{key:`count`,type:`number`,label:`Count`,min:0,max:100,unit:`items`},{key:`enabled`,type:`boolean`,label:`Enabled`},{key:`mode`,type:`select`,label:`Mode`,options:[{value:`a`,label:`Alpha`},{value:`b`,label:`Beta`}]},{key:`tags`,type:`tags`,label:`Tags`,span:2,suggestions:[`camera`,`zone`,`alert`]},{key:`confidence`,type:`slider`,label:`Confidence`,min:0,max:100,step:5,unit:`%`,span:2},{key:`info`,type:`info`,label:`Note`,content:`This is an informational message for the user.`,variant:`info`}]}]};function d(){let[e,d]=t({name:`Example`,count:10,enabled:!0,mode:`a`,tags:[`camera`],confidence:60});return n(`div`,{className:`p-6 space-y-6 max-w-5xl mx-auto`,children:[n(`div`,{className:`mb-6`,children:[r(`h1`,{className:`text-xl font-bold text-foreground`,children:`Component Showroom`}),r(`p`,{className:`text-sm text-foreground-subtle mt-1`,children:`All UI components at a glance`})]}),r(c,{title:`Typography`,children:n(`div`,{className:`space-y-3`,children:[r(`h1`,{className:`text-2xl font-bold text-foreground`,children:`Heading 1 — Display title`}),r(`h2`,{className:`text-xl font-semibold text-foreground`,children:`Heading 2 — Section title`}),r(`h3`,{className:`text-base font-semibold text-foreground`,children:`Heading 3 — Card title`}),r(`h4`,{className:`text-sm font-semibold text-foreground`,children:`Heading 4 — Sub-section`}),r(`p`,{className:`text-sm text-foreground`,children:`Body text — Regular paragraph content goes here. It uses the foreground color.`}),r(`p`,{className:`text-sm text-foreground-subtle`,children:`Subtle text — Secondary/descriptive text with reduced emphasis.`}),r(`p`,{className:`text-xs text-foreground-subtle uppercase tracking-wider font-semibold`,children:`Label / Caption`}),r(`p`,{className:`text-xs text-foreground-disabled`,children:`Disabled / placeholder text`})]})}),r(c,{title:`Colors`,children:n(`div`,{className:`flex flex-wrap gap-4`,children:[r(l,{name:`primary`,cssVar:`--color-primary`}),r(l,{name:`background`,cssVar:`--color-background`}),r(l,{name:`surface`,cssVar:`--color-surface`}),r(l,{name:`foreground`,cssVar:`--color-foreground`}),r(l,{name:`success`,cssVar:`--color-success`}),r(l,{name:`warning`,cssVar:`--color-warning`}),r(l,{name:`danger`,cssVar:`--color-danger`}),r(l,{name:`info`,cssVar:`--color-info`}),r(l,{name:`border`,cssVar:`--color-border`}),r(`div`,{className:`w-px`}),r(l,{name:`onvif`,hex:`#3b82f6`}),r(l,{name:`hikvision`,hex:`#a855f7`}),r(l,{name:`reolink`,hex:`#06b6d4`}),r(l,{name:`ha`,hex:`#22d3ee`}),r(l,{name:`rtsp`,hex:`#78716c`})]})}),r(c,{title:`Buttons`,children:n(`div`,{className:`flex flex-wrap gap-3`,children:[r(`button`,{className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white hover:opacity-90 transition-opacity`,children:`Primary`}),r(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-border bg-surface px-4 py-2 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors`,children:`Secondary`}),r(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-danger/40 bg-danger/10 px-4 py-2 text-sm font-medium text-danger hover:bg-danger/20 transition-colors`,children:`Danger`}),r(`button`,{disabled:!0,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white opacity-40 cursor-not-allowed`,children:`Disabled`}),r(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-warning/40 bg-warning/10 px-4 py-2 text-sm font-medium text-warning hover:bg-warning/20 transition-colors`,children:`Warning`}),r(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-success/40 bg-success/10 px-4 py-2 text-sm font-medium text-success hover:bg-success/20 transition-colors`,children:`Success`})]})}),r(c,{title:`Inputs`,children:n(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[n(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Text input`}),r(`input`,{type:`text`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`Type something...`})]}),n(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Number input`}),r(`input`,{type:`number`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`0`})]}),n(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Password input`}),r(`input`,{type:`password`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`••••••••`})]}),n(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Select`}),n(`select`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,children:[r(`option`,{children:`Option A`}),r(`option`,{children:`Option B`}),r(`option`,{children:`Option C`})]})]}),n(`div`,{className:`md:col-span-2`,children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Textarea`}),r(`textarea`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 resize-y min-h-[60px]`,placeholder:`Enter multi-line text...`,rows:3})]}),r(`div`,{children:n(`label`,{className:`flex items-center gap-2 cursor-pointer select-none`,children:[r(`input`,{type:`checkbox`,className:`h-3.5 w-3.5 rounded border-border accent-primary`,defaultChecked:!0}),r(`span`,{className:`text-xs font-medium text-foreground`,children:`Checkbox (checked)`})]})}),r(`div`,{children:n(`div`,{className:`flex items-center justify-between`,children:[r(`span`,{className:`text-xs font-medium text-foreground`,children:`Toggle switch`}),r(f,{})]})}),n(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Slider`}),r(`input`,{type:`range`,className:`w-full h-1 accent-primary cursor-pointer`,min:0,max:100,defaultValue:60})]}),n(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Tags example`}),r(`div`,{className:`flex flex-wrap gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 min-h-[38px]`,children:[`camera`,`zone`,`alert`].map(e=>r(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary`,children:e},e))})]})]})}),r(c,{title:`Badges`,children:n(`div`,{className:`space-y-3`,children:[n(`div`,{children:[r(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`StatusBadge`}),r(`div`,{className:`flex flex-wrap gap-2`,children:[`running`,`stopped`,`error`,`online`,`offline`,`idle`].map(e=>r(i,{status:e},e))})]}),n(`div`,{children:[r(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`CapabilityBadges`}),r(s,{capabilities:[`streaming`,`detection`,`recording`,`audio`]})]})]})}),r(c,{title:`Cards`,children:n(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[n(`div`,{className:`rounded-lg bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Surface card`}),r(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-surface`. Default card background."})]}),n(`div`,{className:`rounded-lg border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Bordered card`}),r(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `border border-border bg-surface`."})]}),n(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-primary mb-1`,children:`Accent card`}),r(`p`,{className:`text-xs text-foreground-subtle`,children:`Highlighted with primary color.`})]}),n(`div`,{className:`rounded-lg bg-background p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Background card`}),r(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-background`. Inset card."})]})]})}),r(c,{title:`Provider Icons`,children:r(`div`,{className:`flex flex-wrap gap-4`,children:[`onvif`,`hikvision`,`reolink`,`homeassistant`,`rtsp`,`onvif`].map(e=>r(a,{type:e,size:`lg`,showLabel:!0},e))})}),n(c,{title:`Form Builder Demo`,children:[r(o,{schema:u,values:e,onChange:d}),n(`details`,{className:`mt-3`,children:[r(`summary`,{className:`text-[10px] text-foreground-subtle cursor-pointer hover:text-foreground`,children:`View current values`}),r(`pre`,{className:`mt-2 rounded-md bg-background p-3 text-[10px] text-foreground-subtle overflow-auto`,children:JSON.stringify(e,null,2)})]})]}),r(c,{title:`Info Boxes`,children:r(`div`,{className:`space-y-2`,children:[{variant:`info`,label:`Info`,content:`This is an informational message. Use it for tips and hints.`},{variant:`warning`,label:`Warning`,content:`This action may have side effects. Proceed with caution.`},{variant:`success`,label:`Success`,content:`Operation completed successfully. All systems are green.`},{variant:`danger`,label:`Danger`,content:`This operation is irreversible. Data will be permanently deleted.`}].map(({variant:e,label:t,content:i})=>{let a={info:{border:`border-info`,bg:`bg-info/5`,text:`text-info`},warning:{border:`border-warning`,bg:`bg-warning/5`,text:`text-warning`},success:{border:`border-success`,bg:`bg-success/5`,text:`text-success`},danger:{border:`border-danger`,bg:`bg-danger/5`,text:`text-danger`}}[e];return n(`div`,{className:`rounded-md border-l-4 px-3 py-2.5 ${a.border} ${a.bg}`,children:[r(`p`,{className:`text-xs font-semibold mb-0.5 ${a.text}`,children:t}),r(`p`,{className:`text-xs text-foreground-subtle leading-relaxed`,children:i})]},e)})})})]})}function f(){let[e,n]=t(!0);return r(`button`,{type:`button`,role:`switch`,"aria-checked":e,onClick:()=>n(e=>!e),className:[`relative inline-flex h-4 w-8 shrink-0 items-center rounded-full transition-colors duration-150 cursor-pointer`,e?`bg-primary`:`bg-foreground-subtle/30`].join(` `),children:r(`span`,{className:[`inline-block h-3 w-3 rounded-full bg-white shadow transition-transform duration-150`,e?`translate-x-4`:`translate-x-0.5`].join(` `)})})}export{d as ShowroomPage};
|
|
1
|
+
import{$ as e,J as t,S as n,x as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{M as i}from"./src-BpDNu6in.js";import{J as a,R as o,Y as s}from"./index-DrWxDgY9.js";e();function c({title:e,children:t}){return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`border-b border-border px-4 py-2.5`,children:r(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:e})}),r(`div`,{className:`p-4`,children:t})]})}function l({name:e,cssVar:t,hex:i}){return n(`div`,{className:`flex flex-col items-center gap-1.5`,children:[r(`div`,{className:`h-10 w-10 rounded-lg border border-border shadow-inner`,style:{backgroundColor:t?`var(${t})`:i}}),r(`span`,{className:`text-[10px] text-foreground-subtle text-center leading-tight`,children:e})]})}var u={sections:[{id:`demo`,title:`Demo Fields`,columns:2,fields:[{key:`name`,type:`text`,label:`Name`,placeholder:`Enter name`},{key:`count`,type:`number`,label:`Count`,min:0,max:100,unit:`items`},{key:`enabled`,type:`boolean`,label:`Enabled`},{key:`mode`,type:`select`,label:`Mode`,options:[{value:`a`,label:`Alpha`},{value:`b`,label:`Beta`}]},{key:`tags`,type:`tags`,label:`Tags`,span:2,suggestions:[`camera`,`zone`,`alert`]},{key:`confidence`,type:`slider`,label:`Confidence`,min:0,max:100,step:5,unit:`%`,span:2},{key:`info`,type:`info`,label:`Note`,content:`This is an informational message for the user.`,variant:`info`}]}]};function d(){let[e,d]=t({name:`Example`,count:10,enabled:!0,mode:`a`,tags:[`camera`],confidence:60});return n(`div`,{className:`p-6 space-y-6 max-w-5xl mx-auto`,children:[n(`div`,{className:`mb-6`,children:[r(`h1`,{className:`text-xl font-bold text-foreground`,children:`Component Showroom`}),r(`p`,{className:`text-sm text-foreground-subtle mt-1`,children:`All UI components at a glance`})]}),r(c,{title:`Typography`,children:n(`div`,{className:`space-y-3`,children:[r(`h1`,{className:`text-2xl font-bold text-foreground`,children:`Heading 1 — Display title`}),r(`h2`,{className:`text-xl font-semibold text-foreground`,children:`Heading 2 — Section title`}),r(`h3`,{className:`text-base font-semibold text-foreground`,children:`Heading 3 — Card title`}),r(`h4`,{className:`text-sm font-semibold text-foreground`,children:`Heading 4 — Sub-section`}),r(`p`,{className:`text-sm text-foreground`,children:`Body text — Regular paragraph content goes here. It uses the foreground color.`}),r(`p`,{className:`text-sm text-foreground-subtle`,children:`Subtle text — Secondary/descriptive text with reduced emphasis.`}),r(`p`,{className:`text-xs text-foreground-subtle uppercase tracking-wider font-semibold`,children:`Label / Caption`}),r(`p`,{className:`text-xs text-foreground-disabled`,children:`Disabled / placeholder text`})]})}),r(c,{title:`Colors`,children:n(`div`,{className:`flex flex-wrap gap-4`,children:[r(l,{name:`primary`,cssVar:`--color-primary`}),r(l,{name:`background`,cssVar:`--color-background`}),r(l,{name:`surface`,cssVar:`--color-surface`}),r(l,{name:`foreground`,cssVar:`--color-foreground`}),r(l,{name:`success`,cssVar:`--color-success`}),r(l,{name:`warning`,cssVar:`--color-warning`}),r(l,{name:`danger`,cssVar:`--color-danger`}),r(l,{name:`info`,cssVar:`--color-info`}),r(l,{name:`border`,cssVar:`--color-border`}),r(`div`,{className:`w-px`}),r(l,{name:`onvif`,hex:`#3b82f6`}),r(l,{name:`hikvision`,hex:`#a855f7`}),r(l,{name:`reolink`,hex:`#06b6d4`}),r(l,{name:`ha`,hex:`#22d3ee`}),r(l,{name:`rtsp`,hex:`#78716c`})]})}),r(c,{title:`Buttons`,children:n(`div`,{className:`flex flex-wrap gap-3`,children:[r(`button`,{className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white hover:opacity-90 transition-opacity`,children:`Primary`}),r(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-border bg-surface px-4 py-2 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors`,children:`Secondary`}),r(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-danger/40 bg-danger/10 px-4 py-2 text-sm font-medium text-danger hover:bg-danger/20 transition-colors`,children:`Danger`}),r(`button`,{disabled:!0,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white opacity-40 cursor-not-allowed`,children:`Disabled`}),r(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-warning/40 bg-warning/10 px-4 py-2 text-sm font-medium text-warning hover:bg-warning/20 transition-colors`,children:`Warning`}),r(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-success/40 bg-success/10 px-4 py-2 text-sm font-medium text-success hover:bg-success/20 transition-colors`,children:`Success`})]})}),r(c,{title:`Inputs`,children:n(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[n(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Text input`}),r(`input`,{type:`text`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`Type something...`})]}),n(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Number input`}),r(`input`,{type:`number`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`0`})]}),n(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Password input`}),r(`input`,{type:`password`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`••••••••`})]}),n(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Select`}),n(`select`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,children:[r(`option`,{children:`Option A`}),r(`option`,{children:`Option B`}),r(`option`,{children:`Option C`})]})]}),n(`div`,{className:`md:col-span-2`,children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Textarea`}),r(`textarea`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 resize-y min-h-[60px]`,placeholder:`Enter multi-line text...`,rows:3})]}),r(`div`,{children:n(`label`,{className:`flex items-center gap-2 cursor-pointer select-none`,children:[r(`input`,{type:`checkbox`,className:`h-3.5 w-3.5 rounded border-border accent-primary`,defaultChecked:!0}),r(`span`,{className:`text-xs font-medium text-foreground`,children:`Checkbox (checked)`})]})}),r(`div`,{children:n(`div`,{className:`flex items-center justify-between`,children:[r(`span`,{className:`text-xs font-medium text-foreground`,children:`Toggle switch`}),r(f,{})]})}),n(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Slider`}),r(`input`,{type:`range`,className:`w-full h-1 accent-primary cursor-pointer`,min:0,max:100,defaultValue:60})]}),n(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Tags example`}),r(`div`,{className:`flex flex-wrap gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 min-h-[38px]`,children:[`camera`,`zone`,`alert`].map(e=>r(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary`,children:e},e))})]})]})}),r(c,{title:`Badges`,children:n(`div`,{className:`space-y-3`,children:[n(`div`,{children:[r(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`StatusBadge`}),r(`div`,{className:`flex flex-wrap gap-2`,children:[`running`,`stopped`,`error`,`online`,`offline`,`idle`].map(e=>r(i,{status:e},e))})]}),n(`div`,{children:[r(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`CapabilityBadges`}),r(s,{capabilities:[`streaming`,`detection`,`recording`,`audio`]})]})]})}),r(c,{title:`Cards`,children:n(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[n(`div`,{className:`rounded-lg bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Surface card`}),r(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-surface`. Default card background."})]}),n(`div`,{className:`rounded-lg border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Bordered card`}),r(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `border border-border bg-surface`."})]}),n(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-primary mb-1`,children:`Accent card`}),r(`p`,{className:`text-xs text-foreground-subtle`,children:`Highlighted with primary color.`})]}),n(`div`,{className:`rounded-lg bg-background p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Background card`}),r(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-background`. Inset card."})]})]})}),r(c,{title:`Provider Icons`,children:r(`div`,{className:`flex flex-wrap gap-4`,children:[`onvif`,`hikvision`,`reolink`,`homeassistant`,`rtsp`,`onvif`].map(e=>r(a,{type:e,size:`lg`,showLabel:!0},e))})}),n(c,{title:`Form Builder Demo`,children:[r(o,{schema:u,values:e,onChange:d}),n(`details`,{className:`mt-3`,children:[r(`summary`,{className:`text-[10px] text-foreground-subtle cursor-pointer hover:text-foreground`,children:`View current values`}),r(`pre`,{className:`mt-2 rounded-md bg-background p-3 text-[10px] text-foreground-subtle overflow-auto`,children:JSON.stringify(e,null,2)})]})]}),r(c,{title:`Info Boxes`,children:r(`div`,{className:`space-y-2`,children:[{variant:`info`,label:`Info`,content:`This is an informational message. Use it for tips and hints.`},{variant:`warning`,label:`Warning`,content:`This action may have side effects. Proceed with caution.`},{variant:`success`,label:`Success`,content:`Operation completed successfully. All systems are green.`},{variant:`danger`,label:`Danger`,content:`This operation is irreversible. Data will be permanently deleted.`}].map(({variant:e,label:t,content:i})=>{let a={info:{border:`border-info`,bg:`bg-info/5`,text:`text-info`},warning:{border:`border-warning`,bg:`bg-warning/5`,text:`text-warning`},success:{border:`border-success`,bg:`bg-success/5`,text:`text-success`},danger:{border:`border-danger`,bg:`bg-danger/5`,text:`text-danger`}}[e];return n(`div`,{className:`rounded-md border-l-4 px-3 py-2.5 ${a.border} ${a.bg}`,children:[r(`p`,{className:`text-xs font-semibold mb-0.5 ${a.text}`,children:t}),r(`p`,{className:`text-xs text-foreground-subtle leading-relaxed`,children:i})]},e)})})})]})}function f(){let[e,n]=t(!0);return r(`button`,{type:`button`,role:`switch`,"aria-checked":e,onClick:()=>n(e=>!e),className:[`relative inline-flex h-4 w-8 shrink-0 items-center rounded-full transition-colors duration-150 cursor-pointer`,e?`bg-primary`:`bg-foreground-subtle/30`].join(` `),children:r(`span`,{className:[`inline-block h-3 w-3 rounded-full bg-white shadow transition-transform duration-150`,e?`translate-x-4`:`translate-x-0.5`].join(` `)})})}export{d as ShowroomPage};
|