@camstack/addon-admin-ui 1.2.523 → 1.2.524
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/assets/{AddonAssetIcon-VXnpNoSj.js → AddonAssetIcon-CYhJlTNc.js} +1 -1
- package/dist/assets/Addons-BRZelwav.js +5 -0
- package/dist/assets/{AdminPage-B9JLs4rT.js → AdminPage-B1Q3Lunl.js} +1 -1
- package/dist/assets/{AdminSectionedPage-EY_w3HY7.js → AdminSectionedPage-CDZfKkL5.js} +1 -1
- package/dist/assets/AiProfiles-DC8OxOmV.js +3 -0
- package/dist/assets/BrokerEditorDialog-BX5w7CMy.js +1 -0
- package/dist/assets/Build-BVaH843t.js +40 -0
- package/dist/assets/{Calendars-ClQsQ24o.js → Calendars-q3MUFOBU.js} +1 -1
- package/dist/assets/Cluster-BKvY1r-a.js +1 -0
- package/dist/assets/ComposedDeviceEditDialog-BLfm22uf.js +1 -0
- package/dist/assets/CompositionBlockEditor-CJhCzXua.js +2 -0
- package/dist/assets/{CompositionEditorPage-NlrSqavW.js → CompositionEditorPage-dOMxAK9V.js} +1 -1
- package/dist/assets/Data-BVPL4yIo.js +2 -0
- package/dist/assets/DeviceDetail-BO5_O1mV.js +2 -0
- package/dist/assets/{DeviceDoActionFields-CSKUhZmq.js → DeviceDoActionFields-B50ODgPq.js} +1 -1
- package/dist/assets/{Devices-DtEGEpYK.js → Devices-CrdlW5-A.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-Er_9ZZbp.js → EmbedPlayerPage-JBC0G-2I.js} +1 -1
- package/dist/assets/History-BP1mlcwA.js +1 -0
- package/dist/assets/Identity-CY_zYbdN.js +1 -0
- package/dist/assets/IntegrationDetail-DCjuDqWm.js +1 -0
- package/dist/assets/IntegrationHub-DE2mwBdj.js +1 -0
- package/dist/assets/Integrations-BmHL7d-i.js +1 -0
- package/dist/assets/Integrations-CKAi9srg.js +1 -0
- package/dist/assets/{Library-CWzUsm1c.js → Library-BrWQ54N7.js} +1 -1
- package/dist/assets/Locations-3qWlGxP3.js +3 -0
- package/dist/assets/{Logs-CkwhOBrz.js → Logs-DYi_B3vg.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-B_J8Nub8.js → MaskShapeCanvas-D8Ke0Dim.js} +1 -1
- package/dist/assets/{MotionZonesSettings-DSDOgPiK.js → MotionZonesSettings--YqW3Onz.js} +1 -1
- package/dist/assets/MyAccess-DswPvXxB.js +2 -0
- package/dist/assets/Network-ChYmByS2.js +1 -0
- package/dist/assets/{NodeAddonsSettingsPanel-CNSfsu26.js → NodeAddonsSettingsPanel-DtvhgNC4.js} +1 -1
- package/dist/assets/Notifications-5onsUC_w.js +1 -0
- package/dist/assets/Pipeline-CgmB5Be8.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-Zr9fXd19.js → PrivacyMaskSettings-B-vpuYKA.js} +1 -1
- package/dist/assets/Recordings-Bglrn4rQ.js +1 -0
- package/dist/assets/RemoteGrid-C_9BszV-.js +1 -0
- package/dist/assets/{ScanNetworkModal-BO8EFEZ1.js → ScanNetworkModal-BnhOMFd1.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-CvqEBzUw.js → SceneMonitorEditor-CkaBEtmE.js} +1 -1
- package/dist/assets/SessionsList--FQem8XB.js +2 -0
- package/dist/assets/{Showroom-ClQBf_59.js → Showroom-B9J1IdLQ.js} +1 -1
- package/dist/assets/{System-d-rVWfA6.js → System-BVE97mrs.js} +1 -1
- package/dist/assets/Templates-CvoAkIdF.js +1 -0
- package/dist/assets/{Terminal-dvCiPiu7.js → Terminal-ieNh6d83.js} +5 -5
- package/dist/assets/{Viewer-D04RI6WE.js → Viewer-CAf7sAU0.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CO8DU_dY.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Bi1zqe4S.js} +1 -1
- package/dist/assets/{addon-icons-context-BsBIxYDH.js → addon-icons-context-RPiI9H0L.js} +1 -1
- package/dist/assets/{archive-Do2e48DU.js → archive-DQvuyIac.js} +1 -1
- package/dist/assets/{assignment-candidates-8RM__6oC.js → assignment-candidates-83kFfE1Z.js} +1 -1
- package/dist/assets/{authed-media-BYa-9dIZ.js → authed-media-BSoR_xYF.js} +1 -1
- package/dist/assets/{bell-off-RPYQoGP1.js → bell-off-C3u183tq.js} +1 -1
- package/dist/assets/{board-model-C9BgTio0.js → board-model-sARab1AV.js} +1 -1
- package/dist/assets/{boxes-BEverhi4.js → boxes-CVkAEP7e.js} +1 -1
- package/dist/assets/circle-slash-C86XHeiD.js +1 -0
- package/dist/assets/client-DcvpIFoh.js +674 -0
- package/dist/assets/{cloud-upload-nVfWiPdO.js → cloud-upload-CHQjI4ZF.js} +1 -1
- package/dist/assets/crop-Ct8elLRy.js +1 -0
- package/dist/assets/{device-integration-icon-C2pH_5Gl.js → device-integration-icon-DCuiIOlj.js} +1 -1
- package/dist/assets/device-picker-model-BvJkcx-a.js +1 -0
- package/dist/assets/{dist-BVH-vBQM.js → dist-B5lzpDFY.js} +1 -1
- package/dist/assets/{dist-ByEQfnSV.js → dist-BSrNHoV1.js} +1 -1
- package/dist/assets/{file-up-CUjXrmMK.js → file-up-C9_pj2VT.js} +1 -1
- package/dist/assets/{format-BccZ2tds.js → format-DGQA45Ye.js} +1 -1
- package/dist/assets/grip-vertical-C_VoFjYu.js +1 -0
- package/dist/assets/{hard-drive-download-DiXdli_I.js → hard-drive-download-DiC0khcq.js} +1 -1
- package/dist/assets/{hostInit-Bta217FF.js → hostInit-Dq6hIrVo.js} +1 -1
- package/dist/assets/{i18n-COiZcYwm.js → i18n-C-H4BlYV.js} +1 -1
- package/dist/assets/icons-C7pfBl-Q.js +1 -0
- package/dist/assets/index-DjwiZ7qT.css +2 -0
- package/dist/assets/index-o6kBNilE.js +4 -0
- package/dist/assets/{key-C0PivC5X.js → key-Cz6uvkUc.js} +1 -1
- package/dist/assets/{key-round-Cu5Tucyk.js → key-round-B9WTP907.js} +1 -1
- package/dist/assets/{layers-Cd1UYZNk.js → layers-DGMlfnn4.js} +1 -1
- package/dist/assets/{linked-devices-model-CFrDp7fw.js → linked-devices-model-D6PgoQtW.js} +1 -1
- package/dist/assets/{list-ordered-Bkr6PCeB.js → list-ordered-wHEw5a_e.js} +1 -1
- package/dist/assets/location-owned-usage-B-4MuD-Z.js +1 -0
- package/dist/assets/{log-in-DV8GfIgr.js → log-in-Da7IGp_j.js} +1 -1
- package/dist/assets/{memory-stick-C6TRN6ht.js → memory-stick-BLbgKSl7.js} +1 -1
- package/dist/assets/{message-square-plus-DTJ5QsLH.js → message-square-plus-CMdSHNUk.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-c0dc6497.js → mf-entry-bootstrap-0-e016a0f6.js} +2 -2
- package/dist/assets/{mic-off-gUMH3Z4J.js → mic-off-CIzR-elk.js} +1 -1
- package/dist/assets/{monitor-off-C4w1KSTZ.js → monitor-off-lToaeJ-K.js} +1 -1
- package/dist/assets/{monitor-smartphone-CpCqKvAV.js → monitor-smartphone-Dr1ELple.js} +1 -1
- package/dist/assets/mount-BvJkcx-a.js +1 -0
- package/dist/assets/{player-overlays-CZbAbeZY.js → player-overlays-oTS1TZZY.js} +1 -1
- package/dist/assets/{recycle-BaznD-UX.js → recycle-BNUPyJ7u.js} +1 -1
- package/dist/assets/remoteEntry-BK4ei3jy.js +1 -0
- package/dist/assets/{ruler-BSo-rKM0.js → ruler-CvDT4Z7Y.js} +1 -1
- package/dist/assets/{scan-eye-DN1vlvLP.js → scan-eye-BhxGMB3E.js} +1 -1
- package/dist/assets/{scissors-CC58_qMU.js → scissors-C-pdrglA.js} +1 -1
- package/dist/assets/{search-x-tQuhnR8q.js → search-x-wBrdZZXu.js} +1 -1
- package/dist/assets/{send-CAZEgHzo.js → send-D5hwnH6i.js} +1 -1
- package/dist/assets/{settings-2-BuBH9G2o.js → settings-2-D64sFGFI.js} +1 -1
- package/dist/assets/{shapes-D2hlOKTD.js → shapes-HTfCvSL2.js} +1 -1
- package/dist/assets/{sigma-Ceyn_S95.js → sigma-BYdS13dc.js} +1 -1
- package/dist/assets/{speaker-BRYEJSzP.js → speaker-DCCyafUF.js} +1 -1
- package/dist/assets/src-XEHc18wE.js +67 -0
- package/dist/assets/{step-inspector-model-BfR3NdqL.js → step-inspector-model-a05i0m0c.js} +1 -1
- package/dist/assets/{table-2-CuSc759e.js → table-2-BgDon14h.js} +1 -1
- package/dist/assets/{timer-reset-Bvn2aK40.js → timer-reset-Dst_i1Qg.js} +1 -1
- package/dist/assets/{unlink-BU_py8I2.js → unlink-CmmNdYky.js} +1 -1
- package/dist/assets/{usb-TZrC9eYC.js → usb-BCFcIAg4.js} +1 -1
- package/dist/assets/{use-device-bound-caps-CYR80PtH.js → use-device-bound-caps-CI6zlnII.js} +1 -1
- package/dist/assets/{use-scenes-feed-Ddftx740.js → use-scenes-feed-junBfGeR.js} +1 -1
- package/dist/assets/{use-stationary-objects-CJ3xxs43.js → use-stationary-objects-blP9Y5SS.js} +1 -1
- package/dist/assets/useEventInvalidation-BvJkcx-a.js +1 -0
- package/dist/assets/{useNodeUrlSelection-DNEz-JoD.js → useNodeUrlSelection-Cb470tqR.js} +1 -1
- package/dist/assets/user-round-D3ZUZuP3.js +1 -0
- package/dist/assets/{user-x-CYHlbR6F.js → user-x-891p2Gny.js} +1 -1
- package/dist/assets/{variable-BNQlwoos.js → variable-HM7A54CP.js} +1 -1
- package/dist/assets/{video-CrmOxhYy.js → video-Dx3E7zlj.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Bucq-FfY.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DHe9cBRl.js} +2 -2
- package/dist/index.html +10 -10
- package/dist/server/addon.js +43 -6
- package/package.json +1 -1
- package/dist/assets/Addons-DlINdzv0.js +0 -5
- package/dist/assets/AiProfiles-fuyzr8D4.js +0 -3
- package/dist/assets/BrokerEditorDialog-DoEQXizE.js +0 -1
- package/dist/assets/Build-CvZFLBc9.js +0 -40
- package/dist/assets/Cluster-D31IV0wr.js +0 -1
- package/dist/assets/ComposedDeviceEditDialog-Chymp38w.js +0 -1
- package/dist/assets/CompositionBlockEditor-CpPHLcVD.js +0 -2
- package/dist/assets/Data-BBsE7UVR.js +0 -2
- package/dist/assets/DeviceDetail-zZcKfcTs.js +0 -2
- package/dist/assets/History-DEuMaAFu.js +0 -1
- package/dist/assets/Identity-Bo-ulITU.js +0 -1
- package/dist/assets/IntegrationDetail-IopkO40B.js +0 -1
- package/dist/assets/IntegrationHub-CaKFrwmD.js +0 -1
- package/dist/assets/Integrations-B0XFfGvM.js +0 -1
- package/dist/assets/Integrations-DrmJI4oI.js +0 -1
- package/dist/assets/Locations-CUYgtHWg.js +0 -3
- package/dist/assets/MyAccess-kZWZLQ6w.js +0 -2
- package/dist/assets/Network-CsAvssW1.js +0 -1
- package/dist/assets/Notifications-eEXyaFax.js +0 -1
- package/dist/assets/Pipeline-CL-VwLPy.js +0 -1
- package/dist/assets/Recordings-BrITac0q.js +0 -1
- package/dist/assets/RemoteGrid-BGbiDThN.js +0 -1
- package/dist/assets/SessionsList-BkbXjQt1.js +0 -2
- package/dist/assets/Templates-BY9R_5lz.js +0 -1
- package/dist/assets/circle-slash-Bb_aa_QL.js +0 -1
- package/dist/assets/client-D-g0nOrC.js +0 -674
- package/dist/assets/crop-DVR1vsA9.js +0 -1
- package/dist/assets/device-picker-model-DBfk1Co5.js +0 -1
- package/dist/assets/icons-CDeaov6N.js +0 -1
- package/dist/assets/index-DnHMM2c9.css +0 -2
- package/dist/assets/index-Dqmlzvdc.js +0 -4
- package/dist/assets/location-owned-usage-E6eX4phu.js +0 -1
- package/dist/assets/mount-DBfk1Co5.js +0 -1
- package/dist/assets/remoteEntry-8jIMK97P.js +0 -1
- package/dist/assets/src-iRjUEwun.js +0 -67
- package/dist/assets/useEventInvalidation-DBfk1Co5.js +0 -1
- package/dist/assets/user-round-jCdxL4f8.js +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as l,Ei as u,Fn as d,Ht as f,In as p,Oi as m,Q as h,Qi as g,Vn as _,Zr as v,bi as y,fi as b,fr as x,ii as S,lr as C,mi as w,na as T,ra as E,st as D,ti as O,ur as k,vn as A,wn as j,zt as M}from"./player-overlays-oTS1TZZY.js";import{n as N,t as P}from"./cloud-upload-CHQjI4ZF.js";import{t as F}from"./circle-slash-C86XHeiD.js";import{t as I}from"./hard-drive-download-DiC0khcq.js";import{Ad as L,An as R,Ca as ee,Cr as te,Cu as ne,Ea as z,Et as B,Fd as V,Id as H,Jn as re,Kn as ie,Lu as ae,Nr as oe,Pr as se,Sa as ce,Su as le,Ta as ue,Tr as de,Yi as fe,Yn as pe,Zn as me,_a as he,_t as ge,ba as _e,bo as ve,br as ye,da as be,fa as xe,ga as Se,ha as Ce,iu as we,jn as Te,ma as Ee,mt as De,pa as Oe,ri as U,va as ke,vt as Ae,wa as je,wr as Me,wu as Ne,xa as Pe,xr as Fe,xu as Ie,ya as Le,yr as Re,yt as ze}from"./src-XEHc18wE.js";import{t as W}from"./i18n-C-H4BlYV.js";import{t as G}from"./useTranslation-BJr-n0es.js";import"./mount-BvJkcx-a.js";import{T as Be,hr as Ve,pr as He,yr as Ue}from"./index-o6kBNilE.js";import{t as We}from"./AdminSectionedPage-CDZfKkL5.js";import{t as Ge}from"./AdminPage-B1Q3Lunl.js";import{n as Ke}from"./authed-media-BSoR_xYF.js";import{t as K}from"./format-size-DIxKXxtj.js";import{a as qe,c as Je,l as Ye,n as Xe,o as Ze,s as Qe,t as $e,u as et}from"./location-owned-usage-B-4MuD-Z.js";o();function tt(){let{t:n}=G(),a=s(),o=D(),{data:c,isLoading:l,isError:u}=Ne({}),d=ne(),f=t(()=>d.data??[],[d.data]),{data:p}=we({},{refetchOnWindowFocus:!1}),m=t(()=>$e(c??[],p?.locations),[c,p?.locations]),{data:h}=le({},{refetchOnWindowFocus:!1}),g=t(()=>qe(h),[h]),{state:_,openNew:v,openEdit:y,close:b}=ge(),[x,S]=Ae(`type`),C=()=>{S(null),b()},w=e=>{S(e),v()},T=e=>{S(null),y(e.id)},E=c??[],O=_.mode===`edit`?E.find(e=>e.id===_.id)??null:null;i(()=>{_.mode===`new`&&(x===null||x===``)&&(S(null),b())},[_.mode,x,b,S]),i(()=>{_.mode===`edit`&&!l&&O===null&&(S(null),b())},[_.mode,l,O,b,S]),i(()=>{_.mode===`closed`&&x!==null&&S(null)},[_.mode,x,S]);let k=Ie({onSuccess:()=>{a.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),A=ae({onSuccess:()=>{a.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),j=async(e,t)=>{Ye(t)&&!await o({title:n(`system.storage.disable`,`Disable "{{displayName}}"?`,{displayName:e.displayName}),message:n(`system.storage.nothingIsDeletedSetThe`,`{{consequence}} Nothing is deleted — set the location back to Read-only or Active to bring its footage back.`,{consequence:Je(t).consequence}),confirmLabel:n(`common.disable`,`Disable`),variant:`danger`})||A.mutate(Qe(e,{mode:t}))},M=async e=>{if(await o({title:n(`system.storage.deleteLocation`,`Delete location "{{displayName}}"?`,{displayName:e.displayName}),message:n(`system.storage.thisRemovesTheLocationRecord`,`This removes the location record. Files on disk are not deleted; the underlying directory or remote path stays untouched.`),confirmLabel:n(`common.delete`,`Delete`),variant:`danger`}))try{await k.mutateAsync({id:e.id}),_.mode===`edit`&&_.id===e.id&&C()}catch(t){await o({title:n(`system.storage.deleteAnyway`,`Delete anyway?`),message:n(`system.storage.forcingNote`,{error:t instanceof Error?t.message:String(t)}),confirmLabel:n(`system.storage.forceDelete`,`Force delete`),variant:`danger`})&&k.mutate({id:e.id,force:!0},{onSuccess:()=>{_.mode===`edit`&&_.id===e.id&&C()}})}},N=t(()=>{let e=new Map;for(let t of c??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[c]),P=l||d.isLoading,F=u||d.isError,I=_.mode===`new`&&x!==null&&x!==``,L=_.mode===`edit`&&O!==null;return e(Ge,{embedded:!0,children:[P&&r(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:n(`system.storage.loadingLocations`,`Loading locations…`)}),F&&r(`div`,{className:`text-xs text-danger`,children:n(`system.storage.failedToLoadStorageLocations`,`Failed to load storage locations.`)}),!P&&!F&&e(`div`,{className:`space-y-3`,children:[f.length===0&&r(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-[11px] text-foreground-subtle italic`,children:n(`system.storage.noStorageLocationsDeclaredBy`,`No storage locations declared by any installed addon.`)}),f.map(e=>r(Xe,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:N.get(e.id)??[],onAdd:w,onEdit:T,onDelete:e=>{M(e)},ownedBytesById:m,drainById:g,onSetMode:(e,t)=>{j(e,t)}},e.id))]}),I&&x!==null&&r(et,{initialType:x,onClose:C,onCreated:()=>{a.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),C()}}),L&&O!==null&&r(Ze,{location:O,onClose:C,onSaved:()=>{a.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),C()}})]})}var q={settings:{labelKey:`helpers.backupDatabases.settings.label`,descriptionKey:`helpers.backupDatabases.settings.description`,shortKey:`helpers.backupDatabases.settings.short`},events:{labelKey:`helpers.backupDatabases.events.label`,descriptionKey:`helpers.backupDatabases.events.description`,shortKey:`helpers.backupDatabases.events.short`},history:{labelKey:`helpers.backupDatabases.history.label`,descriptionKey:`helpers.backupDatabases.history.description`,shortKey:`helpers.backupDatabases.history.short`}},nt=Object.keys(q),J=[`settings`];function rt(){return W.t(`helpers.backupDatabases.notCreated`)}function it(e){return W.t(q[e].labelKey)}function at(e){return W.t(q[e].shortKey)}function ot(e){return W.t(q[e].descriptionKey)}function Y(e){let t=new Set(e);return nt.filter(e=>t.has(e))}function X(e){return e!==void 0&&e.length>0?Y(e):J}function st(e){return Y(e)}function ct(e,t){return t===void 0||!t.answered?`unknown`:t.databases.includes(e)?`present`:`absent`}function lt(e,t,n){return ct(e,t)===`absent`&&!n.has(e)}function ut(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function dt(e){return!e.includes(`settings`)}function ft(e){return{databases:[...st(e)]}}function pt(e,t){return e!==void 0&&e.length>0?Y(e):t!==void 0&&t.length>0?Y(t.map(e=>e.databaseId??`settings`)):J}function Z({databases:e}){return r(`span`,{className:`text-xs font-medium uppercase tracking-wide text-foreground-muted`,"data-testid":`backup-database-badges`,children:e.map(e=>at(e)).join(` · `)})}o();var mt=[[`backup`,`listDestinations`]],ht=[`backup`,`listArchives`];function gt({destinationId:i,restoreSupported:o,onOpenRestoreWizard:c}){let{t:l}=G(),u=s(),d=D(),{data:p,isLoading:m,isError:h}=he({destinationId:i}),g=p??[],_=xe({onSuccess:()=>{u.invalidateQueries({queryKey:[[...ht]]}),u.invalidateQueries({queryKey:mt})}}),y=n(async e=>{await d({title:l(`backup.archiveList.deleteThisArchive`,`Delete this archive?`),message:l(`backup.archiveList.permanentlyDeletesAndFrees`,`Permanently deletes "{{value1}}" and frees {{value2}}.`,{value1:e.label??e.id,value2:K(e.sizeBytes)}),confirmLabel:l(`common.delete`,`Delete`),variant:`danger`})&&_.mutate({destinationId:i,backupId:e.id})},[d,i,_,l]),[b,S]=a(null),w=n(async e=>{S(e.id);try{let t=await Ke(_t(i,e.id)),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.label??e.id}.tar.gz${e.encryption===void 0?``:`.csbk`}`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n)}finally{S(null)}},[i]),T=t(()=>[...g].toSorted((e,t)=>t.createdAt-e.createdAt),[g]);return m?r(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:l(`backup.archiveList.loadingArchives`,`Loading archives…`)}):h?r(`div`,{className:`text-xs text-danger py-2`,children:l(`backup.archiveList.failedToReadManifestFor`,`Failed to read manifest for this destination`)}):T.length===0?r(`div`,{className:`text-xs text-foreground-subtle italic py-2`,children:l(`backup.archiveList.noArchivesAtThisDestination`,`No archives at this destination yet.`)}):r(R,{columns:[{key:`when`,header:l(`backup.archiveList.when`,`When`),sortValue:e=>e.createdAt,render:e=>r(`span`,{className:`tabular-nums`,children:vt(e.createdAt)})},{key:`label`,header:l(`backup.archiveList.label`,`Label`),sortValue:e=>e.label??null,render:t=>e(`span`,{className:`inline-flex items-center gap-1`,children:[t.encryption!==void 0&&r(C,{className:`h-3 w-3 text-success`,"aria-label":l(`backup.archiveList.encryptedRestoreNeedsBackupKey`,`encrypted — restore needs backup key {{keyId}}`,{keyId:t.encryption.keyId})}),t.label??r(`span`,{className:`text-foreground-subtle italic`,children:`—`})]})},{key:`databases`,header:l(`backup.archiveList.databases`,`Databases`),nowrap:!1,notSortableReason:`Database badges`,render:e=>r(Z,{databases:X(e.databases)})},{key:`includes`,header:l(`backup.archiveList.files`,`Files`),nowrap:!1,notSortableReason:`Location list`,render:e=>e.locations.length>0?r(`span`,{className:`text-foreground-subtle`,children:e.locations.join(`, `)}):r(`span`,{className:`text-foreground-subtle italic`,children:l(`common.none`)})},{key:`size`,header:l(`backup.archiveList.size`,`Size`),align:`right`,sortValue:e=>e.sizeBytes,render:e=>r(`span`,{className:`tabular-nums`,children:K(e.sizeBytes)})},{key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:t=>e(`span`,{className:`flex items-center justify-end gap-1`,children:[e(U,{variant:`ghost`,size:`sm`,onClick:()=>{w(t)},disabled:b===t.id,title:l(`backup.archiveList.downloadArchive`,`Download archive`),children:[b===t.id?r(x,{className:`h-3 w-3 animate-spin`}):r(v,{className:`h-3 w-3`}),l(`backup.archiveList.download`,`Download`)]}),o&&c&&e(U,{variant:`ghost`,size:`sm`,onClick:()=>c({destinationId:i,archiveId:t.id}),title:l(`backup.archiveList.restoreFromThisArchive`,`Restore from this archive`),children:[r(j,{className:`h-3 w-3`}),l(`backup.archiveList.restore`,`Restore`)]}),r(H,{variant:`ghost`,size:`sm`,icon:f,"aria-label":l(`backup.archiveList.delete`,`Delete {{value1}}`,{value1:t.label??t.id}),disabled:_.isPending,onClick:()=>{y(t)}})]})}],rows:T,rowKey:e=>e.id,minWidthPx:760,emptyMessage:l(`backup.archiveList.noArchivesAtThisDestination`,`No archives at this destination yet.`)})}function _t(e,t){return h(`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}function vt(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}o();var yt=[[`backup`,`listSchedules`]];function bt({onEdit:i,onOpenRestoreWizard:o}){let{t:s}=G(),{data:c,isLoading:l,isError:u,error:d,refetch:f}=Pe(),p=c??[],m=Le().data??[],h=t(()=>{let e=new Map;for(let t of m)e.set(t.id,t);return e},[m]),[g,_]=a(null),v=n(e=>{_(t=>t===e?null:e)},[]),y=t(()=>xt({destById:h,expandedId:g,onToggleExpand:v,onEdit:i}),[h,g,v,i]);return l?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle animate-pulse`,children:[r(x,{className:`h-3.5 w-3.5 animate-spin`}),s(`backup.backupEntriesTable.loadingBackupEntries`,`Loading backup entries…`)]}):u?r(oe,{title:s(`backup.backupEntriesTable.failedToLoadBackupEntries`,`Failed to load backup entries`),message:d instanceof Error?d.message:s(`backup.backupEntriesTable.unknownError`,`Unknown error`),onRetry:()=>void f()}):p.length===0?r(se,{icon:N,title:s(`backup.backupEntriesTable.noBackupEntriesYet`,`No backup entries yet`),description:s(`backup.backupEntriesTable.createOneToScheduleBackups`,`Create one to schedule backups across one or more storage locations.`)}):r(R,{columns:y,rows:p,rowKey:e=>e.id,minWidthPx:980,maxBodyHeight:Te,emptyMessage:s(`backup.backupEntriesTable.noBackupEntriesYet`,`No backup entries yet`),onRowClick:e=>i(e),isExpanded:e=>e.id===g,renderExpanded:e=>r(Ot,{row:e,destById:h,...o?{onOpenRestoreWizard:o}:{}})})}function xt(t){return[{key:`expand`,header:``,width:`w-8`,nowrap:!0,notSortableReason:`Expand control`,render:e=>{let n=t.expandedId===e.id;return r(H,{variant:`ghost`,size:`sm`,icon:n?m:u,"aria-label":n?W.t(`backup.backupEntriesTable.hideArchives`,`Hide archives`):W.t(`backup.backupEntriesTable.showArchives`,`Show archives`),"aria-expanded":n,onClick:n=>{n.stopPropagation(),t.onToggleExpand(e.id)}})}},{key:`entry`,header:W.t(`backup.backupEntriesTable.entry`,`Entry`),sortValue:e=>e.label,render:t=>e(`span`,{className:`flex min-w-0 flex-col`,children:[r(`span`,{className:`truncate font-medium text-foreground`,children:t.label||W.t(`backup.backupEntriesTable.unnamed`,`(unnamed)`)}),t.lastRunAt!==void 0&&r(`span`,{className:`text-[10px] text-foreground-subtle`,children:W.t(`backup.backupEntriesTable.lastRun`,{when:new Date(t.lastRunAt).toLocaleString()})})]})},{key:`enabled`,header:W.t(`backup.backupEntriesTable.enabled`,`Enabled`),width:`w-20`,nowrap:!0,sortValue:e=>+!!e.enabled,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(Tt,{row:e})})},{key:`databases`,header:W.t(`backup.backupEntriesTable.backsUp`,`Backs up`),nowrap:!1,notSortableReason:`Database badges`,render:e=>r(Z,{databases:X(e.databases)})},{key:`locations`,header:W.t(`backup.backupEntriesTable.locations`,`Locations`),nowrap:!1,notSortableReason:`Location chips`,render:e=>r(St,{row:e,destById:t.destById})},{key:`retention`,header:W.t(`backup.backupEntriesTable.retention`,`Retention`),width:`w-24`,nowrap:!0,sortValue:e=>e.retentionCount,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(Et,{row:e})})},{key:`schedule`,header:W.t(`backup.backupEntriesTable.schedule`,`Schedule`),width:`w-48`,nowrap:!0,sortValue:e=>e.cron,render:e=>r(Ct,{row:e})},{key:`actions`,header:``,align:`right`,nowrap:!0,notSortableReason:`Actions`,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(Dt,{row:e,onEdit:()=>t.onEdit(e)})})}]}function St({row:e,destById:t}){let{t:n}=G();return e.locationIds.length===0?r(`span`,{className:`text-[11px] italic text-danger`,children:n(`backup.backupEntriesTable.noLocations`,`No locations`)}):r(`span`,{className:`flex flex-wrap gap-1`,children:e.locationIds.map(e=>r(`span`,{className:`inline-flex items-center rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-foreground`,title:e,children:t.get(e)?.displayName??e},e))})}function Ct({row:t}){let{t:n}=G(),i=t.cron.trim().length>0;return e(`span`,{className:`flex flex-col items-start gap-0.5`,children:[e(`span`,{className:`inline-flex items-center gap-1`,children:[r(N,{className:`h-3 w-3 text-foreground-subtle`}),r(`span`,{className:`font-mono text-[11px] text-foreground`,children:i?t.cron:n(`backup.backupEntriesTable.manual`,`Manual`)})]}),i&&t.nextRunAt!==void 0&&r(`span`,{className:`text-[10px] text-foreground-subtle`,children:W.t(`common.nextRun`,{when:new Date(t.nextRunAt).toLocaleString()})})]})}function wt(e){return t(()=>({id:e.id,label:e.label,cron:e.cron,locationIds:[...e.locationIds],retentionCount:e.retentionCount,...e.dataSources?{dataSources:[...e.dataSources]}:{},...e.databases?{databases:[...e.databases]}:{}}),[e])}function Tt({row:e}){let{t}=G(),n=s(),i=z({onSuccess:()=>{n.invalidateQueries({queryKey:yt})}}),a=wt(e);return r(`label`,{className:`inline-flex cursor-pointer items-center`,children:r(`input`,{type:`checkbox`,className:`accent-primary`,checked:e.enabled,disabled:i.isPending,onChange:e=>i.mutate({...a,enabled:e.target.checked}),"aria-label":t(`backup.backupEntriesTable.enable`,`Enable {{value1}}`,{value1:e.label||e.id})})})}function Et({row:e}){let{t}=G(),n=s(),o=z({onSuccess:()=>{n.invalidateQueries({queryKey:yt})}}),c=wt(e),[l,u]=a(String(e.retentionCount));return i(()=>{u(String(e.retentionCount))},[e.retentionCount]),r(V,{type:`number`,min:1,max:1e3,value:l,disabled:o.isPending,onChange:e=>u(e.target.value),onBlur:()=>{let t=Number.parseInt(l,10);if(Number.isNaN(t)||t<1){u(String(e.retentionCount));return}t!==e.retentionCount&&o.mutate({...c,enabled:e.enabled,retentionCount:t})},onKeyDown:t=>{t.key===`Enter`&&t.target.blur(),t.key===`Escape`&&u(String(e.retentionCount))},className:`w-16`,"aria-label":t(`backup.backupEntriesTable.retentionFor`,`Retention for {{value1}}`,{value1:e.label||e.id})})}function Dt({row:t,onEdit:n}){let{t:i}=G(),a=s(),o=D(),c=Oe({onSuccess:()=>{a.invalidateQueries({queryKey:yt})}}),l=ue({onMutate:()=>{a.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})},onSuccess:()=>{a.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),a.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),a.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})}}),u=()=>{t.locationIds.length!==0&&l.mutate({destinations:[...t.locationIds],...t.dataSources&&t.dataSources.length>0?{locations:[...t.dataSources]}:{},label:t.label,retentionCount:t.retentionCount,databases:[...X(t.databases)]})},d=async()=>{await o({title:i(`backup.backupEntriesTable.deleteBackupEntry`,`Delete backup entry?`),message:i(`backup.backupEntriesTable.willStopRunningExistingArchives`,`"{{value1}}" will stop running. Existing archives are kept.`,{value1:t.label||t.id}),confirmLabel:i(`common.delete`,`Delete`),variant:`warning`})&&c.mutate({id:t.id})};return e(`span`,{className:`flex items-center justify-end gap-1.5`,children:[e(U,{size:`sm`,type:`button`,onClick:u,disabled:l.isPending||t.locationIds.length===0,title:i(`backup.backupEntriesTable.runThisEntryNow`,`Run this entry now`),children:[l.isPending?r(x,{className:`h-3 w-3 animate-spin`}):r(p,{className:`h-3 w-3`}),i(`backup.backupEntriesTable.runNow`,`Run now`)]}),r(H,{variant:`ghost`,size:`sm`,icon:_,"aria-label":i(`backup.backupEntriesTable.edit`,`Edit {{value1}}`,{value1:t.label||t.id}),onClick:n}),r(H,{variant:`ghost`,size:`sm`,icon:f,"aria-label":i(`backup.backupEntriesTable.delete`,`Delete {{value1}}`,{value1:t.label||t.id}),disabled:c.isPending,onClick:()=>{d()}})]})}function Ot({row:t,destById:n,onOpenRestoreWizard:i}){let{t:a}=G();return e(`div`,{className:`space-y-4 rounded-lg border border-border bg-background/30 px-4 py-3`,children:[r(`p`,{className:`text-[11px] font-medium text-foreground-subtle`,children:a(`backup.backupEntriesTable.archivesFor`,{name:t.label||t.id})}),t.locationIds.length===0&&r(`p`,{className:`text-xs italic text-foreground-subtle`,children:a(`backup.backupEntriesTable.thisEntryHasNoLocations`,`This entry has no locations selected.`)}),t.locationIds.map(t=>e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[11px] font-medium text-foreground-subtle`,children:n.get(t)?.displayName??t}),r(gt,{destinationId:t,restoreSupported:n.get(t)?.restoreSupported??!0,...i?{onOpenRestoreWizard:i}:{}})]},t))]})}function kt({selected:t,onChange:n,disabled:i=!1,testId:a=`backup-databases`}){let{t:o}=G(),s=ke().data,c=t.size>0&&dt(Y(t)),l=t.size===0?`Pick at least one.`:c?`Snapshots only: configuration and files are not part of this backup.`:null;return r(B,{label:o(`backup.backupDatabasePicker.whatToBackUp`,`What to back up`),required:!0,...l===null?{}:{description:l},children:r(`div`,{className:`divide-y divide-border rounded border border-border bg-background`,"data-testid":a,children:nt.map(o=>{let c=ct(o,s),l=i||lt(o,s,t);return e(`label`,{className:`flex items-start gap-2 px-3 py-2 text-xs ${l?`opacity-60`:`cursor-pointer hover:bg-primary/5`}`,children:[r(me,{checked:t.has(o),disabled:l,onChange:()=>n(ut(t,o)),"data-testid":`${a}-${o}`}),e(`span`,{className:`min-w-0 flex-1`,children:[r(`span`,{className:`flex flex-wrap items-center gap-1.5 text-foreground`,children:it(o)}),r(`span`,{className:`block text-[11px] text-foreground-subtle`,children:c===`absent`?rt():ot(o)})]})]},o)})})})}o();function At({onClose:t}){let{t:n}=G(),i=s(),[o,c]=a(new Set(J)),l=ue({onMutate:()=>{i.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})},onSuccess:()=>{i.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),i.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),i.invalidateQueries({queryKey:[[`backup`,`listRuns`]]}),t()}});return r(Re,{open:!0,onOpenChange:e=>!e&&t(),children:e(Fe,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(Me,{children:[r(de,{children:n(`backup.backupNowDialog.backUpNow`,`Back up now`)}),r(`p`,{className:`text-xs text-foreground-subtle`,children:n(`backup.backupNowDialog.runsOnceAndWritesThe`,`Runs once and writes the archive to every enabled backup location.`)})]}),r(ye,{children:e(`div`,{className:`p-4`,children:[r(kt,{selected:o,onChange:c,disabled:l.isPending,testId:`backup-now-databases`}),l.error&&r(`p`,{role:`alert`,className:`pt-2 text-xs text-danger`,children:l.error.message})]})}),e(te,{children:[r(U,{variant:`outline`,size:`sm`,onClick:t,children:n(`common.cancel`,`Cancel`)}),e(U,{size:`sm`,onClick:()=>{o.size!==0&&l.mutate(ft(o))},disabled:o.size===0||l.isPending,"data-testid":`backup-now-run`,children:[l.isPending?r(x,{className:`h-3.5 w-3.5 animate-spin`}):r(p,{className:`h-3.5 w-3.5`}),n(`backup.backupNowDialog.backUpNow`,`Back up now`)]})]})]})})}o();function jt(e){return e===null?`—`:new Date(e).toLocaleString()}function Mt(e){let t=new Blob([`${e.secretKey}\n`],{type:`text/plain`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`camstack-backup-key-${e.keyId}.txt`,r.click(),URL.revokeObjectURL(n)}function Nt({revealed:t,onDone:n}){let{t:i}=G(),[o,s]=a(!1),[c,l]=a(!1);return r(Re,{open:!0,onOpenChange:e=>!e&&o&&n(),children:e(Fe,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`border-danger/40`,"aria-labelledby":`backup-key-title`,children:[r(Me,{children:r(de,{id:`backup-key-title`,children:i(`backup.encryptionCard.yourKey`,{keyId:t.keyId})})}),e(ye,{className:`space-y-3`,children:[e(`p`,{className:`flex items-start gap-2 rounded-md border border-danger/40 bg-danger/10 p-2 text-xs text-foreground`,children:[r(M,{className:`mt-0.5 h-4 w-4 shrink-0 text-danger`}),r(`span`,{children:i(`backup.backupEncryptionCard.thisKeyIsShownOnly`,`This key is shown only once. CamStack does not keep it — not the hub, not its database, not its backups. Without it, an encrypted backup cannot be restored by anyone, including you. Store it in a password manager or print it, away from this server.`)})]}),r(`div`,{className:`break-all rounded-md border border-border bg-background p-2 font-mono text-xs text-foreground select-all`,children:t.secretKey}),e(`div`,{className:`flex flex-wrap gap-2`,children:[e(U,{size:`sm`,variant:`outline`,onClick:()=>{navigator.clipboard?.writeText(t.secretKey).then(()=>l(!0))},children:[r(S,{className:`mr-1 h-3.5 w-3.5`}),c?i(`backup.backupEncryptionCard.copied`,`Copied`):i(`common.copy`,`Copy`)]}),e(U,{size:`sm`,variant:`outline`,onClick:()=>Mt(t),children:[r(v,{className:`mr-1 h-3.5 w-3.5`}),i(`backup.backupEncryptionCard.downloadAsFile`,`Download as file`)]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground`,children:[r(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked),className:`accent-primary`}),i(`backup.backupEncryptionCard.iHaveStoredThisKey`,`I have stored this key somewhere safe, off this server.`)]})]}),r(te,{children:r(U,{size:`sm`,disabled:!o,onClick:n,children:i(`backup.backupEncryptionCard.iHaveStoredIt`,`I have stored it`)})})]})})}function Pt(){let{t}=G(),n=Ce(),i=je(),o=Ee(),s=D(),[l,u]=a(null),[d,f]=a(null),p=n.data?.enabled??!1,m=n.data?.active??null,h=(n.data?.keys??[]).filter(e=>e.retiredAt!==null),g=async()=>{if(await s({title:p?t(`backup.backupEncryptionCard.replaceTheBackupKey`,`Replace the backup key`):t(`backup.backupEncryptionCard.encryptBackups`,`Encrypt backups`),message:p?t(`backup.backupEncryptionCard.aNewKeyIsGenerated`,`A new key is generated and shown once; new backups are encrypted to it. Older backups keep needing the key they were made with — keep that one too.`):t(`backup.backupEncryptionCard.aBackupKeyIsGenerated`,`A backup key is generated and shown once. Every new backup is encrypted to it, and restoring one will ask for it. Existing backups stay as they are.`),confirmLabel:p?t(`backup.backupEncryptionCard.generateANewKey`,`Generate a new key`):t(`backup.backupEncryptionCard.generateTheKey`,`Generate the key`),variant:`warning`})){f(null);try{let e=await i.mutateAsync({});u({keyId:e.keyId,secretKey:e.secretKey})}catch(e){f(e instanceof Error?e.message:String(e))}}},_=async()=>{if(await s({title:t(`backup.backupEncryptionCard.turnBackupEncryptionOff`,`Turn backup encryption off`),message:t(`backup.backupEncryptionCard.newBackupsWillBeWritten`,`New backups will be written unencrypted. Existing encrypted backups still need their key to be restored.`),confirmLabel:t(`backup.backupEncryptionCard.turnOff`,`Turn off`),variant:`danger`})){f(null);try{await o.mutateAsync({}),n.refetch()}catch(e){f(e instanceof Error?e.message:String(e))}}};return e(`div`,{className:`space-y-2 rounded-lg border border-border bg-surface p-4`,children:[e(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[e(`div`,{className:`flex items-center gap-2`,children:[p?r(C,{className:`h-4 w-4 text-success`}):r(k,{className:`h-4 w-4 text-foreground-subtle`}),r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`backup.backupEncryptionCard.encryption`,`Encryption`)}),r(`span`,{className:`text-xs text-foreground-subtle`,children:p&&m!==null?t(`backup.backupEncryptionCard.onKeySince`,`On — key {{keyId}}, since {{value2}}`,{keyId:m.keyId,value2:jt(m.createdAt)}):t(`backup.backupEncryptionCard.offBackupsAreNotEncrypted`,`Off — backups are not encrypted`)})]}),r(`div`,{className:`flex gap-2`,children:p?e(c,{children:[r(U,{size:`sm`,variant:`outline`,disabled:i.isPending,onClick:()=>void g(),children:t(`backup.backupEncryptionCard.replaceKey`,`Replace key`)}),r(U,{size:`sm`,variant:`outline`,disabled:o.isPending,onClick:()=>void _(),children:t(`backup.backupEncryptionCard.turnOff`,`Turn off`)})]}):r(U,{size:`sm`,disabled:i.isPending,onClick:()=>void g(),children:t(`backup.backupEncryptionCard.enableEncryption`,`Enable encryption`)})})]}),r(`p`,{className:`text-xs text-foreground-subtle`,children:t(`backup.backupEncryptionCard.archivesAreEncryptedOnThis`,`Archives are encrypted on this server before they reach any destination. The server keeps only a public key, so it can encrypt scheduled backups but cannot decrypt them — only your backup key can. Covers the database snapshot, config.yaml, addon data (HomeKit pairing, Matter fabric, Tailscale state) and TLS.`)}),h.length>0&&e(`div`,{className:`text-xs`,children:[r(`p`,{className:`text-foreground-subtle`,children:t(`backup.backupEncryptionCard.olderKeysBackupsMadeWith`,`Older keys (backups made with them still need them):`)}),r(`ul`,{className:`font-mono text-foreground`,children:h.map(t=>e(`li`,{children:[t.keyId,` · `,jt(t.createdAt),` → `,jt(t.retiredAt)]},t.keyId))})]}),d!==null&&r(`p`,{className:`text-xs text-danger`,children:d}),l!==null&&r(Nt,{revealed:l,onDone:()=>{u(null),n.refetch()}})]})}o();var Ft=[{id:`manual`,labelKey:`backup.cronEditor.presetManual`,cron:``},{id:`hourly`,labelKey:`backup.cronEditor.presetHourly`,cron:`0 * * * *`,descriptionKey:`backup.cronEditor.presetHourlyDesc`},{id:`every-3h`,labelKey:`backup.cronEditor.preset3h`,cron:`0 */3 * * *`,description:`00:00, 03:00, 06:00, 09:00 …`},{id:`every-6h`,labelKey:`backup.cronEditor.preset6h`,cron:`0 */6 * * *`,description:`00:00, 06:00, 12:00, 18:00`},{id:`daily-3am`,labelKey:`backup.cronEditor.presetDaily`,cron:`0 3 * * *`,descriptionKey:`backup.cronEditor.presetDailyDesc`},{id:`weekly-sun`,labelKey:`backup.cronEditor.presetWeekly`,cron:`0 3 * * 0`,descriptionKey:`backup.cronEditor.presetWeeklyDesc`}];function It(e){let t=e.trim();for(let e of Ft)if(e.cron===t)return e.id;return`custom`}function Lt({value:t,onChange:n,previewCount:o=5,disabled:s=!1}){let{t:c}=G(),l=It(t),[u,d]=a(l===`custom`);i(()=>{l!==`custom`&&d(!1)},[l]);let f=Bt(t,250),p=ce({cron:f,count:o},{enabled:f.trim().length>0}),m=p.data??null,h=e=>{d(!1),n(e.cron)},g=u||l===`custom`;return e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`backup.cronEditor.schedulePreset`,`Schedule preset`)}),e(`div`,{className:`flex flex-wrap gap-1.5`,children:[Ft.map(e=>r(`button`,{type:`button`,onClick:()=>h(e),disabled:s,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(!u&&l===e.id?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),title:e.descriptionKey===void 0?e.description??c(e.labelKey):c(e.descriptionKey),children:c(e.labelKey)},e.id)),r(`button`,{type:`button`,onClick:()=>{d(!0),t.trim().length===0&&n(`0 3 * * *`)},disabled:s,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(g?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),children:c(`backup.cronEditor.custom`,`Custom…`)})]})]}),g&&e(`div`,{className:`space-y-1`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`backup.cronEditor.cronExpression5FieldPosix`,`Cron expression (5-field POSIX)`)}),r(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),disabled:s,placeholder:`0 3 * * *`,spellCheck:!1,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`}),e(`p`,{className:`text-[10px] text-foreground-subtle`,children:[c(`backup.cronEditor.format`,`Format:`),` `,r(He,{i18nKey:`backup.cronEditor.formatLine`,components:{code:r(`span`,{className:`font-mono`})}})]})]}),r(Rt,{cron:f,preview:m,loading:p.isFetching})]})}function Rt({cron:t,preview:n,loading:i}){let{t:a}=G();return i&&n===null?e(`div`,{className:`flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:[r(x,{className:`h-3 w-3 animate-spin`}),a(`backup.cronEditor.validating`,`Validating…`)]}):n===null?null:n.ok?n.nextRuns.length===0?r(`div`,{className:`rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:a(`backup.cronEditor.noFutureRunsMatchThis`,`No future runs match this expression.`)}):e(`div`,{className:`space-y-1`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:a(`backup.cronEditor.nextRuns`,`Next runs`)}),r(`ul`,{className:`rounded border border-border bg-background/40 divide-y divide-border`,children:n.nextRuns.map((t,n)=>e(`li`,{className:`flex items-center justify-between px-3 py-1.5 text-[11px]`,children:[r(`span`,{className:`text-foreground tabular-nums`,children:new Date(t).toLocaleString()}),r(`span`,{className:`text-foreground-subtle text-[10px] tabular-nums`,children:zt(t)})]},`${t}-${n}`))})]}):r(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:n.error??a(`backup.cronEditor.invalidCronExpression`,`Invalid cron expression`)})}function zt(e){let t=e-Date.now();if(t<=0)return W.t(`helpers.relativeTime.now`);let n=Math.floor(t/1e3);if(n<60)return W.t(`helpers.relativeTime.inSeconds`,{count:n});let r=Math.floor(n/60);if(r<60)return W.t(`helpers.relativeTime.inMinutes`,{count:r});let i=Math.floor(r/60);if(i<24)return W.t(`helpers.relativeTime.inHours`,{count:i});let a=Math.floor(i/24);return W.t(`helpers.relativeTime.inDays`,{count:a})}function Bt(e,n){let[r,o]=a(e),s=t(()=>e,[e]);return i(()=>{let e=setTimeout(()=>o(s),n);return()=>clearTimeout(e)},[s,n]),r}o();var Vt=[[`backup`,`listSchedules`]];function Ht({entry:n,onClose:i,onSaved:o}){let{t:c}=G(),l=s(),u=Le(),d=u.data??[],[f,p]=a(n?.label??``),[m,h]=a(n?.cron??`0 3 * * *`),[g,_]=a(n?.enabled??!0),[v,y]=a(String(n?.retentionCount??7)),[b,S]=a(new Set(n?.locationIds??[])),[C,w]=a(new Set(n===null?J:X(n.databases))),T=z({onSuccess:()=>{l.invalidateQueries({queryKey:Vt}),o()}}),E=e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},D=Number.parseInt(v,10),O=t(()=>f.trim().length>0&&b.size>0&&C.size>0&&!Number.isNaN(D)&&D>=1&&D<=1e3,[f,b,C,D]),k=()=>{O&&T.mutate({...n?{id:n.id}:{},label:f.trim(),cron:m.trim(),enabled:g,locationIds:Array.from(b),retentionCount:D,databases:[...st(C)]})},A=T.error instanceof Error?T.error.message:null;return r(ze,{open:!0,onClose:i,title:n?c(`backup.backupEntryModal.editBackupEntry`,`Edit backup entry`):c(`backup.backupEntryModal.newBackupEntry`,`New backup entry`),icon:N,error:A,width:`lg`,testId:`backup-entry-form`,footer:e(U,{size:`sm`,type:`button`,onClick:k,disabled:!O||T.isPending,children:[T.isPending?r(x,{className:`h-3.5 w-3.5 animate-spin`}):null,n?c(`common.save`,`Save`):c(`backup.backupEntryModal.createEntry`,`Create entry`)]}),children:e(`div`,{className:`space-y-4`,children:[r(B,{label:c(`backup.backupEntryModal.name`,`Name`),required:!0,children:r(V,{value:f,onChange:e=>p(e.target.value),placeholder:c(`backup.backupEntryModal.nightlyOffsite`,`Nightly offsite`),autoFocus:!0,"data-testid":`backup-entry-name`})}),e(B,{label:c(`backup.backupEntryModal.locationsSelected`,`Locations ({{value1}} selected)`,{value1:String(b.size)}),required:!0,children:[u.isLoading&&e(`div`,{className:`flex items-center gap-2 px-1 py-2 text-xs text-foreground-subtle`,children:[r(x,{className:`h-3.5 w-3.5 animate-spin`}),c(`backup.backupEntryModal.loadingLocations`,`Loading locations…`)]}),!u.isLoading&&d.length===0&&r(`div`,{className:`rounded border border-border bg-background px-3 py-2 text-xs text-foreground-subtle italic`,children:c(`backup.backupEntryModal.noBackupsStorageLocationsConfigured`,"No `backups` storage locations configured. Add one in Settings → Storage first.")}),d.length>0&&r(`div`,{className:`max-h-52 divide-y divide-border overflow-y-auto rounded border border-border bg-background`,children:d.map(t=>e(`label`,{className:`flex cursor-pointer items-center justify-between px-3 py-2 text-xs hover:bg-primary/5`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(`input`,{type:`checkbox`,checked:b.has(t.id),onChange:()=>E(t.id),className:`accent-primary`}),r(`span`,{className:`text-foreground`,children:t.displayName})]}),e(`div`,{className:`flex items-center gap-1.5`,children:[r(`span`,{className:`rounded border border-border bg-surface px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-foreground-subtle`,children:t.kind}),r(`span`,{className:`font-mono text-[10px] text-foreground-subtle`,children:t.id})]})]},t.id))})]}),r(kt,{selected:C,onChange:w,disabled:T.isPending,testId:`backup-entry-databases`}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[r(B,{label:c(`backup.backupEntryModal.retentionArchivesKept`,`Retention (archives kept)`),required:!0,children:r(V,{type:`number`,min:1,max:1e3,value:v,onChange:e=>y(e.target.value),"data-testid":`backup-entry-retention`})}),r(B,{label:c(`backup.backupEntryModal.enabled`,`Enabled`),description:c(`backup.backupEntryModal.runOnScheduleWhenChecked`,`Run on schedule when checked.`),children:e(`label`,{className:`inline-flex cursor-pointer items-center gap-2 py-1.5 text-xs text-foreground`,children:[r(`input`,{type:`checkbox`,checked:g,onChange:e=>_(e.target.checked),className:`accent-primary`,"data-testid":`backup-entry-enabled`}),r(`span`,{children:c(`backup.backupEntryModal.runOnSchedule`,`Run on schedule`)})]})})]}),r(B,{label:c(`backup.backupEntryModal.schedule`,`Schedule`),children:r(Lt,{value:m,onChange:h,disabled:T.isPending})})]})})}o();var Ut=2e3,Wt=5e3;function Q(e){return e.state===`queued`||e.state===`running`}function Gt(e){if(e.state===`queued`)return{title:W.t(`backup.backupRunsPanel.cancelQueuedBackupRun`,`Cancel queued backup run?`),message:W.t(`backup.backupRunsPanel.thisRunHasNotStarted`,`This run has not started. Cancelling removes it from the queue — nothing has been written, nothing is deleted.`),confirmLabel:W.t(`backup.backupRunsPanel.cancelRun`,`Cancel run`),variant:`warning`};let t=e.completedDestinationIds.length,n=t>0?`${t===1?`The 1 destination`:`The ${t} destinations`} that already completed KEEP${t===1?`S`:``} the archive.`:`No destination has completed yet, so nothing will be kept.`;return{title:W.t(`backup.backupRunsPanel.stopThisBackupRun`,`Stop this backup run?`),message:W.t(`backup.backupRunsPanel.theHalfWrittenStagingArchive`,`The half-written staging archive is deleted and the destination currently uploading discards its partial copy. {{keptSentence}}`,{keptSentence:n}),confirmLabel:W.t(`backup.backupRunsPanel.stopRun`,`Stop run`),variant:`danger`}}function Kt(){let e=D(),[t,i]=a(null),o=_e(void 0,{refetchInterval:e=>(e.state.data??[]).some(Q)?Ut:Wt}),s=be({onSettled:()=>{i(null),o.refetch()}}),c=n(async t=>{await e(Gt(t))&&(i(t.id),s.mutate({runId:t.id}))},[e,s]);return r(qt,{queryState:o.isError?`error`:o.data===void 0?`pending`:`ready`,runs:o.data??[],cancelingId:t,onCancelRequest:e=>{c(e)},now:Date.now()})}function qt({queryState:t,runs:n,cancelingId:i,onCancelRequest:a,now:o}){let{t:s}=G(),c=t===`ready`&&n.some(Q),l=n.filter(e=>e.state===`running`),u=n.filter(e=>e.state===`queued`),d=n.filter(e=>!Q(e)),f=[...l,...u,...d];return e(`section`,{className:`rounded-lg border border-border bg-surface`,children:[e(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border`,children:[r(`h2`,{className:`text-xs font-semibold text-foreground`,children:s(`backup.backupRunsPanel.runs`,`Runs`)}),c&&e(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium text-primary`,title:s(`backup.backupRunsPanel.aBackupRunIsIn`,`A backup run is in progress`),children:[r(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary animate-pulse`}),s(`backup.runsPanel.live`)]}),r(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:s(`backup.backupRunsPanel.oneRunExecutesAtA`,`One run executes at a time — queued runs wait in line.`)})]}),t===`pending`&&r(`div`,{className:`px-3 py-2.5 text-xs text-foreground-subtle animate-pulse`,children:s(`backup.backupRunsPanel.checkingForBackupRuns`,`Checking for backup runs…`)}),t===`error`&&r(`div`,{className:`px-3 py-2.5 text-xs text-danger`,children:s(`backup.backupRunsPanel.couldNotReadBackupRuns`,`Could not read backup runs — the orchestrator did not answer.`)}),t===`ready`&&n.length===0&&r(`div`,{className:`px-3 py-2.5 text-xs text-foreground-subtle italic`,children:s(`backup.backupRunsPanel.noBackupRunsYetRuns`,`No backup runs yet. Runs appear here the moment one starts — manual or scheduled.`)}),t===`ready`&&n.length>0&&r(`div`,{className:`overflow-x-auto`,children:e(`table`,{className:`w-full text-xs min-w-[720px]`,children:[r(`thead`,{children:e(`tr`,{className:`text-foreground-subtle bg-background/30`,children:[r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.run`,`Run`)}),r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.state`,`State`)}),r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.progress`,`Progress`)}),r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.destinations`,`Destinations`)}),r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.timing`,`Timing`)}),r(`th`,{className:`text-right px-3 py-1.5 font-medium w-28`,children:s(`backup.backupRunsPanel.actions`,`Actions`)})]})}),r(`tbody`,{children:f.map(e=>r(Jt,{run:e,canceling:i===e.id,onCancelRequest:a,now:o},e.id))})]})})]})}function Jt({run:t,canceling:n,onCancelRequest:i,now:a}){let{t:o}=G(),s=Q(t);return e(`tr`,{className:`border-t border-border hover:bg-primary/5 align-top`,children:[r(`td`,{className:`px-3 py-2`,children:r(`div`,{className:`text-foreground`,title:t.id,children:t.label??r(`span`,{className:`text-foreground-subtle italic`,children:o(`backup.runsPanel.manual`)})})}),e(`td`,{className:`px-3 py-2`,children:[r(Yt,{run:t}),t.state===`failed`&&t.error!==void 0&&r(`div`,{className:`mt-1 text-[10px] text-danger max-w-56 truncate`,title:t.error,children:t.error})]}),r(`td`,{className:`px-3 py-2`,children:r(Xt,{run:t})}),r(`td`,{className:`px-3 py-2`,children:r(Zt,{run:t})}),r(`td`,{className:`px-3 py-2 text-foreground-subtle tabular-nums`,children:r(Qt,{run:t,now:a})}),r(`td`,{className:`px-3 py-2`,children:r(`div`,{className:`flex justify-end`,children:s&&e(`button`,{onClick:()=>i(t),disabled:n,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:t.state===`queued`?o(`backup.backupRunsPanel.removeThisRunFromThe`,`Remove this run from the queue before it starts`):o(`backup.backupRunsPanel.stopThisRunTheHalf`,`Stop this run — the half-written archive is discarded`),children:[n?r(x,{className:`h-3 w-3 animate-spin`}):r(g,{className:`h-3 w-3`}),t.state===`queued`?o(`common.cancel`,`Cancel`):o(`backup.backupRunsPanel.stop`,`Stop`)]})})})]})}function Yt({run:t}){let{t:n}=G();switch(t.state){case`queued`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:[r(b,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.queued`,`Queued`)]});case`running`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:[r(x,{className:`h-3 w-3 animate-spin`}),t.phase===`uploading`?n(`backup.backupRunsPanel.uploading`,`Uploading`):n(`backup.backupRunsPanel.buildingArchive`,`Building archive`)]});case`succeeded`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-success/10 px-1.5 py-0.5 text-[10px] font-medium text-success`,children:[r(y,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.succeeded`,`Succeeded`)]});case`failed`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-danger/10 px-1.5 py-0.5 text-[10px] font-medium text-danger`,children:[r(w,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.failed`,`Failed`)]});case`cancelled`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:text-amber-300`,title:n(`backup.backupRunsPanel.stoppedBeforeCompletingEveryDestination`,`Stopped before completing every destination — not a success`),children:[r(F,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.stopped`,`Stopped`)]})}}function Xt({run:t}){let{t:n}=G();if(t.state===`queued`)return r(`span`,{className:`text-foreground-subtle`,children:t.queuePosition===void 0?r(`span`,{className:`italic`,children:n(`backup.backupRunsPanel.waitingItsTurn`,`waiting its turn`)}):e(`span`,{className:`inline-flex items-center gap-1`,children:[r(`span`,{className:t.queuePosition===1?`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`:`rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium`,children:$t(t.queuePosition)}),n(`backup.backupRunsPanel.inLine`,`in line`)]})});if(t.state===`running`&&t.phase===`building`)return e(`span`,{className:`inline-flex items-center gap-1.5 text-foreground`,children:[r(I,{className:`h-3 w-3 text-primary`}),r(`span`,{className:`tabular-nums font-medium animate-pulse`,children:K(t.stagedBytes)}),r(`span`,{className:`text-foreground-subtle`,children:n(`backup.backupRunsPanel.stagedSoFar`,`staged so far`)})]});if(t.state===`running`){let i=t.archiveSizeBytes;return e(`span`,{className:`inline-flex items-center gap-1.5 text-foreground`,children:[r(P,{className:`h-3 w-3 text-primary`}),e(`span`,{className:`tabular-nums font-medium`,children:[K(t.uploadedBytes),i===void 0?``:` / ${K(i)}`]}),r(`span`,{className:`text-foreground-subtle`,children:n(`backup.backupRunsPanel.toCurrentDestination`,`to current destination`)})]})}let i=t.archiveSizeBytes??(t.stagedBytes>0?t.stagedBytes:void 0);return i===void 0?r(`span`,{className:`text-foreground-subtle italic`,children:`—`}):r(`span`,{className:`tabular-nums text-foreground`,children:n(`backup.runsPanel.archiveSize`,{size:K(i)})})}function Zt({run:t}){let{t:n}=G(),i=t.destinationIds.length,a=t.completedDestinationIds.length,o=t.failedDestinationIds.length;return i===0?r(`span`,{className:`text-foreground-subtle italic`,children:n(`backup.backupRunsPanel.notResolvedYet`,`not resolved yet`)}):e(`div`,{className:`flex flex-col gap-0.5`,children:[r(`span`,{className:`text-foreground-subtle`,title:t.destinationIds.join(`, `),children:n(`backup.runsPanel.targets`,{count:i})}),e(`span`,{className:`inline-flex items-center gap-2 text-[10px]`,children:[a>0&&r(`span`,{className:`text-success`,title:n(`backup.backupRunsPanel.keptTheirArchive`,`Kept their archive: {{value1}}`,{value1:t.completedDestinationIds.join(`, `)}),children:n(`backup.runsPanel.completed`,{count:a})}),o>0&&r(`span`,{className:`text-danger`,title:n(`backup.backupRunsPanel.failed2`,`Failed: {{value1}}`,{value1:t.failedDestinationIds.join(`, `)}),children:n(`backup.runsPanel.failedCount`,{count:o})})]})]})}function Qt({run:t,now:n}){let{t:i}=G();return t.state===`queued`?r(`span`,{children:i(`backup.runsPanel.queuedAgo`,{elapsed:en(n-t.requestedAt)})}):t.startedAt===void 0?r(`span`,{children:`—`}):t.finishedAt===void 0?r(`span`,{children:i(`backup.runsPanel.runningFor`,{elapsed:en(n-t.startedAt)})}):e(`div`,{className:`flex flex-col gap-0.5`,children:[r(`span`,{children:tn(t.finishedAt)}),r(`span`,{className:`text-[10px]`,children:i(`backup.runsPanel.took`,{elapsed:en(t.finishedAt-t.startedAt)})})]})}function $t(e){if(e<=1)return`next`;let t=e%100;if(t>=11&&t<=13)return`${e}th`;switch(e%10){case 1:return`${e}st`;case 2:return`${e}nd`;case 3:return`${e}rd`;default:return`${e}th`}}function en(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${String(t%60).padStart(2,`0`)}s`:`${Math.floor(n/60)}h ${String(n%60).padStart(2,`0`)}m`}function tn(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}o();var nn=[[`backup`,`list`]];function rn({initialDestinationId:n,initialArchiveId:o,onClose:c,onScheduled:l}){let{t:u}=G(),d=s(),[f,p]=a(n&&o?2:1),[m,h]=a(n),[g,_]=a(o),[v,y]=a(new Set),[b,S]=a(``),{data:C}=Le(),w=C??[],{data:D,isLoading:O}=he({destinationId:m??``},{enabled:!!m}),k=D??[];i(()=>{if(m!==void 0)return;let e=w.filter(e=>e.restoreSupported);e.length===1&&h(e[0].id)},[m,w]);let{data:A}=Se({destinationId:m??``,backupId:g??``},{enabled:!!m&&!!g}),M=t(()=>A?.locations??[],[A]);i(()=>{M.length!==0&&y(e=>e.size===0?new Set(M):e)},[M]);let N=ee({onSuccess:()=>{d.invalidateQueries({queryKey:nn}),l(),c()}}),P=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},F=k.find(e=>e.id===g),I=F?.encryption!==void 0,L=pt(F?.databases,A?.sqliteSnapshots),R=dt(L),ne=!!m&&!!g,z=R||v.size>0,B=ne&&z&&!N.isPending&&(!I||b.trim().length>0),V=()=>{!m||!g||N.mutate({destinationId:m,backupId:g,...R?{}:{locations:[...v]},...I?{backupSecretKey:b.trim()}:{}})};return r(Re,{open:!0,onOpenChange:e=>!e&&c(),children:e(Fe,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(Me,{children:[r(de,{children:u(`backup.restoreWizard.restoreBackup`,`Restore Backup`)}),r(`p`,{className:`text-xs text-foreground-subtle`,children:u(`backup.restoreWizard.stepOf`,{step:f,name:f===1?u(`backup.restoreWizard.pickSource`,`pick source`):f===2?u(`backup.restoreWizard.pickLocations`,`pick locations`):u(`backup.restoreWizard.confirmStep`)})})]}),e(ye,{children:[f===1&&r(an,{destinations:w,destinationId:m,onPickDestination:e=>{h(e),_(void 0),y(new Set)},archives:k,archivesLoading:O,archiveId:g,onPickArchive:_}),f===2&&r(on,{locations:M,picked:v,onToggle:P,databases:L,snapshotsOnly:R}),f===3&&r(sn,{destinationName:w.find(e=>e.id===m)?.displayName??m??``,archive:F,picked:[...v],databases:L,snapshotsOnly:R}),f===3&&F?.encryption!==void 0&&r(cn,{keyId:F.encryption.keyId,value:b,onChange:S}),f===3&&N.error&&r(`p`,{role:`alert`,className:`px-4 pb-2 text-xs text-danger`,children:N.error.message})]}),e(te,{className:`justify-between`,children:[r(`div`,{children:f>1&&e(U,{variant:`outline`,size:`sm`,onClick:()=>p(e=>e===3?2:1),children:[r(E,{className:`h-3 w-3`}),u(`common.back`,`Back`)]})}),e(`div`,{className:`flex items-center gap-2`,children:[r(U,{variant:`outline`,size:`sm`,onClick:c,children:u(`common.cancel`,`Cancel`)}),f<3?e(U,{size:`sm`,disabled:f===1&&!ne||f===2&&!z,onClick:()=>p(e=>e===1?2:3),children:[u(`common.next`,`Next`),r(T,{className:`h-3 w-3`})]}):e(U,{size:`sm`,onClick:V,disabled:!B,children:[N.isPending?r(x,{className:`h-3.5 w-3.5 animate-spin`}):r(j,{className:`h-3.5 w-3.5`}),u(`backup.restoreWizard.scheduleRestore`,`Schedule Restore`)]})]})]})]})})}function an({destinations:t,destinationId:n,onPickDestination:i,archives:a,archivesLoading:o,archiveId:s,onPickArchive:c}){let{t:l}=G(),u=t.filter(e=>e.restoreSupported);return e(`div`,{className:`p-4 space-y-3`,children:[e(`div`,{className:`space-y-1.5`,children:[r(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:l(`backup.restoreWizard.destination`,`Destination`)}),r(L,{value:n??``,onChange:e=>i(e.target.value),options:[{value:``,label:l(`backup.restoreWizard.selectDestination`,`Select destination…`)},...u.map(e=>({value:e.id,label:`${e.displayName} (${e.kind})`}))]})]}),e(`div`,{className:`space-y-1.5`,children:[r(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:l(`backup.restoreWizard.archive`,`Archive`)}),!n&&r(`div`,{className:`text-xs text-foreground-subtle italic`,children:l(`backup.restoreWizard.pickADestinationFirst`,`Pick a destination first.`)}),n&&o&&r(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:l(`backup.restoreWizard.readingArchives`,`Reading archives…`)}),n&&!o&&a.length===0&&r(`div`,{className:`text-xs text-foreground-subtle italic`,children:l(`backup.restoreWizard.noArchivesAvailableAtThis`,`No archives available at this destination.`)}),n&&a.length>0&&r(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:a.map(t=>{let n=s===t.id;return e(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${n?`bg-primary/10`:`hover:bg-primary/5`}`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(`input`,{type:`radio`,name:`archive`,checked:n,onChange:()=>c(t.id),className:`accent-primary`}),e(`div`,{children:[e(`div`,{className:`flex items-center gap-1 font-medium text-foreground`,children:[t.encryption!==void 0&&r(C,{className:`h-3 w-3 text-success`,"aria-label":l(`backup.restoreWizard.encryptedKey`,`encrypted (key {{keyId}})`,{keyId:t.encryption.keyId})}),t.label??t.id]}),r(`div`,{className:`text-[10px] text-foreground-subtle`,children:new Date(t.createdAt).toLocaleString()}),r(`div`,{className:`pt-1`,children:r(Z,{databases:pt(t.databases,void 0)})})]})]}),r(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:K(t.sizeBytes)})]},t.id)})})]})]})}function on({locations:t,picked:n,onToggle:i,databases:a,snapshotsOnly:o}){let{t:s}=G();return o?e(`div`,{className:`space-y-3 p-4`,children:[e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`backup.restoreWizard.databasesInThisArchive`,`Databases in this archive`)}),r(Z,{databases:a})]}),r(`div`,{className:`rounded border border-info/30 bg-info/10 px-3 py-2 text-[11px] text-info`,children:s(`backup.restoreWizard.snapshotsOnlyRestoringThisArchive`,`Snapshots only: restoring this archive replaces just these databases. It does NOT touch configuration, addons, addon data or certificates.`)})]}):t.length===0?r(`div`,{className:`p-4`,children:r(`div`,{className:`text-xs text-foreground-subtle`,children:s(`backup.restoreWizard.loadingArchiveManifestIfThis`,`Loading archive manifest… If this persists, the archive may predate manifests — restoring will apply everything in the tarball.`)})}):e(`div`,{className:`p-4 space-y-3`,children:[e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`backup.restoreWizard.databasesInThisArchive`,`Databases in this archive`)}),r(Z,{databases:a})]}),r(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-[11px] text-warning`,children:s(`backup.restoreWizard.selectedEntriesWillOverwriteLive`,`Selected entries will overwrite live data on the next server restart. Unchecked entries stay current.`)}),e(`div`,{className:`space-y-1.5`,children:[r(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:s(`common.apply`,`Apply`)}),r(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:t.map(t=>e(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[r(`input`,{type:`checkbox`,checked:n.has(t),onChange:()=>i(t),className:`accent-primary`}),r(`span`,{className:`font-mono text-foreground`,children:t}),r(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:un(t)})]},t))})]})]})}function sn({destinationName:t,archive:n,picked:i,databases:a,snapshotsOnly:o}){let{t:s}=G();return e(`div`,{className:`p-4 space-y-3 text-xs`,children:[r(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-warning`,children:s(`backup.restoreWizard.restoreIsAppliedAtNext`,`Restore is applied at next server boot. Active connections will drop when you restart.`)}),e(`dl`,{className:`space-y-1.5`,children:[r($,{term:`Destination`,value:t}),r($,{term:`Archive`,value:n?.label??n?.id??`—`}),n&&r($,{term:`Created`,value:`${new Date(n.createdAt).toLocaleString()} · ${K(n.sizeBytes)}`}),e(`div`,{className:`flex justify-between gap-3`,children:[r(`dt`,{className:`text-foreground-subtle`,children:s(`backup.restoreWizard.databases`,`Databases`)}),r(`dd`,{className:`text-right`,children:r(Z,{databases:a})})]}),r($,{term:`Locations`,value:o?`none (configuration is not touched)`:i.length>0?i.join(`, `):`— (full archive)`})]})]})}function cn({keyId:t,value:n,onChange:i}){let{t:a}=G();return e(`div`,{className:`space-y-1.5 px-4 pb-3`,children:[r(`label`,{htmlFor:`restore-backup-key`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:a(`backup.restoreWizard.backupKey`,`Backup key`)}),r(`input`,{id:`restore-backup-key`,type:`password`,autoComplete:`off`,spellCheck:!1,value:n,onChange:e=>i(e.target.value),placeholder:a(`backup.restoreWizard.camstackBackupSecretV1`,`camstack-backup-secret-v1:…`),className:`w-full rounded border border-border bg-background px-2 py-1.5 font-mono text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(He,{i18nKey:`backup.restoreWizard.encryptedTo`,values:{keyId:t},components:{mono:r(`span`,{className:`font-mono`})}})})]})}function $({term:t,value:n}){return e(`div`,{className:`flex justify-between gap-3`,children:[r(`dt`,{className:`text-foreground-subtle`,children:t}),r(`dd`,{className:`text-foreground font-mono text-right truncate`,children:n})]})}var ln={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function un(e){return ln[e]??``}o();function dn(){let{t}=G(),n=D(),o=fe(),{state:s,openNew:c,openEdit:l,close:u}=ge({editKey:`edit`,newKey:`new`}),f=Pe(),m=f.data??[],[h,g]=a(null),[_,v]=a(!1),[y,b]=a(!1),[S,C]=a(!1),w=s.mode===`edit`?m.find(e=>e.id===s.id)??null:null;i(()=>{s.mode===`edit`&&!f.isLoading&&w===null&&u()},[s.mode,f.isLoading,w,u]);let T=s.mode===`new`||s.mode===`edit`&&w!==null,E=async()=>{await n({title:t(`system.backup.restartServerNow`,`Restart server now?`),message:t(`system.backup.activeConnectionsWillDropAnd`,`Active connections will drop and the apply-backup hook will run before boot.`),confirmLabel:t(`system.backup.restart`,`Restart`),variant:`warning`})&&o.mutate({confirm:!0})};return e(Ge,{embedded:!0,children:[e(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,"data-testid":`backup-actions`,children:[e(U,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>C(!0),"data-testid":`backup-now`,children:[r(p,{className:`h-3.5 w-3.5`}),t(`system.backup.backUpNow`,`Back up now`)]}),e(U,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>v(!0),children:[r(j,{className:`h-3.5 w-3.5`}),t(`system.backup.restore`,`Restore…`)]}),e(U,{size:`sm`,type:`button`,onClick:c,"data-testid":`backup-new-entry`,children:[r(d,{className:`h-3.5 w-3.5`}),t(`system.backup.newEntry`,`New entry`)]})]}),y&&r(`div`,{className:`rounded-lg border border-warning/30 bg-warning/10 px-3 py-2.5 text-xs text-warning`,children:e(`div`,{className:`flex items-center justify-between gap-3`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(j,{className:`h-3.5 w-3.5`}),r(`span`,{children:t(`system.backup.restoreScheduledRestartTheServer`,`Restore scheduled. Restart the server to apply.`)})]}),e(U,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{E()},disabled:o.isPending,children:[o.isPending?r(x,{className:`h-3.5 w-3.5 animate-spin`}):r(j,{className:`h-3.5 w-3.5`}),t(`system.backup.restartNow`,`Restart Now`)]})]})}),r(Pt,{}),r(Kt,{}),r(bt,{onEdit:e=>l(e.id),onOpenRestoreWizard:e=>g(e)}),T&&r(Ht,{entry:w,onClose:u,onSaved:u}),S&&r(At,{onClose:()=>C(!1)}),(h||_)&&r(rn,{...h?{initialDestinationId:h.destinationId,initialArchiveId:h.archiveId}:{},onClose:()=>{g(null),v(!1)},onScheduled:()=>b(!0)})]})}o();function fn(e){return Object.entries(e).map(([e,t])=>`${e} ${t}`).join(` · `)}function pn(e){return e.reduce((e,t)=>e+Object.values(t.stores).reduce((e,t)=>e+t,0),0)}function mn(){let{t}=G(),n=D(),i=ve(),[o,s]=a(null),[l,u]=a(null),d=async e=>{u(null);try{s(await i.mutateAsync({confirm:e}))}catch(e){u(e instanceof Error?e.message:String(e))}},p=async()=>{o===null||o.status!==`dry-run`||await n({title:t(`systemPage.deletedDevices.confirmTitle`,`Delete the data of deleted devices?`),message:o.devices.map(e=>`#${e.deviceId}: ${fn(e.stores)}`).join(`
|
|
2
|
+
`),confirmLabel:t(`systemPage.deletedDevices.confirmLabel`,`Delete`),variant:`danger`})&&await d(!0)},m=[{key:`device`,header:t(`systemPage.deletedDevices.device`,`Device`),render:e=>`#${e.deviceId}`},{key:`stores`,header:t(`systemPage.deletedDevices.stores`,`Data held`),nowrap:!1,render:e=>fn(e.stores)}];return e(`div`,{className:`space-y-4`,"data-testid":`deleted-devices-data`,children:[r(`p`,{className:`text-sm text-foreground-muted`,children:t(`systemPage.deletedDevices.intro`,`Data that still belongs to devices that were deleted before deletions were recorded: footage, events, history and per-addon settings. Scanning deletes nothing; deleting asks first and shows what goes.`)}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(U,{variant:`outline`,onClick:()=>void d(!1),disabled:i.isPending,"data-testid":`deleted-devices-scan`,children:[i.isPending?r(x,{className:`mr-2 h-4 w-4 animate-spin`}):r(A,{className:`mr-2 h-4 w-4`}),t(`systemPage.deletedDevices.scan`,`Scan`)]}),o?.status===`dry-run`&&o.devices.length>0?e(U,{variant:`danger`,onClick:()=>void p(),disabled:i.isPending,"data-testid":`deleted-devices-delete`,children:[r(f,{className:`mr-2 h-4 w-4`}),t(`systemPage.deletedDevices.delete`,`Delete the data of {{count}} devices…`,{count:o.devices.length})]}):null]}),l===null?null:r(`p`,{className:`text-sm text-danger`,children:l}),o?.status===`skipped`?r(`p`,{className:`text-sm text-warning`,"data-testid":`deleted-devices-skipped`,children:t(`systemPage.deletedDevices.skipped`,`Nothing was listed or deleted: the device list could not be trusted ({{reason}}). Try again.`,{reason:o.reason??``})}):null,o!==null&&o.status!==`skipped`?e(c,{children:[r(`p`,{className:`text-sm`,"data-testid":`deleted-devices-summary`,children:o.status===`cleaned`?t(`systemPage.deletedDevices.cleaned`,`Deleted {{rows}} items of {{count}} devices.`,{rows:pn(o.devices),count:o.devices.length}):t(`systemPage.deletedDevices.found`,`{{count}} deleted devices still hold {{rows}} items.`,{rows:pn(o.devices),count:o.devices.length})}),r(R,{columns:m,rows:o.devices,rowKey:e=>e.deviceId,emptyMessage:t(`systemPage.deletedDevices.none`,`No data belongs to a deleted device.`)}),o.unreachable.length>0?r(`p`,{className:`text-xs text-foreground-muted`,children:t(`systemPage.deletedDevices.unreachable`,`Not asked (unreachable): {{names}}`,{names:o.unreachable.join(`, `)})}):null]}):null]})}var hn=`view`,gn=`kinds`,_n=`deleted-devices`;function vn(){let{t}=G(),[n,i]=Ue(),a=n.get(`view`)===`deleted-devices`?_n:gn;return e(`div`,{className:l,children:[e(`div`,{className:`mb-3 space-y-2`,children:[r(ie,{appearance:`pills`,value:a,onValueChange:e=>{i(t=>{let n=new URLSearchParams(t);return e===`kinds`?n.delete(hn):n.set(hn,e),n},{replace:!0})},children:e(re,{className:`flex flex-wrap gap-1`,children:[r(pe,{value:gn,children:t(`systemPage.data.viewKinds`,`Record kinds`)}),r(pe,{value:_n,children:t(`systemPage.data.viewDeletedDevices`,`Deleted devices`)})]})}),a===`kinds`?r(`p`,{className:`text-xs text-foreground-muted`,children:t(`systemPage.data.recordsUnifiedIntro`,`Every declared record kind on this hub. Entry kinds can be added, edited and deleted; the rest are read-only. Secret fields are redacted.`)}):null]}),r(a===`kinds`?De:mn,{})]})}var yn={entries:null,"deleted-devices":`deleted-devices`};function bn(){let{t:e}=G(),t=Be(`/system/data`,{t:e,isAdmin:!0})??{icon:O,title:e(`system.data`,`Data`)},[n]=Ue(),i=yn[n.get(`tab`)??``];if(i!==void 0){let e=new URLSearchParams(n);return e.set(`tab`,`records`),i!==null&&e.set(`view`,i),r(Ve,{replace:!0,to:{search:e.toString()}})}return r(We,{icon:t.icon,title:t.title,defaultSection:`storage`,sectionsLabel:`${t.title} sections`,sections:[{id:`storage`,label:e(`systemPage.data.storage`,`Storage`),content:r(tt,{})},{id:`records`,label:e(`systemPage.data.records`,`Records`),content:r(vn,{}),ownedParams:[`view`,`recordsOwner`,`recordsKind`,`entryNew`,`entryEdit`]},{id:`backup`,label:e(`systemPage.data.backup`,`Backup`),content:r(dn,{})}]})}export{bn as DataPage};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,t as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as f,Dn as p,En as m,Fr as h,G as g,Gi as _,Gn as v,Gr as y,Ht as b,In as x,J as S,K as C,Kr as w,Mn as T,O as E,Ot as D,Pi as O,Qn as k,St as A,Tn as j,V as M,Vn as ee,W as N,Wi as te,Z as ne,Zn as re,_n as P,bi as ie,bt as F,ca as ae,dt as I,er as oe,fr as se,gi as ce,gt as L,hr as R,ki as z,kr as le,lr as ue,ma as de,mr as fe,nr as B,on as pe,q as me,r as he,ri as ge,rn as _e,sr as ve,st as ye,t as be,ti as xe,ur as V,wn as Se,yn as Ce,z as H}from"./player-overlays-oTS1TZZY.js";import{Bn as we,Cr as Te,Dr as Ee,Ga as De,Hi as Oe,Hn as ke,Ja as U,Jt as Ae,La as je,Li as Me,Mo as W,No as Ne,Or as Pe,Qt as Fe,Vn as Ie,Xt as Le,Ya as G,Yi as Re,Yt as ze,Zt as Be,da as Ve,f as He,fi as Ue,ji as We,ko as Ge,n as Ke,nr as qe,qa as Je,qt as Ye,ra as Xe,tr as Ze,yi as Qe,zn as $e}from"./client-DcvpIFoh.js";import{t as et}from"./archive-DQvuyIac.js";import{i as tt,n as nt,r as rt,t as it}from"./scan-eye-BhxGMB3E.js";import{t as at}from"./bell-off-C3u183tq.js";import{r as ot,t as st}from"./sigma-BYdS13dc.js";import{t as ct}from"./boxes-CVkAEP7e.js";import{n as lt}from"./video-Dx3E7zlj.js";import{t as ut}from"./circle-slash-C86XHeiD.js";import{t as dt}from"./file-up-C9_pj2VT.js";import{t as ft}from"./layers-DGMlfnn4.js";import{$t as pt,Ad as mt,Al as ht,An as gt,Ar as _t,Bd as vt,Bn as yt,Bo as bt,Bs as xt,Bt as St,Ci as Ct,Cn as wt,Cr as Tt,Do as Et,Dr as Dt,Dt as Ot,En as kt,Er as At,Et as jt,Fo as Mt,Fr as Nt,Gr as Pt,Gt as Ft,Hd as It,Hr as Lt,Ht as Rt,Id as zt,Io as Bt,It as Vt,Ja as Ht,Ji as Ut,Jn as Wt,Jt as Gt,Kn as Kt,Ko as qt,Kt as Jt,Ld as Yt,Lo as Xt,Mc as Zt,Ml as Qt,Mo as $t,Nn as en,No as tn,Nr as K,Oi as nn,Ol as rn,On as an,Oo as on,Ot as sn,Pc as cn,Po as ln,Ps as un,Pt as dn,Qd as fn,Qt as pn,Rd as mn,Rn as hn,Rs as gn,Rt as _n,So as vn,Sr as yn,Ti as bn,Tr as xn,Ua as Sn,Uo as Cn,Ur as wn,Ut as Tn,V as En,Vl as Dn,Vn as On,Vr as kn,Wa as An,Wr as jn,Xa as Mn,Xn as Nn,Xt as Pn,Yd as Fn,Yn as In,Yr as Ln,Yt as Rn,Yu as zn,Zc as Bn,Zn as Vn,a as Hn,al as Un,at as Wn,br as Gn,c as Kn,cn as qn,co as Jn,cs as Yn,ct as Xn,d as Zn,di as q,dt as Qn,du as $n,ef as er,ei as tr,en as nr,et as rr,fc as ir,fs as ar,gn as or,hu as sr,i as cr,io as lr,it as ur,jl as dr,jo as fr,kl as pr,kn as mr,kr as hr,ll as gr,lt as _r,mu as vr,nr as yr,nu as br,o as xr,ol as Sr,on as Cr,oo as wr,os as Tr,pc as Er,pl as Dr,pu as Or,qa as kr,qd as Ar,qn as jr,r as Mr,ri as J,ro as Nr,sl as Pr,sn as Fr,so as Ir,st as Lr,tf as Rr,tn as zr,to as Br,tr as Vr,tt as Hr,ua as Ur,ut as Wr,vl as Gr,vo as Kr,vr as qr,wc as Jr,wi as Yr,wr as Xr,wt as Zr,xi as Qr,xr as $r,yr as ei,zd as ti,zn as ni,zs as ri,zt as ii}from"./src-XEHc18wE.js";import{t as Y}from"./i18n-C-H4BlYV.js";import{t as X}from"./useTranslation-BJr-n0es.js";import"./mount-BvJkcx-a.js";import{A as ai,C as oi,M as si,N as ci,P as li,_r as ui,ar as di,cr as fi,dr as pi,fr as mi,ir as hi,j as gi,k as _i,lr as vi,mr as yi,or as bi,p as xi,pr as Si,rr as Ci,sr as wi,ur as Z,vr as Ti,yr as Ei}from"./index-o6kBNilE.js";import{n as Di,t as Oi}from"./format-DGQA45Ye.js";import{a as ki,r as Ai,t as ji}from"./ComposedDeviceEditDialog-BLfm22uf.js";import{$ as Mi,A as Ni,B as Pi,D as Fi,E as Ii,F as Li,H as Ri,I as zi,J as Bi,K as Vi,L as Hi,M as Ui,N as Wi,O as Gi,P as Ki,Q as qi,R as Ji,S as Yi,T as Xi,U as Zi,V as Qi,W as $i,X as ea,Y as ta,Z as na,_ as ra,at as ia,b as aa,c as oa,d as sa,et as ca,f as la,h as ua,it as da,j as fa,k as pa,l as ma,m as ha,p as ga,q as _a,rt as va,s as ya,tt as ba,u as xa,v as Sa,x as Ca,z as wa}from"./CompositionBlockEditor-CJhCzXua.js";import{t as Ta}from"./assignment-candidates-83kFfE1Z.js";import{_ as Ea,b as Da,i as Oa,m as ka,o as Aa,t as ja}from"./step-inspector-model-a05i0m0c.js";import"./useEventInvalidation-BvJkcx-a.js";import{t as Ma}from"./use-stationary-objects-blP9Y5SS.js";import{a as Na,i as Pa,n as Fa,o as Ia,r as La,s as Ra,t as za}from"./linked-devices-model-D6PgoQtW.js";import{f as Ba,h as Va,t as Ha}from"./RemoteGrid-C_9BszV-.js";import{t as Ua}from"./authed-media-BSoR_xYF.js";c();function Wa(e){if(typeof e!=`object`||!e)return null;let t=e,n=t.id,r=t.label;if(typeof n!=`string`||typeof r!=`string`)return null;let i=t.available===!0,a=t.enabled,o=t.unavailableReason;return{id:n,label:r,costWhenOff:typeof t.costWhenOff==`string`?t.costWhenOff:``,on:i&&typeof a==`boolean`?a:null,available:i,unavailableReason:typeof o==`string`?o:null}}function Ga(e){if(typeof e!=`object`||!e)return null;let t=e.switches;if(!Array.isArray(t))return null;let n=t.map(Wa).filter(e=>e!==null);return n.length===0?null:n}var Ka=[[/privacy|mask/i,`privacy`],[/microphone|mic\b/i,`microphone`],[/speaker|broker audio|stream audio/i,`speaker`],[/audio/i,`listening`],[/object|detect/i,`detection`],[/event/i,`archive`],[/record/i,`recording`],[/notif/i,`notifications`],[/stream|broker/i,`stream`]];function qa(e){for(let[t,n]of Ka)if(t.test(e))return n;return`generic`}function Ja(e){let t=e.filter(e=>e.on===!1).map(e=>e.id),n=e.filter(e=>e.on===null).map(e=>e.id),r=t=>t.map(t=>e.find(e=>e.id===t)?.label??t).join(`, `),i=[];return t.length>0&&i.push(Y.t(`helpers.cameraSwitchRows.off`,{list:r(t)})),n.length>0&&i.push(Y.t(`helpers.cameraSwitchRows.unknown`,{list:r(n)})),{offIds:t,unknownIds:n,summary:i.length===0?Y.t(`helpers.cameraSwitchRows.allOn`):i.join(` · `)}}var Ya={stream:p,detection:it,privacy:y,microphone:B,speaker:D,listening:nt,archive:et,recording:rt,notifications:te,generic:pe};function Xa({deviceId:t}){let{t:n}=X(),a=l(),s=Number.isFinite(t),[c,u]=o(null),[d,f]=o(!1),p=gr({deviceId:t},{enabled:s});Mr([`pipelineOrchestrator`,`getCameraSwitches`],[`capability.binding-changed`]);let m=Ga(p.data),h=Qt({onError:(e,n)=>{console.error(`[CameraFunctionSwitches] switch write failed — reverting`,{tags:{deviceId:t},meta:{switchId:n.switchId,error:e instanceof Error?e.message:String(e)}}),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraSwitches`]]}),u({id:n.switchId,message:e instanceof Error?e.message:String(e)})},onSuccess:()=>{u(null),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]}),a.invalidateQueries({queryKey:[[`deviceManager`]]}),a.invalidateQueries({queryKey:[[`recording`]]})}}),g=r(e=>{!e.available||e.on===null||h.mutate({deviceId:t,switchId:e.id,enabled:!e.on})},[t,h]);if(m===null)return null;let _=Ja(m),v=e=>c?.id===e.id?c.message:null;return e(mn,{open:d,onOpenChange:f,children:[e(vt,{"aria-label":n(`device.cameraFunctionSwitches.cameraFunctions`,`Camera functions`),title:_.summary,className:`inline-flex items-center gap-1 rounded-lg border px-2 py-1.5 text-[11px] font-medium transition-colors ${c===null?_.offIds.length>0?`border-warning/40 text-warning hover:bg-warning/10`:`border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover`:`border-danger/50 text-danger bg-danger/5`}`,children:[i(pe,{className:`h-3.5 w-3.5`}),i(`span`,{className:`hidden lg:inline`,children:n(`device.cameraFunctionSwitches.functions`,`Functions`)}),_.offIds.length>0&&i(`span`,{className:`rounded bg-warning/20 px-1 text-[9px] font-semibold uppercase tracking-wide`,children:n(`device.cameraFunctionSwitches.offCount`,{count:_.offIds.length})})]}),e(ti,{align:`end`,className:`min-w-[240px] max-h-[60vh] overflow-y-auto p-1`,children:[i(`div`,{className:`px-2 py-1 text-[10px] uppercase tracking-wider text-foreground-subtle`,children:n(`device.cameraFunctionSwitches.cameraFunctions`,`Camera functions`)}),i(`ul`,{className:`space-y-0.5`,children:m.map(e=>i(`li`,{children:i(Za,{row:e,failure:v(e),onToggle:()=>g(e)})},e.id))})]})]})}function Za({row:t,failure:n,onToggle:r}){let{t:a}=X(),o=Ya[qa(t.label)],s=t.on===null,c=t.on===!1,l=n===null?s?t.unavailableReason??`The source that owns this did not answer.`:t.costWhenOff:`Write failed: ${n}`,u=n===null?s?t.unavailableReason??`unknown`:null:`write failed`;return e(`button`,{type:`button`,role:`switch`,"aria-label":t.label,"aria-checked":t.on===!0,disabled:!t.available,onClick:r,title:l,className:`flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-[12px] text-foreground transition-colors hover:bg-surface-hover disabled:opacity-40 disabled:cursor-not-allowed`,children:[i(o,{className:`h-3.5 w-3.5 shrink-0 ${n===null?s?`text-foreground-subtle/50`:c?`text-warning`:`text-success`:`text-danger`}`}),e(`span`,{className:`flex-1 min-w-0 truncate`,children:[t.label,u!==null&&e(`span`,{className:`ml-1 text-[10px] text-foreground-subtle`,children:[`· `,u]})]}),i(`span`,{className:`shrink-0 rounded px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide ${s?`bg-surface-hover text-foreground-subtle/60`:c?`bg-warning/20 text-warning`:`bg-success/20 text-success`}`,children:s?`—`:a(c?`common.off`:`common.on`)})]})}function Qa({deviceId:t}){let n=Ft(I().trpcClient,t);return n===null?null:e(`a`,{href:n.url,target:`_blank`,rel:`noopener noreferrer`,title:`${n.label} — ${n.host}`,className:`inline-flex items-center gap-1.5 rounded-lg px-2 sm: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`,children:[i(w,{className:`h-3.5 w-3.5`}),i(`span`,{className:`hidden sm:inline`,children:n.label})]})}function $a({parentDeviceId:t}){let{t:n}=X(),r=ui(),a=I(),{data:o,isLoading:s,isError:c}=fi(t),{data:l}=fr({deviceId:t},{enabled:Number.isFinite(t)});if(s)return i(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:i(`p`,{className:`text-[10px] text-foreground-subtle`,children:n(`common.loading`,{defaultValue:`Loading…`})})});if(c)return i(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:i(`p`,{className:`text-[10px] text-warning`,children:n(`integrations.childrenLoadError`,{defaultValue:`Failed to load children`})})});let u=(o??[]).filter(e=>e.display?.hidden!==!0);if(u.length===0)return null;let d=St(l?.stableId??``,u,l?.childLayout),f=d.ungrouped,p=e=>r(`/devices/${String(e)}`),m=l?.name??``,h=(e,t)=>i(_n,{trpc:a.trpcClient,device:{...t,name:Jt(t,m)},nameForm:`nested`,...l?{parent:{id:l.id,name:l.name,type:l.type}}:{},variant:`minimal`,onNavigate:p},e),g=f.some(e=>!!e.role),_=f.some(e=>!e.role),v=g&&!_?n(`device.accessories`,{defaultValue:`Accessories`}):!g&&_?n(`device.adoptedDevices`,{defaultValue:`Adopted devices`}):n(`device.children`,{defaultValue:`Children`}),y=f.length>0?e(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[i(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle mb-1.5`,children:v}),i(`div`,{className:`space-y-1`,children:f.map(e=>h(e.id,e))})]}):null,b=d.disabledSection===void 0?null:i(ii,{title:n(`device.disabledSection`,{defaultValue:`Disabled`}),count:d.disabledSection.children.length,defaultOpen:!1,children:i(`div`,{className:`opacity-60 space-y-1`,children:d.disabledSection.children.map(e=>h(e.id,e))})},d.disabledSection.title);if(d.sections.length===0)return b===null?y:e(`div`,{className:`space-y-2`,children:[y,b]});let x=_&&!g;return e(`div`,{className:`space-y-2`,children:[x?y:null,d.sections.map(e=>i(ii,{title:e.title,count:e.children.length,defaultOpen:e.defaultOpen,children:e.children.map(e=>h(e.id,e))},e.title)),x?null:y,b]})}function eo({deviceId:e}){let t=I(),{data:n,isLoading:r}=wi(e),{data:a,isLoading:o}=fi(e),s=r||o,c=(a??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:e.name,features:e.features,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}})),l=typeof n?.linkDeviceId==`number`?n.linkDeviceId:null,u=typeof n?.primaryChildEntityId==`string`?n.primaryChildEntityId:null;return s?i(`div`,{className:`h-full min-h-32 w-full animate-pulse rounded-lg bg-surface`,"aria-hidden":`true`}):i(`div`,{className:`flex h-full w-full flex-col`,children:i(Gt,{trpc:t.trpcClient,children:c,linkDeviceId:l,primaryChildEntityId:u})})}c();function to({dev:t,busy:n,setBusy:r}){let{t:a}=X(),s=t?.motionTrigger,c=S(t?.state.motionTrigger),[l,u]=o(!1);if(!s)return null;let d=c?.enabled===!0,f=c!==void 0,p=async()=>{if(n||!f)return;let e=!d;r(!0),u(!0);try{await s.setMotionTrigger({enabled:e})}finally{r(!1),u(!1)}},m=l?d?`Disabling…`:`Enabling…`:f?d?`On motion: on`:`On motion: off`:`On motion: …`;return e(`button`,{type:`button`,onClick:()=>{p()},disabled:n||!f,title:f?d?a(`hero.motionTriggerToggle.disableTriggerOnMotion`,`Disable trigger on motion`):a(`hero.motionTriggerToggle.enableTriggerOnMotion`,`Enable trigger on motion`):a(`hero.motionTriggerToggle.awaitingState`,`Awaiting state…`),"aria-pressed":d,className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${d?`border-primary/50 bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle hover:text-foreground`}`,children:[i(ae,{className:`h-3 w-3`}),i(`span`,{children:m})]})}c();function Q({deviceId:t,deviceType:n,features:r}){let a=I(),s=pn(n)?.HeroCard??pt,c=C(a.trpcClient,t),l=S(c?.state.deviceStatus),[u,d]=o(!1),f=l!==void 0&&l.online===!1,p=f?l.lastChangedAt:null;return e(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:[f?i(`div`,{className:`flex justify-center`,children:i(Pn,{lastChangedAt:p})}):null,i(s,{trpc:a.trpcClient,deviceId:t,features:r}),i(`div`,{className:`flex justify-center`,children:i(to,{dev:c,busy:u,setBusy:d})})]})}function no({deviceId:e,features:t}){return i(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:i(nr,{trpc:I().trpcClient,deviceId:e,features:t})})}function ro({deviceId:e,features:t}){return i(`div`,{className:`flex h-full w-full flex-col items-stretch p-3 sm:p-4`,children:i(pt,{trpc:I().trpcClient,deviceId:e,features:t})})}function io(e){if(!e)return null;let t=e.channel;return typeof t!=`number`||!Number.isInteger(t)||t<0?null:t}function ao(e){if(!e)return null;let t=io(e.data);return t===null?e.eventType:Y.t(`helpers.eventEmitterFormat.buttonHeadline`,{channel:String(t),eventType:e.eventType})}var oo=1e3,so=60*oo,co=60*so,lo=24*co;function uo(e,t){if(e==null||e<=0)return`—`;let n=t-e;return n<oo?Y.t(`helpers.relativeTime.justNow`):n<so?Y.t(`helpers.relativeTime.secondsAgo`,{count:Math.floor(n/oo)}):n<co?Y.t(`helpers.relativeTime.minutesAgo`,{count:Math.floor(n/so)}):n<lo?Y.t(`helpers.relativeTime.hoursAgo`,{count:Math.floor(n/co)}):Y.t(`helpers.relativeTime.daysAgo`,{count:Math.floor(n/lo)})}c();var fo=1500,po=15e3,mo=1e3;function ho({deviceId:n}){let{t:r}=X(),s=C(I().trpcClient,n)?.state.eventEmitter,c=S(s);a(()=>{if(!s)return;s.refresh();let e=setInterval(()=>{s.refresh()},po);return()=>{clearInterval(e)}},[s]);let l=c?.lastEvent??null,u=l?.seq??null,d=t(null),[f,p]=o(!1);a(()=>{if(u===null)return;let e=d.current;if(d.current=u,e===null||e===u)return;p(!0);let t=setTimeout(()=>{p(!1)},fo);return()=>{clearTimeout(t)}},[u]);let[m,h]=o(()=>Date.now());a(()=>{let e=setInterval(()=>{h(Date.now())},mo);return()=>{clearInterval(e)}},[]);let g=ao(l),_=c?.eventTypes??[],v=c?.eventCountSinceStart??0,y=c!==void 0,b=io(l?.data);return e(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 p-4`,children:[i(`div`,{"data-testid":`event-emitter-indicator`,"data-flashing":String(f),className:`flex h-24 w-24 items-center justify-center rounded-full border-2 transition-all ${f?`border-primary bg-primary/20 text-primary shadow-lg shadow-primary/30 scale-105`:`border-border bg-surface text-foreground-subtle`}`,"aria-live":`polite`,title:g??r(`hero.eventEmitterHero.noPressRecorded`,`No press recorded`),children:i(f?re:le,{className:`h-10 w-10`})}),e(`div`,{className:`text-center`,children:[b!==null&&i(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-primary`,children:r(`hero.eventEmitterHero.button`,`Button {{value1}}`,{value1:String(b)})}),i(`div`,{"data-testid":`event-emitter-headline`,className:`text-sm font-semibold ${g?`text-foreground`:`text-foreground-subtle`}`,children:g??(y?r(`hero.eventEmitterHero.noPressRecorded`,`No press recorded`):r(`hero.eventEmitterHero.awaitingState`,`Awaiting state…`))}),i(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:l?uo(l.timestamp,m):r(`hero.eventEmitterHero.waitingForTheFirstEvent`,`Waiting for the first event`)})]}),_.length>0&&i(`div`,{className:`flex max-w-full flex-wrap justify-center gap-1`,children:_.map(e=>i(`span`,{"data-testid":`event-emitter-chip`,className:`rounded-full border px-2 py-0.5 text-[10px] font-medium ${e===l?.eventType?`border-primary bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle`}`,children:e},e))}),i(`div`,{className:`text-[10px] text-foreground-subtle`,children:r(`hero.eventEmitterHero.sinceStart`,{count:v})})]})}function go({deviceName:t,deviceType:n,provider:r,isOnline:a,features:o}){let{t:s}=X();return e(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border bg-surface p-6 text-center`,children:[i(pi,{type:r,size:`lg`}),e(`div`,{children:[i(`div`,{className:`text-sm font-semibold text-foreground`,children:t}),i(`div`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wider mt-0.5`,children:n})]}),e(`div`,{className:`flex items-center gap-2 flex-wrap justify-center`,children:[i(Wr,{status:a?`online`:`offline`}),o.length>0&&i(mi,{capabilities:o})]}),i(`div`,{className:`text-[10px] text-foreground-subtle italic max-w-xs mt-1`,children:s(`hero.genericHero.noLiveViewForThis`,`No live view for this device type. Use the Config tab or the shortcut row to interact.`)})]})}c();function _o({deviceId:t}){let{t:r}=X(),a=l(),o=Nr({deviceId:t},{refetchInterval:1e4,retry:!1}),s=lr({onSuccess:()=>{a.invalidateQueries({queryKey:[[`deviceDiscovery`,`listDiscovered`]]}),a.invalidateQueries({queryKey:[[`deviceDiscovery`,`getStatus`]]})}}),c=n(()=>vo(o.data??[]),[o.data]);return e(`div`,{className:`flex h-full w-full flex-col gap-3 p-3 sm:p-4`,children:[e(`div`,{className:`flex flex-wrap items-stretch gap-2 sm:gap-3`,children:[i(yo,{label:r(`hero.hubHero.discovered`,`Discovered`),value:c.total,icon:i(v,{className:`h-3.5 w-3.5`})}),i(yo,{label:r(`hero.hubHero.adopted`,`Adopted`),value:c.adopted,accent:`success`}),i(yo,{label:r(`hero.hubHero.available`,`Available`),value:c.available,accent:c.available>0?`primary`:void 0}),e(`button`,{type:`button`,onClick:()=>{s.mutateAsync({deviceId:t}).catch(()=>{})},disabled:s.isPending,className:`inline-flex items-center justify-center gap-1.5 rounded-lg border border-border px-3 py-2 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 self-stretch shrink-0`,children:[s.isPending?i(se,{className:`h-3.5 w-3.5 animate-spin`}):i(m,{className:`h-3.5 w-3.5`}),i(`span`,{className:`hidden sm:inline`,children:r(`hero.hubHero.discover`,`Discover`)})]})]}),e(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-foreground-subtle border-t border-border-subtle pt-2`,children:[i(bo,{icon:i(F,{className:`h-3 w-3 text-emerald-500`}),label:r(`hero.hubHero.online`,`{{online}} online`,{online:c.online})}),i(bo,{icon:i(k,{className:`h-3 w-3 text-amber-500`}),label:r(`hero.hubHero.sleeping`,`{{sleeping}} sleeping`,{sleeping:c.sleeping})}),i(bo,{icon:i(A,{className:`h-3 w-3 text-destructive`}),label:r(`hero.hubHero.offline`,`{{offline}} offline`,{offline:c.offline})}),c.unknown>0?i(bo,{icon:i(ce,{className:`h-3 w-3 text-foreground-subtle`}),label:r(`hero.hubHero.unknown`,`{{unknown}} unknown`,{unknown:c.unknown})}):null]})]})}function vo(e){let t={total:e.length,adopted:0,available:0,online:0,sleeping:0,offline:0,unknown:0};for(let n of e)n.alreadyAdopted?t.adopted+=1:t.available+=1,t[n.status]+=1;return t}function yo({label:t,value:n,icon:r,accent:a}){return e(`div`,{className:`flex flex-1 basis-[140px] min-w-0 flex-col gap-1 rounded-lg border px-2 py-1.5 sm:px-3 sm:py-2 ${a===`success`?`bg-emerald-500/10 border-emerald-500/30 text-emerald-500`:a===`primary`?`bg-primary/10 border-primary/30 text-primary`:`bg-surface-hover border-border text-foreground`}`,children:[e(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wider opacity-70 truncate`,children:[r,i(`span`,{className:`truncate`,children:t})]}),i(`div`,{className:`text-xl sm:text-2xl font-semibold tabular-nums leading-none`,children:n})]})}function bo({icon:t,label:n}){return e(`span`,{className:`inline-flex items-center gap-1`,children:[t,i(`span`,{children:n})]})}var xo={[G.Switch]:Q,[G.Siren]:Q,[G.Light]:Q,[G.Sensor]:Q,[G.Button]:Q,[G.Hub]:_o,[G.Cover]:no,[G.Valve]:Q,[G.Humidifier]:Q,[G.WaterHeater]:Q,[G.Container]:eo,[G.Lock]:Q,[G.Fan]:Q,[G.Thermostat]:Q,[G.Climate]:Q,[G.MediaPlayer]:Q,[G.Control]:Q,[G.AlarmPanel]:Q,[G.EventEmitter]:ho,[G.Notifier]:ro,[G.Script]:Q,[G.Automation]:Q,[G.Presence]:Q,[G.Update]:Q,[G.Vacuum]:Q,[G.LawnMower]:Q,[G.Weather]:Q,[G.Image]:Q,[G.PetFeeder]:Q,[G.PetFountain]:Q,[G.Dishwasher]:Q};function So(e){return xo[e]??go}function Co({deviceId:e}){let t=me(I().trpcClient,e,e=>e.runningState);if(t===void 0||t.running!==!0&&t.running!==!1)return i(d,{});let n=t.running;return i(yt,{running:n,since:t?.since??null,phase:t?.phase??null,className:`px-3 pt-2 sm:px-4`})}function wo(t){let n=So(t.deviceType);return e(d,{children:[i(Co,{deviceId:t.deviceId}),i(n,{...t})]})}function To({deviceId:e,widgets:t}){return t.length===0?null:i(`div`,{className:`flex flex-col gap-3 px-3 pb-3 sm:px-4 sm:pb-4`,"data-testid":`device-hero-widgets`,children:t.map(t=>{let n=i(qr,{widgetId:t.widgetId,deviceId:t.deviceId});return i(`div`,{children:t.deviceId===e?n:i(tr,{deviceId:t.deviceId,children:n})},t.widgetId)})})}function Eo(e){return e.sections.filter(e=>e.location===`hero`).flatMap(t=>t.fields.flatMap(n=>{if(typeof n!=`object`||!n)return[];let r=Reflect.get(n,`type`),i=Reflect.get(n,`widgetId`);return r!==`widget`||typeof i!=`string`||i.length===0?[]:[{widgetId:i,deviceId:e.deviceId,order:t.order??0}]}))}function Do(e){let t=Eo(e),n=new Set(t.map(e=>e.widgetId)),r=e.child===void 0?[]:Eo(e.child),i=[...t,...r.filter(e=>!n.has(e.widgetId))],a=new Set;return i.filter(e=>a.has(e.widgetId)?!1:(a.add(e.widgetId),!0)).sort((e,t)=>e.order-t.order)}function Oo(e){return xr(I().trpcClient,e)}c();function ko(e){let[n,i]=o(`idle`),[s,c]=o(null),l=t(null),u=t(null),d=t(null),f=t(!0),p=ri(),m=gn(),h=xt(),g=r(()=>{if(l.current){try{l.current.close()}catch{}l.current=null}if(u.current){for(let e of u.current.getTracks())try{e.stop()}catch{}u.current=null}d.current=null},[]),_=r(async()=>{if(n===`idle`)return;i(`stopping`);let t=d.current;if(t&&e!==null)try{await Promise.race([h.mutateAsync({deviceId:e,sessionId:t}),new Promise((e,t)=>setTimeout(()=>t(Error(`server stopSession timeout`)),2e3))])}catch(e){console.warn(`[intercom] server stopSession failed (continuing teardown)`,e)}g(),f.current&&(i(`idle`),c(null))},[n,e,h,g]),v=r(async()=>{if(e===null||n!==`idle`&&n!==`error`)return;c(null);let t=null,r=null,a=null;try{i(`requesting-mic`),t=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),u.current=t,i(`starting`);let n=await p.mutateAsync({deviceId:e});a=n.sessionId,d.current=a,i(`connecting`),r=new RTCPeerConnection,l.current=r,r.oniceconnectionstatechange=()=>{if(!f.current)return;let e=r.iceConnectionState;e===`connected`||e===`completed`?i(`talking`):(e===`failed`||e===`closed`||e===`disconnected`)&&f.current&&(c(e===`failed`?`WebRTC connection failed`:null),_())};for(let e of t.getAudioTracks())r.addTrack(e,t);await r.setRemoteDescription({type:`offer`,sdp:n.sdpOffer});let o=await r.createAnswer();await r.setLocalDescription(o);let s=r.localDescription?.sdp??o.sdp??``;await m.mutateAsync({deviceId:e,sessionId:a,sdpAnswer:s})}catch(n){let o=n instanceof Error?n.message:String(n);if(console.warn(`[intercom] start failed`,n),r)try{r.close()}catch{}if(t)for(let e of t.getTracks())try{e.stop()}catch{}if(l.current=null,u.current=null,a!==null)try{await h.mutateAsync({deviceId:e,sessionId:a})}catch{}d.current=null,f.current&&(c(o),i(`error`))}},[e,n,p,m,h,_]);return a(()=>(f.current=!0,()=>{f.current=!1;let t=d.current;if(t!==null&&e!==null&&h.mutate({deviceId:e,sessionId:t}),l.current){try{l.current.close()}catch{}l.current=null}if(u.current){for(let e of u.current.getTracks())try{e.stop()}catch{}u.current=null}d.current=null}),[e]),{state:n,error:s,start:v,stop:_,isTalking:n===`talking`}}c();var Ao=0;function $(){return++Ao}function jo(e){switch(e.type){case`system`:return`system`;case`device`:return`#${e.deviceId}`;case`provider`:return e.providerId;case`addon`:return e.addonId}}function Mo(e){return[``,`Commands`,` help Show this help`,` examples Show usage examples for the current scope`,` context Show every available variable + full API surface`,` clear Clear terminal (also Ctrl+L)`,``,`Shortcuts`,` Enter Execute expression`,` Arrow Up/Down Navigate command history`,` Ctrl+L Clear terminal`,``,`Try: ${{system:` sm.summary() // fleet overview`,device:` device.state.battery.value?.sleeping // sync read`,provider:` devices.map(d => d.name)`,addon:` manifest.version`}[e.type]}`,``,`Top-level objects: sm (SystemMirror), DeviceType, Math, JSON, Date, …`]}function No(e){switch(e.type){case`device`:return[``,`── State (sync, zero round-trip) ─────────────────────────`,` device.state.battery.value`,` device.state.battery.value?.level`,` device.state.motion.value?.detected`,``,`── Actions (async, through wrapper chain) ────────────────`,` await device.snapshot.getSnapshot({})`,` await device.ptz.move({ direction: 'left', steps: 1 })`,` await device.switch.setState({ on: true })`,``,`── Wait for condition ───────────────────────────────────`,` await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)`,``,`── Subscribe to changes ─────────────────────────────────`,` const off = device.state.battery.subscribe(s => console.log(s))`,``,`── Quick info ───────────────────────────────────────────`,` info.name device name`,` info.addonId owning addon`,` sm.dump(deviceId) full debug dump`];case`system`:return[``,`── Lookups ──────────────────────────────────────────────`,` sm.getDeviceById(8)`,` sm.getDeviceByName('Sala da pranzo')`,` sm.getDevicesByAddon('reolink')`,` sm.getDevicesByType(DeviceType.Camera)`,``,`── Filters (typed query) ────────────────────────────────`,` sm.query({ addonId: 'reolink', online: true })`,` sm.query({ caps: ['battery', 'snapshot'] })`,` sm.query({ name: /^Cam-/ })`,``,`── Cross-device ─────────────────────────────────────────`,` sm.whereState('battery', s => s.level < 20).length`,` sm.mapState('battery', s => s.level)`,` sm.countByCap('snapshot')`,``,`── Batch action ─────────────────────────────────────────`,` await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })`,``,`── Listen ───────────────────────────────────────────────`,` sm.listenCap('motion', (id, s) => console.log(id, s))`,` sm.onDeviceAdded((id, info) => console.log('+', info.name))`,``,`── Diagnostics ──────────────────────────────────────────`,` sm.summary()`,` sm.dump(8)`];case`provider`:return[``,` devices.map(d => d.name)`,` await getIntegration()`,` sm.getDevicesByAddon('<this-addon-id>').length`];case`addon`:return[``,` manifest.name`,` manifest.version`,` declaration`]}}function Po(e){let t=[``,`Scope: ${e.type}`,``];switch(e.type){case`system`:return[...t,`Primary API — sm (SystemMirror):`,` sm.getDeviceById(id) DeviceProxy | null (sync)`,` sm.getDeviceByName(name) DeviceProxy | null`,` sm.getDeviceByStableId(sid) DeviceProxy | null`,` sm.getAllDevices() readonly DeviceProxy[]`,` sm.getDeviceInfo(id) DeviceInfo | null`,` sm.summary() fleet stats`,``,`Filters — sm.query({...}):`,` sm.query({ addonId: 'reolink', online: true })`,` sm.query({ caps: ['battery', 'snapshot'] }) // ALL caps required`,` sm.query({ anyCap: ['ptz', 'motion'] }) // ANY cap`,` sm.query({ name: { contains: 'sala' } }) // case-insensitive`,` sm.query({ name: /^Cam-\\d+$/ })`,` sm.query({ type: DeviceType.Camera })`,` sm.query({ parentDeviceId: 8 }) // accessories of cam 8`,` sm.query({ where: (info, dev) => dev.state.battery.value?.sleeping })`,``,`State queries:`,` sm.whereState('battery', s => s.level < 20)`,` sm.mapState('battery', s => s.level)`,` sm.findState('motion', s => s.detected)`,` sm.countByCap('snapshot')`,``,`Listeners (return unsubscribe fn):`,` sm.listen((id, cap, slice) => …) // every state change`,` sm.listenCap('motion', (id, slice) => …)`,` sm.listenDevice(8, (id, cap, slice) => …)`,` sm.onDeviceAdded((id, info) => …)`,` sm.onDeviceRemoved((id, info) => …)`,``,`Wait primitives:`,` await sm.waitForState(8, 'battery', s => !s.sleeping, 30_000)`,` await sm.waitForDevice(99, 30_000)`,``,`Batch:`,` await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })`,` await sm.forEachCap('reboot', d => d.reboot.reboot({}))`,``,`Diagnostics:`,` sm.dump(8) debug dump (one device)`,` sm.dump() full fleet dump`,` sm.summary() breakdown by cap/addon/type`,``,`Legacy: deviceRegistry, addonRegistry, eventBus, devices(), addons()`];case`device`:return[...t,`Pre-bound variables:`,` device DeviceProxy for this device (sync state + async methods)`,` deviceId number`,` info DeviceInfo metadata (name, addonId, type, online, …)`,` sm SystemMirror (full cluster view)`,` rawDevice legacy IDevice instance (escape hatch)`,``,`Reactive state (sync, zero round-trip):`,` device.state.battery.value BatteryStatus | undefined`,` device.state.battery.value?.sleeping`,` device.state.battery.value?.level`,` device.state.motion.value?.detected`,` device.state.switch.value?.on`,` device.state.brightness.value?.level`,` device.state.doorbell.value?.lastPressedAt`,``,`Cap actions (async, through wrapper chain):`,` await device.snapshot.getSnapshot({})`,` await device.snapshot.getSnapshot({ streamId: 'high' })`,` await device.ptz.move({ direction: 'left', steps: 1 })`,` await device.ptz.goToPreset({ presetId: 'home' })`,` await device.switch.setState({ on: true })`,` await device.brightness.setBrightness({ level: 60 })`,` await device.reboot.reboot({})`,``,`Subscribe to slice changes:`,` const off = device.state.battery.subscribe(s => console.log(s))`,` // off() to unsubscribe`,``,`Wait for a state condition:`,` await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)`,``,`Diagnostics:`,` info.name device name`,` info.addonId which addon owns it`,` info.online transport health`,` sm.dump(deviceId) full debug dump (binding + state + info)`];case`provider`:return[...t,`Pre-bound variables:`,` devices Devices belonging to this provider (raw IDevice[])`,` getIntegration() Integration metadata`,``,`For typed device access use the SystemMirror:`,` await getSystemMirror()`,` sm.getDevicesByAddon('this-addon-id')`];case`addon`:return[...t,`Pre-bound variables:`,` manifest { name, version, ... }`,` declaration addon declaration`,` source addon source location`,``,`Examples:`,` manifest.name`,` manifest.version`]}}function Fo({scope:n,greeting:s,className:c}){let{t:l}=X(),d=I(),[f,p]=o(()=>{let e=[];return s&&e.push({id:$(),kind:`info`,text:s}),e.push({id:$(),kind:`info`,text:`scope: ${jo(n)} — type help or context for available commands`}),e}),[m,h]=o(``),[g,_]=o([]),[v,y]=o(-1),b=t(null),x=t(null);a(()=>{let e=x.current;e&&(e.scrollTop=e.scrollHeight)},[f]);let S=r(()=>{b.current?.focus()},[]),C=u({mutationFn:e=>d.trpcClient.repl.execute.mutate({code:e,scope:n}),onSuccess:e=>{let t=e??{},n=typeof t.output==`string`?t.output:e==null?`undefined`:typeof e==`string`?e:JSON.stringify(e,null,2),r=t.type===`error`;p(e=>[...e,{id:$(),kind:r?`error`:`result`,text:n}])},onError:e=>{let t=e instanceof Error?e.message:String(e);p(e=>[...e,{id:$(),kind:`error`,text:t}])}});function w(e){let t=e.trim();if(t){if(t===`clear`){p([{id:$(),kind:`info`,text:`scope: ${jo(n)}`}]),h(``);return}if(t===`help`){p(e=>[...e,{id:$(),kind:`input`,text:`> ${t}`},...Mo(n).map(e=>({id:$(),kind:`info`,text:e}))]),h(``);return}if(t===`context`){p(e=>[...e,{id:$(),kind:`input`,text:`> ${t}`},...Po(n).map(e=>({id:$(),kind:`info`,text:e}))]),h(``);return}if(t===`examples`){p(e=>[...e,{id:$(),kind:`input`,text:`> ${t}`},...No(n).map(e=>({id:$(),kind:`info`,text:e}))]),h(``);return}_(e=>[...e,t]),y(-1),p(e=>[...e,{id:$(),kind:`input`,text:`> ${t}`}]),h(``),C.mutate(t)}}function T(e){if(e.key===`Enter`){e.preventDefault(),w(m);return}if(e.key===`ArrowUp`){if(e.preventDefault(),g.length===0)return;let t=v===-1?g.length-1:Math.max(0,v-1);y(t),h(g[t]??``);return}if(e.key===`ArrowDown`){if(e.preventDefault(),v===-1)return;let t=v+1;t>=g.length?(y(-1),h(``)):(y(t),h(g[t]??``));return}e.ctrlKey&&e.key===`l`&&(e.preventDefault(),p([{id:$(),kind:`info`,text:`scope: ${jo(n)}`}]))}let E={input:`text-zinc-300`,result:`text-emerald-300`,error:`text-red-300`,info:`text-zinc-400`};return e(`div`,{className:`flex flex-col bg-[#0c0a09] rounded-lg border border-border overflow-hidden font-mono text-xs ${c??``}`,onClick:S,children:[e(`div`,{ref:x,className:`flex-1 overflow-y-auto p-3 space-y-1 min-h-[120px]`,children:[f.map(e=>i(`pre`,{className:`whitespace-pre-wrap break-words leading-relaxed ${E[e.kind]}`,children:e.text},e.id)),C.isPending&&i(`span`,{className:`text-zinc-500 animate-pulse`,children:l(`shared.replTerminal.thinking`,`…thinking`)})]}),e(`div`,{className:`flex items-center gap-2 border-t border-zinc-800 px-3 py-2 bg-[#0c0a09]`,children:[i(`span`,{className:`text-emerald-400 flex-shrink-0 select-none font-bold`,children:l(`shared.replTerminal.text`,`>`)}),i(`input`,{ref:b,value:m,onChange:e=>h(e.target.value),onKeyDown:T,disabled:C.isPending,placeholder:`device.state.battery.value`,autoFocus:!0,className:`flex-1 bg-transparent text-zinc-100 placeholder:text-zinc-600 focus:outline-none caret-emerald-400 disabled:opacity-50`,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`})]})]})}function Io(e,t){return e===null?null:{playbackUrl:e.url,...e.format===void 0?{}:{playbackFormat:e.format},playbackAuthToken:t,...e.label===void 0?{}:{playbackLabel:e.label}}}c();function Lo({deviceId:e,intercomAvailable:t=!1}){let r=I(),a=typeof window<`u`?ne():``,o=Number.isFinite(e),s=Oo(o?e:null),c=Ma(o?[e]:[]),l=n(()=>{if(!o)return;let e=[];for(let t of c.rows){let n=Hn(t);n!==null&&e.push(n)}return e},[o,c.rows]),{streams:u,pipelineMetrics:f,createSession:p,sendAnswer:m,handleOffer:h,getIceServers:_,addIceCandidate:v,getIceCandidates:y,closeSession:b,getSessionState:x,applyDownlinkProbe:S}=kt(r.trpcClient,o?e:null),C=g(o?e:null,{width:Ho}),w=ko(o&&t?e:null),T=w.state===`requesting-mic`||w.state===`starting`||w.state===`connecting`||w.state===`stopping`,E=w.isTalking||T,D=()=>{w.state===`idle`||w.state===`error`?w.start():w.state!==`stopping`&&w.stop()},O=he(),k=_t(),A=typeof window<`u`?window.localStorage.getItem(`camstack_admin_token`):null,j=Io(k.request,A),M=O.length>0?i(d,{children:O.map(e=>i(`div`,{className:`absolute inset-0`,children:e.node},e.id))}):null;return i(rr,{serverUrl:a,createSession:p,sendAnswer:m,handleOffer:h,getIceServers:_,addIceCandidate:v,getIceCandidates:y,closeSession:b,getSessionState:x,applyDownlinkProbe:S,...j===null?{}:{...j,onExitPlayback:()=>k.clear()},streams:u,pipelineMetrics:f,phase:s.phase,detections:s,...l===void 0?{}:{stationaryObjects:l},defaultShowDetections:!0,defaultShowMotion:!0,showPlayStop:!0,snapshotSrc:C.src,...C.src?{posterUrl:C.src}:{},snapshotLoading:C.loading,onRefreshSnapshot:C.refresh,intercomAvailable:t,intercomShown:E,onIntercomToggle:D,extraOverlay:M,chromeless:!0,className:`h-full`})}function Ro({deviceId:e,containerDeviceId:t}){let{t:n}=X();return Number.isFinite(e)?i(`div`,{className:`flex flex-col h-full`,children:i(qn,{...t===void 0?{deviceId:e}:{containerDeviceId:t},limit:50,maxHeight:`max-h-full`,showScope:!1,showFilters:!1})}):i(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:n(`device.panelContent.notLoaded`,{id:e})})}function zo({deviceId:e}){let{t}=X();if(!Number.isFinite(e))return i(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:t(`device.panelContent.notLoaded`,{id:e})});let n=[`CamStack REPL — device #${e}`,``,` device.state.battery.value sync state read`,` await device.snapshot.getSnapshot({}) cap action`,``,` type 'examples' for more, 'context' for the full API`].join(`
|
|
2
|
+
`);return i(Fo,{scope:{type:`device`,deviceId:e},greeting:n,className:`h-full border-0 rounded-none`})}function Bo({deviceId:e}){let{t}=X();return Number.isFinite(e)?i(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:i(Fr,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):i(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:t(`device.panelContent.notLoaded`,{id:e})})}function Vo({deviceId:e}){let{t}=X();return Number.isFinite(e)?i(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:i(Cr,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):i(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:t(`device.panelContent.notLoaded`,{id:e})})}var Ho=960;function Uo({initialName:e,label:t=`Name`,layout:n=`inline`,bound:r}){return i(Z,{label:t,layout:n,value:i(`input`,{type:`text`,value:r.value,"aria-label":t,placeholder:e,onChange:e=>r.onChange(e.target.value),className:`flex-1 min-w-0 w-full px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary`})})}c();function Wo({label:t=`Location`,layout:r=`inline`,bound:a}){let{t:o}=X(),{data:s}=bt(),c=s??[],l=a.value.trim().toLowerCase(),u=n(()=>l.length===0?[]:c.filter(e=>e.toLowerCase()!==l&&e.toLowerCase().includes(l)),[c,l]);return i(Z,{label:t,layout:r,value:e(`div`,{className:`relative`,children:[i(`input`,{type:`text`,value:a.value,"aria-label":t,onChange:e=>a.onChange(e.target.value),placeholder:o(`shared.locationRow.roomAreaOrLeaveEmpty`,`Room / area (or leave empty to clear)`),className:`flex-1 min-w-0 w-full px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary`}),u.length>0&&i(`div`,{className:`absolute z-10 left-0 right-0 mt-0.5 max-h-40 overflow-y-auto rounded-md border border-border bg-surface shadow-md`,children:u.map(t=>e(`button`,{type:`button`,onClick:()=>a.onChange(t),className:`w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover`,children:[i(ve,{className:`h-3 w-3 text-foreground-subtle flex-shrink-0`}),i(`span`,{className:`truncate`,children:t})]},t))})]})})}var Go=`w-full min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary disabled:opacity-50 disabled:cursor-not-allowed`,Ko=0,qo=10;function Jo(e){if(e.trim()===``)return``;let t=Number.parseInt(e,10);return Number.isFinite(t)?String(t<Ko?Ko:t>qo?qo:t):``}function Yo({value:e,onChange:t,disabled:n=!1,placeholder:r,className:a,id:o,"aria-label":s}){return i(`input`,{type:`number`,min:Ko,max:qo,step:1,id:o,className:a??Go,"aria-label":s,placeholder:r,value:e,onChange:e=>{t(Jo(e.target.value))},disabled:n})}function Xo({deviceName:t,value:n,inheritedIcon:r,inheritedLabel:a,disabled:o,onChange:s}){let{t:c}=X(),l={trigger:c(`deviceDisplay.pickIcon`,{name:t}),panel:c(`deviceDisplay.iconFor`,{name:t}),searchPlaceholder:c(`deviceDisplay.iconSearchPlaceholder`),clear:a,noMatches:c(`deviceDisplay.iconNoMatches`)};return e(`div`,{className:`flex items-center gap-2`,children:[i(Yt,{value:n===``?null:n,onPick:e=>s(e??``),categoryLabel:e=>c(`deviceDisplay.iconCategory.${e}`,{defaultValue:Qe(e)}),fallbackGlyph:r,labels:l,disabled:o}),i(`span`,{className:`text-[11px] text-foreground-subtle`,children:n===``?a:n})]})}var Zo=`w-full min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary disabled:opacity-50`;function Qo(e){if(e.trim()===``)return;let t=Number.parseInt(e,10);return Number.isFinite(t)?t:void 0}function $o({device:t,role:n,display:r,onChange:a}){let o=de();Fn();let{t:s}=X(),c=l(),u=n===null?void 0:zr[n],f=u?.kind===`numeric`,p=n!==null||t.parentDeviceId!==null&&t.parentDeviceId!==void 0,m=t.sourceInfo?.quantity,h=u?.kind===`numeric`?u.quantity??(m!==void 0&&m!==`device`?m:void 0):void 0,g=h===void 0?void 0:Ge(h),_=g===void 0?void 0:je(g),{data:v}=tn({},{staleTime:6e4,enabled:n!==null}),y=Tr({onSuccess:()=>{c.invalidateQueries({queryKey:[[`deviceManager`]]})}}),b=()=>{if(n===null)return;let e=Qo(r.precision),t={...r.icon===``?{}:{icon:r.icon},...r.unit===``?{}:{unit:r.unit},...e===void 0?{}:{precision:e}};y.mutate({defaults:{...v?.defaults,[n]:t}})},x=n===null?void 0:v?.defaults?.[n]?.icon,S=x===void 0?void 0:Ar(x),C=n===null?er(t.type,o):fn(n,o),w={icon:S??C.icon,label:S===void 0?C.label:String(x)},T=n===null&&t.type===G.Container?s(`deviceDisplay.inheritedContainer`):S===void 0?s(`deviceDisplay.inherited`,{name:w.label}):s(`deviceDisplay.inheritedRoleDefault`,{icon:w.label,role:C.label}),E=n===null?``:fn(n,o).label;return e(`div`,{className:`mt-3 divide-y divide-border border-t border-border`,children:[i(Z,{label:s(`deviceDisplay.icon`),value:i(Xo,{deviceName:t.name,value:r.icon,inheritedIcon:w.icon,inheritedLabel:T,disabled:!1,onChange:e=>a({icon:e})})}),p&&i(Z,{label:s(`deviceDisplay.label`),value:i(`input`,{type:`text`,className:Zo,"aria-label":s(`deviceDisplay.label`),placeholder:n===null?t.name:E,value:r.label,onChange:e=>a({label:e.target.value})})}),f&&e(d,{children:[i(Z,{label:s(`deviceDisplay.unit`),value:i(En,{dimension:_,value:r.unit,onChange:e=>a({unit:e}),disabled:!1,"aria-label":s(`deviceDisplay.unit`),inheritLabel:s(`deviceDisplay.unitSource`,{unit:g===void 0?``:` (${g})`}),emptyReason:s(`deviceDisplay.unitSource`,{unit:``})})}),i(Z,{label:s(`deviceDisplay.precision`),value:i(Yo,{"aria-label":s(`deviceDisplay.precision`),placeholder:s(`deviceDisplay.precisionInherit`),value:r.precision,onChange:e=>a({precision:e}),disabled:!1})})]}),n!==null&&i(`div`,{className:`px-3 sm:px-4 py-2`,children:i(J,{type:`button`,variant:`outline`,size:`sm`,onClick:b,disabled:y.isPending,title:s(`deviceDisplay.setRoleDefaultTitle`,{role:E}),children:s(`deviceDisplay.setRoleDefault`,{role:E})})})]})}function es(e){return typeof e.linkDeviceId==`number`}var ts=new Set(Object.values(U));function ns(e){return ts.has(e)}var rs={[G.Switch]:[U.Siren,U.Floodlight,U.Spotlight,U.PirSensor,U.Chime,U.Autotrack,U.Nightvision,U.PrivacyMask,U.BinaryHelper],[G.Light]:[U.Floodlight,U.Spotlight,U.Nightvision],[G.Siren]:[U.Siren],[G.Button]:[U.Doorbell],[G.Sensor]:[U.MotionSensor,U.ContactSensor,U.LeakSensor,U.SmokeSensor,U.COSensor,U.GasSensor,U.TamperSensor,U.VibrationSensor,U.ConnectivitySensor,U.SoundSensor,U.BinarySensor,U.TemperatureSensor,U.HumiditySensor,U.AmbientLightSensor,U.PressureSensor,U.WindSensor,U.RainSensor,U.UvSensor,U.SolarRadiationSensor,U.SoilMoistureSensor,U.PowerSensor,U.EnergySensor,U.VoltageSensor,U.CurrentSensor,U.AirQualitySensor,U.BatterySensor,U.NumericSensor,U.EnumSensor,U.DateTimeSensor,U.GenericSensor],[G.Control]:[U.NumericControl,U.SelectControl,U.TextControl,U.DateTimeControl],[G.Notifier]:[U.MobilePushNotifier,U.MessagingNotifier,U.EmailNotifier,U.GenericNotifier]};function is(e){for(let t of Object.values(G))if(t===e)return!0;return!1}function as(e){return is(e)?rs[e]??[]:[]}function os(e,t){let n=as(t);return e==null||e===``||n.includes(e)?n:[...n,e]}function ss({device:t}){let{t:n}=X(),r=de(),a=di(),o=a?.identity??null,s=o?.name??t.name,c=o?.location??t.location??``,l=o?.role??t.role??null,u=o?.display.hidden??t.display?.hidden===!0,d=a!==null&&o!==null;return e(`section`,{"aria-label":n(`customize.identity.title`),className:`${E} ${f}`,children:[e(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[d?i(Uo,{deviceId:t.id,initialName:s,label:n(`customize.identity.name`),layout:`stacked`,bound:{value:s,onChange:a.setIdentityName}}):i(Z,{label:n(`customize.identity.name`),layout:`stacked`,value:s}),d?i(Wo,{deviceId:t.id,initialLocation:c,label:n(`customize.identity.room`),layout:`stacked`,bound:{value:c,onChange:a.setIdentityLocation}}):i(Z,{label:n(`customize.identity.room`),layout:`stacked`,value:c===``?n(`common.unset`):c}),i(Z,{label:n(`customize.identity.type`),layout:`stacked`,value:t.type}),i(Z,{label:n(`customize.identity.hidden`),layout:`stacked`,value:i(Vn,{"aria-label":n(`deviceDisplay.hideFromLists`),checked:u,disabled:!d,onChange:e=>a?.setIdentityDisplay({hidden:e.target.checked})})}),i(Z,{label:n(`customize.identity.role`),layout:`stacked`,value:es(t)||!d?i(`span`,{children:cs(l,n(`customize.identity.noRole`),r)}):i(mt,{"aria-label":n(`customize.identity.role`),value:l??``,options:[{value:``,label:n(`customize.identity.noRole`)},...os(l,t.type).map(e=>({value:e,label:cs(e,n(`customize.identity.noRole`),r)}))],onChange:e=>a.setIdentityRole(e.target.value===``?null:e.target.value)})})]}),o!==null&&a!==null&&i($o,{device:t,role:l,display:o.display,onChange:a.setIdentityDisplay})]})}function cs(e,t,n){return e==null||e===``?t:ns(e)?fn(e,n).label:e}function ls(e){let t=we({draft:{kind:`pulse`,cap:e.cap,targetId:e.targetId,enabled:e.enabled,debounceMs:e.debounceMs,...e.edges===void 0?{}:{edges:[...e.edges]},sources:e.sources.map(e=>({addonId:e.addonId,stableId:e.stableId,cap:e.cap,fieldPath:e.fieldPath}))},device:e.device,changedAtFields:e.sources.map(e=>e.changedAtField)});return t.ok?t.value:null}function us(e){let t=Ie({draft:{kind:`span`,cap:e.cap,targetId:e.targetId,timeoutMs:e.timeoutMs,...e.cooldownMs===void 0?{}:{cooldownMs:e.cooldownMs},sources:e.sources.map(e=>({addonId:e.addonId,stableId:e.stableId,cap:e.cap,fieldPath:e.fieldPath,mode:e.mode}))},device:e.device});return t.ok?t.value:null}function ds(e,t){return{deviceId:e,config:t.config}}function fs(e,t){return{deviceId:e,patch:{motionCooldownMs:t}}}async function ps(e,t,n,r){await n(ds(e,t)),await r(fs(e,t.timeoutMs))}c();function ms(t){let{t:n}=X(),r=t.mode===`change`?n(`customize.scalar.changeTitle`,{title:t.title}):n(`customize.scalar.addTitle`,{title:t.title});return i(ei,{open:t.open,onOpenChange:e=>!e&&t.onClose(),children:e($r,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,"aria-label":r,children:[i(Xr,{children:i(xn,{children:r})}),t.open?i(hs,{...t}):null]})})}function hs(t){let{t:r}=X(),a=Mt({projection:`slim`}),s=Mi(n(()=>a.status===`success`?ia(a.data):[],[a.status,a.data]),t.sources[0]),[c,l]=o(()=>gs(t.sources)),[u,f]=o(null),[p,m]=o(!1);!p&&s!==null&&(f(s),m(!0));let[h,g]=o(t.edge),[_,v]=o(t.debounceMs/1e3),y=_s(c),b=y.length===0?null:ls({cap:t.cap,targetId:t.targetId,device:t.target,enabled:t.enabled,debounceMs:Math.round(_*1e3),edges:[h],sources:y}),x=y[0]??null,S=ar({deviceId:c[0]?.deviceId??0}),C=ys(S.status===`success`?S.data:void 0,x),w=Be(ze,C,Math.round(_*1e3));return e(d,{children:[e(Gn,{className:`flex flex-col gap-3 p-2 sm:p-4`,children:[i(`p`,{className:`text-[11px] text-foreground-muted`,children:r(`customize.event.pulseBody`)}),i(qi,{kind:`event`,shape:`pulse`,enabled:t.open,hostId:t.host.id,devicePickerTestId:`event-pulse-picker`,destination:{cap:t.cap,targetId:t.targetId,title:t.title},device:u,picked:c,onDeviceChange:f,onPickedChange:l,edges:t.edges,edge:h,onEdgeChange:g,debounceSec:_,onDebounceSecChange:v,sourceModes:[],timeoutSec:0,onTimeoutSecChange:()=>void 0,cooldownSec:null,onCooldownSecChange:()=>void 0}),C.kind===`level`?i(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:r(vs(C,w.lastPressedAt))}):null]}),e(Tt,{className:`flex flex-wrap gap-2`,children:[i(J,{variant:`ghost`,onClick:t.onClose,children:r(`customize.scalar.cancel`)}),i(J,{"data-testid":`event-save`,disabled:!t.canSave||b===null,onClick:()=>{b!==null&&t.onSave(b)},children:r(`customize.scalar.save`)})]})]})}function gs(e){return e.map(e=>({deviceId:0,addonId:e.addonId,stableId:e.stableId,cap:e.cap,fieldPath:e.fieldPath,deviceName:e.stableId,changedAtField:e.changedAtField}))}function _s(e){return e.map(e=>({addonId:e.addonId,stableId:e.stableId,cap:e.cap,fieldPath:e.fieldPath,changedAtField:e.changedAtField??De[e.cap]??`lastChangedAt`}))}function vs(e,t){return e.kind===`unread`?`customize.event.previewWaiting`:e.active&&t===null?`customize.event.previewAlreadyOn`:t===null?`customize.event.previewQuiet`:`customize.event.previewCounted`}function ys(e,t){if(e===void 0||t===null)return{kind:`unread`};let n=e[t.cap],r=n===void 0?void 0:da(n,t.fieldPath),i=De[t.cap]??t.changedAtField,a=n===void 0?void 0:da(n,i);return typeof r==`boolean`?{kind:`level`,active:r,changedAt:typeof a==`number`&&Number.isFinite(a)?a:null}:{kind:`unread`}}function bs(e,t,n){if(e===`pending`)return{kind:`pending`,seconds:null};if(e===`unknown`||e==null)return{kind:`unknown`,seconds:null};if(!e)return{kind:`quiet`,seconds:null};let r=xs(t,n);return r===null?{kind:`unknown`,seconds:null}:{kind:`active`,seconds:r}}function xs(e,t){if(e==null||!Number.isFinite(e)||e<Oi)return null;let n=Math.floor((t-e)/1e3);return n<0?0:n}function Ss(e,t){if(e===`pending`)return{kind:`pending`,lastPressedAt:null,pressCount:null};if(e===`unknown`)return{kind:`unknown`,lastPressedAt:null,pressCount:null};let n=typeof e==`number`&&Number.isFinite(e)&&e>=Oi?e:null,r=typeof t==`number`&&Number.isFinite(t)&&t>=0?t:null;return n===null?{kind:`none`,lastPressedAt:null,pressCount:r}:{kind:`ring`,lastPressedAt:n,pressCount:r}}c();var Cs={id:0,name:``,type:`unknown`,stableId:``,parentDeviceId:null};function ws({device:t,handle:n,availability:r,cap:a,title:s,view:c}){let{t:l,i18n:u}=X(),f=Pi(),[p,m]=o(!1),[h,g]=o(null),v=_a(n.state),y=Qi(v,a),b=Es(n,y),x=b.kind===`known`&&b.value!==null?$e({feature:b.value,device:n.target,cap:a,targetId:c.id,timestampPath:c.timestampPath,counterPath:c.counterPath}):null,S=x!==null,C=ta(S),w=x?.draft.sources[0]??null,T=w===null||C.kind!==`known`?null:C.value.find(e=>Xe({addonId:e.addonId,stableId:e.stableId})===Xe(w))??null,E=Ds(S,C.kind,T!==null),D=wn(T===null?Cs:ca(T),`compact`),O=wn(t,`full`),k=Ye({cap:a,targetId:c.id,device:n.target,timestampPath:c.timestampPath,counterPath:c.counterPath,apply:c.apply,stored:b,sourcePresence:E,sourceUnknownReason:C.kind===`unknown`?C.reason:null}),A=n.state.kind===`none`||n.state.kind===`present`;if(r.kind===`absent`||!c.deviceTypes.includes(t.type))return null;let j=async e=>{let t=await n.save(e);g(t.kind===`refused`?t.reason:null)},M=Os(x),ee=x?.draft.edges?.[0],N=ee!==void 0&&c.edges.includes(ee)?ee:c.defaultEdge,te=w===null?``:va(w.cap,w.fieldPath,u.language),ne=b.kind===`known`&&b.value===null,re=!S&&b.kind===`known`&&b.value!==null;return e(d,{children:[i(na,{id:a,icon:_,title:s,testId:`event-card-${a}`,actions:e(d,{children:[y!==null&&e(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground`,children:[i(Vn,{"aria-label":l(`customize.doorbell.active`),checked:y.enabled!==!1,disabled:!A||n.saving,onChange:e=>{j(Zi(v,n.target,{...y,enabled:e.target.checked}))}}),l(`customize.doorbell.active`)]}),i(q,{children:l(zi(k.text,k.status.state))})]}),children:i(`div`,{className:`flex flex-col gap-2 px-3 py-2 sm:px-4`,children:r.kind===`pending`||r.kind===`present`&&!A?i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:l(`customize.event.checking`)}):r.kind===`unknown`?i(K,{title:l(`customize.scalar.unreadable`),message:r.reason}):e(d,{children:[S&&w!==null&&i(`p`,{className:`text-xs text-foreground`,children:l(`customize.scalar.override`,{name:T===null?w.stableId:D,field:te})}),S&&i(Ts,{deviceId:t.id,cap:a,timestampPath:c.timestampPath,counterPath:c.counterPath,startedAt:n.state.kind===`present`?n.state.view.block.createdAt:null}),re&&y!==null&&e(`p`,{className:`text-xs text-foreground flex flex-wrap items-center gap-1`,children:[l(`customize.doorbell.otherFormula`),i(Ui,{handle:n,cap:a,fieldPath:c.counterPath})]}),ne&&i(`p`,{className:`text-xs text-foreground-subtle`,children:l(`customize.scalar.noOverride`)}),h!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger break-words`,children:h}),e(`div`,{className:`flex flex-wrap gap-2`,children:[S&&i(J,{variant:`outline`,size:`sm`,disabled:n.saving,onClick:()=>m(!0),children:l(`customize.scalar.change`)}),S&&i(J,{variant:`ghost`,size:`sm`,disabled:n.saving,onClick:()=>{if(v===null)return;let e=$i(v,a);f(l(`customize.doorbell.removeWhat`,{name:T===null?O:D}),e===null).then(t=>{t&&j(e)})},children:l(`customize.scalar.remove`)}),ne&&i(J,{variant:`outline`,size:`sm`,"data-testid":`event-add-${a}`,disabled:n.saving,onClick:()=>m(!0),children:l(`customize.scalar.add`)})]})]})})}),i(ms,{open:p,mode:S?`change`:`add`,title:s,cap:a,targetId:c.id,host:t,target:n.target,enabled:y?.enabled!==!1,debounceMs:x?.draft.debounceMs??c.debounceMs,edges:c.edges,edge:N,sources:M,canSave:A&&!n.saving,onClose:()=>m(!1),onSave:e=>{m(!1),j(Zi(v,n.target,e))}})]})}function Ts({deviceId:t,cap:n,timestampPath:r,counterPath:a,startedAt:o}){let{t:s}=X(),c=wa({deviceId:t,cap:n,path:r}),l=wa({deviceId:t,cap:n,path:a}),u=Ss(c.kind===`pending`?`pending`:c.kind!==`value`||typeof c.value!=`number`?`unknown`:c.value,l.kind===`value`&&typeof l.value==`number`?l.value:null);return u.kind===`pending`?i(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:s(`customize.event.checking`)}):u.kind===`unknown`?i(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:s(`customize.event.doorbellLast.unknown`)}):u.kind===`none`?e(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:[s(`customize.event.doorbellLast.none`,{when:o===null?``:Di(o)}),u.pressCount===null?``:` · ${s(`customize.event.doorbellCount`,{count:u.pressCount})}`]}):e(`p`,{role:`status`,className:`text-[11px] text-foreground`,children:[s(`customize.event.doorbellLast.ring`,{when:Di(u.lastPressedAt)}),u.pressCount===null?``:` · ${s(`customize.event.doorbellCount`,{count:u.pressCount})}`]})}function Es(e,t){return e.state.kind===`pending`?{kind:`pending`}:e.state.kind===`unknown`||e.state.kind===`not-loaded`?{kind:`unknown`,reason:e.state.reason}:{kind:`known`,value:t}}function Ds(e,t,n){return e?t===`pending`?`pending`:t===`unknown`?`unknown`:n?`present`:`absent`:`present`}function Os(e){return e===null?[]:e.draft.sources.map((t,n)=>({addonId:t.addonId,stableId:t.stableId,cap:t.cap,fieldPath:t.fieldPath,changedAtField:e.changedAtFields[n]??``}))}c();function ks(t){let{t:n}=X(),r=t.mode===`change`?n(`customize.scalar.changeTitle`,{title:t.title}):n(`customize.scalar.addTitle`,{title:t.title});return i(ei,{open:t.open,onOpenChange:e=>!e&&t.onClose(),children:e($r,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,"aria-label":r,children:[i(Xr,{children:i(xn,{children:r})}),t.open?i(As,{...t}):null]})})}function As(t){let{t:r}=X(),a=Mt({projection:`slim`}),s=Mi(n(()=>a.status===`success`?ia(a.data):[],[a.status,a.data]),t.sources[0]),[c,l]=o(()=>js(t.sources)),[u,f]=o(null),[p,m]=o(!1);!p&&s!==null&&(f(s),m(!0));let[h,g]=o(t.timeoutMs/1e3),[_,v]=o((t.cooldownMs??0)/1e3),y=Ms(c),b=us({cap:t.cap,targetId:t.targetId,device:t.target,timeoutMs:Math.round(h*1e3),cooldownMs:t.cooldownMs===null?void 0:Math.round(_*1e3),sources:y}),x=c[0];return e(d,{children:[e(Gn,{className:`flex flex-col gap-3 p-2 sm:p-4`,children:[i(`p`,{className:`text-[11px] text-foreground-muted`,children:r(`customize.event.spanBody`)}),i(qi,{kind:`event`,shape:`span`,enabled:t.open,hostId:t.host.id,devicePickerTestId:`event-span-picker`,destination:{cap:t.cap,targetId:t.targetId,title:t.title},device:u,picked:c,onDeviceChange:f,onPickedChange:e=>l(e.filter(e=>!(e.addonId===t.host.addonId&&e.stableId===t.host.stableId))),edges:[],edge:`rising`,onEdgeChange:()=>void 0,debounceSec:0,onDebounceSecChange:()=>void 0,sourceModes:t.sourceModes,timeoutSec:h,onTimeoutSecChange:g,cooldownSec:t.cooldownMs===null?null:_,onCooldownSecChange:v}),x!==void 0&&i(Ns,{deviceId:x.deviceId,cap:x.cap,fieldPath:x.fieldPath,timeoutMs:Math.round(h*1e3)})]}),e(Tt,{className:`flex flex-wrap gap-2`,children:[i(J,{variant:`ghost`,onClick:t.onClose,children:r(`customize.scalar.cancel`)}),i(J,{"data-testid":`event-save`,disabled:!t.canSave||b===null,onClick:()=>{b!==null&&t.onSave(b)},children:r(`customize.scalar.save`)})]})]})}function js(e){return e.map(e=>({deviceId:0,addonId:e.addonId,stableId:e.stableId,cap:e.cap,fieldPath:e.fieldPath,deviceName:e.label.length>0?e.label:e.stableId,mode:e.mode}))}function Ms(e){return e.map(e=>({addonId:e.addonId,stableId:e.stableId,cap:e.cap,fieldPath:e.fieldPath,mode:e.mode??`in-addition`,label:e.deviceName}))}function Ns({deviceId:e,cap:t,fieldPath:n,timeoutMs:r}){let{t:a}=X(),o=wa({deviceId:e,cap:t,path:n}),s=o.kind===`value`&&typeof o.value==`boolean`?{kind:`level`,active:o.value,changedAt:null}:{kind:`unread`},c=Fe(Le,s,{timeoutMs:r,cooldownMs:0,nowMs:Date.now()});return s.kind===`unread`?null:i(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:a(Ps(s,c.open))})}function Ps(e,t){return e.kind===`unread`?`customize.event.previewWaiting`:t?`customize.event.previewMotionOn`:e.active?`customize.event.previewSensorOn`:`customize.event.previewMotionOff`}c();function Fs({device:n,availability:r,cap:a,title:s,view:c,sensors:l}){let{t:u}=X(),f=pr(),p=Bn(),m=nn({addonId:`pipeline-orchestrator`,deviceId:n.id,nodeId:`hub`}),[h,g]=o(!1),[_,v]=o(null),y=t(!1),[b,x]=o(!1),S=Ls(l),C=ta(!0),w=Ae(c.id,S),T=Vs(Ea(m.data).motionCooldownMs,c.timeoutMs);if(r.kind===`absent`||!c.deviceTypes.includes(n.type))return null;let E=b||f.isPending||p.isPending,D=w.writable&&!E&&r.kind===`present`,O=async e=>{if(!w.writable||y.current){v(u(`customize.saveInFlight`));return}y.current=!0,x(!0);try{await ps(n.id,e,async e=>{await f.mutateAsync({deviceId:e.deviceId,config:e.config===null?null:{sensors:e.config.sensors.map(e=>({addonId:e.addonId,stableId:e.stableId,mode:e.mode}))}})},async e=>{let t={motionCooldownMs:e.patch.motionCooldownMs};await p.mutateAsync({deviceId:e.deviceId,patch:t})}),v(null),await l.refetch()===`failed`&&v(u(`customize.motion.refetchFailed`))}catch(e){v(e instanceof Error?e.message:String(e))}finally{y.current=!1,x(!1)}},k=w.rows.map(e=>({addonId:e.addonId,stableId:e.stableId,cap:`binary`,fieldPath:`on`,mode:e.mode,label:e.name}));return e(d,{children:[i(na,{id:a,icon:ae,title:s,testId:`event-card-${a}`,actions:i(q,{children:u(zi(w.text,w.status.state))}),children:i(`div`,{className:`flex flex-col gap-2 px-3 py-2 sm:px-4`,children:r.kind===`pending`||S.kind===`pending`?i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:u(`customize.motion.reading`)}):r.kind===`unknown`||S.kind===`unknown`?i(Rs,{reason:Bs(S)||(r.kind===`unknown`?r.reason:``)}):e(d,{children:[i(Is,{deviceId:n.id}),w.rows.length===0?i(`p`,{className:`text-xs text-foreground-subtle`,children:u(`customize.scalar.noOverride`)}):i(`ul`,{className:`flex flex-col gap-1`,children:w.rows.map(t=>e(`li`,{className:`text-xs text-foreground`,children:[i(zs,{row:t,fleet:C}),t.reason===null?``:` — ${u(`customize.motion.state.${t.state}`)}`]},t.key))}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:u(`customize.event.timeoutSeconds`,{seconds:T/1e3})}),_!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger break-words`,children:_}),i(`div`,{className:`flex flex-wrap gap-2`,children:i(J,{variant:`outline`,size:`sm`,"data-testid":`event-add-${a}`,disabled:!D,onClick:()=>g(!0),children:w.rows.length===0?u(`customize.scalar.add`):u(`customize.scalar.change`)})})]})})}),i(ks,{open:h,mode:w.rows.length===0?`add`:`change`,title:s,cap:a,targetId:c.id,host:n,target:{addonId:n.addonId,stableId:n.stableId},timeoutMs:T,cooldownMs:c.cooldownMs,sourceModes:c.sourceModes,sources:k,canSave:D,onClose:()=>g(!1),onSave:e=>{g(!1),O(e)}})]})}function Is({deviceId:e}){let{t}=X(),n=wa({deviceId:e,cap:`motion`,path:`detected`}),r=wa({deviceId:e,cap:`motion`,path:`lastDetectedAt`}),a=bs(n.kind===`pending`?`pending`:n.kind!==`value`||typeof n.value!=`boolean`?`unknown`:n.value,r.kind===`value`&&typeof r.value==`number`?r.value:null,Date.now());return i(`p`,{role:`status`,className:`text-xs text-foreground`,children:t(a.kind===`active`?`customize.event.motionNow.active`:`customize.event.motionNow.${a.kind}`,a.seconds===null?void 0:{seconds:a.seconds})})}function Ls(e){return e.presence===`pending`?{kind:`pending`}:e.status===null?{kind:`unknown`,reason:e.failureReason}:{kind:`known`,value:e.status}}function Rs({reason:e}){let{t}=X(),n=e.trim();return n.length===0?i(K,{message:t(`customize.motion.unreadableBare`)}):i(K,{title:t(`customize.motion.unreadable`,{reason:n}),message:n})}function zs({row:e,fleet:t}){let n=Pt();if(t.kind!==`known`)return e.name;let r=t.value.find(t=>t.addonId===e.addonId&&t.stableId===e.stableId);return r===void 0?e.name:ba(ca(r),t.value.map(ca),n)}function Bs(e){return e.kind===`unknown`?e.reason??``:e.kind===`known`&&e.value.state===`unreadable`?e.value.reason:``}function Vs(e,t){return e!==null&&Number.isFinite(e)?e:t}var Hs=ke;function Us(e,t){let n=Hs[e];return n===void 0?null:n.targets.find(e=>e.id===t)??null}function Ws({device:e,handle:t,facts:n,sensors:r}){let{t:a}=X();return i(d,{children:Hi().map(o=>{let s=o.pulse??o.span;if(s===null||!s.deviceTypes.includes(e.type))return null;let c=Us(o.cap,s.id);if(c===null)return null;let l=a(o.pulse===null?`customize.motion.title`:`customize.doorbell.title`),u=Wi(Li(o.cap,c),n);return o.pulse===null?o.span===null?null:i(Fs,{device:e,availability:u,cap:o.cap,title:l,view:o.span,sensors:r},o.cap):i(ws,{device:e,handle:t,availability:u,cap:o.cap,title:l,view:o.pulse},o.cap)})})}function Gs({id:t,icon:n,title:r,headerControl:a,addLabel:o,onAdd:s,addDisabled:c=!1,notices:l,suggestion:u,children:f}){let{t:p}=X(),m=s!==void 0&&o!==void 0;return e(na,{id:t,icon:n,title:r,actions:e(d,{children:[a,m&&!c&&u!==void 0&&u.count>0&&e(J,{variant:`ghost`,size:`sm`,onClick:u.onOpen,children:[i(_e,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),p(`customize.suggest.hint`,{count:u.count,location:u.location})]}),m&&i(J,{variant:`outline`,size:`sm`,disabled:c,onClick:s,children:o})]}),children:[l!==void 0&&i(`div`,{className:`flex flex-col gap-1 px-3 pt-2 empty:hidden sm:px-4`,children:l}),i(`ul`,{className:`flex flex-col divide-y divide-border`,children:f})]})}c();var Ks=`flex items-center gap-2 px-3 py-2 text-sm sm:px-4`,qs=`list-none px-3 py-2 text-xs text-foreground-subtle sm:px-4`;function Js({entry:e}){let{t}=X();return e.readOnly?i(q,{variant:`info`,children:e.addonId}):i(q,{variant:`primary`,children:t(`actions.source.internal`,`Internal`)})}function Ys({device:t}){let{t:n}=X(),r=l(),a=Ct({}),s=Qr({deviceId:t.id}),[c,u]=o(!1),[f,p]=o([]),m=()=>void r.invalidateQueries({queryKey:[[`actions`]]}),h=bn({onSuccess:m}),g=Yr({onSuccess:m}),_=a.data??[],v=s.data?.actionIds??[],y=v.flatMap(e=>_.filter(t=>t.id===e)),b=_.filter(e=>!v.includes(e.id)),S=s.data!==void 0&&a.data!==void 0,C=e=>h.mutate({deviceId:t.id,actionIds:[...e]}),w=()=>{p([]),u(!0)},T=e=>p(f.includes(e)?f.filter(t=>t!==e):[...f,e]);return e(d,{children:[e(Gs,{id:`linked-actions`,icon:fe,title:n(`customize.linkedActions.title`,`Linked actions`),addLabel:n(`customize.linkedActions.add`,`Add`),onAdd:S&&b.length>0?w:void 0,addDisabled:h.isPending,children:[!S&&i(`li`,{className:qs,children:n(`customize.linkedActions.loading`,`Checking linked actions.`)}),S&&y.length===0&&i(`li`,{className:qs,children:n(`customize.linkedActions.none`,`None linked.`)}),y.map(r=>e(`li`,{className:Ks,children:[i(`span`,{className:`min-w-0 flex-1 truncate`,children:r.name}),i(Js,{entry:r}),i(zt,{icon:x,variant:`ghost`,size:`sm`,"aria-label":n(`customize.linkedActions.run`,`Run {{name}}`,{name:r.name}),disabled:g.isPending,onClick:()=>g.mutate({actionId:r.id,deviceId:t.id})}),i(zt,{icon:L,variant:`ghost`,size:`sm`,"aria-label":n(`customize.linkedActions.unlink`,`Unlink {{name}}`,{name:r.name}),disabled:h.isPending,onClick:()=>C(v.filter(e=>e!==r.id))})]},r.id)),h.error!==null&&i(`li`,{role:`alert`,className:`list-none px-3 py-2 text-xs text-danger sm:px-4`,children:h.error.message}),i(`li`,{className:qs,children:n(`customize.linkedActions.hint`,`Linked actions show as buttons on this camera. Nothing is linked unless you pick it.`)})]}),i(ei,{open:c,onOpenChange:u,children:e($r,{placement:`sheet-on-mobile`,children:[e(Xr,{children:[i(xn,{children:n(`customize.linkedActions.pickTitle`,`Link actions to {{name}}`,{name:t.name})}),i(yn,{children:n(`customize.linkedActions.pickHint`,`Pick the actions to link. Nothing is chosen for you.`)})]}),i(Gn,{children:i(`ul`,{className:`space-y-1`,children:b.map(t=>i(`li`,{children:e(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-surface-hover`,children:[i(Vn,{checked:f.includes(t.id),onChange:()=>T(t.id)}),i(`span`,{className:`flex-1`,children:t.name}),i(Js,{entry:t})]})},t.id))})}),e(Tt,{className:`flex flex-wrap gap-2`,children:[i(J,{variant:`outline`,onClick:()=>u(!1),children:n(`common.cancel`,`Cancel`)}),i(J,{disabled:f.length===0||h.isPending,onClick:()=>{C([...v,...f]),u(!1)},children:n(`customize.linkedActions.addN`,`Add {{count}}`,{count:f.length})})]})]})})]})}c();function Xs(e,t){let r=typeof e==`string`&&e.length>0,i=ta(t&&r);return n(()=>t?Ca(i,e):null,[t,i,e])}c();function Zs(e){return e==null?null:e.message}function Qs({device:t}){let n=de(),{t:r}=X(),a=l(),s=Pi(),c=Ue.includes(t.type),[u,f]=o(!1),[p,m]=o(!1),[h,g]=o(null),_=Ir({deviceId:t.id},{enabled:c}),v=La({status:_.status,data:_.data,error:Zs(_.error)===null?null:{message:Zs(_.error)??``}}),y=v.kind===`present`?v.slot.slotRef:``,b=v.kind===`present`?[...Fa(v.slot,v.value).map(e=>e.deviceId),...Pa(v.slot,v.value)]:[],x=Jn(),S=ta(c&&v.kind===`present`&&(u||b.length>0)),C=Xs(t.location,c&&v.kind===`present`),w=wr({deviceId:t.id,slotRef:y},{enabled:(u||C!==null)&&v.kind===`present`});if(!c||v.kind===`absent`)return null;if(v.kind!==`present`)return i(Gs,{id:`linked`,icon:R,title:r(`customize.linked.title`),notices:v.kind===`pending`?i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:r(`customize.assign.checking`)}):i(`p`,{role:`alert`,className:`text-xs text-warning break-words`,children:r(`customize.assign.unknown`,{reason:v.reason})}),children:null});let T=v.value,E=new Map(S.kind===`known`?S.value.map(e=>[e.id,e]):[]),D=T.trackedDeviceIds!==void 0,O=(e,t)=>{let n=E.get(e.deviceId);return{...e,name:e.name??n?.name??null,type:n?.type??null,detail:n===void 0?null:Ta(n.integration,n.location),orphan:t}},k=[...Fa(v.slot,T).map(e=>O(e,!1)),...Pa(v.slot,T).map(e=>O({deviceId:e,name:null,health:`ok`,implied:!1,tracked:!0},!0))],A=new Set(b),j=S.kind===`unknown`?S:w.status===`error`?{kind:`unknown`,reason:Zs(w.error)??r(`helpers.customize.requestFailed`)}:S.kind===`pending`||w.status===`pending`||w.data===void 0?{kind:`pending`}:{kind:`known`,value:za(w.data.candidates,E,A)},M=async e=>{if(p){g(r(`customize.saveInFlight`));return}m(!0),g(null);try{await x.mutateAsync({deviceId:t.id,slotRef:v.slot.slotRef,value:e}),await _.refetch(),await a.invalidateQueries({queryKey:[[`deviceManager`]]})}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(!1)}},ee=async e=>{await s(r(`customize.linked.removeWhat`,{name:e.name??`#${e.deviceId}`}),!1)&&await M(Ra(T,e.deviceId))},N=[{key:`device`,header:r(`customize.linked.device`),cell:t=>e(`div`,{className:`flex flex-col min-w-0`,children:[i(`span`,{className:`truncate text-xs text-foreground`,children:t.name??`#${t.deviceId}`}),t.detail!==null&&i(`span`,{className:`truncate text-[11px] text-foreground-subtle`,children:t.detail}),t.orphan&&i(`span`,{className:`text-[11px] text-foreground-subtle`,children:r(`customize.linked.notLinked`)}),t.health!==`ok`&&i(`span`,{role:`alert`,className:`text-[11px] text-warning`,children:r(`customize.linked.health.${t.health}`)})]})},{key:`type`,header:r(`customize.linked.type`),headerClassName:`hidden sm:table-cell`,cellClassName:`hidden sm:table-cell text-xs text-foreground-subtle`,cell:e=>e.type===null?`—`:er(e.type,n).label},{key:`controls`,header:r(`customize.linked.controls`),headerClassName:`hidden md:table-cell`,cellClassName:`hidden md:table-cell text-xs text-foreground-subtle`,cell:e=>e.orphan?`—`:r(`customize.linked.yes`)},...D?[{key:`tracked`,header:r(`customize.linked.tracked`),cellClassName:`text-right`,headerClassName:`text-right`,cell:e=>i(Nn,{checked:e.tracked,disabled:p,"aria-label":r(`customize.linked.trackFor`,{name:e.name??e.deviceId}),onCheckedChange:t=>void M(Ia(T,e.deviceId,t))})}]:[],{key:`remove`,header:``,cellClassName:`text-right w-10`,cell:e=>e.implied||e.orphan?null:i(zt,{icon:L,variant:`ghost`,size:`sm`,"aria-label":r(`customize.assign.removeNamed`,{name:e.name??e.deviceId}),disabled:p,onClick:t=>{t.stopPropagation(),ee(e)}})}];return e(d,{children:[i(Gs,{id:`linked`,icon:R,title:r(`customize.linked.title`),addLabel:r(`customize.linked.add`),onAdd:p?void 0:()=>f(!0),...C===null?{}:{suggestion:{count:Yi(j,C,e=>e.deviceId),location:C.location,onOpen:()=>f(!0)}},notices:e(d,{children:[S.kind===`unknown`&&i(`p`,{role:`alert`,className:`text-xs text-warning break-words`,children:r(`customize.assign.devicesUnreadable`,{reason:S.reason})}),h!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger break-words`,children:h})]}),children:e(`li`,{className:`list-none px-3 py-2 sm:px-4`,children:[k.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`customize.assign.none`)}):i(dn,{mode:`generic`,items:k,getKey:e=>String(e.deviceId),getSearchText:e=>[e.name??``,e.detail??``,e.type??``,String(e.deviceId)].join(` `),getFilterType:e=>e.type===null?null:er(e.type,n).label,columns:N,searchPlaceholder:r(`customize.assign.search`),emptyLabel:r(`customize.assign.none`)}),k.some(e=>!e.orphan)&&i(`p`,{className:`mt-2 text-[10px] text-foreground-subtle`,children:r(`customize.linked.controlsAlways`)}),D&&i(`p`,{className:`mt-0.5 text-[10px] text-foreground-subtle`,children:r(`customize.linked.trackedHint`)})]})}),i(aa,{open:u,title:r(`customize.linked.pickTitle`),selection:`multi`,candidates:j,room:C,confirmLabel:e=>r(`customize.assign.addCount`,{count:e}),onConfirm:e=>{f(!1),M(Na(T,e.map(e=>e.deviceId)))},onClose:()=>f(!1)})]})}c();function $s(e){return e instanceof Error?e.message:String(e)}function ec(e){let n=Ht({addonId:e.addonId,stableId:e.stableId}),r=Sn(),i=Br(),a=An(),s=Bi({status:n.status,data:n.data,error:n.error===null||n.error===void 0?null:{message:n.error.message}}),{t:c}=X(),l=t(!1),[u,d]=o(!1),f=async e=>{let t=Ri(s,e);try{switch(t.kind){case`refused`:return{kind:`refused`,reason:t.reason};case`noop`:return{kind:`saved`};case`create`:await r.mutateAsync({block:t.input});break;case`update`:await i.mutateAsync({blockId:t.blockId,expectedUpdatedAt:t.expectedUpdatedAt,block:{composition:t.composition}});break;case`delete`:await a.mutateAsync({blockId:t.blockId});break}return await n.refetch(),{kind:`saved`}}catch(e){return{kind:`refused`,reason:$s(e)}}};return{target:e,state:s,saving:u||r.isPending||i.isPending||a.isPending,save:async e=>{if(l.current)return{kind:`refused`,reason:c(`customize.saveInFlight`)};l.current=!0,d(!0);try{return await f(e)}finally{l.current=!1,d(!1)}}}}var tc=`pipeline-orchestrator`;function nc(e){return e.data===void 0?e.status===`pending`?`pending`:e.status===`error`?`unknown`:`pending`:e.data.cameraSensors===void 0?`absent`:`present`}function rc(e,t){return e===`absent`?`absent`:nc(t)}async function ic(e){try{return(await e()).isError?`failed`:`answered`}catch{return`failed`}}function ac(e,t){let n=Nt(tc),r=Pr({deviceId:e},{enabled:t&&n!==`absent`}),i=()=>ic(r.refetch),a=r.data===void 0&&r.status===`error`?r.error?.message??null:null;return t?{presence:rc(n,{status:r.status,data:r.data}),status:r.data?.cameraSensors??null,failureReason:a,refetch:i}:{presence:`absent`,status:null,failureReason:null,refetch:i}}function oc(e,t){let n=Mn({deviceType:e.type}),r=on({deviceId:e.id}),i=ln({deviceId:e.id}),a=ea(n,e=>new Set(e.caps.map(e=>e.cap))),o=ea(r,e=>Ki(e.entries)),s=ea(i,e=>e);return{deviceType:e.type,composable:a,nativeCaps:o,wireable:s,composed:new Set((t?.features??[]).map(e=>e.cap))}}function sc(e,t,n){let r=t.kind===`known`&&t.value.has(`consumables`),i=wa(r?{deviceId:e,cap:pa,path:Ni}:null);return fa(t,n,r?i:null)}var cc=`ir-transmitter`;function lc(e,t){let n=new Map(t.customButtons.map(e=>[Pe(e.key),e.name])),r=new Map;for(let t of e?.buttons??[])t.label!==void 0&&!r.has(t.role)&&r.set(t.role,t.label);let i=new Set,a=[],o=(e,t)=>{if(i.has(e))return;i.add(e);let o=Ee(e)!==null;a.push({role:e,custom:o,inLayout:t,name:o?n.get(e)??r.get(e)??Ba(e):null})};for(let t of e?.buttons??[])o(t.role,!0);for(let e of n.keys())o(e,!1);for(let e of Object.keys(t.bindings))o(e,!1);return a}function uc(e,t,n){let r=Ee(t);if(r===null||e.customButtons.some(e=>e.key===r))return e;let i={key:r,name:n};return{...e,customButtons:[...e.customButtons,i]}}function dc(e,t,n,r=Ba(t)){return uc({...e,bindings:{...e.bindings,[t]:{action:n}}},t,r)}function fc(e,t){let n=Object.fromEntries(Object.entries(e.bindings).filter(([e])=>e!==t)),r=Ee(t);return{...e,bindings:n,customButtons:r===null?e.customButtons:e.customButtons.filter(e=>e.key!==r)}}function pc(e){return e.deviceId>0&&e.cap!==``&&e.method!==``}var mc={kind:`cap`,deviceId:0,cap:``,method:``};function hc(e){let{action:t}=e;return t.cap===`ir-transmitter`&&t.method===`send`?t.deviceId:null}function gc(e,t){return{action:{...e.action,deviceId:t}}}function _c(e){let t=Object.entries(e.bindings).filter(([,e])=>!pc(e.action)).map(([e])=>e);if(t.length>0)return{incomplete:t,config:null};let n=Te.safeParse(e);return{incomplete:t,config:n.success?n.data:null}}function vc(e,t){if(t===null||t<=0)return{status:`refused`,reason:`no-transmitter`};let n;try{n=JSON.parse(e)}catch{return{status:`refused`,reason:`not-json`}}try{let e=Ke(n),r=Ze(e.table,{transmitterDeviceId:t}),i=[...e.skipped.map(e=>({name:e.name,reason:e.reason})),...r.skipped];return{status:`ok`,draft:r,bound:Object.keys(r.bindings).length,skipped:i}}catch(e){if(e instanceof qe)return{status:`refused`,reason:`not-smartir`};throw e}}function yc(e,t){let n=new Set(e.customButtons.map(e=>e.key));return{...e,bindings:{...e.bindings,...t.bindings},customButtons:[...e.customButtons,...t.customButtons.filter(e=>!n.has(e.key))],power:{mode:t.power.mode}}}c();function bc({role:t,binding:n,devices:r,transmitters:a,testable:s,testResult:c,onBind:l,onClear:u,onTest:f}){let{t:p}=X(),[m,h]=o(!1),g=t.name??p(`remote.role.${t.role}`,Ba(t.role)),_=n===void 0?null:hc(n),v=n!==void 0&&pc(n.action),y=m||n!==void 0&&_===null;return e(`li`,{className:`space-y-2 rounded border border-border bg-surface p-2`,"data-testid":`binding-${t.role}`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:g}),t.custom&&i(q,{variant:`neutral`,children:p(`remote.bindings.custom`)}),!t.inLayout&&i(q,{variant:`warning`,children:p(`remote.bindings.notInLayout`)}),_!==null&&i(q,{variant:`info`,children:p(`remote.bindings.infrared`)}),n===void 0&&i(`span`,{className:`text-xs text-foreground-subtle`,children:p(`remote.bindings.native`)}),e(`div`,{className:`ml-auto flex items-center gap-1`,children:[n===void 0&&!m&&i(J,{size:`sm`,variant:`outline`,onClick:()=>{h(!0),l(mc)},"data-testid":`bind-${t.role}`,children:p(`remote.bindings.bind`)}),n!==void 0&&e(d,{children:[i(J,{size:`sm`,variant:`outline`,disabled:!s||!v,title:s?void 0:p(`remote.bindings.saveToTest`),onClick:f,"data-testid":`test-${t.role}`,children:p(`remote.bindings.test`)}),i(J,{size:`sm`,variant:`ghost`,onClick:()=>{h(!1),u()},"data-testid":`clear-${t.role}`,children:p(`remote.bindings.clear`)})]})]})]}),_!==null&&n!==void 0&&i(mt,{"aria-label":p(`remote.bindings.transmitterFor`,{name:g}),value:String(_),options:a.map(e=>({value:String(e.id),label:e.name})),onChange:e=>l(gc(n,Number(e.target.value)).action),"data-testid":`transmitter-${t.role}`}),y&&_===null&&n!==void 0&&i(ki,{step:n.action,devices:r,variables:[],onChange:e=>{typeof e.deviceId==`number`&&l({...e,deviceId:e.deviceId})}}),c!==null&&i(`p`,{role:`status`,className:`text-xs text-foreground-muted`,"data-testid":`result-${t.role}`,children:c})]})}c();function xc({transmitterId:n,onApply:r}){let{t:a}=X(),s=t(null),[c,l]=o(``),[u,d]=o(null),[f,p]=o(null),m=e=>{p(e.trim()===``?null:vc(e,n))},h=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t===void 0)return;d(t.name);let n=await t.text();l(n),m(n)};return e(`div`,{className:`space-y-2`,"data-testid":`smartir-import`,children:[i(`p`,{className:`text-xs text-foreground-muted`,children:a(`remote.import.hint`)}),i(jt,{label:a(`remote.import.pasteLabel`),children:i(`textarea`,{value:c,rows:5,onChange:e=>{l(e.target.value),d(null),p(null)},className:`w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`,"data-testid":`smartir-text`})}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`input`,{ref:s,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>void h(e),"data-testid":`smartir-file`}),e(J,{size:`sm`,variant:`outline`,onClick:()=>s.current?.click(),children:[i(dt,{className:`mr-1 h-3 w-3`,"aria-hidden":!0}),a(`remote.import.chooseFile`)]}),u!==null&&i(`span`,{className:`truncate font-mono text-[11px] text-foreground-subtle`,children:u}),i(J,{size:`sm`,variant:`secondary`,disabled:c.trim()===``,onClick:()=>m(c),"data-testid":`smartir-read`,children:a(`remote.import.read`)})]}),f?.status===`refused`&&i(`p`,{role:`alert`,className:`text-xs text-danger`,"data-testid":`smartir-refused`,children:a(`remote.import.refused.${f.reason}`)}),f?.status===`ok`&&e(`div`,{className:`space-y-2`,"data-testid":`smartir-summary`,children:[i(`p`,{className:`text-xs text-foreground`,children:a(`remote.import.summary`,{count:f.bound})}),f.skipped.length>0&&e(`div`,{className:`space-y-1`,children:[i(`p`,{className:`text-xs text-warning`,children:a(`remote.import.skipped`,{count:f.skipped.length})}),i(`ul`,{className:`max-h-24 space-y-0.5 overflow-y-auto text-[11px] text-foreground-muted`,children:f.skipped.map(t=>e(`li`,{children:[t.name,` — `,t.reason]},`${t.name}:${t.reason}`))})]}),i(J,{size:`sm`,disabled:f.bound===0,onClick:()=>{r(f.draft),l(``),d(null),p(null)},"data-testid":`smartir-apply`,children:a(`remote.import.apply`)})]})]})}c();function Sc({device:t,open:n,onClose:r}){let{t:a}=X(),o=$n({deviceId:t.id},{enabled:n});return i(ei,{open:n,onOpenChange:e=>!e&&r(),children:e($r,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(Xr,{children:i(xn,{children:a(`remote.dialog.title`,{name:t.name})})}),o.data===void 0?i(Gn,{children:o.status===`error`?i(K,{title:a(`remote.dialog.unreadable`),message:o.error?.message??``,onRetry:()=>void o.refetch()}):i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:a(`remote.dialog.loading`)})}):i(wc,{device:t,initial:o.data,onClose:r})]})})}function Cc(e,t){switch(e.status){case`sent`:return t(`remote.test.sent`,{count:e.sends});case`skipped`:return t(`remote.test.skipped`);case`refused`:return t(`remote.test.refused.${e.reason}`,{detail:e.detail??``})}}function wc({device:t,initial:r,onClose:a}){let{t:s}=X(),c=l(),[u,f]=o(r),[p,m]=o(null),[h,g]=o({}),_=zn({kind:`remote`}),v=Or({deviceId:t.id}),y=Ai(),b=Xt({capNames:[cc]}),x=sr(),S=vr(),C=n(()=>{let e=new Set(b.data??[]);return y.filter(t=>e.has(t.id))},[y,b.data]),w=(_.data??[]).find(e=>e.id===u.layoutTemplateId),T=w===void 0?null:Va(w.payload),E=n(()=>lc(T,u),[T,u]),D=n(()=>new Set((v.data?.commands??[]).map(e=>e.role)),[v.data]),O=_c(u),k=n(()=>new Set(Object.keys(u.bindings)),[u.bindings]),A=async()=>{if(O.config!==null){m(null);try{let e=await x.mutateAsync({deviceId:t.id,config:O.config});if(e.status===`refused`){m(e.detail);return}await c.invalidateQueries({queryKey:[[`remote`]]}),a()}catch(e){m(e instanceof Error?e.message:String(e))}}},j=async e=>{try{let n=await S.mutateAsync({deviceId:t.id,role:e,repeat:1});g(t=>({...t,[e]:Cc(n,s)}))}catch(t){g(n=>({...n,[e]:t instanceof Error?t.message:String(t)}))}},M=(e,t)=>f(n=>dc(n,e,t));return e(d,{children:[e(Gn,{className:`space-y-5`,children:[e(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[i(jt,{label:s(`remote.dialog.template`),children:i(mt,{value:u.layoutTemplateId??``,options:[{value:``,label:s(`remote.dialog.noTemplate`)},...(_.data??[]).map(e=>({value:e.id,label:e.name}))],onChange:e=>f(t=>({...t,layoutTemplateId:e.target.value===``?null:e.target.value})),"data-testid":`remote-template`})}),i(jt,{label:s(`remote.dialog.transmitter`),children:i(mt,{value:u.defaultTransmitterId===null?``:String(u.defaultTransmitterId),options:[{value:``,label:s(`remote.dialog.noTransmitter`)},...C.map(e=>({value:String(e.id),label:e.name}))],onChange:e=>f(t=>({...t,defaultTransmitterId:e.target.value===``?null:Number(e.target.value)})),"data-testid":`remote-transmitter`})}),i(jt,{label:s(`remote.dialog.power`),children:i(mt,{value:u.power.mode,options:[{value:`toggle`,label:s(`remote.dialog.powerToggle`)},{value:`discrete`,label:s(`remote.dialog.powerDiscrete`)}],onChange:e=>f(t=>({...t,power:{mode:e.target.value===`discrete`?`discrete`:`toggle`}})),"data-testid":`remote-power`})})]}),_.data!==void 0&&_.data.length===0&&i(`p`,{className:`text-xs text-foreground-muted`,children:s(`remote.dialog.noTemplatesHint`)}),T!==null&&i(`div`,{className:`mx-auto w-full max-w-xs`,"data-testid":`remote-preview`,children:i(Ha,{grid:T,label:s(`remote.dialog.preview`),boundRoles:k})}),e(`section`,{className:`space-y-2`,children:[i(`h3`,{className:`text-sm font-medium text-foreground`,children:s(`remote.import.title`)}),i(xc,{transmitterId:u.defaultTransmitterId,onApply:e=>f(t=>yc(t,e))})]}),e(`section`,{className:`space-y-2`,children:[i(`h3`,{className:`text-sm font-medium text-foreground`,children:s(`remote.bindings.title`)}),E.length===0?i(`p`,{className:`text-xs text-foreground-muted`,children:s(`remote.bindings.empty`)}):i(`ul`,{className:`space-y-2`,children:E.map(e=>i(bc,{role:e,binding:u.bindings[e.role],devices:y,transmitters:C,testable:D.has(e.role),testResult:h[e.role]??null,onBind:t=>M(e.role,t),onClear:()=>f(t=>fc(t,e.role)),onTest:()=>void j(e.role)},e.role))})]}),O.incomplete.length>0&&i(`p`,{role:`alert`,className:`text-xs text-warning`,"data-testid":`remote-incomplete`,children:s(`remote.dialog.incomplete`,{count:O.incomplete.length})}),p!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger`,children:p})]}),e(Tt,{children:[i(J,{variant:`ghost`,onClick:a,children:s(`common.cancel`)}),i(J,{disabled:O.config===null||x.isPending,onClick:()=>void A(),"data-testid":`remote-save`,children:s(`common.save`)})]})]})}c();function Tc({device:t}){let{t:n}=X(),[r,a]=o(!1),s=$n({deviceId:t.id}),c=zn({kind:`remote`}),l=s.data,u=l===void 0?0:Object.keys(l.bindings).length,d=l?.layoutTemplateId==null?null:(c.data??[]).find(e=>e.id===l.layoutTemplateId)?.name??null;return e(na,{id:`remote`,title:n(`remote.card.title`),icon:h,testId:`customize-remote`,actions:i(J,{size:`sm`,variant:`outline`,onClick:()=>a(!0),"data-testid":`remote-open`,children:n(`remote.card.configure`)}),children:[s.status===`error`?i(`p`,{role:`alert`,className:`text-xs text-danger`,children:s.error?.message??n(`remote.dialog.unreadable`)}):l===void 0?i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:n(`remote.dialog.loading`)}):i(`p`,{className:`text-xs text-foreground-muted`,"data-testid":`remote-summary`,children:u===0&&d===null?n(`remote.card.none`):n(`remote.card.summary`,{template:d??n(`remote.dialog.noTemplate`),count:u})}),r&&i(Sc,{device:t,open:r,onClose:()=>a(!1)})]})}var Ec={remote:Tc};function Dc(e){let t=[];for(let[n,r]of Object.entries(ke))r.targets.some(t=>t.cardinality===`config`&&t.deviceTypes.includes(e))&&t.push(n);return t}function Oc({device:e}){return Dc(e.type).map(t=>{let n=Ec[t];return n===void 0?null:i(n,{device:e},t)})}function kc(e,t){switch(e.kind){case`group`:return e.active===null?t(`helper.aggregate.${e.aggregate}`):t(`helper.active.${e.active}`);case`statistic`:return t(`helper.statName.${e.stat}`);case`integral`:case`threshold`:case`derivative`:return t(`helper.template.${e.kind}`);case`arithmetic`:return t(`helper.template.${e.op}`);case`expression`:return e.expr}}function Ac(e,t){switch(e.kind){case`integral`:return[{label:t(`helper.reset`),value:t(`helper.resetName.${e.reset}`)}];case`threshold`:return[{label:t(`helper.highEdge`),value:String(e.high)},{label:t(`helper.lowEdge`),value:String(e.low)}];case`derivative`:return[{label:t(`helper.per`),value:t(`helper.perName.${e.per}`)}];default:return[]}}function jc({draft:t,device:n,onEdit:r}){let{t:a,i18n:o}=X(),s=vi(),c=ma(t),l=Ac(t,e=>a(e));return i(an,{headingId:`helper-summary-${n.id}`,title:a(`customize.composed.helper.title`),testId:`helper-summary`,actions:e(J,{variant:`outline`,size:`sm`,onClick:r,"data-testid":`helper-summary-edit`,children:[i(ee,{className:`h-3 w-3`,"aria-hidden":!0}),a(`common.edit`)]}),children:e(`div`,{className:f,children:[i(mr,{label:a(`customize.composed.helper.function`),children:kc(t,e=>a(e))}),l.map(e=>i(mr,{label:e.label,children:e.value},e.label)),c.length>0&&i(mr,{label:a(`customize.composed.helper.members`),children:i(`ul`,{className:`flex flex-col gap-0.5`,"data-testid":`helper-summary-members`,children:c.map(t=>{let n=s.data?.find(e=>e.addonId===t.source.addonId&&e.stableId===t.source.stableId);return e(`li`,{className:`flex flex-wrap items-baseline gap-x-1.5`,children:[n===void 0?i(`span`,{children:t.source.stableId}):i(kn,{device:n,form:`compact`}),i(`span`,{className:`text-foreground-muted`,children:va(t.cap,t.fieldPath,o.language)})]},`${t.source.addonId}:${t.source.stableId}:${t.cap}:${t.fieldPath}`)})})})]})})}c();function Mc({device:t}){let{t:r}=X(),a=t.stableId.startsWith(`composed-`)?t.stableId.slice(Re.length):null,s=kr({blockId:a??``},{enabled:a!==null}),c=Br(),[l,u]=o(!1),d=n(()=>{let e=new Set;for(let{cap:t}of Ii())e.add(t);for(let{cap:t}of Gi())e.add(t);for(let{cap:t}of Hi())e.add(t);for(let n of Dc(t.type))e.add(n);return e},[t.type]);if(a===null)return i(`p`,{className:`text-xs text-foreground-subtle`,children:r(`customize.composed.missingBlock`)});if(s.status===`pending`)return i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:r(`customize.loadingDevice`)});if(s.status===`error`)return i(K,{title:r(`customize.composed.loadFailed`),message:s.error.message,onRetry:()=>void s.refetch()});if(s.data.state===`not-loaded`)return i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:r(`customize.status.notLoaded`,{reason:s.data.reason})});let f=s.data.view;if(f===null)return i(`p`,{className:`text-xs text-foreground-subtle`,children:r(`customize.composed.notFound`)});let p=We(f.block);if(p===null)return i(`p`,{className:`text-xs text-foreground-subtle`,children:r(`compositionEditor.notComposition`)});if(la(p)){let n=oa(p.helper,t.name,t.location??``);return n===null?i(`p`,{role:`alert`,children:r(`helper.unreadable`)}):e(`div`,{className:`flex flex-col gap-3`,children:[i(ss,{device:t}),i(jc,{draft:n,device:t,onEdit:()=>u(!0)}),i(ji,{blockId:l?f.block.id:null,onClose:()=>{u(!1),s.refetch()}})]})}let m={target:{addonId:t.addonId,stableId:t.stableId},state:{kind:`present`,view:f,composition:p},saving:c.isPending,save:async e=>{if(e===null)return{kind:`refused`,reason:r(`customize.composed.noDelete`)};try{return await c.mutateAsync({blockId:f.block.id,expectedUpdatedAt:f.block.updatedAt,block:{composition:e}}),await s.refetch(),{kind:`saved`}}catch(e){return{kind:`refused`,reason:e instanceof Error?e.message:String(e)}}}};return e(`div`,{className:`flex flex-col gap-3`,children:[i(ss,{device:t}),Vi(p)===`incomplete`&&i(q,{variant:`warning`,children:r(`customize.blockStatus.incomplete`)}),i(Oc,{device:t}),i(Ji,{device:t,handle:m,skipCaps:d})]})}c();function Nc({deviceId:e}){let{t}=X(),n=fr({deviceId:e}),r=n.data;if(r==null)return n.status===`error`?i(K,{title:t(`customize.deviceUnreadable`),message:n.error?.message??``,onRetry:()=>void n.refetch()}):r===null?i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:t(`customize.noSuchDevice`,{deviceId:e})}):i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:t(`customize.loadingDevice`)});let a=r.addonId===`composer`?i(Mc,{device:r}):i(Pc,{device:r,target:{addonId:r.addonId,stableId:r.stableId}});return i(hi,{deviceId:r.id,seed:{name:r.name,location:r.location??``,role:r.role??null,display:r.display},children:a})}function Pc({device:t,target:r}){let a=ec(r),o=Nt(`composer`),{t:s}=X(),c=ac(t.id,t.type===G.Camera),l=oc(t,_a(a.state)),u=sc(t.id,l.nativeCaps,l.wireable),d={deviceType:t.type,composable:l.composable,nativeCaps:l.nativeCaps,cameraSensors:c.presence},f=n(()=>{let e=new Set;for(let{cap:t}of Ii())e.add(t);for(let{cap:t}of Gi())e.add(t);for(let{cap:t}of Hi())e.add(t);for(let n of Dc(t.type))e.add(n);return e},[t.type]);return e(`div`,{className:`flex flex-col gap-3`,children:[i(ss,{device:t}),o===`absent`&&i(`p`,{role:`alert`,className:`text-xs text-warning`,children:s(`customize.composerAbsent`)}),a.state.kind!==`none`&&i(Fc,{state:a.state}),i(Ws,{device:t,handle:a,facts:d,sensors:c}),i(Xi,{device:t,handle:a,facts:d}),i(Fi,{device:t,handle:a,facts:d,defaults:u}),i(Oc,{device:t}),i(Ji,{device:t,handle:a,skipCaps:f}),i(Qs,{device:t}),t.type===G.Camera&&i(Ys,{device:t})]})}function Fc({state:t}){let{t:n}=X();switch(t.kind){case`pending`:return i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:n(`customize.status.pending`)});case`unknown`:return i(K,{title:n(`customize.status.unknownTitle`),message:t.reason});case`not-loaded`:return i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:n(`customize.status.notLoaded`,{reason:t.reason})});case`none`:return null;case`present`:{let r=t.view.block;return e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(q,{variant:r.status===`running`?`success`:r.status===`failed`?`danger`:`warning`,children:n(`customize.blockStatus.${r.status}`)}),!r.enabled&&i(q,{variant:`default`,children:n(`customize.status.off`)}),r.lastError!==void 0&&i(`span`,{className:`text-[11px] text-foreground-muted break-words`,children:r.lastError}),t.view.state.kind===`unreachable`&&i(`span`,{className:`text-[11px] text-warning`,children:n(`customize.status.composerUnreachable`,{reason:t.view.state.error})})]})}}}var Ic=`overview`;function Lc(e,t){return e.some(e=>e.id===t)?t:Ic}function Rc({deviceId:t}){let{t:n}=X(),r=l(),a=Number.isFinite(t),{data:o}=fr({deviceId:t},{enabled:a}),s=typeof o?.type==`string`?o.type:`camera`;Mr([`deviceManager`,`getBindings`],[`capability.binding-changed`]);let{data:c,isLoading:u,isError:d,error:f}=on({deviceId:t},{enabled:a}),{data:p}=Bt({deviceType:s},{enabled:!!s}),m=Yn({onSuccess:()=>{r.invalidateQueries({queryKey:[[`deviceManager`,`getBindings`]]})}});if(u)return i(`div`,{className:`p-4`,children:i(`div`,{className:`h-20 rounded-lg border border-border bg-surface animate-pulse`})});if(d)return e(`div`,{className:`p-4 text-xs text-red-400`,children:[n(`device.bindingsTab.failedToLoadBindings`,`Failed to load bindings:`),` `,f instanceof Error?f.message:String(f)]});let h=new Map,g={};for(let e of p??[])g[e.capName]=e.wrappers;for(let e of c?.entries??[])h.set(e.capName,{...e,wrappers:g[e.capName]??[]});for(let e of p??[])h.has(e.capName)||h.set(e.capName,{capName:e.capName,kind:`unbound`,providerAddonId:``,providerNodeId:``,nativeAddonId:``,wrappers:e.wrappers});let _=[...h.values()].toSorted((e,t)=>e.capName.localeCompare(t.capName));if(_.length===0)return e(`div`,{className:`flex flex-col items-center justify-center gap-2 p-8 text-foreground-subtle`,children:[i(ct,{className:`h-8 w-8 opacity-40`}),i(`p`,{className:`text-xs`,children:n(`device.bindingsTab.noCapabilityProvidersApplicableTo`,`No capability providers applicable to this device yet.`)}),i(`p`,{className:`text-[10px] opacity-60`,children:n(`device.bindingsTab.nativeProvidersShowUpHere`,`Native providers show up here as soon as the owning addon registers them.`)})]});let v=_.filter(e=>e.kind!==`unbound`).length,y=[{key:`capability`,header:n(`device.bindingsTab.capability`,`Capability`),render:e=>i(`span`,{className:`font-mono text-foreground`,children:e.capName})},{key:`kind`,header:n(`device.bindingsTab.kind`,`Kind`),render:e=>i(zc,{kind:e.kind})},{key:`provider`,header:n(`device.bindingsTab.activeProvider`,`Active Provider`),render:e=>i(`span`,{className:`font-mono text-foreground-subtle`,children:e.providerAddonId||i(`span`,{className:`opacity-40`,children:`—`})})},{key:`node`,header:n(`device.bindingsTab.node`,`Node`),render:e=>e.providerNodeId?i(Bc,{nodeId:e.providerNodeId}):i(`span`,{className:`text-[10px] opacity-40`,children:`—`})},{key:`native`,header:n(`device.bindingsTab.kindNative`,`Native`),render:e=>i(`span`,{className:`font-mono text-foreground-subtle`,children:e.nativeAddonId||i(`span`,{className:`opacity-40`,children:`—`})})},{key:`wrapper`,header:n(`device.bindingsTab.wrapper`,`Wrapper`),render:e=>{let n=e.kind===`wrapped`?e.providerAddonId:null;return i(Vc,{wrappers:e.wrappers,activeWrapperId:n,disabled:m.isPending,onPick:r=>{let i=n===r;m.mutate({deviceId:t,capName:e.capName,wrapperAddonId:r,active:!i})}})}}];return e(`div`,{className:`flex flex-col gap-3 p-1`,children:[i(`div`,{className:`text-[11px] text-foreground-subtle`,children:i(Si,{i18nKey:`device.bindingsTab.boundSummary`,count:_.length,values:{bound:v},components:{b:i(`span`,{className:`font-medium text-foreground`}),em:i(`em`,{})}})}),i(gt,{columns:y,rows:_,rowKey:e=>e.capName,minWidthPx:720})]})}function zc({kind:t}){let{t:n}=X();return t===`native`?e(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-success/30 text-success bg-success/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[i(P,{className:`h-3 w-3`}),n(`device.bindingsTab.kindNative`)]}):t===`wrapped`?e(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-primary/30 text-primary bg-primary/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[i(ft,{className:`h-3 w-3`}),n(`device.bindingsTab.wrapped`)]}):t===`linked`?e(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-warning/30 text-warning bg-warning/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[i(R,{className:`h-3 w-3`}),n(`device.bindingsTab.linked`)]}):e(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border text-foreground-subtle/70 px-1.5 py-0.5 text-[10px] font-medium`,children:[i(oe,{className:`h-3 w-3`}),n(`common.unbound`)]})}function Bc({nodeId:e}){return i(`span`,{className:`inline-flex items-center rounded-md border border-border px-1.5 py-0.5 font-mono text-[10px] ${e===`hub`?`text-foreground-subtle`:`text-foreground`}`,children:e})}function Vc({wrappers:t,activeWrapperId:n,disabled:r,onPick:a}){let{t:o}=X();return t.length===0?i(`span`,{className:`text-[10px] opacity-40`,children:o(`device.bindingsTab.noneAvailable`,`none available`)}):i(`div`,{className:`flex flex-wrap gap-1`,children:t.map(t=>{let s=t===n;return e(`button`,{disabled:r,onClick:()=>a(t),title:s?o(`device.bindingsTab.clickToDeactivateRevertTo`,`Click to deactivate (revert to native)`):o(`device.bindingsTab.activateWrapper`,`Activate wrapper {{wrapperId}}`,{wrapperId:t}),className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 font-mono text-[10px] transition-colors disabled:opacity-50 ${s?`border-primary/40 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[i(s?z:j,{className:`h-3 w-3`}),t]},t)})})}function Hc({deviceId:t,activeSubTab:n,onSubTabChange:r,deviceType:a,isAdmin:o}){return e(`div`,{className:`flex flex-col gap-3`,children:[gi(a,o)&&i(Dt,{deviceId:t,readOnly:!0}),i(_i,{deviceId:t,activeSubTab:n,onSubTabChange:r})]})}c();var Uc=[[`pipelineOrchestrator`,`getCameraDetectionSource`]];function Wc(e){let t=l(),n=Un({deviceId:e},{refetchOnMount:`always`}),i=rn(),[a,s]=o(null),[c,u]=o(null),d=r(async n=>{u(null),s(n);try{await i.mutateAsync({deviceId:e,source:n}),await t.invalidateQueries({queryKey:Uc})}catch(e){u(e instanceof Error?e.message:`Could not change the root detector`),await t.invalidateQueries({queryKey:Uc})}finally{s(null)}},[e,i,t]),f=n.data??null;return{view:f,isLoading:n.isLoading,source:a??f?.source??null,saving:a!==null,error:c,pick:d}}var Gc=`object-detection`;function Kc(e){return[e.addonId,...e.children.flatMap(Kc)]}function qc(e,t){if(e===`pipeline`)return new Set;let n=Jc(t,Gc);return n===void 0?new Set:new Set(e===`onboard`?[n.addonId]:Kc(n))}function Jc(e,t){for(let n of e){if(n.addonId===t)return n;let e=Jc(n.children,t);if(e!==void 0)return e}}function Yc(e,t){return e===`onboard`?Y.t(`helpers.detectionSourceModel.badgeCameraAi`):t===`object-detection`?Y.t(`helpers.detectionSourceModel.badgeNoRoot`):Y.t(`helpers.detectionSourceModel.badgeIdle`)}function Xc(e){switch(e){case`pipeline`:return Y.t(`helpers.detectionSourceModel.explainPipeline`);case`onboard`:return Y.t(`helpers.detectionSourceModel.explainOnboard`);case`none`:return Y.t(`helpers.detectionSourceModel.explainNone`)}}function Zc(e){switch(e){case`boxed`:return``;case`while-streaming`:return Y.t(`helpers.detectionSourceModel.geometryWhileStreaming`);case`flag-only`:return Y.t(`helpers.detectionSourceModel.geometryFlagOnly`);case`unknown`:return Y.t(`helpers.detectionSourceModel.geometryUnknown`)}}function Qc(e,t){return e===`onboard`?Y.t(`helpers.detectionSourceModel.noticeOnboard`):t===`object-detection`?Y.t(`helpers.detectionSourceModel.noticeNoRoot`):Y.t(`helpers.detectionSourceModel.noticeIdle`)}var $c=[`pl-2`,`pl-6`,`pl-10`,`pl-14`],el={detector:`success`,cropper:`info`,classifier:`primary`,refiner:`warning`,"audio-classifier":`neutral`};function tl(e){return $c[Math.min(e,$c.length-1)]??`pl-2`}function nl(e){return e.zoneDriven?{kind:`zone-driven`}:{kind:`gate`,effectiveOn:e.ownOn,defaultOn:e.defaultOn,explicit:e.choice!==`auto`}}function rl(e,t,n){return e.kind===`parent`?n:Yc(e.source,t)}function il({inputs:t,outputs:n}){return t.length===0&&n.length===0?null:e(`span`,{className:`inline-flex flex-wrap items-center gap-1`,children:[t.map(e=>i(q,{size:`sm`,variant:`info`,children:e},`in-${e}`)),t.length>0&&n.length>0&&i(`span`,{className:`text-[10px] text-foreground-subtle`,"aria-hidden":!0,children:`→`}),n.map(e=>i(q,{size:`sm`,variant:`success`,children:e},`out-${e}`))]})}function al({rows:t,label:n,selectedId:r,busy:a,onOpen:o,onSet:s}){let{t:c}=X(),l=e=>{switch(e){case`detector`:return c(`device.cameraStepInspector.kindDetector`,`detector`);case`cropper`:return c(`device.cameraStepInspector.kindCropper`,`cropper`);case`classifier`:return c(`device.cameraStepInspector.kindClassifier`,`classifier`);case`refiner`:return c(`device.cameraStepInspector.kindRefiner`,`refiner`);case`audio-classifier`:return c(`device.cameraStepInspector.kindAudio`,`audio`)}},u=c(`device.cameraStepInspector.offBecauseParent`,`Off because its parent is off`);return i(`ul`,{"aria-label":n,className:`divide-y divide-border rounded-md border border-border`,children:t.map(t=>{let n=t.stepId===r,c=t.blocked===null?null:rl(t.blocked,t.stepId,u);return e(`li`,{"data-step":t.stepId,"data-runs":t.runs?`yes`:`no`,className:`flex flex-wrap items-center gap-x-2 gap-y-1.5 py-2 pr-2 ${tl(t.depth)} ${n?`bg-primary/10`:t.runs?``:`bg-muted/40`}`,children:[e(`button`,{type:`button`,"aria-expanded":n,onClick:()=>o(t.stepId),className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 text-left`,children:[i(`span`,{className:`text-sm font-medium ${t.runs?`text-foreground`:`text-foreground-muted`}`,children:t.name}),i(q,{size:`sm`,variant:el[t.kind],children:l(t.kind)}),i(il,{inputs:t.inputs,outputs:t.outputs}),c!==null&&i(`span`,{className:`text-[11px] text-warning`,children:c})]}),i(_r,{gate:nl(t),busy:a,onSet:e=>s(t.stepId,e)})]},t.stepId)})})}function ol(e,t){let n=e?.[t];return n===void 0?`auto`:n?`on`:`off`}function sl(e,t){return e===`auto`?t:e===`on`}function cl(e,t,n){return e!==`onboard`&&e!==`none`||!n.has(t)?null:{kind:`source`,source:e}}function ll(e,t,n,r,i){let a=e.zoneDrivenIds??new Set;return t.flatMap(t=>{let o=a.has(t.addonId),s=ol(e.toggles,t.addonId),c=e.defaults[t.addonId]??!0,l=o||sl(s,c),u=r===null?cl(e.source,t.addonId,i):{kind:`parent`,ancestorId:r.stepId},d={stepId:t.addonId,name:t.addonName,kind:t.slot,depth:n,inputs:t.inputClasses,outputs:t.outputClasses,choice:s,defaultOn:c,ownOn:l,runs:u===null&&l,blocked:u,zoneDriven:o},f=l?r:{stepId:t.addonId};return[d,...ll(e,t.children,n+1,f,i)]})}function ul(e){let t=e.source===null?new Set:qc(e.source,e.tree);return ll(e,e.tree,0,null,t)}function dl({source:t,geometry:n,saving:r,error:a,onPick:o}){let{t:s}=X(),c=n===`flag-only`,l=Zc(n);return e(`section`,{"aria-label":s(`device.detectionSourceControl.rootDetector`,`Root detector`),"aria-busy":r,className:`space-y-1.5 rounded-md border border-border bg-surface px-3 py-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[i(`h3`,{className:M,children:s(`device.detectionSourceControl.rootDetector`,`Root detector`)}),i(Xn,{label:s(`device.detectionSourceControl.rootDetector`,`Root detector`),value:t,onChange:e=>{!r&&e!==t&&o(e)},options:[{value:`pipeline`,label:s(`device.detectionSourceControl.thisNode`,`This node`)},{value:`onboard`,label:s(`device.detectionSourceControl.cameraOnboardAi`,`Camera onboard AI`),disabled:c&&t!==`onboard`,reason:l},{value:`none`,label:s(`device.detectionSourceControl.none`,`None`)}]}),r&&i(`span`,{className:`text-[10px] text-foreground-subtle`,children:s(`device.detectionSourceControl.saving`,`Saving…`)})]}),e(`p`,{className:H,children:[Xc(t),` `,s(`device.detectionSourceControl.oneRoot`)]}),l!==``&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:l}),a!==null&&i(`p`,{role:`alert`,className:`text-[11px] text-danger`,children:a})]})}c();var fl=new Set([`package-detection`]),pl=`/system/pipeline?view=nodes`;function ml(e){return Object.fromEntries(e.slots.flatMap(e=>e.addons.map(e=>[e.id,e.enabledByDefault??!0])))}function hl({deviceId:a}){let{t:c}=X(),u=ye(),d=It(),f=l(),p=I().trpcClient,m=t(null),h=t(null),g=Sr({deviceId:a},{refetchOnMount:`always`}),_=Gr(void 0,{refetchOnMount:`always`});Mr([`nodes`,`topology`],[`agent.online`,`agent.offline`,`agent.unregistered`,`addon.installed`,`addon.uninstalled`]);let{nodes:v}=Rr(),y=n(()=>{let e=new Set((_.data??[]).map(e=>e.nodeId));return v.filter(t=>t.isOnline&&e.has(t.id)).map(e=>({id:e.id,name:e.name}))},[_.data,v]),b=y.map(e=>e.id).join(`,`),x=s({enabled:y.length>0,queryKey:[[`pipelineExecutor`,`getSchema`],`camera-step-schemas`,b],queryFn:async()=>{let e={};for(let t of y)try{e[t.id]=await p.pipelineExecutor.getSchema.query({nodeId:t.id})}catch{}return e}}),S=r(()=>{f.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraSettings`]]})},[f]),C=dr({onSuccess:S}),w=ht(),[T,E]=o(null),[D,O]=o(!1),[k,A]=o(null),j=Wc(a),M=x.data??{},ee=g.data??null,N=y.map(e=>M[e.id]).find(e=>e!==void 0)??null,te=n(()=>N?Hr(N):[],[N]),ne=n(()=>N===null?[]:ul({tree:te,toggles:ee?.stepToggles,defaults:ml(N),source:j.source,zoneDrivenIds:fl}),[te,N,ee?.stepToggles,j.source]),{selection:re,open:P,close:ie}=ka(n(()=>ne.map(e=>e.stepId),[ne]),[]),F=y[0]?.id,ae=r(async e=>{if(T!==null){if(!await u({title:c(`stepInspector.stepMatrixFrame.discardUnsavedChanges`,`Discard unsaved changes?`),message:c(`stepInspector.stepMatrixFrame.thisStepHasChangesThat`,`This step has changes that are not saved yet.`),confirmLabel:c(`stepInspector.stepMatrixFrame.discard`,`Discard`),variant:`danger`}))return;E(null)}e()},[u,T,c]),oe=e=>{e!==re.stepId&&ae(()=>P({stepId:e}))},se=()=>{ae(()=>ie())};if(_.isLoading||y.length>0&&x.isLoading)return i(`div`,{className:`animate-pulse p-4 text-xs text-foreground-subtle`,children:c(`device.cameraStepInspector.loadingPipeline`,`Loading pipeline…`)});if(y.length===0)return i(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:c(`device.cameraStepInspector.noPipelineNodeIsOnline`,`No pipeline node is online.`)});if(N===null)return i(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:c(`device.cameraStepInspector.catalogUnavailable`,`Catalog unavailable.`)});let ce=e=>_.data?.find(e=>e.nodeId===F)?.settings.stepSettings?.[e]??{},R=ne.find(e=>e.stepId===re.stepId)??null,z=R===null?null:Oa(N,R.stepId),le=d?i(Wn,{onClick:se}):i(zt,{icon:L,variant:`ghost`,size:`sm`,"aria-label":c(`common.close`,`Close`),onClick:se});return e(`div`,{ref:m,className:`space-y-2`,children:[j.view?.onboard.available===!0&&j.source!==null&&i(dl,{source:j.source,geometry:j.view.onboard.geometry,saving:j.saving,error:j.error,onPick:e=>void j.pick(e)}),i(`p`,{className:H,children:i(Si,{i18nKey:`device.cameraStepInspector.modelsChosenByAccelerators`,components:{nodes:i(yi,{to:pl,className:`font-medium text-primary hover:underline`})}})}),re.staleStepId!==null&&i(`p`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-1.5 text-[11px] text-warning`,children:c(`stepInspector.stepMatrixFrame.staleStep`,{id:re.staleStepId})}),i(al,{rows:ne,label:c(`device.cameraStepInspector.detectionStepsOfThisCamera`,`Detection steps of this camera`),selectedId:re.stepId,busy:C.isPending,onOpen:oe,onSet:(e,t)=>C.mutate({deviceId:a,addonId:e,enabled:t})}),i(Lr,{open:R!==null&&z!==null,anchor:m,onClose:se,label:c(`stepInspector.stepMatrixFrame.stepSettings`,`Step settings`),children:R!==null&&z!==null&&i(gl,{addon:z,nodeBag:ce(R.stepId),storedCamera:ee?.stepSettings?.[R.stepId],draft:T?.stepId===R.stepId?T:null,saving:D,status:k,notice:R.blocked?.kind===`source`?Qc(R.blocked.source,R.stepId):null,closeButton:le,onEscape:se,headingRef:e=>{h.current=e},onDraft:e=>{A(null),E({stepId:R.stepId,camera:e})},onDiscard:()=>E(null),onSave:async e=>{O(!0);try{await w.mutateAsync({deviceId:a,addonId:R.stepId,settings:Object.keys(e).length>0?{...e}:null}),E(null),A({kind:`saved`})}catch(e){A({kind:`error`,error:e instanceof Error?e.message:c(`device.cameraStepInspector.saveFailed`)})}finally{O(!1),S()}}})})]})}function gl({addon:t,nodeBag:n,storedCamera:r,draft:a,saving:o,status:s,notice:c,closeButton:l,onEscape:u,headingRef:d,onDraft:f,onDiscard:p,onSave:m}){let{t:h}=X(),g=Vr(t),_=ja(g),v=Aa(g),y=a?.camera??r,b=a!==null&&!He(a.camera,r??{});return i(ur,{ref:d,title:h(`device.cameraStepInspector.thisCamera`,`{{name}} · this camera`,{name:t.name}),subtitle:t.slot,leading:l,onEscape:u,..._.length>0?{saveBar:{dirtyCount:+!!b,saving:o,status:s?.kind??null,...s?.error===void 0?{}:{error:s.error},onSave:()=>void m(a?.camera??r??{}),onDiscard:p,scope:i(`p`,{className:H,children:h(`device.cameraStepInspector.appliesToAllAcceleratorsOf`,`Applies to: all accelerators of this camera.`)})}}:{},children:e(`div`,{className:`space-y-3`,children:[c!==null&&i(`p`,{role:`note`,className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-1.5 text-[11px] text-warning`,children:c}),_.length>0?i(_l,{addon:t,fields:_,nodeBag:n,cameraBag:y,onChange:f}):i(`p`,{className:H,children:h(`device.cameraStepInspector.noCameraSettings`,`This step has no settings on this camera.`)}),v&&i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`accelerator-only-thresholds`,children:h(`device.cameraStepInspector.thresholdsAreTheAccelerators`,`Confidence thresholds belong to the model, so they are set on the accelerator that runs it (Pipeline → Nodes), not per camera.`)})]})})}function _l({addon:e,fields:t,nodeBag:n,cameraBag:r,onChange:a}){let{t:o}=X();return i(yr,{addon:e,fields:t,layers:{node:n,...r===void 0?{}:{camera:r}},target:`camera`,labels:{camera:o(`device.cameraStepInspector.layerCamera`,`This camera`),node:o(`device.cameraStepInspector.layerNode`,`Node`)},modelId:e.defaultModelId,onChangeLayer:a})}function vl(e,t,n){return{id:e,get label(){return Y.t(t)},icon:n}}var yl=[vl(`object-detection`,`helpers.detectionSettingsGroups.objectDetection`,`scan-search`),vl(`tracking`,`helpers.detectionSettingsGroups.tracking`,`route`),vl(`motion`,`helpers.detectionSettingsGroups.motion`,`activity`),vl(`stationary`,`helpers.detectionSettingsGroups.stationary`,`square-parking`),vl(`zones`,`helpers.detectionSettingsGroups.zones`,`shapes`),vl(`audio`,`helpers.detectionSettingsGroups.audio`,`volume-2`),vl(`cluster`,`helpers.detectionSettingsGroups.cluster`,`server`)],bl={"pipeline-object-detection":`object-detection`,"detection-sensitivity":`object-detection`,"onboard-object-detection":`object-detection`,tracking:`tracking`,"tracking-core":`tracking`,"motion-tuning":`motion`,"stationary-objects":`stationary`,occupancy:`stationary`,zones:`zones`,"pipeline-audio":`audio`,"cluster-assignment":`cluster`,"orchestrator-live":`cluster`};function xl(e){return bl[e]??`object-detection`}c();var Sl=`steps`,Cl=`settings`,wl=new Set([Sl,Cl]);function Tl(e){return e.location===`top-tab`&&(e.tab===`detection-pipeline`||e.tab===`zones`)}function El({deviceId:t,activeSubTab:n,onSubTabChange:a}){let{t:o}=X();return e(Kt,{value:n&&wl.has(n)?n:Sl,onValueChange:r(e=>{a?.(e)},[a]),className:`flex flex-col`,children:[e(Wt,{className:`flex-shrink-0`,children:[i(In,{value:Sl,children:o(`device.detectionPipelineTab.steps`,`Steps`)}),i(In,{value:Cl,children:o(`device.detectionPipelineTab.settings`,`Settings`)})]}),i(jr,{value:Sl,children:i(hl,{deviceId:t})}),i(jr,{value:Cl,children:i(_i,{deviceId:t,sectionFilter:Tl,subTabGrouping:{groupOf:e=>xl(e.id),tabs:yl}})})]})}var Dl=`Notifications`,Ol={i18nKey:`device.deviceNotificationMute.cameraCostWhenOff`,text:`This camera never notifies — no rule, no target, no alarm. Existing events, tracks and recordings are unaffected.`},kl={i18nKey:`device.deviceNotificationMute.deviceCostWhenOff`,text:`This device never notifies — no rule, no target, no alarm.`};function Al(e){let{mutedDeviceIds:t,deviceId:n}=e,r=t===null?null:!t.includes(n),i=e.pendingOn??null;return{label:Dl,on:r===null?null:i??r,available:r!==null,costWhenOff:e.isCamera?Ol:kl}}function jl(e,t){return!e.available||e.on===null?null:{deviceId:t,muted:e.on}}c();function Ml(e){if(typeof e!=`object`||!e)return null;let t={...e}.mutedDeviceIds;return Array.isArray(t)?t.filter(e=>typeof e==`number`):null}function Nl({deviceId:t,isCamera:n}){let{t:a}=X(),s=l(),c=Number.isFinite(t),[u,d]=o(null),[f,p]=o(null),m=Al({mutedDeviceIds:Ml(Zt({},{enabled:c}).data),deviceId:t,isCamera:n,pendingOn:f}),h=a(m.costWhenOff.i18nKey,m.costWhenOff.text),g=cn({onError:e=>{console.error(`[DeviceNotificationMute] mute write failed — reverting`,{tags:{deviceId:t},meta:{error:e instanceof Error?e.message:String(e)}}),p(null),d(e instanceof Error?e.message:String(e)),s.invalidateQueries({queryKey:[[`notificationRules`,`listDeviceMutes`]]})},onSuccess:()=>{d(null),p(null),s.invalidateQueries({queryKey:[[`notificationRules`]]})}}),v=r(()=>{let e=jl(m,t);e!==null&&(p(!e.muted),g.mutate(e))},[t,g,m]),y=m.on===null,b=m.on===!1,x=b?at:_;return e(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[e(`div`,{className:`border-b border-border px-4 py-2 flex items-center justify-between gap-2`,children:[i(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:a(`device.deviceNotificationMute.notifications`,`Notifications`)}),b&&i(`span`,{className:`rounded bg-warning/20 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-warning`,children:a(`common.muted`)})]}),e(`div`,{className:`px-4 py-3 flex items-start gap-3`,children:[e(`button`,{type:`button`,role:`switch`,"aria-label":m.label,"aria-checked":m.on===!0,disabled:!m.available||g.isPending,onClick:v,title:y?a(`device.deviceNotificationMute.notificationMuteStateUnknownThe`,`Notification mute — state unknown; the notification centre did not answer.`):b?a(`device.deviceNotificationMute.muted`,`Muted. {{costWhenOff}}`,{costWhenOff:h}):a(`device.deviceNotificationMute.notifyingMutingIt`,`Notifying. Muting it: {{costWhenOff}}`,{costWhenOff:h}),className:`inline-flex items-center gap-1.5 rounded-lg border px-2 py-1.5 text-[11px] font-medium transition-colors disabled:cursor-not-allowed ${u===null?y?`border-dashed border-border text-foreground-subtle/50`:b?`border-warning/40 text-warning hover:bg-warning/10`:`border-success/30 text-success hover:bg-success/10`:`border-danger/50 text-danger bg-danger/5`}`,children:[i(x,{className:`h-3.5 w-3.5`}),i(`span`,{children:y?a(`device.deviceNotificationMute.unknown`,`Unknown`):b?a(`device.deviceNotificationMute.muted2`,`Muted`):a(`device.deviceNotificationMute.notifying`,`Notifying`)})]}),i(`p`,{className:`flex-1 text-[11px] leading-relaxed text-foreground-subtle`,children:u===null?y?a(`device.deviceNotificationMute.theNotificationCentreDidNot`,`The notification centre did not answer, so this device’s mute state is unknown.`):h:a(`device.deviceNotificationMute.writeFailed`,`Write failed: {{failure}}`,{failure:u})})]})]})}c();function Pl({deviceId:t,template:n,members:a,fleet:s,fleetKind:c,snapshot:l,nameOf:u}){let{t:f}=X(),[p,m]=o(()=>new Map),h=r((e,t)=>{m(n=>{if(Vl(n.get(e),t))return n;let r=new Map(n);return r.set(e,t),r})},[]);if(n.family!==`actuator`)return null;let g=ya(l),_=n.id!==`switch`,v=_?ra(n.id,a.map(e=>p.get(Bl(e))??{kind:`pending`})):null;return e(d,{children:[_&&a.map(e=>i(Rl,{member:e,row:zl(s,e),fleetKind:c,onRead:h},Bl(e))),v!==null&&i(Fl,{view:v}),n.id===`lock`&&i(Il,{deviceId:t}),e(`div`,{"data-testid":`helper-commands`,children:[i(`h3`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:f(`helper.commandTitle`)}),g.kind===`pending`&&i(`p`,{role:`status`,className:`mt-1 text-xs text-foreground-subtle`,children:f(`helper.reportingPending`)}),g.kind===`unavailable`&&i(K,{title:f(`helper.outputUnavailable`),message:g.message}),g.kind===`none`&&i(`p`,{className:`mt-1 text-xs text-foreground-muted`,children:f(`helper.commandNone`)}),g.kind===`rows`&&i(Ll,{view:g,nameOf:u})]})]})}function Fl({view:t}){let{t:n}=X(),r=t.kind===`ready`?t.methods.filter(e=>e!==`switch.setState`):[];return e(`div`,{"data-testid":`helper-shared-caps`,children:[i(`h3`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:n(`helper.sharedCaps`)}),t.kind===`pending`&&i(`p`,{role:`status`,className:`mt-1 text-xs text-foreground-subtle`,children:n(`helper.sharedPending`)}),t.kind===`unavailable`&&i(`p`,{role:`status`,className:`mt-1 text-xs text-foreground-subtle`,children:n(`helper.sharedUnavailable`)}),t.kind===`ready`&&r.length===0&&i(`p`,{className:`mt-1 text-xs text-foreground-muted`,children:n(`helper.sharedNone`)}),t.kind===`ready`&&r.length>0&&e(`ul`,{className:`mt-1 flex flex-col gap-0.5 text-xs text-foreground`,children:[r.map(e=>i(`li`,{children:n(`helper.method.${e}`)},e)),t.modes.filter(e=>e.startsWith(`light-color`)).map(e=>i(`li`,{children:n(`helper.mode.${e}`)},e))]})]})}function Il({deviceId:t}){let{t:n}=X(),r=ir(),a=Er(),[s,c]=o(null);return e(`div`,{className:`flex flex-col gap-2`,"data-testid":`helper-lock-controls`,children:[e(`div`,{className:`flex flex-wrap gap-2`,children:[e(J,{variant:`outline`,"data-testid":`helper-lock-all`,disabled:r.isPending,onClick:()=>{c(null),r.mutateAsync({deviceId:t}).catch(e=>c(e instanceof Error?e.message:String(e)))},children:[i(ue,{className:`h-4 w-4`,"aria-hidden":!0}),n(`helper.lockAll`)]}),i(wt,{label:n(`helper.unlockAll`),icon:V,title:n(`helper.unlockTitle`),description:n(`helper.unlockBody`),confirmLabel:n(`helper.unlockConfirm`),triggerVariant:`outline`,action:()=>a.mutateAsync({deviceId:t,confirm:!0})})]}),s!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger`,children:s})]})}function Ll({view:t,nameOf:n}){let{t:r}=X();return i(`ul`,{className:`mt-1 flex flex-col gap-0.5 text-xs text-foreground`,"data-testid":`helper-command-rows`,children:t.rows.map(t=>e(`li`,{children:[n(t.deviceId),` — `,r(`helper.method.${t.cap}.${t.method}`),` —`,` `,t.ok?r(`helper.commandOk`):r(`helper.commandFailed`),t.error===null?``:` — ${t.error}`]},`${t.deviceId}:${t.cap}:${t.at}`))})}function Rl({member:e,row:t,fleetKind:n,onRead:r}){let i=Bl(e),o=on({deviceId:t?.id??0},{enabled:n===`answered`&&t!==null});return a(()=>{if(n!==`answered`){r(i,{kind:`pending`});return}if(t===null){r(i,{kind:`ready`,caps:[],features:[]});return}if(o.status===`pending`){r(i,{kind:`pending`});return}if(o.status===`error`){r(i,{kind:`error`});return}r(i,{kind:`ready`,caps:o.data.entries.map(e=>e.capName),features:[...t.features]})},[o.data,o.status,n,i,r,t]),null}function zl(e,t){let n=e.find(e=>e.addonId===t.source.addonId&&e.stableId===t.source.stableId);return n===void 0?null:{id:n.id,name:n.name,features:n.features}}function Bl(e){return`${e.source.addonId}/${e.source.stableId}`}function Vl(e,t){return e===void 0||e.kind!==t.kind?!1:e.kind!==`ready`||t.kind!==`ready`?!0:e.caps.join(`\0`)===t.caps.join(`\0`)&&e.features.join(`\0`)===t.features.join(`\0`)}function Hl({helper:t,snapshot:n}){let{t:r}=X(),a=sa(n),o=Wl(n,t);return i(an,{headingId:`helper-history-status`,title:r(`helper.template.${t.kind}`),icon:ot,testId:`helper-history-status`,children:e(`div`,{className:`${f} flex flex-col gap-3`,children:[o.kind===`pending`&&i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:r(`helper.outputPending`)}),o.kind===`number`&&i(Qn,{value:Ul(t,o.value),label:r(`helper.output`)}),o.kind===`empty`&&i(`p`,{className:`text-xs text-foreground-subtle`,children:r(`helper.noReading`)}),a.kind===`ready`&&a.excluded>0&&i(`p`,{className:`text-xs text-foreground-muted`,"data-testid":`helper-history-gaps`,children:r(`helper.gaps`,{count:a.excluded})}),a.kind===`unavailable`&&i(K,{title:r(`helper.outputUnavailable`),message:a.message})]})})}function Ul(e,t){if(e.kind!==`derivative`)return String(t);let n=Me(e);return n===null?String(t):`${t} ${n}`}function Wl(e,t){if(e.kind===`pending`)return{kind:`pending`};if(e.kind!==`answered`)return{kind:`empty`};let n=t.kind===`statistic`||t.kind===`derivative`?{cap:`numeric-sensor`,field:`value`}:t.output===`energy`?{cap:`power-meter`,field:`energy`}:{cap:`meter`,field:`value`},r=e.caps[n.cap]?.[n.field];return typeof r==`number`&&Number.isFinite(r)?{kind:`number`,value:r}:{kind:`empty`}}function Gl({helper:t,snapshot:n}){let{t:r}=X(),a=Jl(n,t),o=t.kind===`arithmetic`?sa(n):null;return i(an,{headingId:`helper-math-status`,title:r(`helper.template.${Kl(t)}`),icon:st,testId:`helper-math-status`,children:e(`div`,{className:`${f} flex flex-col gap-3`,children:[a.kind===`pending`&&i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:r(`helper.outputPending`)}),a.kind===`number`&&i(Qn,{value:String(a.value),label:r(`helper.output`)}),a.kind===`boolean`&&i(Qn,{value:a.value?r(`helper.on`):r(`helper.off`),label:r(`helper.output`)}),a.kind===`empty`&&i(`p`,{className:`text-xs text-foreground-subtle`,children:r(`helper.noReading`)}),o?.kind===`ready`&&i(`p`,{className:`text-sm text-foreground`,"data-testid":`helper-reporting`,children:r(`helper.reporting`,{included:o.included,total:o.total})}),o?.kind===`unavailable`&&i(K,{title:r(`helper.outputUnavailable`),message:o.message})]})})}function Kl(e){return e.kind===`arithmetic`?e.op:e.kind}function ql(e){return e.kind===`threshold`||e.kind===`expression`&&e.output===`boolean`?{cap:`binary`,field:`on`}:{cap:`numeric-sensor`,field:`value`}}function Jl(e,t){if(e.kind===`pending`)return{kind:`pending`};if(e.kind!==`answered`)return{kind:`empty`};let n=ql(t),r=e.caps[n.cap]?.[n.field];return typeof r==`number`&&Number.isFinite(r)?{kind:`number`,value:r}:typeof r==`boolean`?{kind:`boolean`,value:r}:{kind:`empty`}}c();function Yl({deviceId:t,stableId:n}){let{t:a}=X(),s=n.startsWith(`composed-`)?n.slice(Re.length):null,c=kr({blockId:s??``},{enabled:s!==null}),l=ar({deviceId:t},{enabled:s!==null}),u=Mt({projection:`slim`},{enabled:s!==null}),[d,p]=o(()=>new Map),m=Ln(),h=Pt(),g=r((e,t)=>{p(n=>{let r=n.get(e);if(r?.name===t.name&&r.presence===t.presence)return n;let i=new Map(n);return i.set(e,t),i})},[]);if(s===null)return null;if(c.status===`pending`)return i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:a(`helper.checking`)});if(c.status===`error`)return i(K,{title:a(`helper.outputUnavailable`),message:c.error.message});if(c.data.state!==`loaded`||c.data.view===null)return null;let _=We(c.data.view.block);if(_===null||!la(_))return null;let v=_.helper;if(v.kind===`threshold`||v.kind===`arithmetic`||v.kind===`expression`)return i(Gl,{helper:v,snapshot:$l(l.status,l.data,l.error?.message)});if(Ve(v))return i(Hl,{helper:v,snapshot:$l(l.status,l.data,l.error?.message)});if(v.kind!==`group`)return null;let y=Oe(v.templateId);if(y===null)return null;let b=$l(l.status,l.data,l.error?.message),x=ua(b,y),S=sa(b),C=u.status===`success`?u.data.map(eu):[],w=tu(u.status),T=ha(v.members.map(e=>d.get(Ql(e))??{name:e.source.stableId,presence:`unknown`})),E=x.kind===`number`?x.unit===void 0?String(x.value):`${x.value} ${x.unit}`:x.kind===`boolean`?x.value?a(Zl(y.id,`on`)):a(Zl(y.id,`off`)):x.kind===`empty`?a(`helper.noReading`):null;return i(an,{headingId:`helper-group-status`,title:a(`helper.statusTitle`),icon:ct,testId:`helper-group-status`,children:e(`div`,{className:`${f} flex flex-col gap-3`,children:[v.members.map(e=>i(Xl,{member:e,row:C.find(t=>t.addonId===e.source.addonId&&t.stableId===e.source.stableId)??null,fleetKind:w,isState:y.activeWhen!==void 0,onLive:g},Ql(e))),x.kind===`pending`&&i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:a(`helper.outputPending`)}),x.kind===`unavailable`&&i(K,{title:a(`helper.outputUnavailable`),message:x.message}),E!==null&&i(Qn,{value:E,label:a(`helper.template.${y.id}`)}),S.kind===`pending`&&i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:a(`helper.reportingPending`)}),S.kind===`unavailable`&&i(K,{title:a(`helper.outputUnavailable`),message:S.message}),S.kind===`absent`&&i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:a(`helper.reportingAbsent`)}),S.kind===`ready`&&i(`p`,{className:`text-sm text-foreground`,"data-testid":`helper-reporting`,children:a(`helper.reporting`,{included:S.included,total:S.total})}),S.kind===`ready`&&S.excluded>0&&e(`div`,{children:[i(`h3`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:a(`helper.excluded`)}),T.kind===`pending`?i(`p`,{role:`status`,className:`mt-1 text-xs text-foreground-subtle`,children:a(`helper.excludedPending`)}):T.names.length===0?i(`p`,{className:`mt-1 text-xs text-foreground-muted`,children:a(`helper.excludedUnnamed`)}):i(`ul`,{className:`mt-1 flex flex-col gap-0.5 text-xs text-foreground`,"data-testid":`helper-excluded`,children:T.names.map(e=>i(`li`,{children:e},e))})]}),i(Pl,{deviceId:t,template:y,members:v.members,fleet:C.map(e=>({id:e.id,name:e.name,addonId:e.addonId,stableId:e.stableId,features:e.features})),fleetKind:w,snapshot:b,nameOf:e=>{if(m===null)return C.find(t=>t.id===e)?.name??String(e);let t=m.byId.get(e);return t===void 0?String(e):Lt(t,`compact`,m,h)}})]})})}function Xl({member:e,row:t,fleetKind:n,isState:r,onLive:i}){let o=t?.online===!0,s=ar({deviceId:t?.id??0},{enabled:n===`answered`&&t!==null&&o}),c=xa(s.status,s.status===`success`?Sa(s.data):void 0,e.cap,e.fieldPath,r),l=ga({fleet:n,deviceOnline:n===`answered`?t===null?null:t.online:!0,field:c}),u=t?.name??e.source.stableId,d=jn(t?.id??0,`compact`,u),f=t===null?u:d,p=Ql(e);return a(()=>{i(p,{name:f,presence:l})},[p,f,i,l]),null}function Zl(e,t){return[`cover`,`valve`,`lock`,`media-player`,`climate`].includes(e)?`helper.state.${e}.${t}`:`helper.${t}`}function Ql(e){return`${e.source.addonId}/${e.source.stableId}/${e.cap}.${e.fieldPath}`}function $l(e,t,n){return e===`pending`?{kind:`pending`}:e===`error`?{kind:`error`,message:n??``}:{kind:`answered`,caps:Sa(t)}}function eu(e){return{id:e.id,name:e.name,online:e.online,addonId:e.addonId,stableId:e.stableId,features:e.features??[]}}function tu(e){return e===`pending`?`pending`:e===`error`?`error`:`answered`}function nu(e,t){return{switchId:e,label:W[e].label,detail:t===void 0||t.length===0?null:t}}function ru(e){let t=new Map;for(let n of e.switches)n.deviceId===e.sourceId&&(t.has(n.switchId)||t.set(n.switchId,n));return t}function iu(e){let t=ru(e),n=new Set(e.sourceStillLive),r=e.sourceStillLive.map(e=>nu(e,t.get(e)?.detail)),i=[...t.values()].filter(e=>e.outcome===`not-offered`&&!n.has(e.switchId)).map(e=>nu(e.switchId,e.detail));return{inheritedId:e.sourceId,retiredId:e.targetId,swapped:e.swapped,verdict:r.length===0?`quiet`:`still-live`,stillLive:r,neverOffered:i}}c();function au(e,t){return e.filter(e=>e.isCamera&&e.id!==t).map(e=>({id:e.id,name:e.name})).toSorted((e,t)=>e.name.localeCompare(t.name))}function ou({deviceId:t,deviceName:r}){let{t:a}=X(),s=ye(),[c,l]=o(null),u=Mt({isCamera:!0,projection:`slim`}),d=Cn(),f=u.data!==void 0,p=n(()=>u.data===void 0?[]:au(u.data,t),[u.data,t]),m=p.find(e=>e.id===c)??null,h=d.data===void 0?null:iu(d.data),g=d.error===null?null:d.error.message,_=async()=>{m===null||m.id===t||await s({title:a(`deviceMigrate.confirmTitle`,`Replace “{{source}}” with “{{target}}”?`,{source:r,target:m.name}),message:a(`deviceMigrate.confirmMessage`,`“{{target}}” takes over number {{sourceId}}. That number is what every recording, event, rule, zone and home-automation export of “{{source}}” is filed under, so all of it follows the number to the new hardware and keeps working. “{{source}}” is switched off and handed number {{targetId}} in exchange. This swaps two device identities and cannot be undone from here.`,{source:r,target:m.name,sourceId:t,targetId:m.id}),confirmLabel:a(`deviceMigrate.confirmAction`,`Migrate`),variant:`danger`})&&d.mutate({sourceId:t,targetId:m.id})};return e(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3`,children:[e(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[e(`div`,{className:`min-w-0`,children:[i(`h2`,{className:`text-xs font-semibold uppercase tracking-wider text-foreground`,children:a(`deviceMigrate.title`,`Migrate to…`)}),i(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:a(`deviceMigrate.subtitle`,`Replace this camera with other hardware you have already adopted. The new camera inherits number {{deviceId}}, so recordings, rules and integrations follow it.`,{deviceId:t})})]}),e(`div`,{className:`flex shrink-0 items-center gap-2`,children:[e(`select`,{"aria-label":a(`deviceMigrate.pickerLabel`,`Replacement camera`),className:`rounded-md border border-border bg-background px-2 py-1.5 text-xs text-foreground disabled:opacity-50`,disabled:!f||p.length===0||d.isPending,value:c===null?``:String(c),onChange:e=>{let t=e.target.value;l(t===``?null:Number(t))},children:[i(`option`,{value:``,children:f?a(`deviceMigrate.pickerPlaceholder`,`Select a camera…`):a(`deviceMigrate.pickerPending`,`Reading the fleet…`)}),p.map(t=>e(`option`,{value:String(t.id),children:[t.name,` (#`,t.id,`)`]},t.id))]}),e(`button`,{type:`button`,disabled:m===null||d.isPending,onClick:()=>{_()},className:`inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-foreground hover:bg-surface disabled:opacity-50`,children:[i(tt,{className:`h-3 w-3`}),d.isPending?a(`deviceMigrate.running`,`Migrating…`):a(`deviceMigrate.action`,`Migrate`)]})]})]}),f&&p.length===0&&i(`p`,{className:`mt-2 text-[11px] text-foreground-subtle`,children:a(`deviceMigrate.noTargets`,`No other camera is adopted, so there is nothing to migrate to.`)}),g!==null&&i(`p`,{className:`mt-2 text-[11px] text-danger`,children:a(`deviceMigrate.failed`,`Migration failed: {{error}}`,{error:g})}),h!==null&&i(su,{report:h})]})}function su({report:t}){let{t:n}=X(),r=t.verdict===`quiet`;return e(`div`,{className:`mt-3 space-y-2 border-t border-border pt-3`,children:[i(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`deviceMigrate.swapped`,`The replacement now answers on number {{inheritedId}}; the old camera was handed number {{retiredId}}.`,{inheritedId:t.inheritedId,retiredId:t.retiredId})}),r?e(`div`,{className:`flex items-start gap-2 rounded-md border border-success/30 bg-success/5 px-3 py-2`,children:[i(ie,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-success`}),i(`p`,{className:`text-[11px] leading-relaxed text-foreground`,children:n(`deviceMigrate.quiet`,`Every function on the replaced camera was switched off — the old hardware is quiet.`)})]}):e(`div`,{className:`rounded-md border border-warning/40 bg-warning/5 px-3 py-2`,children:[e(`div`,{className:`flex items-start gap-2`,children:[i(p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`}),i(`p`,{className:`text-[11px] leading-relaxed text-foreground`,children:n(`deviceMigrate.stillLive`,`The replaced camera could not be reached, so these functions are STILL RUNNING on the old hardware. Nothing here failed to migrate — but until you unplug it or reach it physically, it can still produce data.`)})]}),i(`ul`,{className:`mt-2 space-y-1 pl-5`,children:t.stillLive.map(t=>e(`li`,{className:`text-[11px] text-foreground`,children:[i(`span`,{className:`font-medium`,children:t.label}),t.detail!==null&&e(`span`,{className:`text-foreground-subtle`,children:[` — `,t.detail]})]},t.switchId))})]}),t.neverOffered.length>0&&e(`div`,{className:`rounded-md border border-border px-3 py-2`,children:[e(`div`,{className:`flex items-start gap-2`,children:[i(ut,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),i(`p`,{className:`text-[11px] leading-relaxed text-foreground-subtle`,children:n(`deviceMigrate.neverOffered`,`The replaced camera never offered these, so there was nothing to switch off. They are not running.`)})]}),i(`ul`,{className:`mt-2 space-y-1 pl-5`,children:t.neverOffered.map(e=>i(`li`,{className:`text-[11px] text-foreground-subtle`,children:e.label},e.switchId))})]})]})}c();function cu({deviceId:t}){let{t:n}=X(),[r,a]=o(null),s=Kr({onSuccess:e=>{a(e.changed?`Re-aligned with source — ${e.rebuiltChildren} child${e.rebuiltChildren===1?``:`ren`} rebuilt.`:`Already up to date.`)},onError:e=>a(`Re-sync failed: ${e.message}`)});return e(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3`,children:[e(`div`,{className:`flex items-center justify-between gap-3`,children:[e(`div`,{children:[i(`h2`,{className:`text-xs font-semibold uppercase tracking-wider text-foreground`,children:n(`device.resyncButton.reSync`,`Re-sync`)}),i(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:n(`device.resyncButton.reAlignThisDeviceS`,`Re-align this device's type, role, capabilities and units with its source.`)})]}),e(`button`,{type:`button`,disabled:s.isPending,onClick:()=>{a(null),s.mutate({camDeviceId:t})},className:`inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-foreground hover:bg-surface disabled:opacity-50`,children:[i(m,{className:`h-3 w-3 ${s.isPending?`animate-spin`:``}`}),s.isPending?n(`device.resyncButton.reSyncing`,`Re-syncing…`):n(`device.resyncButton.reSync`,`Re-sync`)]})]}),r!==null&&i(`p`,{className:`mt-2 text-[11px] text-foreground-subtle`,children:r})]})}function lu(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function uu({device:t}){let{t:n}=X(),r=ui(),a=typeof t.id==`number`?t.id:null,o=typeof t.name==`string`?t.name:``,s=jn(a??0,`full`,o),c=String(t.type??``),l=c===G.Camera,u=c===G.Hub,d=t.features??[],f=d.includes(Je.Resyncable),{data:p}=Jr({deviceId:a??0},{enabled:a!==null&&l,refetchInterval:5e3}),m=p?.streams??{},h=Object.entries(m),g=d.includes(Je.DoorbellButton),_=cr(g?{deviceId:a??void 0,historyLimit:10}:void 0),v=_.latest?Date.now()-_.latest.timestamp<3e4:!1;return e(`div`,{className:`space-y-5`,children:[t.addonId===`composer`&&a!==null&&typeof t.stableId==`string`&&i(Yl,{deviceId:a,stableId:t.stableId}),u&&a!==null&&i(sn,{deviceId:a,onOpenChild:e=>r(`/devices/${e}`)}),f&&a!==null&&i(cu,{deviceId:a}),l&&a!==null&&i(ou,{deviceId:a,deviceName:s}),a!==null&&i(Nl,{deviceId:a,isCamera:l}),l&&a!==null&&i(qr,{widgetId:`pipeline-orchestrator/pipeline-quick-stats`,host:`device-tab`,deviceId:a}),g&&i(Ot,{history:_.history,latestIsFresh:v}),l&&a!==null&&i(qr,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:a}),l&&h.length>0&&e(`div`,{className:`@container rounded-lg border border-border bg-surface overflow-hidden`,style:{containerType:`inline-size`},children:[i(`div`,{className:`border-b border-border px-4 py-2`,children:i(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:n(`device.overviewTab.streamNetwork`,`Stream Network`)})}),i(`div`,{className:`divide-y divide-border`,children:h.map(([t,r])=>e(`div`,{className:`px-4 py-2.5`,children:[e(`div`,{className:`flex items-center gap-2 mb-2`,children:[i(F,{className:`h-3 w-3 text-foreground-subtle`}),i(`span`,{className:`text-[11px] font-medium text-foreground`,children:t})]}),e(`div`,{className:`grid grid-cols-2 @[640px]:grid-cols-4 gap-2`,children:[i(du,{label:n(`device.overviewTab.nominal`,`Nominal`),value:lu(r.nominalBitrateKbps??0)}),i(du,{label:n(`device.overviewTab.observed`,`Observed`),value:lu(r.observedBitrateKbps??0)}),i(du,{label:n(`device.overviewTab.peak`,`Peak`),value:lu(r.peakBitrateKbps??0)}),i(du,{label:n(`device.overviewTab.packetLoss`,`Packet Loss`),value:`${(r.packetLossPercent??0).toFixed(2)}%`,warning:(r.packetLossPercent??0)>1})]})]},t))})]}),i(bi,{})]})}function du({label:t,value:n,warning:r}){return e(`div`,{children:[i(`p`,{className:`text-[10px] text-foreground-subtle`,children:t}),i(`p`,{className:`text-xs font-medium ${r?`text-warning`:`text-foreground`}`,children:n})]})}var fu=`history`,pu=[{id:`overview`,labelKey:`helpers.structuralTabs.overview`,cameraOnly:!1,adminOnly:!1},{id:`config`,labelKey:`helpers.structuralTabs.config`,cameraOnly:!1,adminOnly:!1},{id:xi,labelKey:`helpers.structuralTabs.customize`,cameraOnly:!1,adminOnly:!0},{id:fu,labelKey:`helpers.structuralTabs.history`,cameraOnly:!1,adminOnly:!1},{id:`detection-pipeline`,labelKey:`helpers.structuralTabs.detectionPipeline`,cameraOnly:!0,adminOnly:!1},{id:`bindings`,labelKey:`helpers.structuralTabs.bindings`,cameraOnly:!0,adminOnly:!1}],mu=new Set([G.Hub,G.Container]);function hu(e,t){let n=e===G.Camera,r=e===void 0||!mu.has(e);return pu.filter(e=>(n||!e.cameraOnly)&&(t||!e.adminOnly)&&(r||e.id!==`history`)).map(({id:e,labelKey:t})=>({id:e,label:Y.t(t)}))}function gu({provider:e,integrationId:t,name:n}){let r=ui(),a=t===null?`/integrations`:oi(e,t),o=n===null?`Open integrations`:`Open integration ${n}`;return i(`button`,{type:`button`,onClick:()=>r(a),className:`shrink-0 rounded-md transition-opacity hover:opacity-80 focus:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,title:o,"aria-label":o,children:i(pi,{type:e,size:`lg`})})}c();var _u=[{id:`logs`,icon:Ce,labelKey:`common.logs`},{id:`repl`,icon:lt,labelKey:`deviceDetail.repl`},{id:`events`,icon:te,labelKey:`common.events`},{id:`state`,icon:xe,labelKey:`common.state`}];function vu(){let{t:a}=X(),s=de(),c=Ti(),u=Number(c.deviceId),f=Number.isFinite(u),p=ui(),h=l(),g=ye(),_=I(),{user:v}=Ci(),y=v?.isAdmin===!0,[x,S]=Ei(),C=x.get(`tab`)??`overview`,w=x.get(`sub`),[E,D]=o(`logs`),k=`device-detail.left-col-width-px`,[A,j]=o(()=>{if(typeof window>`u`)return null;let e=window.localStorage.getItem(k),t=e?Number(e):NaN;return Number.isFinite(t)&&t>0?t:null}),M=t(A);M.current=A;function ee(e){e.preventDefault();let t=e.clientX,n=e.currentTarget.previousElementSibling?.getBoundingClientRect().width??A??0,r=Math.max(330,Math.floor(window.innerWidth*.7)),i=e=>{j(Math.max(280,Math.min(r,n+(e.clientX-t))))},a=()=>{document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a);let e=M.current;if(e!==null)try{window.localStorage.setItem(k,String(Math.round(e)))}catch{}document.body.style.userSelect=``,document.body.style.cursor=``};document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`,document.addEventListener(`mousemove`,i),document.addEventListener(`mouseup`,a)}let{data:te,isLoading:ne,isError:re}=fr({deviceId:u},{enabled:f,refetchInterval:5e3,retry:1}),{data:P}=$t({deviceId:u},{enabled:f}),ie=n(()=>{let e=P?.settings?.sections??[],t=P?.live?.sections??[],n=[...e,...t],r=new Set;for(let e of n)e.location===`top-tab`&&e.tab&&r.add(e.tab===`zones`?`detection-pipeline`:e.tab);return n.some(li)&&r.add(si),[...r].map(e=>e===`export`?{id:e,label:ci,isAddonContrib:!0}:{id:e,label:Ne[e]?.label??e,isAddonContrib:!0})},[P]),F=te,ae=String(F?.name??c.deviceId??`Device`),oe=F?.online===!0,se=oe?`online`:`offline`,ce=String(F?.addonId??`rtsp`),L=F?.features??[],R=F?.type,z=R===G.Camera,{data:le}=fi(f?u:0),ue=R===G.Container,fe=n(()=>(le??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}})),[le]),B=n(()=>ue?Rn(fe,typeof F?.linkDeviceId==`number`?F.linkDeviceId:null,typeof F?.primaryChildEntityId==`string`?F.primaryChildEntityId:null)?.id??null:null,[ue,fe,F?.linkDeviceId,F?.primaryChildEntityId]),{data:pe}=$t({deviceId:B??0},{enabled:B!==null}),he=n(()=>{if(B===null)return[];let e=pe?.settings?.sections??[],t=pe?.live?.sections??[],n=new Set;for(let r of[...e,...t])r.location===`top-tab`&&r.tab&&n.add(r.tab);return[...n].map(e=>({id:e,label:Ne[e]?.label??e,isAddonContrib:!0,childDeviceId:B}))},[B,pe]),ge=n(()=>Do({sections:[...P?.settings?.sections??[],...P?.live?.sections??[]],deviceId:u,...B===null?{}:{child:{sections:[...pe?.settings?.sections??[],...pe?.live?.sections??[]],deviceId:B}}}),[P,pe,u,B]),_e=typeof F?.parentDeviceId==`number`?F.parentDeviceId:null,{data:ve}=fr({deviceId:_e??0},{enabled:_e!==null}),xe={id:Number.isFinite(u)?u:0,name:ae,type:`unknown`,stableId:``,parentDeviceId:null},V=wn(F??xe,`full`),Ce=wn(ve??xe,`full`),H=It(),we=F?.disabled!==!0,Te=n(()=>{let e=P?.settings?.sections??[],t=P?.live?.sections??[];return ai([...e,...t],R,y,P!==void 0)},[P,R,y]),Ee=n(()=>{let e=new Set,t=[];for(let n of[...hu(R,y),...ie,...he])n.id===`config`&&!Te||e.has(n.id)||(e.add(n.id),t.push(n));return t},[R,y,ie,he,Te]),De=n(()=>Lc(Ee,C),[Ee,C]),Oe=r(e=>{S(t=>{let n=new URLSearchParams(t);e===`overview`?n.delete(`tab`):n.set(`tab`,e),n.delete(`sub`);for(let e of Da)n.delete(e);return n},{replace:!0})},[S]),ke=r(e=>{S(t=>{let n=new URLSearchParams(t);return n.set(`sub`,e),n},{replace:!0})},[S]),U=(le??[]).length>0,Ae=n(()=>_u.filter(({featureGate:e})=>!e||L.includes(e)),[L]),{data:je}=un(void 0),Me=n(()=>F?Vt(F,je):null,[F,je]),W=Me?.kind===`resolved`?Me.integration:null,Pe=W===null?Me?.kind===`unknown`?a(`deviceDetail.loadingIntegration`):Me?.kind===`orphan`?a(`deviceDetail.missingIntegration`):a(`deviceDetail.noIntegration`):W.name,Fe=W!==null&&W.addonId===ce?W.name:ce,Ie=qt({onSuccess:()=>{h.invalidateQueries({queryKey:[[`deviceManager`]]}),p(W?.id?oi(W.addonId,W.id):`/integrations`)}}),Le=Et({onSuccess:()=>{h.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Re=vn({onSuccess:()=>{h.invalidateQueries({queryKey:[[`deviceManager`]]})}}),ze=br(),Be=Ut({onSuccess:()=>{h.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ve=L.includes(Je.Rebootable),He=L.includes(Je.BatteryOperated),Ue=Tn(_.trpcClient,He&&f?u:null),We=Rt(_.trpcClient,f?u:null),Ge=me(_.trpcClient,f?u:null,e=>e.runningState),Ke=Ge===void 0||Ge.running===null?null:Ge.running,qe=er(R??`unknown`,s).icon,[Ye,Xe]=o(!1),Ze=async()=>{if(!Ye){Xe(!0);try{let e=V.replace(/[^a-zA-Z0-9_.-]+/g,`_`),t=new Date().toISOString().replace(/[:.]/g,`-`);await Ua(`${N}/${String(u)}.jpg?force=1`,`${e}-${t}.jpg`)}finally{Xe(!1)}}},Qe=Le.isPending||Re.isPending,{data:$e}=Dr({deviceId:u},{enabled:f&&z,refetchInterval:1e4}),et=$e?.agentNodeId??null,tt=typeof et==`string`&&et.length>0&&!et.startsWith(`addon:`)?et:void 0,{data:nt}=Dn({deviceId:u,...tt?{nodeId:tt}:{}},{enabled:f&&z,refetchInterval:3e3,retry:!1}),{data:rt}=Ur({deviceId:u},{enabled:f&&z,refetchInterval:3e3,retry:!1}),it=rt?.level?.dbfs??null;function at(){if(!f)return null;switch(De){case`overview`:return i(uu,{device:F??{}});case`config`:return i(Hc,{deviceId:u,activeSubTab:w,onSubTabChange:ke,deviceType:R,isAdmin:y});case`detection-pipeline`:return i(El,{deviceId:u,activeSubTab:w,onSubTabChange:ke});case`bindings`:return i(Rc,{deviceId:u});case fu:return i(Zn,{deviceId:u,onNavigate:e=>p(e)});case xi:return i(Nc,{deviceId:u});default:{let e=De,t=ie.some(t=>t.id===e),n=he.find(t=>t.id===e);if(!t&&n===void 0)return null;let r=n?.childDeviceId??u;if(e===`export`)return i(_i,{deviceId:u,sectionFilter:li,activeSubTab:w,onSubTabChange:ke});let a=i(_i,{deviceId:r,sectionFilter:t=>t.location===`top-tab`&&(t.tab===e||e===`detection-pipeline`&&t.tab===`zones`),flattenSubTabs:e===`detection-pipeline`,activeSubTab:w,onSubTabChange:ke});return n!==void 0&&r!==u?i(tr,{deviceId:r,children:a}):a}}}return f?ne?e(`div`,{className:`flex flex-col h-full`,children:[e(`div`,{className:`border-b border-border bg-surface px-6 py-4`,children:[i(`div`,{className:`h-4 w-48 rounded bg-surface-hover animate-pulse mb-3`}),i(`div`,{className:`h-8 w-64 rounded bg-surface-hover animate-pulse`})]}),i(`div`,{className:`flex-1 p-6`,children:i(`div`,{className:`h-40 rounded-lg border border-border bg-surface animate-pulse`})})]}):re||!te?e(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle`,children:[i(`p`,{className:`text-lg font-semibold text-foreground`,children:a(`deviceDetail.deviceNotFound`,`Device not found`)}),i(`p`,{className:`text-xs`,children:i(Si,{i18nKey:`deviceDetail.noDeviceWithId`,values:{id:u},components:{code:i(`code`,{className:`font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]`})}})}),i(`button`,{onClick:()=>p(`/integrations`),className:`mt-2 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:a(`deviceDetail.backToIntegrations`,`Back to Integrations`)})]}):e(`div`,{className:`absolute inset-0 flex flex-col overflow-clip`,children:[e(`div`,{className:`border-b border-border bg-surface px-6 py-3 flex-shrink-0`,children:[i(`div`,{className:`mb-2`,children:i(en,{items:[{label:a(`deviceDetail.integrations`,`Integrations`),onClick:()=>p(`/integrations`)},W===null?{label:Pe}:{label:Pe,onClick:()=>p(oi(W.addonId,W.id))},{label:V}]})}),e(`div`,{className:`flex items-center gap-2 sm:gap-3`,children:[W!==null&&i(gu,{provider:W.addonId,integrationId:W.id,name:W.name}),i(ni,{running:Ke,children:i(qe,{className:`h-5 w-5 text-foreground-subtle shrink-0`,"aria-hidden":!0})}),e(`div`,{className:`min-w-0 flex-1`,children:[e(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[i(`h1`,{className:`text-sm sm:text-base font-semibold text-foreground truncate`,children:V}),i(Wr,{status:se}),He&&i(On,{status:Ue,variant:`full`}),i(hn,{status:We})]}),_e!==null&&ve&&e(`button`,{type:`button`,onClick:()=>p(`/devices/${_e}`),className:`text-[10px] text-foreground-subtle hover:text-primary transition-colors mt-0.5 inline-flex items-center gap-1`,title:a(`deviceDetail.openParentDevice`,`Open parent device {{name}}`,{name:Ce}),children:[i(`span`,{children:`↑`}),i(`span`,{className:`truncate`,children:Ce})]}),i(`div`,{className:`hidden md:flex items-center gap-3 mt-0.5 text-[10px] text-foreground-subtle`,children:L.length>0&&i(mi,{capabilities:L})})]}),nt&&i(`div`,{className:`hidden lg:flex`,children:i(yu,{metrics:nt,dbfs:it})}),e(`div`,{className:`flex items-center gap-1 shrink-0`,children:[e(`button`,{onClick:async()=>{we?await g({title:a(`deviceDetail.disable`,`Disable "{{name}}"?`,{name:V}),message:a(`deviceDetail.theDeviceWillStopProcessing`,`The device will stop processing streams and events. You can re-enable it later.`),confirmLabel:a(`common.disable`,`Disable`),variant:`danger`})&&Re.mutate({deviceId:u}):Le.mutate({deviceId:u})},disabled:Qe,title:we?a(`deviceDetail.disableDevice`,`Disable device`):a(`deviceDetail.enableDevice`,`Enable device`),className:`inline-flex items-center gap-1.5 rounded-lg px-2 sm:px-2.5 py-1.5 text-[11px] font-medium border transition-colors disabled:opacity-50 ${we?`border-success/30 text-success hover:bg-success/10`:`border-border text-foreground-subtle/50 hover:text-foreground hover:bg-surface-hover`}`,children:[i(T,{className:`h-3.5 w-3.5`}),i(`span`,{className:`hidden sm:inline`,children:Qe?a(`deviceDetail.updating`,`Updating…`):we?a(`deviceDetail.enabled`,`Enabled`):a(`deviceDetail.disabled`,`Disabled`)})]}),i(`div`,{className:`hidden sm:block h-5 w-px bg-border mx-1`}),z&&e(d,{children:[i(Xa,{deviceId:u}),i(`div`,{className:`hidden sm:block h-5 w-px bg-border mx-1`})]}),i(Qa,{deviceId:u}),i(Zr,{triggerClassName:`ml-1`,items:[{id:`snapshot`,label:a(`deviceDetail.takeSnapshot`,`Take snapshot`),description:a(`deviceDetail.fetchAFreshFrameAnd`,`Fetch a fresh frame and download it.`),icon:O,disabled:Ye,onClick:()=>{Ze()}},{id:`reboot`,label:a(`deviceDetail.rebootDevice`,`Reboot device`),description:a(`deviceDetail.cameraGoesOfflineFor30`,`Camera goes offline for ~30 seconds.`),icon:Se,hidden:!Ve,disabled:ze.isPending,danger:!0,onClick:async()=>{await g({title:a(`deviceDetail.reboot`,`Reboot "{{name}}"?`,{name:V}),message:a(`deviceDetail.theCameraWillGoOffline`,`The camera will go offline for around 30 seconds while the firmware reboots.`),confirmLabel:a(`deviceDetail.reboot2`,`Reboot`),variant:`danger`})&&ze.mutate({deviceId:u})}},{id:`restart-addon`,label:a(`deviceDetail.restartAddon`,`Restart addon`),description:a(`deviceDetail.bouncesEveryDeviceServedBy`,`Bounces every device served by {{servingAddonLabel}}.`,{servingAddonLabel:Fe}),icon:m,disabled:Be.isPending,danger:!0,onClick:async()=>{await g({title:a(`deviceDetail.restart`,`Restart "{{servingAddonLabel}}"?`,{servingAddonLabel:Fe}),message:a(`deviceDetail.restartingTheAddonWillBriefly`,`Restarting the addon will briefly disconnect every device served by it (not just "{{name}}"). Streams will reconnect automatically.`,{name:V}),confirmLabel:a(`deviceDetail.restart2`,`Restart`),variant:`danger`})&&Be.mutate({addonId:ce})}},{id:`delete`,label:a(`deviceDetail.deleteDevice`,`Delete device`),description:a(`deviceDetail.removeTheDeviceAndAll`,`Remove the device and all its settings.`),icon:b,separatorBefore:!0,disabled:Ie.isPending,danger:!0,onClick:async()=>{await g({title:a(`deviceDetail.delete`,`Delete "{{name}}"?`,{name:V}),message:a(`deviceDetail.thisWillRemoveTheDevice`,`This will remove the device and all its settings. This action cannot be undone.`),confirmLabel:a(`common.delete`,`Delete`),variant:`danger`})&&Ie.mutate({deviceId:u})}}]})]})]})]}),i(tr,{deviceId:u,device:F??void 0,children:i(hr,{children:i(At,{children:i(be,{children:i(Kn,{children:e(`main`,{className:H?`flex-1 overflow-y-auto flex flex-col`:`flex-1 min-h-0 overflow-hidden flex flex-row`,children:[e(`div`,{className:H?`flex flex-col bg-surface`:`${A===null?`w-1/2 lg:w-1/3`:``} flex-shrink-0 flex flex-col bg-surface min-h-0 overflow-y-auto`,style:!H&&A!==null?{width:`${String(A)}px`}:void 0,children:[i(`div`,{className:z?`flex-shrink-0 border-b border-border-subtle bg-black`:H?`flex-shrink-0 border-b border-border-subtle bg-surface`:`shrink-0 border-b border-border-subtle bg-surface`,children:z?i(Lo,{deviceId:u,intercomAvailable:L.includes(Je.TwoWayAudio)}):e(`div`,{children:[i(wo,{deviceId:u,deviceName:V,deviceType:R??`unknown`,provider:ce,isOnline:oe,features:L}),i(To,{deviceId:u,widgets:ge})]})}),z&&ge.length>0&&i(`div`,{className:`flex-shrink-0 border-b border-border-subtle bg-surface pt-3 sm:pt-4`,children:i(To,{deviceId:u,widgets:ge})}),e(`div`,{className:H?`flex flex-col border-b border-border`:`flex-1 min-h-64 flex flex-col overflow-hidden`,children:[i(`div`,{className:`flex-shrink-0 border-b border-border-subtle px-2 py-1.5`,children:i(`div`,{className:`flex gap-1 overflow-x-auto -mx-1 px-1 pb-0.5`,children:Ae.map(({id:t,labelKey:n,icon:r})=>{let o=E===t;return e(`button`,{onClick:()=>D(t),title:a(n),className:`flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium transition-colors flex-shrink-0 ${o?`bg-primary/15 text-primary`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[i(r,{className:`h-3 w-3`}),a(n)]},t)})})}),e(`div`,{className:H?`h-72 overflow-hidden`:`flex-1 min-h-0 overflow-hidden`,children:[E===`logs`&&i(Ro,{deviceId:u,containerDeviceId:R===`container`?u:void 0}),E===`repl`&&i(zo,{deviceId:u}),E===`events`&&i(Bo,{deviceId:u}),E===`state`&&i(Vo,{deviceId:u})]})]})]}),!H&&i(`div`,{role:`separator`,"aria-orientation":`vertical`,title:a(`deviceDetail.dragToResize`,`Drag to resize`),onMouseDown:ee,className:`flex-shrink-0 w-1 cursor-col-resize bg-border hover:bg-primary/40 transition-colors group relative z-10`,children:i(`span`,{className:`absolute inset-y-0 -left-1 -right-1`})}),e(`div`,{className:H?`flex flex-1 flex-col`:`flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden`,children:[i(`div`,{className:`flex-shrink-0 border-b border-border bg-surface px-4`,children:i(`div`,{className:`flex flex-nowrap overflow-x-auto md:flex-wrap md:overflow-x-visible items-center gap-0`,children:Ee.map(t=>{let n=De===t.id;return e(`button`,{onClick:()=>Oe(t.id),className:`relative flex-shrink-0 px-3 py-2 text-xs font-medium transition-colors ${n?`text-primary`:`text-foreground-subtle hover:text-foreground`}`,children:[t.label,n&&i(`span`,{className:`absolute bottom-0 left-0 right-0 h-0.5 rounded-full bg-primary`})]},t.id)})})}),e(`div`,{className:H?`p-3 flex flex-1 flex-col gap-3`:`flex-1 min-h-0 overflow-y-auto p-4 flex flex-col gap-3`,children:[De===`overview`&&U&&i($a,{parentDeviceId:u}),at()]})]})]})})})})})})]}):e(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle`,children:[i(`p`,{className:`text-lg font-semibold text-foreground`,children:a(`deviceDetail.invalidDeviceId`,`Invalid device id`)}),i(`p`,{className:`text-xs`,children:i(Si,{i18nKey:`deviceDetail.invalidSegment`,values:{segment:c.deviceId},components:{code:i(`code`,{className:`font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]`})}})}),i(`button`,{onClick:()=>p(`/integrations`),className:`mt-2 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:a(`deviceDetail.backToIntegrations`,`Back to Integrations`)})]})}function yu({metrics:t,dbfs:n}){let r=de(),{t:a}=X(),o=or(t.phase??`idle`,r);return e(`div`,{className:`flex items-center gap-3 flex-shrink-0`,children:[e(`div`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`h-1.5 w-1.5 rounded-full ${o.dotClass}`}),i(`span`,{className:`text-[10px] font-medium ${o.textColor}`,children:o.label})]}),i(`div`,{className:`h-3 w-px bg-border`}),e(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[i(ae,{className:`h-3 w-3`}),i(`span`,{className:`text-foreground tabular-nums`,children:(t.actualFps??0).toFixed(1)}),i(`span`,{children:a(`common.fpsWord`)})]}),e(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[i(ge,{className:`h-3 w-3`}),i(`span`,{className:`text-foreground tabular-nums`,children:(t.avgInferenceTimeMs??0).toFixed(0)}),i(`span`,{children:`ms`})]}),e(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,title:a(`deviceDetail.currentAudioLevelDbfs`,`Current audio level (dBFS)`),children:[i(D,{className:`h-3 w-3`}),i(`span`,{className:`text-foreground tabular-nums`,children:n==null?`—`:n.toFixed(0)}),i(`span`,{children:`dB`})]}),(t.queueDepth??0)>0&&e(`span`,{className:`text-[10px] text-warning tabular-nums`,children:[`q:`,t.queueDepth]})]})}export{vu as DeviceDetailPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,K as t,S as n,et as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{cn as i,dn as a,fn as o,hn as s,ln as c,mn as l,pn as u,un as d}from"./client-
|
|
1
|
+
import{C as e,K as t,S as n,et as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{cn as i,dn as a,fn as o,hn as s,ln as c,mn as l,pn as u,un as d}from"./client-DcvpIFoh.js";import{U as f}from"./src-XEHc18wE.js";import{t as p}from"./i18n-C-H4BlYV.js";import{t as m}from"./useTranslation-BJr-n0es.js";import"./index-o6kBNilE.js";import{n as h,t as g}from"./use-device-bound-caps-CI6zlnII.js";r();var _=`mt-1 w-full rounded border border-border bg-background px-2 py-1 text-xs`,v=`block text-[11px] font-medium text-foreground`,y=`deviceId`;function b(e,t){return t.length===0?0:t.length===1?t[0]:t.find(t=>!e.includes(t))??t[t.length-1]}function x(e,t,n){if(t.length===0)return[];if(t.length===1)return t;let r=t.find(t=>!e.includes(t));if(r===void 0)return t;let i=n(r);if(i===void 0)return[r];let a=e[0]??t.find(e=>e!==r);if(a===void 0)return[r];let o=n(a);return o===void 0||!s(o,i)?[r]:t.filter(e=>{let t=n(e);return t!==void 0&&s(o,t)})}function S(e){return e.length===0?0:e.length===1?e[0]:[...e]}function C(e){return typeof e==`number`?e>0?[e]:[]:Array.isArray(e)?e.filter(e=>e>0):[]}function w(e,t){return{deviceId:e,cap:t.cap,method:t.method,...t.args===void 0?{}:{args:{...t.args}}}}function T(e,t){return p.t(`deviceDoAction.customLabel`,{name:`${e}.${t}`})}function E({value:r,onChange:p,devices:E,listState:D,fleet:O,allowTriggerDevice:k=!1,allowMultiSameFamily:A=!1,testId:j=`device-do-action`}){let{t:M}=m(),N=typeof r.deviceId!=`number`&&!Array.isArray(r.deviceId),P=C(r.deviceId),F=t(()=>E.filter(e=>u(String(e.type??``))),[E]),I=t(()=>{let e=new Map;for(let t of F)t.type!==void 0&&t.type!==null&&e.set(t.id,String(t.type));return e},[F]),L=t(()=>{if(!A||P.length===0)return F;let e=I.get(P[0]);return e===void 0?F:F.filter(t=>{if(P.includes(t.id))return!0;let n=t.type!==void 0&&t.type!==null?String(t.type):void 0;return n!==void 0&&s(e,n)})},[A,P,F,I]),R=g(!A&&P.length===1?P[0]:0),z=h(A?P:[]),B=t(()=>N?a():P.length===0?[]:A?z.isLoading&&z.data===void 0?[]:d(P.map(e=>({boundCaps:z.data?.get(e),deviceType:I.get(e)}))):R.data===void 0&&R.isLoading?[]:c({boundCaps:R.data,deviceType:I.get(P[0])}),[N,P,A,z.data,z.isLoading,R.data,R.isLoading,I]),V=o(r.cap,r.method,r.args),H=l(r.cap,r.method,r.args),U=r.cap!==``&&r.method!==``&&H===null&&(N||P.length>0),W=A?z.isLoading:R.isLoading,G=A?z.isError:R.isError,K=e=>{if(e.startsWith(`custom:`))return;let t=i.find(t=>t.id===e);t!==void 0&&p(w(N?r.deviceId:P.length>0?S(P):F[0]?.id??0,t))};return e(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,"data-testid":j,children:[k&&e(`div`,{className:`w-full max-w-xs`,children:[n(`label`,{className:v,children:M(`deviceDoAction.deviceDoActionFields.target`,`Target`)}),e(`select`,{className:_,"data-testid":`${j}-target`,value:N?`trigger`:`device`,onChange:e=>{if(e.target.value===`trigger`){p({deviceId:{$var:y},cap:``,method:``});return}p({deviceId:F[0]?.id??0,cap:``,method:``})},children:[n(`option`,{value:`device`,children:M(`deviceDoAction.deviceDoActionFields.specificDevice`,`Specific device`)}),n(`option`,{value:`trigger`,children:M(`deviceDoAction.deviceDoActionFields.theDeviceThatTriggeredThis`,`The device that triggered this run`)})]})]}),!N&&e(`div`,{"data-testid":`${j}-device`,children:[n(`label`,{className:v,children:M(`deviceDoAction.deviceLabel`,{count:A?2:1})}),n(f,{devices:L,listState:D,...O===void 0?{}:{fleet:O},value:[...P],onChange:e=>{p({deviceId:S(A?x(P,e,e=>I.get(e)):(()=>{let t=b(P,e);return t>0?[t]:[]})()),cap:``,method:``})},emptyLabel:A?`No devices selected`:`No device selected`,noun:`device`,testId:`${j}-device-picker`}),A&&P.length>1&&n(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:M(`deviceDoAction.deviceDoActionFields.sameFamilyOnlyTheAction`,`Same family only — the action runs on each selected device.`)})]}),e(`div`,{className:`w-full max-w-sm`,children:[n(`label`,{className:v,children:M(`deviceDoAction.deviceDoActionFields.action`,`Action`)}),e(`select`,{className:_,"data-testid":`${j}-action`,value:V===`custom:${r.cap}.${r.method}`?V:H?.id??``,disabled:!N&&(P.length===0||W),onChange:e=>K(e.target.value),children:[n(`option`,{value:``,children:!N&&P.length===0?M(`deviceDoAction.deviceDoActionFields.pickADeviceFirst`,`Pick a device first`):W?M(`deviceDoAction.deviceDoActionFields.loadingActions`,`Loading actions…`):B.length===0?M(`deviceDoAction.deviceDoActionFields.noActionsForThisDevice`,`No actions for this device`):M(`deviceDoAction.deviceDoActionFields.selectAnAction`,`Select an action…`)}),U&&n(`option`,{value:V,children:T(r.cap,r.method)}),B.map(e=>n(`option`,{value:e.id,children:e.label},e.id))]}),G&&n(`p`,{className:`mt-1 text-[11px] text-warning`,children:M(`deviceDoAction.deviceDoActionFields.couldNotReadThisDevice`,`Could not read this device’s capabilities.`)})]}),H?.openArgs!==void 0&&H.openArgs.length>0&&n(`div`,{className:`flex flex-col gap-2`,children:H.openArgs.map(t=>{let i=r.args?.[t.key],a=typeof i==`string`||typeof i==`number`?String(i):``;return e(`div`,{className:`w-full max-w-sm`,children:[n(`label`,{className:v,htmlFor:`${j}-${t.key}`,children:t.label}),n(`input`,{id:`${j}-${t.key}`,className:_,"data-testid":`${j}-${t.key}`,type:t.kind===`number`?`number`:`text`,value:a,onChange:e=>{let n=e.target.value,i=r.args===void 0?{}:{...r.args};if(n===``)delete i[t.key];else if(t.kind===`number`){let e=Number(n);Number.isNaN(e)?delete i[t.key]:i[t.key]=e}else i[t.key]=n;p(Object.keys(i).length>0?{...r,args:i}:{deviceId:r.deviceId,cap:r.cap,method:r.method})}})]},t.key)})})]})}export{E as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,K as t,R as n,S as r,et as i,o as a}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Pi as o,dt as s,zt as c}from"./player-overlays-
|
|
1
|
+
import{C as e,K as t,R as n,S as r,et as i,o as a}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Pi as o,dt as s,zt as c}from"./player-overlays-oTS1TZZY.js";import{Do as l,Fo as u,Ft as d,Ko as f,Ps as p,Pt as m,So as h,r as g}from"./src-XEHc18wE.js";import{t as _}from"./useTranslation-BJr-n0es.js";import{_r as v,dr as y}from"./index-o6kBNilE.js";import{t as b}from"./AdminPage-B1Q3Lunl.js";import"./useEventInvalidation-BvJkcx-a.js";import{t as x}from"./device-integration-icon-DCuiIOlj.js";i();var S=32;function C(e,t){let n=e=>t(e).kind===`orphan`,r=new Set;for(let t of e)n(t)&&r.add(t.id);let i=new Map;for(let t of e)i.set(t.id,t);let a=(e,t=0)=>{if(t>S)return!1;if(r.has(e.id))return!0;if(e.parentDeviceId==null)return!1;let n=i.get(e.parentDeviceId);return n?a(n,t+1):!1},o=[],s=[];for(let t of e)a(t)?s.push(t):o.push(t);return{activeDevices:o,orphanDevices:s}}function w(){let{t:i}=_(),S=v(),w=s(),T=a();g([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]),g([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`]);let{data:E}=u({projection:`slim`}),{data:D}=p(void 0),O=f({onSuccess:()=>{T.invalidateQueries({queryKey:[[`deviceManager`]]})}}),k=h({onSuccess:()=>{T.invalidateQueries({queryKey:[[`deviceManager`]]})}}),A=l({onSuccess:()=>{T.invalidateQueries({queryKey:[[`deviceManager`]]})}}),j=t(()=>E??[],[E]),M=t(()=>d(D),[D]),{activeDevices:N,orphanDevices:P}=t(()=>C(j,M),[j,M]),F=t(()=>{let e=new Map;for(let t of j)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[j]),I=n(e=>F.get(e)??null,[F]),L=t(()=>(D??[]).map(e=>({id:e.id,name:e.name??e.addonId,icon:r(y,{type:e.addonId,size:`sm`})})),[D]),R=n(e=>S(`/devices/${String(e)}`),[S]);return e(b,{icon:o,title:i(`nav.devices`,`Devices`),children:[r(m,{context:`devices`,devices:N,trpc:w.trpcClient,filters:{integrations:L},integrationOf:M,resolveIntegrationIcon:x,resolveParent:I,onNavigate:R,batchActions:{remove:O.mutate,disable:k.mutate,enable:A.mutate}}),P.length>0&&e(`div`,{className:`mt-6 space-y-2`,children:[e(`div`,{className:`flex items-baseline gap-2`,children:[r(c,{className:`h-3.5 w-3.5 text-warning shrink-0`}),r(`h2`,{className:`text-sm font-semibold text-foreground`,children:i(`devices.orphanDevices`,`Orphan devices`)}),r(`span`,{className:`text-[10px] text-foreground-subtle`,children:i(`common.deviceOrphans`,{count:P.length})})]}),e(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 p-2`,children:[r(`p`,{className:`text-[11px] text-foreground-subtle px-2 pb-2`,children:i(`devices.theseDevicesReferenceAnIntegration`,"These devices reference an integration that is no longer registered (their `integrationId`, or — for older devices without one — their `addonId`). Delete them, or re-install the missing integration to bring them back online. The provider badge beside each row is the addon that serves it.")}),r(m,{context:`devices`,devices:P,trpc:w.trpcClient,integrationOf:M,urlScope:`nested`,lsKey:`devices:orphan`,resolveIntegrationIcon:x,resolveParent:I,onNavigate:R})]})]})]})}export{w as DevicesPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,K as t,S as n,V as r,Y as i,d as a,et as o,u as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{lt as c}from"./player-overlays-
|
|
1
|
+
import{C as e,K as t,S as n,V as r,Y as i,d as a,et as o,u as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{lt as c}from"./player-overlays-oTS1TZZY.js";import{Co as l}from"./client-DcvpIFoh.js";import{D as u,F as d,N as f,O as p,T as m,y as h}from"./__vite-browser-external-BCAtXlNQ.js";import{En as g,Mn as _,mn as v,of as y,un as b}from"./src-XEHc18wE.js";import{t as x}from"./useTranslation-BJr-n0es.js";o();var S=d([p({kind:m(`adaptive`)}),p({kind:m(`profile`),profile:l})]),C=p({serverUrl:f().min(1),token:f().min(1),deviceId:u().int().nonnegative(),target:S,muted:h()});function w(e,t){let n=t===void 0?{type:`state`,state:e}:{type:`state`,state:e,message:t};window.ReactNativeWebView?.postMessage(JSON.stringify(n))}function T(e){switch(e){case`playing`:return`playing`;case`error`:return`error`;case`connecting`:case`disconnected`:case`idle`:return`connecting`}}function E(e){return e.kind===`adaptive`?{kind:`adaptive`}:{kind:`profile`,profile:e.profile}}function D(e){return e.kind===`adaptive`?`embed:adaptive`:`embed:profile:${e.profile}`}function O(){let e=window.__CAMSTACK_EMBED__;if(e==null)return{ok:!1,error:`window.__CAMSTACK_EMBED__ is not set`};let t=C.safeParse(e);return t.success?{ok:!0,config:t.data}:{ok:!1,error:t.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `)}}function k({message:t}){let{t:n}=x();return r(()=>{w(`error`,t)},[t]),e(`div`,{style:{position:`fixed`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,background:`#000`,color:`#f87171`,fontFamily:`system-ui, sans-serif`,fontSize:13,padding:16,textAlign:`center`},children:[n(`embedPlayerPage.embedConfigError`,`Embed config error:`),` `,t]})}function A({system:e,deviceId:a,initialTarget:o,initialMuted:s}){let[c,l]=i(o),[u,d]=i(s),{handleOffer:f,getIceServers:p,addIceCandidate:m,getIceCandidates:h,closeSession:v,getSessionState:y,getSessionDebug:b,applyDownlinkProbe:x}=g(e.trpcClient,a),C=t(()=>E(c),[c]),O=t(()=>(e,t)=>f(C,e,t),[f,C]),k=t(()=>(e,t,n)=>f(n,t,e),[f]);r(()=>(window.__camstackEmbed={setMuted:e=>d(e),setTarget:e=>{let t=S.safeParse(e);t.success&&l(t.data)}},()=>{window.__camstackEmbed&&delete window.__camstackEmbed}),[]);let A=D(c);return n(`div`,{style:{position:`fixed`,inset:0,width:`100vw`,height:`100vh`,background:`#000`},children:n(_,{serverUrl:e.serverUrl,streamKey:A,autoPlay:!0,muted:u,showControls:!1,className:`w-full h-full`,getSessionDebug:b,applyDownlinkProbe:x,handleOffer:O,reoffer:k,getSessionState:y,getIceServers:p,addIceCandidate:m,getIceCandidates:h,closeSession:v,onStateChange:e=>w(T(e)),onError:e=>w(`error`,e)},A)})}function j(){let{t:e}=x(),i=t(()=>O(),[]),o=t(()=>{if(!i.ok)return null;let e=v({serverUrl:i.config.serverUrl,token:i.config.token}),t=new a({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1}}});return b(t),{system:e,queryClient:t}},[i]);return r(()=>{if(o)return()=>{o.system.close()}},[o]),i.ok?o?n(c,{system:o.system,children:n(s,{client:o.queryClient,children:n(y.Provider,{client:o.system.trpcClient,queryClient:o.queryClient,children:n(A,{system:o.system,deviceId:i.config.deviceId,initialTarget:i.config.target,initialMuted:i.config.muted})})})}):n(k,{message:e(`embedPlayerPage.failedToInitialiseTheEmbed`,`Failed to initialise the embed player`)}):n(k,{message:i.error})}export{j as EmbedPlayerPage};
|